Package org.zeroexchange.model.resource.category

Examples of org.zeroexchange.model.resource.category.Category


    @Override
    public Collection<Property> getProperties(Category foreignCategory) {
        if(foreignCategory == null) {
            return Collections.emptySet();
        }
        Category category = categoryDAO.getById(foreignCategory.getId());
        List<Property> properties = new ArrayList<Property>();
        while(category != null) {
            properties.addAll(category.getProperties());
            category = category.getParent();
        }
        return properties;
    }
View Full Code Here


    /**
     * Persists the specified category.
     */
    private void persist(XResourceCategory sourceCategory, Category parent) {
       
        Category targetCategory = new Category();
       
        targetCategory.setLeafCategory(sourceCategory.getSubcategories().isEmpty());
        targetCategory.setParent(parent);
        targetCategory.setAlias(sourceCategory.getAlias() != null ? sourceCategory.getAlias() :
            parent != null ? parent.getAlias() : null);
        Collection<XProperty> sourceProperties = sourceCategory.getProperties();
        Collection<Property> targetProperties = targetCategory.getProperties();
        for(XProperty sourceProperty: sourceProperties) {
            Property targetProperty = new Property();
            targetProperty.setCategory(targetCategory);
            targetProperty.setName(sourceProperty.getName());
            PropertyType propertyType = (PropertyType) propertyTypeDAO.getById(sourceProperty.getPropertyType());
            if(propertyType == null) {
                throw new BusinessLogicException("Property type is unknown: '" + sourceProperty.getPropertyType() + "'");
            }
            targetProperty.setPropertyType(propertyType);
            targetProperty.setDictionary(sourceProperty.getDictonary());
           
            //Setup property titles
            PropertyStrings propertyStrings = new PropertyStrings();
            propertyStrings.setTarget(targetProperty);
            for(XLocalizedString title: sourceProperty.getTitles()) {
                LocalizationUtils.setValue(propertyStrings, title.getValue(), title.getLang());
            }
            targetProperty.setTitles(propertyStrings);
            targetProperty.setContainerType(0);
            targetProperties.add(targetProperty);
        }
       
        //Setup category titles
        CategoryStrings categoryStrings = new CategoryStrings();
        categoryStrings.setTarget(targetCategory);
        for(XLocalizedString title: sourceCategory.getTitles()){
            LocalizationUtils.setValue(categoryStrings, title.getValue(), title.getLang());
        }
        targetCategory.setTitles(categoryStrings);
       
        //Save the new category
        targetCategory = categoryDAO.save(targetCategory);
       
        //Iterate through the subcategories
View Full Code Here

        categorySelector.setWindowClosedCallback(new WindowClosedCallback() {
            private static final long serialVersionUID = 1L;

            @Override
            public void onClose(AjaxRequestTarget target) {
                Category category = (Category) getSession().getAttribute(SESSKEY_CATEGORY);
                setModelObject(category);
                target.add(categoryTitle);
               
                if(category != null) {
                    onCategorySelected(category, target);
View Full Code Here

    /**
     * Returns classes model.
     */
    protected TreeModel getClassesModel() {
        Category rootCategory = null;
        DataSet<Category> rootCategories = null;
        if(searchParameters == null || StringUtils.isBlank(searchParameters.getQuery())) {
            rootCategories = getCategories((Category)null);
            if(rootCategories.getTotalCount() <= 1) {
                rootCategory = rootCategories.iterator().next();
View Full Code Here

TOP

Related Classes of org.zeroexchange.model.resource.category.Category

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.