mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V1.3 to V1.4 (Workflow changes required)
svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4152 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4153 . svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4163 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4164 . svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4178 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4179 . svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4328 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4329 . svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4331 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4332 . git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4529 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -2,6 +2,7 @@ package org.alfresco.web.bean.repository;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -9,6 +10,7 @@ import java.util.Map;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
||||
@@ -60,6 +62,69 @@ public class TransientNode extends Node
|
||||
initNode(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a transient node for an item yet to be created in the Repository.
|
||||
*
|
||||
* This will apply any one-time initialisation required upon creation of the node
|
||||
* e.g. assignment of default values.
|
||||
*
|
||||
* @param dictionaryService dictionary service
|
||||
* @param typeDef The type definition this node will represent
|
||||
* @param name The name of the node
|
||||
* @param data The properties and associations this node will have
|
||||
* @return transient node
|
||||
*/
|
||||
public static TransientNode createNew(DictionaryService dictionaryService, TypeDefinition typeDef, String name, Map<QName, Serializable> data)
|
||||
{
|
||||
// build a complete anonymous type for the start task
|
||||
List<AspectDefinition> aspects = typeDef.getDefaultAspects();
|
||||
List<QName> aspectNames = new ArrayList<QName>(aspects.size());
|
||||
getMandatoryAspects(typeDef, aspectNames);
|
||||
ClassDefinition startTaskDef = dictionaryService.getAnonymousType(typeDef.getName(), aspectNames);
|
||||
|
||||
// initialise start task values
|
||||
Map<QName, Serializable> startValues = new HashMap<QName, Serializable>();
|
||||
if (data != null)
|
||||
{
|
||||
startValues.putAll(data);
|
||||
}
|
||||
|
||||
// apply default values
|
||||
Map<QName, PropertyDefinition> propertyDefs = startTaskDef.getProperties();
|
||||
for (Map.Entry<QName, PropertyDefinition> entry : propertyDefs.entrySet())
|
||||
{
|
||||
String defaultValue = entry.getValue().getDefaultValue();
|
||||
if (defaultValue != null)
|
||||
{
|
||||
if (startValues.get(entry.getKey()) == null)
|
||||
{
|
||||
startValues.put(entry.getKey(), defaultValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new TransientNode(typeDef.getName(), name, startValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a flattened list of all mandatory aspects for a given class
|
||||
*
|
||||
* @param classDef the class
|
||||
* @param aspects a list to hold the mandatory aspects
|
||||
*/
|
||||
private static void getMandatoryAspects(ClassDefinition classDef, List<QName> aspects)
|
||||
{
|
||||
for (AspectDefinition aspect : classDef.getDefaultAspects())
|
||||
{
|
||||
QName aspectName = aspect.getName();
|
||||
if (!aspects.contains(aspectName))
|
||||
{
|
||||
aspects.add(aspect.getName());
|
||||
getMandatoryAspects(aspect, aspects);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises the node.
|
||||
*
|
||||
|
@@ -253,40 +253,37 @@ public class ManageTaskDialog extends BaseDialogBean
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedTransition != null)
|
||||
UserTransaction tx = null;
|
||||
|
||||
try
|
||||
{
|
||||
UserTransaction tx = null;
|
||||
|
||||
try
|
||||
{
|
||||
tx = Repository.getUserTransaction(context);
|
||||
tx.begin();
|
||||
|
||||
// prepare the edited parameters for saving
|
||||
Map<QName, Serializable> params = WorkflowUtil.prepareTaskParams(this.taskNode);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Transitioning task with parameters: " + params);
|
||||
|
||||
// update the task with the updated parameters
|
||||
this.workflowService.updateTask(this.task.id, params, null, null);
|
||||
|
||||
// signal the selected transition to the workflow task
|
||||
this.workflowService.endTask(this.task.id, selectedTransition);
|
||||
|
||||
// commit the changes
|
||||
tx.commit();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Ended task with transition: " + selectedTransition);
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
// rollback the transaction
|
||||
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
||||
Utils.addErrorMessage(formatErrorMessage(e), e);
|
||||
outcome = this.getErrorOutcome(e);
|
||||
}
|
||||
tx = Repository.getUserTransaction(context);
|
||||
tx.begin();
|
||||
|
||||
// prepare the edited parameters for saving
|
||||
Map<QName, Serializable> params = WorkflowUtil.prepareTaskParams(this.taskNode);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Transitioning task with parameters: " + params);
|
||||
|
||||
// update the task with the updated parameters
|
||||
this.workflowService.updateTask(this.task.id, params, null, null);
|
||||
|
||||
// signal the selected transition to the workflow task
|
||||
this.workflowService.endTask(this.task.id, selectedTransition);
|
||||
|
||||
// commit the changes
|
||||
tx.commit();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Ended task with transition: " + selectedTransition);
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
// rollback the transaction
|
||||
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
||||
Utils.addErrorMessage(formatErrorMessage(e), e);
|
||||
outcome = this.getErrorOutcome(e);
|
||||
}
|
||||
|
||||
return outcome;
|
||||
|
@@ -202,7 +202,7 @@ public class StartWorkflowWizard extends BaseWizardBean
|
||||
logger.debug("Start task definition: " + taskDef);
|
||||
|
||||
// create an instance of a task from the data dictionary
|
||||
this.startTaskNode = new TransientNode(taskDef.metadata.getName(),
|
||||
this.startTaskNode = TransientNode.createNew(dictionaryService, taskDef.metadata,
|
||||
"task_" + System.currentTimeMillis(), null);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user