diff --git a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/DocumentDao.java b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/DocumentDao.java index 0d58e3b1..ebf3a45b 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/DocumentDao.java +++ b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/DocumentDao.java @@ -89,7 +89,7 @@ public class DocumentDao { */ public DocumentDto getDocument(String id) { EntityManager em = ThreadLocalContext.get().getEntityManager(); - StringBuilder sb = new StringBuilder("select d.DOC_ID_C, d.DOC_TITLE_C, d.DOC_DESCRIPTION_C, d.DOC_SUBJECT_C, d.DOC_IDENTIFIER_C, d.DOC_CREATEDATE_D, d.DOC_LANGUAGE_C, "); + StringBuilder sb = new StringBuilder("select d.DOC_ID_C, d.DOC_TITLE_C, d.DOC_DESCRIPTION_C, d.DOC_SUBJECT_C, d.DOC_IDENTIFIER_C, d.DOC_PUBLISHER_C, d.DOC_FORMAT_C, d.DOC_SOURCE_C, d.DOC_TYPE_C, d.DOC_COVERAGE_C, d.DOC_RIGHTS_C, d.DOC_CREATEDATE_D, d.DOC_LANGUAGE_C, "); sb.append(" (select count(s.SHA_ID_C) from T_SHARE s, T_ACL ac where ac.ACL_SOURCEID_C = d.DOC_ID_C and ac.ACL_TARGETID_C = s.SHA_ID_C and ac.ACL_DELETEDATE_D is null and s.SHA_DELETEDATE_D is null), "); sb.append(" (select count(f.FIL_ID_C) from T_FILE f where f.FIL_DELETEDATE_D is null and f.FIL_IDDOC_C = d.DOC_ID_C), "); sb.append(" u.USE_USERNAME_C "); @@ -111,6 +111,12 @@ public class DocumentDao { documentDto.setDescription((String) o[i++]); documentDto.setSubject((String) o[i++]); documentDto.setIdentifier((String) o[i++]); + documentDto.setPublisher((String) o[i++]); + documentDto.setFormat((String) o[i++]); + documentDto.setSource((String) o[i++]); + documentDto.setType((String) o[i++]); + documentDto.setCoverage((String) o[i++]); + documentDto.setRights((String) o[i++]); documentDto.setCreateTimestamp(((Timestamp) o[i++]).getTime()); documentDto.setLanguage((String) o[i++]); documentDto.setShared(((Number) o[i++]).intValue() > 0); @@ -300,6 +306,12 @@ public class DocumentDao { documentFromDb.setDescription(document.getDescription()); documentFromDb.setSubject(document.getSubject()); documentFromDb.setIdentifier(document.getIdentifier()); + documentFromDb.setPublisher(document.getPublisher()); + documentFromDb.setFormat(document.getFormat()); + documentFromDb.setSource(document.getSource()); + documentFromDb.setType(document.getType()); + documentFromDb.setCoverage(document.getCoverage()); + documentFromDb.setRights(document.getRights()); documentFromDb.setCreateDate(document.getCreateDate()); documentFromDb.setLanguage(document.getLanguage()); diff --git a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/dto/DocumentDto.java b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/dto/DocumentDto.java index e67a7f7d..e5ed2eb1 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/dto/DocumentDto.java +++ b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/dto/DocumentDto.java @@ -34,6 +34,36 @@ public class DocumentDto { */ private String identifier; + /** + * Publisher. + */ + private String publisher; + + /** + * Format. + */ + private String format; + + /** + * Source. + */ + private String source; + + /** + * Type. + */ + private String type; + + /** + * Coverage. + */ + private String coverage; + + /** + * Rights. + */ + private String rights; + /** * Language. */ @@ -98,6 +128,54 @@ public class DocumentDto { public void setIdentifier(String identifier) { this.identifier = identifier; } + + public String getPublisher() { + return publisher; + } + + public void setPublisher(String publisher) { + this.publisher = publisher; + } + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getCoverage() { + return coverage; + } + + public void setCoverage(String coverage) { + this.coverage = coverage; + } + + public String getRights() { + return rights; + } + + public void setRights(String rights) { + this.rights = rights; + } public Long getCreateTimestamp() { return createTimestamp; diff --git a/docs-core/src/main/java/com/sismics/docs/core/dao/lucene/LuceneDao.java b/docs-core/src/main/java/com/sismics/docs/core/dao/lucene/LuceneDao.java index cd2d1d0c..a96f807a 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/dao/lucene/LuceneDao.java +++ b/docs-core/src/main/java/com/sismics/docs/core/dao/lucene/LuceneDao.java @@ -161,6 +161,12 @@ public class LuceneDao { query.add(qpHelper.parse(searchQuery, "description"), Occur.SHOULD); query.add(qpHelper.parse(searchQuery, "subject"), Occur.SHOULD); query.add(qpHelper.parse(searchQuery, "identifier"), Occur.SHOULD); + query.add(qpHelper.parse(searchQuery, "publisher"), Occur.SHOULD); + query.add(qpHelper.parse(searchQuery, "format"), Occur.SHOULD); + query.add(qpHelper.parse(searchQuery, "source"), Occur.SHOULD); + query.add(qpHelper.parse(searchQuery, "type"), Occur.SHOULD); + query.add(qpHelper.parse(searchQuery, "coverage"), Occur.SHOULD); + query.add(qpHelper.parse(searchQuery, "rights"), Occur.SHOULD); query.add(qpHelper.parse(fullSearchQuery, "content"), Occur.SHOULD); // Search @@ -210,6 +216,24 @@ public class LuceneDao { if (document.getIdentifier() != null) { luceneDocument.add(new TextField("identifier", document.getIdentifier(), Field.Store.NO)); } + if (document.getPublisher() != null) { + luceneDocument.add(new TextField("publisher", document.getPublisher(), Field.Store.NO)); + } + if (document.getFormat() != null) { + luceneDocument.add(new TextField("format", document.getFormat(), Field.Store.NO)); + } + if (document.getSource() != null) { + luceneDocument.add(new TextField("source", document.getSource(), Field.Store.NO)); + } + if (document.getType() != null) { + luceneDocument.add(new TextField("type", document.getType(), Field.Store.NO)); + } + if (document.getCoverage() != null) { + luceneDocument.add(new TextField("coverage", document.getCoverage(), Field.Store.NO)); + } + if (document.getRights() != null) { + luceneDocument.add(new TextField("rights", document.getRights(), Field.Store.NO)); + } return luceneDocument; } diff --git a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Document.java b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Document.java index 2964a02d..7b9da6f2 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Document.java +++ b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Document.java @@ -60,6 +60,42 @@ public class Document implements Loggable { @Column(name = "DOC_IDENTIFIER_C", length = 500) private String identifier; + /** + * Publisher. + */ + @Column(name = "DOC_PUBLISHER_C", length = 500) + private String publisher; + + /** + * Format. + */ + @Column(name = "DOC_FORMAT_C", length = 500) + private String format; + + /** + * Source. + */ + @Column(name = "DOC_SOURCE_C", length = 500) + private String source; + + /** + * Type. + */ + @Column(name = "DOC_TYPE_C", length = 100) + private String type; + + /** + * Coverage. + */ + @Column(name = "DOC_COVERAGE_C", length = 100) + private String coverage; + + /** + * Rights. + */ + @Column(name = "DOC_RIGHTS_C", length = 100) + private String rights; + /** * Creation date. */ @@ -127,6 +163,54 @@ public class Document implements Loggable { public void setIdentifier(String identifier) { this.identifier = identifier; } + + public String getPublisher() { + return publisher; + } + + public void setPublisher(String publisher) { + this.publisher = publisher; + } + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getCoverage() { + return coverage; + } + + public void setCoverage(String coverage) { + this.coverage = coverage; + } + + public String getRights() { + return rights; + } + + public void setRights(String rights) { + this.rights = rights; + } public Date getCreateDate() { return createDate; diff --git a/docs-core/src/main/resources/db/update/dbupdate-006-0.sql b/docs-core/src/main/resources/db/update/dbupdate-006-0.sql index 4d3e8248..3ec07e0e 100644 --- a/docs-core/src/main/resources/db/update/dbupdate-006-0.sql +++ b/docs-core/src/main/resources/db/update/dbupdate-006-0.sql @@ -1,18 +1,24 @@ alter table T_DOCUMENT add column DOC_SUBJECT_C varchar(500); alter table T_DOCUMENT add column DOC_IDENTIFIER_C varchar(500); +alter table T_DOCUMENT add column DOC_PUBLISHER_C varchar(500); +alter table T_DOCUMENT add column DOC_FORMAT_C varchar(500); +alter table T_DOCUMENT add column DOC_SOURCE_C varchar(500); +alter table T_DOCUMENT add column DOC_TYPE_C varchar(100); +alter table T_DOCUMENT add column DOC_COVERAGE_C varchar(100); +alter table T_DOCUMENT add column DOC_RIGHTS_C varchar(100); create memory table T_VOCABULARY ( VOC_ID_C varchar(36) not null, VOC_NAME_C varchar(50) not null, VOC_VALUE_C varchar(100) not null, VOC_ORDER_N int not null, primary key (VOC_ID_C) ); insert into T_VOCABULARY(VOC_ID_C, VOC_NAME_C, VOC_VALUE_C, VOC_ORDER_N) values('type-collection', 'type', 'Collection', 0); insert into T_VOCABULARY(VOC_ID_C, VOC_NAME_C, VOC_VALUE_C, VOC_ORDER_N) values('type-dataset', 'type', 'Dataset', 1); insert into T_VOCABULARY(VOC_ID_C, VOC_NAME_C, VOC_VALUE_C, VOC_ORDER_N) values('type-event', 'type', 'Event', 2); insert into T_VOCABULARY(VOC_ID_C, VOC_NAME_C, VOC_VALUE_C, VOC_ORDER_N) values('type-image', 'type', 'Image', 3); -insert into T_VOCABULARY(VOC_ID_C, VOC_NAME_C, VOC_VALUE_C, VOC_ORDER_N) values('type-interactive_resource', 'type', 'Interactive Resource', 4); -insert into T_VOCABULARY(VOC_ID_C, VOC_NAME_C, VOC_VALUE_C, VOC_ORDER_N) values('type-moving_image', 'type', 'Moving Image', 5); -insert into T_VOCABULARY(VOC_ID_C, VOC_NAME_C, VOC_VALUE_C, VOC_ORDER_N) values('type-physical_object', 'type', 'Physical Object', 6); +insert into T_VOCABULARY(VOC_ID_C, VOC_NAME_C, VOC_VALUE_C, VOC_ORDER_N) values('type-interactive-resource', 'type', 'Interactive Resource', 4); +insert into T_VOCABULARY(VOC_ID_C, VOC_NAME_C, VOC_VALUE_C, VOC_ORDER_N) values('type-moving-image', 'type', 'Moving Image', 5); +insert into T_VOCABULARY(VOC_ID_C, VOC_NAME_C, VOC_VALUE_C, VOC_ORDER_N) values('type-physical-object', 'type', 'Physical Object', 6); insert into T_VOCABULARY(VOC_ID_C, VOC_NAME_C, VOC_VALUE_C, VOC_ORDER_N) values('type-service', 'type', 'Service', 7); insert into T_VOCABULARY(VOC_ID_C, VOC_NAME_C, VOC_VALUE_C, VOC_ORDER_N) values('type-software', 'type', 'Software', 8); insert into T_VOCABULARY(VOC_ID_C, VOC_NAME_C, VOC_VALUE_C, VOC_ORDER_N) values('type-sound', 'type', 'Sound', 9); -insert into T_VOCABULARY(VOC_ID_C, VOC_NAME_C, VOC_VALUE_C, VOC_ORDER_N) values('type-still_image', 'type', 'Still Image', 10); +insert into T_VOCABULARY(VOC_ID_C, VOC_NAME_C, VOC_VALUE_C, VOC_ORDER_N) values('type-still-image', 'type', 'Still Image', 10); insert into T_VOCABULARY(VOC_ID_C, VOC_NAME_C, VOC_VALUE_C, VOC_ORDER_N) values('type-text', 'type', 'Text', 11); insert into T_VOCABULARY(VOC_ID_C, VOC_NAME_C, VOC_VALUE_C, VOC_ORDER_N) values('coverage-afg', 'coverage', 'Afghanistan', 0); diff --git a/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java b/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java index e206b9cd..bb798b1a 100644 --- a/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java +++ b/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java @@ -130,6 +130,12 @@ public class DocumentResource extends BaseResource { // Below is specific to GET /document/id document.add("subject", JsonUtil.nullable(documentDto.getSubject())); document.add("identifier", JsonUtil.nullable(documentDto.getIdentifier())); + document.add("publisher", JsonUtil.nullable(documentDto.getPublisher())); + document.add("format", JsonUtil.nullable(documentDto.getFormat())); + document.add("source", JsonUtil.nullable(documentDto.getSource())); + document.add("type", JsonUtil.nullable(documentDto.getType())); + document.add("coverage", JsonUtil.nullable(documentDto.getCoverage())); + document.add("rights", JsonUtil.nullable(documentDto.getRights())); document.add("creator", documentDto.getCreator()); // Add ACL @@ -393,6 +399,12 @@ public class DocumentResource extends BaseResource { @FormParam("description") String description, @FormParam("subject") String subject, @FormParam("identifier") String identifier, + @FormParam("publisher") String publisher, + @FormParam("format") String format, + @FormParam("source") String source, + @FormParam("type") String type, + @FormParam("coverage") String coverage, + @FormParam("rights") String rights, @FormParam("tags") List tagList, @FormParam("language") String language, @FormParam("create_date") String createDateStr) { @@ -405,7 +417,13 @@ public class DocumentResource extends BaseResource { language = ValidationUtil.validateLength(language, "language", 3, 3, false); description = ValidationUtil.validateLength(description, "description", 0, 4000, true); subject = ValidationUtil.validateLength(subject, "subject", 0, 500, true); - identifier = ValidationUtil.validateLength(identifier, "description", 0, 500, true); + identifier = ValidationUtil.validateLength(identifier, "identifier", 0, 500, true); + publisher = ValidationUtil.validateLength(publisher, "publisher", 0, 500, true); + format = ValidationUtil.validateLength(format, "format", 0, 500, true); + source = ValidationUtil.validateLength(source, "source", 0, 500, true); + type = ValidationUtil.validateLength(type, "type", 0, 100, true); + coverage = ValidationUtil.validateLength(coverage, "coverage", 0, 100, true); + rights = ValidationUtil.validateLength(rights, "rights", 0, 100, true); Date createDate = ValidationUtil.validateDate(createDateStr, "create_date", true); if (!Constants.SUPPORTED_LANGUAGES.contains(language)) { throw new ClientException("ValidationError", MessageFormat.format("{0} is not a supported language", language)); @@ -419,6 +437,12 @@ public class DocumentResource extends BaseResource { document.setDescription(description); document.setSubject(subject); document.setIdentifier(identifier); + document.setPublisher(publisher); + document.setFormat(format); + document.setSource(source); + document.setType(type); + document.setCoverage(coverage); + document.setRights(rights); document.setLanguage(language); if (createDate == null) { document.setCreateDate(new Date()); @@ -470,6 +494,12 @@ public class DocumentResource extends BaseResource { @FormParam("description") String description, @FormParam("subject") String subject, @FormParam("identifier") String identifier, + @FormParam("publisher") String publisher, + @FormParam("format") String format, + @FormParam("source") String source, + @FormParam("type") String type, + @FormParam("coverage") String coverage, + @FormParam("rights") String rights, @FormParam("tags") List tagList, @FormParam("language") String language, @FormParam("create_date") String createDateStr) { @@ -483,6 +513,12 @@ public class DocumentResource extends BaseResource { description = ValidationUtil.validateLength(description, "description", 0, 4000, true); subject = ValidationUtil.validateLength(subject, "subject", 0, 500, true); identifier = ValidationUtil.validateLength(identifier, "identifier", 0, 500, true); + publisher = ValidationUtil.validateLength(publisher, "publisher", 0, 500, true); + format = ValidationUtil.validateLength(format, "format", 0, 500, true); + source = ValidationUtil.validateLength(source, "source", 0, 500, true); + type = ValidationUtil.validateLength(type, "type", 0, 100, true); + coverage = ValidationUtil.validateLength(coverage, "coverage", 0, 100, true); + rights = ValidationUtil.validateLength(rights, "rights", 0, 100, true); Date createDate = ValidationUtil.validateDate(createDateStr, "create_date", true); if (language != null && !Constants.SUPPORTED_LANGUAGES.contains(language)) { throw new ClientException("ValidationError", MessageFormat.format("{0} is not a supported language", language)); @@ -509,6 +545,24 @@ public class DocumentResource extends BaseResource { if (!StringUtils.isEmpty(identifier)) { document.setIdentifier(identifier); } + if (!StringUtils.isEmpty(publisher)) { + document.setPublisher(publisher); + } + if (!StringUtils.isEmpty(format)) { + document.setFormat(format); + } + if (!StringUtils.isEmpty(source)) { + document.setSource(source); + } + if (!StringUtils.isEmpty(type)) { + document.setType(type); + } + if (!StringUtils.isEmpty(coverage)) { + document.setCoverage(coverage); + } + if (!StringUtils.isEmpty(rights)) { + document.setRights(rights); + } if (createDate != null) { document.setCreateDate(createDate); } diff --git a/docs-web/src/main/java/com/sismics/docs/rest/resource/VocabularyResource.java b/docs-web/src/main/java/com/sismics/docs/rest/resource/VocabularyResource.java index cb99c733..5941e28e 100644 --- a/docs-web/src/main/java/com/sismics/docs/rest/resource/VocabularyResource.java +++ b/docs-web/src/main/java/com/sismics/docs/rest/resource/VocabularyResource.java @@ -42,6 +42,7 @@ public class VocabularyResource extends BaseResource { for (Vocabulary vocabulary : vocabularyList) { entries.add(Json.createObjectBuilder() .add("id", vocabulary.getId()) + .add("name", vocabulary.getName()) .add("value", vocabulary.getValue()) .add("order", vocabulary.getOrder())); } @@ -113,7 +114,9 @@ public class VocabularyResource extends BaseResource { // Validate input data name = ValidationUtil.validateLength(name, "name", 1, 50, true); - ValidationUtil.validateRegex(name, "name", "[a-z0-9\\-]+"); + if (name != null) { + ValidationUtil.validateRegex(name, "name", "[a-z0-9\\-]+"); + } value = ValidationUtil.validateLength(value, "value", 1, 100, true); Integer order = null; if (orderStr != null) { diff --git a/docs-web/src/main/webapp/src/partial/docs/document.edit.html b/docs-web/src/main/webapp/src/partial/docs/document.edit.html index 50738c40..f25c1be5 100644 --- a/docs-web/src/main/webapp/src/partial/docs/document.edit.html +++ b/docs-web/src/main/webapp/src/partial/docs/document.edit.html @@ -2,70 +2,99 @@
-
- -
- +
+ Primary metadata +
+ +
+ +
-
-
- -
- +
+ +
+ +
-
-
- -
- +
+ +
+ +
-
-
- -
- +
+ +
+ +
-
-
- -
- +
+ +
+ +
+
+ + {{ orphanFiles.length }} file{{ orphanFiles.length > 1 ? 's' : '' }} +
-
-
- -
- +
+ +
+ +
-
-
- -
- + + +
+ Additional metadata +
+ +
+ +
-
- + {{ orphanFiles.length }} file{{ orphanFiles.length > 1 ? 's' : '' }} +
+ +
+ +
-
-
- -
- +
+ +
+ +
-
+
+ +
+ +
+
+
+ +
+ +
+
+
+
diff --git a/docs-web/src/main/webapp/src/partial/docs/document.view.content.html b/docs-web/src/main/webapp/src/partial/docs/document.view.content.html index a2d7b591..41b78fb7 100644 --- a/docs-web/src/main/webapp/src/partial/docs/document.view.content.html +++ b/docs-web/src/main/webapp/src/partial/docs/document.view.content.html @@ -4,6 +4,12 @@
{{ document.subject }}
Identifier
{{ document.identifier }}
+
Publisher
+
{{ document.publisher }}
+
Format
+
{{ document.format }}
+
Source
+
{{ document.source }}