First cut of the start workflow wizard

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3483 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2006-08-11 12:22:18 +00:00
parent 60cf6056c5
commit 65f394a878
13 changed files with 663 additions and 31 deletions

View File

@@ -36,8 +36,6 @@ import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.web.app.Application;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Lighweight client side representation of a node held in the repository.
@@ -48,28 +46,25 @@ public class Node implements Serializable
{
private static final long serialVersionUID = 3544390322739034169L;
protected static final Log logger = LogFactory.getLog(Node.class);
protected NodeRef nodeRef;
private String name;
private QName type;
private String path;
private String id;
private Set<QName> aspects = null;
private Map<String, Boolean> permissions;
private Boolean locked = null;
private Boolean workingCopyOwner = null;
protected String name;
protected QName type;
protected String path;
protected String id;
protected Set<QName> aspects = null;
protected Map<String, Boolean> permissions;
protected Boolean locked = null;
protected Boolean workingCopyOwner = null;
protected QNameNodeMap<String, Object> properties;
protected boolean propsRetrieved = false;
protected ServiceRegistry services = null;
protected boolean childAssocsRetrieved = false;
protected QNameNodeMap childAssociations;
protected boolean assocsRetrieved = false;
protected QNameNodeMap associations;
private boolean childAssocsRetrieved = false;
private QNameNodeMap childAssociations;
private Map<String, Map<String, ChildAssociationRef>> childAssociationsAdded;
private Map<String, Map<String, ChildAssociationRef>> childAssociationsRemoved;
private boolean assocsRetrieved = false;
private QNameNodeMap associations;
private Map<String, Map<String, AssociationRef>> associationsAdded;
private Map<String, Map<String, AssociationRef>> associationsRemoved;
@@ -94,7 +89,7 @@ public class Node implements Serializable
/**
* @return All the properties known about this node.
*/
public Map<String, Object> getProperties()
public final Map<String, Object> getProperties()
{
if (this.propsRetrieved == false)
{
@@ -120,7 +115,7 @@ public class Node implements Serializable
{
if (this.assocsRetrieved == false)
{
associations = new QNameNodeMap(getServiceRegistry().getNamespaceService(), this);
this.associations = new QNameNodeMap(getServiceRegistry().getNamespaceService(), this);
List<AssociationRef> assocs = getServiceRegistry().getNodeService().getTargetAssocs(this.nodeRef, RegexQNamePattern.MATCH_ALL);
@@ -341,7 +336,7 @@ public class Node implements Serializable
*
* @return true if the permission is applied to the node for this user, false otherwise
*/
public final boolean hasPermission(String permission)
public boolean hasPermission(String permission)
{
Boolean valid = null;
if (permissions != null)

View File

@@ -16,15 +16,11 @@
*/
package org.alfresco.web.bean.repository;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.alfresco.service.namespace.NamespacePrefixResolver;
import org.alfresco.service.namespace.QNameMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* A extension of the repo QNameMap to provide custom property resolving support for Node wrappers.
@@ -86,6 +82,7 @@ public final class QNameNodeMap<K,V> extends QNameMap implements Map, Cloneable
/**
* @see java.util.Map#get(java.lang.Object)
*/
@SuppressWarnings("unchecked")
public Object get(Object key)
{
String qnameKey = Repository.resolveToQNameString(key.toString());
@@ -120,6 +117,7 @@ public final class QNameNodeMap<K,V> extends QNameMap implements Map, Cloneable
/**
* Shallow copy the map by copying keys and values into a new QNameNodeMap
*/
@SuppressWarnings("unchecked")
public Object clone()
{
QNameNodeMap map = new QNameNodeMap(this.resolver, this.parent);

View File

@@ -0,0 +1,141 @@
package org.alfresco.web.bean.repository;
import java.io.Serializable;
import java.util.HashSet;
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.DictionaryService;
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.namespace.QName;
import org.alfresco.util.GUID;
/**
* Represents a transient node i.e. it is not and will not be present in the repository.
* <p>
* This type of node is typically used to drive the property sheet when data collection
* is required for a type but the node does not need to be stored in the repository. An
* example use is the workflow, transient nodes are used to collect workitem metadata.
*
* @author gavinc
*/
public class TransientNode extends Node
{
private static final long serialVersionUID = 2140554155948154106L;
/**
* Constructor.
* <p>
* NOTE: The name is NOT automatically added to the map of properties,
* if you need the name of this node to be in the map then add it to
* the map passed in to this constructor.
*
* @param type The type this node will represent
* @param name The name of the node
* @param data The properties and associations this node will have
*/
public TransientNode(QName type, String name, Map<QName, Serializable> data)
{
// create a dummy NodeRef to pass to the constructor
super(new NodeRef(Repository.getStoreRef(), GUID.generate()));
this.type = type;
this.name = name;
// initialise the node
initNode(data);
}
/**
* Initialises the node.
*
* @param data The properties and associations to initialise the node with
*/
protected void initNode(Map<QName, Serializable> data)
{
// setup the transient node so that the super class methods work
// and do not need to go back to the repository
DictionaryService ddService = this.getServiceRegistry().getDictionaryService();
// marshall the given properties and associations into the internal maps
this.associations = new QNameNodeMap(getServiceRegistry().getNamespaceService(), this);
this.childAssociations = new QNameNodeMap(getServiceRegistry().getNamespaceService(), this);
if (data != null)
{
// go through all data items and allocate to the correct internal list
for (QName item : data.keySet())
{
PropertyDefinition propDef = ddService.getProperty(item);
if (propDef != null)
{
this.properties.put(item, data.get(item));
}
else
{
// see if the item is either type of association
AssociationDefinition assocDef = ddService.getAssociation(item);
if (assocDef != null)
{
if (assocDef.isChild())
{
this.childAssociations.put(item, data.get(item));
}
else
{
this.associations.put(item, data.get(item));
}
}
}
}
}
// show that the maps have been initialised
this.propsRetrieved = true;
this.assocsRetrieved = true;
this.childAssocsRetrieved = true;
// setup the list of aspects the node would have
TypeDefinition typeDef = ddService.getType(this.type);
if (typeDef == null)
{
throw new AlfrescoRuntimeException("Failed to find type definition for start task: " + this.type);
}
this.aspects = new HashSet<QName>();
for (AspectDefinition aspectDef : typeDef.getDefaultAspects())
{
this.aspects.add(aspectDef.getName());
}
// setup remaining variables
this.path = "";
this.locked = Boolean.FALSE;
this.workingCopyOwner = Boolean.FALSE;
}
@Override
public boolean hasPermission(String permission)
{
return true;
}
@Override
public void reset()
{
// don't reset anything otherwise we'll lose our data
// with no way of getting it back!!
}
@Override
public String toString()
{
return "Transient node of type: " + getType() +
"\nProperties: " + this.getProperties().toString();
}
}