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());
}
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);
}
}
}
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;
}
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;
}
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;
}
Aggregations