branch develop updated (3290654 -> c615964)
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 3290654 Refs #6308 : Change information text for supervisor admin page new 4e09a96 prepare document edit service new b54a05d Merge branch 'develop' into feature/6435-modify-document new 9139630 add edit document page new b0a9c28 cannot edit document used by questions new b789cd4 fixes #6435 Merge branch 'feature/6435-modify-document' into develop new c615964 Merge branch 'develop' of https://git.codelutin.com/coselmar into develop The 6 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 c6159649a91059ac02da323514732d87f108eb2c Merge: b789cd4 3290654 Author: Yannick Martel <martel@©odelutin.com> Date: Wed Jan 21 18:16:22 2015 +0100 Merge branch 'develop' of https://git.codelutin.com/coselmar into develop commit b789cd461e14f93efc0545fbf7c75ad4de39b101 Merge: 19ba20f b0a9c28 Author: Yannick Martel <martel@©odelutin.com> Date: Wed Jan 21 18:16:07 2015 +0100 fixes #6435 Merge branch 'feature/6435-modify-document' into develop commit b0a9c2844cf0fb97a679f554e56b464269ba1ea8 Author: Yannick Martel <martel@©odelutin.com> Date: Wed Jan 21 18:16:03 2015 +0100 cannot edit document used by questions commit 91396303b4273f34348bfbfce74a715e7e2eb2d2 Author: Yannick Martel <martel@©odelutin.com> Date: Wed Jan 21 17:50:23 2015 +0100 add edit document page commit b54a05d8704d102690de5e3d57957ff23dbaec1d Merge: 4e09a96 19ba20f Author: Yannick Martel <martel@©odelutin.com> Date: Wed Jan 21 12:08:03 2015 +0100 Merge branch 'develop' into feature/6435-modify-document commit 4e09a9665c18f531809074b5a80cae3ca7deb8df Author: Yannick Martel <martel@©odelutin.com> Date: Wed Jan 21 11:57:34 2015 +0100 prepare document edit service Summary of changes: .../fr/ifremer/coselmar/beans/DocumentBean.java | 16 +++++ .../coselmar/services/v1/DocumentsWebService.java | 84 +++++++++++++++++++++- .../src/main/webapp/js/coselmar-controllers.js | 82 ++++++++++++++++++++- .../src/main/webapp/js/coselmar-services.js | 7 +- .../src/main/webapp/views/documents/document.html | 82 +-------------------- .../{newdocument.html => editDocument.html} | 80 +++++---------------- .../documents/{document.html => viewDocument.html} | 41 ++++------- 7 files changed, 211 insertions(+), 181 deletions(-) copy coselmar-ui/src/main/webapp/views/documents/{newdocument.html => editDocument.html} (75%) copy coselmar-ui/src/main/webapp/views/documents/{document.html => viewDocument.html} (67%) -- 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 4e09a9665c18f531809074b5a80cae3ca7deb8df Author: Yannick Martel <martel@©odelutin.com> Date: Wed Jan 21 11:57:34 2015 +0100 prepare document edit service --- .../coselmar/services/v1/DocumentsWebService.java | 74 +++++++++++++++++++++- 1 file changed, 72 insertions(+), 2 deletions(-) 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 9392bf6..6305cf8 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 @@ -346,8 +346,78 @@ public class DocumentsWebService extends CoselmarWebServiceSupport { } - public void saveDocument(DocumentBean documentBean) { - throw new CoselmarTechnicalException("not yet implemented"); + public void saveDocument(DocumentBean document) throws InvalidCredentialException, UnauthorizedException { + Preconditions.checkNotNull(document); + Preconditions.checkNotNull(document.getId()); + + // Check authentication + String authorization = getContext().getHeader("Authorization"); + UserWebToken userWebToken = checkAuthentication(authorization); + + String documentId = getDocumentFullId(document.getId()); + + Document documentEntity = getDocumentDao().forTopiaIdEquals(documentId).findUnique(); + + if (!isAllowedToAccessDocument(userWebToken, documentEntity)) { + + String message = String.format("User %s %s ('%s') try to modify document '%s'", + userWebToken.getFirstName(), userWebToken.getLastName(), userWebToken.getUserId(), documentId); + if (log.isWarnEnabled()) { + log.warn(message); + } + throw new UnauthorizedException(message); + + } + + boolean isUsedByQuestions = getQuestionDao().forRelatedDocumentsContains(documentEntity).exists(); + if (isUsedByQuestions) { + String message = "Document is used by some questions, cannot be modified."; + if (log.isWarnEnabled()) { + log.warn(message); + } + throw new UnauthorizedException(message); + } + + documentEntity.setName(document.getName()); + documentEntity.setPrivacy(Privacy.valueOf(document.getPrivacy().toUpperCase())); + + documentEntity.clearKeywords(); + documentEntity.addAllKeywords(document.getKeywords()); + + documentEntity.setType(document.getType()); + documentEntity.setSummary(document.getSummary()); + documentEntity.setLanguage(document.getLanguage()); + documentEntity.setPublicationDate(document.getPublicationDate()); + + // Legal / copyright part + documentEntity.setAuthors(document.getAuthors()); + documentEntity.setCopyright(document.getCopyright()); + documentEntity.setLicense(document.getLicense()); + + // Resource part + documentEntity.setExternalUrl(document.getExternalUrl()); + + documentEntity.setComment(document.getComment()); + + commit(); + + // Update index information for this document + String lightId = document.getId(); + DocumentBean result = BeanEntityConverter.toBean(lightId, documentEntity); + + DocumentsIndexationService documentsIndexationService = getServicesContext().newService(DocumentsIndexationService.class); + try { + documentsIndexationService.indexDocument(result); + if (log.isDebugEnabled()) { + String message = String.format("Document '%s' was updated in index", document.getName()); + log.debug(message); + } + } catch (IOException e) { + if (log.isErrorEnabled()) { + log.error("Unable to update document index information", e); + } + } + } public void deleteDocument(String documentId) throws InvalidCredentialException, UnauthorizedException { -- 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 b54a05d8704d102690de5e3d57957ff23dbaec1d Merge: 4e09a96 19ba20f Author: Yannick Martel <martel@©odelutin.com> Date: Wed Jan 21 12:08:03 2015 +0100 Merge branch 'develop' into feature/6435-modify-document .../coselmar/services/UsersWebServiceTest.java | 54 ++++++++++++++++++---- 1 file changed, 46 insertions(+), 8 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 91396303b4273f34348bfbfce74a715e7e2eb2d2 Author: Yannick Martel <martel@©odelutin.com> Date: Wed Jan 21 17:50:23 2015 +0100 add edit document page --- .../src/main/webapp/js/coselmar-controllers.js | 83 +++++++- .../src/main/webapp/js/coselmar-services.js | 7 +- .../src/main/webapp/views/documents/document.html | 82 +------- .../main/webapp/views/documents/editDocument.html | 227 +++++++++++++++++++++ .../documents/{document.html => viewDocument.html} | 37 +--- 5 files changed, 320 insertions(+), 116 deletions(-) diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index e1eadae..83eba95 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -149,14 +149,14 @@ coselmarControllers.controller("NewDocumentCtrl", ['$scope', '$location', 'docum if (keyword && $scope.document.keywords.indexOf(keyword) == -1) { $scope.document.keywords.push(keyword); } - } + }; $scope.removeKeyword = function(keyword) { var position = $scope.document.keywords.indexOf(keyword); if (keyword && position != -1) { $scope.document.keywords.splice(position, 1); } - } + }; }]); @@ -167,7 +167,11 @@ coselmarControllers.controller("DocumentViewCtrl", $scope.container = {baseUrl : coselmarConfig.BASE_URL}; - documentService.getDocument($routeParams.documentId, $scope); + $scope.editSession = $routeParams.edit ? $routeParams.edit : false; + + documentService.getDocument($routeParams.documentId, function(document) { + $scope.document = document; + }); $scope.deleteDocument = function(documentId){ @@ -178,6 +182,79 @@ coselmarControllers.controller("DocumentViewCtrl", }); }; + + // edit part + + $scope.canEdit = true; + + //to enter in edit mode from view + $scope.edit = function() { + $location.search("edit"); + } + + $scope.existing = {'types' : [], 'keywords' : []}; + + if ($scope.editSession == true) { + documentService.findAllTypes(function(results) { + $scope.existing.types = results; + }); + + documentService.findAllKeywords(function(results) { + $scope.existing.keywords = results; + }); + } + + $scope.isFormValid = function() { + var isValid = $scope.document.name && $scope.document.name.length > 0; + console.log(isValid); + isValid = isValid && $scope.document.type && $scope.document.type.length > 0; + isValid = isValid && $scope.document.keywords && $scope.document.keywords.length > 0; + isValid = isValid && $scope.document.authors && $scope.document.authors.length > 0; + isValid = isValid && $scope.document.copyright && $scope.document.copyright.length > 0; + isValid = isValid && $scope.document.summary && $scope.document.summary.length > 0; + if (!$scope.document.fileName) { + isValid = isValid && $scope.document.externalUrl && $scope.document.externalUrl.length > 0; + } + return isValid; + }; + + $scope.saveDocument = function(){ + + if (angular.isDate($scope.document.publicationDate)) { + $scope.document.publicationDate = $scope.document.publicationDate.getTime(); + } + + // Call service to create a new document + if ($scope.isFormValid()) { + $scope.hasErrors = false; + + documentService.saveDocument($scope.document, function() { + $location.search(""); + }, function(error) { + console.log("error occurs"); + } + ); + + } else { + $scope.hasErrors = true; + } + + }; + + $scope.addKeyword = function(keyword) { + if (keyword && $scope.document.keywords.indexOf(keyword) == -1) { + $scope.document.keywords.push(keyword); + } + }; + + $scope.removeKeyword = function(keyword) { + var position = $scope.document.keywords.indexOf(keyword); + if (keyword && position != -1) { + $scope.document.keywords.splice(position, 1); + } + }; + + } ]); // Controller for document file download diff --git a/coselmar-ui/src/main/webapp/js/coselmar-services.js b/coselmar-ui/src/main/webapp/js/coselmar-services.js index e0cebeb..76cadac 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-services.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-services.js @@ -91,13 +91,10 @@ function Document(resource, config){ docResource.upload(null, formData, successFunction, failFunction); }; - this.getDocument = function(id, scope){ + this.getDocument = function(id, successFunction){ // Load the document var docResource = resource(baseURL + '/:documentId', {documentId:'@documentId'}); - docResource.get({documentId:id}, function(document){ - console.log(document); - scope.document = document; - }); + docResource.get({documentId:id}, successFunction); }; this.deleteDocument = function(id, scope, successFunction){ diff --git a/coselmar-ui/src/main/webapp/views/documents/document.html b/coselmar-ui/src/main/webapp/views/documents/document.html index c6f382b..5ca277c 100644 --- a/coselmar-ui/src/main/webapp/views/documents/document.html +++ b/coselmar-ui/src/main/webapp/views/documents/document.html @@ -22,82 +22,6 @@ #L% --> <div style="padding: 0px 0px 0px 30px"> - <div class="page-header" style="margin: 0"> - <h1> - <!-- Heading goes here --> - Document's Details - </h1> - </div> - <div> - <table class="table table-striped"> - <tr> - <td>File Name</td> - <td>{{document.name}}</td> - </tr> - <tr> - <td>Depositor</td> - <td>{{document.ownerName}}</td> - </tr> - <tr> - <td>Type</td> - <td>{{document.type}}</td> - </tr> - <tr> - <td>Keywords</td> - <td>{{document.keywords}}</td> - </tr> - <tr> - <td>Privacy</td> - <td>{{document.privacy}}</td> - </tr> - <tr> - <td>Deposite Date</td> - <td>{{document.depositDate | date:'mediumDate'}}</td> - </tr> - <tr> - <td>Summary</td> - <td>{{document.summary}}</td> - </tr> - <tr> - <td>Authors</td> - <td>{{document.authors}}</td> - </tr> - <tr> - <td>Copyright</td> - <td>{{document.copyright}}</td> - </tr> - <tr> - <td>License</td> - <td>{{document.license}}</td> - </tr> - <tr> - <td>Language</td> - <td>{{document.language}}</td> - </tr> - <tr> - <td>PublicationDate</td> - <td>{{document.publicationDate | date:'mediumDate'}}</td> - </tr> - <tr> - <td>Document type</td> - <td ng-if="document.withFile">{{document.mimeType}}</td> - <td ng-if="!document.withFile">External Link</td> - </tr> - <tr ng-if="document.withFile && document.fileName"> - <td>Document File</td> - <td>{{document.fileName}}</td> - </tr> - <tr> - <td>Comment</td> - <td>{{document.comment}}</td> - </tr> - </table> - <div class="float-right"> - <a href="{{container.baseUrl}}/documents/{{document.id}}/file" class="btn btn-primary" ng-if="document.withFile">Download</a> - <a href="{{document.externalUrl}}" target="_blank" class="btn btn-primary" ng-if="document.externalUrl">Open Link</a> - <a class="btn btn-danger" - ng-confirm-message="Do you really want to delete this document ?" - ng-confirm-click="deleteDocument(document.id)">Delete</a> - </div> - </div> -</div> \ No newline at end of file + <div ng-include="src='views/documents/viewDocument.html'" ng-if="editSession != true" /> + <div ng-include="src='views/documents/editDocument.html'" ng-if="editSession == true" /> +</div> diff --git a/coselmar-ui/src/main/webapp/views/documents/editDocument.html b/coselmar-ui/src/main/webapp/views/documents/editDocument.html new file mode 100644 index 0000000..af40a5f --- /dev/null +++ b/coselmar-ui/src/main/webapp/views/documents/editDocument.html @@ -0,0 +1,227 @@ + <div class="page-header" style="margin: 0"> + <h2>{{document.name}}</h2> + </div> + + <div style="padding-bottom: 50px"> + + <div class=""> + + <form class="form-horizontal" name="documentForm" role="form" > + + <!-- Line with Title, type and privacy --> + <div class="form-group row"> + <div ng-class="{'has-error' : documentForm.name.$invalid && !documentForm.name.$pristine}"> + <label class="col-md-2 control-label">Name *</label> + + <div class="col-md-4"> + <input type="text" class="form-control" name="name" + placeholder="Document Name" + ng-model="document.name" required/> + + <p ng-show="documentForm.name.$invalid && !documentForm.name.$pristine" + class="help-block">Document name is required.</p> + </div> + </div> + + <div class="" + ng-class="{'has-error' : documentForm.type.$invalid && !documentForm.type.$pristine}"> + <label class="col-md-1 control-label">Type *</label> + + <div class="col-md-2"> + <input type="text" class="form-control" name="type" + data-ng-model="document.type" list="existingTypes" required/> + + <p ng-show="documentForm.type.$invalid && !documentForm.type.$pristine" + class="help-block">Document type is required.</p> + </div> + <datalist id="existingTypes"> + <option data-ng-repeat="type in existing.types" value="{{type}}"> + </datalist> + </div> + + <div> + + <label class="col-md-1 control-label">Privacy</label> + + <div class="col-md-2"> + <input type="text" class="form-control" name="type" + data-ng-model="document.privacy" disabled="disabled"/> + </div> + </div> + </div> + + <!-- Line with Data : file or External URL --> + <div class="form-group" + ng-class="{'has-error' : !document.externalUrl + && !documentForm.externalUrl.$pristine && !document.fileName}"> + + <div> + <label class="col-md-2 control-label">File</label> + + <div class="col-md-4"> + <input type="text" class="form-control" name="fileName" + data-ng-model="document.fileName" disabled="disabled" /> + </div> + </div> + + <div> + <label class="col-md-2 control-label">External URL</label> + + <div class="col-md-4"> + <input type="input" class="form-control" name="externalUrl" + placeholder="http://website" + ng-model="document.externalUrl" /> + + </div> + </div> + <p ng-show="!document.externalUrl && !documentForm.externalUrl.$pristine && !document.fileName" + class="help-block text-center clear">For this document, an external URL is required.</p> + </div> + + <!-- Line with Keywords --> + <div class="form-group"> + <div ng-class="{'has-error' : documentForm.keywords.$invalid + && !documentForm.keywords.$pristine}"> + + <label class="col-md-2 control-label">keywords *</label> + + <div class="col-md-2"> + <input type="text" class="form-control" name="keywords" + placeholder="Validate with add" + ng-model="toAddKeyword" list="existingKeywords" /> + + <p ng-show="document.keywords.length < 1 && !documentForm.keywords.$pristine" + class="help-block">At least one keyword is required.</p> + </div> + <datalist id="existingKeywords"> + <option data-ng-repeat="keyword in existing.keywords" value="{{keyword}}"> + </datalist> + </div> + + <div class="col-md-1"> + <button class="btn btn-primary" value="add" + ng-click="addKeyword(toAddKeyword); toAddKeyword=''">add</button> + </div> + + + <div class="col-md-7"> + <span ng-repeat="keyword in document.keywords" class="" aria-hidden="true"> + {{keyword}} + <button type="button" class="close" title="remove" ng-click="removeKeyword(keyword);"> + × + </button> + </span> + + </div> + </div> + + <!-- Line with Authors and copyright--> + <div class="form-group"> + <div ng-class="{'has-error' : documentForm.authors.$invalid + && !documentForm.authors.$pristine}"> + <label class="col-md-2 control-label">Authors *</label> + + <div class="col-md-4"> + <input type="text" class="form-control" name="authors" + placeholder="Name FirstName" + ng-model="document.authors" required/> + + <p ng-show="documentForm.authors.$invalid && !documentForm.authors.$pristine" + class="help-block">Document authors is required.</p> + </div> + </div> + + <div ng-class="{'has-error' : documentForm.copyright.$invalid + && !documentForm.copyright.$pristine}"> + + <label class="col-md-2 control-label">Copyright *</label> + + <div class="col-md-4"> + <input type="text" class="form-control" name="copyright" + placeholder="Copyright owner" + ng-model="document.copyright" required/> + + <p ng-show="documentForm.copyright.$invalid && !documentForm.copyright.$pristine" + class="help-block">Copyright is required.</p> + </div> + </div> + </div> + + <!-- Line with License, publication date and language --> + <div class="form-group"> + <div > + <label class="col-md-2 control-label">Licence</label> + + <div class="col-md-4"> + <input type="text" class="form-control" name="licence" + placeholder="License of document" + ng-model="document.licence"/> + </div> + </div> + + <div> + <label class="col-md-1 control-label">Language</label> + + <div class="col-md-1"> + <input type="text" class="form-control" name="language" + placeholder="en,fr,..." + ng-model="document.language"/> + </div> + </div> + + <div> + <label class="col-md-2 control-label">Publication date</label> + + <div class="col-md-2"> + <div class="input-group"> + <input type="text" class="form-control" name="publicationDate" + placeholder="dd/MM/yyyy" + ng-model="document.publicationDate" + datepicker-popup="dd/MM/yyyy" is-open="publicationDateOpened" + ng-click="publicationDateOpened = true"/> + <span class="input-group-addon"><span class="glyphicon glyphicon-calendar" aria-hidden="true"></span></span> + </div> + </div> + + </div> + </div> + + <!-- Summary --> + <div class="form-group" + ng-class="{'has-error' : documentForm.summary.$invalid && !documentForm.summary.$pristine}"> + <label class="col-md-2 control-label">Summary *</label> + + <div class="col-md-10"> + <textarea type="text" class="form-control" name="summary" rows="5" + placeholder="Tape the document summary, it will help to retrieve document" + ng-model="document.summary" required/> + + <p ng-show="documentForm.summary.$invalid && !documentForm.summary.$pristine" + class="help-block">A summary is required.</p> + </div> + </div> + + <!-- Comment --> + <div class="form-group" > + <label class="col-md-2 control-label">Comment</label> + + <div class="col-md-10"> + <textarea type="text" class="form-control" name="comment" rows="5" + ng-model="document.comment" /> + + </div> + </div> + + <div class="form-group"> + <div ng-if="hasErrors" class="has-error"> + <div class="text-center help-block">Some mandatory fields (*) have not been filled.</div> + </div> + <div class="float-right col-md-4"> + <input type="submit" value="Submit" class="btn btn-action btn-success" + ng-click="saveDocument()" /> + </div> + </div> + </form> + </div> + + </div> diff --git a/coselmar-ui/src/main/webapp/views/documents/document.html b/coselmar-ui/src/main/webapp/views/documents/viewDocument.html similarity index 67% copy from coselmar-ui/src/main/webapp/views/documents/document.html copy to coselmar-ui/src/main/webapp/views/documents/viewDocument.html index c6f382b..e604b4f 100644 --- a/coselmar-ui/src/main/webapp/views/documents/document.html +++ b/coselmar-ui/src/main/webapp/views/documents/viewDocument.html @@ -1,27 +1,4 @@ -<!-- - #%L - Coselmar :: UI - $Id:$ - $HeadURL:$ - %% - Copyright (C) 2014 Ifremer, Code Lutin - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program. If not, see - <http://www.gnu.org/licenses/gpl-3.0.html>. - #L% - --> -<div style="padding: 0px 0px 0px 30px"> + <div class="page-header" style="margin: 0"> <h1> <!-- Heading goes here --> @@ -93,11 +70,13 @@ </tr> </table> <div class="float-right"> - <a href="{{container.baseUrl}}/documents/{{document.id}}/file" class="btn btn-primary" ng-if="document.withFile">Download</a> - <a href="{{document.externalUrl}}" target="_blank" class="btn btn-primary" ng-if="document.externalUrl">Open Link</a> - <a class="btn btn-danger" + <a class="btn btn-action btn-edit" ng-click="edit()" ng-if="editSession != true && canEdit"> + <span class="fa fa-edit" aria-hidden="true"></span>Edit + </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" ng-confirm-message="Do you really want to delete this document ?" ng-confirm-click="deleteDocument(document.id)">Delete</a> </div> - </div> -</div> \ No newline at end of file + </div> \ No newline at end of file -- 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 b0a9c2844cf0fb97a679f554e56b464269ba1ea8 Author: Yannick Martel <martel@©odelutin.com> Date: Wed Jan 21 18:16:03 2015 +0100 cannot edit document used by questions --- .../java/fr/ifremer/coselmar/beans/DocumentBean.java | 16 ++++++++++++++++ .../coselmar/services/v1/DocumentsWebService.java | 10 ++++++++++ coselmar-ui/src/main/webapp/js/coselmar-controllers.js | 3 +-- .../src/main/webapp/views/documents/viewDocument.html | 4 ++++ 4 files changed, 31 insertions(+), 2 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 2b60237..6726a35 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 @@ -56,6 +56,7 @@ public class DocumentBean implements Serializable { protected boolean withFile; protected String mimeType; protected String externalUrl; + protected Set<QuestionBean> relatedQuestions; public DocumentBean(String id, String name, String ownerName, String privacy, Date depositDate, Collection<String> keywords, @@ -246,4 +247,19 @@ public class DocumentBean implements Serializable { public void setComment(String comment) { this.comment = comment; } + + public Set<QuestionBean> getRelatedQuestions() { + return relatedQuestions; + } + + public void setRelatedQuestions(Set<QuestionBean> relatedQuestions) { + this.relatedQuestions = relatedQuestions; + } + + public void addRelatedQuestion(QuestionBean relatedQuestion) { + if (this.relatedQuestions == null) { + this.relatedQuestions = new HashSet<>(); + } + this.relatedQuestions.add(relatedQuestion); + } } 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 6305cf8..53def42 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 @@ -37,12 +37,14 @@ import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import fr.ifremer.coselmar.beans.DocumentBean; +import fr.ifremer.coselmar.beans.QuestionBean; import fr.ifremer.coselmar.beans.UserWebToken; import fr.ifremer.coselmar.converter.BeanEntityConverter; import fr.ifremer.coselmar.persistence.entity.CoselmarUser; import fr.ifremer.coselmar.persistence.entity.CoselmarUserRole; import fr.ifremer.coselmar.persistence.entity.Document; import fr.ifremer.coselmar.persistence.entity.Privacy; +import fr.ifremer.coselmar.persistence.entity.Question; import fr.ifremer.coselmar.services.CoselmarTechnicalException; import fr.ifremer.coselmar.services.CoselmarWebServiceSupport; import fr.ifremer.coselmar.services.errors.InvalidCredentialException; @@ -103,6 +105,14 @@ public class DocumentsWebService extends CoselmarWebServiceSupport { } DocumentBean documentBean = BeanEntityConverter.toBean(documentId, document); + + // Manage related Question + List<Question> relatedQuestions = getQuestionDao().forRelatedDocumentsContains(document).findAll(); + for (Question relatedQuestion : relatedQuestions) { + QuestionBean questionBean = BeanEntityConverter.toLightBean(getPersistenceContext().getTopiaIdFactory(), relatedQuestion); + documentBean.addRelatedQuestion(questionBean); + } + return documentBean; } diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index 83eba95..935beec 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -171,6 +171,7 @@ coselmarControllers.controller("DocumentViewCtrl", documentService.getDocument($routeParams.documentId, function(document) { $scope.document = document; + $scope.canEdit = !(document.relatedQuestions && document.relatedQuestions.length > 0); }); $scope.deleteDocument = function(documentId){ @@ -185,8 +186,6 @@ coselmarControllers.controller("DocumentViewCtrl", // edit part - $scope.canEdit = true; - //to enter in edit mode from view $scope.edit = function() { $location.search("edit"); diff --git a/coselmar-ui/src/main/webapp/views/documents/viewDocument.html b/coselmar-ui/src/main/webapp/views/documents/viewDocument.html index e604b4f..62899cc 100644 --- a/coselmar-ui/src/main/webapp/views/documents/viewDocument.html +++ b/coselmar-ui/src/main/webapp/views/documents/viewDocument.html @@ -68,6 +68,10 @@ <td>Comment</td> <td>{{document.comment}}</td> </tr> + <tr> + <td>Questions with the document</td> + <td>{{document.relatedQuestions.length || 0}}</td> + </tr> </table> <div class="float-right"> <a class="btn btn-action btn-edit" ng-click="edit()" ng-if="editSession != true && canEdit"> -- 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 b789cd461e14f93efc0545fbf7c75ad4de39b101 Merge: 19ba20f b0a9c28 Author: Yannick Martel <martel@©odelutin.com> Date: Wed Jan 21 18:16:07 2015 +0100 fixes #6435 Merge branch 'feature/6435-modify-document' into develop .../fr/ifremer/coselmar/beans/DocumentBean.java | 16 ++ .../coselmar/services/v1/DocumentsWebService.java | 84 +++++++- .../src/main/webapp/js/coselmar-controllers.js | 82 +++++++- .../src/main/webapp/js/coselmar-services.js | 7 +- .../src/main/webapp/views/documents/document.html | 82 +------- .../main/webapp/views/documents/editDocument.html | 227 +++++++++++++++++++++ .../documents/{document.html => viewDocument.html} | 41 ++-- 7 files changed, 421 insertions(+), 118 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 c6159649a91059ac02da323514732d87f108eb2c Merge: b789cd4 3290654 Author: Yannick Martel <martel@©odelutin.com> Date: Wed Jan 21 18:16:22 2015 +0100 Merge branch 'develop' of https://git.codelutin.com/coselmar into develop coselmar-ui/src/main/webapp/views/users/newuser.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm