ScriptNode activeWorkflows getter. Workflow JS API constructors made public.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10386 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mike Hatfield 2008-08-15 16:53:20 +00:00
parent 18db34ffdb
commit ffda0d4f49
7 changed files with 49 additions and 13 deletions

View File

@ -48,6 +48,7 @@ import org.alfresco.repo.thumbnail.ThumbnailDetails;
import org.alfresco.repo.thumbnail.ThumbnailRegistry; import org.alfresco.repo.thumbnail.ThumbnailRegistry;
import org.alfresco.repo.thumbnail.script.ScriptThumbnail; import org.alfresco.repo.thumbnail.script.ScriptThumbnail;
import org.alfresco.repo.version.VersionModel; import org.alfresco.repo.version.VersionModel;
import org.alfresco.repo.workflow.jscript.JscriptWorkflowInstance;
import org.alfresco.scripts.ScriptException; import org.alfresco.scripts.ScriptException;
import org.alfresco.service.ServiceRegistry; import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.Action;
@ -74,6 +75,8 @@ import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.version.Version; import org.alfresco.service.cmr.version.Version;
import org.alfresco.service.cmr.version.VersionHistory; import org.alfresco.service.cmr.version.VersionHistory;
import org.alfresco.service.cmr.version.VersionType; import org.alfresco.service.cmr.version.VersionType;
import org.alfresco.service.cmr.workflow.WorkflowInstance;
import org.alfresco.service.cmr.workflow.WorkflowService;
import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.service.namespace.RegexQNamePattern;
@ -133,7 +136,7 @@ public class ScriptNode implements Serializable, Scopeable
/** The target associations from this node */ /** The target associations from this node */
private ScriptableQNameMap<String, Object> targetAssocs = null; private ScriptableQNameMap<String, Object> targetAssocs = null;
/** The source assoications to this node */ /** The source associations to this node */
private ScriptableQNameMap<String, Object> sourceAssocs = null; private ScriptableQNameMap<String, Object> sourceAssocs = null;
/** The child associations for this node */ /** The child associations for this node */
@ -148,6 +151,9 @@ public class ScriptNode implements Serializable, Scopeable
/** The versions of this node */ /** The versions of this node */
private Scriptable versions = null; private Scriptable versions = null;
/** The active workflows acting on this node */
private Scriptable activeWorkflows = null;
protected ServiceRegistry services = null; protected ServiceRegistry services = null;
private NodeService nodeService = null; private NodeService nodeService = null;
private Boolean isDocument = null; private Boolean isDocument = null;
@ -2270,6 +2276,35 @@ public class ScriptNode implements Serializable, Scopeable
return nodes; return nodes;
} }
// ------------------------------------------------------------------------------
// Workflow methods
/**
* Get active workflow instances this node belongs to
*
* @return the active workflow instances this node belongs to
*/
public Scriptable getActiveWorkflows()
{
if (this.activeWorkflows == null)
{
WorkflowService workflowService = this.services.getWorkflowService();
List<WorkflowInstance> workflowInstances = workflowService.getWorkflowsForContent(this.nodeRef, true);
Object[] jsWorkflowInstances = new Object[workflowInstances.size()];
int index = 0;
for (WorkflowInstance workflowInstance : workflowInstances)
{
jsWorkflowInstances[index++] = new JscriptWorkflowInstance(workflowInstance, this.services, this.scope);
}
this.activeWorkflows = Context.getCurrentContext().newArray(this.scope, jsWorkflowInstances);
}
return this.activeWorkflows;
}
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Helper methods // Helper methods
@ -2380,6 +2415,7 @@ public class ScriptNode implements Serializable, Scopeable
this.isContainer = null; this.isContainer = null;
this.parent = null; this.parent = null;
this.primaryParentAssoc = null; this.primaryParentAssoc = null;
this.activeWorkflows = null;
} }
/** /**

View File

@ -78,7 +78,7 @@ public class JscriptWorkflowDefinition implements Serializable
* @param serviceRegistry reference to the Service Registry * @param serviceRegistry reference to the Service Registry
* @param scope the root scripting scope for this object * @param scope the root scripting scope for this object
*/ */
JscriptWorkflowDefinition(final WorkflowDefinition cmrWorkflowDefinition, public JscriptWorkflowDefinition(final WorkflowDefinition cmrWorkflowDefinition,
final ServiceRegistry serviceRegistry, final Scriptable scope) final ServiceRegistry serviceRegistry, final Scriptable scope)
{ {
this.id = cmrWorkflowDefinition.id; this.id = cmrWorkflowDefinition.id;
@ -101,7 +101,7 @@ public class JscriptWorkflowDefinition implements Serializable
* @param serviceRegistry reference to the Service Registry * @param serviceRegistry reference to the Service Registry
* @param scope root scripting scope for this object * @param scope root scripting scope for this object
*/ */
JscriptWorkflowDefinition(final String id, final String name, final String version, public JscriptWorkflowDefinition(final String id, final String name, final String version,
final String title, final String description, ServiceRegistry serviceRegistry, final String title, final String description, ServiceRegistry serviceRegistry,
final Scriptable scope) final Scriptable scope)
{ {

View File

@ -77,7 +77,7 @@ public class JscriptWorkflowInstance implements Serializable
* @param serviceRegistry Service Registry instance * @param serviceRegistry Service Registry instance
* @param scope the root scripting scope for this object * @param scope the root scripting scope for this object
*/ */
JscriptWorkflowInstance(final String id, final String description, final Date startDate, public JscriptWorkflowInstance(final String id, final String description, final Date startDate,
final ServiceRegistry serviceRegistry, final Scriptable scope) final ServiceRegistry serviceRegistry, final Scriptable scope)
{ {
this.id = id; this.id = id;
@ -97,7 +97,7 @@ public class JscriptWorkflowInstance implements Serializable
* @param serviceRegistry Service Registry instance * @param serviceRegistry Service Registry instance
* @param scope the root scripting scope for this object * @param scope the root scripting scope for this object
*/ */
JscriptWorkflowInstance(final WorkflowInstance public JscriptWorkflowInstance(final WorkflowInstance
cmrWorkflowInstance, final ServiceRegistry serviceRegistry, final Scriptable scope) cmrWorkflowInstance, final ServiceRegistry serviceRegistry, final Scriptable scope)
{ {
this.id = cmrWorkflowInstance.id; this.id = cmrWorkflowInstance.id;

View File

@ -73,7 +73,7 @@ public class JscriptWorkflowNode implements Serializable
* @param scope root scripting scope for this object * @param scope root scripting scope for this object
* @param serviceRegistry service registry object * @param serviceRegistry service registry object
*/ */
JscriptWorkflowNode(String name, String title, String description, public JscriptWorkflowNode(String name, String title, String description,
boolean isTaskNode, ArrayList<JscriptWorkflowTransition> transitions, boolean isTaskNode, ArrayList<JscriptWorkflowTransition> transitions,
Scriptable scope, ServiceRegistry serviceRegistry) Scriptable scope, ServiceRegistry serviceRegistry)
{ {
@ -96,7 +96,7 @@ public class JscriptWorkflowNode implements Serializable
* @param scope root scripting scope for this newly instantiated object * @param scope root scripting scope for this newly instantiated object
* @param serviceRegistry service registry object * @param serviceRegistry service registry object
*/ */
JscriptWorkflowNode(WorkflowNode workflowNode, Scriptable scope, ServiceRegistry serviceRegistry) public JscriptWorkflowNode(WorkflowNode workflowNode, Scriptable scope, ServiceRegistry serviceRegistry)
{ {
this.name = workflowNode.name; this.name = workflowNode.name;
this.title = workflowNode.title; this.title = workflowNode.title;

View File

@ -77,7 +77,7 @@ public class JscriptWorkflowPath implements Serializable
* @param serviceRegistry Service Registry object * @param serviceRegistry Service Registry object
* @param scope the root scripting scope for this object * @param scope the root scripting scope for this object
*/ */
JscriptWorkflowPath(final String id, final WorkflowNode node, final JscriptWorkflowInstance instance, public JscriptWorkflowPath(final String id, final WorkflowNode node, final JscriptWorkflowInstance instance,
final ServiceRegistry serviceRegistry, final Scriptable scope) final ServiceRegistry serviceRegistry, final Scriptable scope)
{ {
this.id = id; this.id = id;
@ -97,7 +97,7 @@ public class JscriptWorkflowPath implements Serializable
* @param serviceRegistry Service Registry object * @param serviceRegistry Service Registry object
* @param scope the root scripting scope for this object * @param scope the root scripting scope for this object
*/ */
JscriptWorkflowPath(final WorkflowPath cmrWorkflowPath, public JscriptWorkflowPath(final WorkflowPath cmrWorkflowPath,
final ServiceRegistry serviceRegistry, Scriptable scope) final ServiceRegistry serviceRegistry, Scriptable scope)
{ {
this.id = cmrWorkflowPath.id; this.id = cmrWorkflowPath.id;

View File

@ -77,7 +77,7 @@ public class JscriptWorkflowTask implements Serializable
* @param description workflow task description * @param description workflow task description
* @param serviceRegistry Service Registry object * @param serviceRegistry Service Registry object
*/ */
JscriptWorkflowTask(final String id, final String name, final String title, public JscriptWorkflowTask(final String id, final String name, final String title,
final String description, final ServiceRegistry serviceRegistry, final String description, final ServiceRegistry serviceRegistry,
final ScriptableQNameMap<String, Serializable> properties) final ScriptableQNameMap<String, Serializable> properties)
{ {
@ -96,7 +96,7 @@ public class JscriptWorkflowTask implements Serializable
* @param cmrWorkflowTask an instance of WorkflowTask from CMR workflow object model * @param cmrWorkflowTask an instance of WorkflowTask from CMR workflow object model
* @param serviceRegistry Service Registry object * @param serviceRegistry Service Registry object
*/ */
JscriptWorkflowTask(final WorkflowTask cmrWorkflowTask, public JscriptWorkflowTask(final WorkflowTask cmrWorkflowTask,
final ServiceRegistry serviceRegistry) final ServiceRegistry serviceRegistry)
{ {
this.id = cmrWorkflowTask.id; this.id = cmrWorkflowTask.id;

View File

@ -49,7 +49,7 @@ public class JscriptWorkflowTransition implements Serializable
* @param title Workflow transition title * @param title Workflow transition title
* @param description Workflow transition description * @param description Workflow transition description
*/ */
JscriptWorkflowTransition(String id, String title, String description) public JscriptWorkflowTransition(String id, String title, String description)
{ {
this.id = id; this.id = id;
this.title = title; this.title = title;
@ -63,7 +63,7 @@ public class JscriptWorkflowTransition implements Serializable
* @param transition CMR WorkflowTransition object from which * @param transition CMR WorkflowTransition object from which
* to create a new instance of this class * to create a new instance of this class
*/ */
JscriptWorkflowTransition(WorkflowTransition transition) public JscriptWorkflowTransition(WorkflowTransition transition)
{ {
this.id = transition.id; this.id = transition.id;
this.title = transition.title; this.title = transition.title;