use of org.alfresco.service.cmr.dictionary.TypeDefinition in project acs-community-packaging by Alfresco.
the class CreateRuleWizard method getModelTypes.
/**
* Returns a list of the types available in the repository
*
* @return List of SelectItem objects
*/
public List<SelectItem> getModelTypes() {
if ((this.modelTypes == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
FacesContext context = FacesContext.getCurrentInstance();
ConfigService svc = Application.getConfigService(context);
Config wizardCfg = svc.getConfig("Action Wizards");
if (wizardCfg != null) {
ConfigElement typesCfg = wizardCfg.getConfigElement("subtypes");
if (typesCfg != null) {
this.modelTypes = new ArrayList<SelectItem>();
for (ConfigElement child : typesCfg.getChildren()) {
QName idQName = Repository.resolveToQName(child.getAttribute("name"));
// get the display label from config
String label = Utils.getDisplayLabel(context, child);
// if there wasn't a client based label try and get it from the dictionary
if (label == null) {
TypeDefinition typeDef = this.getDictionaryService().getType(idQName);
if (typeDef != null) {
label = typeDef.getTitle(this.getDictionaryService());
} else {
label = idQName.getLocalName();
}
}
this.modelTypes.add(new SelectItem(idQName.toString(), label));
}
// make sure the list is sorted by the label
QuickSort sorter = new QuickSort(this.modelTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
} else {
logger.warn("Could not find 'subtypes' configuration element");
}
} else {
logger.warn("Could not find 'Action Wizards' configuration section");
}
}
return this.modelTypes;
}
use of org.alfresco.service.cmr.dictionary.TypeDefinition 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.TypeDefinition in project acs-community-packaging by Alfresco.
the class DataDictionary method getPropertyDefinition.
/**
* Returns the property definition for the given property on the given node
*
* @param node The node from which to get the property
* @param property The property to find the definition for
* @return The property definition or null if the property is not known
*/
public PropertyDefinition getPropertyDefinition(Node node, String property) {
PropertyDefinition propDef = null;
TypeDefinition typeDef = getTypeDef(node.getType(), node.getAspects());
if (typeDef != null) {
Map<QName, PropertyDefinition> properties = typeDef.getProperties();
propDef = properties.get(Repository.resolveToQName(property));
}
return propDef;
}
use of org.alfresco.service.cmr.dictionary.TypeDefinition in project SearchServices by Alfresco.
the class Solr4QueryParser method createTypeQuery.
protected Query createTypeQuery(String queryText, boolean exactOnly) throws ParseException {
TypeDefinition target = QueryParserUtils.matchTypeDefinition(searchParameters.getNamespace(), namespacePrefixResolver, dictionaryService, queryText);
if (target == null) {
return new TermQuery(new Term(FIELD_TYPE, "_unknown_"));
}
if (exactOnly) {
QName targetQName = target.getName();
TermQuery termQuery = new TermQuery(new Term(FIELD_TYPE, targetQName.toString()));
return termQuery;
} else {
Collection<QName> subclasses = dictionaryService.getSubTypes(target.getName(), true);
BooleanQuery.Builder booleanQuery = new BooleanQuery.Builder();
for (QName qname : subclasses) {
TypeDefinition current = dictionaryService.getType(qname);
if (target.getName().equals(current.getName()) || current.getIncludedInSuperTypeQuery()) {
TermQuery termQuery = new TermQuery(new Term(FIELD_TYPE, qname.toString()));
if (termQuery != null) {
booleanQuery.add(termQuery, Occur.SHOULD);
}
}
}
return booleanQuery.build();
}
}
use of org.alfresco.service.cmr.dictionary.TypeDefinition in project alfresco-remote-api by Alfresco.
the class CustomModelsImpl method getCustomType.
@Override
public CustomType getCustomType(String modelName, String typeName, Parameters parameters) {
if (typeName == null) {
throw new InvalidArgumentException(TYPE_NAME_NULL_ERR);
}
final CustomModelDefinition modelDef = getCustomModelImpl(modelName);
QName typeQname = QName.createQName(modelDef.getName().getNamespaceURI(), typeName);
TypeDefinition customTypeDef = customModelService.getCustomType(typeQname);
if (customTypeDef == null) {
throw new EntityNotFoundException(typeName);
}
// Check if inherited properties have been requested
boolean includeInheritedProps = hasSelectProperty(parameters, SELECT_ALL_PROPS);
return convertToCustomType(customTypeDef, includeInheritedProps);
}
Aggregations