use of org.alfresco.service.cmr.dictionary.PropertyDefinition in project acs-community-packaging by Alfresco.
the class TransientNode method initNode.
/**
* Initialises the node.
*
* @param data The properties and associations to initialise the node with
*/
protected void initNode(Map<QName, Serializable> data) {
if (logger.isDebugEnabled())
logger.debug("Initialising transient node with data: " + data);
DictionaryService ddService = this.getServiceRegistry().getDictionaryService();
// marshall the given properties and associations into the internal maps
this.associations = new QNameNodeMap(this, this);
this.childAssociations = new QNameNodeMap(this, 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()) {
Object obj = data.get(item);
if (obj instanceof NodeRef) {
NodeRef child = (NodeRef) obj;
// create a child association reference, add it to a list and add the list
// to the list of child associations for this node
List<ChildAssociationRef> assocs = new ArrayList<ChildAssociationRef>(1);
ChildAssociationRef childRef = new ChildAssociationRef(assocDef.getName(), this.nodeRef, null, child);
assocs.add(childRef);
this.childAssociations.put(item, assocs);
} else if (obj instanceof List) {
List targets = (List) obj;
List<ChildAssociationRef> assocs = new ArrayList<ChildAssociationRef>(targets.size());
for (Object target : targets) {
if (target instanceof NodeRef) {
NodeRef currentChild = (NodeRef) target;
ChildAssociationRef childRef = new ChildAssociationRef(assocDef.getName(), this.nodeRef, null, currentChild);
assocs.add(childRef);
}
}
if (assocs.size() > 0) {
this.childAssociations.put(item, assocs);
}
}
} else {
Object obj = data.get(item);
if (obj instanceof NodeRef) {
NodeRef target = (NodeRef) obj;
// create a association reference, add it to a list and add the list
// to the list of associations for this node
List<AssociationRef> assocs = new ArrayList<AssociationRef>(1);
AssociationRef assocRef = new AssociationRef(null, this.nodeRef, assocDef.getName(), target);
assocs.add(assocRef);
this.associations.put(item, assocs);
} else if (obj instanceof List) {
List targets = (List) obj;
List<AssociationRef> assocs = new ArrayList<AssociationRef>(targets.size());
for (Object target : targets) {
if (target instanceof NodeRef) {
NodeRef currentTarget = (NodeRef) target;
AssociationRef assocRef = new AssociationRef(null, this.nodeRef, assocDef.getName(), currentTarget);
assocs.add(assocRef);
}
}
if (assocs.size() > 0) {
this.associations.put(item, assocs);
}
}
}
}
}
}
}
// 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: " + this.type);
}
// get flat list of all aspects for the type
List<QName> defaultAspects = new ArrayList<QName>(16);
getMandatoryAspects(typeDef, defaultAspects);
this.aspects = new HashSet<QName>(defaultAspects);
// setup remaining variables
this.path = null;
this.locked = Boolean.FALSE;
this.workingCopyOwner = Boolean.FALSE;
}
use of org.alfresco.service.cmr.dictionary.PropertyDefinition in project acs-community-packaging by Alfresco.
the class BaseComponentGenerator method generateAndAdd.
@SuppressWarnings("unchecked")
public UIComponent generateAndAdd(FacesContext context, UIPropertySheet propertySheet, PropertySheetItem item) {
UIComponent component = null;
if (item instanceof UIProperty) {
// get the property definition
PropertyDefinition propertyDef = getPropertyDefinition(context, propertySheet.getNode(), item.getName());
// create the component and add it to the property sheet
component = createComponent(context, propertySheet, item);
// setup the component for multi value editing if necessary
component = setupMultiValuePropertyIfNecessary(context, propertySheet, item, propertyDef, component);
// setup common aspects of the property i.e. value binding
setupProperty(context, propertySheet, item, propertyDef, component);
// add the component now, it needs to be added before the validations
// are setup as we need access to the component id, which in turn needs
// to have a parent to get the correct id
item.getChildren().add(component);
// setup the component for mandatory validation if necessary
setupMandatoryPropertyIfNecessary(context, propertySheet, item, propertyDef, component);
// setup any constraints the property has
setupConstraints(context, propertySheet, item, propertyDef, component);
// setup any converter the property needs
setupConverter(context, propertySheet, item, propertyDef, component);
} else if (item instanceof UISeparator) {
// just create the component and add it
component = createComponent(context, propertySheet, item);
item.getChildren().add(component);
} else {
// get the association definition
AssociationDefinition assocationDef = this.getAssociationDefinition(context, propertySheet.getNode(), item.getName());
// create the component and add it to the property sheet
component = createComponent(context, propertySheet, item);
// setup common aspects of the association i.e. value binding
setupAssociation(context, propertySheet, item, assocationDef, component);
// add the component now, it needs to be added before the validations
// are setup as we need access to the component id, which needs have a
// parent to get the correct id
item.getChildren().add(component);
// setup the component for mandatory validation if necessary
setupMandatoryAssociationIfNecessary(context, propertySheet, item, assocationDef, component);
// setup any converter the association needs
setupConverter(context, propertySheet, item, assocationDef, component);
}
return component;
}
use of org.alfresco.service.cmr.dictionary.PropertyDefinition in project acs-community-packaging by Alfresco.
the class TextFieldGenerator method getListOfValuesConstraint.
/**
* Retrieves the list of values constraint for the item, if it has one
*
* @param context FacesContext
* @param propertySheet The property sheet being generated
* @param item The item being generated
* @return The constraint if the item has one, null otherwise
*/
protected ListOfValuesConstraint getListOfValuesConstraint(FacesContext context, UIPropertySheet propertySheet, PropertySheetItem item) {
ListOfValuesConstraint lovConstraint = null;
// get the property definition for the item
PropertyDefinition propertyDef = getPropertyDefinition(context, propertySheet.getNode(), item.getName());
if (propertyDef != null) {
// go through the constaints and see if it has the
// list of values constraint
List<ConstraintDefinition> constraints = propertyDef.getConstraints();
for (ConstraintDefinition constraintDef : constraints) {
Constraint constraint = constraintDef.getConstraint();
if (constraint instanceof ListOfValuesConstraint) {
lovConstraint = (ListOfValuesConstraint) constraint;
break;
}
}
}
return lovConstraint;
}
use of org.alfresco.service.cmr.dictionary.PropertyDefinition in project acs-community-packaging by Alfresco.
the class StartWorkflowWizard method getPackageActionGroup.
/**
* Returns the action group the current task uses for the workflow package
*
* @return action group id
*/
public String getPackageActionGroup() {
String actionGroup = null;
WorkflowDefinition flowDef = this.getWorkflows().get(this.selectedWorkflow);
WorkflowTaskDefinition taskDef = flowDef.getStartTaskDefinition();
if (taskDef != null) {
PropertyDefinition propDef = taskDef.metadata.getProperties().get(WorkflowModel.PROP_PACKAGE_ACTION_GROUP);
if (propDef != null) {
actionGroup = propDef.getDefaultValue();
}
}
return actionGroup;
}
use of org.alfresco.service.cmr.dictionary.PropertyDefinition in project records-management by Alfresco.
the class RecordServiceImpl method isRecordMetadataProperty.
/**
* @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#isRecordMetadataProperty(org.alfresco.service.namespace.QName)
*/
@Override
public boolean isRecordMetadataProperty(QName property) {
boolean result = false;
PropertyDefinition propertyDefinition = dictionaryService.getProperty(property);
if (propertyDefinition != null) {
ClassDefinition classDefinition = propertyDefinition.getContainerClass();
if (classDefinition != null && getRecordMetadataAspectsMap().containsKey(classDefinition.getName())) {
result = true;
}
}
return result;
}
Aggregations