This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit cf38c8d9b10d0ffce7853b414efd46dcb7e9fd40 Author: Yannick Martel <martel@©odelutin.com> Date: Wed Nov 26 10:17:13 2014 +0100 #6140 add new metadata in document entity --- .../src/main/xmi/coselmar-model.properties | 5 +- .../src/main/xmi/coselmar-model.zargo | Bin 6029 -> 6487 bytes .../fr/ifremer/coselmar/beans/DocumentBean.java | 127 ++++++++++++++++++++- .../coselmar/converter/BeanEntityConverter.java | 30 ++++- 4 files changed, 155 insertions(+), 7 deletions(-) diff --git a/coselmar-persistence/src/main/xmi/coselmar-model.properties b/coselmar-persistence/src/main/xmi/coselmar-model.properties index a91b2b0..1835e8e 100644 --- a/coselmar-persistence/src/main/xmi/coselmar-model.properties +++ b/coselmar-persistence/src/main/xmi/coselmar-model.properties @@ -24,4 +24,7 @@ model.tagvalue.version=1.0 package.fr.ifremer.coselmar.persistence.entity.stereotype=entity -model.tagvalue.useEnumerationName=true \ No newline at end of file +model.tagvalue.useEnumerationName=true + +# Text +fr.ifremer.coselmar.persistence.entity.Document.attribute.summary.tagValue.hibernateAttributeType=text \ No newline at end of file diff --git a/coselmar-persistence/src/main/xmi/coselmar-model.zargo b/coselmar-persistence/src/main/xmi/coselmar-model.zargo index 11e04de..b07f229 100644 Binary files a/coselmar-persistence/src/main/xmi/coselmar-model.zargo and b/coselmar-persistence/src/main/xmi/coselmar-model.zargo differ diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/DocumentBean.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/DocumentBean.java index 85445e4..93528a0 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/DocumentBean.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/DocumentBean.java @@ -35,22 +35,59 @@ import java.util.Set; */ public class DocumentBean implements Serializable { + // Standard Data protected String id; protected String name; protected String ownerName; protected String privacy; protected Set<String> keywords; protected Date depositDate; + protected String authors; + protected String license; + protected String copyright; + protected String type; + protected String language; + protected String summary; + protected Date publicationDate; + + // Document could be internal file or external link + protected boolean isFile; protected String mimeType; + protected String externalUrl; - public DocumentBean(String id, String name, String ownerName, String privacy, Date depositDate, Collection<String> keywords, String mimeType) { + public DocumentBean(String id, String name, String ownerName, String privacy, + Date depositDate, Collection<String> keywords, + String type, String summary, String language, Date publicationDate, + String authors, String license, String copyright, + boolean isFile, String mimeType, String externalUrl) { this.id = id; this.name = name; this.ownerName = ownerName; this.privacy = privacy; - this.depositDate = depositDate; + if (depositDate != null) { + this.depositDate = new Date(depositDate.getTime()); + } this.keywords = new HashSet<>(keywords); this.mimeType = mimeType; + + this.type = type; + this.summary = summary; + this.language = language; + if (publicationDate != null) { + this.publicationDate = new Date(publicationDate.getTime()); + } + + this.authors = authors; + this.license = license; + this.copyright = copyright; + + if (isFile) { + this.isFile = true; + this.mimeType = mimeType; + } else { + this.isFile = false; + this.externalUrl = externalUrl; + } } public String getId() { @@ -90,7 +127,9 @@ public class DocumentBean implements Serializable { } public void setDepositDate(Date depositDate) { - this.depositDate = depositDate; + if (depositDate != null) { + this.depositDate = new Date(depositDate.getTime()); + } } public Set<String> getKeywords() { @@ -107,4 +146,86 @@ public class DocumentBean implements Serializable { } this.keywords.addAll(keywords); } + + public String getAuthors() { + return authors; + } + + public void setAuthors(String authors) { + this.authors = authors; + } + + public String getLicense() { + return license; + } + + public void setLicense(String license) { + this.license = license; + } + + public String getCopyright() { + return copyright; + } + + public void setCopyright(String copyright) { + this.copyright = copyright; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getLanguage() { + return language; + } + + public void setLanguage(String language) { + this.language = language; + } + + public String getSummary() { + return summary; + } + + public void setSummary(String summary) { + this.summary = summary; + } + + public Date getPublicationDate() { + return publicationDate; + } + + public void setPublicationDate(Date publicationDate) { + if (publicationDate != null) { + this.publicationDate = new Date(publicationDate.getTime()); + } + } + + public boolean isFile() { + return isFile; + } + + public void setFile(boolean isFile) { + this.isFile = isFile; + } + + public String getExternalUrl() { + return externalUrl; + } + + public void setExternalUrl(String externalUrl) { + this.externalUrl = externalUrl; + } + + public String getMimeType() { + return mimeType; + } + + public void setMimeType(String mimeType) { + this.mimeType = mimeType; + } } diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/converter/BeanEntityConverter.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/converter/BeanEntityConverter.java index f024037..26ea92a 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/converter/BeanEntityConverter.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/converter/BeanEntityConverter.java @@ -30,6 +30,7 @@ import fr.ifremer.coselmar.beans.DocumentBean; import fr.ifremer.coselmar.beans.UserBean; import fr.ifremer.coselmar.persistence.entity.CoselmarUser; import fr.ifremer.coselmar.persistence.entity.Document; +import org.apache.commons.lang3.StringUtils; /** * @author ymartel <martel@codelutin.com> @@ -38,14 +39,37 @@ public class BeanEntityConverter { public static DocumentBean toBean(Document document) { String documentLightId = document.getTopiaId().replace(Document.class.getCanonicalName() + "_", ""); - Date depositeDate = new Date(document.getDepositDate().getTime()); + Date depositeDate = document.getDepositDate(); + Date publicationDate = document.getPublicationDate(); + CoselmarUser documentOwner = document.getOwner(); + String owner = "N/A"; + if (documentOwner != null) { + String firstname = documentOwner.getFirstname(); + String lastname = documentOwner.getName(); + owner = StringUtils.defaultString(firstname) + StringUtils.defaultString(lastname); + } + + return new DocumentBean(documentLightId, document.getName(), - "N/A", + owner, document.getPrivacy().name(), depositeDate, document.getKeywords(), - document.getMimeType()); + + document.getType(), + document.getSummary(), + document.getLanguage(), + publicationDate, + + document.getAuthors(), + document.getLicense(), + document.getCopyright(), + + document.isIsFile(), + document.getMimeType(), + document.getExternalUrl() + ); } public static UserBean toBean(CoselmarUser user) { -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.