Package com.centraview.contact.individual

Examples of com.centraview.contact.individual.IndividualVO


        * @param indID int individual id
        * @return boolean status of operation
        */
       public boolean updateIndividuals(ArrayList IVOs,int indID)
       {
         IndividualVO ivo = null;
         ContactFacadeLocal indL = null;
         ContactHelperLocal contacthelperL = null;

         try
         {
           InitialContext ic = CVUtility.getInitialContext();
           ContactFacadeLocalHome home = (ContactFacadeLocalHome)ic.lookup("local/ContactFacade");
           indL = home.create();
           indL.setDataSource(this.dataSource);

           int size = IVOs.size();

           ContactHelperLocalHome homeHelper = (ContactHelperLocalHome)ic.lookup("local/ContactHelper");
           contacthelperL = homeHelper.create();
           contacthelperL.setDataSource(this.dataSource);

           for ( int i=0;i<size;i++)
           {
             ivo = (IndividualVO) IVOs.get(i);
             ivo.setContactID(ivo.getIndividualID());

             AddressVO adrVO = contacthelperL.getPrimaryAddressForContact(indID, ivo.getIndividualID(), ivo.getContactType());
             ivo.getPrimaryAddress().setAddressID(adrVO.getAddressID());

             Collection col = contacthelperL.getPrimaryMOCForContact(indID, ivo.getContactID(), ivo.getContactType());
             Iterator it = col.iterator();
             Vector vec = ivo.getMOC();
             int vecsize = vec.size();
             while (it.hasNext()){
               MethodOfContactVO moc = (MethodOfContactVO)it.next();
               for (int j = 0; j < vecsize; j++){
                 if(moc.getMocType() == ((MethodOfContactVO) vec.elementAt(j)).getMocType()){
                   ((MethodOfContactVO) vec.elementAt(j)).setMocID(moc.getMocID());
                   ((MethodOfContactVO) vec.elementAt(j)).added(false);
                   ((MethodOfContactVO) vec.elementAt(j)).updated(true);
                   break;
                 }
               }
             }
             indL.updateIndividual(ivo,indID);
             logger.info("Updated " + ivo.getIndividualID() + " Individual record");
           }
         }catch(Exception e)
         {
           logger.debug("Error in updating Individual : "+e);
           e.printStackTrace();
View Full Code Here


        * @param arl ArrayList with individuals
        * @param indId int individual id
        */
       public void deleteIndividuals(String modulename, ArrayList arl, int indId)
       {
         IndividualVO ivo = new IndividualVO();
         String extId = "";
         int intId = 0;

         Iterator it = arl.iterator();

         ContactFacadeLocal helperL = null;
         try
         {
           InitialContext ic = CVUtility.getInitialContext();
           ContactFacadeLocalHome home = (ContactFacadeLocalHome ) ic.lookup("local/ContactFacade");
           helperL = home.create();

           while(it.hasNext())
           {
             ivo = (IndividualVO)it.next();
             extId = ivo.getExternalID();
             intId = this.getCVidForExtid(modulename,extId);
             helperL.deleteIndividual(indId, intId);
             logger.info("Individual " + intId + " object deleted");
           }

View Full Code Here

        entityForm.set("mocExt" + count, mocContentExt);
        entityForm.set("mocId" + count, String.valueOf(moc.getMocID()));
        count++;
      }
    }
    IndividualVO individualVO = this.getIndividualVO();
    if (individualVO != null) {
      entityForm.set("pcIndividualId", new Integer(individualVO.getContactID()));
      if (individualVO.getFirstName() != null) {
        entityForm.set("pcFirstName", individualVO.getFirstName());
      }
      if (individualVO.getMiddleName() != null) {
        entityForm.set("pcMiddleInitial", individualVO.getMiddleName());
      }
      if (individualVO.getLastName() != null) {
        entityForm.set("pcLastName", individualVO.getLastName());
      }
      if (individualVO.getTitle() != null) {
        entityForm.set("pcTitle", individualVO.getTitle());
      }
    }
    AddressVO address = this.getPrimaryAddress();
    if (address != null) {
      if (address.getAddressID() != 0) {
View Full Code Here

      String pcFName = dynaForm.get("pcFirstName") == null ? "" : (String)dynaForm.get("pcFirstName");
      String pcMName = dynaForm.get("pcMiddleInitial") == null ? "" : (String)dynaForm.get("pcMiddleInitial");
      String pcLName = dynaForm.get("pcLastName") == null ? "" : (String)dynaForm.get("pcLastName");
      String pcTitle = dynaForm.get("pcTitle") == null ? "" : (String)dynaForm.get("pcTitle");

      IndividualVO individualVO = null;
      int individualId = dynaForm.get("pcIndividualId") == null ? 0 : ((Integer)dynaForm.get("pcIndividualId")).intValue();
      if (individualId != 0) {
        individualVO = contactFacadeRemote.getIndividual(individualId);
        // In certain cases (when the individual was imported via marketing list)
        // The individual and the Entity share the same (exact) Address  Therefore
        // If that is the case, I must make sure the IndividualVO address is updated also
        // otherwise the crapiness of the Entity and Individual EJB interaction. will
        // cause a condition, which always reverts the common address to the old one
        // if it were changed.
        // The real solution is probably to delete this code, and make a method on the
        // Individual EJB that simply updates the potentially changed fields on the Individual.
        AddressVO individualPrimaryAddress = individualVO.getPrimaryAddress();
        if (individualPrimaryAddress.getAddressID() == primaryAddress.getAddressID()) {
          individualVO.setPrimaryAddress(primaryAddress);
        }

        // We must clear the mocs on this Individual otherwise we will create new mocs
        // associated with the Individual
        individualVO.clearMOC();
        if ((pcFName != null && !((pcFName.trim()).equals(""))) || (pcLName != null && !((pcLName.trim()).equals(""))) || (pcMName != null && !((pcMName.trim()).equals(""))) || (pcTitle != null && !((pcTitle.trim()).equals("")))) {
          if (CVUtility.updateFieldPermitted(entityRights, "firstname")) {
            individualVO.setFirstName(pcFName);
          }
          if (CVUtility.updateFieldPermitted(entityRights, "middlename")) {
            individualVO.setMiddleName(pcMName);
          }
          if (CVUtility.updateFieldPermitted(entityRights, "lastname")) {
            individualVO.setLastName(pcLName);
          }
          if (CVUtility.updateFieldPermitted(entityRights, "title")) {
            individualVO.setTitle(pcTitle);
          }
          this.setIndividualID(individualId);
        }
        String first = individualVO.getFirstName();
        String last = individualVO.getLastName();
        if ((first == null || first.equals("")) && (last == null || last.equals(""))) {
          individualVO = null;
          this.setIndividualID(0);
        }
        this.setIndividualVO(individualVO);
      } else {
        // we may be creating a new one.
        if ((pcFName != null && !((pcFName.trim()).equals(""))) || (pcLName != null && !((pcLName.trim()).equals(""))) || (pcMName != null && !((pcMName.trim()).equals(""))) || (pcTitle != null && !((pcTitle.trim()).equals("")))) {
          individualVO = new IndividualVO();
          if (CVUtility.updateFieldPermitted(entityRights, "firstname")) {
            individualVO.setFirstName(pcFName);
          }
          if (CVUtility.updateFieldPermitted(entityRights, "middlename")) {
            individualVO.setMiddleName(pcMName);
          }
          if (CVUtility.updateFieldPermitted(entityRights, "lastname")) {
            individualVO.setLastName(pcLName);
          }
          if (CVUtility.updateFieldPermitted(entityRights, "title")) {
            individualVO.setTitle(pcTitle);
          }
          String first = individualVO.getFirstName();
          String last = individualVO.getLastName();
          if ((first == null || first.equals("")) && (last == null || last.equals(""))) {
            individualVO = null;
          } else {
            this.setIndividualID(0);
            individualVO.setContactID(0);
            individualVO.setIsPrimaryContact("YES");
          }
        }
        this.setIndividualVO(individualVO);
      }
View Full Code Here

   * @param  int  IndividualID to fetch
   * return  IndividualVO
  */
  public IndividualVO getIndividual(int indId)
  {
    IndividualVO iv = null;
    try
    {
      InitialContext ic = CVUtility.getInitialContext();
      IndividualLocalHome home = (IndividualLocalHome)ic.lookup("local/Individual");
      IndividualLocal remote =  home.findByPrimaryKey(new IndividualPK(indId,this.dataSource));
      // the ejbLoad will take care of setting the dataSource on a findByPrimaryKey.
      iv = remote.getIndividualVOWithBasicReferences();
      CommonHelperLocalHome chhome= (CommonHelperLocalHome)ic.lookup("local/CommonHelper");
      CommonHelperLocal commonhelper= chhome.create();
      // we need to explicitly set the dataSource on a stateless session bean.
      commonhelper.setDataSource(dataSource);
      iv.setSourceName(commonhelper.getSourceName(iv.getSource()));
    }catch(Exception e){
      System.out.println("[Exception][ContactFacadeEJB.getIndividual] Exception Thrown: "+e);
      //e.printStackTrace();
    }
    return iv;
View Full Code Here

      IndividualLocalHome home = (IndividualLocalHome)ic.lookup("local/Individual");

      ctx.getUserTransaction().begin();

      IndividualLocal remote =  home.create(indDetail,actionUserId,this.dataSource);
      IndividualVO vo = remote.getIndividualVOBasic();
      indID = vo.getContactID();

      ctx.getUserTransaction().commit();

       // The code to add the entry in DB is added to IndividualEJB
       // The reson is the IndividualCreate method is called directly
View Full Code Here

    try{
      InitialContext ic = CVUtility.getInitialContext();
      IndividualLocalHome home = (IndividualLocalHome)ic.lookup("local/Individual");
      IndividualLocal remote =  home.findByPrimaryKey(new IndividualPK(individualId,this.dataSource));

      IndividualVO indVO = remote.getIndividualVOWithBasicReferences();

      HashMap hmDetails=new HashMap();
      hmDetails.put("title",indVO.getFirstName() + " " + indVO.getLastName());
      hmDetails.put("owner",new Integer(indVO.getOwner()));
      hmDetails.put("module",new Integer(1));
      hmDetails.put("recordtype",new Integer(2));

      InitialContext ctxl=CVUtility.getInitialContext();
      CvAtticLocalHome cahome=(CvAtticLocalHome)ctxl.lookup("local/CvAttic");

      CvAtticLocal caremote =cahome.create();
      caremote.setDataSource(this.dataSource);

      int transactionID=caremote.getAtticTransactionID(indID,Constants.CV_GARBAGE,hmDetails);

      HashMap hmind=new HashMap();
      hmind.put("IndividualID",(new Integer(indVO.getContactID())).toString());
      caremote.dumpData(indID,transactionID,"individual",hmind);

      AddressVO adv = indVO.getPrimaryAddress();
      if (adv != null)
      {
        HashMap hmaddr=new HashMap();
        hmaddr.put("AddressID",(new Integer(adv.getAddressID())).toString());
        caremote.dumpData(indID,transactionID,"address",hmaddr);

        HashMap addressRelateHashMap = new HashMap();
        addressRelateHashMap.put("Address",(new Integer(adv.getAddressID())).toString());
        caremote.dumpData(indID,transactionID,"addressrelate", addressRelateHashMap);
      }

      Vector mocvec = indVO.getMOC();
      if (mocvec != null)
      {
        Iterator it = mocvec.iterator();
        while (it.hasNext())
        {
          MethodOfContactVO mocv = (MethodOfContactVO)it.next();

          HashMap hmmocr=new HashMap();
          hmmocr.put("MOCID",(new Integer(mocv.getMocID())).toString());
          hmmocr.put("ContactType",(new Integer(2)).toString());
          hmmocr.put("ContactID",(new Integer(individualId)).toString());
          caremote.dumpData(indID, transactionID, "mocrelate", hmmocr);

          HashMap hmmoc=new HashMap();
          hmmoc.put("MOCID",(new Integer(mocv.getMocID())).toString());
          hmmoc.put("MOCType", Integer.toString(mocv.getMocType()));
          caremote.dumpData(indID, transactionID, "methodofcontact", hmmoc);
        }
      }

      Vector vec = indVO.getCustomField();
      if (vec != null)
      {
        Iterator it = vec.iterator();
        while (it.hasNext())
        {
          CustomFieldVO cfv = (CustomFieldVO)it.next();
          String cftablename = "customfieldscalar";
          if (cfv.getFieldType() == CustomFieldVO.MULTIPLE)
          {
            cftablename = "customfieldmultiple";
          }

          HashMap hmcfv=new HashMap();
          hmcfv.put("CustomFieldID",(new Integer(cfv.getFieldID())).toString());
          caremote.dumpData(indID,transactionID,cftablename,hmcfv);
        }
      }
      remote.setOperationIndividualId(individualId);

      ctx.getUserTransaction().begin();
      remote.remove();
      ctx.getUserTransaction().commit();

            HashMap historyInfo = new HashMap();
        historyInfo.put("recordID",new Integer(individualId));
        historyInfo.put("recordTypeID", new Integer(Constants.IndividualModuleID));
        historyInfo.put("operation", new Integer(Constants.DELETED));
        historyInfo.put("individualID", new Integer(indID));
        historyInfo.put("referenceActivityID", new Integer(0));
        historyInfo.put("recordName", indVO.getFirstName()+ " "+ indVO.getMiddleName()+ " " + indVO.getLastName());
        CVUtility.addHistoryRecord(historyInfo , this.dataSource);

    }catch(FinderException fe){
      System.out.println("[Exception][ContactFacadeEJB.deleteIndividual] Exception Thrown: "+fe);
    }catch(RemoveException fe){
View Full Code Here

      Iterator resultsIterator = results.iterator();
      while(resultsIterator.hasNext())
      {
        HashMap resultMap = (HashMap)resultsIterator.next();
        int individualId = ((Number)resultMap.get("individualid")).intValue();
        IndividualVO individual = this.getIndividual(individualId);
        individualVOs.add(individual);
      } // end while(resultsIterator.hasNext())
    } // end if (results != null)
    return individualVOs;
  }   // end getAllIndividualVOs() method
View Full Code Here

      IndividualLocalHome ih = (IndividualLocalHome)ic.lookup("local/Individual");

      try {
        IndividualLocal il = ih.findByPrimaryContact(cntId, this.dataSource);
        IndividualVO iv = il.getIndividualVOBasic();
        this.envo.setIndividualVO(iv);
      }catch(FinderException e){
        IndividualVO iv = new IndividualVO();
        iv.setEntityID(this.envo.getContactID());
        this.envo.setIndividualVO(iv);
      }

      if (this.envo.getAccManager() != 0) {
        try {
          IndividualLocal ilAccMang = ih.findByPrimaryKey(new IndividualPK(envo.getAccManager(), this.dataSource));
          IndividualVO indAccMang =   ilAccMang.getIndividualVOBasic();
          this.envo.setAcctMgrName(indAccMang.getFirstName()+" "+indAccMang.getLastName());
        }catch(Exception e){
          logger.error("[getEntityVOWithBasicReferences] Exception thrown.", e);
          this.envo.setAcctMgrName("");
        }
      } else {
View Full Code Here

        // update the 'entity.Modified' field, since we are already
        // updating that record at this time.
        remote.addMOC((MethodOfContactVO)(mocIter.next()), newEntityID, contactType, individualID, false);
      }

      IndividualVO individualVO = entityVO.getIndividualVO();
      if (individualVO != null && individualVO.getContactID() <= 0) {
        IndividualLocalHome ih = (IndividualLocalHome)ic.lookup("local/Individual");
        individualVO.setEntityID(newEntityID);
        ih.create(individualVO, individualID, dataSource);
      }
      // Save CustomFields from the Form (which is only the 3 on the form)
      CustomFieldLocalHome custHome = (CustomFieldLocalHome)ic.lookup("local/CustomField");
      CustomFieldLocal custRemote = custHome.create();
View Full Code Here

TOP

Related Classes of com.centraview.contact.individual.IndividualVO

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.