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
This commit is contained in:
Roy Wetherall
2012-07-06 05:15:53 +00:00
parent 42c1070f09
commit 6c9ac0e377
4 changed files with 229 additions and 0 deletions

View File

@@ -359,6 +359,15 @@
<property name="contentService" ref="ContentService"/> <property name="contentService" ref="ContentService"/>
</bean> </bean>
<bean id="webscript.org.alfresco.slingshot.rmsearch.rmsearchproperties.get"
class="org.alfresco.module.org_alfresco_module_rm.script.slingshot.RMSearchPropertiesGet"
parent="webscript">
<property name="namespaceService" ref="namespaceService"/>
<property name="dictionaryService" ref="DictionaryService"/>
<property name="adminService" ref="RecordsManagementAdminService"/>
<property name="recordsManagementService" ref="RecordsManagementService" />
</bean>
<bean id="webscript.org.alfresco.slingshot.forms.metadata.get" <bean id="webscript.org.alfresco.slingshot.forms.metadata.get"
class="org.alfresco.module.org_alfresco_module_rm.script.slingshot.forms.RMMetaDataGet" class="org.alfresco.module.org_alfresco_module_rm.script.slingshot.forms.RMMetaDataGet"
parent="webscript"> parent="webscript">

View File

@@ -0,0 +1,9 @@
<webscript>
<shortname>rmsearchproperties</shortname>
<description>RM Search Properties</description>
<url>/slingshot/rmsearchproperties</url>
<format default="json">argument</format>
<authentication>user</authentication>
<transaction allow="readonly">required</transaction>
<lifecycle>internal</lifecycle>
</webscript>

View File

@@ -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>
</#list>
]
}<#if group_has_next>,</#if>
</#list>
]
}
}
</#escape>

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
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<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
Map<String, Object> model = new HashMap<String, Object>(13);
List<Group> groups = new ArrayList<Group>(5);
Set<QName> aspects = recordsManagementService.getRecordMetaDataAspects();
for (QName aspect : aspects)
{
Map<QName, PropertyDefinition> 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<QName, PropertyDefinition> 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;
}
}
}