diff --git a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/DocumentDao.java b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/DocumentDao.java index c2e3337c..b84df3d9 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/DocumentDao.java +++ b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/DocumentDao.java @@ -202,9 +202,14 @@ public class DocumentDao { StringBuilder sb = new StringBuilder("select distinct d.DOC_ID_C c0, d.DOC_TITLE_C c1, d.DOC_DESCRIPTION_C c2, d.DOC_CREATEDATE_D c3, d.DOC_LANGUAGE_C c4, "); sb.append(" (select count(s.SHA_ID_C) from T_SHARE s, T_ACL ac where ac.ACL_SOURCEID_C = d.DOC_ID_C and ac.ACL_TARGETID_C = s.SHA_ID_C and ac.ACL_DELETEDATE_D is null and s.SHA_DELETEDATE_D is null) c5, "); - sb.append(" (select count(f.FIL_ID_C) from T_FILE f where f.FIL_DELETEDATE_D is null and f.FIL_IDDOC_C = d.DOC_ID_C) c6 "); + sb.append(" (select count(f.FIL_ID_C) from T_FILE f where f.FIL_DELETEDATE_D is null and f.FIL_IDDOC_C = d.DOC_ID_C) c6, "); + sb.append(" rs2.RTP_ID_C c7 "); sb.append(" from T_DOCUMENT d "); - + sb.append(" left join (select rs.*, rs3.idDocument\n" + + "from T_ROUTE_STEP rs \n" + + "join (select r.RTE_IDDOCUMENT_C idDocument, rs.RTP_IDROUTE_C idRoute, min(rs.RTP_ORDER_N) minOrder from T_ROUTE_STEP rs join T_ROUTE r on r.RTE_ID_C = rs.RTP_IDROUTE_C and r.RTE_DELETEDATE_D is null where rs.RTP_DELETEDATE_D is null and rs.RTP_ENDDATE_D is null group by rs.RTP_IDROUTE_C, r.RTE_IDDOCUMENT_C) rs3 on rs.RTP_IDROUTE_C = rs3.idRoute and rs.RTP_ORDER_N = rs3.minOrder \n" + + "where rs.RTP_IDTARGET_C in (:targetIdList)) rs2 on rs2.idDocument = d.DOC_ID_C "); + // Add search criterias if (criteria.getTargetIdList() != null) { // Read permission is enough for searching @@ -251,7 +256,10 @@ public class DocumentDao { criteriaList.add("d.DOC_IDUSER_C = :creatorId"); parameterMap.put("creatorId", criteria.getCreatorId()); } - + if (criteria.getActiveRoute() != null && criteria.getActiveRoute()) { + criteriaList.add("rs2.RTP_ID_C is not null"); + } + criteriaList.add("d.DOC_DELETEDATE_D is null"); if (!criteriaList.isEmpty()) { @@ -274,7 +282,8 @@ public class DocumentDao { documentDto.setCreateTimestamp(((Timestamp) o[i++]).getTime()); documentDto.setLanguage((String) o[i++]); documentDto.setShared(((Number) o[i++]).intValue() > 0); - documentDto.setFileCount(((Number) o[i]).intValue()); + documentDto.setFileCount(((Number) o[i++]).intValue()); + documentDto.setActiveRoute(o[i] != null); documentDtoList.add(documentDto); } diff --git a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/criteria/DocumentCriteria.java b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/criteria/DocumentCriteria.java index a05f73fc..b39cf87f 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/criteria/DocumentCriteria.java +++ b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/criteria/DocumentCriteria.java @@ -54,6 +54,11 @@ public class DocumentCriteria { * Creator ID. */ private String creatorId; + + /** + * A route is active. + */ + private Boolean activeRoute; public List getTargetIdList() { return targetIdList; @@ -126,4 +131,13 @@ public class DocumentCriteria { public void setCreatorId(String creatorId) { this.creatorId = creatorId; } + + public Boolean getActiveRoute() { + return activeRoute; + } + + public DocumentCriteria setActiveRoute(Boolean activeRoute) { + this.activeRoute = activeRoute; + return this; + } } diff --git a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/dto/DocumentDto.java b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/dto/DocumentDto.java index 64009a0e..b0bf8447 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/dto/DocumentDto.java +++ b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/dto/DocumentDto.java @@ -85,7 +85,12 @@ public class DocumentDto { * Document creator. */ private String creator; - + + /** + * A route is active. + */ + private boolean activeRoute; + public String getId() { return id; } @@ -213,4 +218,13 @@ public class DocumentDto { public void setCreator(String creator) { this.creator = creator; } + + public boolean isActiveRoute() { + return activeRoute; + } + + public DocumentDto setActiveRoute(boolean activeRoute) { + this.activeRoute = activeRoute; + return this; + } } diff --git a/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java b/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java index 30ffa7cf..46ba2ccf 100644 --- a/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java +++ b/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java @@ -333,6 +333,7 @@ public class DocumentResource extends BaseResource { * @apiSuccess {Number} documents.create_date Create date (timestamp) * @apiSuccess {String} documents.language Language * @apiSuccess {Boolean} documents.shared True if the document is shared + * @apiSuccess {Boolean} documents.active_route True if a route is active on this document * @apiSuccess {Number} documents.file_count Number of files in this document * @apiSuccess {Object[]} documents.tags List of tags * @apiSuccess {String} documents.tags.id ID @@ -397,6 +398,7 @@ public class DocumentResource extends BaseResource { .add("create_date", documentDto.getCreateTimestamp()) .add("language", documentDto.getLanguage()) .add("shared", documentDto.getShared()) + .add("active_route", documentDto.isActiveRoute()) .add("file_count", documentDto.getFileCount()) .add("tags", tags)); } @@ -514,6 +516,12 @@ public class DocumentResource extends BaseResource { documentCriteria.setCreatorId(user.getId()); } break; + case "workflow": + // New shared state criteria + if (params[1].equals("me")) { + documentCriteria.setActiveRoute(true); + } + break; case "full": // New full content search criteria fullQuery.add(params[1]); diff --git a/docs-web/src/main/webapp/src/app/docs/controller/document/Document.js b/docs-web/src/main/webapp/src/app/docs/controller/document/Document.js index f63be117..4ec2df83 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/document/Document.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/document/Document.js @@ -200,6 +200,12 @@ angular.module('docs').controller('Document', function ($scope, $rootScope, $tim return s + 'tag:' + t.name + ' '; }, ''); } + if ($scope.advsearch.shared) { + search += 'shared:yes '; + } + if ($scope.advsearch.workflow) { + search += 'workflow:me '; + } $scope.search = search; $scope.searchOpened = false; }; diff --git a/docs-web/src/main/webapp/src/index.html b/docs-web/src/main/webapp/src/index.html index 303592ea..bfac96bc 100644 --- a/docs-web/src/main/webapp/src/index.html +++ b/docs-web/src/main/webapp/src/index.html @@ -167,7 +167,7 @@
-