Merged DEV/RM-DEV to HEAD

14731: Branch for continued records managment development
   14739: Records Management Action Service updates
   14756: Declare/Undeclare record RM actions added
   14791: RM dynamic modelling Stage One.
   14878: Record mamagement events
   14927: Importing the recordsCustomModel.xml
   14993: RM. Handle changes to the Vital Record Definition
   14996: Checking in comments that record the fact that this class is likely to be deleted soon.
   15011: Typo in PublishVitalRecordDefinitionAction.
   15027: Custom properties and associations for RM
   15053: First cut of records management events
   15057: Vital Records refactor, renaming and test fixing
   15060: Form config for RM types and aspects updated to reflect current model
   15071: - MOB-988: Completed type based form support, means that 'create' pages can now be implemented for RM
          - Updated form test page to include 'destination' field to allow instances to be created
   15075: Refactored defineCustomProp,Assoc out into RM actions.
Modified: svn:mergeinfo
   Merged /alfresco/BRANCHES/DEV/RM-DEV:r14731-15075

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@15076 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2009-07-06 10:07:37 +00:00
parent b695037db1
commit e025d28ebd
3 changed files with 59 additions and 9 deletions

View File

@@ -37,6 +37,7 @@ import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.forms.AssociationFieldDefinition.Direction;
import org.alfresco.repo.forms.PropertyFieldDefinition.FieldConstraint;
import org.alfresco.repo.forms.processor.node.TypeFormProcessor;
import org.alfresco.repo.jscript.ClasspathScriptLocation;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.service.cmr.repository.ContentData;
@@ -921,7 +922,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest
}
// supply the destination
data.addFieldData("destination", this.folder.toString());
data.addFieldData(TypeFormProcessor.DESTINATION, this.folder.toString());
// persist the data
NodeRef newNode = (NodeRef)this.formService.saveForm(new Item(TYPE_FORM_ITEM_KIND, "cm:content"), data);
@@ -936,6 +937,13 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest
// check the titled aspect was automatically applied
assertTrue("Expecting the cm:titled to have been applied",
this.nodeService.hasAspect(this.document, ContentModel.ASPECT_TITLED));
// test different forms of itemId's
newNode = (NodeRef)this.formService.saveForm(new Item(TYPE_FORM_ITEM_KIND, "cm_content"), data);
assertNotNull("Expected new node to be created using itemId cm_content", newNode);
newNode = (NodeRef)this.formService.saveForm(new Item(TYPE_FORM_ITEM_KIND, ContentModel.TYPE_CONTENT.toString()), data);
assertNotNull("Expected new node to be created using itemId " + ContentModel.TYPE_CONTENT.toString(), newNode);
}
public void testNoForm() throws Exception

View File

@@ -48,6 +48,7 @@ import org.alfresco.repo.forms.AssociationFieldDefinition.Direction;
import org.alfresco.repo.forms.FormData.FieldData;
import org.alfresco.repo.forms.PropertyFieldDefinition.FieldConstraint;
import org.alfresco.repo.forms.processor.FilteredFormProcessor;
import org.alfresco.service.cmr.dictionary.AspectDefinition;
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
import org.alfresco.service.cmr.dictionary.ChildAssociationDefinition;
import org.alfresco.service.cmr.dictionary.Constraint;
@@ -308,20 +309,39 @@ public class NodeFormProcessor extends FilteredFormProcessor
// get data dictionary definition for node if it is provided
QName type = null;
Map<QName, Serializable> propValues = Collections.emptyMap();
Map<QName, PropertyDefinition> propDefs = null;
Map<QName, AssociationDefinition> assocDefs = null;
if (nodeRef != null)
{
type = this.nodeService.getType(nodeRef);
typeDef = this.dictionaryService.getAnonymousType(type, this.nodeService.getAspects(nodeRef));
// NOTE: the anonymous type returns all property and association defs
// for all aspects applied as well as the type
propDefs = typeDef.getProperties();
assocDefs = typeDef.getAssociations();
propValues = this.nodeService.getProperties(nodeRef);
}
else
{
type = typeDef.getName();
}
Map<QName, PropertyDefinition> propDefs = typeDef.getProperties();
Map<QName, AssociationDefinition> assocDefs = typeDef.getAssociations();
// we only get the properties and associations of the actual type so
// we also need to manually get properties and associations from any
// mandatory aspects
propDefs = new HashMap<QName, PropertyDefinition>(16);
assocDefs = new HashMap<QName, AssociationDefinition>(16);
propDefs.putAll(typeDef.getProperties());
assocDefs.putAll(typeDef.getAssociations());
List<AspectDefinition> aspects = typeDef.getDefaultAspects(true);
for (AspectDefinition aspect : aspects)
{
propDefs.putAll(aspect.getProperties());
assocDefs.putAll(aspect.getAssociations());
}
}
for (String fieldName : fields)
{

View File

@@ -59,9 +59,10 @@ public class TypeFormProcessor extends NodeFormProcessor
/** Logger */
private static Log logger = LogFactory.getLog(TypeFormProcessor.class);
protected static final String DESTINATION = "destination";
protected static final String NAME_PROP_DATA = PROP + DATA_KEY_SEPARATOR + "cm" + DATA_KEY_SEPARATOR + "name";
public static final String DESTINATION = "alf_destination";
/*
* @see org.alfresco.repo.forms.processor.node.NodeFormProcessor#getTypedItem(org.alfresco.repo.forms.Item)
*/
@@ -73,8 +74,29 @@ public class TypeFormProcessor extends NodeFormProcessor
try
{
// convert the prefix type into full QName representation
// TODO: Also look for and deal with full QName as itemId
QName type = QName.createQName(item.getId(), this.namespaceService);
// the type name may be provided in the prefix form i.e.
// prefix:type, the : may be replaced with _ if the item id
// was passed on a URL or the full qname may be provided.
QName type = null;
String itemId = item.getId();
if (itemId.startsWith("{"))
{
// item id looks like a full qname
type = QName.createQName(itemId);
}
else if (itemId.indexOf("_") != -1)
{
// if item id contains _ change the first occurrence to :
// as it's more than likely been converted for URL use
int idx = itemId.indexOf("_");
String parsedItemId = itemId.substring(0, idx) + ":" + itemId.substring(idx+1);
type = QName.createQName(parsedItemId, this.namespaceService);
}
else
{
// try and create the QName using the item id as is
type = QName.createQName(itemId, this.namespaceService);
}
// retrieve the type from the dictionary
typeDef = this.dictionaryService.getType(type);
@@ -246,7 +268,7 @@ public class TypeFormProcessor extends NodeFormProcessor
{
throw new FormException("Failed to persist form for '" +
typeDef.getName().toPrefixString(this.namespaceService) +
"' as destination data was not present.");
"' as '" + DESTINATION + "' data was not provided.");
}
// create the parent NodeRef