org.alfresco.service.cmr.dictionary.TypeDefinition Java Examples
The following examples show how to use
org.alfresco.service.cmr.dictionary.TypeDefinition.
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: WorkflowObjectFactory.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Gets the Task {@link TypeDefinition} for the given name. * * @param name the name of the task definition. * @param isStart is theis a start task? * @return the task {@link TypeDefinition}. */ public TypeDefinition getTaskTypeDefinition(String name, boolean isStart) { TypeDefinition typeDef = null; if(name!=null) { QName typeName = qNameConverter.mapNameToQName(name); typeDef = dictionaryService.getType(typeName); } if (typeDef == null) { QName defaultTypeName = isStart? defaultStartTaskType : WorkflowModel.TYPE_WORKFLOW_TASK; typeDef = dictionaryService.getType(defaultTypeName); if (typeDef == null) { String msg = messageService.getMessage("workflow.get.task.definition.metadata.error", name); throw new WorkflowException( msg); } } return typeDef; }
Example #2
Source File: WorkflowPropertyHandlerRegistry.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public Map<String, Object> handleVariablesToSet(Map<QName, Serializable> properties, TypeDefinition type, Object object, Class<?> objectType) { Map<String, Object> variablesToSet = new HashMap<String, Object>(); for (Entry<QName, Serializable> entry : properties.entrySet()) { QName key = entry.getKey(); Serializable value = entry.getValue(); WorkflowPropertyHandler handler = handlers.get(key); if (handler == null) { handler = defaultHandler; } Object result = handler.handleProperty(key, value, type, object, objectType); if (WorkflowPropertyHandler.DO_NOT_ADD.equals(result)==false) { String keyStr = qNameConverter.mapQNameToName(key); variablesToSet.put(keyStr, result); } } return variablesToSet; }
Example #3
Source File: ActivitiWorkflowServiceIntegrationTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Actually tests if the priority is the default value. This is based on the assumption that custom * tasks are defaulted to a priority of 50 (which is invalid). I'm testing that the code I wrote decides this is an * invalid number and sets it to the default value (2). */ @Test public void testPriorityIsValid() { WorkflowDefinition definition = deployDefinition("activiti/testCustomActiviti.bpmn20.xml"); personManager.setUser(USER1); // Start the Workflow WorkflowPath path = workflowService.startWorkflow(definition.getId(), null); String instanceId = path.getInstance().getId(); // Check the Start Task is completed. WorkflowTask startTask = workflowService.getStartTask(instanceId); assertEquals(WorkflowTaskState.COMPLETED, startTask.getState()); List<WorkflowTask> tasks = workflowService.getTasksForWorkflowPath(path.getId()); for (WorkflowTask workflowTask : tasks) { Map<QName, Serializable> props = workflowTask.getProperties(); TypeDefinition typeDefinition = workflowTask.getDefinition().getMetadata(); Map<QName, PropertyDefinition> propertyDefs = typeDefinition.getProperties(); PropertyDefinition priorDef = propertyDefs.get(WorkflowModel.PROP_PRIORITY); assertEquals(props.get(WorkflowModel.PROP_PRIORITY),Integer.valueOf(priorDef.getDefaultValue())); } }
Example #4
Source File: RestVariableHelper.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
/** * @param variables raw variables * @param typeDefinition the typê definition for the start-task of the process, used to extract types. * @return list of {@link Variable}, representing the given raw variables */ public List<Variable> getVariables(Map<String, Object> variables, TypeDefinition typeDefinition) { List<Variable> result = new ArrayList<Variable>(); TypeDefinitionContext context = new TypeDefinitionContext(typeDefinition, getQNameConverter()); Variable variable = null; for(Entry<String, Object> entry : variables.entrySet()) { if(!INTERNAL_PROPERTIES.contains(entry.getKey())) { variable = new Variable(); variable.setName(entry.getKey()); // Set value and type setVariableValueAndType(variable, entry.getValue(), context); result.add(variable); } } return result; }
Example #5
Source File: AbstractWorkflowPropertyHandler.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
protected Object handleDefaultProperty(Object task, TypeDefinition type, QName key, Serializable value) { PropertyDefinition propDef = type.getProperties().get(key); if (propDef != null) { return handleProperty(value, propDef); } else { AssociationDefinition assocDef = type.getAssociations().get(key); if (assocDef != null) { return handleAssociation(value, assocDef); } else if (value instanceof NodeRef) { return nodeConverter.convertNode((NodeRef)value, false); } } return value; }
Example #6
Source File: RepoDictionaryDAOTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public void testPropertyOverride() { TypeDefinition type1 = service.getType(QName.createQName(TEST_URL, "overridetype1")); Map<QName, PropertyDefinition> props1 = type1.getProperties(); PropertyDefinition prop1 = props1.get(QName.createQName(TEST_URL, "propoverride")); String def1 = prop1.getDefaultValue(); assertEquals("one", def1); TypeDefinition type2 = service.getType(QName.createQName(TEST_URL, "overridetype2")); Map<QName, PropertyDefinition> props2 = type2.getProperties(); PropertyDefinition prop2 = props2.get(QName.createQName(TEST_URL, "propoverride")); String def2 = prop2.getDefaultValue(); assertEquals("two", def2); TypeDefinition type3 = service.getType(QName.createQName(TEST_URL, "overridetype3")); Map<QName, PropertyDefinition> props3 = type3.getProperties(); PropertyDefinition prop3 = props3.get(QName.createQName(TEST_URL, "propoverride")); String def3 = prop3.getDefaultValue(); assertEquals("three", def3); }
Example #7
Source File: ItemTypeDefinitionWrapper.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void updateDefinition(DictionaryService dictionaryService) { TypeDefinition typeDef = dictionaryService.getType(alfrescoName); if (typeDef != null) { setTypeDefDisplayName(typeDef.getTitle(dictionaryService)); setTypeDefDescription(typeDef.getDescription(dictionaryService)); } else { super.updateDefinition(dictionaryService); } updateTypeDefInclProperties(); }
Example #8
Source File: WorkflowRestImpl.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
/** * @param taskType type of the task * @return all types (and aspects) which properties should not be used for form-model elements */ protected Set<QName> getTypesToExclude(TypeDefinition taskType) { HashSet<QName> typesToExclude = new HashSet<QName>(); ClassDefinition parentClassDefinition = taskType.getParentClassDefinition(); boolean contentClassFound = false; while(parentClassDefinition != null) { if(contentClassFound) { typesToExclude.add(parentClassDefinition.getName()); } else if(ContentModel.TYPE_CONTENT.equals(parentClassDefinition.getName())) { // All parents of "cm:content" should be ignored as well for fetching start-properties typesToExclude.add(ContentModel.TYPE_CONTENT); typesToExclude.addAll(parentClassDefinition.getDefaultAspectNames()); contentClassFound = true; } parentClassDefinition = parentClassDefinition.getParentClassDefinition(); } return typesToExclude; }
Example #9
Source File: DocumentTypeDefinitionWrapper.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void updateDefinition(DictionaryService dictionaryService) { TypeDefinition typeDef = dictionaryService.getType(alfrescoName); if (typeDef != null) { setTypeDefDisplayName(typeDef.getTitle(dictionaryService)); setTypeDefDescription(typeDef.getDescription(dictionaryService)); } else { super.updateDefinition(dictionaryService); } updateTypeDefInclProperties(); }
Example #10
Source File: TypeRoutingContentStore.java From alfresco-simple-content-stores with Apache License 2.0 | 6 votes |
private void afterPropertiesSet_validateSelectors() { PropertyCheck.mandatory(this, "storeByTypeName", this.storeByTypeName); if (this.storeByTypeName.isEmpty()) { throw new IllegalStateException("No stores have been defined for node types"); } this.storeByTypeQName = new HashMap<>(); this.storeByTypeName.forEach((typeName, store) -> { final QName typeQName = QName.resolveToQName(this.namespaceService, typeName); if (typeQName == null) { throw new IllegalStateException(typeQName + " cannot be resolved to a qualified name"); } final TypeDefinition type = this.dictionaryService.getType(typeQName); if (type == null) { throw new IllegalStateException(typeQName + " cannot be resolved to a registered node type"); } this.storeByTypeQName.put(typeQName, store); }); }
Example #11
Source File: TypeAndAspectsFormProcessor.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected Set<QName> getAspectNames(TypeDefinition item) { Set<QName> requestedAspects = new HashSet<QName>(); // default aspects from type definition requestedAspects.addAll(super.getAspectNames(item)); // additional requested aspects requestedAspects.addAll(getRequestedAspects()); return requestedAspects; }
Example #12
Source File: ActivitiDescriptionPropertyHandler.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected Object handleDelegateTaskProperty(DelegateTask task, TypeDefinition type, QName key, Serializable value) { checkType(key, value, String.class); task.setDescription((String) value); return DO_NOT_ADD; }
Example #13
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 #14
Source File: ActivitiPooledActorsPropertyHandler.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected Object handleTaskProperty(Task task, TypeDefinition type, QName key, Serializable value) { List<IdentityLink> links = taskService.getIdentityLinksForTask(task.getId()); UserAndGroupUpdates updates = getUserAndGroupUpdates(value, links); updateTaskCandidates(task.getId(), updates); return DO_NOT_ADD; }
Example #15
Source File: ActivitiPooledActorsPropertyHandler.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected Object handleDelegateTaskProperty(DelegateTask task, TypeDefinition type, QName key, Serializable value) { List<IdentityLinkEntity> links = ((TaskEntity)task).getIdentityLinks(); UserAndGroupUpdates updates = getUserAndGroupUpdates(value, links); updateTaskCandidates(task, updates); return DO_NOT_ADD; }
Example #16
Source File: WorkflowFormProcessorTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@SuppressWarnings("unchecked") private DictionaryService makeDictionaryService() { DictionaryService mock = mock(DictionaryService.class); TypeDefinition taskTypeDef = definition.getStartTaskDefinition().getMetadata(); when(mock.getAnonymousType((QName) any(), (Collection<QName>) any())).thenReturn(taskTypeDef); return mock; }
Example #17
Source File: TasksImpl.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override public CollectionWithPagingInfo<FormModelElement> getTaskFormModel(String taskId, Paging paging) { // Check if task can be accessed by the current user HistoricTaskInstance task = getValidHistoricTask(taskId); String formKey = task.getFormKey(); // Lookup type definition for the task TypeDefinition taskType = getWorkflowFactory().getTaskFullTypeDefinition(formKey, true); return getFormModelElements(taskType, paging); }
Example #18
Source File: DictionaryComponent.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
public Collection<QName> getTypes(QName model) { Collection<TypeDefinition> types = dictionaryDAO.getTypes(model); Collection<QName> qnames = new ArrayList<QName>(types.size()); for (TypeDefinition def : types) { qnames.add(def.getName()); } return qnames; }
Example #19
Source File: QueryParserUtils.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
public static TypeDefinition matchTypeDefinition(String defaultNameSpaceUri, NamespacePrefixResolver namespacePrefixResolver, DictionaryService dictionaryService, String string) { QName search = QName.createQName(expandQName(defaultNameSpaceUri, namespacePrefixResolver, string)); TypeDefinition typeDefinition = dictionaryService.getType(QName.createQName(expandQName(defaultNameSpaceUri, namespacePrefixResolver, string))); QName match = null; if (typeDefinition == null) { for (QName definition : dictionaryService.getAllTypes()) { if (definition.getNamespaceURI().equalsIgnoreCase(search.getNamespaceURI())) { if (definition.getLocalName().equalsIgnoreCase(search.getLocalName())) { if (match == null) { match = definition; } else { throw new DictionaryException("Ambiguous data datype " + string); } } } } } else { return typeDefinition; } if (match == null) { return null; } else { return dictionaryService.getType(match); } }
Example #20
Source File: ActivitiOwnerPropertyHandler.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected Object handleTaskProperty(Task task, TypeDefinition type, QName key, Serializable value) { //Task assignment needs to be done after setting all properties // so it is handled in ActivitiPropertyConverter. return DO_NOT_ADD; }
Example #21
Source File: ActivitiPriorityPropertyHandler.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected Object handleDelegateTaskProperty(DelegateTask task, TypeDefinition type, QName key, Serializable value) { checkType(key, value, Integer.class); task.setPriority((Integer) value); return DO_NOT_ADD; }
Example #22
Source File: ActivitiPriorityPropertyHandler.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected Object handleTaskProperty(Task task, TypeDefinition type, QName key, Serializable value) { int priority; // ACE-3121: Workflow Admin Console: Cannot change priority for activiti // It could be a String that converts to an int, like when coming from WorkflowInterpreter.java if (value instanceof String) { try { priority = Integer.parseInt((String) value); } catch (NumberFormatException e) { throw getInvalidPropertyValueException(key, value); } } else { checkType(key, value, Integer.class); priority = (Integer) value; } // Priority value validation not performed to allow for future model changes task.setPriority(priority); return DO_NOT_ADD; }
Example #23
Source File: ActivitiDueDatePropertyHandler.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected Object handleDelegateTaskProperty(DelegateTask task, TypeDefinition type, QName key, Serializable value) { checkType(key, value, Date.class); task.setDueDate((Date) value); return DO_NOT_ADD; }
Example #24
Source File: NodeContext.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Construct * * @param elementName QName * @param parentContext ParentContext * @param typeDef TypeDefinition */ public NodeContext(QName elementName, ParentContext parentContext, TypeDefinition typeDef) { super(elementName, parentContext.getDictionaryService(), parentContext.getImporter()); this.parentContext = parentContext; this.typeDef = typeDef; this.uuid = null; }
Example #25
Source File: WorkflowModelBuilder.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
private Map<String, Object> buildTypeDefinition(TypeDefinition typeDefinition) { Map<String, Object> model = new HashMap<String, Object>(); model.put(TYPE_DEFINITION_NAME, typeDefinition.getName()); model.put(TYPE_DEFINITION_TITLE, typeDefinition.getTitle(dictionaryService)); model.put(TYPE_DEFINITION_DESCRIPTION, typeDefinition.getDescription(dictionaryService)); model.put(TYPE_DEFINITION_URL, getUrl(typeDefinition)); return model; }
Example #26
Source File: ActivitiWorkflowEngine.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * @param path WorkflowPath * @param instance ProcessInstance */ private void endStartTaskAutomatically(WorkflowPath path, ProcessInstance instance) { // Check if StartTask Needs to be ended automatically WorkflowDefinition definition = path.getInstance().getDefinition(); TypeDefinition metadata = definition.getStartTaskDefinition().getMetadata(); Set<QName> aspects = metadata.getDefaultAspectNames(); if(aspects.contains(WorkflowModel.ASPECT_END_AUTOMATICALLY)) { String taskId = ActivitiConstants.START_TASK_PREFIX + instance.getId(); endStartTask(taskId); } }
Example #27
Source File: ActivitiTaskTypeManager.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public TypeDefinition getFullTaskDefinition(DelegateTask delegateTask) { FormData formData = null; TaskEntity taskEntity = (TaskEntity) delegateTask; TaskFormHandler taskFormHandler = taskEntity.getTaskDefinition().getTaskFormHandler(); if (taskFormHandler != null) { formData = taskFormHandler.createTaskForm(taskEntity); } return getFullTaskDefinition(delegateTask.getId(), formData); }
Example #28
Source File: ActivitiTaskPropertyHandler.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ public Object handleProperty(QName key, Serializable value, TypeDefinition type, Object object, Class<?> objectType) { if (DelegateTask.class.equals(objectType)) { return handleDelegateTaskProperty((DelegateTask)object, type, key, value); } else if (Task.class.equals(objectType)) { return handleTaskProperty((Task)object, type, key, value); } return handleProcessPropert(null, type, key, value); }
Example #29
Source File: CustomType.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
public CustomType(TypeDefinition typeDefinition, MessageLookup messageLookup, List<CustomModelProperty> properties) { this.name = typeDefinition.getName().getLocalName(); this.prefixedName = typeDefinition.getName().toPrefixString(); this.title = typeDefinition.getTitle(messageLookup); this.description = typeDefinition.getDescription(messageLookup); this.parentName = getParentNameAsString(typeDefinition.getParentName()); this.properties = setList(properties); }
Example #30
Source File: ActivitiDescriptionPropertyHandler.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected Object handleTaskProperty(Task task, TypeDefinition type, QName key, Serializable value) { checkType(key, value, String.class); task.setDescription((String) value); return DO_NOT_ADD; }