当前位置: 首页>>代码示例>>Java>>正文


Java TypeDefinition.getProperties方法代码示例

本文整理汇总了Java中org.alfresco.service.cmr.dictionary.TypeDefinition.getProperties方法的典型用法代码示例。如果您正苦于以下问题:Java TypeDefinition.getProperties方法的具体用法?Java TypeDefinition.getProperties怎么用?Java TypeDefinition.getProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.alfresco.service.cmr.dictionary.TypeDefinition的用法示例。


在下文中一共展示了TypeDefinition.getProperties方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testPropertyOverride

import org.alfresco.service.cmr.dictionary.TypeDefinition; //导入方法依赖的package包/类
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);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:RepoDictionaryDAOTest.java

示例2: testPriorityIsValid

import org.alfresco.service.cmr.dictionary.TypeDefinition; //导入方法依赖的package包/类
/**
 * 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).
 */
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()));        
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:30,代码来源:ActivitiWorkflowServiceIntegrationTest.java

示例3: testPropertyOverride

import org.alfresco.service.cmr.dictionary.TypeDefinition; //导入方法依赖的package包/类
@Test
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);
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:22,代码来源:DictionaryDAOTest.java

示例4: makeItemData

import org.alfresco.service.cmr.dictionary.TypeDefinition; //导入方法依赖的package包/类
@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);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:14,代码来源:ContentModelFormProcessor.java

示例5: getMissingMandatoryTaskProperties

import org.alfresco.service.cmr.dictionary.TypeDefinition; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:22,代码来源:ActivitiPropertyConverter.java

示例6: persistNode

import org.alfresco.service.cmr.dictionary.TypeDefinition; //导入方法依赖的package包/类
@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);

}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:31,代码来源:TypeAndAspectsFormProcessor.java

示例7: buildProperties

import org.alfresco.service.cmr.dictionary.TypeDefinition; //导入方法依赖的package包/类
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;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:35,代码来源:WorkflowModelBuilder.java

示例8: buildPropertyLabels

import org.alfresco.service.cmr.dictionary.TypeDefinition; //导入方法依赖的package包/类
private Map<String, String> buildPropertyLabels(WorkflowTask task, Map<String, Object> properties)
{
    TypeDefinition taskType = task.getDefinition().getMetadata();
    final Map<QName, PropertyDefinition> propDefs = taskType.getProperties();
    return CollectionUtils.transform(properties, new Function<Entry<String, Object>, Pair<String, String>>()
    {
        @Override
        public Pair<String, String> apply(Entry<String, Object> entry)
        {
            String propName = entry.getKey();
            PropertyDefinition propDef = propDefs.get(qNameConverter.mapNameToQName(propName));
            if(propDef != null )
            {
                List<ConstraintDefinition> constraints = propDef.getConstraints();
                for (ConstraintDefinition constraintDef : constraints)
                {
                    Constraint constraint = constraintDef.getConstraint();
                    if (constraint instanceof ListOfValuesConstraint)
                    {
                        ListOfValuesConstraint listConstraint = (ListOfValuesConstraint) constraint;
                        String label = listConstraint.getDisplayLabel(String.valueOf(entry.getValue()), dictionaryService);
                        return new Pair<String, String>(propName, label);
                    }
                }
            }
            return null;
        }
    });
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:30,代码来源:WorkflowModelBuilder.java

示例9: persistNode

import org.alfresco.service.cmr.dictionary.TypeDefinition; //导入方法依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:57,代码来源:ContentModelFormProcessor.java

示例10: getTaskProperties

import org.alfresco.service.cmr.dictionary.TypeDefinition; //导入方法依赖的package包/类
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);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:44,代码来源:ActivitiPropertyConverter.java

示例11: setDefaultTaskProperties

import org.alfresco.service.cmr.dictionary.TypeDefinition; //导入方法依赖的package包/类
/**
 * Sets Default Properties of Task
 * 
 * @param task
 *            task instance
 */
public void setDefaultTaskProperties(DelegateTask task)
{
    TypeDefinition typeDefinition = typeManager.getFullTaskDefinition(task);
    // Only local task properties should be set to default value
    Map<QName, Serializable> existingValues = getTaskProperties(task, typeDefinition, true);
    Map<QName, Serializable> defaultValues = new HashMap<QName, Serializable>();

    Map<QName, PropertyDefinition> propertyDefs = typeDefinition.getProperties();

    // for each property, determine if it has a default value
    for (Map.Entry<QName, PropertyDefinition> entry : propertyDefs.entrySet())
    {
        QName key = entry.getKey();
        String defaultValue = entry.getValue().getDefaultValue();
        if (defaultValue != null && existingValues.get(key) == null)
        {
            defaultValues.put(key, defaultValue);
        }
    }

    // Special case for property priorities
    PropertyDefinition priorDef = propertyDefs.get(WorkflowModel.PROP_PRIORITY);
    Serializable existingValue = existingValues.get(WorkflowModel.PROP_PRIORITY);
    try
    {
    	if(priorDef != null) {
         for (ConstraintDefinition constraintDef : priorDef.getConstraints())
         {
             constraintDef.getConstraint().evaluate(existingValue);
         }
    	}
    }
    catch (ConstraintException ce)
    {
        if(priorDef != null) {
            Integer defaultVal = Integer.valueOf(priorDef.getDefaultValue());
            if (logger.isDebugEnabled())
            {
                logger.debug("Task priority value ("+existingValue+") was invalid so it was set to the default value of "+defaultVal+". Task:"+task.getName());
            }
            defaultValues.put(WorkflowModel.PROP_PRIORITY, defaultVal);
        }
    }    
    
    // Special case for task description default value
    String description = (String) existingValues.get(WorkflowModel.PROP_DESCRIPTION);
    if (description == null || description.length() == 0)
    {
        //Try the localised task description first
        String processDefinitionKey = ((ProcessDefinition) ((TaskEntity)task).getExecution().getProcessDefinition()).getKey();
        description = factory.getTaskDescription(typeDefinition, factory.buildGlobalId(processDefinitionKey), null, task.getTaskDefinitionKey());
        if (description != null && description.length() > 0) {
            defaultValues.put(WorkflowModel.PROP_DESCRIPTION,  description);
        } else {
            String descriptionKey = factory.mapQNameToName(WorkflowModel.PROP_WORKFLOW_DESCRIPTION);
            description = (String) task.getExecution().getVariable(descriptionKey); 
            if (description != null && description.length() > 0) {
                defaultValues.put(WorkflowModel.PROP_DESCRIPTION,  description); 
            } else {
                defaultValues.put(WorkflowModel.PROP_DESCRIPTION,  task.getName());
            }
        }
         
    }

    // Assign the default values to the task
    if (defaultValues.size() > 0)
    {
        setTaskProperties(task, defaultValues);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:78,代码来源:ActivitiPropertyConverter.java

示例12: getStartVariables

import org.alfresco.service.cmr.dictionary.TypeDefinition; //导入方法依赖的package包/类
public Map<String, Object> getStartVariables(String processDefId, Map<QName, Serializable> properties)
{
    ProcessDefinition procDef = activitiUtil.getProcessDefinition(processDefId);
    String startTaskTypeName = activitiUtil.getStartTaskTypeName(processDefId);
    TypeDefinition startTaskType  = factory.getTaskFullTypeDefinition(startTaskTypeName, true);
    
    // Lookup type definition for the startTask
    Map<QName, PropertyDefinition> taskProperties = startTaskType.getProperties();
    
    // Get all default values from the definitions
    Map<QName, Serializable> defaultProperties = new HashMap<QName, Serializable>();
    for (Map.Entry<QName, PropertyDefinition> entry : taskProperties.entrySet())
    {
        String defaultValue = entry.getValue().getDefaultValue();
        if (defaultValue != null)
        {
            defaultProperties.put(entry.getKey(), defaultValue);
        }
    }
    
    // Put all passed properties in map with defaults
    if(properties != null)
    {
        defaultProperties.putAll(properties);
    }
    
    // Special case for task description default value
    // Use the shared description set in the workflowinstance
    String description = (String) defaultProperties.get(WorkflowModel.PROP_DESCRIPTION);
    if(description == null)
    {
        String wfDescription = (String) defaultProperties.get(WorkflowModel.PROP_WORKFLOW_DESCRIPTION);
        String procDefKey = procDef.getKey();
        ReadOnlyProcessDefinition deployedDef = activitiUtil.getDeployedProcessDefinition(processDefId);
        String startEventName = deployedDef.getInitial().getId();
        String wfDefKey = factory.buildGlobalId(procDefKey);
        description = factory.getTaskDescription(startTaskType, wfDefKey, wfDescription, startEventName);
        defaultProperties.put(WorkflowModel.PROP_DESCRIPTION, description);
    }
    
    //Special case for workflowDueDate. 
    if(!defaultProperties.containsKey(WorkflowModel.PROP_WORKFLOW_DUE_DATE) && taskProperties.containsKey(WorkflowModel.PROP_WORKFLOW_DUE_DATE))
    {
        defaultProperties.put(WorkflowModel.PROP_WORKFLOW_DUE_DATE, null);
    }
    
    return handlerRegistry.handleVariablesToSet(defaultProperties, startTaskType, null, Void.class);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:49,代码来源:ActivitiPropertyConverter.java


注:本文中的org.alfresco.service.cmr.dictionary.TypeDefinition.getProperties方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。