06-10-2010 04:43 AM
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<!–
Define the model factory used to generate object models suitable for use with freemarker templates.
–>
<bean id="templateActionModelFactory" class="org.alfresco.repo.action.scheduled.FreeMarkerWithLuceneExtensionsModelFactory">
<property name="serviceRegistry">
<ref bean="ServiceRegistry"/>
</property>
</bean>
<!–
An example action template that defines an action to add the generalclassifiable aspect to all nodes that do not have
and add a category defined by path.
–>
<bean id="addAmministratiAction" class="org.alfresco.repo.action.scheduled.SimpleTemplateActionDefinition">
<property name="actionName">
<value>AmministratiActionExecuter</value>
</property>
<property name="parameterTemplates">
<map>
<entry>
<key>
<value>QUERY</value>
</key>
<value>PROVA</value>
</entry>
</map>
</property>
<property name="templateActionModelFactory">
<ref bean="templateActionModelFactory"/>
</property>
<property name="dictionaryService">
<ref bean="DictionaryService"/>
</property>
<property name="actionService">
<ref bean="ActionService"/>
</property>
<property name="templateService">
<ref bean="TemplateService"/>
</property>
</bean>
<bean id="addClassifiableAspectEveryTenMinutes" class="org.alfresco.repo.action.scheduled.CronScheduledQueryBasedTemplateActionDefinition">
<property name="transactionMode">
<value>UNTIL_FIRST_FAILURE</value>
</property>
<property name="compensatingActionMode">
<value>IGNORE</value>
</property>
<property name="searchService">
<ref bean="SearchService"/>
</property>
<property name="templateService">
<ref bean="TemplateService"/>
</property>
<property name="queryLanguage">
<value>lucene</value>
</property>
<property name="stores">
<list>
<value>workspace://SpacesStore</value>
</list>
</property>
<!– Find all nodes that do not have the aspect –>
<property name="queryTemplate">
<value>PATH:"/app:company_home"</value>
</property>
<property name="cronExpression">
<value>0 0/5 * * * ?</value>
</property>
<property name="jobName">
<value>jobA</value>
</property>
<property name="jobGroup">
<value>jobGroup</value>
</property>
<property name="triggerName">
<value>triggerA</value>
</property>
<property name="triggerGroup">
<value>triggerGroup</value>
</property>
<property name="scheduler">
<ref bean="schedulerFactory"/>
</property>
<property name="actionService">
<ref bean="ActionService"/>
</property>
<property name="templateActionModelFactory">
<ref bean="templateActionModelFactory"/>
</property>
<property name="templateActionDefinition">
<ref bean="addAmministratiAction"/>
</property>
<property name="transactionService">
<ref bean="TransactionService"/>
</property>
<property name="runAsUser">
<value>admin</value>
</property>
</bean>
</beans>
public void doExample(ServiceRegistry serviceRegistry) throws Exception {
//
// create a workflow service
//
WorkflowService workflowService = serviceRegistry.getWorkflowService();
PersonService personService = serviceRegistry.getPersonService();
List a = workflowService.getAllDefinitions();
Iterator i = a.iterator();
String wid = "";
while (i.hasNext()) {
WorkflowDefinition wd = (WorkflowDefinition) i.next();
System.out.println("workflow name—–>" + wd.name);
if (wd.name.equals("jbpm$wf:parallelgroupreview") || wd.name.equals("jbpm$wf:adhoc") ) {
System.out.println(wd.id);
wid = wd.id;
}
}
// Create a workflow node reference
NodeRef workflowNodeRef = workflowService.createPackage(null);
// Finally kick the workflow off.
Map<QName, Serializable> parameters = new HashMap<QName, Serializable>();
Date dueDate = new Date(System.currentTimeMillis());
parameters.put(WorkflowModel.ASSOC_PACKAGE, workflowNodeRef);
NodeRef personNodeId = personService.getPerson("USER_TEST");
parameters.put(WorkflowModel.ASSOC_ASSIGNEE,personNodeId );
parameters.put(WorkflowModel.PROP_DUE_DATE, dueDate);
parameters.put(WorkflowModel.PROP_DESCRIPTION, "PROP_DESCRIPTION");
parameters.put(WorkflowModel.PROP_WORKFLOW_DUE_DATE, dueDate);
parameters.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, "PROP_WORKFLOW_DESCRIPTION");
WorkflowPath path = workflowService.startWorkflow(wid, parameters);
System.out.println("initiated successfully");
WorkflowTaskQuery query = new WorkflowTaskQuery();
query.setTaskState(WorkflowTaskState.COMPLETED);
query.setTaskState(WorkflowTaskState.IN_PROGRESS);
List<WorkflowTask> tasks = workflowService.queryTasks(query);
System.out.println("before");
// create a list of transient nodes to represents
for (WorkflowTask task : tasks) {
System.out.println("Task name—>" + task.name);
WorkflowTaskDefinition wdef = task.definition;
System.out.println("map size———–>" + wdef.metadata.getDefaultValues().size());
Map m = task.properties;
Set s = m.keySet();
Iterator it = s.iterator();
while (it.hasNext()) {
QName key = (QName) it.next();
// System.out.println("key——–>"+ m.get(key));
// Serializable pd=(Serializable)m.get(key);
System.out.println("Key" + key.getLocalName());
System.out.println("value——->" + m.get(key));
}
}
}
06-10-2010 06:37 AM
06-10-2010 06:40 AM
06-10-2010 08:13 AM
public static void doExample(ServiceRegistry serviceRegistry) throws Exception {
//
// create a workflow service
//
WorkflowService workflowService = serviceRegistry.getWorkflowService();
PersonService personService = serviceRegistry.getPersonService();
List a = workflowService.getAllDefinitions();
Iterator i = a.iterator();
String wid = "";
while (i.hasNext()) {
Object obj = (Object) i.next();
WorkflowDefinition wd = (WorkflowDefinition)obj;
//String engineId = (String) serviceRegistry.getNodeService().getProperty((NodeRef)obj,WorkflowModel.PROP_WORKFLOW_DEF_ENGINE_ID);
System.out.println("workflow name—–>" + wd.name);
if (wd.name.equals("jbpm$wf:parallelgroupreview") || wd.name.equals("jbpm$wf:adhoc") ) {
System.out.println(wd.id);
wid = wd.id;
}
}
// Create a workflow node reference
NodeRef workflowNodeRef = workflowService.createPackage(null);
// Finally kick the workflow off.
Map<QName, Serializable> parameters = new HashMap<QName, Serializable>();
Date dueDate = new Date(System.currentTimeMillis());
parameters.put(WorkflowModel.ASSOC_PACKAGE, workflowNodeRef);
NodeRef personNodeId = personService.getPerson("ABRAMO.SALZILLO");
parameters.put(WorkflowModel.ASSOC_ASSIGNEE,personNodeId );
parameters.put(WorkflowModel.PROP_DUE_DATE, dueDate);
parameters.put(WorkflowModel.PROP_DESCRIPTION, "PROP_DESCRIPTION");
parameters.put(WorkflowModel.PROP_WORKFLOW_DUE_DATE, dueDate);
parameters.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, "PROP_WORKFLOW_DESCRIPTION");
System.out.println("initiated successfully");
WorkflowPath wfPath = workflowService.startWorkflow(wid, parameters);
// New code
String workflowId = wfPath.instance.id;
String wfPathId = wfPath.id;
List<WorkflowTask> wfTasks = workflowService.getTasksForWorkflowPath(wfPathId);
for (Iterator iterator = wfTasks.iterator(); iterator.hasNext();) {
WorkflowTask workflowTask = (WorkflowTask) iterator.next();
System.out.println("Task name—>" + workflowTask.name);
}
WorkflowTask wfFirstStartTask = wfTasks.get(0);
WorkflowTask wfFirstStartTaskEnd = workflowService.endTask(wfFirstStartTask.id, null);
System.out.println("task started successfully");
WorkflowTaskQuery query = new WorkflowTaskQuery();
query.setTaskState(WorkflowTaskState.COMPLETED);
query.setTaskState(WorkflowTaskState.IN_PROGRESS);
List<WorkflowTask> tasks = workflowService.queryTasks(query);
System.out.println("before");
// create a list of transient nodes to represents
for (WorkflowTask task : tasks) {
System.out.println("Task name—>" + task.name);
WorkflowTaskDefinition wdef = task.definition;
System.out.println("map size———–>" + wdef.metadata.getDefaultValues().size());
Map m = task.properties;
Set s = m.keySet();
Iterator it = s.iterator();
while (it.hasNext()) {
QName key = (QName) it.next();
// System.out.println("key——–>"+ m.get(key));
// Serializable pd=(Serializable)m.get(key);
System.out.println("Key" + key.getLocalName());
System.out.println("value——->" + m.get(key));
}
}
}
07-24-2013 01:32 AM
07-24-2014 02:10 PM
07-24-2014 04:38 PM
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.