Package org.joget.directory.model

Examples of org.joget.directory.model.Organization


    }

    public Boolean assignUserToOrganization(String userId, String organizationId) {
        try {
            User user = userDao.getUserById(userId);
            Organization organization = organizationDao.getOrganization(organizationId);

            //get only 1st employment
            if (user != null && user.getEmployments() != null && user.getEmployments().size() > 0 && organization != null) {
                Employment employment = (Employment) user.getEmployments().iterator().next();
                if (!organization.getId().equals(employment.getOrganizationId())) {
                    if (employment.getHods() != null && !employment.getHods().isEmpty() && employment.getDepartment() != null) {
                        Department orgDepartment = employment.getDepartment();
                        orgDepartment.setHod(null);
                        departmentDao.updateDepartment(orgDepartment);
                    }
                   
                    employment.setOrganizationId(organization.getId());
                    employment.setDepartmentId(null);
                    employment.setGradeId(null);
                    employment.getHods().clear();
                    saveOrUpdate("Employment", employment);
                }
View Full Code Here


    }

    public Boolean unassignUserFromOrganization(String userId, String organizationId) {
        try {
            User user = userDao.getUserById(userId);
            Organization organization = organizationDao.getOrganization(organizationId);

            //get only 1st employment
            if (user != null && user.getEmployments() != null && user.getEmployments().size() > 0 && organization != null) {
                Employment employment = (Employment) user.getEmployments().iterator().next();
                if (organization.getId().equals(employment.getOrganizationId())) {
                    if (employment.getHods() != null && !employment.getHods().isEmpty() && employment.getDepartment() != null) {
                        Department orgDepartment = employment.getDepartment();
                        orgDepartment.setHod(null);
                        departmentDao.updateDepartment(orgDepartment);
                    }
View Full Code Here

    public void testOrganizationChart() {
       
        // assign parent department to organization
        LogUtil.info(getClass().getName(), "testOrganizationChart: assign parent department to organization");
        Department dept = directoryManager.getDepartmentById(TEST_DEPARTMENT_PARENT);
        Organization organization = organizationDao.getOrganization(TEST_ORGANIZATION);
        dept.setOrganization(organization);
        departmentDao.updateDepartment(dept);
        Department loadedDept = directoryManager.getDepartmentById(dept.getId());
        Assert.isTrue(loadedDept.getOrganization().getId().equals(organization.getId()));

        // assign sub-department to parent and organization
        LogUtil.info(getClass().getName(), "testOrganizationChart: assign sub-department to parent and organization");
        Department child = directoryManager.getDepartmentById(TEST_DEPARTMENT_CHILD);
        child.setOrganization(organization);
View Full Code Here

        Assert.isTrue(testDept == null);
       
        // delete organization
        LogUtil.info(getClass().getName(), "testDeletion: delete organization");
        organizationDao.deleteOrganization(TEST_ORGANIZATION);
        Organization testOrg = organizationDao.getOrganization(TEST_ORGANIZATION);
        Assert.isTrue(testOrg == null);
    }
View Full Code Here

        Assert.isTrue(testOrg == null);
    }
   
    protected void addOrganization(String id) {
        LogUtil.info(getClass().getName(), "addOrganization");
        Organization organization = new Organization();
        organization.setId(id);
        organization.setName(id);
        organization.setDescription(id);
        organizationDao.addOrganization(organization);
    }
View Full Code Here

        }
    }

    public Boolean deleteOrganization(String id) {
        try {
            Organization organization = getOrganization(id);
            if (organization != null) {
                Set<Department> departments = organization.getDepartments();
                Set<Grade> grades = organization.getGrades();
                Set<Group> groups = organization.getGroups();
                Set<Employment> employments = organization.getEmployments();
               
                if (employments != null) {
                    for (Employment employment : employments) {
                        getEmploymentDao().unassignUserFromOrganization(employment.getUserId(), id);
                    }
                    employments.clear();
                }
               
                if (groups != null) {
                    organization.getGroups().removeAll(groups);
                }

                if (departments != null) {
                    for (Department department : departments) {
                        getDepartmentDao().deleteDepartment(department.getId());
View Full Code Here

        }
    }

    public Organization getOrganizationByName(String name) {
        try {
            Organization organization = new Organization();
            organization.setName(name);
            List organizations = findByExample("Organization", organization);

            if (organizations.size() > 0) {
                return (Organization) organizations.get(0);
            }
View Full Code Here

        return "console/directory/orgList";
    }

    @RequestMapping("/console/directory/org/create")
    public String consoleOrgCreate(ModelMap model) {
        model.addAttribute("organization", new Organization());
        return "console/directory/orgCreate";
    }
View Full Code Here

                    errors.add("console.directory.org.error.label.idExists");
                } else {
                    invalid = !organizationDao.addOrganization(organization);
                }
            } else {
                Organization o = organizationDao.getOrganization(organization.getId());
                o.setName(organization.getName());
                o.setDescription(organization.getDescription());
                invalid = !organizationDao.updateOrganization(o);
            }

            if (!errors.isEmpty()) {
                model.addAttribute("errors", errors);
View Full Code Here

        return "console/directory/deptEdit";
    }

    @RequestMapping(value = "/console/directory/dept/submit/(*:action)", method = RequestMethod.POST)
    public String consoleDeptSubmit(ModelMap model, @RequestParam("action") String action, @RequestParam("orgId") String orgId, @RequestParam(value = "parentId", required = false) String parentId, @ModelAttribute("department") Department department, BindingResult result) {
        Organization organization = organizationDao.getOrganization(orgId);
        Department parent = null;
        if (parentId != null && parentId.trim().length() > 0) {
            parent = departmentDao.getDepartment(parentId);
        }

        // validate ID
        validator.validate(department, result);

        boolean invalid = result.hasErrors();
        if (!invalid) {
            // check error
            Collection<String> errors = new ArrayList<String>();

            if ("create".equals(action)) {
                // check id exist
                if (departmentDao.getDepartment(department.getId()) != null) {
                    errors.add("console.directory.department.error.label.idExists");
                } else {
                    department.setOrganization(organization);
                    if (parent != null) {
                        department.setParent(parent);
                    }
                    invalid = !departmentDao.addDepartment(department);
                }
            } else {
                Department d = departmentDao.getDepartment(department.getId());
                d.setName(department.getName());
                d.setDescription(department.getDescription());
                invalid = !departmentDao.updateDepartment(d);
            }

            if (!errors.isEmpty()) {
                model.addAttribute("errors", errors);
                invalid = true;
            }
        }

        if (invalid) {
            model.addAttribute("organization", organization);
            model.addAttribute("department", department);
            if (parent != null) {
                model.addAttribute("parent", parent);
            }
            if ("create".equals(action)) {
                return "console/directory/deptCreate";
            } else {
                return "console/directory/deptEdit";
            }
        } else {
            String id = organization.getId();
            String contextPath = WorkflowUtil.getHttpServletRequest().getContextPath();
            String url = contextPath;
            if ("create".equals(action)) {
                if (parent != null) {
                    url += "/web/console/directory/dept/view/" + parent.getId();
View Full Code Here

TOP

Related Classes of org.joget.directory.model.Organization

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.