mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Started efactoring InviatationServiceImpl so that it uses Activit workflow engine.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29990 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1246,37 +1246,47 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
String msg = messageService.getMessage(ERR_END_UNEXISTING_TASK, taskId);
|
||||
throw new WorkflowException(msg);
|
||||
}
|
||||
|
||||
// Signal the transition on the task
|
||||
if (transition != null &&
|
||||
ActivitiConstants.DEFAULT_TRANSITION_NAME.equals(transition)==false)
|
||||
{
|
||||
// Only 'Next' is supported as transition.
|
||||
String msg = messageService.getMessage(ERR_END_TASK_INVALID_TRANSITION, transition, taskId, ActivitiConstants.DEFAULT_TRANSITION_NAME);
|
||||
throw new WorkflowException(msg);
|
||||
}
|
||||
setOutcome(task);
|
||||
setOutcome(task, transition);
|
||||
taskService.complete(localTaskId);
|
||||
// The task should have a historicTaskInstance
|
||||
HistoricTaskInstance historicTask = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
|
||||
return typeConverter.convert(historicTask);
|
||||
}
|
||||
|
||||
private void setOutcome(Task task)
|
||||
private void setOutcome(Task task, String transition)
|
||||
{
|
||||
String outcomeValue = ActivitiConstants.DEFAULT_TRANSITION_NAME;
|
||||
HashMap<QName, Serializable> updates = new HashMap<QName, Serializable>();
|
||||
|
||||
Map<QName, Serializable> properties = propertyConverter.getTaskProperties(task, false);
|
||||
QName outcomePropName = (QName) properties.get(WorkflowModel.PROP_OUTCOME_PROPERTY_NAME);
|
||||
if(outcomePropName !=null)
|
||||
{
|
||||
Serializable rawOutcome = properties.get(outcomePropName);
|
||||
String outcomeValue = ActivitiConstants.DEFAULT_TRANSITION_NAME;
|
||||
if(rawOutcome != null)
|
||||
if(transition != null)
|
||||
{
|
||||
outcomeValue = DefaultTypeConverter.INSTANCE.convert(String.class, rawOutcome);
|
||||
outcomeValue = transition;
|
||||
Serializable transitionValue = propertyConverter.convertValueToPropertyType(task, transition, outcomePropName);
|
||||
updates.put(outcomePropName, transitionValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serializable rawOutcome = properties.get(outcomePropName);
|
||||
if(rawOutcome != null)
|
||||
{
|
||||
outcomeValue = DefaultTypeConverter.INSTANCE.convert(String.class, rawOutcome);
|
||||
}
|
||||
}
|
||||
String outcomeName = factory.mapQNameToName(WorkflowModel.PROP_OUTCOME);
|
||||
taskService.setVariableLocal(task.getId(), outcomeName, outcomeValue);
|
||||
}
|
||||
else if (transition != null &&
|
||||
ActivitiConstants.DEFAULT_TRANSITION_NAME.equals(transition)==false)
|
||||
{
|
||||
// Only 'Next' is supported as transition.
|
||||
String taskId = createGlobalId(task.getId());
|
||||
String msg = messageService.getMessage(ERR_END_TASK_INVALID_TRANSITION, transition, taskId, ActivitiConstants.DEFAULT_TRANSITION_NAME);
|
||||
throw new WorkflowException(msg);
|
||||
}
|
||||
updates.put(WorkflowModel.PROP_OUTCOME, outcomeValue);
|
||||
propertyConverter.updateTask(task, updates, null, null);
|
||||
}
|
||||
|
||||
private WorkflowTask endStartTask(String taskId, String localTaskId, String transition)
|
||||
|
@@ -60,6 +60,6 @@ public abstract class BaseJavaDelegate implements JavaDelegate
|
||||
*/
|
||||
protected String getName()
|
||||
{
|
||||
return getClass().getName();
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
}
|
||||
|
@@ -61,6 +61,7 @@ import org.alfresco.service.cmr.dictionary.ClassAttributeDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowException;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
@@ -600,6 +601,23 @@ public class ActivitiPropertyConverter
|
||||
throw new WorkflowException(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a {@link Serializable} value to the type of the specified property.
|
||||
* @param value
|
||||
* @param definition
|
||||
* @return
|
||||
*/
|
||||
public Serializable convertValueToPropertyType(Task task, Serializable value, QName propertyName)
|
||||
{
|
||||
TypeDefinition taskDef = typeManager.getFullTaskDefinition(task);
|
||||
PropertyDefinition propDef = taskDef.getProperties().get(propertyName);
|
||||
if(propDef != null)
|
||||
{
|
||||
return (Serializable) DefaultTypeConverter.INSTANCE.convert(propDef.getDataType(), value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<QName, Serializable> getNewTaskProperties(Task task, Map<QName, Serializable> properties, Map<QName, List<NodeRef>> add,
|
||||
Map<QName, List<NodeRef>> remove)
|
||||
|
Reference in New Issue
Block a user