Package com.mossle.party.domain

Examples of com.mossle.party.domain.PartyEntity


    public static final int TYPE_USER = 1;
    public static final int TYPE_POSITION = 2;
    private PartyEntityManager partyEntityManager;

    public int getJobLevelByUserId(String userId) {
        PartyEntity partyEntity = partyEntityManager.findUnique(
                "from PartyEntity where partyType.type=? and ref=?", TYPE_USER,
                userId);

        for (PartyStruct partyStruct : partyEntity.getParentStructs()) {
            if (partyStruct.getParentEntity().getPartyType().getType() == TYPE_POSITION) {
                return partyStruct.getParentEntity().getLevel();
            }
        }
View Full Code Here


    }

    public int getJobLevelByInitiatorAndPosition(String userId,
            String positionName) {
        String hql = "from PartyEntity where partyType.type=? and name=?";
        PartyEntity partyEntity = partyEntityManager.findUnique(hql,
                TYPE_POSITION, positionName);

        return partyEntity.getLevel();
    }
View Full Code Here

    }

    public String getSuperiorId(String userId) {
        logger.debug("user id : {}", userId);

        PartyEntity partyEntity = partyEntityManager.findUnique(
                "from PartyEntity where partyType.type=? and ref=?", TYPE_USER,
                userId);
        logger.debug("party entity : {}, {}", partyEntity.getId(),
                partyEntity.getName());

        PartyEntity superior = this.findSuperior(partyEntity);

        if (superior == null) {
            return null;
        }

        return superior.getRef();
    }
View Full Code Here

        return superior.getRef();
    }

    public List<String> getPositionUserIds(String userId, String positionName) {
        PartyEntity partyEntity = partyEntityManager.findUnique(
                "from PartyEntity where partyType.type=? and ref=?", TYPE_USER,
                userId);

        return this.findPositionUserIds(partyEntity, positionName);
    }
View Full Code Here

        return this.findPositionUserIds(partyEntity, positionName);
    }

    public List<OrgDTO> getOrgsByUserId(String userId) {
        PartyEntity partyEntity = partyEntityManager.findUnique(
                "from PartyEntity where partyType.type=? and ref=?", TYPE_USER,
                userId);

        if (partyEntity == null) {
            return Collections.emptyList();
        }

        List<OrgDTO> orgDtos = new ArrayList<OrgDTO>();

        for (PartyStruct partyStruct : partyEntity.getParentStructs()) {
            PartyEntity parent = partyStruct.getParentEntity();

            if (parent.getPartyType().getType() == TYPE_ORG) {
                OrgDTO orgDto = new OrgDTO();
                orgDto.setId(Long.toString(parent.getId()));
                orgDto.setName(parent.getName());
                orgDto.setTypeName(parent.getPartyType().getName());
                orgDto.setType(parent.getPartyType().getType());
                orgDto.setRef(parent.getRef());
                orgDtos.add(orgDto);
            }
        }

        return orgDtos;
View Full Code Here

        return orgDtos;
    }

    // ~ ==================================================
    public PartyEntity findSuperior(PartyEntity child) {
        PartyEntity partyEntity = this.findUpperDepartment(child);

        while (partyEntity != null) {
            logger.debug("partyEntity : {}, {}", partyEntity.getId(),
                    partyEntity.getName());

            for (PartyStruct partyStruct : partyEntity.getChildStructs()) {
                PartyEntity childPartyEntity = partyStruct.getChildEntity();
                logger.debug("child : {}, {}", childPartyEntity.getId(),
                        childPartyEntity.getName());

                PartyEntity superior = null;

                if (childPartyEntity.getPartyType().getType() == TYPE_POSITION) {
                    superior = this.findAdministrator(childPartyEntity);
                } else if ((childPartyEntity.getPartyType().getType() == TYPE_USER)
                        && (partyStruct.getAdmin() == 1)) {
View Full Code Here

        return null;
    }

    public PartyEntity findAdministrator(PartyEntity parent) {
        for (PartyStruct partyStruct : parent.getChildStructs()) {
            PartyEntity partyEntity = null;
            PartyEntity child = partyStruct.getChildEntity();
            logger.debug("child : {}, {}", child.getId(), child.getName());

            if (child.getPartyType().getType() == TYPE_POSITION) {
                partyEntity = this.findAdministrator(parent);
            } else if ((child.getPartyType().getType() == TYPE_USER)
                    && (partyStruct.getAdmin() == 1)) {
                partyEntity = child;
            }

            if (partyEntity != null) {
View Full Code Here

    }

    public List<String> findPositionUserIds(PartyEntity parent,
            String positionName) {
        List<String> userIds = new ArrayList<String>();
        PartyEntity partyEntity = this.findUpperDepartment(parent);

        while (partyEntity != null) {
            if (partyEntity.getPartyType().getType() == TYPE_ORG) {
                for (PartyStruct partyStruct : partyEntity.getChildStructs()) {
                    PartyEntity child = partyStruct.getChildEntity();

                    if ((child.getPartyType().getType() == TYPE_POSITION)
                            && child.getName().equals(positionName)) {
                        for (PartyStruct ps : child.getChildStructs()) {
                            userIds.add(ps.getChildEntity().getRef());
                        }
                    }
                }
            } else if ((parent.getPartyType().getType() == TYPE_POSITION)
                    && parent.getName().equals(positionName)) {
                for (PartyStruct partyStruct : parent.getChildStructs()) {
                    PartyEntity child = partyStruct.getChildEntity();

                    if (child.getPartyType().getType() == TYPE_USER) {
                        userIds.add(child.getRef());
                    }
                }
            }

            if (userIds.isEmpty()) {
View Full Code Here

    @RequestMapping("admin-batch-save")
    public String save(@RequestParam("id") Long id,
            @RequestParam("userIds") List<Long> userIds,
            RedirectAttributes redirectAttributes) {
        PartyEntity group = partyEntityManager.findUnique(
                "from PartyEntity where partyType.id=2 and reference=?",
                Long.toString(id));

        for (Long userId : userIds) {
            PartyEntity user = partyEntityManager.findUnique(
                    "from PartyEntity where partyType.id=1 and reference=?",
                    Long.toString(userId));

            PartyStruct partyStruct = partyStructManager
                    .findUnique(
View Full Code Here

    @RequestMapping("admin-batch-remove")
    public String remove(@RequestParam("id") Long id,
            @RequestParam("selectedItem") List<Long> selectedItem,
            RedirectAttributes redirectAttributes) {
        PartyEntity group = partyEntityManager.findUnique(
                "from PartyEntity where partyType.id=2 and reference=?",
                Long.toString(id));

        for (Long userId : selectedItem) {
            PartyEntity user = partyEntityManager.findUnique(
                    "from PartyEntity where partyType.id=1 and reference=?",
                    Long.toString(userId));

            PartyStruct partyStruct = partyStructManager
                    .findUnique(
View Full Code Here

TOP

Related Classes of com.mossle.party.domain.PartyEntity

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.