Heinous merge from HEAD. Seems to basically work. Be on guard however.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4137 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-10-18 02:24:36 +00:00
parent 2d13a492d0
commit a2f161b731
92 changed files with 18500 additions and 11155 deletions

View File

@@ -5,6 +5,7 @@ import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.service.cmr.workflow.WorkflowInstance;
import org.alfresco.service.cmr.workflow.WorkflowService;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.dialog.BaseDialogBean;
@@ -18,7 +19,7 @@ import org.apache.commons.logging.LogFactory;
*/
public class CancelWorkflowDialog extends BaseDialogBean
{
protected String workflowInstanceId;
protected WorkflowInstance workflowInstance;
protected WorkflowService workflowService;
private static final Log logger = LogFactory.getLog(CancelWorkflowDialog.class);
@@ -32,11 +33,17 @@ public class CancelWorkflowDialog extends BaseDialogBean
super.init(parameters);
// make sure the workflow instance id has been passed
this.workflowInstanceId = this.parameters.get("workflow-instance-id");
if (this.workflowInstanceId == null || this.workflowInstanceId.length() == 0)
String workflowInstanceId = this.parameters.get("workflow-instance-id");
if (workflowInstanceId == null || workflowInstanceId.length() == 0)
{
throw new IllegalArgumentException("Cancel workflow dialog called without workflow instance id");
}
this.workflowInstance = workflowService.getWorkflowById(workflowInstanceId);
if (this.workflowInstance == null)
{
throw new IllegalArgumentException("Failed to find workflow instance for id: " + workflowInstanceId);
}
}
@Override
@@ -44,13 +51,13 @@ public class CancelWorkflowDialog extends BaseDialogBean
throws Exception
{
if (logger.isDebugEnabled())
logger.debug("Cancelling workflow with id: " + this.workflowInstanceId);
logger.debug("Cancelling workflow with id: " + this.workflowInstance.id);
// cancel the workflow
this.workflowService.cancelWorkflow(this.workflowInstanceId);
this.workflowService.cancelWorkflow(this.workflowInstance.id);
if (logger.isDebugEnabled())
logger.debug("Cancelled workflow with id: " + this.workflowInstanceId);
logger.debug("Cancelled workflow with id: " + this.workflowInstance.id);
return outcome;
}
@@ -67,9 +74,21 @@ public class CancelWorkflowDialog extends BaseDialogBean
return false;
}
@Override
public String getCancelButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), "no");
}
@Override
public String getFinishButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), "yes");
}
// ------------------------------------------------------------------------------
// Bean Getters and Setters
/**
* Returns the confirmation to display to the user before deleting the content.
*
@@ -80,8 +99,13 @@ public class CancelWorkflowDialog extends BaseDialogBean
String confirmMsg = Application.getMessage(FacesContext.getCurrentInstance(),
"cancel_workflow_confirm");
return MessageFormat.format(confirmMsg,
new Object[] {this.parameters.get("workflow-instance-name")});
String workflowLabel = this.workflowInstance.definition.title;
if (this.workflowInstance.description != null && this.workflowInstance.description.length() > 0)
{
workflowLabel = workflowLabel + " (" + this.workflowInstance.description + ")";
}
return MessageFormat.format(confirmMsg, new Object[] {workflowLabel});
}
/**

View File

@@ -26,6 +26,7 @@ import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.alfresco.web.bean.repository.MapNode;
import org.alfresco.web.bean.repository.Node;
@@ -105,16 +106,7 @@ public class ManageTaskDialog extends BaseDialogBean
this.workflowInstance = this.task.path.instance;
// setup the workflow package for the task
Serializable obj = this.task.properties.get(WorkflowModel.ASSOC_PACKAGE);
// TODO: remove this workaroud where JBPM may return a String and not the NodeRef
if (obj instanceof NodeRef)
{
this.workflowPackage = (NodeRef)obj;
}
else if (obj instanceof String)
{
this.workflowPackage = new NodeRef((String)obj);
}
this.workflowPackage = (NodeRef)this.task.properties.get(WorkflowModel.ASSOC_PACKAGE);
if (logger.isDebugEnabled())
{
@@ -208,7 +200,7 @@ public class ManageTaskDialog extends BaseDialogBean
@Override
public String getFinishButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), "save");
return Application.getMessage(FacesContext.getCurrentInstance(), "save_changes");
}
@Override
@@ -251,7 +243,7 @@ public class ManageTaskDialog extends BaseDialogBean
String selectedTransition = null;
for (WorkflowTransition trans : this.transitions)
{
Object result = reqParams.get(CLIENT_ID_PREFIX + trans.title);
Object result = reqParams.get(CLIENT_ID_PREFIX + FacesHelper.makeLegalId(trans.title));
if (result != null)
{
// this was the button that was pressed
@@ -635,7 +627,10 @@ public class ManageTaskDialog extends BaseDialogBean
node.addPropertyResolver("displayPath", this.browseBean.resolverDisplayPath);
// add a property resolver to indicate whether the item has been completed or not
// node.addPropertyResolver("completed", this.completeResolver);
// node.addPropertyResolver("completed", this.completeResolver);
// add the id of the task being managed
node.getProperties().put("taskId", this.task.id);
this.resources.add(node);
}

View File

@@ -50,7 +50,7 @@ public class ReassignTaskDialog extends BaseDialogBean
{
super.init(parameters);
this.taskId = this.parameters.get("task-id");
this.taskId = this.parameters.get("id");
if (this.taskId == null || this.taskId.length() == 0)
{
throw new IllegalArgumentException("Reassign task dialog called without task id");
@@ -137,12 +137,13 @@ public class ReassignTaskDialog extends BaseDialogBean
{
tx = Repository.getUserTransaction(context, true);
tx.begin();
// build xpath to match available User/Person objects
NodeRef peopleRef = personService.getPeopleContainer();
// NOTE: see SearcherComponentTest
String xpath = "*[like(@" + NamespaceService.CONTENT_MODEL_PREFIX + ":" + "firstName, '%" + contains + "%', false)" +
" or " + "like(@" + NamespaceService.CONTENT_MODEL_PREFIX + ":" + "lastName, '%" + contains + "%', false)]";
String xpath = "*[not(@" + NamespaceService.CONTENT_MODEL_PREFIX + ":" + "userName='guest') and " +
"(like(@" + NamespaceService.CONTENT_MODEL_PREFIX + ":" + "firstName, '%" + contains + "%', false)" +
" or " + "like(@" + NamespaceService.CONTENT_MODEL_PREFIX + ":" + "lastName, '%" + contains + "%', false))]";
List<NodeRef> nodes = searchService.selectNodes(
peopleRef,

View File

@@ -46,6 +46,7 @@ import org.apache.commons.logging.LogFactory;
public class StartWorkflowWizard extends BaseWizardBean
{
protected String selectedWorkflow;
protected String previouslySelectedWorkflow;
protected List<SelectItem> availableWorkflows;
protected Map<String, WorkflowDefinition> workflows;
protected WorkflowService workflowService;
@@ -77,18 +78,13 @@ public class StartWorkflowWizard extends BaseWizardBean
this.selectedWorkflow = null;
}
this.previouslySelectedWorkflow = null;
this.startTaskNode = null;
this.resources = null;
this.itemsToAdd = null;
this.packageItemsToAdd = new ArrayList<String>();
this.isItemBeingAdded = false;
if (this.packageItemsRichList != null)
{
this.packageItemsRichList.setValue(null);
this.packageItemsRichList = null;
}
// TODO: Does this need to be in a read-only transaction??
resetRichList();
// add the item the workflow wizard was started on to the list of resources
String itemToWorkflowId = this.parameters.get("item-to-workflow");
@@ -110,11 +106,7 @@ public class StartWorkflowWizard extends BaseWizardBean
public void restored()
{
// reset the workflow package rich list so everything gets re-evaluated
if (this.packageItemsRichList != null)
{
this.packageItemsRichList.setValue(null);
this.packageItemsRichList = null;
}
resetRichList();
}
@Override
@@ -190,13 +182,14 @@ public class StartWorkflowWizard extends BaseWizardBean
{
String stepName = Application.getWizardManager().getCurrentStepName();
if ("options".equals(stepName) && this.startTaskNode == null)
if ("options".equals(stepName) &&
(this.selectedWorkflow.equals(this.previouslySelectedWorkflow) == false))
{
// retrieve the start task for the selected workflow, get the task
// definition and create a transient node to allow the property
// sheet to collect the required data.
WorkflowDefinition flowDef = this.workflows.get(this.selectedWorkflow);
WorkflowDefinition flowDef = this.workflows.get(this.selectedWorkflow);
if (logger.isDebugEnabled())
logger.debug("Selected workflow: "+ flowDef);
@@ -211,20 +204,60 @@ public class StartWorkflowWizard extends BaseWizardBean
this.startTaskNode = new TransientNode(taskDef.metadata.getName(),
"task_" + System.currentTimeMillis(), null);
}
// we also need to reset the resources list so that the actions get re-evaluated
resetRichList();
}
return null;
}
@Override
public String back()
{
String stepName = Application.getWizardManager().getCurrentStepName();
// if we have come back to the "choose-workflow" step remember
// the current workflow selection
if ("choose-workflow".equals(stepName))
{
this.previouslySelectedWorkflow = this.selectedWorkflow;
}
return null;
}
@Override
public boolean getNextButtonDisabled()
{
return this.nextButtonDisabled;
}
@Override
public String getContainerTitle()
{
String wizTitle = null;
ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance());
String stepName = Application.getWizardManager().getCurrentStepName();
if ("choose-workflow".equals(stepName) == false && this.selectedWorkflow != null)
{
String titlePattern = bundle.getString("start_named_workflow_wizard");
WorkflowDefinition workflowDef = this.workflows.get(this.selectedWorkflow);
wizTitle = MessageFormat.format(titlePattern, new Object[] {workflowDef.title});
}
else
{
wizTitle = bundle.getString("start_workflow_wizard");
}
return wizTitle;
}
// ------------------------------------------------------------------------------
// Event Handlers
/**
* Prepares the dialog to allow the user to add an item to the workflow package
*
@@ -293,7 +326,7 @@ public class StartWorkflowWizard extends BaseWizardBean
// reset the rich list so it re-renders
this.packageItemsRichList.setValue(null);
}
// ------------------------------------------------------------------------------
// Bean Getters and Setters
@@ -465,33 +498,34 @@ public class StartWorkflowWizard extends BaseWizardBean
*/
public List<SelectItem> getStartableWorkflows()
{
if (this.availableWorkflows == null)
// NOTE: we don't cache the list of startable workflows as they could get
// updated, in which case we need the latest instance id, they could
// theoretically also get removed.
this.availableWorkflows = new ArrayList<SelectItem>(4);
this.workflows = new HashMap<String, WorkflowDefinition>(4);
List<WorkflowDefinition> workflowDefs = this.workflowService.getDefinitions();
for (WorkflowDefinition workflowDef : workflowDefs)
{
this.availableWorkflows = new ArrayList<SelectItem>(4);
this.workflows = new HashMap<String, WorkflowDefinition>(4);
List<WorkflowDefinition> workflowDefs = this.workflowService.getDefinitions();
for (WorkflowDefinition workflowDef : workflowDefs)
String label = workflowDef.title;
if (workflowDef.description != null && workflowDef.description.length() > 0)
{
String label = workflowDef.title;
if (workflowDef.description != null && workflowDef.description.length() > 0)
{
label = label + " (" + workflowDef.description + ")";
}
this.availableWorkflows.add(new SelectItem(workflowDef.id, label));
this.workflows.put(workflowDef.id, workflowDef);
}
// set the initial selected workflow to the first in the list, unless there are no
// workflows, in which disable the next button
if (this.availableWorkflows.size() > 0)
{
this.selectedWorkflow = (String)this.availableWorkflows.get(0).getValue();
}
else
{
this.nextButtonDisabled = true;
label = label + " (" + workflowDef.description + ")";
}
this.availableWorkflows.add(new SelectItem(workflowDef.id, label));
this.workflows.put(workflowDef.id, workflowDef);
}
// set the initial selected workflow to the first in the list, unless there are no
// workflows, in which disable the next button
if (this.availableWorkflows.size() > 0)
{
this.selectedWorkflow = (String)this.availableWorkflows.get(0).getValue();
}
else
{
this.nextButtonDisabled = true;
}
return availableWorkflows;
@@ -559,4 +593,19 @@ public class StartWorkflowWizard extends BaseWizardBean
{
this.workflowService = workflowService;
}
// ------------------------------------------------------------------------------
// Helper methods
/**
* Resets the rich list
*/
protected void resetRichList()
{
if (this.packageItemsRichList != null)
{
this.packageItemsRichList.setValue(null);
this.packageItemsRichList = null;
}
}
}

View File

@@ -196,7 +196,10 @@ public class WorkflowBean
}
// add the targets for this particular association
params.put(assocQName, (Serializable)targets);
if (targets.size() > 0)
{
params.put(assocQName, (Serializable)targets);
}
}
return params;
@@ -223,19 +226,8 @@ public class WorkflowBean
node.getProperties().put("id", task.id);
// add the name of the source space (if there is one)
// TODO: remove this workaroud where JBPM may return a String and not the NodeRef
Serializable obj = task.properties.get(WorkflowModel.PROP_CONTEXT);
NodeRef context = null;
if (obj instanceof NodeRef)
{
context = (NodeRef)obj;
}
else if (obj instanceof String)
{
context = new NodeRef((String)obj);
}
if (context != null)
NodeRef context = (NodeRef)task.properties.get(WorkflowModel.PROP_CONTEXT);
if (context != null && this.nodeService.exists(context))
{
String name = Repository.getNameForNode(this.nodeService, context);
node.getProperties().put("sourceSpaceName", name);
@@ -268,7 +260,6 @@ public class WorkflowBean
// add the workflow instance id and name this taks belongs to
node.getProperties().put("workflowInstanceId", task.path.instance.id);
node.getProperties().put("workflowInstanceName", task.path.instance.definition.title);
}
return node;