diff --git a/README.md b/README.md index d2df1f6..a487c2d 100644 --- a/README.md +++ b/README.md @@ -83,4 +83,36 @@ From Sample 2 Site > Values = 1,2 ## Version 3.1.0 -Added controls for default value and parent selection \ No newline at end of file +Added controls for default value and parent selection + +## Version 3.2.0 + +AMP artifacts ready-to-deploy available at [3.2.0](https://github.com/keensoft/alfresco-datalist-constraints/releases/tag/3.2.0) + +Keywords `[ADD]` and `[REPLACE]` have been added to define the behaviour of a list inside a Site: + +* `[ADD]` merges values from global Dictionary list and Site list +* `[REPLACE]` includes only values from Site list + +This keyword has to be included in any place at `Description` field when declaring the list inside a Site. + +** Sample scenario ** + +Datalist definitions + +``` +Dictionary Site > Datalist "Options" > Values = 1,2 +Sample 1 Site > Datalist "Options" (including [ADD] in description) > Values = 3,4 +Sample 2 Site > Datalist "Options" (including [REPLACE] in description) > Values = 3,4 +Sample 3 Site > No datalist defined +``` + +Values provided by combos + +``` +Outside from a Site > Values = 1,2 +From Advanced Search > Values = 1,2,3,4 +From Sample 1 Site > Values = 1,2,3,4 +From Sample 2 Site > Values = 3,4 +From Sample 3 Site > Values = 1,2 +``` \ No newline at end of file diff --git a/datalist-model-repo/pom.xml b/datalist-model-repo/pom.xml index c8db5a0..d3de917 100644 --- a/datalist-model-repo/pom.xml +++ b/datalist-model-repo/pom.xml @@ -4,7 +4,7 @@ 4.0.0 es.keensoft datalist-model-repo - 3.1.0 + 3.2.0 datalist-model-repo Repository AMP project amp Manages the lifecycle of the site-props-repo Repository AMP (Alfresco Module Package) diff --git a/datalist-model-repo/src/main/java/es/keensoft/alfresco/action/webscript/DataListWebScript.java b/datalist-model-repo/src/main/java/es/keensoft/alfresco/action/webscript/DataListWebScript.java index 0852c75..a75ffb9 100644 --- a/datalist-model-repo/src/main/java/es/keensoft/alfresco/action/webscript/DataListWebScript.java +++ b/datalist-model-repo/src/main/java/es/keensoft/alfresco/action/webscript/DataListWebScript.java @@ -28,10 +28,14 @@ import org.springframework.extensions.webscripts.WebScriptResponse; import es.keensoft.alfresco.model.DatalistModel; +import es.keensoft.alfresco.model.DatalistModel.DataListStatus; public class DataListWebScript extends AbstractWebScript { - private static final String JSON_CODE = "code"; + private static final String REPLACE_DESK_MARK = "[REPLACE]"; + private static final String ADD_DESC_MARK = "[ADD]"; + + private static final String JSON_CODE = "code"; private static final String JSON_VALUE = "value"; private static final String DATALIST_CONTAINER_ID = "dataLists"; @@ -71,8 +75,21 @@ public void execute(WebScriptRequest request, WebScriptResponse response) throws siteId = siteInfo.getShortName(); } } - if (siteId != null && existsDatalist(siteId, targetedDataListName)) { - sites.add(siteService.getSite(siteId)); + DataListStatus siteStatus = DataListStatus.NONE; + if (siteId != null) { + siteStatus = existsDatalist(siteId, targetedDataListName); + switch(siteStatus) { + case NONE: + sites = siteService.listSites(null, DATALIST_PRESET); + break; + case ADD: + sites = siteService.listSites(null, DATALIST_PRESET); + sites.add(siteService.getSite(siteId)); + break; + case REPLACE: + sites.add(siteService.getSite(siteId)); + break; + } } else { sites = siteService.listSites(null, DATALIST_PRESET); } @@ -168,18 +185,29 @@ public int compare(Map.Entry o1, return sortedMap; } - private boolean existsDatalist(String siteId, String targetedDataListName) { + private DataListStatus existsDatalist(String siteId, String targetedDataListName) { NodeRef dataListContainer = SiteServiceImpl.getSiteContainer(siteId, DATALIST_CONTAINER_ID, true, siteService, transactionService, taggingService); List dataListsNodes = nodeService.getChildAssocs(dataListContainer); for (ChildAssociationRef dataList : dataListsNodes) { if (dataList.getTypeQName().isMatch(ContentModel.ASSOC_CONTAINS)) { if (nodeService.getProperty(dataList.getChildRef(), ContentModel.PROP_TITLE).toString().equals(targetedDataListName)) { - return true; + Object description = nodeService.getProperty(dataList.getChildRef(), ContentModel.PROP_DESCRIPTION); + if (description != null) { + if (description.toString().indexOf(ADD_DESC_MARK) > 0) { + return DataListStatus.ADD; + } else if (description.toString().indexOf(REPLACE_DESK_MARK) > 0) { + return DataListStatus.REPLACE; + } else { + return DataListStatus.REPLACE; + } + } else { + return DataListStatus.REPLACE; + } } } } - return false; + return DataListStatus.NONE; } diff --git a/datalist-model-repo/src/main/java/es/keensoft/alfresco/model/DatalistModel.java b/datalist-model-repo/src/main/java/es/keensoft/alfresco/model/DatalistModel.java index 5f1bcc5..53b96f6 100644 --- a/datalist-model-repo/src/main/java/es/keensoft/alfresco/model/DatalistModel.java +++ b/datalist-model-repo/src/main/java/es/keensoft/alfresco/model/DatalistModel.java @@ -9,4 +9,8 @@ public class DatalistModel { public static final QName DATALIST_MODEL_VALUE_PROPERTY = QName.createQName(DATALIST_MODEL_URI, "value"); public static final QName DATALIST_MODEL_ITEM_TYPE = QName.createQName(DATALIST_MODEL_URI, "optionList"); + public enum DataListStatus { + ADD, REPLACE, NONE + } + } diff --git a/datalist-model-share/pom.xml b/datalist-model-share/pom.xml index aa65a1a..9d7ba13 100644 --- a/datalist-model-share/pom.xml +++ b/datalist-model-share/pom.xml @@ -4,7 +4,7 @@ 4.0.0 es.keensoft datalist-model-share - 3.1.0 + 3.2.0 site-props-share AMP project amp Manages the lifecycle of the site-props-share AMP (Alfresco Module Package)