Java Code Examples for org.alfresco.service.cmr.dictionary.TypeDefinition#getAssociations()
The following examples show how to use
org.alfresco.service.cmr.dictionary.TypeDefinition#getAssociations() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContentModelFormProcessor.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected ContentModelItemData<ItemType> makeItemData(ItemType item) { TypeDefinition baseType = getBaseType(item); Set<QName> aspects = getAspectNames(item); TypeDefinition anonType = dictionaryService.getAnonymousType(baseType.getName(), aspects); Map<QName, PropertyDefinition> propDefs = anonType.getProperties(); Map<QName, AssociationDefinition> assocDefs = anonType.getAssociations(); Map<QName, Serializable> propValues = getPropertyValues(item); Map<QName, Serializable> assocValues = getAssociationValues(item); Map<String, Object> transientValues = getTransientValues(item); return new ContentModelItemData<ItemType>(item, propDefs, assocDefs, propValues, assocValues, transientValues); }
Example 2
Source File: ActivitiPropertyConverter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Get missing mandatory properties on Task * * @param task * task instance * @return array of missing property names (or null, if none) */ private List<QName> getMissingMandatoryTaskProperties(DelegateTask task) { TypeDefinition typeDefinition = typeManager.getFullTaskDefinition(task); // retrieve properties of task Map<QName, Serializable> existingValues = getTaskProperties(task, typeDefinition, false); Map<QName, PropertyDefinition> propertyDefs = typeDefinition.getProperties(); Map<QName, AssociationDefinition> assocDefs = typeDefinition.getAssociations(); List<QName> missingProps = findMissingProperties(existingValues, propertyDefs); List<QName> missingAssocs= findMissingProperties(existingValues, assocDefs); missingProps.addAll(missingAssocs); return missingProps; }
Example 3
Source File: ParentContext.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Construct * * @param elementName QName * @param parent NodeContext * @param assocDef AssociationDefinition */ public ParentContext(QName elementName, NodeContext parent, AssociationDefinition assocDef) { this(elementName, parent); TypeDefinition typeDef = parent.getTypeDefinition(); if (typeDef != null) { // // Ensure association type is valid for node parent // // Build complete Type Definition Set<QName> allAspects = new HashSet<QName>(); for (AspectDefinition typeAspect : parent.getTypeDefinition().getDefaultAspects()) { allAspects.add(typeAspect.getName()); } allAspects.addAll(parent.getNodeAspects()); TypeDefinition anonymousType = getDictionaryService().getAnonymousType(parent.getTypeDefinition().getName(), allAspects); // Determine if Association is valid for Type Definition Map<QName, AssociationDefinition> nodeAssociations = anonymousType.getAssociations(); if (nodeAssociations.containsKey(assocDef.getName()) == false) { throw new ImporterException("Association " + assocDef.getName() + " is not valid for node " + parent.getTypeDefinition().getName()); } } parentRef = parent.getNodeRef(); assocType = assocDef.getName(); }
Example 4
Source File: WorkflowModelBuilder.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
private Map<String, Object> buildProperties(WorkflowTask task, Collection<String> propertyFilters) { Map<QName, Serializable> properties = task.getProperties(); Collection<QName> keys; if (propertyFilters == null || propertyFilters.size() == 0) { TypeDefinition taskType = task.getDefinition().getMetadata(); Map<QName, PropertyDefinition> propDefs = taskType.getProperties(); Map<QName, AssociationDefinition> assocDefs = taskType.getAssociations(); Set<QName> propKeys = properties.keySet(); keys = new HashSet<QName>(propDefs.size() + assocDefs.size() + propKeys.size()); keys.addAll(propDefs.keySet()); keys.addAll(assocDefs.keySet()); keys.addAll(propKeys); keys.add(WorkflowModel.PROP_HIDDEN_TRANSITIONS); } else { keys = buildQNameKeys(propertyFilters); } Map<String, Object> result = buildQNameProperties(properties, keys, task); // ALF-18092: Special handling for the "hiddenTransitions" property, as it can be an empty string if (keys.contains(WorkflowModel.PROP_HIDDEN_TRANSITIONS)) { List<?> hiddenTransitions = getHiddenTransitions(properties); if (hiddenTransitions != null) { result.put(qNameConverter.mapQNameToName(WorkflowModel.PROP_HIDDEN_TRANSITIONS), hiddenTransitions); } } return result; }
Example 5
Source File: ContentModelFormProcessor.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * 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); } }
Example 6
Source File: ActivitiPropertyConverter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public Map<QName, Serializable> getTaskProperties(Task task) { // retrieve type definition for task TypeDefinition taskDef = typeManager.getFullTaskDefinition(task); Map<QName, PropertyDefinition> taskProperties = taskDef.getProperties(); Map<QName, AssociationDefinition> taskAssociations = taskDef.getAssociations(); TaskService taskService = activitiUtil.getTaskService(); // Get all task variables including execution vars. Map<String, Object> variables = taskService.getVariables(task.getId()); Map<String, Object> localVariables = taskService.getVariablesLocal(task.getId()); // Map the arbitrary properties Map<QName, Serializable> properties =mapArbitraryProperties(variables, localVariables, taskProperties, taskAssociations); // Map activiti task instance fields to properties properties.put(WorkflowModel.PROP_TASK_ID, task.getId()); properties.put(WorkflowModel.PROP_DESCRIPTION, task.getDescription()); // Since the task is never started explicitally, we use the create time properties.put(WorkflowModel.PROP_START_DATE, task.getCreateTime()); // Due date is present on the task properties.put(WorkflowModel.PROP_DUE_DATE, task.getDueDate()); // Since this is a runtime-task, it's not completed yet properties.put(WorkflowModel.PROP_COMPLETION_DATE, null); properties.put(WorkflowModel.PROP_PRIORITY, task.getPriority()); properties.put(ContentModel.PROP_CREATED, task.getCreateTime()); properties.put(ContentModel.PROP_OWNER, task.getAssignee()); // Be sure to fetch the outcome String outcomeVarName = factory.mapQNameToName(WorkflowModel.PROP_OUTCOME); if(variables.get(outcomeVarName) != null) { properties.put(WorkflowModel.PROP_OUTCOME, (Serializable) variables.get(outcomeVarName)); } List<IdentityLink> links = taskService.getIdentityLinksForTask(task.getId()); mapPooledActors(links, properties); return filterTaskProperties(properties); }
Example 7
Source File: ActivitiPropertyConverter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public Map<QName, Serializable> getTaskProperties(DelegateTask task, TypeDefinition typeDefinition, boolean localOnly) { Map<QName, PropertyDefinition> taskProperties = typeDefinition.getProperties(); Map<QName, AssociationDefinition> taskAssociations = typeDefinition.getAssociations(); // Get the local task variables Map<String, Object> localVariables = task.getVariablesLocal(); Map<String, Object> variables = null; if(localOnly==false) { variables = new HashMap<String, Object>(); variables.putAll(localVariables); // Execution-variables should also be added, if no value is present locally Map<String, Object> executionVariables = task.getExecution().getVariables(); for(Entry<String, Object> entry : executionVariables.entrySet()) { String key = entry.getKey(); if(localVariables.containsKey(key)==false) { variables.put(key, entry.getValue()); } } } else { // Only local variables should be used. variables = localVariables; } // Map the arbitrary properties Map<QName, Serializable> properties =mapArbitraryProperties(variables, localVariables, taskProperties, taskAssociations); // Map activiti task instance fields to properties properties.put(WorkflowModel.PROP_TASK_ID, task.getId()); // Since the task is never started explicitally, we use the create time properties.put(WorkflowModel.PROP_START_DATE, task.getCreateTime()); // Due date properties.put(WorkflowModel.PROP_DUE_DATE, task.getDueDate()); // Since this is a runtime-task, it's not completed yet properties.put(WorkflowModel.PROP_COMPLETION_DATE, null); properties.put(WorkflowModel.PROP_PRIORITY, task.getPriority()); properties.put(ContentModel.PROP_CREATED, task.getCreateTime()); properties.put(ContentModel.PROP_OWNER, task.getAssignee()); // TODO: Expose in DelegateTask Set<IdentityLink> links = ((TaskEntity)task).getCandidates(); mapPooledActors(links, properties); return filterTaskProperties(properties); }
Example 8
Source File: ActivitiPropertyConverter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@SuppressWarnings("unchecked") public Map<QName, Serializable> getTaskProperties(HistoricTaskInstance historicTask, Map<String,Object> localVariables) { // Retrieve type definition for task, based on taskFormKey variable String formKey = (String) localVariables.get(ActivitiConstants.PROP_TASK_FORM_KEY); TypeDefinition taskDef = typeManager.getFullTaskDefinition(formKey); Map<QName, PropertyDefinition> taskProperties = taskDef.getProperties(); Map<QName, AssociationDefinition> taskAssociations = taskDef.getAssociations(); Map<String, Object> allVariables = getHistoricProcessVariables(historicTask.getProcessInstanceId()); allVariables.putAll(localVariables); // Map the arbitrary properties Map<QName, Serializable> properties =mapArbitraryProperties(allVariables, localVariables, taskProperties, taskAssociations); // Map activiti task instance fields to properties properties.put(WorkflowModel.PROP_TASK_ID, historicTask.getId()); properties.put(WorkflowModel.PROP_DESCRIPTION, historicTask.getDescription()); // Since the task is never started explicitly, we use the create time properties.put(WorkflowModel.PROP_START_DATE, historicTask.getStartTime()); properties.put(WorkflowModel.PROP_DUE_DATE, historicTask.getDueDate()); properties.put(WorkflowModel.PROP_COMPLETION_DATE, historicTask.getEndTime()); properties.put(WorkflowModel.PROP_PRIORITY, historicTask.getPriority()); properties.put(ContentModel.PROP_CREATED, historicTask.getStartTime()); properties.put(ContentModel.PROP_OWNER, historicTask.getAssignee()); // Be sure to fetch the outcome String outcomeVarName = factory.mapQNameToName(WorkflowModel.PROP_OUTCOME); if(localVariables.get(outcomeVarName) != null) { properties.put(WorkflowModel.PROP_OUTCOME, (Serializable) localVariables.get(outcomeVarName)); } // History of pooled actors is stored in task variable List<NodeRef> pooledActors = new ArrayList<NodeRef>(); List<String> pooledActorRefIds = (List<String>) localVariables.get(ActivitiConstants.PROP_POOLED_ACTORS_HISTORY); if(pooledActorRefIds != null) { for(String nodeId : pooledActorRefIds) { pooledActors.add(new NodeRef(nodeId)); } } // Add pooled actors. When no actors are found, set empty list properties.put(WorkflowModel.ASSOC_POOLED_ACTORS, (Serializable) pooledActors); return filterTaskProperties(properties); }