org.alfresco.service.cmr.dictionary.AssociationDefinition Java Examples

The following examples show how to use org.alfresco.service.cmr.dictionary.AssociationDefinition. 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: RepoDictionaryDAOTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testChildAssocPropagate()
{
    // Check the default value
    AssociationDefinition assocDef = service.getAssociation(QName.createQName(TEST_URL, "childassoc1"));
    assertNotNull("No such child association found", assocDef);
    assertTrue("Expected a child association", assocDef instanceof ChildAssociationDefinition);
    ChildAssociationDefinition childAssocDef = (ChildAssociationDefinition) assocDef;
    assertFalse("Expected 'false' for default timestamp propagation", childAssocDef.getPropagateTimestamps());

    // Check the explicit value
    assocDef = service.getAssociation(QName.createQName(TEST_URL, "childassocPropagate"));
    assertNotNull("No such child association found", assocDef);
    assertTrue("Expected a child association", assocDef instanceof ChildAssociationDefinition);
    childAssocDef = (ChildAssociationDefinition) assocDef;
    assertTrue("Expected 'true' for timestamp propagation", childAssocDef.getPropagateTimestamps());
}
 
Example #2
Source File: AbstractClassGet.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Override method from DeclarativeWebScript
 */
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
{
    Map<String, Object> model = new HashMap<String, Object>(3);
    Map<QName, ClassDefinition> classdef = new HashMap<QName, ClassDefinition>();
    Map<QName, Collection<PropertyDefinition>> propdef = new HashMap<QName, Collection<PropertyDefinition>>();
    Map<QName, Collection<AssociationDefinition>> assocdef = new HashMap<QName, Collection<AssociationDefinition>>();

    QName classQname = getClassQname(req);
    classdef.put(classQname, this.dictionaryservice.getClass(classQname));
    propdef.put(classQname, this.dictionaryservice.getClass(classQname).getProperties().values());
    assocdef.put(classQname, this.dictionaryservice.getClass(classQname).getAssociations().values());

    model.put(MODEL_PROP_KEY_CLASS_DETAILS, classdef.values());
    model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, propdef.values());
    model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, assocdef.values());
    model.put(MODEL_PROP_KEY_MESSAGE_LOOKUP, this.dictionaryservice);

    return model;
}
 
Example #3
Source File: DictionaryDAOTest.java    From alfresco-data-model with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void testChildAssocPropagate()
{
    // Check the default value
    AssociationDefinition assocDef = service.getAssociation(QName.createQName(TEST_URL, "childassoc1"));
    assertNotNull("No such child association found", assocDef);
    assertTrue("Expected a child association", assocDef instanceof ChildAssociationDefinition);
    ChildAssociationDefinition childAssocDef = (ChildAssociationDefinition) assocDef;
    assertFalse("Expected 'false' for default timestamp propagation", childAssocDef.getPropagateTimestamps());

    // Check the explicit value
    assocDef = service.getAssociation(QName.createQName(TEST_URL, "childassocPropagate"));
    assertNotNull("No such child association found", assocDef);
    assertTrue("Expected a child association", assocDef instanceof ChildAssociationDefinition);
    childAssocDef = (ChildAssociationDefinition) assocDef;
    assertTrue("Expected 'true' for timestamp propagation", childAssocDef.getPropagateTimestamps());
}
 
Example #4
Source File: FieldUtils.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Generates a list of association fields with values.
 * 
 * @param assocDefs List of association definitions to generate
 * @param values Map containing the values to use for each property
 * @param group The group the field belongs to
 * @param namespaceService NamespaceService instance
 * @return List of generated Field objects
 */
public static List<Field> makeAssociationFields(
            Collection<AssociationDefinition> assocDefs,
            Map<AssociationDefinition, Object> values,
            FieldGroup group,
            NamespaceService namespaceService,
            DictionaryService dictionaryService)
{
    AssociationFieldProcessor processor = new AssociationFieldProcessor(namespaceService, dictionaryService);
    ArrayList<Field> fields = new ArrayList<Field>(assocDefs.size());
    for (AssociationDefinition propDef : assocDefs)
    {
        Object value = values == null ? null : values.get(propDef);
        Field field = processor.makeField(propDef, value, group);
        fields.add(field);
    }
    return fields;
}
 
Example #5
Source File: RelationshipTypeDefintionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void updateDefinition(DictionaryService dictionaryService)
{
    AssociationDefinition assocDef = dictionaryService.getAssociation(alfrescoName);

    if (assocDef != null)
    {
        setTypeDefDisplayName(assocDef.getTitle(dictionaryService));
        setTypeDefDescription(assocDef.getDescription(dictionaryService));
    }
    else
    {
        super.updateDefinition(dictionaryService);
    }
    
    updateTypeDefInclProperties();
}
 
Example #6
Source File: FormProcessorTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected Map<QName, AssociationDefinition> makeTaskAssociationDefs()
{
    Map<QName, AssociationDefinition> associations = new HashMap<QName, AssociationDefinition>();
    QName actorName = QName.createQName(NamespaceService.BPM_MODEL_1_0_URI, "Actor");

    // Add Assigneee association
    MockClassAttributeDefinition assigneeDef = MockClassAttributeDefinition.mockAssociationDefinition(ASSIGNEE_NAME, actorName);
    associations.put(ASSIGNEE_NAME, assigneeDef);

    // Add Assigneee association
    MockClassAttributeDefinition actorsDef = MockClassAttributeDefinition.mockAssociationDefinition(ACTORS_NAME, actorName);
    associations.put(ACTORS_NAME, actorsDef);

    // Add association with _
    MockClassAttributeDefinition with_ = MockClassAttributeDefinition.mockAssociationDefinition(ASSOC_WITH_, actorName);
    associations.put(ASSOC_WITH_, with_);

    return associations;
}
 
Example #7
Source File: AbstractWorkflowPropertyHandler.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 #8
Source File: ActivitiPropertyConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private Map<QName, Serializable> mapArbitraryProperties(Map<String, Object> variables,
        final Map<String, Object> localVariables,
            final Map<QName, PropertyDefinition> taskProperties,
            final Map<QName, AssociationDefinition> taskAssociations) 
{
    EntryTransformer<String, Object, QName, Serializable> transformer = new EntryTransformer<String, Object, QName, Serializable>()
    {
        @Override
        public Pair<QName, Serializable> apply(Entry<String, Object> entry)
        {
            String key = entry.getKey();
            QName qname = factory.mapNameToQName(key);
            // Add variable, only if part of task definition or locally defined
            // on task
            if (taskProperties.containsKey(qname) 
                    || taskAssociations.containsKey(qname) 
                    || localVariables.containsKey(key))
            {
                Serializable value = convertPropertyValue(entry.getValue());
                return new Pair<QName, Serializable>(qname, value);
            }
            return null;
        }
    };
    return CollectionUtils.transform(variables, transformer);
}
 
Example #9
Source File: AbstractDictionaryRegistry.java    From alfresco-data-model with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected AssociationDefinition getAssociationImpl(QName assocName)
{
	AssociationDefinition assocDef = null;

    List<CompiledModel> models = getModelsForUri(assocName.getNamespaceURI());
    if(models != null && models.size() > 0)
    {
     for (CompiledModel model : models)
     {
     	assocDef = model.getAssociation(assocName);
     	if(assocDef != null)
     	{
     		break;
     	}
     }
    }

    return assocDef;
}
 
Example #10
Source File: PolicyComponentImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public BehaviourDefinition<ClassFeatureBehaviourBinding> bindAssociationBehaviour(QName policy, QName className, QName assocName, Behaviour behaviour)
{
    // Validate arguments
    ParameterCheck.mandatory("Policy", policy);
    ParameterCheck.mandatory("Class Reference", className);
    ParameterCheck.mandatory("Association Reference", assocName);
    ParameterCheck.mandatory("Behaviour", behaviour);

    // Validate Binding
    AssociationDefinition assocDefinition = dictionary.getAssociation(assocName);
    if (assocDefinition == null)
    {
        throw new IllegalArgumentException("Association " + assocName + " of class " + className + " has not been defined in the data dictionary");
    }
    
    // Create behaviour definition and bind to policy
    ClassFeatureBehaviourBinding binding = new ClassFeatureBehaviourBinding(dictionary, className, assocName);
    BehaviourDefinition<ClassFeatureBehaviourBinding> definition = createBehaviourDefinition(PolicyType.Association, policy, binding, behaviour);
    getAssociationBehaviourIndex(policy).putClassBehaviour(definition);
    
    if (logger.isInfoEnabled())
        logger.info("Bound " + behaviour + " to policy " + policy + " for association " + assocName + " of class " + className);

    return definition;
}
 
Example #11
Source File: RepoDictionaryDAOTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testLabels()
{
    QName model = QName.createQName(TEST_URL, "dictionarydaotest");
    ModelDefinition modelDef = service.getModel(model);
    assertEquals("Model Description", modelDef.getDescription(service));
    QName type = QName.createQName(TEST_URL, "base");
    TypeDefinition typeDef = service.getType(type);
    assertEquals("Base Title", typeDef.getTitle(service));
    assertEquals("Base Description", typeDef.getDescription(service));
    QName prop = QName.createQName(TEST_URL, "prop1");
    PropertyDefinition propDef = service.getProperty(prop);
    assertEquals("Prop1 Title", propDef.getTitle(service));
    assertEquals("Prop1 Description", propDef.getDescription(service));
    QName assoc = QName.createQName(TEST_URL, "assoc1");
    AssociationDefinition assocDef = service.getAssociation(assoc);
    assertEquals("Assoc1 Title", assocDef.getTitle(service));
    assertEquals("Assoc1 Description", assocDef.getDescription(service));
    QName datatype = QName.createQName(TEST_URL, "datatype");
    DataTypeDefinition datatypeDef = service.getDataType(datatype);
    assertEquals("alfresco/model/dataTypeAnalyzers", datatypeDef.getAnalyserResourceBundleName());
}
 
Example #12
Source File: FieldProcessorTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private Map<QName, AssociationDefinition> makeAssociationDefs()
{
    QName targetClass = QName.createQName(URI, "Target");
    AssociationDefinition assocDef1 = MockClassAttributeDefinition.mockAssociationDefinition(
            qName1, targetClass,
            null,// Defalt title, so sets label to be same as name.
            DESCRIPTION1, false, false, false);
    MockClassAttributeDefinition assocDef2 = MockClassAttributeDefinition.mockAssociationDefinition(
            qName2, targetClass,
            TITLE, DESCRIPTION2,
            true, true, true);
    Map<QName, AssociationDefinition> assocDefs = new HashMap<QName, AssociationDefinition>();
    assocDefs.put(qName1, assocDef1);
    assocDefs.put(qName2, assocDef2);
    return assocDefs;
}
 
Example #13
Source File: ExporterComponent.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Is the association unexportable?
 */
private boolean isExcludedAspectAssociation(QName[] excludeAspects, QName associationQName)
{
    AssociationDefinition assocDef = dictionaryService.getAssociation(associationQName);
    if (assocDef == null)
    {
        return false;
    }
    
    ClassDefinition classDef = assocDef.getSourceClass();
    if (classDef == null || !classDef.isAspect())
    {
        return false;
    }
    
    return isExcludedAspect(excludeAspects, classDef.getName());
}
 
Example #14
Source File: ChildAssociatedNodeFinder.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void init()
{
    super.init();
    // Quickly scan the supplied association types and remove any that either
    // do not exist or are not child association types.
    DictionaryService dictionaryService = serviceRegistry.getDictionaryService();
    childAssociationTypes.clear();
    for (QName associationType : suppliedAssociationTypes)
    {
        AssociationDefinition assocDef = dictionaryService.getAssociation(associationType);
        if (assocDef != null && assocDef.isChild())
        {
            childAssociationTypes.add(associationType);
        }
    }
    initialised = true;
}
 
Example #15
Source File: CMISMapping.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Is an association valid in CMIS? It must be a non-child relationship and
 * the source and target must both be valid CMIS types.
 * 
 * @param associationQName QName
 * @return boolean
 */
public boolean isValidCmisRelationship(QName associationQName)
{
    if (associationQName == null)
    {
        return false;
    }
    if (associationQName.equals(RELATIONSHIP_QNAME))
    {
        return true;
    }
    AssociationDefinition associationDefinition = dictionaryService.getAssociation(
            associationQName);
    if (associationDefinition == null)
    {
        return false;
    }
    if (associationDefinition.isChild())
    {
        return false;
    }
    if(!isValidCmisRelationshipEndPoint(associationDefinition.getTargetClass().getName()))
    {
        return false;
    }
    if(!isValidCmisRelationshipEndPoint(associationDefinition.getSourceClass().getName()))
    {
        return false;
    }
    return true;
}
 
Example #16
Source File: WorkflowModelBuilder.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
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 #17
Source File: CMISStrictDictionaryService.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
private RelationshipTypeDefintionWrapper createAssocDef(QName classQName)
{
	RelationshipTypeDefintionWrapper assocTypeDef = null;

    if(cmisMapping.isValidCmisRelationship(classQName))
    {
     // create appropriate kind of type definition
     AssociationDefinition assocDef = dictionaryService.getAssociation(classQName);
     String typeId = cmisMapping.getCmisTypeId(BaseTypeId.CMIS_RELATIONSHIP, classQName);
     assocTypeDef = new RelationshipTypeDefintionWrapper(cmisMapping, accessorMapping, luceneBuilderMapping, 
             typeId, dictionaryService, assocDef);
    }

    return assocTypeDef;
}
 
Example #18
Source File: WorkflowFormProcessorTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private TypeDefinition makeTypeDef()
{
    TypeDefinition typeDef = mock(TypeDefinition.class);
    QName name = QName.createQName(NamespaceService.BPM_MODEL_1_0_URI, TASK_DEF_NAME);
    when(typeDef.getName()).thenReturn(name);

    // Set up task property definitions
    Map<QName, PropertyDefinition> propertyDefs = makeTaskPropertyDefs();
    when(typeDef.getProperties()).thenReturn(propertyDefs);

    // Set up task association definitions.
    Map<QName, AssociationDefinition> associationDefs = makeTaskAssociationDefs();
    when(typeDef.getAssociations()).thenReturn(associationDefs);
    return typeDef;
}
 
Example #19
Source File: DelegateModelQuery.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
public AssociationDefinition getAssociation(QName name)
{
    AssociationDefinition def = query.getAssociation(name);
    if (def == null)
    {
        def = delegate.getAssociation(name);
    }
    return def;
}
 
Example #20
Source File: TaskFormProcessorTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private TypeDefinition makeTypeDef()
{
    TypeDefinition typeDef = mock(TypeDefinition.class);
    QName name = QName.createQName(NamespaceService.BPM_MODEL_1_0_URI, TASK_DEF_NAME);
    when(typeDef.getName()).thenReturn(name);

    // Set up task property definitions
    Map<QName, PropertyDefinition> propertyDefs = makeTaskPropertyDefs();
    when(typeDef.getProperties()).thenReturn(propertyDefs);

    // Set up task association definitions.
    Map<QName, AssociationDefinition> associationDefs = makeTaskAssociationDefs();
    when(typeDef.getAssociations()).thenReturn(associationDefs);
    return typeDef;
}
 
Example #21
Source File: FieldProcessorTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private ContentModelItemData<Void> makeItemData()
{
    Map<QName, PropertyDefinition> propDefs = makePropertyDefs();
    Map<QName, AssociationDefinition> assocDefs = makeAssociationDefs();
    
    Map<QName, Serializable> propValues = new HashMap<QName, Serializable>();
    Map<QName, Serializable> assocValues = new HashMap<QName, Serializable>();
    Map<String, Object> transientValues = new HashMap<String, Object>();
    return new ContentModelItemData<Void>(null, propDefs, assocDefs, propValues, assocValues, transientValues);
}
 
Example #22
Source File: DbNodeServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private Set<QName> getMissingAspectsAssoc(
        Set<QName> existingAspects,
        Map<QName, Serializable> existingProperties,
        QName assocTypeQName)
{
        AssociationDefinition assocDef = dictionaryService.getAssociation(assocTypeQName);
        if (assocDef == null)
        {
            return Collections.emptySet();
        }
        ClassDefinition classDefinition = assocDef.getSourceClass();
        return getMissingAspects(existingAspects, existingProperties, classDefinition.getName());
}
 
Example #23
Source File: RestVariableHelper.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Sets the variable value with possible conversion to the correct format to be used in the response and sets
 * the type accordingly. If the variables is defined on the {@link TypeDefinition}, the data-type is used. If it's not
 * defined, the type is deducted from the raw variable value.
 */
protected void setVariableValueAndType(Variable variable, Object value, TypeDefinitionContext context)
{
    PropertyDefinition propDef = context.getPropertyDefinition(variable.getName());
    if (propDef != null)
    {
        variable.setValue(getSafePropertyValue(value));
        variable.setType(propDef.getDataType().getName().toPrefixString(namespaceService));
    }
    else
    {
        // Not defined as a property, check if it's an association
        AssociationDefinition assocDef = context.getAssociationDefinition(variable.getName());
        if (assocDef == null)
        {
            // Try to get an association definition through dictionary
            String[] prefixLocalName = variable.getName().split("_");
            if (prefixLocalName.length == 2)
            {
                QName qName = QName.createQName(prefixLocalName[0], prefixLocalName[1], namespaceService);
                assocDef = dictionaryService.getAssociation(qName);
            }
        }
        
        if (assocDef != null)
        {
            // Type of variable is the target class-name
            variable.setType(assocDef.getTargetClass().getName().toPrefixString(namespaceService));
            variable.setValue(getAssociationRepresentation(value, assocDef));
        }
        else
        {
            // Variable is not declared as property or association type-def. Use actual raw value as base for conversion.
            variable.setValue(getSafePropertyValue(value));
            variable.setType(extractTypeStringFromValue(value));
        }
    }
}
 
Example #24
Source File: AbstractDictionaryRegistry.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Collection<QName> getAssociations(boolean includeInherited)
{
    Collection<QName> types = new ArrayList<QName>(100);
    for (QName model : getCompiledModels(includeInherited).keySet())
    {
    	for(AssociationDefinition assocDef : getModel(model).getAssociations())
    	{
    		types.add(assocDef.getName());
    	}
    }
    return types;
}
 
Example #25
Source File: RestVariableHelper.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @return object that represents the association value. 
 */
protected Object getAssociationRepresentation(Object value, AssociationDefinition assocDef)
{
    Object result = null;
    if(value != null)
    {
        if(assocDef.isTargetMany()) 
        {
            // Construct list of representations of the nodeRefs
            List<Object> list = new ArrayList<Object>();
            if(value instanceof Collection<?>)
            {
                for(Object entry : (Collection<?>) value)
                {
                    list.add(getRepresentationForNodeRef(entry, assocDef.getTargetClass()));
                }
            }
            else
            {
                // Many-property but only single value present
                list.add(getRepresentationForNodeRef(value, assocDef.getTargetClass()));
            }
            result = list;
        }
        else
        {
            // Association is a single nodeRef, get representation for it
            result = getRepresentationForNodeRef(value, assocDef.getTargetClass());
        }
    }
    return result;
}
 
Example #26
Source File: AssocTargetTypeIntegrityEvent.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void checkIntegrity(List<IntegrityRecord> eventResults)
{
    QName assocTypeQName = getTypeQName();
    NodeRef targetNodeRef = getNodeRef();
    // if the node is gone then the check is irrelevant
    QName targetNodeTypeQName = getNodeType(targetNodeRef);
    if (targetNodeTypeQName == null)
    {
        // target or source is missing
        if (logger.isDebugEnabled())
        {
            logger.debug("Ignoring integrity check - node gone: \n" +
                    "   event: " + this);
        }
        return;
    }
    
    // get the association def
    AssociationDefinition assocDef = getAssocDef(eventResults, assocTypeQName);
    // the association definition must exist
    if (assocDef == null)
    {
        IntegrityRecord result = new IntegrityRecord(
                "Association type does not exist: \n" +
                "   Target Node: " + targetNodeRef + "\n" +
                "   Target Node Type: " + targetNodeTypeQName + "\n" +
                "   Association Type: " + assocTypeQName);
        eventResults.add(result);
        return;
    }
    
    // perform required checks
    checkTargetType(eventResults, assocDef, targetNodeRef, targetNodeTypeQName);
}
 
Example #27
Source File: ContentModelFormProcessor.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 #28
Source File: AssocTargetRoleIntegrityEvent.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void checkIntegrity(List<IntegrityRecord> eventResults)
{
    QName assocTypeQName = getTypeQName();
    QName assocQName = getQName();
    NodeRef sourceNodeRef = getNodeRef();
    
    // get the association def
    AssociationDefinition assocDef = getAssocDef(eventResults, assocTypeQName);
    // the association definition must exist
    if (assocDef == null)
    {
        IntegrityRecord result = new IntegrityRecord(
                "Association type does not exist: \n" +
                "   Association Type: " + assocTypeQName);
        eventResults.add(result);
        return;
    }
    
    // check that we are dealing with child associations
    if (assocQName == null)
    {
        throw new IllegalArgumentException("The association qualified name must be supplied");
    }
    if (!assocDef.isChild())
    {
        throw new UnsupportedOperationException("This operation is only relevant to child associations");
    }
    ChildAssociationDefinition childAssocDef = (ChildAssociationDefinition) assocDef;
    
    // perform required checks
    checkAssocQNameRegex(eventResults, childAssocDef, assocQName, sourceNodeRef);
}
 
Example #29
Source File: AssocSourceTypeIntegrityEvent.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void checkIntegrity(List<IntegrityRecord> eventResults)
{
    QName assocTypeQName = getTypeQName();
    NodeRef sourceNodeRef = getNodeRef();
    // if the node is gone then the check is irrelevant
    QName sourceNodeTypeQName = getNodeType(sourceNodeRef);
    if (sourceNodeTypeQName == null)
    {
        // target or source is missing
        if (logger.isDebugEnabled())
        {
            logger.debug("Ignoring integrity check - node gone: \n" +
                    "   event: " + this);
        }
        return;
    }
    
    // get the association def
    AssociationDefinition assocDef = getAssocDef(eventResults, assocTypeQName);
    // the association definition must exist
    if (assocDef == null)
    {
        IntegrityRecord result = new IntegrityRecord(
                "Association type does not exist: \n" +
                "   Source Node: " + sourceNodeRef + "\n" +
                "   Source Node Type: " + sourceNodeTypeQName + "\n" +
                "   Association Type: " + assocTypeQName);
        eventResults.add(result);
        return;
    }
    
    // perform required checks
    checkSourceType(eventResults, assocDef, sourceNodeRef, sourceNodeTypeQName);
}
 
Example #30
Source File: IntegrityChecker.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @see PropertiesIntegrityEvent
 * @see AssocTargetMultiplicityIntegrityEvent
 */
public void onAddAspect(NodeRef nodeRef, QName aspectTypeQName)
{
    if (! storesToIgnore.contains(tenantService.getBaseName(nodeRef.getStoreRef()).toString()))
    {
        IntegrityEvent event = null;
        // check properties on node
        event = new PropertiesIntegrityEvent(nodeService, dictionaryService, nodeRef);
        save(event);
        
        // check for associations defined on the aspect
        AspectDefinition aspectDef = dictionaryService.getAspect(aspectTypeQName);
        if (aspectDef == null)
        {
            throw new DictionaryException("The aspect type is not recognized: " + aspectTypeQName);
        }
        Map<QName, AssociationDefinition> assocDefs = aspectDef.getAssociations();
        
        // check the multiplicity of each association with the node acting as a source
        for (AssociationDefinition assocDef : assocDefs.values())
        {
            QName assocTypeQName = assocDef.getName();
            // check target multiplicity
            event = new AssocTargetMultiplicityIntegrityEvent(
                    nodeService,
                    dictionaryService,
                    nodeRef,
                    assocTypeQName,
                    false);
            save(event);
        }
    }
}