branch develop updated (d201394 -> cf4f833)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git from d201394 Refs #6440 : Update display of user edition page new cf4f833 better filter for document edit and delete The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit cf4f833c60b8038cdb9a89cd726ef71762d7ec45 Author: Yannick Martel <martel@©odelutin.com> Date: Thu Jan 22 10:43:22 2015 +0100 better filter for document edit and delete Summary of changes: .../java/fr/ifremer/coselmar/beans/DocumentBean.java | 12 +++++++++++- .../ifremer/coselmar/converter/BeanEntityConverter.java | 14 +++++++++----- .../fr/ifremer/coselmar/services/v1/AdminWebService.java | 2 +- .../coselmar/services/v1/DocumentsWebService.java | 8 ++++---- .../indexation/DocumentsIndexationServiceTest.java | 16 ++++++++-------- coselmar-ui/src/main/webapp/js/coselmar-controllers.js | 1 + .../src/main/webapp/views/documents/documents.html | 4 ++-- .../src/main/webapp/views/documents/viewDocument.html | 2 +- 8 files changed, 37 insertions(+), 22 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit cf4f833c60b8038cdb9a89cd726ef71762d7ec45 Author: Yannick Martel <martel@©odelutin.com> Date: Thu Jan 22 10:43:22 2015 +0100 better filter for document edit and delete --- .../java/fr/ifremer/coselmar/beans/DocumentBean.java | 12 +++++++++++- .../ifremer/coselmar/converter/BeanEntityConverter.java | 14 +++++++++----- .../fr/ifremer/coselmar/services/v1/AdminWebService.java | 2 +- .../coselmar/services/v1/DocumentsWebService.java | 8 ++++---- .../indexation/DocumentsIndexationServiceTest.java | 16 ++++++++-------- coselmar-ui/src/main/webapp/js/coselmar-controllers.js | 1 + .../src/main/webapp/views/documents/documents.html | 4 ++-- .../src/main/webapp/views/documents/viewDocument.html | 2 +- 8 files changed, 37 insertions(+), 22 deletions(-) diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/DocumentBean.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/DocumentBean.java index 6726a35..76ec1db 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/DocumentBean.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/DocumentBean.java @@ -39,6 +39,7 @@ public class DocumentBean implements Serializable { protected String id; protected String name; protected String ownerName; + protected String ownerId; protected String privacy; protected Set<String> keywords; protected Date depositDate; @@ -58,7 +59,7 @@ public class DocumentBean implements Serializable { protected String externalUrl; protected Set<QuestionBean> relatedQuestions; - public DocumentBean(String id, String name, String ownerName, String privacy, + public DocumentBean(String id, String name, String ownerName, String ownerId, String privacy, Date depositDate, Collection<String> keywords, String type, String summary, String language, Date publicationDate, String authors, String license, String copyright, @@ -67,6 +68,7 @@ public class DocumentBean implements Serializable { this.id = id; this.name = name; this.ownerName = ownerName; + this.ownerId = ownerId; this.privacy = privacy; if (depositDate != null) { this.depositDate = new Date(depositDate.getTime()); @@ -117,6 +119,14 @@ public class DocumentBean implements Serializable { this.ownerName = ownerName; } + public String getOwnerId() { + return ownerId; + } + + public void setOwnerId(String ownerId) { + this.ownerId = ownerId; + } + public String getPrivacy() { return privacy; } diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/converter/BeanEntityConverter.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/converter/BeanEntityConverter.java index 3dc4765..4c9ce3b 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/converter/BeanEntityConverter.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/converter/BeanEntityConverter.java @@ -46,21 +46,26 @@ import org.nuiton.topia.persistence.TopiaIdFactory; */ public class BeanEntityConverter { - public static DocumentBean toBean(String lightId, Document document) { + public static DocumentBean toBean(TopiaIdFactory idFactory, Document document) { + String lightId = idFactory.getRandomPart(document.getTopiaId()); Date depositeDate = document.getDepositDate(); Date publicationDate = document.getPublicationDate(); CoselmarUser documentOwner = document.getOwner(); String owner = "N/A"; + String ownerId = "N/A"; if (documentOwner != null) { String firstname = documentOwner.getFirstname(); String lastname = documentOwner.getName(); owner = StringUtils.defaultString(firstname) + StringUtils.defaultString(lastname); + + ownerId = idFactory.getRandomPart(documentOwner.getTopiaId()); } return new DocumentBean(lightId, document.getName(), owner, + ownerId, document.getPrivacy().name(), depositeDate, document.getKeywords(), @@ -181,8 +186,7 @@ public class BeanEntityConverter { Collection<Document> relatedDocuments = question.getRelatedDocuments(); if (relatedDocuments != null && !relatedDocuments.isEmpty()) { for (Document relatedDocument : relatedDocuments) { - String lightId = idFactory.getRandomPart(relatedDocument.getTopiaId()); - DocumentBean documentBean = toBean(lightId, relatedDocument); + DocumentBean documentBean = toBean(idFactory, relatedDocument); result.addRelatedDocument(documentBean); } } @@ -200,7 +204,7 @@ public class BeanEntityConverter { if (closingDocuments != null && !closingDocuments.isEmpty()) { for (Document relatedDocument : closingDocuments) { String lightId = idFactory.getRandomPart(relatedDocument.getTopiaId()); - DocumentBean documentBean = toBean(lightId, relatedDocument); + DocumentBean documentBean = toBean(idFactory, relatedDocument); result.addClosingDocument(documentBean); } } @@ -244,7 +248,7 @@ public class BeanEntityConverter { if (closingDocuments != null && !closingDocuments.isEmpty()) { for (Document relatedDocument : closingDocuments) { String lightId = idFactory.getRandomPart(relatedDocument.getTopiaId()); - DocumentBean documentBean = toBean(lightId, relatedDocument); + DocumentBean documentBean = toBean(idFactory, relatedDocument); result.addClosingDocument(documentBean); } } diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/AdminWebService.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/AdminWebService.java index 6a158ba..0bbad15 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/AdminWebService.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/AdminWebService.java @@ -77,7 +77,7 @@ public class AdminWebService extends CoselmarWebServiceSupport { List<Document> documents = getDocumentDao().findAll(); for (Document document : documents) { String lightId = getPersistenceContext().getTopiaIdFactory().getRandomPart(document.getTopiaId()); - DocumentBean documentBean = BeanEntityConverter.toBean(lightId, document); + DocumentBean documentBean = BeanEntityConverter.toBean(getPersistenceContext().getTopiaIdFactory(), document); documentsIndexationService.indexDocument(documentBean); } diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/DocumentsWebService.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/DocumentsWebService.java index 53def42..01e6041 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/DocumentsWebService.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/DocumentsWebService.java @@ -104,7 +104,7 @@ public class DocumentsWebService extends CoselmarWebServiceSupport { } - DocumentBean documentBean = BeanEntityConverter.toBean(documentId, document); + DocumentBean documentBean = BeanEntityConverter.toBean(getPersistenceContext().getTopiaIdFactory(), document); // Manage related Question List<Question> relatedQuestions = getQuestionDao().forRelatedDocumentsContains(document).findAll(); @@ -161,7 +161,7 @@ public class DocumentsWebService extends CoselmarWebServiceSupport { for (Document document : documentList) { String lightId = getPersistenceContext().getTopiaIdFactory().getRandomPart(document.getTopiaId()); - DocumentBean documentBean = BeanEntityConverter.toBean(lightId, document); + DocumentBean documentBean = BeanEntityConverter.toBean(getPersistenceContext().getTopiaIdFactory(), document); result.add(documentBean); } @@ -254,7 +254,7 @@ public class DocumentsWebService extends CoselmarWebServiceSupport { commit(); String lightId = getPersistenceContext().getTopiaIdFactory().getRandomPart(documentEntity.getTopiaId()); - DocumentBean result = BeanEntityConverter.toBean(lightId, documentEntity); + DocumentBean result = BeanEntityConverter.toBean(getPersistenceContext().getTopiaIdFactory(), documentEntity); DocumentsIndexationService documentsIndexationService = getServicesContext().newService(DocumentsIndexationService.class); try { @@ -413,7 +413,7 @@ public class DocumentsWebService extends CoselmarWebServiceSupport { // Update index information for this document String lightId = document.getId(); - DocumentBean result = BeanEntityConverter.toBean(lightId, documentEntity); + DocumentBean result = BeanEntityConverter.toBean(getPersistenceContext().getTopiaIdFactory(), documentEntity); DocumentsIndexationService documentsIndexationService = getServicesContext().newService(DocumentsIndexationService.class); try { diff --git a/coselmar-rest/src/test/java/fr/ifremer/coselmar/services/indexation/DocumentsIndexationServiceTest.java b/coselmar-rest/src/test/java/fr/ifremer/coselmar/services/indexation/DocumentsIndexationServiceTest.java index 13746ef..eff808f 100644 --- a/coselmar-rest/src/test/java/fr/ifremer/coselmar/services/indexation/DocumentsIndexationServiceTest.java +++ b/coselmar-rest/src/test/java/fr/ifremer/coselmar/services/indexation/DocumentsIndexationServiceTest.java @@ -62,7 +62,7 @@ public class DocumentsIndexationServiceTest extends AbstractCoselmarServiceTest serviceContext.newService(DocumentsIndexationService.class); DocumentBean documentOne = new DocumentBean("document1", - "Ceci n'est pas un document", "John Doe", Privacy.PUBLIC.name(), + "Ceci n'est pas un document", "John Doe", "user001", Privacy.PUBLIC.name(), new Date(), Lists.newArrayList("document", "test"), "testDocument", "This is not a fake document used for test", "fr", null, "Jack, Jane", null, null, false, null, "http://somewhere", "no comment", null); @@ -105,7 +105,7 @@ public class DocumentsIndexationServiceTest extends AbstractCoselmarServiceTest serviceContext.newService(DocumentsIndexationService.class); DocumentBean documentOne = new DocumentBean("document1", - "Ceci n'est pas un document", "John Doe", Privacy.PUBLIC.name(), + "Ceci n'est pas un document", "John Doe", "user001", Privacy.PUBLIC.name(), new Date(), Lists.newArrayList("document", "test"), "testDocument", "This is not a fake document used for test", "fr", null, "Jack, Jane", null, null, false, null, "http://somewhere", "no comment", null); @@ -128,7 +128,7 @@ public class DocumentsIndexationServiceTest extends AbstractCoselmarServiceTest Assert.assertEquals("document1", documentMatchingPartOfSummaryIds.get(0)); documentOne = new DocumentBean("document1", - "Doc Premier", "John Doe", Privacy.PUBLIC.name(), + "Doc Premier", "John Doe", "user001", Privacy.PUBLIC.name(), new Date(), Lists.newArrayList("test", "update"), "testDocument", "This is a fake doc updated for test", "fr", null, "James, JJ", null, null, false, null, "http://somewhere", "no comment", null); @@ -199,7 +199,7 @@ public class DocumentsIndexationServiceTest extends AbstractCoselmarServiceTest String documentOneId = "testSearchMultiple_document1"; DocumentBean documentOne = new DocumentBean(documentOneId, - "Ceci n'est pas un document", "John Doe", Privacy.PUBLIC.name(), + "Ceci n'est pas un document", "John Doe", "user001", Privacy.PUBLIC.name(), new Date(), Lists.newArrayList("document", "test"), "testDocument", "This is not a fake document used for test", "fr", null, "Jack, Jane", null, null, false, null, "http://somewhere", "no comment", null); @@ -209,7 +209,7 @@ public class DocumentsIndexationServiceTest extends AbstractCoselmarServiceTest String documentTwoId = "testSearchMultiple_document2"; DocumentBean documentTwo = new DocumentBean(documentTwoId, - "Tardis documentation", "The Doctor", Privacy.PUBLIC.name(), + "Tardis documentation", "The Doctor", "user003", Privacy.PUBLIC.name(), new Date(), Lists.newArrayList("tardis", "documentation", "old", "new", "borrowed", "blue"), "testDocument", "This is part of document about the TARDIS", "fr", null, "The Doctor, Rose, Amy, River, Clara", null, null, false, null, "http://tardis.wikia.com/wiki/TARDIS", "no comment", null); @@ -243,7 +243,7 @@ public class DocumentsIndexationServiceTest extends AbstractCoselmarServiceTest serviceContext.newService(DocumentsIndexationService.class); DocumentBean documentOne = new DocumentBean("document1", - "Ceci n'est pas un document", "John Doe", Privacy.PUBLIC.name(), + "Ceci n'est pas un document", "John Doe", "user001", Privacy.PUBLIC.name(), new Date(), Lists.newArrayList("document", "test"), "testDocument", "This is not a fake document used for test", "fr", null, "Jack, Jane", null, null, false, null, "http://somewhere", "no comment", null); @@ -251,7 +251,7 @@ public class DocumentsIndexationServiceTest extends AbstractCoselmarServiceTest documentsIndexationService.indexDocument(documentOne); DocumentBean documentTwo = new DocumentBean("document2", - "Another document", "Amy Pond", Privacy.PUBLIC.name(), + "Another document", "Amy Pond", "user002", Privacy.PUBLIC.name(), new Date(), Lists.newArrayList("document", "test", "fish"), "testDocument", "This is just an other document used for test", "fr", null, "Amy, Rory", null, null, false, null, "http://somewhere", "no comment", null); @@ -259,7 +259,7 @@ public class DocumentsIndexationServiceTest extends AbstractCoselmarServiceTest documentsIndexationService.indexDocument(documentTwo); DocumentBean documentThree = new DocumentBean("document3", - "Tardis documentation", "The Doctor", Privacy.PUBLIC.name(), + "Tardis documentation", "The Doctor", "user003", Privacy.PUBLIC.name(), new Date(), Lists.newArrayList("tardis", "documentation", "old", "new", "borrowed", "blue"), "testDocument", "This is part of documentation about the TARDIS", "fr", null, "The Doctor, Rose, Amy, River, Clara", null, null, false, null, "http://tardis.wikia.com/wiki/TARDIS", "no comment", null); diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index 935beec..a46cd87 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -172,6 +172,7 @@ coselmarControllers.controller("DocumentViewCtrl", documentService.getDocument($routeParams.documentId, function(document) { $scope.document = document; $scope.canEdit = !(document.relatedQuestions && document.relatedQuestions.length > 0); + $scope.canEdit = $scope.canEdit && ($scope.currentUser.role == 'ADMIN' || $scope.currentUser.role == 'SUPERVISOR' || $scope.currentUser.userId == document.ownerId); }); $scope.deleteDocument = function(documentId){ diff --git a/coselmar-ui/src/main/webapp/views/documents/documents.html b/coselmar-ui/src/main/webapp/views/documents/documents.html index 524653e..5fa2d56 100644 --- a/coselmar-ui/src/main/webapp/views/documents/documents.html +++ b/coselmar-ui/src/main/webapp/views/documents/documents.html @@ -62,8 +62,8 @@ <td><span ng-repeat="keyword in document.keywords">{{keyword}} ,</span></td> <td>{{document.ownerName}}</td> <td>{{document.depositDate | date:'mediumDate'}}</td> - <td>N/A</td> - <td><a class="btn btn-action btn-disable" + <td class="text-center">{{document.relatedQuestions.length || 0}}</td> + <td ng-if="currentUser.role == 'ADMIN'"><a class="btn btn-action btn-disable" ng-confirm-message="Do you really want to delete this document ?" ng-confirm-click="deleteDocument(document.id)"> <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>Delete</a> diff --git a/coselmar-ui/src/main/webapp/views/documents/viewDocument.html b/coselmar-ui/src/main/webapp/views/documents/viewDocument.html index 62899cc..34313b4 100644 --- a/coselmar-ui/src/main/webapp/views/documents/viewDocument.html +++ b/coselmar-ui/src/main/webapp/views/documents/viewDocument.html @@ -79,7 +79,7 @@ </a> <a href="{{container.baseUrl}}/documents/{{document.id}}/file" class="btn btn-action btn-success" ng-if="document.withFile">Download</a> <a href="{{document.externalUrl}}" target="_blank" class="btn btn-action btn-success" ng-if="document.externalUrl">Open Link</a> - <a class="btn btn-action btn-disable" + <a class="btn btn-action btn-disable" ng-if="currentUser.role == 'ADMIN'" ng-confirm-message="Do you really want to delete this document ?" ng-confirm-click="deleteDocument(document.id)">Delete</a> </div> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm