From 6c9ac0e377a36593652bae74c8fb1367f35f32dc Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Fri, 6 Jul 2012 05:15:53 +0000 Subject: [PATCH] RM-420: Search UI needs dynamic lists * added web script to provide a list of all the custom and record meta-data properties to the search UI grouped accordingly. * removed all hard coded references to the DOD model still present in the search UI. * property hint drop down, column selection list, sort order list and result implementation all now use web script to provide dynamic list of properties rather than hard coding customisable or dod model elements into code. * as a side effect also fixed the following: - RM-342: Search results table dosn't show info for special types - RM-84: Result options is not applied for Special types options - RM-337: Custom metadata for Non-electronic Document doesn't appear in RM search - RM-370: Record Series check box is present at Components part git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.0@38853 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../rm-webscript-context.xml | 9 + .../rmsearch/rmsearchproperties.get.desc.xml | 9 + .../rmsearch/rmsearchproperties.get.json.ftl | 27 +++ .../slingshot/RMSearchPropertiesGet.java | 184 ++++++++++++++++++ 4 files changed, 229 insertions(+) create mode 100644 rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsearchproperties.get.desc.xml create mode 100644 rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsearchproperties.get.json.ftl create mode 100644 rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSearchPropertiesGet.java diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml index 79437c28cb..d9b8e146f3 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml @@ -359,6 +359,15 @@ + + + + + + + diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsearchproperties.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsearchproperties.get.desc.xml new file mode 100644 index 0000000000..18105dc400 --- /dev/null +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsearchproperties.get.desc.xml @@ -0,0 +1,9 @@ + + rmsearchproperties + RM Search Properties + /slingshot/rmsearchproperties + argument + user + required + internal + \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsearchproperties.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsearchproperties.get.json.ftl new file mode 100644 index 0000000000..e5fe1b268d --- /dev/null +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/rmsearchproperties.get.json.ftl @@ -0,0 +1,27 @@ +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "data" : + { + "groups" : + [ + <#list groups as group> + { + "id" : "${group.id}", + "label" : "${group.label}", + "properties" : + [ + <#list group.properties as property> + { + "prefix" : "${property.prefix}", + "name" : "${property.shortName}", + "label" : "${property.label}", + "type" : "${property.type}" + }<#if property_has_next>, + + ] + }<#if group_has_next>, + + ] + } +} + \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSearchPropertiesGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSearchPropertiesGet.java new file mode 100644 index 0000000000..8948cb0895 --- /dev/null +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSearchPropertiesGet.java @@ -0,0 +1,184 @@ +/* + * Copyright (C) 2005-2011 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.slingshot; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService; +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; +import org.alfresco.service.cmr.dictionary.AspectDefinition; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.dictionary.PropertyDefinition; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * RM serach properties GET web script + * + * @author Roy Wetherall + */ +public class RMSearchPropertiesGet extends DeclarativeWebScript +{ + private RecordsManagementAdminService adminService; + + private RecordsManagementService recordsManagementService; + + private DictionaryService dictionaryService; + + private NamespaceService namespaceService; + + public void setAdminService(RecordsManagementAdminService adminService) + { + this.adminService = adminService; + } + + public void setRecordsManagementService(RecordsManagementService recordsManagementService) + { + this.recordsManagementService = recordsManagementService; + } + + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /* + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + Map model = new HashMap(13); + + List groups = new ArrayList(5); + + Set aspects = recordsManagementService.getRecordMetaDataAspects(); + for (QName aspect : aspects) + { + Map properties = dictionaryService.getPropertyDefs(aspect); + Property[] propObjs = new Property[properties.size()]; + int index = 0; + for (PropertyDefinition propertyDefinition : properties.values()) + { + Property propObj = new Property(propertyDefinition); + propObjs[index] = propObj; + index ++; + } + + AspectDefinition aspectDefinition = dictionaryService.getAspect(aspect); + Group group = new Group(aspect.getLocalName(), aspectDefinition.getTitle(), propObjs); + groups.add(group); + } + + Map customProps = adminService.getCustomPropertyDefinitions(); + Property[] propObjs = new Property[customProps.size()]; + int index = 0; + for (PropertyDefinition propertyDefinition : customProps.values()) + { + Property propObj = new Property(propertyDefinition); + propObjs[index] = propObj; + index ++; + } + + Group group = new Group("rmcustom", "Custom", propObjs); + groups.add(group); + + model.put("groups", groups); + return model; + } + + public class Group + { + private String id; + private String label; + private Property[] properties; + + public Group(String id, String label, Property[] properties) + { + this.id = id; + this.label = label; + this.properties = properties; + } + + public String getId() + { + return id; + } + + public String getLabel() + { + return label; + } + + public Property[] getProperties() + { + return properties; + } + } + + public class Property + { + private String prefix; + private String shortName; + private String label; + private String type; + + public Property(PropertyDefinition propertyDefinition) + { + QName qName = propertyDefinition.getName().getPrefixedQName(namespaceService); + this.prefix = QName.splitPrefixedQName(qName.toPrefixString())[0]; + this.shortName = qName.getLocalName(); + this.label = propertyDefinition.getTitle(); + this.type = propertyDefinition.getDataType().getName().getLocalName(); + } + + public String getPrefix() + { + return prefix; + } + + public String getShortName() + { + return shortName; + } + + public String getLabel() + { + return label; + } + + public String getType() + { + return type; + } + } +} \ No newline at end of file