Package net.stinfoservices.pacifiq.shared.dto

Examples of net.stinfoservices.pacifiq.shared.dto.ProgramDTO


    }

    @Override
    public ProgramDTO loadProgram(Long id) throws Exception {
        ServiceSecurityHelper.hasAuthority(ProfileHelper.ADMINISTRATOR, getSession());
        return new ProgramDTO(programDAO.find(id), DTOPath.PROGRAM_NAME);
    }
View Full Code Here


     */
    public List<ProgramDTO> refreshProgramSimpleList() throws Exception {
        List<Program> programs = programDAO.findAll();
        List<ProgramDTO> dtos = new ArrayList<ProgramDTO>();
        for (Program p : programs) {
            dtos.add(new ProgramDTO(p, DTOPath.PROGRAM_NAME));
        }
        return dtos;
    }
View Full Code Here

        }

        if (hasRights) {
            List<ProgramDTO> programs = new ArrayList<ProgramDTO>();
            for (Program program : programDAO.findAll()) {
                programs.add(new ProgramDTO(program, DTOPath.PROGRAM_BOARD));
            }
            return programs;
        }

        if (hasSpecificRights) {
            UzerDTO user = (UzerDTO) getSession().getAttribute("user");

            Set<ProgramDTO> specPrograms = new HashSet<ProgramDTO>();
            specPrograms.addAll(user.getProgramsWithConsultationRights());
            specPrograms.addAll(user.getProgramsWithEditionRights());

            List<Long> programsId = new ArrayList<Long>();
            for (ProgramDTO program : specPrograms) {
                programsId.add(program.getId());
            }

            List<ProgramDTO> programs = new ArrayList<ProgramDTO>();
            for (Program program : programDAO.findByIds(programsId)) {
                programs.add(new ProgramDTO(program, DTOPath.PROGRAM_BOARD));
            }
            return programs;
        }
        return null;
    }
View Full Code Here

    @Override
    public ProgramDTO findProgram(Long programId) throws Exception {
        boolean hasRights = false;
        boolean hasSpecificRights = false;
        ProgramDTO program = null;

        try {
            ServiceSecurityHelper.hasAuthority(ProfileHelper.PROGRAMS_CONSULTATION, getSession());
            hasRights = true;
        } catch (Exception aae1) {
            ServiceSecurityHelper.hasAuthority(ProfileHelper.SPECIFIC_PROGRAMS_CONSULTATION, getSession());
            hasSpecificRights = true;
        }
        if (hasRights) {
            Program programFound = programDAO.find(programId);

            if (programFound != null) {
                program = new ProgramDTO(programFound, DTOPath.PROGRAM_BOARD);
            }
        } else if (hasSpecificRights) {
            // Uzer has already somes PROGRAM_NAME lists
            UzerDTO user = (UzerDTO) getSession().getAttribute("user");

            if (user != null) {
                for (ProgramDTO dto : user.getProgramsWithConsultationRights()) {
                    if (dto.getId().equals(programId)) {

                        // convert from PROGRAM_NAME to PROGRAM_BOARD
                        Program programFound = programDAO.find(programId);
                        program = new ProgramDTO(programFound, DTOPath.PROGRAM_BOARD);

                        break;
                    }
                }
            }
View Full Code Here

            }
        }

        if (hasRights && !readOnly) {
            // no problem, you are a boss
            ProgramDTO programDTO = new ProgramDTO(programDAO.find(id), DTOPath.PROGRAM_DOC);
            if (isAdmin || (programDTO.getEcmManager() != null && programDTO.getEcmManager().getId() == user.getId())
                    || (programDTO.getProgramManager() != null && programDTO.getProgramManager().getId() == user.getId())) {
                programDTO.enableGC4LaunchButton();
            }
            return programDTO;
        } else if (hasRights && readOnly && readOnlySpecific) {
            // simple pure reader
            ProgramDTO programDTO = new ProgramDTO(programDAO.find(id), DTOPath.PROGRAM_DOC);
            programDTO.freeze();
            if (isAdmin || (programDTO.getEcmManager() != null && programDTO.getEcmManager().getId() == user.getId())
                    || (programDTO.getProgramManager() != null && programDTO.getProgramManager().getId() == user.getId())) {
                programDTO.enableGC4LaunchButton();
            }
            return programDTO;
        }

        if (hasSpecificRights || !readOnlySpecific) {

            Set<ProgramDTO> specProgramsConsultation = new HashSet<ProgramDTO>();
            Set<ProgramDTO> specProgramsEdition = new HashSet<ProgramDTO>();
            specProgramsConsultation.addAll(user.getProgramsWithConsultationRights());
            specProgramsEdition.addAll(user.getProgramsWithEditionRights());

            List<Long> programsIdConsultation = new ArrayList<Long>();
            List<Long> programsIdEdition = new ArrayList<Long>();
            for (ProgramDTO program : specProgramsConsultation) {
                programsIdConsultation.add(program.getId());
            }
            for (ProgramDTO program : specProgramsEdition) {
                programsIdEdition.add(program.getId());
            }

            if (programsIdEdition.contains(id)) {
                ProgramDTO programDTO = new ProgramDTO(programDAO.find(id), DTOPath.PROGRAM_DOC);
                if (isAdmin || (programDTO.getEcmManager() != null && programDTO.getEcmManager().getId() == user.getId())
                        || (programDTO.getProgramManager() != null && programDTO.getProgramManager().getId() == user.getId())) {
                    programDTO.enableGC4LaunchButton();
                }
                return programDTO;
            }
            if (specProgramsConsultation.contains(id)) {
                ProgramDTO programDTO = new ProgramDTO(programDAO.find(id), DTOPath.PROGRAM_DOC);
                programDTO.freeze();
                if (isAdmin || (programDTO.getEcmManager() != null && programDTO.getEcmManager().getId() == user.getId())
                        || (programDTO.getProgramManager() != null && programDTO.getProgramManager().getId() == user.getId())) {
                    programDTO.enableGC4LaunchButton();
                }
                return programDTO;
            }
        }
        return null;
View Full Code Here

    @Override
    public ProgramDTO loadDocumentProgramGc4Launch(Long programId) throws Exception {
        // Admin + program manager + ECM manager
        boolean isAdmin = false;
        ProgramDTO program = null;

        try {
            ServiceSecurityHelper.hasAuthority(ProfileHelper.ADMINISTRATOR, getSession());
            isAdmin = true;
        } catch (Exception aae1) {
            isAdmin = false;
        }
        if (isAdmin) {
            Program programFound = programDAO.find(programId);

            if (programFound != null) {
                program = new ProgramDTO(programFound, DTOPath.PROGRAM_GC_FOR_LAUNCH);
                // do enable Save button even if program is validated...
                program.doForceDisplayGC4LaunchSaveButton();
            }
        } else {
            // Uzer has already somes PROGRAM_NAME lists
            UzerDTO user = (UzerDTO) getSession().getAttribute("user");

            if (user != null) {
                for (ProgramDTO dto : user.getProgramsManaged()) {
                    if (dto.getId().equals(programId)) {
                        // convert from PROGRAM_NAME to PROGRAM_GC_FOR_LAUNCH
                        Program programFound = programDAO.find(programId);
                        program = new ProgramDTO(programFound, DTOPath.PROGRAM_GC_FOR_LAUNCH);
                        // do not enable Save button even if program is validated...
                        break;
                    }
                }
                for (ProgramDTO dto : user.getEcmManaged()) {
                    if (dto.getId().equals(programId)) {
                        // convert from PROGRAM_NAME to PROGRAM_GC_FOR_LAUNCH
                        Program programFound = programDAO.find(programId);
                        program = new ProgramDTO(programFound, DTOPath.PROGRAM_GC_FOR_LAUNCH);
                        // do enable Save button even if program is validated...
                        program.doForceDisplayGC4LaunchSaveButton();
                        break;
                    }
                }
            }
        }
View Full Code Here

            Program program = (document.getId() == null ? new Program() : programDAO.find(document.getId()));
            applyDiffProgram(program, document);
            Program programWithId = programDAO.save(program);
            UzerDTO user = (UzerDTO) getSession().getAttribute("user");
            alertManagement.alert(user);
            ProgramDTO programIdAndEnableGC4LaunchButton = new ProgramDTO();
            programIdAndEnableGC4LaunchButton.setId(programWithId.getId());

            if (isAdmin || (programWithId.getEcmManager() != null && programWithId.getEcmManager().getId() == user.getId())
                    || (programWithId.getProgramManager() != null && programWithId.getProgramManager().getId() == user.getId())) {
                programIdAndEnableGC4LaunchButton.enableGC4LaunchButton();
            }
            return programIdAndEnableGC4LaunchButton;
        }

        if (hasSpecificRights) {
            UzerDTO user = (UzerDTO) getSession().getAttribute("user");

            Set<ProgramDTO> specPrograms = new HashSet<ProgramDTO>();
            specPrograms.addAll(user.getProgramsWithConsultationRights());
            specPrograms.addAll(user.getProgramsWithEditionRights());

            List<Long> programsId = new ArrayList<Long>();
            for (ProgramDTO program : specPrograms) {
                programsId.add(program.getId());
            }

            if (programsId.contains(document.getId())) {
                Program program = programDAO.find(document.getId());
                applyDiffProgram(program, document);
                Program programWithId = programDAO.save(program);
                // programDAO.getSessionFactory().getCurrentSession().flush();
                alertManagement.alert(user);
                ProgramDTO programIdAndEnableGC4LaunchButton = new ProgramDTO();
                programIdAndEnableGC4LaunchButton.setId(programWithId.getId());
                if (isAdmin || (programWithId.getEcmManager() != null && programWithId.getEcmManager().getId() == user.getId())
                        || (programWithId.getProgramManager() != null && programWithId.getProgramManager().getId() == user.getId())) {
                    programIdAndEnableGC4LaunchButton.enableGC4LaunchButton();
                }
                return programIdAndEnableGC4LaunchButton;
            }
        }
        return null;
View Full Code Here

     */
    public ConsumptionDTO(Consumption consumption, DTOPath path) {
        setId(consumption.getId());
        setCategory(consumption.getCategory());
        // setItem is done using cross-reference in ProgramDTO for DTOPath.PROGRAM_GC_FOR_LAUNCH
        setProgram(new ProgramDTO(consumption.getProgram(), DTOPath.PROGRAM_NAME));
        setQuantity(consumption.getQuantity());
    }
View Full Code Here

        if (path.accept(DTOPath.UZER_WITH_PROGRAMS)) {
            password = owner.getPassword();

            final ArrayList<ProgramDTO> programsWithConsultRightsSet = new ArrayList<ProgramDTO>();
            for (Program program : owner.getProgramsWithConsultationRights()) {
                programsWithConsultRightsSet.add(new ProgramDTO(program, path));
            }
            programsWithConsultationRights = programsWithConsultRightsSet;

            final ArrayList<ProgramDTO> programsWithEditRightsSet = new ArrayList<ProgramDTO>();
            for (Program program : owner.getProgramsWithEditionRights()) {
                programsWithEditRightsSet.add(new ProgramDTO(program, path));
            }
            programsWithEditionRights = programsWithEditRightsSet;

            final ArrayList<ProgramDTO> ecmManageds = new ArrayList<ProgramDTO>();
            for (Program program : owner.getEcmManaged()) {
                ecmManageds.add(new ProgramDTO(program, path));
            }
            ecmManaged = ecmManageds;

            final ArrayList<ProgramDTO> processesManageds = new ArrayList<ProgramDTO>();
            for (Program program : owner.getProcessesManaged()) {
                processesManageds.add(new ProgramDTO(program, path));
            }

            processesManaged = processesManageds;
            // Set to List
            Collections.sort(processesManageds, new ProgramComparator());

            final ArrayList<ProgramDTO> programsManageds = new ArrayList<ProgramDTO>();
            for (Program program : owner.getProgramsManaged()) {
                programsManageds.add(new ProgramDTO(program, path));
            }
            programsManaged = programsManageds;
            // Set to List
            Collections.sort(programsManaged, new ProgramComparator());
View Full Code Here

    @Test
    public void testClone() throws Exception {
        Program prog = programDAO.find(1L);
        assertNotNull(prog);

        ProgramDTO dto = new ProgramDTO(prog, DTOPath.PROGRAM_DOC);
        ProgramDTO dtoClone = dto.clone();
        assertEquals(dtoClone.getName(), dto.getName());
    }
View Full Code Here

TOP

Related Classes of net.stinfoservices.pacifiq.shared.dto.ProgramDTO

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.