Search in sources :

Example 11 with FieldData

use of org.alfresco.repo.forms.FormData.FieldData in project alfresco-repository by Alfresco.

the class WorkflowFormProcessorTest method checkPackageActionGroups.

private void checkPackageActionGroups(FormData formData) {
    FieldData pckgActionData = formData.getFieldData("prop_bpm_packageActionGroup");
    assertNotNull(pckgActionData);
    assertEquals("add_package_item_actions", pckgActionData.getValue());
    FieldData pckgItemActionData = formData.getFieldData("prop_bpm_packageItemActionGroup");
    assertNotNull(pckgItemActionData);
    assertEquals("start_package_item_actions", pckgItemActionData.getValue());
}
Also used : FieldData(org.alfresco.repo.forms.FormData.FieldData)

Example 12 with FieldData

use of org.alfresco.repo.forms.FormData.FieldData in project alfresco-repository by Alfresco.

the class TypeAndAspectsFormProcessor method createNode.

@SuppressWarnings("unchecked")
@Override
protected NodeRef createNode(TypeDefinition typeDef, FormData data) {
    NodeRef nodeRef = null;
    if (data != null) {
        // firstly, ensure we have a destination to create the node in
        NodeRef parentRef = null;
        FieldData destination = data.getFieldData(DESTINATION);
        if (destination == null) {
            throw new FormException("Failed to persist form for '" + typeDef.getName().toPrefixString(this.namespaceService) + "' as '" + DESTINATION + "' data was not provided.");
        }
        // create the parent NodeRef
        String destinationValue = (String) destination.getValue();
        parentRef = getParentNodeRef(destinationValue);
        if (parentRef == null) {
            throw new FormException("Failed to persist form for '" + typeDef.getName().toPrefixString(this.namespaceService) + "' as '" + destinationValue + "' does not exist as path or NodeRef in the system.");
        }
        data.removeFieldData(DESTINATION);
        // if a name property is present in the form data use it as the node
        // name,
        // otherwise generate a guid
        String nodeName = null;
        FieldData nameData = data.getFieldData(NAME_PROP_DATA);
        if (nameData != null) {
            nodeName = (String) nameData.getValue();
            // remove the name data otherwise 'rename' gets called in
            // persistNode
            data.removeFieldData(NAME_PROP_DATA);
        }
        if (nodeName == null || nodeName.length() == 0) {
            nodeName = GUID.generate();
        }
        // create the node
        Map<QName, Serializable> nodeProps = new HashMap<QName, Serializable>(1);
        nodeProps.put(ContentModel.PROP_NAME, nodeName);
        nodeRef = this.nodeService.createNode(parentRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName(nodeName)), typeDef.getName(), nodeProps).getChildRef();
        // generating the form
        for (QName qname : getRequestedAspects()) {
            this.nodeService.addAspect(nodeRef, qname, new HashMap<QName, Serializable>());
        }
        // if the physical structure is configured we'll create for now
        // simple folders
        FieldData physicalStructure = data.getFieldData(PHYSICAL_STRUCTURE);
        if (physicalStructure != null) {
            List<String> folderPhysicalStructure = (List<String>) physicalStructure.getValue();
            createPhysicalStructure(nodeRef, folderPhysicalStructure);
            data.removeFieldData(PHYSICAL_STRUCTURE);
        }
    }
    return nodeRef;
}
Also used : FieldData(org.alfresco.repo.forms.FormData.FieldData) NodeRef(org.alfresco.service.cmr.repository.NodeRef) FormException(org.alfresco.repo.forms.FormException) Serializable(java.io.Serializable) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

FieldData (org.alfresco.repo.forms.FormData.FieldData)12 Serializable (java.io.Serializable)6 HashMap (java.util.HashMap)6 QName (org.alfresco.service.namespace.QName)6 ArrayList (java.util.ArrayList)4 FormException (org.alfresco.repo.forms.FormException)4 NodeRef (org.alfresco.service.cmr.repository.NodeRef)4 List (java.util.List)3 DataTypeDefinition (org.alfresco.service.cmr.dictionary.DataTypeDefinition)2 PropertyDefinition (org.alfresco.service.cmr.dictionary.PropertyDefinition)2 TypeDefinition (org.alfresco.service.cmr.dictionary.TypeDefinition)2 Collection (java.util.Collection)1 StringTokenizer (java.util.StringTokenizer)1 FieldDefinition (org.alfresco.repo.forms.FieldDefinition)1 ScriptableHashMap (org.alfresco.repo.jscript.ScriptableHashMap)1 Action (org.alfresco.service.cmr.action.Action)1 ParameterDefinition (org.alfresco.service.cmr.action.ParameterDefinition)1 AssociationDefinition (org.alfresco.service.cmr.dictionary.AssociationDefinition)1 ChildAssociationDefinition (org.alfresco.service.cmr.dictionary.ChildAssociationDefinition)1 DictionaryService (org.alfresco.service.cmr.dictionary.DictionaryService)1