1
0
mirror of https://github.com/sismics/docs.git synced 2025-12-24 23:22:56 +00:00

#65: Add subject and identifier metadata

This commit is contained in:
jendib
2016-02-13 18:47:13 +01:00
parent 509ab82745
commit 34d1422868
14 changed files with 126 additions and 156 deletions

View File

@@ -128,7 +128,8 @@ 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("creator", documentDto.getCreator());
// Add ACL
@@ -390,6 +391,8 @@ public class DocumentResource extends BaseResource {
public Response add(
@FormParam("title") String title,
@FormParam("description") String description,
@FormParam("subject") String subject,
@FormParam("identifier") String identifier,
@FormParam("tags") List<String> tagList,
@FormParam("language") String language,
@FormParam("create_date") String createDateStr) {
@@ -401,6 +404,8 @@ public class DocumentResource extends BaseResource {
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, "description", 0, 500, 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));
@@ -412,6 +417,8 @@ public class DocumentResource extends BaseResource {
document.setUserId(principal.getId());
document.setTitle(title);
document.setDescription(description);
document.setSubject(subject);
document.setIdentifier(identifier);
document.setLanguage(language);
if (createDate == null) {
document.setCreateDate(new Date());
@@ -461,6 +468,8 @@ public class DocumentResource extends BaseResource {
@PathParam("id") String id,
@FormParam("title") String title,
@FormParam("description") String description,
@FormParam("subject") String subject,
@FormParam("identifier") String identifier,
@FormParam("tags") List<String> tagList,
@FormParam("language") String language,
@FormParam("create_date") String createDateStr) {
@@ -472,6 +481,8 @@ public class DocumentResource extends BaseResource {
title = ValidationUtil.validateLength(title, "title", 1, 100, true);
language = ValidationUtil.validateLength(language, "language", 3, 3, true);
description = ValidationUtil.validateLength(description, "description", 0, 4000, true);
subject = ValidationUtil.validateLength(subject, "subject", 0, 500, true);
identifier = ValidationUtil.validateLength(identifier, "identifier", 0, 500, 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));
@@ -492,6 +503,12 @@ public class DocumentResource extends BaseResource {
if (!StringUtils.isEmpty(description)) {
document.setDescription(description);
}
if (!StringUtils.isEmpty(subject)) {
document.setSubject(subject);
}
if (!StringUtils.isEmpty(identifier)) {
document.setIdentifier(identifier);
}
if (createDate != null) {
document.setCreateDate(createDate);
}

View File

@@ -18,6 +18,20 @@
name="description" ng-model="document.description" ng-disabled="fileIsUploading"></textarea>
</div>
</div>
<div class="form-group" ng-class="{ 'has-error': !documentForm.subject.$valid }">
<label class="col-sm-2 control-label" for="inputSubject">Subject</label>
<div class="col-sm-10">
<input ng-maxlength="500" class="form-control" type="text" id="inputSubject"
placeholder="Subject" name="subject" ng-model="document.subject" ng-disabled="fileIsUploading" />
</div>
</div>
<div class="form-group" ng-class="{ 'has-error': !documentForm.identifier.$valid }">
<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="Identifier" name="identifier" ng-model="document.identifier" ng-disabled="fileIsUploading" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="inputCreateDate">Creation date</label>
<div class="col-sm-10">

View File

@@ -1,4 +1,10 @@
<p class="well-sm" ng-bind-html="document.description | newline"></p>
<dl class="dl-horizontal">
<dt ng-if="document.subject">Subject</dt>
<dd ng-if="document.subject">{{ document.subject }}</dd>
<dt ng-if="document.identifier">Identifier</dt>
<dd ng-if="document.identifier">{{ document.identifier }}</dd>
</dl>
<div ng-file-drop drag-over-class="bg-success" ng-multiple="true" allow-dir="false" ng-model="dropFiles"
accept="image/*,application/pdf,application/zip" ng-file-change="fileDropped($files, $event, $rejectedFiles)">

View File

@@ -34,6 +34,12 @@
</div>
<p ng-bind-html="document.description | newline"></p>
<dl class="dl-horizontal">
<dt ng-if="document.subject">Subject</dt>
<dd ng-if="document.subject">{{ document.subject }}</dd>
<dt ng-if="document.identifier">Identifier</dt>
<dd ng-if="document.identifier">{{ document.identifier }}</dd>
</dl>
<div class="row" ui-sortable="fileSortableOptions" ng-model="files" ng-show="files.length > 0">
<div class="col-xs-6 col-sm-4 col-md-3 col-lg-2 text-center" ng-repeat="file in files">