Search in sources :

Example 21 with QuickSort

use of org.alfresco.web.data.QuickSort in project acs-community-packaging by Alfresco.

the class BaseActionWizard method getObjectTypes.

/**
 * @return Returns a list of object types to allow the user to select from
 */
public List<SelectItem> getObjectTypes() {
    if ((this.objectTypes == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
        FacesContext context = FacesContext.getCurrentInstance();
        // add the well known object type to start with
        this.objectTypes = new ArrayList<SelectItem>(5);
        // add any configured content or folder sub-types to the list
        ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
        Config wizardCfg = svc.getConfig("Action Wizards");
        if (wizardCfg != null) {
            ConfigElement typesCfg = wizardCfg.getConfigElement("specialise-types");
            if (typesCfg != null) {
                for (ConfigElement child : typesCfg.getChildren()) {
                    QName idQName = Repository.resolveToQName(child.getAttribute("name"));
                    TypeDefinition typeDef = this.getDictionaryService().getType(idQName);
                    // the content or folder type itself
                    if (typeDef != null && typeDef.getName().equals(ContentModel.TYPE_CONTENT) == false && typeDef.getName().equals(ContentModel.TYPE_FOLDER) == false && (this.getDictionaryService().isSubClass(typeDef.getName(), ContentModel.TYPE_CONTENT) || this.getDictionaryService().isSubClass(typeDef.getName(), ContentModel.TYPE_FOLDER))) {
                        // try and 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) {
                            label = typeDef.getTitle(this.getDictionaryService());
                        }
                        // finally, just use the localname
                        if (label == null) {
                            label = idQName.getLocalName();
                        }
                        this.objectTypes.add(new SelectItem(idQName.toString(), label));
                    }
                }
                // make sure the list is sorted by the label
                QuickSort sorter = new QuickSort(this.objectTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
                sorter.sort();
                // add the select an action item at the start of the list
                this.objectTypes.add(0, new SelectItem("null", Application.getMessage(FacesContext.getCurrentInstance(), "select_a_type")));
            } else {
                logger.warn("Could not find 'specialise-types' configuration element");
            }
        } else {
            logger.warn("Could not find 'Action Wizards' configuration section");
        }
    }
    return this.objectTypes;
}
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) SelectItem(javax.faces.model.SelectItem) Config(org.springframework.extensions.config.Config) QName(org.alfresco.service.namespace.QName) TypeDefinition(org.alfresco.service.cmr.dictionary.TypeDefinition)

Example 22 with QuickSort

use of org.alfresco.web.data.QuickSort in project acs-community-packaging by Alfresco.

the class BaseActionWizard method getRemovableAspects.

/**
 * Returns a list of aspects that can be removed
 *
 * @return List of SelectItem objects representing the aspects that can be removed
 */
public List<SelectItem> getRemovableAspects() {
    if ((this.removableAspects == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
        // get the list of common aspects
        this.removableAspects = new ArrayList<SelectItem>();
        this.removableAspects.addAll(getCommonAspects());
        // get those aspects configured to appear only in the remove aspect action
        ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
        Config wizardCfg = svc.getConfig("Action Wizards");
        if (wizardCfg != null) {
            ConfigElement aspectsCfg = wizardCfg.getConfigElement("aspects-remove");
            if (aspectsCfg != null) {
                List<SelectItem> aspects = readAspectsConfig(FacesContext.getCurrentInstance(), aspectsCfg);
                this.removableAspects.addAll(aspects);
            } else {
                logger.warn("Could not find 'aspects-remove' configuration element");
            }
        } else {
            logger.warn("Could not find 'Action Wizards' configuration section");
        }
        // make sure the list is sorted by the label
        QuickSort sorter = new QuickSort(this.removableAspects, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
        sorter.sort();
    }
    return this.removableAspects;
}
Also used : QuickSort(org.alfresco.web.data.QuickSort) ConfigService(org.springframework.extensions.config.ConfigService) ConfigElement(org.springframework.extensions.config.ConfigElement) SelectItem(javax.faces.model.SelectItem) Config(org.springframework.extensions.config.Config)

Example 23 with QuickSort

use of org.alfresco.web.data.QuickSort in project acs-community-packaging by Alfresco.

the class BaseActionWizard method getTransformers.

/**
 * Returns the transformers that are available
 *
 * @return List of SelectItem objects representing the available transformers
 */
public List<SelectItem> getTransformers() {
    if ((this.transformers == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
        ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
        Config wizardCfg = svc.getConfig("Action Wizards");
        if (wizardCfg != null) {
            ConfigElement transformersCfg = wizardCfg.getConfigElement("transformers");
            if (transformersCfg != null) {
                FacesContext context = FacesContext.getCurrentInstance();
                Map<String, String> mimeTypes = this.getMimetypeService().getDisplaysByMimetype();
                this.transformers = new ArrayList<SelectItem>();
                for (ConfigElement child : transformersCfg.getChildren()) {
                    String id = child.getAttribute("name");
                    // try and get the display label from config
                    String label = Utils.getDisplayLabel(context, child);
                    // if there wasn't a client based label get it from the mime type service
                    if (label == null) {
                        label = mimeTypes.get(id);
                    }
                    // if there is still no label use the raw mimetype
                    if (label == null) {
                        label = id;
                    }
                    this.transformers.add(new SelectItem(id, label));
                }
                // make sure the list is sorted by the label
                QuickSort sorter = new QuickSort(this.transformers, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
                sorter.sort();
            } else {
                logger.warn("Could not find 'transformers' configuration element");
            }
        } else {
            logger.warn("Could not find 'Action Wizards' configuration section");
        }
    }
    return this.transformers;
}
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)

Example 24 with QuickSort

use of org.alfresco.web.data.QuickSort in project acs-community-packaging by Alfresco.

the class UIStoreSelector method createList.

/**
 * @return List of SelectItem components
 */
protected List<SelectItem> createList() {
    List<SelectItem> items = new ArrayList<SelectItem>(5);
    Constraint storesConstraint = ConstraintRegistry.getInstance().getConstraint("defaultStoreSelector");
    for (String store : ((ListOfValuesConstraint) storesConstraint).getAllowedValues()) {
        items.add(new SelectItem(store, store));
    }
    // make sure the list is sorted by the values
    QuickSort sorter = new QuickSort(items, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
    sorter.sort();
    return items;
}
Also used : QuickSort(org.alfresco.web.data.QuickSort) Constraint(org.alfresco.service.cmr.dictionary.Constraint) ListOfValuesConstraint(org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint) SelectItem(javax.faces.model.SelectItem) ArrayList(java.util.ArrayList) ListOfValuesConstraint(org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint)

Example 25 with QuickSort

use of org.alfresco.web.data.QuickSort in project acs-community-packaging by Alfresco.

the class BaseInviteUsersWizard method getEmailTemplates.

/**
 * @return Returns the list of email templates for user notification
 */
public List<SelectItem> getEmailTemplates() {
    List<SelectItem> wrappers = null;
    try {
        FacesContext fc = FacesContext.getCurrentInstance();
        NodeRef rootNodeRef = this.getNodeService().getRootNode(Repository.getStoreRef());
        NamespaceService resolver = Repository.getServiceRegistry(fc).getNamespaceService();
        List<NodeRef> results = this.getSearchService().selectNodes(rootNodeRef, getEmailTemplateXPath(), null, resolver, false);
        wrappers = new ArrayList<SelectItem>(results.size() + 1);
        if (results.size() != 0) {
            DictionaryService dd = Repository.getServiceRegistry(fc).getDictionaryService();
            for (NodeRef ref : results) {
                if (this.getNodeService().exists(ref) == true) {
                    Node childNode = new Node(ref);
                    if (dd.isSubClass(childNode.getType(), ContentModel.TYPE_CONTENT)) {
                        wrappers.add(new SelectItem(childNode.getId(), childNode.getName()));
                    }
                }
            }
            // make sure the list is sorted by the label
            QuickSort sorter = new QuickSort(wrappers, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
            sorter.sort();
        }
    } catch (AccessDeniedException accessErr) {
    // ignore the result if we cannot access the root
    }
    // add an entry (at the start) to instruct the user to select an item
    if (wrappers == null) {
        wrappers = new ArrayList<SelectItem>(1);
    }
    wrappers.add(0, new SelectItem("none", Application.getMessage(FacesContext.getCurrentInstance(), "select_a_template")));
    return wrappers;
}
Also used : FacesContext(javax.faces.context.FacesContext) NodeRef(org.alfresco.service.cmr.repository.NodeRef) DictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService) QuickSort(org.alfresco.web.data.QuickSort) AccessDeniedException(org.alfresco.repo.security.permissions.AccessDeniedException) NamespaceService(org.alfresco.service.namespace.NamespaceService) SortableSelectItem(org.alfresco.web.ui.common.SortableSelectItem) SelectItem(javax.faces.model.SelectItem) Node(org.alfresco.web.bean.repository.Node)

Aggregations

QuickSort (org.alfresco.web.data.QuickSort)30 SelectItem (javax.faces.model.SelectItem)22 FacesContext (javax.faces.context.FacesContext)11 Config (org.springframework.extensions.config.Config)9 ConfigElement (org.springframework.extensions.config.ConfigElement)9 ConfigService (org.springframework.extensions.config.ConfigService)9 NodeRef (org.alfresco.service.cmr.repository.NodeRef)8 Node (org.alfresco.web.bean.repository.Node)6 ArrayList (java.util.ArrayList)5 QName (org.alfresco.service.namespace.QName)5 TreeNode (org.alfresco.web.ui.repo.component.UITree.TreeNode)5 ResponseWriter (javax.faces.context.ResponseWriter)4 ServiceRegistry (org.alfresco.service.ServiceRegistry)4 DictionaryService (org.alfresco.service.cmr.dictionary.DictionaryService)4 TypeDefinition (org.alfresco.service.cmr.dictionary.TypeDefinition)4 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)4 IOException (java.io.IOException)3 UserTransaction (javax.transaction.UserTransaction)3 MimetypeService (org.alfresco.service.cmr.repository.MimetypeService)3 HashMap (java.util.HashMap)2