Search in sources :

Example 31 with AssociationDefinition

use of org.alfresco.service.cmr.dictionary.AssociationDefinition in project alfresco-repository by Alfresco.

the class RepoDictionaryDAOTest method testLabels.

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());
}
Also used : AssociationDefinition(org.alfresco.service.cmr.dictionary.AssociationDefinition) ChildAssociationDefinition(org.alfresco.service.cmr.dictionary.ChildAssociationDefinition) QName(org.alfresco.service.namespace.QName) ModelDefinition(org.alfresco.service.cmr.dictionary.ModelDefinition) DataTypeDefinition(org.alfresco.service.cmr.dictionary.DataTypeDefinition) PropertyDefinition(org.alfresco.service.cmr.dictionary.PropertyDefinition) TypeDefinition(org.alfresco.service.cmr.dictionary.TypeDefinition) DataTypeDefinition(org.alfresco.service.cmr.dictionary.DataTypeDefinition)

Example 32 with AssociationDefinition

use of org.alfresco.service.cmr.dictionary.AssociationDefinition in project acs-community-packaging by Alfresco.

the class UIAssociation method generateItem.

protected void generateItem(FacesContext context, UIPropertySheet propSheet) throws IOException {
    String associationName = (String) getName();
    // get details of the association
    DataDictionary dd = (DataDictionary) FacesContextUtils.getRequiredWebApplicationContext(context).getBean(Application.BEAN_DATA_DICTIONARY);
    AssociationDefinition assocDef = dd.getAssociationDefinition(propSheet.getNode(), associationName);
    if (assocDef == null) {
        logger.warn("Failed to find association definition for association '" + associationName + "'");
    } else {
        // that the association is not a parent child one
        if (assocDef.isChild()) {
            logger.warn("The association named '" + associationName + "' is not an association");
        } else {
            String displayLabel = (String) getDisplayLabel();
            if (displayLabel == null) {
                // try and get the repository assigned label
                displayLabel = assocDef.getTitle(dd.getDictionaryService());
                // if the label is still null default to the local name of the property
                if (displayLabel == null) {
                    displayLabel = assocDef.getName().getLocalName();
                }
            }
            // generate the label and type specific control
            generateLabel(context, propSheet, displayLabel);
            generateControl(context, propSheet, assocDef);
        }
    }
}
Also used : AssociationDefinition(org.alfresco.service.cmr.dictionary.AssociationDefinition) DataDictionary(org.alfresco.web.bean.repository.DataDictionary)

Example 33 with AssociationDefinition

use of org.alfresco.service.cmr.dictionary.AssociationDefinition in project acs-community-packaging by Alfresco.

the class DataDictionary method getAssociationDefinition.

/**
 * Returns the association definition for the given association on the given node
 *
 * @param node The node from which to get the association
 * @param association The association to find the definition for
 * @return The association definition or null if the association is not known
 */
public AssociationDefinition getAssociationDefinition(Node node, String association) {
    AssociationDefinition assocDef = null;
    TypeDefinition typeDef = getTypeDef(node.getType(), node.getAspects());
    if (typeDef != null) {
        Map<QName, AssociationDefinition> assocs = typeDef.getAssociations();
        assocDef = assocs.get(Repository.resolveToQName(association));
    }
    return assocDef;
}
Also used : AssociationDefinition(org.alfresco.service.cmr.dictionary.AssociationDefinition) QName(org.alfresco.service.namespace.QName) TypeDefinition(org.alfresco.service.cmr.dictionary.TypeDefinition)

Example 34 with AssociationDefinition

use of org.alfresco.service.cmr.dictionary.AssociationDefinition in project records-management by Alfresco.

the class RecordsManagementAdminBase method existsTitle.

/**
 * Checks if the given association definition title exists
 *
 * @param associationDefinitionTitle The association definition title
 * @return <code>true</code> if the association definition title exists, <code>false</code> otherwise
 */
protected boolean existsTitle(String associationDefinitionTitle) {
    boolean existsLabel = false;
    Collection<AssociationDefinition> associationDefinitions = getCustomAssociations().values();
    for (AssociationDefinition associationDefinition : associationDefinitions) {
        if (associationDefinition.getTitle(getDictionaryService()).equalsIgnoreCase(associationDefinitionTitle)) {
            existsLabel = true;
        }
    }
    return existsLabel;
}
Also used : AssociationDefinition(org.alfresco.service.cmr.dictionary.AssociationDefinition)

Example 35 with AssociationDefinition

use of org.alfresco.service.cmr.dictionary.AssociationDefinition in project records-management by Alfresco.

the class RecordsManagementAdminBase method getCustomAssociations.

/**
 * Gets all the custom associations
 *
 * @return All custom associations
 */
protected Map<QName, AssociationDefinition> getCustomAssociations() {
    Map<QName, AssociationDefinition> customAssociations = new HashMap<QName, AssociationDefinition>();
    AspectDefinition aspectDefn = getDictionaryService().getAspect(ASPECT_CUSTOM_ASSOCIATIONS);
    if (aspectDefn != null) {
        customAssociations.putAll(aspectDefn.getAssociations());
    }
    return customAssociations;
}
Also used : AssociationDefinition(org.alfresco.service.cmr.dictionary.AssociationDefinition) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) AspectDefinition(org.alfresco.service.cmr.dictionary.AspectDefinition)

Aggregations

AssociationDefinition (org.alfresco.service.cmr.dictionary.AssociationDefinition)60 QName (org.alfresco.service.namespace.QName)46 PropertyDefinition (org.alfresco.service.cmr.dictionary.PropertyDefinition)24 ChildAssociationDefinition (org.alfresco.service.cmr.dictionary.ChildAssociationDefinition)19 NodeRef (org.alfresco.service.cmr.repository.NodeRef)17 TypeDefinition (org.alfresco.service.cmr.dictionary.TypeDefinition)15 HashMap (java.util.HashMap)13 Serializable (java.io.Serializable)11 ArrayList (java.util.ArrayList)11 ClassDefinition (org.alfresco.service.cmr.dictionary.ClassDefinition)9 DataTypeDefinition (org.alfresco.service.cmr.dictionary.DataTypeDefinition)7 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)6 AspectDefinition (org.alfresco.service.cmr.dictionary.AspectDefinition)6 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)6 Collection (java.util.Collection)5 AssociationRef (org.alfresco.service.cmr.repository.AssociationRef)5 HashSet (java.util.HashSet)4 List (java.util.List)4 Map (java.util.Map)4 Pair (org.alfresco.util.Pair)3