09-07-2012 04:21 PM
<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>
09-07-2012 05:42 PM
<?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>
09-08-2012 02:35 AM
<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;
}
}
09-08-2012 06:31 AM
03-26-2015 02:44 PM
09-08-2012 08:39 AM
09-11-2012 08:24 AM
{
"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;
}
03-01-2017 04:29 AM
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()
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.