Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Add qualifiedName for GlossaryEntry DTO
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Jun 7, 2016
1 parent 5ce2924 commit 495858b
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public class GlossaryFileUploadForm implements Serializable {
@PartType("text/plain")
private String fileName;

@FormParam("qualifiedName")
@PartType("text/plain")
private String qualifiedName;


public InputStream getFileStream() {
return fileStream;
Expand Down Expand Up @@ -83,4 +87,12 @@ public String getFileName() {
public void setFileName(String fileName) {
this.fileName = fileName;
}

public String getQualifiedName() {
return qualifiedName;
}

public void setQualifiedName(String qualifiedName) {
this.qualifiedName = qualifiedName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
**/
@XmlRootElement(name = "glossaryEntry")
@XmlType(name = "glossaryEntryType", propOrder = { "id", "pos",
"description", "sourceReference", "glossaryTerms", "termsCount" })
@JsonPropertyOrder({ "id", "pos", "description", "srcLang", "sourceReference", "glossaryTerms", "termsCount" })
"description", "sourceReference", "glossaryTerms", "termsCount", "qualifiedName" })
@JsonPropertyOrder({ "id", "pos", "description", "srcLang", "sourceReference", "glossaryTerms", "termsCount", "qualifiedName" })
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public class GlossaryEntry implements Serializable, HasMediaType {
/**
Expand All @@ -66,6 +66,8 @@ public class GlossaryEntry implements Serializable, HasMediaType {

private String sourceReference;

private String qualifiedName;

private int termsCount = 0;

public GlossaryEntry() {
Expand Down Expand Up @@ -151,6 +153,16 @@ public void setSourceReference(String ref) {
this.sourceReference = ref;
}

@XmlElement(name = "qualified-name", namespace = Namespaces.ZANATA_API)
@JsonProperty("qualified-name")
public String getQualifiedName() {
return qualifiedName;
}

public void setQualifiedName(String qualifiedName) {
this.qualifiedName = qualifiedName;
}

@Override
public String toString() {
return DTOUtil.toXML(this);
Expand All @@ -176,8 +188,10 @@ public boolean equals(Object o) {
if (srcLang != null ? !srcLang.equals(that.srcLang) :
that.srcLang != null)
return false;
return qualifiedName != null ?
qualifiedName.equals(that.qualifiedName) :
that.qualifiedName == null;

return true;
}

@Override
Expand All @@ -192,6 +206,9 @@ public int hashCode() {
result = 31 * result + (srcLang != null ? srcLang.hashCode() : 0);
result = 31 * result +
(sourceReference != null ? sourceReference.hashCode() : 0);
result =
31 * result +
(qualifiedName != null ? qualifiedName.hashCode() : 0);
result = 31 * result + termsCount;
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,52 @@ public interface GlossaryResource extends RestResource {
*/
public static final int MAX_PAGE_SIZE = 1000;

/**
* Qualified name for Global/default glossary
*/
public static final String GLOBAL_QUALIFIED_NAME = "global/default";

/**
* Return list of global glossary qualifiedName
*
* @return The following response status codes will be returned from this
* operation:<br>
* OK(200) - Response containing all Glossary entries in the system.
* INTERNAL SERVER ERROR(500) - If there is an unexpected error in
* the server while performing this operation.
*/
@GET
@Path("/qualifiedName")
@Produces({ MediaTypes.APPLICATION_ZANATA_GLOSSARY_JSON,
MediaType.APPLICATION_JSON })
@TypeHint(List.class)
public Response getGlobalQualifiedName();

/**
* Return list of project glossary qualifiedName
*
* @param projectSlug
* identifier for project
*
* @return The following response status codes will be returned from this
* operation:<br>
* OK(200) - Response containing all Glossary entries in the system.
* INTERNAL SERVER ERROR(500) - If there is an unexpected error in
* the server while performing this operation.
*/
@GET
@Path("/project/qualifiedName")
@Produces({ MediaTypes.APPLICATION_ZANATA_GLOSSARY_JSON,
MediaType.APPLICATION_JSON })
@TypeHint(List.class)
public Response getProjectQualifiedName(String projectSlug);

/**
* Return source locales available for all glossary entries
*
* @param qualifiedName
* Qualified name of glossary, default to {@link #GLOBAL_QUALIFIED_NAME}
*
* @return The following response status codes will be returned from this
* operation:<br>
* OK(200) - Response containing all Glossary entries in the system.
Expand All @@ -82,7 +125,8 @@ public interface GlossaryResource extends RestResource {
MediaTypes.APPLICATION_ZANATA_GLOSSARY_JSON,
MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@TypeHint(GlossaryInfo.class)
public Response getInfo();
public Response getInfo(
@DefaultValue(GLOBAL_QUALIFIED_NAME) @QueryParam("qualifiedName") String qualifiedName);

/**
* Returns Glossary entries for the given source and translation locale with
Expand All @@ -102,6 +146,8 @@ public interface GlossaryResource extends RestResource {
* @param fields
* Fields to sort. Comma separated. e.g sort=desc,-part_of_speech
* See {@link org.zanata.common.GlossarySortField}
* @param qualifiedName
* Qualified name of glossary, default to {@link #GLOBAL_QUALIFIED_NAME}
* @return The following response status codes will be returned from this
* operation:<br>
* OK(200) - Response containing all Glossary entries for the given
Expand All @@ -121,20 +167,24 @@ public Response getEntries(
@DefaultValue("1") @QueryParam("page") int page,
@DefaultValue("1000") @QueryParam("sizePerPage") int sizePerPage,
@QueryParam("filter") String filter,
@QueryParam("sort") String fields);
@QueryParam("sort") String fields,
@DefaultValue(GLOBAL_QUALIFIED_NAME) @QueryParam("qualifiedName") String qualifiedName);

/**
* Download all glossary entries as file
*
* @param fileType - po or cvs (case insensitive). Default - csv
* @param locales - optional comma separated list of languages required.
* @param qualifiedName
* Qualified name of glossary, default to {@link #GLOBAL_QUALIFIED_NAME}
*/
@GET
@Path("/file")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response downloadFile(
@DefaultValue("csv") @QueryParam("fileType") String fileType,
@QueryParam("locales") String locales);
@QueryParam("locales") String locales,
@DefaultValue(GLOBAL_QUALIFIED_NAME) @QueryParam("qualifiedName") String qualifiedName);

/**
* Create or update glossary entry
Expand Down Expand Up @@ -198,6 +248,9 @@ public Response downloadFile(
/**
* Delete all glossary terms.
*
* @param qualifiedName
* Qualified name of glossary, default to {@link #GLOBAL_QUALIFIED_NAME}
*
* @return The following response status codes will be returned from this
* operation:<br>
* OK(200) - If the glossary entries were successfully deleted.
Expand All @@ -207,6 +260,7 @@ public Response downloadFile(
* the server while performing this operation.
*/
@DELETE
public Response deleteAllEntries();
public Response deleteAllEntries(
@DefaultValue(GLOBAL_QUALIFIED_NAME) @QueryParam("qualifiedName") String qualifiedName);

}

0 comments on commit 495858b

Please sign in to comment.