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());
}
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;
}
Aggregations