As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
<constraints> <constraint name="docks:CustomerListConstraint" type="com.lion.ecm.model.contraints.ListOfCustomersQueryConstraint" > <!– NEED TO INJECT searchService here to pass to contraint class–> <parameter name="caseSensitive"> <value>true</value> </parameter> </constraint> </constraints>
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'> <beans> <bean id="ListOfCustomersQueryConstraint" class="com.lion.ecm.model.contraints.ListOfCustomersQueryConstraint"> <property name="searchService"> <ref bean="SearchService" /> </property> </bean> </beans>
<beans> <!– Registration of new models –> <bean id="docks.docksBillingModel" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap"> <property name="models"> <list> <value>com/lion/ecm/aspects/docksBillingModel.xml</value> </list> </property> </bean> <bean id="ListOfCustomersQueryConstraint" class="com.lion.ecm.model.contraints.ListOfCustomersQueryConstraint"> <property name="searchService"> <ref bean="SearchService" /> </property> </bean> </beans>
<?xml version="1.0" encoding="UTF-8"?> <model xmlns="http://www.alfresco.org/model/dictionary/1.0" name="docks:docksBillingModel"> <description>Docks Model</description> <author>Denis Miorandi</author> <version>1.0</version> <imports> <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/> <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/> </imports> <namespaces> <namespace uri="http://www.lion.org/model/content/1.0" prefix="docks"/> </namespaces> <data-types/> <constraints> <!– constraint name="docks:CustomerListConstraint" type="LIST"–> [b] <constraint name="docks:CustomerListConstraint" type="com.lion.ecm.model.contraints.ListOfCustomersQueryConstraint" > <!– parameter name="allowedValues"> <list> <value>ABC</value> <value>DEF</value> </list> </parameter–> <parameter name="caseSensitive"> <value>true</value> </parameter> </constraint>[/b] </constraints> <types> <type name="docks:document"> <title>Docks Document</title> <parent>cm:content</parent> <properties> <property name="docks:numbers"> <type>d:text</type> <mandatory>false</mandatory> <index enabled="true"/> </property> <property name="docks:childNumbers"> <type>d:text</type> <mandatory>false</mandatory> <index enabled="true"/> </property> <property name="docks:documentType"> <type>d:text</type> <mandatory>false</mandatory> <index enabled="true"/> </property> <property name="docks:documentParsed"> <type>d:boolean</type> <mandatory>false</mandatory> <index enabled="true"/> </property> <property name="docks:documentAggregated"> <type>d:boolean</type> <mandatory>false</mandatory> <index enabled="true"/> </property> <property name="docks:documentEmail"> <type>d:text</type> <mandatory>false</mandatory> <index enabled="true"/> </property> <property name="docks:documentSent"> <type>d:boolean</type> <mandatory>false</mandatory> <index enabled="true"/> </property> <property name="docks:documentCustomer"> <type>d:text</type> <mandatory>false</mandatory> <index enabled="true"> <atomic>false</atomic> <stored>false</stored> <tokenised>TRUE</tokenised> </index> <constraints> <constraint name="docks:documentCustomerList" ref="docks:CustomerListConstraint" /> </constraints> </property> </properties> <associations> <child-association name="docks:childsDocumentLink"> <title>Related Documents</title> <source> <mandatory>false</mandatory> <many>false</many> </source> <target> <class>docks:document</class> <mandatory enforced="false">false</mandatory> <many>true</many> </target> <duplicate>false</duplicate> <propagateTimestamps>false</propagateTimestamps> </child-association> </associations> <overrides/> <mandatory-aspects/> </type> </types> <aspects> <aspect name="docks:documentaspect"> <title>Document details</title> <properties> <property name="docks:numberAspect"> <type>d:text</type> <mandatory>false</mandatory> <index enabled="true"/> </property> </properties> <associations/> <overrides/> <mandatory-aspects/> </aspect> </aspects> </model>
package com.lion.ecm.model.contraints; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint; import org.alfresco.service.cmr.search.SearchService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; // Retreive list of customers via lucene query public class ListOfCustomersQueryConstraint extends ListOfValuesConstraint implements Serializable { private static final long serialVersionUID = 1L; private static Log logger = LogFactory .getLog(ListOfCustomersQueryConstraint.class); private SearchService searchService; public void setSearchService(SearchService searchService) { this.searchService = searchService; } @Override public void initialize() { loadDB(); } @Override public List<String> getAllowedValues() { super.setAllowedValues(loadDB()); return super.getAllowedValues(); } @Override public void setAllowedValues(List allowedValues) { } protected List<String> loadDB() { ArrayList<String> allowedValues = new ArrayList<String>(); try { // do search here //searchService.query(searchParameters); } catch (Exception e) { logger.error("Error on enumerating values of customers"); } finally { } return allowedValues; } }
{ "selectOptions": [ { "name": "bob" }, { "name": "jill" }, { "name": "mark" }, { "name": "sarah" } ] }
//get the list element var targetListEl = Dom.get('targetListId'), html, selectOptions; //targetListId is the id of your select element if(typeof targetListEl !== "undefined") { //Get the select options JSON from the response selectOptions = response.json.selectOptions; //Generate the select html html = '<select id="targetListId" name="targetListId" tabindex="0">'; //Iterate over the select options list and create the select options tags for(i = 0, ii = selectOptions.length; i < ii; i++) { html += '<option value="'+ selectOptions[i].name +'">' + selectOptions[i].name + '</option>'; } //update the select html targetListEl.outerHTML = html; }
Lets use static Spring service provider
public class ServiceStaticProvider { private static NodeService nodeService; private static ContentService contentService; private static FileFolderService fileFolderService; private static SearchService searchService; public static NodeService getNodeService() { return nodeService; } public static ContentService getContentService() { return contentService; } public static FileFolderService getFileFolderService() { return fileFolderService; } public static SearchService getSearchService() { return searchService; } public void setNodeService(NodeService nodeService) { ServiceStaticProvider.nodeService = nodeService; } public void setContentService(ContentService contentService) { ServiceStaticProvider.contentService = contentService; } public void setFileFolderService(FileFolderService fileFolderService) { ServiceStaticProvider.fileFolderService = fileFolderService; } public void setSearchService(SearchService searchService) { ServiceStaticProvider.searchService = searchService; }
}
<bean id="serviceStaticProvider" class="com.wwwwww.ServiceStaticProvider"> <property name="fileFolderService"> <ref bean="fileFolderService" /> </property> <property name="nodeService"> <ref bean="nodeService" /> </property> <property name="contentService"> <ref bean="contentService" /> </property> <property name="searchService"> <ref bean="searchService" /> </property> </bean> In you extension class of ListOfValuesContraint just useServiceStaticProvider.getSearchService()