use of org.alfresco.repo.forms.FormData.FieldData in project alfresco-repository by Alfresco.
the class TypeAndAspectsFormProcessor method persistNode.
@Override
protected void persistNode(NodeRef nodeRef, FormData data) {
super.persistNode(nodeRef, data);
QName type = this.nodeService.getType(nodeRef);
Set<QName> aspectNames = getAspectNames(getTypedItem(typeItem));
TypeDefinition typeDef = this.dictionaryService.getAnonymousType(type, aspectNames);
Map<QName, PropertyDefinition> propDefs = typeDef.getProperties();
Map<QName, Serializable> propsToPersist = new HashMap<QName, Serializable>();
for (FieldData fieldData : data) {
String fieldName = fieldData.getName();
if (fieldName.startsWith(PROP_DATA_PREFIX)) {
processPropertyPersist(nodeRef, propDefs, fieldData, propsToPersist, data);
}
}
this.nodeService.addProperties(nodeRef, propsToPersist);
}
use of org.alfresco.repo.forms.FormData.FieldData in project alfresco-repository by Alfresco.
the class RemoveChildAssocCommand method persistNode.
/**
* Persists the given FormData on the given NodeRef
*
* @param nodeRef The NodeRef to persist the form data on
* @param data The FormData to persist
*/
protected void persistNode(NodeRef nodeRef, FormData data) {
// get the property definitions for the type of node being persisted
QName type = this.nodeService.getType(nodeRef);
TypeDefinition typeDef = this.dictionaryService.getAnonymousType(type, this.nodeService.getAspects(nodeRef));
Map<QName, AssociationDefinition> assocDefs = typeDef.getAssociations();
Map<QName, ChildAssociationDefinition> childAssocDefs = typeDef.getChildAssociations();
Map<QName, PropertyDefinition> propDefs = typeDef.getProperties();
Map<QName, Serializable> propsToPersist = new HashMap<QName, Serializable>(data.getNumberOfFields());
List<AbstractAssocCommand> assocsToPersist = new ArrayList<AbstractAssocCommand>();
for (FieldData fieldData : data) {
// NOTE: ignore file fields for now, not supported yet!
if (fieldData.isFile() == false) {
String fieldName = fieldData.getName();
if (fieldName.startsWith(PROP_DATA_PREFIX)) {
processPropertyPersist(nodeRef, propDefs, fieldData, propsToPersist, data);
} else if (fieldName.startsWith(ASSOC_DATA_PREFIX)) {
processAssociationPersist(nodeRef, assocDefs, childAssocDefs, fieldData, assocsToPersist);
} else if (getLogger().isWarnEnabled()) {
getLogger().warn("Ignoring unrecognised field '" + fieldName + "'");
}
}
}
// persist the properties using addProperties as this changes the repo
// values of
// those properties included in the Map, but leaves any other property
// values unchanged,
// whereas setProperties causes the deletion of properties that are not
// included in the Map.
this.nodeService.addProperties(nodeRef, propsToPersist);
for (AbstractAssocCommand cmd : assocsToPersist) {
// TODO If there is an attempt to add and remove the same assoc in
// one request,
// we could drop each request and do nothing.
cmd.updateAssociations(nodeService);
}
}
use of org.alfresco.repo.forms.FormData.FieldData in project alfresco-repository by Alfresco.
the class ActionFormProcessor method getActionedUponNodeRef.
/**
* This method returns the actionedUponNodeRef based on the submitted form data.
*/
private NodeRef getActionedUponNodeRef(ActionDefinition item, FormData data) {
FieldData actionedUponNodeRef = data.getFieldData(DESTINATION);
NodeRef result = null;
// executer implementations will throw an exception on execution.
if (actionedUponNodeRef != null) {
String nodeRefString = (String) actionedUponNodeRef.getValue();
if (NodeRef.isNodeRef(nodeRefString)) {
result = new NodeRef(nodeRefString);
} else {
// We will disallow a malformed actionedUponNodeRef string
throw new FormException("Illegal actionedUponNodeRef: " + nodeRefString);
}
}
return result;
}
use of org.alfresco.repo.forms.FormData.FieldData in project alfresco-repository by Alfresco.
the class ScriptFormData method getData.
public ScriptableHashMap<String, ScriptFieldData> getData() {
ScriptableHashMap<String, ScriptFieldData> result = new ScriptableHashMap<String, ScriptFieldData>();
if (this.formData != null) {
for (FieldData fieldData : formData) {
ScriptFieldData wrappedFieldData = new ScriptFieldData(fieldData);
result.put(fieldData.getName(), wrappedFieldData);
}
}
return result;
}
use of org.alfresco.repo.forms.FormData.FieldData in project alfresco-repository by Alfresco.
the class TaskFormProcessorTest method checkPackageActionGroups.
private void checkPackageActionGroups(FormData formData) {
FieldData pckgActionData = formData.getFieldData("prop_bpm_packageActionGroup");
assertNotNull(pckgActionData);
assertEquals("", pckgActionData.getValue());
FieldData pckgItemActionData = formData.getFieldData("prop_bpm_packageItemActionGroup");
assertNotNull(pckgItemActionData);
assertEquals("read_package_item_actions", pckgItemActionData.getValue());
}
Aggregations