Package com.google.code.lightssh.project.party.entity

Examples of com.google.code.lightssh.project.party.entity.PartyRelationship


    aboutRollups[internalOrgs.length] = RoleType.INTERNAL_ORG;
    aboutRollups[internalOrgs.length+1] = RoleType.PARENT_ORG;
    List<PartyRole> partyRoles = partyRoleManager.list(party,aboutRollups);
   
    //TODO partyRelationshipManager.removeByFromRole(partyRole);
    PartyRelationship pr = partyRelationshipManager.getRollupByFromParty( party );
    if( pr != null )
      partyRelationshipManager.remove( pr );
   
    //顺序问题
    for( PartyRole partyRole:partyRoles ){
View Full Code Here


        if( interalOrgSet.contains( role.getType() ) )
          toRole = role;
      }
     
      if( fromRole != null && toRole != null ){
        PartyRelationship pr = new PartyRelationship(
            RelationshipType.ORG_ROLLUP,fromRole,toRole );
        partyRelationshipManager.save( pr );
      }
    }else{ //修改数据
      RoleType type = types[0];
      for( RoleType item:types ){
        if( !RoleType.PARENT_ORG.equals(item))
          type = item;
      }
       
      PartyRole newFromRole = null;
      List<PartyRole> savedPartyRoles = partyRoleManager.list(
              party, RoleType.internalOrg() );
      if( savedPartyRoles != null && !savedPartyRoles.isEmpty()){
        //savedPartyRoles.size()>1 数据有问题
        newFromRole = savedPartyRoles.get(0);
        savedPartyRoles.get(0).setType( type );
      }else{
        //用于数据容错,正常情况不会执行
        newFromRole = new PartyRole(party,type);
        savedPartyRoles.add( newFromRole );
      }
      partyRoleManager.save(savedPartyRoles);
     
      if( party.getParent() != null ){
        PartyRole newToRole = null;
        RoleType[] allowedSelectTypes = RoleType.internalOrg();
        RoleType[] paramRoleTypes = new RoleType[allowedSelectTypes.length+1];
        paramRoleTypes[allowedSelectTypes.length] = RoleType.PARENT_ORG;
        System.arraycopy( allowedSelectTypes,0, paramRoleTypes, 0,allowedSelectTypes.length);
        List<PartyRole> newToRoles = partyRoleManager.list(
                party.getParent(), paramRoleTypes );
        if( newToRoles != null && !newToRoles.isEmpty() ){
          newToRole = newToRoles.get(0);
          for( PartyRole role:newToRoles )
            if( RoleType.PARENT_ORG.equals(role.getType()) )
              newToRole = role;
        }else{
          throw new ApplicationException("("+ party.getParent().getName()+")缺失["
              +RoleType.internalOrg()+"]中的一种角色!");
        }
        PartyRelationship pr = partyRelationshipManager.getRollupByFromParty( party );
        if( pr != null ){
          pr.setTo( newToRole );
          //pr.setFrom(newFromRole);
        }else{
          pr = new PartyRelationship(RelationshipType.ORG_ROLLUP
              ,newFromRole,newToRole );
        }
        partyRelationshipManager.save( pr );
      }
    }
View Full Code Here

  @Override
  public Organization getOrganizationWithParent(Party party) {
    Organization org = this.getOrganization(party);
    if( org != null ){
      PartyRelationship relationship = partyRelationshipManager
        .getRollupByFromParty(org);
      if( relationship != null && relationship.getTo() != null
          && relationship.getTo() != null ){

        Organization parent = this.getOrganization(relationship.getTo().getParty() );
        //&& relationship.getTo().getParty() instanceof Organization
        org.setParent( parent );
      }
    }
   
View Full Code Here

TOP

Related Classes of com.google.code.lightssh.project.party.entity.PartyRelationship

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.