Package org.joget.directory.model

Examples of org.joget.directory.model.Department


        organizationDao.addOrganization(organization);
    }

    protected void addDepartment(String id) {
        LogUtil.info(getClass().getName(), "addDepartment");
        Department department = new Department();
        department.setId(id);
        department.setName(id);
        department.setDescription(id);
        departmentDao.addDepartment(department);
    }
View Full Code Here


    }

    public User getHodByDepartmentId(String departmentId) {
        try {
            if (departmentId != null) {
                Department department = departmentDao.getDepartment(departmentId);
                if (department != null && department.getHod() != null) {
                    Employment employment = department.getHod();
                    if (employment.getUser() != null) {
                        return getUserById(employment.getUserId());
                    }
                }
            }
View Full Code Here

    @Rollback(true)
    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);
        child.setParent(loadedDept);
        departmentDao.updateDepartment(child);
        Collection<Department> subDepartments = departmentDao.getDepartmentsByParentId(null, TEST_DEPARTMENT_PARENT, null, null, null, null);
        Assert.isTrue(((Department) subDepartments.iterator().next()).getId().equals(child.getId()));

        // assign dept HOD
        LogUtil.info(getClass().getName(), "testOrganizationChart: assign dept HOD");
        addEmployment(TEST_DEPARTMENT_PARENT_HOD, TEST_DEPARTMENT_PARENT, TEST_ORGANIZATION);
        employmentDao.assignUserAsDepartmentHOD(TEST_DEPARTMENT_PARENT_HOD, TEST_DEPARTMENT_PARENT);
View Full Code Here

        }
    }

    public Boolean deleteDepartment(String id) {
        try {
            Department department = getDepartment(id);
            if (department != null) {
                Set<Department> childs = department.getChildrens();
                Set<Employment> employments = department.getEmployments();

                if (childs != null) {
                    for (Department child : childs) {
                        delete("Department", child);
                    }
                }

                department.setHod(null);

                if (employments != null) {
                    for (Employment employment : employments) {
                        employmentDao.unassignUserReportTo(employment.getUserId());
                        employmentDao.unassignUserFromDepartment(employment.getUserId(), id);
View Full Code Here

        }
    }

    public Department getDepartmentByName(String name) {
        try {
            Department department = new Department();
            department.setName(name);
            List departments = findByExample("Department", department);

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

        return null;
    }

    public Department getParentDepartment(String id) {
        try {
            Department department = getDepartment(id);
            return department.getParent();
        } catch (Exception e) {
            LogUtil.error(DepartmentDaoImpl.class.getName(), e, "Get Parent Department Error!");
        }

        return null;
View Full Code Here

        return null;
    }

    public Department getParentDepartmentByName(String name) {
        try {
            Department department = getDepartmentByName(name);
            return department.getParent();
        } catch (Exception e) {
            LogUtil.error(DepartmentDaoImpl.class.getName(), e, "Get Parent Department By Name Error!");
        }

        return null;
View Full Code Here

       
        User requester = directoryManager.getUserByUsername(requesterUsername);
        if (requester != null && requester.getEmployments() != null && !requester.getEmployments().isEmpty()) {
            Employment employment = (Employment) requester.getEmployments().iterator().next();
            if (employment != null && employment.getDepartment() != null) {
                Department dept = employment.getDepartment();
                User hod = directoryManager.getDepartmentHod(dept.getId());
               
                if (hod != null) {
                    resultList.add(hod.getUsername());
                }
            }
View Full Code Here

    }

    @RequestMapping("/console/directory/dept/create")
    public String consoleDeptCreate(ModelMap model, @RequestParam("orgId") String orgId, @RequestParam(value = "parentId", required = false) String parentId) {
        model.addAttribute("organization", organizationDao.getOrganization(orgId));
        model.addAttribute("department", new Department());
        if (parentId != null && parentId.trim().length() > 0) {
            model.addAttribute("parent", departmentDao.getDepartment(parentId));
        }
        return "console/directory/deptCreate";
    }
View Full Code Here

        return "console/directory/deptCreate";
    }

    @RequestMapping("/console/directory/dept/view/(*:id)")
    public String consoleDeptView(ModelMap model, @RequestParam("id") String id) {
        Department department = directoryManager.getDepartmentById(id);
        model.addAttribute("department", department);

        User hod = directoryManager.getDepartmentHod(id);
        model.addAttribute("hod", hod);

        if (department != null && department.getOrganization() != null) {
            Collection<Grade> grades = directoryManager.getGradesByOrganizationId(null, department.getOrganization().getId(), "name", false, null, null);
            model.addAttribute("grades", grades);
        }

        model.addAttribute("isCustomDirectoryManager", DirectoryUtil.isCustomDirectoryManager());

View Full Code Here

TOP

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

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.