package org.ellectra.gui.managebeans;

import java.util.ArrayList;

import java.util.Collections;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.component.UIData;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;
import javax.faces.validator.ValidatorException;
import javax.xml.ws.WebServiceRef;
import org.ellectra.gui.utils.JSFUtils;
import org.ellectra.wsassignepows.UpdateAssignedPOsService;
import org.ellectra.wsmanageassignpo.ManageAssignedPOsService;
import org.ellectra.wsmu.ManageUserService;
import org.ellectra.wsmu.UserAccountType;
import org.ellectra.wsvassignpo.PoType;
import org.ellectra.wsvassignpo.ViewAssignedPOsService;

public class associateuserswithtender {

    @WebServiceRef(wsdlLocation = "http://localhost:18181/UpdateAssignedPOsService/UpdateAssignedPOsPort?wsdl")
    private UpdateAssignedPOsService service_3;
    @WebServiceRef(wsdlLocation = "http://localhost:18181/ManageAssignedPOsService/ManageAssignedPOsPort?wsdl")
    private ManageAssignedPOsService service_2;
    @WebServiceRef(wsdlLocation = "http://localhost:18181/ManageUserService/ManageUserPort?wsdl")
    private ManageUserService service_1;
    @WebServiceRef(wsdlLocation = "http://localhost:18181/ViewAssignedPOsService/ViewAssignedPOsPort?wsdl")
    private ViewAssignedPOsService service;
    
    String a_au1;
    String a_au2 = "0";
    Integer a_au3;
    private String buttonAddDisabled = "true";
    List<UserAccountType> dUsersGlobal;
    
    private UIData allusersdata = null;
    private ArrayList<associatepeoplelistview> allusersusers = new ArrayList();
    private UIData adata = null;
    private UIData edata = null;
    private UIData odata = null;
    ArrayList<associatepeoplelist> ausers = new ArrayList();
    ArrayList<associatepeoplelist> eusers = new ArrayList();
    ArrayList<associatepeoplelist> ousers = new ArrayList();
    
    ArrayList<bpeluserlist> blist = new ArrayList();
    private List userslistbox = Collections.EMPTY_LIST;
    private UIInput userslistboxlist;
    
    String dUserloginname;
    String dUserloginsignature;
    String dUserloginOrganization;
    String dUserloginrole;
    int dUserloginid;
    int mytenderid;
    int mycalloftender;
    int idone = 0;
    
    private static final String PO_ADMIN = "PROCUREMENT_OFFICER_ADMINISTRATIVE";
    private static final String PO_OPEN = "PROCUREMENT_OFFICER_OPENING";
    private static final String PO_EVAL = "PROCUREMENT_OFFICER_EVALUATING";
    
    
    private void reset() {
        ausers.clear();
        eusers.clear();
        ousers.clear();
        blist.clear();
        userslistbox = Collections.EMPTY_LIST;
        
        a_au2 = "0";
        buttonAddDisabled = "true";
        idone=0;
    }
    

    public void GetSessionVariables() {

        dUserloginname = (String) JSFUtils.retrieveOnSession(FacesContext.getCurrentInstance(), "LOGINUSER");
        dUserloginsignature = (String) JSFUtils.retrieveOnSession(FacesContext.getCurrentInstance(), "LOGINSIGNATURE");
        dUserloginOrganization = (String) JSFUtils.retrieveOnSession(FacesContext.getCurrentInstance(), "LOGINORGANIZATION");
        dUserloginrole = (String) JSFUtils.retrieveOnSession(FacesContext.getCurrentInstance(), "LOGINROLE");
        String szTemp = (String) JSFUtils.retrieveOnSession(FacesContext.getCurrentInstance(), "LOGINUSERID");
        dUserloginid = Integer.valueOf(szTemp).intValue();
        szTemp = (String) JSFUtils.retrieveOnSession(FacesContext.getCurrentInstance(), "TENDERIDI");
        mytenderid = Integer.valueOf(szTemp).intValue();
        szTemp = (String) JSFUtils.retrieveOnSession(FacesContext.getCurrentInstance(), "CALLTENDERID");
        mycalloftender = Integer.valueOf(szTemp).intValue();

    }
 
    
    /**
     * 
     * @param sourceObj is of associatepeoplelistview type
     * @param targetObj is of associatepeoplelist type
     * @return
     */
    private boolean compare(Object sourceObj, Object targetObj, int comparison) {
        int userId1 = 0;
        int userId2 = 0;
        String role1 = "";
        String role2 = "";
        
        if (comparison == 0) {
            userId1 = ((associatepeoplelistview)sourceObj).getIuserid();
            role1 = ((associatepeoplelistview)sourceObj).getRole();
            userId2 = ((associatepeoplelist)targetObj).getIuserid();
            role2 = ((associatepeoplelist)targetObj).getRole();
        }
        else if (comparison == 1) {
            userId1 = ((associatepeoplelist)sourceObj).getIuserid();
            role1 = ((associatepeoplelist)sourceObj).getRole();
            userId2 = ((associatepeoplelistview)targetObj).getIuserid();
            role2 = ((associatepeoplelistview)targetObj).getRole();
        }
        return ((userId1 == userId2) && (role1.trim().equals(role2.trim()))); 
    }
    
    /**
     * search for the given object in a target list
     * @param sourceObj
     * @param targetList
     * @return
     */
    private boolean foundInTargetList(Object sourceObj, ArrayList targetList) {
        boolean result = false;
        if (!targetList.isEmpty()) {
            int comparison = 0;
            if (targetList.get(0) instanceof associatepeoplelistview)
                comparison = 1;

            for (int j = 0; j < targetList.size(); j++) {
                Object targetObj = targetList.get(j);
                boolean found = compare(sourceObj, targetObj, comparison);
                if (found) {
                    result = true;
                    break;
                }
            }
        }
        return result;
    }
    
    /**
     * if the PO is in local list but not in DB, THEN create it
     * @param sessionList, the local list
     */
    private void handleCreation (ArrayList<associatepeoplelist> sessionList) {
        for (int i = 0; i < sessionList.size(); i++) {
          associatepeoplelist sourceObj = sessionList.get(i);
          
          if (!foundInTargetList(sourceObj, allusersusers)) {
              bpeluserlist bpelitem = new bpeluserlist();
              
              bpelitem.setUserID(sourceObj.getIuserid());
              String sourceObjRole = sourceObj.getRole();
              if (sourceObjRole.equals("Administrating"))
                  bpelitem.setRole(PO_ADMIN);
              else if (sourceObjRole.equals("Opening"))
                  bpelitem.setRole(PO_OPEN);
              else if (sourceObjRole.equals("Evaluating"))
                  bpelitem.setRole(PO_EVAL);
              
              if (!sourceObj.getEmail().equals("NA") )
                  bpelitem.setEmail(sourceObj.getEmail());
              else 
                  bpelitem.setEmail(" ");
              
              bpelitem.setBcreated(true);
              bpelitem.setBdeleted(false); 
              blist.add(bpelitem); 
          }
      }
    }
    
    /**
     * if the PO is both in DB and local list, THEN do nothing
     * if the PO is in DB but not in local list, THEN delete it
     */
    private void handleDeletion () {
        for (int i = 0; i < allusersusers.size(); i++) {
          associatepeoplelistview sourceObj = allusersusers.get(i);
          
          bpeluserlist bpelitem = new bpeluserlist();
          
          bpelitem.setUserID(sourceObj.getIuserid());
          String sourceObjRole = sourceObj.getRole();
          if (sourceObjRole.equals("Administrating"))
              bpelitem.setRole(PO_ADMIN);
          else if (sourceObjRole.equals("Opening"))
              bpelitem.setRole(PO_OPEN);
          else if (sourceObjRole.equals("Evaluating"))
              bpelitem.setRole(PO_EVAL);
          
          if (foundInTargetList(sourceObj, ausers) || foundInTargetList(sourceObj, ousers) || foundInTargetList(sourceObj, eusers)) {
              bpelitem.setBcreated(false);
              bpelitem.setBdeleted(false);
              //not set assoId
              //not set email
          }
          else {
              if (!sourceObj.getEmail().equals("NA") )
                  bpelitem.setEmail(sourceObj.getEmail());
              else 
                  bpelitem.setEmail(" ");
              
              bpelitem.setAssid(sourceObj.getAssid());
              bpelitem.setBcreated(false);
              bpelitem.setBdeleted(true);  
          }
          blist.add(bpelitem);  
      }
    }
    
   public void validateMinNum(FacesContext context, UIComponent toValidate, Object value) throws ValidatorException {
        Integer minOpen = (Integer) value;
        if (minOpen < 2) {
            FacesMessage message = new FacesMessage("The minimum opening staff number must be greater or equal to (2)!");
            context.addMessage("associateuserwithtender", message);
            throw new ValidatorException(message);
        }
        if (minOpen > ousers.size()) {
           FacesMessage message = new FacesMessage("Minimum opening staff number should be less or equal to opening users!");
           context.addMessage("associateuserwithtender", message);
           throw new ValidatorException(message); 
        }
    }
   
   
   //this can be used when OKpresses start, in order to test the content of the lista
   /**
    * System.err.println("--------- A users ---------------");
      for (int i = 0; i < ausers.size(); i++) {
            associatepeoplelist ditem = ausers.get(i);

            System.err.println("role: " + ditem.getRole());
            System.err.println("userId: " + ditem.getIuserid());
            System.err.println("email: " + ditem.getEmail());
            System.err.println("name: " + ditem.getName());

        }
      System.err.println("--------- O users ---------------");
      for (int j = 0; j < ousers.size(); j++) {
            associatepeoplelist ditem = ousers.get(j);

            System.err.println("role: " + ditem.getRole());
            System.err.println("userId: " + ditem.getIuserid());
            System.err.println("email: " + ditem.getEmail());
            System.err.println("name: " + ditem.getName());

        }
      System.err.println("--------- E users ---------------");
      for (int k = 0; k < eusers.size(); k++) {
            associatepeoplelist ditem = eusers.get(k);

            System.err.println("role: " + ditem.getRole());
            System.err.println("userId: " + ditem.getIuserid());
            System.err.println("email: " + ditem.getEmail());
            System.err.println("name: " + ditem.getName());

        }
      for (int dds = 0; dds < blist.size(); dds++) {
            bpeluserlist ditem = blist.get(dds);

            System.err.println("role: " + ditem.getRole());
            System.err.println("userId: " + ditem.getUserID());
            System.err.println("toCreate: " + ditem.isBcreated());
            System.err.println("toDelete: " + ditem.isBdeleted());
            System.err.println("email: " + ditem.getEmail());
            System.err.println("assocId: " + ditem.getAssid());

        }
      reset();
    * 
    */
    
    public String OKpresses() {
      // now create the BPELLIST............
      idone=0;
      handleDeletion();
      handleCreation(ausers);
      handleCreation(ousers);
      handleCreation(eusers);
               
      try { 
            org.ellectra.wsassignepows.UpdateAssignedPOsPortType port = service_3.getUpdateAssignedPOsPort();

            // TODO initialize WS operation arguments here
            org.ellectra.wsassignepows.UpdateAssignedPOsRequest part1 = new org.ellectra.wsassignepows.UpdateAssignedPOsRequest();

            part1.setActorSignature(dUserloginsignature);
            part1.setCallForTenderID(mycalloftender);
            part1.setMinNumOfPOsForOpen(a_au3);
            
            List<org.ellectra.wsassignepows.PoType> dlocalist = part1.getPO();
            for (int dds = 0; dds < blist.size(); dds++) {
                org.ellectra.wsassignepows.PoType dd2 = new org.ellectra.wsassignepows.PoType();
                bpeluserlist ditem = blist.get(dds);

                dd2.setRoleType(ditem.getRole());
                dd2.setUserAccountID(ditem.getUserID());
                dd2.setToCreate(ditem.isBcreated());
                dd2.setToDelete(ditem.isBdeleted());
                
                if (ditem.getEmail() != null)
                    dd2.setUserAccountEmail(ditem.getEmail());
                else 
                    dd2.setUserAccountEmail(" ");
                
                
                if (ditem.isBdeleted())
                    dd2.setCallAssocID(ditem.getAssid());
                
                dlocalist.add(dd2);

            }
            // TODO process result here
            org.ellectra.wsassignepows.UpdateAssignedPOsResponse result = port.updateAssignedPOsOperation(part1);
            reset();
        //System.out.println("Result = "+result.getReturnMessage()+result.isReturn());
        } catch (Exception ex) {
            // TODO handle custom exceptions here
            ex.printStackTrace();
            System.out.println("error on associate = " + ex.getLocalizedMessage() + ex.getMessage());
            reset();
        }

        return "associatepeopleback";
    }
    
    public String Cancel() {
        a_au2 = "0";
        buttonAddDisabled = "true";
        idone=0;
        return "associatepeopleback";
    }
    
    /**
     * Function to add a PO to the appropriate list
     * @param event
     */
    public void addToListp(ActionEvent event) {
        
        // value of listbox is userid-name-email
        int iplace = a_au1.indexOf("-");
        int lastplace = a_au1.lastIndexOf("-");
        
        String aname = a_au1.substring(iplace + 1, lastplace - 1);
        String email = a_au1.substring(lastplace + 2, a_au1.length());
        String id = a_au1.substring(0, iplace - 1);
        int useridtoadd = Integer.valueOf(id);
        
        associatepeoplelist pp = new associatepeoplelist();
        pp.setName(aname);
        pp.setIuserid(useridtoadd);
        pp.setEmail(email.trim());
        
        if (a_au2.equals(PO_ADMIN)) {
            pp.setRole("Administrating");
            ausers.add(pp);

        } else if (a_au2.equals(PO_OPEN)) {
            pp.setRole("Opening");
            ousers.add(pp);

        } else if (a_au2.equals(PO_EVAL)) {
            pp.setRole("Evaluating");
            eusers.add(pp);

        } else {}
        FacesContext context = FacesContext.getCurrentInstance();
        context.renderResponse();
    }

    
    /**
     * Function to remove a checked PO from the appropriate list 
     * @param event
     */
    public void removeFromListp(ActionEvent event) {
        idone = 1;
        
        for (int i = 0; i < ausers.size(); i++) {
            associatepeoplelist as = ausers.get(i);
            System.err.println("ausers: [" + i +"]," + as.isChecked());
            if (as.isChecked()) {
                ausers.remove(as);
            }
        }

        for (int j = 0; j < ousers.size(); j++) {
            associatepeoplelist os = ousers.get(j);
            System.err.println("ousers: [" + j +"]," + os.isChecked());
            if (os.isChecked()) {
                ousers.remove(os);
            }
        }

        for (int k = 0; k < eusers.size(); k++) {
            associatepeoplelist es = eusers.get(k);
            System.err.println("eusers: [" + k +"]," + es.isChecked());
            if (es.isChecked()) {
                eusers.remove(es);
            }
        }

        FacesContext context = FacesContext.getCurrentInstance();
        context.renderResponse();
    }
    
    public void userSelected(ValueChangeEvent event) {
        a_au1 = (String) event.getNewValue();
        FacesContext context = FacesContext.getCurrentInstance();
        context.renderResponse();
    }

    public void roleSelected(ValueChangeEvent event) {
        a_au2 = (String) event.getNewValue();
         if (a_au2.equals("0"))
             setButtonAddDisabled("true");
         else
             setButtonAddDisabled("false");
                    
        FacesContext context = FacesContext.getCurrentInstance();
        context.renderResponse();

    }
    
    public void checkedSelectedAdmin(ValueChangeEvent event) {
        Boolean toSet = (Boolean) event.getNewValue();
        
        associatepeoplelist selected = (associatepeoplelist) this.getAdata().getRowData();
        selected.setChecked(toSet);
        FacesContext context = FacesContext.getCurrentInstance();
        context.renderResponse();
    }
    
    public void checkedSelectedOpen(ValueChangeEvent event) {
        Boolean toSet = (Boolean) event.getNewValue();
        
        associatepeoplelist selected = (associatepeoplelist) this.getOdata().getRowData();
        selected.setChecked(toSet);
        FacesContext context = FacesContext.getCurrentInstance();
        context.renderResponse();
    }
    
    public void checkedSelectedEval(ValueChangeEvent event) {
        Boolean toSet = (Boolean) event.getNewValue();
        
        associatepeoplelist selected = (associatepeoplelist) this.getEdata().getRowData();
        selected.setChecked(toSet);
        FacesContext context = FacesContext.getCurrentInstance();
        context.renderResponse();
    }
    
   /**
    * This function populates the dropdown list containing the users of a specific role
    * @return
    */ 
   public List getUserslistbox() {
        //GetSessionVariables();
        List usersTemp = new ArrayList();
        if (idone == 0)
            LoadUsers();
        
        for (int i = 0; i < dUsersGlobal.size(); i++) {
            UserAccountType dele = dUsersGlobal.get(i);
            
            if (a_au2.equalsIgnoreCase("0")) {
                //String orgid = Integer.toString(dele.getUserId());
                SelectItem item = new SelectItem("1 - NA", "Select Role Type");
                usersTemp.add(item);
            } 
            else {
                //populate list ONLY with users of the given role
                if (dele.getUserRole().getRole().get(0).equalsIgnoreCase(a_au2)) {
                    boolean toBeAdded = false;

                    associatepeoplelistview sourceObj = new associatepeoplelistview();
                    sourceObj.setIuserid(dele.getUserId());

                    if (a_au2.equalsIgnoreCase(PO_ADMIN)) {
                        sourceObj.setRole("Administrating");
                        toBeAdded = !foundInTargetList(sourceObj, ausers);
                    } 
                    if (a_au2.equalsIgnoreCase(PO_OPEN)) {
                        sourceObj.setRole("Opening");
                        toBeAdded = !foundInTargetList(sourceObj, ousers);
                    } 
                    if (a_au2.equalsIgnoreCase(PO_EVAL)) {
                        sourceObj.setRole("Evaluating");
                        toBeAdded = !foundInTargetList(sourceObj, eusers);
                    } 

                    if (toBeAdded) {
                        String userid = Integer.toString(dele.getUserId());    
                        String email = "NA";
                        if (dele.getEmail() != null)
                            email = dele.getEmail();
                        
                        // SelectItem item = new SelectItem("1 - "+dele.getFirstName(),dele.getFirstName());
                        SelectItem item = new SelectItem(userid + " - " + dele.getFirstName() + " " + dele.getLastName() + " - " + email, dele.getFirstName() + " " + dele.getLastName());
                        usersTemp.add(item); 
                    }
                }
            }
           
            /*else {
                //populate list ONLY with users of the given role
                if (dele.getUserRole().getRole().get(0).equalsIgnoreCase(a_au2)) {
                   
                    String userid = Integer.toString(dele.getUserId());    
                    String email = "NA";
                    if (dele.getEmail() != null)
                        email = dele.getEmail();
                    // SelectItem item = new SelectItem("1 - "+dele.getFirstName(),dele.getFirstName());
                    SelectItem item = new SelectItem(userid + " - " + dele.getFirstName() + " " + dele.getLastName() + " - " + email, dele.getFirstName() + " " + dele.getLastName());
                    usersTemp.add(item);
                }

            }*/
        
        }//for
        return usersTemp;
    }
   
   /**
    * This function gets a list of all the users in the system and copies this list to "dUsersGlobal"
    */
     public void LoadUsers() {
         GetSessionVariables();
         try { 
            org.ellectra.wsmu.ManageUserPortType port = service_1.getManageUserPort();

            org.ellectra.wsmu.ManageUserRequest part1 = new org.ellectra.wsmu.ManageUserRequest();
            part1.setAction("FR2_UserAcc_GetUsers");
            part1.setActorSignature("123456");

            org.ellectra.wsmu.ManageUserResponse result = port.manageUserOperation(part1);
            dUsersGlobal = result.getUserAccount();
        } catch (Exception ex) {
            // TODO handle custom exceptions here
            System.out.println("error on load users = " + ex.getLocalizedMessage());
        }
    }
    
    /**
     * This function is used to populate the lists (depending on the role) containing all the associated users
     */
    public void LoadAllUsers() {
        System.err.println("load all users");
        
        if (idone == 0) {
            idone = 1;
            System.err.println("load new users");
            ausers.clear();
            ousers.clear();
            eusers.clear();
            try { 
                org.ellectra.wsvassignpo.ViewAssignedPOsPortType port = service.getViewAssignedPOsPort();

                org.ellectra.wsvassignpo.ViewAssignedPOsRequest part1 = new org.ellectra.wsvassignpo.ViewAssignedPOsRequest();
                part1.setActorSignature(dUserloginsignature);
                part1.setCallForTenderID(mycalloftender);
                
                org.ellectra.wsvassignpo.ViewAssignedPOsResponse result = port.viewAssignedPOsOperation(part1);
                int iMin = result.getMinNumOfPOsForOpen();
                
                List<org.ellectra.wsvassignpo.PoType> dpo = result.getPO();
                
                for (int i = 0; i < dpo.size(); i++) {
                    org.ellectra.wsvassignpo.PoType bpelout = new org.ellectra.wsvassignpo.PoType();
                    bpelout = dpo.get(i);
                    
                    associatepeoplelist padd = new associatepeoplelist();
                    //padd.setChecked(false);
                    padd.setIuserid(bpelout.getUserAccountID());
                    padd.setName(bpelout.getFirstName() + " " + bpelout.getLastName());
                    
                    if (bpelout.getUserAccountEmail() != null)
                        padd.setEmail(bpelout.getUserAccountEmail());
                    else 
                        padd.setEmail("NA");
                    
                        
                    if (bpelout.getRoleType().equalsIgnoreCase(PO_ADMIN)) {
                        padd.setRole("Administrating");
                        ausers.add(padd);
                    }
                    if (bpelout.getRoleType().equalsIgnoreCase(PO_OPEN)) {
                        padd.setRole("Opening");
                        ousers.add(padd);
                    }
                    if (bpelout.getRoleType().equalsIgnoreCase(PO_EVAL)) {
                        padd.setRole("Evaluating");
                        eusers.add(padd);
                    }
                }
                
            } catch (Exception ex) {
                System.out.println("Errors = " + ex.getLocalizedMessage() + ex.getMessage());
            }
        }
    }

    
    /**
     * This function is used to populate the list containing all the assigned to a call POs, no matter what the role is
     */
    private void PopulateAllUsersForCallOfTenders() {
        GetSessionVariables();
        allusersusers.clear();
        try { 
            org.ellectra.wsvassignpo.ViewAssignedPOsPortType port = service.getViewAssignedPOsPort();
            // TODO initialize WS operation arguments here
            org.ellectra.wsvassignpo.ViewAssignedPOsRequest part1 = new org.ellectra.wsvassignpo.ViewAssignedPOsRequest();
            part1.setActorSignature(dUserloginsignature);
            part1.setCallForTenderID(mycalloftender);

            // TODO process result here
            org.ellectra.wsvassignpo.ViewAssignedPOsResponse result = port.viewAssignedPOsOperation(part1);
            if (result.getMinNumOfPOsForOpen() != null)
                a_au3 = result.getMinNumOfPOsForOpen();
            
            List<org.ellectra.wsvassignpo.PoType> dd = result.getPO();
            //System.err.print("users are : "+dd.size());
            for (int i1 = 0; i1 < dd.size(); i1++) {
                org.ellectra.wsvassignpo.PoType bpelout = new org.ellectra.wsvassignpo.PoType();
                bpelout = dd.get(i1);
                
                associatepeoplelistview ditem = new associatepeoplelistview();
                ditem.setAssid(bpelout.getAssociationID());
                ditem.setIuserid(bpelout.getUserAccountID());
                ditem.setLastname(bpelout.getLastName());
                ditem.setName(bpelout.getFirstName());
                
                if (bpelout.getUserAccountEmail() != null)
                    ditem.setEmail(bpelout.getUserAccountEmail());
                else
                    ditem.setEmail("NA");
                
                if (bpelout.getRoleType().equalsIgnoreCase(PO_ADMIN)) {
                       ditem.setRole("Administrating");
                }
                else if (bpelout.getRoleType().equalsIgnoreCase(PO_OPEN)) {
                       ditem.setRole("Opening");
                }
                else if (bpelout.getRoleType().equalsIgnoreCase(PO_EVAL)) {
                       ditem.setRole("Evaluating"); 
                }
                
                allusersusers.add(ditem);
            }
        } catch (Exception ex) {
            // TODO handle custom exceptions here
            System.out.println("Errors = " + ex.getLocalizedMessage() + ex.getMessage());
        }

    }

    public ArrayList<associatepeoplelistview> getAllusersusers() {
        PopulateAllUsersForCallOfTenders();
        return allusersusers;
    }

    public void setAllusersusers(ArrayList<associatepeoplelistview> allusersusers) {
        this.allusersusers = allusersusers;
    }
    
    public ArrayList<associatepeoplelist> getAusers() {
        LoadAllUsers();
        return ausers;
    }

    public void setAusers(ArrayList<associatepeoplelist> ausers) {
        this.ausers = ausers;
    }
    
    public String getA_au1() {
        return a_au1;
    }

    public void setA_au1(String a_au1) {
        this.a_au1 = a_au1;
    }

    public String getA_au2() {
        return a_au2;
    }

    public void setA_au2(String a_au2) {
        this.a_au2 = a_au2;
    }

    public Integer getA_au3() {
        return a_au3;
    }

    public void setA_au3(Integer a_au3) {
        this.a_au3 = a_au3;
    }

    public UIData getEdata() {
        return edata;
    }

    public void setEdata(UIData edata) {
        this.edata = edata;
    }

    public UIData getOdata() {
        return odata;
    }

    public void setOdata(UIData odata) {
        this.odata = odata;
    }

    public ArrayList<associatepeoplelist> getEusers() {
        return eusers;
    }

    public void setEusers(ArrayList<associatepeoplelist> eusers) {
        this.eusers = eusers;
    }

    public ArrayList<associatepeoplelist> getOusers() {
        return ousers;
    }

    public void setOusers(ArrayList<associatepeoplelist> ousers) {
        this.ousers = ousers;
    }

    public UIData getAdata() {
        return adata;
    }

    public void setAdata(UIData adata) {
        this.adata = adata;
    }


    public void setUserslistbox(List userslistbox) {
        this.userslistbox = userslistbox;
    }

    public UIInput getUserslistboxlist() {
        return userslistboxlist;
    }

    public void setUserslistboxlist(UIInput userslistboxlist) {
        this.userslistboxlist = userslistboxlist;
    }

    public UIData getAllusersdata() {
        return allusersdata;
    }

    public void setAllusersdata(UIData allusersdata) {
        this.allusersdata = allusersdata;
    }

    public String getButtonAddDisabled() {
        return buttonAddDisabled;
    }

    public void setButtonAddDisabled(String buttonAddDisabled) {
        this.buttonAddDisabled = buttonAddDisabled;
    }


}
