Search in sources :

Example 16 with ClassDefinition

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

the class CustomisableGet method executeImpl.

/**
 * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
 */
@Override
public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
    Map<String, Object> model = new HashMap<String, Object>();
    Set<QName> qnames = rmAdminService.getCustomisable();
    ArrayList<Item> items = new ArrayList<Item>(qnames.size());
    for (QName qname : qnames) {
        ClassDefinition definition = dictionaryService.getClass(qname);
        if (definition != null) {
            String name = qname.toPrefixString(namespaceService);
            String title = definition.getTitle(dictionaryService);
            if (title == null || title.length() == 0) {
                title = qname.getLocalName();
            }
            boolean isAspect = definition.isAspect();
            items.add(new Item(name, isAspect, title));
        }
    }
    // Sort the customisable types and aspects by title
    Collections.sort(items, new Comparator<Item>() {

        @Override
        public int compare(Item o1, Item o2) {
            return o1.title.compareToIgnoreCase(o2.title);
        }
    });
    model.put("items", items);
    return model;
}
Also used : HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) ArrayList(java.util.ArrayList) ClassDefinition(org.alfresco.service.cmr.dictionary.ClassDefinition)

Example 17 with ClassDefinition

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

the class IdentifierServiceImpl method lookupGenerator.

/**
 * @param type content type (could be aspect or type)
 * @return
 */
private IdentifierGenerator lookupGenerator(QName type) {
    ParameterCheck.mandatory("type", type);
    if (logger.isDebugEnabled()) {
        logger.debug("Looking for idGenerator for type " + type.toString());
    }
    // Look for the generator related to the type
    IdentifierGenerator result = register.get(type);
    if (result == null) {
        // Check the parent type
        ClassDefinition typeDef = dictionaryService.getClass(type);
        if (typeDef != null) {
            QName parentType = typeDef.getParentName();
            if (parentType != null) {
                // Recurse to find parent type generator
                result = lookupGenerator(parentType);
            }
        } else {
            if (logger.isDebugEnabled()) {
                logger.debug("Unable to find type definition for " + type.toString() + " when generating identifier.");
            }
        }
    }
    return result;
}
Also used : QName(org.alfresco.service.namespace.QName) ClassDefinition(org.alfresco.service.cmr.dictionary.ClassDefinition)

Aggregations

ClassDefinition (org.alfresco.service.cmr.dictionary.ClassDefinition)17 QName (org.alfresco.service.namespace.QName)12 PropertyDefinition (org.alfresco.service.cmr.dictionary.PropertyDefinition)11 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)8 Collection (java.util.Collection)6 AssociationDefinition (org.alfresco.service.cmr.dictionary.AssociationDefinition)5 WebScriptException (org.springframework.extensions.webscripts.WebScriptException)3 HashSet (java.util.HashSet)2 BooleanQuery (org.apache.lucene.search.BooleanQuery)2 ConstantScoreQuery (org.apache.lucene.search.ConstantScoreQuery)2 MatchAllDocsQuery (org.apache.lucene.search.MatchAllDocsQuery)2 MultiTermQuery (org.apache.lucene.search.MultiTermQuery)2 Query (org.apache.lucene.search.Query)2 RegexpQuery (org.apache.lucene.search.RegexpQuery)2 TermQuery (org.apache.lucene.search.TermQuery)2 TermRangeQuery (org.apache.lucene.search.TermRangeQuery)2 SpanNearQuery (org.apache.lucene.search.spans.SpanNearQuery)2 SpanOrQuery (org.apache.lucene.search.spans.SpanOrQuery)2 SpanQuery (org.apache.lucene.search.spans.SpanQuery)2