#65: Publisher, format, source metadata

This commit is contained in:
jendib 2016-02-14 22:47:49 +01:00
parent ed51b77b0e
commit 359f5b5f49
11 changed files with 394 additions and 62 deletions

View File

@ -89,7 +89,7 @@ public class DocumentDao {
*/ */
public DocumentDto getDocument(String id) { public DocumentDto getDocument(String id) {
EntityManager em = ThreadLocalContext.get().getEntityManager(); 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(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(" (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 "); sb.append(" u.USE_USERNAME_C ");
@ -111,6 +111,12 @@ public class DocumentDao {
documentDto.setDescription((String) o[i++]); documentDto.setDescription((String) o[i++]);
documentDto.setSubject((String) o[i++]); documentDto.setSubject((String) o[i++]);
documentDto.setIdentifier((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.setCreateTimestamp(((Timestamp) o[i++]).getTime());
documentDto.setLanguage((String) o[i++]); documentDto.setLanguage((String) o[i++]);
documentDto.setShared(((Number) o[i++]).intValue() > 0); documentDto.setShared(((Number) o[i++]).intValue() > 0);
@ -300,6 +306,12 @@ public class DocumentDao {
documentFromDb.setDescription(document.getDescription()); documentFromDb.setDescription(document.getDescription());
documentFromDb.setSubject(document.getSubject()); documentFromDb.setSubject(document.getSubject());
documentFromDb.setIdentifier(document.getIdentifier()); 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.setCreateDate(document.getCreateDate());
documentFromDb.setLanguage(document.getLanguage()); documentFromDb.setLanguage(document.getLanguage());

View File

@ -34,6 +34,36 @@ public class DocumentDto {
*/ */
private String identifier; 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. * Language.
*/ */
@ -98,6 +128,54 @@ public class DocumentDto {
public void setIdentifier(String identifier) { public void setIdentifier(String identifier) {
this.identifier = 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() { public Long getCreateTimestamp() {
return createTimestamp; return createTimestamp;

View File

@ -161,6 +161,12 @@ public class LuceneDao {
query.add(qpHelper.parse(searchQuery, "description"), Occur.SHOULD); query.add(qpHelper.parse(searchQuery, "description"), Occur.SHOULD);
query.add(qpHelper.parse(searchQuery, "subject"), Occur.SHOULD); query.add(qpHelper.parse(searchQuery, "subject"), Occur.SHOULD);
query.add(qpHelper.parse(searchQuery, "identifier"), 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); query.add(qpHelper.parse(fullSearchQuery, "content"), Occur.SHOULD);
// Search // Search
@ -210,6 +216,24 @@ public class LuceneDao {
if (document.getIdentifier() != null) { if (document.getIdentifier() != null) {
luceneDocument.add(new TextField("identifier", document.getIdentifier(), Field.Store.NO)); 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; return luceneDocument;
} }

View File

@ -60,6 +60,42 @@ public class Document implements Loggable {
@Column(name = "DOC_IDENTIFIER_C", length = 500) @Column(name = "DOC_IDENTIFIER_C", length = 500)
private String identifier; 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. * Creation date.
*/ */
@ -127,6 +163,54 @@ public class Document implements Loggable {
public void setIdentifier(String identifier) { public void setIdentifier(String identifier) {
this.identifier = 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() { public Date getCreateDate() {
return createDate; return createDate;

View File

@ -1,18 +1,24 @@
alter table T_DOCUMENT add column DOC_SUBJECT_C varchar(500); 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_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) ); 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-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-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-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-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-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-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-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-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-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-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('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); insert into T_VOCABULARY(VOC_ID_C, VOC_NAME_C, VOC_VALUE_C, VOC_ORDER_N) values('coverage-afg', 'coverage', 'Afghanistan', 0);

View File

@ -130,6 +130,12 @@ public class DocumentResource extends BaseResource {
// Below is specific to GET /document/id // Below is specific to GET /document/id
document.add("subject", JsonUtil.nullable(documentDto.getSubject())); document.add("subject", JsonUtil.nullable(documentDto.getSubject()));
document.add("identifier", JsonUtil.nullable(documentDto.getIdentifier())); 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()); document.add("creator", documentDto.getCreator());
// Add ACL // Add ACL
@ -393,6 +399,12 @@ public class DocumentResource extends BaseResource {
@FormParam("description") String description, @FormParam("description") String description,
@FormParam("subject") String subject, @FormParam("subject") String subject,
@FormParam("identifier") String identifier, @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<String> tagList, @FormParam("tags") List<String> tagList,
@FormParam("language") String language, @FormParam("language") String language,
@FormParam("create_date") String createDateStr) { @FormParam("create_date") String createDateStr) {
@ -405,7 +417,13 @@ public class DocumentResource extends BaseResource {
language = ValidationUtil.validateLength(language, "language", 3, 3, false); language = ValidationUtil.validateLength(language, "language", 3, 3, false);
description = ValidationUtil.validateLength(description, "description", 0, 4000, true); description = ValidationUtil.validateLength(description, "description", 0, 4000, true);
subject = ValidationUtil.validateLength(subject, "subject", 0, 500, 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); Date createDate = ValidationUtil.validateDate(createDateStr, "create_date", true);
if (!Constants.SUPPORTED_LANGUAGES.contains(language)) { if (!Constants.SUPPORTED_LANGUAGES.contains(language)) {
throw new ClientException("ValidationError", MessageFormat.format("{0} is not a supported language", 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.setDescription(description);
document.setSubject(subject); document.setSubject(subject);
document.setIdentifier(identifier); document.setIdentifier(identifier);
document.setPublisher(publisher);
document.setFormat(format);
document.setSource(source);
document.setType(type);
document.setCoverage(coverage);
document.setRights(rights);
document.setLanguage(language); document.setLanguage(language);
if (createDate == null) { if (createDate == null) {
document.setCreateDate(new Date()); document.setCreateDate(new Date());
@ -470,6 +494,12 @@ public class DocumentResource extends BaseResource {
@FormParam("description") String description, @FormParam("description") String description,
@FormParam("subject") String subject, @FormParam("subject") String subject,
@FormParam("identifier") String identifier, @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<String> tagList, @FormParam("tags") List<String> tagList,
@FormParam("language") String language, @FormParam("language") String language,
@FormParam("create_date") String createDateStr) { @FormParam("create_date") String createDateStr) {
@ -483,6 +513,12 @@ public class DocumentResource extends BaseResource {
description = ValidationUtil.validateLength(description, "description", 0, 4000, true); description = ValidationUtil.validateLength(description, "description", 0, 4000, true);
subject = ValidationUtil.validateLength(subject, "subject", 0, 500, true); subject = ValidationUtil.validateLength(subject, "subject", 0, 500, true);
identifier = ValidationUtil.validateLength(identifier, "identifier", 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); Date createDate = ValidationUtil.validateDate(createDateStr, "create_date", true);
if (language != null && !Constants.SUPPORTED_LANGUAGES.contains(language)) { if (language != null && !Constants.SUPPORTED_LANGUAGES.contains(language)) {
throw new ClientException("ValidationError", MessageFormat.format("{0} is not a supported language", 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)) { if (!StringUtils.isEmpty(identifier)) {
document.setIdentifier(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) { if (createDate != null) {
document.setCreateDate(createDate); document.setCreateDate(createDate);
} }

View File

@ -42,6 +42,7 @@ public class VocabularyResource extends BaseResource {
for (Vocabulary vocabulary : vocabularyList) { for (Vocabulary vocabulary : vocabularyList) {
entries.add(Json.createObjectBuilder() entries.add(Json.createObjectBuilder()
.add("id", vocabulary.getId()) .add("id", vocabulary.getId())
.add("name", vocabulary.getName())
.add("value", vocabulary.getValue()) .add("value", vocabulary.getValue())
.add("order", vocabulary.getOrder())); .add("order", vocabulary.getOrder()));
} }
@ -113,7 +114,9 @@ public class VocabularyResource extends BaseResource {
// Validate input data // Validate input data
name = ValidationUtil.validateLength(name, "name", 1, 50, true); 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); value = ValidationUtil.validateLength(value, "value", 1, 100, true);
Integer order = null; Integer order = null;
if (orderStr != null) { if (orderStr != null) {

View File

@ -2,70 +2,99 @@
<div ng-show="document || !isEdit()"> <div ng-show="document || !isEdit()">
<form name="documentForm" class="form-horizontal"> <form name="documentForm" class="form-horizontal">
<div class="form-group" ng-class="{ 'has-error': !documentForm.title.$valid }"> <fieldset>
<label class="col-sm-2 control-label" for="inputTitle">Title</label> <legend>Primary metadata</legend>
<div class="col-sm-10"> <div class="form-group" ng-class="{ 'has-error': !documentForm.title.$valid }">
<input required ng-maxlength="100" class="form-control" type="text" id="inputTitle" <label class="col-sm-2 control-label" for="inputTitle">Title</label>
placeholder="Title" name="title" ng-model="document.title" autocomplete="off" <div class="col-sm-10">
typeahead="document for document in getTitleTypeahead($viewValue) | filter: $viewValue" <input required ng-maxlength="100" class="form-control" type="text" id="inputTitle"
typeahead-wait-ms="200" ng-disabled="fileIsUploading" /> placeholder="The nature or genre of the resource" name="title" ng-model="document.title" autocomplete="off"
typeahead="document for document in getTitleTypeahead($viewValue) | filter: $viewValue"
typeahead-wait-ms="200" ng-disabled="fileIsUploading" />
</div>
</div> </div>
</div> <div class="form-group" ng-class="{ 'has-error': !documentForm.description.$valid }">
<div class="form-group" ng-class="{ 'has-error': !documentForm.description.$valid }"> <label class="col-sm-2 control-label" for="inputDescription">Description</label>
<label class="col-sm-2 control-label" for="inputDescription">Description</label> <div class="col-sm-10">
<div class="col-sm-10"> <textarea ng-maxlength="4000" class="form-control" rows="5" id="inputDescription" placeholder="An account of the resource"
<textarea ng-maxlength="4000" class="form-control" rows="5" id="inputDescription" name="description" ng-model="document.description" ng-disabled="fileIsUploading"></textarea>
name="description" ng-model="document.description" ng-disabled="fileIsUploading"></textarea> </div>
</div> </div>
</div> <div class="form-group">
<div class="form-group" ng-class="{ 'has-error': !documentForm.subject.$valid }"> <label class="col-sm-2 control-label" for="inputCreateDate">Creation date</label>
<label class="col-sm-2 control-label" for="inputSubject">Subject</label> <div class="col-sm-10">
<div class="col-sm-10"> <input type="text" id="inputCreateDate" ng-readonly="true" datepicker-popup="yyyy-MM-dd" class="form-control"
<input ng-maxlength="500" class="form-control" type="text" id="inputSubject" ng-model="document.create_date" starting-day="1" show-weeks="false" ng-disabled="fileIsUploading" />
placeholder="Subject" name="subject" ng-model="document.subject" ng-disabled="fileIsUploading" /> </div>
</div> </div>
</div> <div class="form-group">
<div class="form-group" ng-class="{ 'has-error': !documentForm.identifier.$valid }"> <label class="col-sm-2 control-label" for="inputLanguage">Language</label>
<label class="col-sm-2 control-label" for="inputIdentifier">Identifier</label> <div class="col-sm-10">
<div class="col-sm-10"> <select class="form-control" id="inputLanguage" ng-model="document.language" ng-disabled="fileIsUploading">
<input ng-maxlength="500" class="form-control" type="text" id="inputIdentifier" <option value="fra">French</option>
placeholder="Identifier" name="identifier" ng-model="document.identifier" ng-disabled="fileIsUploading" /> <option value="eng">English</option>
<option value="jpn">Japanese</option>
</select>
</div>
</div> </div>
</div> <div class="form-group">
<div class="form-group"> <label class="col-sm-2 control-label" for="inputFiles">New files</label>
<label class="col-sm-2 control-label" for="inputCreateDate">Creation date</label> <div class="col-sm-6">
<div class="col-sm-10"> <file class="form-control" id="inputFiles" multiple="multiple" ng-model="newFiles"
<input type="text" id="inputCreateDate" ng-readonly="true" datepicker-popup="yyyy-MM-dd" class="form-control" accept="image/png,image/jpg,image/jpeg,image/gif,application/pdf,application/vnd.oasis.opendocument.text,application/vnd.openxmlformats-officedocument.wordprocessingml.document"
ng-model="document.create_date" starting-day="1" show-weeks="false" ng-disabled="fileIsUploading" /> ng-disabled="fileIsUploading"></file>
</div>
<div class="col-sm-4" ng-if="orphanFiles.length > 0">
+ {{ orphanFiles.length }} file{{ orphanFiles.length > 1 ? 's' : '' }}
</div>
</div> </div>
</div> <div class="form-group">
<div class="form-group"> <label class="col-sm-2 control-label" for="inputTags">Tags</label>
<label class="col-sm-2 control-label" for="inputLanguage">Language</label> <div class="col-sm-10">
<div class="col-sm-10"> <select-tag tags="document.tags" ref="inputTags" ng-disabled="fileIsUploading"></select-tag>
<select class="form-control" id="inputLanguage" ng-model="document.language" ng-disabled="fileIsUploading"> </div>
<option value="fra">French</option>
<option value="eng">English</option>
<option value="jpn">Japanese</option>
</select>
</div> </div>
</div> </fieldset>
<div class="form-group">
<label class="col-sm-2 control-label" for="inputFiles">New files</label> <fieldset>
<div class="col-sm-6"> <legend>Additional metadata</legend>
<file class="form-control" id="inputFiles" multiple="multiple" ng-model="newFiles" <div class="form-group" ng-class="{ 'has-error': !documentForm.subject.$valid }">
accept="image/png,image/jpg,image/jpeg,image/gif,application/pdf,application/vnd.oasis.opendocument.text,application/vnd.openxmlformats-officedocument.wordprocessingml.document" <label class="col-sm-2 control-label" for="inputSubject">Subject</label>
ng-disabled="fileIsUploading"></file> <div class="col-sm-10">
<input ng-maxlength="500" class="form-control" type="text" id="inputSubject"
placeholder="The topic of the resource" name="subject" ng-model="document.subject" ng-disabled="fileIsUploading" />
</div>
</div> </div>
<div class="col-sm-4" ng-if="orphanFiles.length > 0"> <div class="form-group" ng-class="{ 'has-error': !documentForm.identifier.$valid }">
+ {{ orphanFiles.length }} file{{ orphanFiles.length > 1 ? 's' : '' }} <label class="col-sm-2 control-label" for="inputIdentifier">Identifier</label>
<div class="col-sm-10">
<input ng-maxlength="500" class="form-control" type="text" id="inputIdentifier"
placeholder="An unambiguous reference to the resource within a given context" name="identifier" ng-model="document.identifier" ng-disabled="fileIsUploading" />
</div>
</div> </div>
</div> <div class="form-group" ng-class="{ 'has-error': !documentForm.publisher.$valid }">
<div class="form-group"> <label class="col-sm-2 control-label" for="inputPublisher">Publisher</label>
<label class="col-sm-2 control-label" for="inputTags">Tags</label> <div class="col-sm-10">
<div class="col-sm-10"> <input ng-maxlength="500" class="form-control" type="text" id="inputPublisher"
<select-tag tags="document.tags" ref="inputTags" ng-disabled="fileIsUploading"></select-tag> placeholder="An entity responsible for making the resource available" name="publisher" ng-model="document.publisher" ng-disabled="fileIsUploading" />
</div>
</div> </div>
</div> <div class="form-group" ng-class="{ 'has-error': !documentForm.format.$valid }">
<label class="col-sm-2 control-label" for="inputFormat">Format</label>
<div class="col-sm-10">
<input ng-maxlength="500" class="form-control" type="text" id="inputFormat"
placeholder="The file format, physical medium, or dimensions of the resource" name="format" ng-model="document.format" ng-disabled="fileIsUploading" />
</div>
</div>
<div class="form-group" ng-class="{ 'has-error': !documentForm.source.$valid }">
<label class="col-sm-2 control-label" for="inputSource">Source</label>
<div class="col-sm-10">
<input ng-maxlength="500" class="form-control" type="text" id="inputSource"
placeholder="A related resource from which the described resource is derived" name="source" ng-model="document.source" ng-disabled="fileIsUploading" />
</div>
</div>
</fieldset>
<div class="form-group"> <div class="form-group">
<div class="col-sm-offset-2 col-sm-10"> <div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary" ng-disabled="!documentForm.$valid || fileIsUploading" ng-click="edit()">{{ isEdit() ? 'Edit' : 'Add' }}</button> <button type="submit" class="btn btn-primary" ng-disabled="!documentForm.$valid || fileIsUploading" ng-click="edit()">{{ isEdit() ? 'Edit' : 'Add' }}</button>

View File

@ -4,6 +4,12 @@
<dd ng-if="document.subject">{{ document.subject }}</dd> <dd ng-if="document.subject">{{ document.subject }}</dd>
<dt ng-if="document.identifier">Identifier</dt> <dt ng-if="document.identifier">Identifier</dt>
<dd ng-if="document.identifier">{{ document.identifier }}</dd> <dd ng-if="document.identifier">{{ document.identifier }}</dd>
<dt ng-if="document.publisher">Publisher</dt>
<dd ng-if="document.publisher">{{ document.publisher }}</dd>
<dt ng-if="document.format">Format</dt>
<dd ng-if="document.format">{{ document.format }}</dd>
<dt ng-if="document.source">Source</dt>
<dd ng-if="document.source">{{ document.source }}</dd>
</dl> </dl>
<div ng-file-drop drag-over-class="bg-success" ng-multiple="true" allow-dir="false" ng-model="dropFiles" <div ng-file-drop drag-over-class="bg-success" ng-multiple="true" allow-dir="false" ng-model="dropFiles"

View File

@ -64,6 +64,12 @@ public class TestDocumentResource extends BaseJerseyTest {
.param("description", "My super description for document 1") .param("description", "My super description for document 1")
.param("subject", "Subject document 1") .param("subject", "Subject document 1")
.param("identifier", "Identifier document 1") .param("identifier", "Identifier document 1")
.param("publisher", "Publisher document 1")
.param("format", "Format document 1")
.param("source", "Source document 1")
.param("type", "Software")
.param("coverage", "Greenland")
.param("rights", "Public Domain")
.param("tags", tag1Id) .param("tags", tag1Id)
.param("language", "eng") .param("language", "eng")
.param("create_date", Long.toString(create1Date))), JsonObject.class); .param("create_date", Long.toString(create1Date))), JsonObject.class);
@ -164,6 +170,12 @@ public class TestDocumentResource extends BaseJerseyTest {
Assert.assertEquals(1, searchDocuments("super description", document1Token)); Assert.assertEquals(1, searchDocuments("super description", document1Token));
Assert.assertEquals(1, searchDocuments("subject", document1Token)); Assert.assertEquals(1, searchDocuments("subject", document1Token));
Assert.assertEquals(1, searchDocuments("identifier", document1Token)); Assert.assertEquals(1, searchDocuments("identifier", document1Token));
Assert.assertEquals(1, searchDocuments("publisher", document1Token));
Assert.assertEquals(1, searchDocuments("format", document1Token));
Assert.assertEquals(1, searchDocuments("source", document1Token));
Assert.assertEquals(1, searchDocuments("software", document1Token));
Assert.assertEquals(1, searchDocuments("greenland", document1Token));
Assert.assertEquals(1, searchDocuments("public domain", document1Token));
Assert.assertEquals(1, searchDocuments("at:" + DateTimeFormat.forPattern("yyyy").print(new Date().getTime()), document1Token)); Assert.assertEquals(1, searchDocuments("at:" + DateTimeFormat.forPattern("yyyy").print(new Date().getTime()), document1Token));
Assert.assertEquals(1, searchDocuments("at:" + DateTimeFormat.forPattern("yyyy-MM").print(new Date().getTime()), document1Token)); Assert.assertEquals(1, searchDocuments("at:" + DateTimeFormat.forPattern("yyyy-MM").print(new Date().getTime()), document1Token));
Assert.assertEquals(1, searchDocuments("at:" + DateTimeFormat.forPattern("yyyy-MM-dd").print(new Date().getTime()), document1Token)); Assert.assertEquals(1, searchDocuments("at:" + DateTimeFormat.forPattern("yyyy-MM-dd").print(new Date().getTime()), document1Token));
@ -196,6 +208,12 @@ public class TestDocumentResource extends BaseJerseyTest {
Assert.assertEquals("My super description for document 1", json.getString("description")); Assert.assertEquals("My super description for document 1", json.getString("description"));
Assert.assertEquals("Subject document 1", json.getString("subject")); Assert.assertEquals("Subject document 1", json.getString("subject"));
Assert.assertEquals("Identifier document 1", json.getString("identifier")); Assert.assertEquals("Identifier document 1", json.getString("identifier"));
Assert.assertEquals("Publisher document 1", json.getString("publisher"));
Assert.assertEquals("Format document 1", json.getString("format"));
Assert.assertEquals("Source document 1", json.getString("source"));
Assert.assertEquals("Software", json.getString("type"));
Assert.assertEquals("Greenland", json.getString("coverage"));
Assert.assertEquals("Public Domain", json.getString("rights"));
Assert.assertEquals("eng", json.getString("language")); Assert.assertEquals("eng", json.getString("language"));
Assert.assertEquals(create1Date, json.getJsonNumber("create_date").longValue()); Assert.assertEquals(create1Date, json.getJsonNumber("create_date").longValue());
tags = json.getJsonArray("tags"); tags = json.getJsonArray("tags");
@ -223,6 +241,14 @@ public class TestDocumentResource extends BaseJerseyTest {
.post(Entity.form(new Form() .post(Entity.form(new Form()
.param("title", "My new super document 1") .param("title", "My new super document 1")
.param("description", "My new super description for document 1") .param("description", "My new super description for document 1")
.param("subject", "My new subject for document 1")
.param("identifier", "My new identifier for document 1")
.param("publisher", "My new publisher for document 1")
.param("format", "My new format for document 1")
.param("source", "My new source for document 1")
.param("type", "Image")
.param("coverage", "France")
.param("rights", "All Rights Reserved")
.param("tags", tag2Id)), JsonObject.class); .param("tags", tag2Id)), JsonObject.class);
Assert.assertEquals(document1Id, json.getString("id")); Assert.assertEquals(document1Id, json.getString("id"));
@ -239,6 +265,14 @@ public class TestDocumentResource extends BaseJerseyTest {
.get(JsonObject.class); .get(JsonObject.class);
Assert.assertTrue(json.getString("title").contains("new")); Assert.assertTrue(json.getString("title").contains("new"));
Assert.assertTrue(json.getString("description").contains("new")); Assert.assertTrue(json.getString("description").contains("new"));
Assert.assertTrue(json.getString("subject").contains("new"));
Assert.assertTrue(json.getString("identifier").contains("new"));
Assert.assertTrue(json.getString("publisher").contains("new"));
Assert.assertTrue(json.getString("format").contains("new"));
Assert.assertTrue(json.getString("source").contains("new"));
Assert.assertEquals("Image", json.getString("type"));
Assert.assertEquals("France", json.getString("coverage"));
Assert.assertEquals("All Rights Reserved", json.getString("rights"));
tags = json.getJsonArray("tags"); tags = json.getJsonArray("tags");
Assert.assertEquals(1, tags.size()); Assert.assertEquals(1, tags.size());
Assert.assertEquals(tag2Id, tags.getJsonObject(0).getString("id")); Assert.assertEquals(tag2Id, tags.getJsonObject(0).getString("id"));

View File

@ -38,10 +38,12 @@ public class TestVocabularyResource extends BaseJerseyTest {
Assert.assertEquals(249, json.getJsonArray("entries").size()); Assert.assertEquals(249, json.getJsonArray("entries").size());
JsonObject entry = json.getJsonArray("entries").getJsonObject(0); JsonObject entry = json.getJsonArray("entries").getJsonObject(0);
Assert.assertEquals("coverage-afg", entry.getString("id")); Assert.assertEquals("coverage-afg", entry.getString("id"));
Assert.assertEquals("coverage", entry.getString("name"));
Assert.assertEquals("Afghanistan", entry.getString("value")); Assert.assertEquals("Afghanistan", entry.getString("value"));
Assert.assertEquals(0, entry.getJsonNumber("order").intValue()); Assert.assertEquals(0, entry.getJsonNumber("order").intValue());
entry = json.getJsonArray("entries").getJsonObject(248); entry = json.getJsonArray("entries").getJsonObject(248);
Assert.assertEquals("coverage-zwe", entry.getString("id")); Assert.assertEquals("coverage-zwe", entry.getString("id"));
Assert.assertEquals("coverage", entry.getString("name"));
Assert.assertEquals("Zimbabwe", entry.getString("value")); Assert.assertEquals("Zimbabwe", entry.getString("value"));
Assert.assertEquals(248, entry.getJsonNumber("order").intValue()); Assert.assertEquals(248, entry.getJsonNumber("order").intValue());