1
0
mirror of https://github.com/sismics/docs.git synced 2025-12-28 17:11:41 +00:00

Nullable document metadata can be emptied

This commit is contained in:
jendib
2016-03-15 00:58:55 +01:00
parent 00ee2d3bf6
commit 0fab8ff935
6 changed files with 29 additions and 41 deletions

View File

@@ -27,7 +27,6 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.StreamingOutput;
import org.apache.commons.lang.StringUtils;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
@@ -547,8 +546,8 @@ public class DocumentResource extends BaseResource {
}
// Validate input data
title = ValidationUtil.validateLength(title, "title", 1, 100, true);
language = ValidationUtil.validateLength(language, "language", 3, 3, true);
title = ValidationUtil.validateLength(title, "title", 1, 100, false);
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, "identifier", 0, 500, true);
@@ -577,42 +576,22 @@ public class DocumentResource extends BaseResource {
}
// Update the document
if (!StringUtils.isEmpty(title)) {
document.setTitle(title);
}
if (!StringUtils.isEmpty(description)) {
document.setDescription(description);
}
if (!StringUtils.isEmpty(subject)) {
document.setSubject(subject);
}
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.setTitle(title);
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());
} else {
document.setCreateDate(createDate);
}
if (language != null) {
document.setLanguage(language);
}
document = documentDao.update(document, principal.getId());

View File

@@ -98,6 +98,7 @@
<label class="col-sm-2 control-label" for="inputType">Type</label>
<div class="col-sm-10">
<select class="form-control" id="inputType" name="type" ng-model="document.type" ng-disabled="fileIsUploading">
<option value=""></option>
<option ng-repeat="vocabulary in vocabularies['type']">{{ vocabulary.value }}</option>
</select>
</div>
@@ -106,6 +107,7 @@
<label class="col-sm-2 control-label" for="inputCoverage">Coverage</label>
<div class="col-sm-10">
<select class="form-control" id="inputCoverage" name="coverage" ng-model="document.coverage" ng-disabled="fileIsUploading">
<option value=""></option>
<option ng-repeat="vocabulary in vocabularies['coverage']">{{ vocabulary.value }}</option>
</select>
</div>
@@ -114,6 +116,7 @@
<label class="col-sm-2 control-label" for="inputRights">Rights</label>
<div class="col-sm-10">
<select class="form-control" id="inputRights" name="rights" ng-model="document.rights" ng-disabled="fileIsUploading">
<option value=""></option>
<option ng-repeat="vocabulary in vocabularies['rights']">{{ vocabulary.value }}</option>
</select>
</div>

View File

@@ -26,8 +26,8 @@
</span>
</span>
</dd>
<dt>Relations</dt>
<dd>
<dt ng-if="document.relations.length > 0">Relations</dt>
<dd ng-if="document.relations.length > 0">
<span ng-repeat="relation in document.relations">
<span class="btn btn-link btn-xs">
<a href="#/document/view/{{ relation.id }}">