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

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


      throw new IllegalArgumentException(
          "保存PartyRole参数错误,Party和RoleType不能为空。");
   
    List<PartyRole> entities = new ArrayList<PartyRole>( types.size() );
    for( RoleType type:types ){
      entities.add( new PartyRole(party,type));
    }
   
    this.save( entities );
  }
View Full Code Here


   
    Set<RoleType> interalOrgSet = new HashSet<RoleType>( );
    CollectionUtils.addAll(interalOrgSet, RoleType.internalOrg());
   
    if( isInsert ){ //新增数据
      PartyRole fromRole = null ; //下级隶属关系
      List<PartyRole> partyRoles = new ArrayList<PartyRole>( newRoleTypes.size() );
      for( RoleType item:newRoleTypes ){
        PartyRole newRole = new PartyRole(party,item);
        partyRoles.add( newRole );
       
        if( interalOrgSet.contains( item ) )
          fromRole = newRole;
      }
      //partyRoleManager.save(party, newRoleTypes );
      partyRoleManager.save( partyRoles );
     
      if( party.getParent() == null || party.getParent().getId() == null )
        return;
     
      PartyRole toRole = null; //上级隶属关系
      List<PartyRole> toRoles = partyRoleManager.list( party.getParent() );
      for( PartyRole role:toRoles ){
        if( RoleType.PARENT_ORG.equals( role.getType() ) ){
          toRole = role;
          break;
        }
         
        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(
View Full Code Here

TOP

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

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.