Search in sources :

Example 26 with TypeDefinition

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;
}
Also used : FacesContext(javax.faces.context.FacesContext) QuickSort(org.alfresco.web.data.QuickSort) ConfigService(org.springframework.extensions.config.ConfigService) ConfigElement(org.springframework.extensions.config.ConfigElement) Config(org.springframework.extensions.config.Config) SelectItem(javax.faces.model.SelectItem) QName(org.alfresco.service.namespace.QName) TypeDefinition(org.alfresco.service.cmr.dictionary.TypeDefinition)

Example 27 with TypeDefinition

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

Example 28 with TypeDefinition

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

Example 29 with TypeDefinition

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();
    }
}
Also used : MultiTermQuery(org.apache.lucene.search.MultiTermQuery) SpanTermQuery(org.apache.lucene.search.spans.SpanTermQuery) TermQuery(org.apache.lucene.search.TermQuery) BooleanQuery(org.apache.lucene.search.BooleanQuery) QName(org.alfresco.service.namespace.QName) Builder(org.apache.lucene.search.BooleanQuery.Builder) Term(org.apache.lucene.index.Term) Builder(org.apache.lucene.search.BooleanQuery.Builder) TypeDefinition(org.alfresco.service.cmr.dictionary.TypeDefinition) DataTypeDefinition(org.alfresco.service.cmr.dictionary.DataTypeDefinition)

Example 30 with TypeDefinition

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);
}
Also used : CustomModelDefinition(org.alfresco.service.cmr.dictionary.CustomModelDefinition) InvalidArgumentException(org.alfresco.rest.framework.core.exceptions.InvalidArgumentException) QName(org.alfresco.service.namespace.QName) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException) TypeDefinition(org.alfresco.service.cmr.dictionary.TypeDefinition) DataTypeDefinition(org.alfresco.service.cmr.dictionary.DataTypeDefinition)

Aggregations

TypeDefinition (org.alfresco.service.cmr.dictionary.TypeDefinition)43 QName (org.alfresco.service.namespace.QName)30 DataTypeDefinition (org.alfresco.service.cmr.dictionary.DataTypeDefinition)18 NodeRef (org.alfresco.service.cmr.repository.NodeRef)13 FacesContext (javax.faces.context.FacesContext)10 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)8 StartFormData (org.activiti.engine.form.StartFormData)8 IOException (java.io.IOException)7 PropertyDefinition (org.alfresco.service.cmr.dictionary.PropertyDefinition)7 Node (org.alfresco.web.bean.repository.Node)7 UserTransaction (javax.transaction.UserTransaction)6 InvalidArgumentException (org.alfresco.rest.framework.core.exceptions.InvalidArgumentException)6 DictionaryService (org.alfresco.service.cmr.dictionary.DictionaryService)6 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)6 Date (java.util.Date)5 SelectItem (javax.faces.model.SelectItem)5 MapNode (org.alfresco.web.bean.repository.MapNode)5 Serializable (java.io.Serializable)4 List (java.util.List)4