Package com.sparc.knappsack.components.entities

Examples of com.sparc.knappsack.components.entities.Category


    @PreAuthorize("hasAccessToCategory(#id, #userAgentInfo.applicationType) or hasRole('ROLE_ADMIN')")
    @RequestMapping(value = "/categories/{id}", method = RequestMethod.GET)
    public String displayApplicationsForCategory(@PathVariable Long id, Model model, UserAgentInfo userAgentInfo) {
        checkRequiredEntity(categoryService, id);

        Category category = categoryService.get(id);

        model.addAttribute("selectedCategory", categoryService.createCategoryModel(category, true));

        User user = userService.getUserFromSecurityContext();
        List<ApplicationModel> applicationModels = userService.getApplicationModelsForUser(user, userAgentInfo.getApplicationType(), category.getId());
        model.addAttribute("applications", applicationModels);

        return "category_resultsTH";
    }
View Full Code Here


    @PreAuthorize("isOrganizationAdmin(#orgId) or hasRole('ROLE_ADMIN')")
    @RequestMapping(value = "/manager/deleteCategory/{id}/{orgId}", method = RequestMethod.GET)
    public String deleteCategory(@PathVariable Long id, @PathVariable Long orgId) {
        checkRequiredEntity(categoryService, id);

        Category category = categoryService.get(id);
        Long organizationId = category.getOrganization().getId();
        if (!orgId.equals(organizationId)) {
            throw new RuntimeException("Attempted to delete category for organization with different Id");
        }

        categoryService.delete(id);
View Full Code Here

            log.info(String.format("Attempted to delete an icon for a non-existent category: %s", id));
            result.setResult(false);
            return result;
        }

        Category category = categoryService.get(id);
        Long organizationId = category.getOrganization().getId();
        if (!orgId.equals(organizationId)) {
            log.error("Attempted to delete category icon for organization with different Id");
            result.setResult(false);
        } else {
            categoryService.deleteIcon(id);

            category = categoryService.get(id);

            if (category != null && category.getIcon() == null) {
                result.setResult(true);
            } else {
                result.setResult(true);
            }
        }
View Full Code Here

    @PreAuthorize("isOrganizationAdmin(#orgId) or hasRole('ROLE_ADMIN')")
    @RequestMapping(value = "/manager/editCategory/{id}/{orgId}", method = RequestMethod.GET)
    public String editCategory(Model model, @PathVariable Long id, @PathVariable Long orgId) {
        checkRequiredEntity(categoryService, id);

        Category category = categoryService.get(id);
        Long organizationId = category.getOrganization().getId();
        if (!orgId.equals(organizationId)) {
            throw new RuntimeException("Attempted to edit category for organization with different Id");
        }

        if (!model.containsAttribute("category")) {

            if (category != null) {
                CategoryForm categoryForm = new CategoryForm();
                categoryForm.setDescription(category.getDescription());
                categoryForm.setId(category.getId());
                categoryForm.setName(category.getName());
                categoryForm.setStorageConfigurationId(category.getStorageConfiguration().getId());

                AppFile icon = category.getIcon();
                if (icon != null) {
                    MockMultipartFile iconMultipartFile = new MockMultipartFile(category.getIcon().getName(), category.getIcon().getName(), category.getIcon().getType(), new byte[0]);
                    categoryForm.setIcon(iconMultipartFile);
                }

                model.addAttribute("category", categoryForm);
            }
        }

        model.addAttribute("isEdit", true);

        if(category != null) {
            model.addAttribute("parentOrgId", category.getOrganization().getId());
            model.addAttribute("parentOrgName", category.getOrganization().getName());
            model.addAttribute("orgStorageConfigId", category.getOrganization().getOrgStorageConfig().getId());
            model.addAttribute("storageConfigurations", category.getOrganization().getOrgStorageConfig().getStorageConfigurations());
        }

        return "manager/manageCategoryTH";
    }
View Full Code Here

        return categoryDao.getAll();
    }

    @Override
    public Category get(Long id) {
        Category category = null;
        if (id != null && id > 0) {
            category = categoryDao.get(id);
        }

        return category;
View Full Code Here

    }

    @Override
    public Category updateCategory(CategoryForm categoryForm) {

        Category savedCategory = get(categoryForm.getId());
        mapCategoryFields(categoryForm, savedCategory);
//        update(savedCategory);

        return savedCategory;
    }
View Full Code Here

        return savedCategory;
    }

    @Override
    public Category saveCategory(CategoryForm categoryForm) {
        Category savedCategory = new Category();
        mapCategoryFields(categoryForm, savedCategory);
//        add(savedCategory);

        return savedCategory;
    }
View Full Code Here

        Long orgStorageConfigId = organization.getOrgStorageConfig().getId();

        /**
         * Create entertainment category
         */
        Category entertainmentCategory = new Category();
        entertainmentCategory.setName("Entertainment");
        entertainmentCategory.setDescription("Applications featuring a bit of levity.");
        entertainmentCategory.setStorageConfiguration(storageConfiguration);
        entertainmentCategory.setOrganization(organization);
        organization.getCategories().add(entertainmentCategory);
        add(entertainmentCategory);

        AppFile icon = createIcon(entertainmentIcon, orgStorageConfigId, storageConfigId, entertainmentCategory.getUuid());
        if (icon != null) {
            icon.setStorable(entertainmentCategory);
            entertainmentCategory.setIcon(icon);
        }
        defaultCategories.add(entertainmentCategory);

        /**
         * Create productivity category
         */
        Category productivityCategory = new Category();
        productivityCategory.setName("Productivity");
        productivityCategory.setDescription("Applications to make your day to day more efficient.");
        productivityCategory.setStorageConfiguration(storageConfiguration);
        productivityCategory.setOrganization(organization);
        organization.getCategories().add(productivityCategory);
        add(productivityCategory);

        icon = createIcon(productivityIcon, orgStorageConfigId, storageConfigId, productivityCategory.getUuid());
        if (icon != null) {
            icon.setStorable(productivityCategory);
            productivityCategory.setIcon(icon);
        }
        defaultCategories.add(productivityCategory);

        /**
         * Create utilities category
         */
        Category utilitiesCategory = new Category();
        utilitiesCategory.setName("Utilities");
        utilitiesCategory.setDescription("Applications with a specific skill set.");
        utilitiesCategory.setStorageConfiguration(storageConfiguration);
        utilitiesCategory.setOrganization(organization);
        organization.getCategories().add(utilitiesCategory);
        add(utilitiesCategory);

        icon = createIcon(utilitiesIcon, orgStorageConfigId, storageConfigId, utilitiesCategory.getUuid());
        if (icon != null) {
            icon.setStorable(utilitiesCategory);
            utilitiesCategory.setIcon(icon);
        }
        defaultCategories.add(utilitiesCategory);

        return defaultCategories;
    }
View Full Code Here

TOP

Related Classes of com.sparc.knappsack.components.entities.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.