mirror of
https://github.com/sismics/docs.git
synced 2025-12-13 09:46:17 +00:00
#65: Add subject and identifier metadata
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
api.current_version=${project.version}
|
||||
api.min_version=1.0
|
||||
db.version=5
|
||||
db.version=6
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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)">
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
api.current_version=${project.version}
|
||||
api.min_version=1.0
|
||||
db.version=5
|
||||
db.version=6
|
||||
@@ -1,3 +1,3 @@
|
||||
api.current_version=${project.version}
|
||||
api.min_version=1.0
|
||||
db.version=5
|
||||
db.version=6
|
||||
@@ -62,6 +62,8 @@ public class TestDocumentResource extends BaseJerseyTest {
|
||||
.put(Entity.form(new Form()
|
||||
.param("title", "My super title document 1")
|
||||
.param("description", "My super description for document 1")
|
||||
.param("subject", "Subject document 1")
|
||||
.param("identifier", "Identifier document 1")
|
||||
.param("tags", tag1Id)
|
||||
.param("language", "eng")
|
||||
.param("create_date", Long.toString(create1Date))), JsonObject.class);
|
||||
@@ -160,6 +162,8 @@ public class TestDocumentResource extends BaseJerseyTest {
|
||||
Assert.assertEquals(1, searchDocuments("full:title", document1Token));
|
||||
Assert.assertEquals(1, searchDocuments("title", document1Token));
|
||||
Assert.assertEquals(1, searchDocuments("super description", document1Token));
|
||||
Assert.assertEquals(1, searchDocuments("subject", document1Token));
|
||||
Assert.assertEquals(1, searchDocuments("identifier", 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-dd").print(new Date().getTime()), document1Token));
|
||||
@@ -190,6 +194,8 @@ public class TestDocumentResource extends BaseJerseyTest {
|
||||
Assert.assertEquals(true, json.getBoolean("shared"));
|
||||
Assert.assertEquals("My super title document 1", json.getString("title"));
|
||||
Assert.assertEquals("My super description for document 1", json.getString("description"));
|
||||
Assert.assertEquals("Subject document 1", json.getString("subject"));
|
||||
Assert.assertEquals("Identifier document 1", json.getString("identifier"));
|
||||
Assert.assertEquals("eng", json.getString("language"));
|
||||
Assert.assertEquals(create1Date, json.getJsonNumber("create_date").longValue());
|
||||
tags = json.getJsonArray("tags");
|
||||
|
||||
Reference in New Issue
Block a user