Package com.centraview.common

Examples of com.centraview.common.DDNameValue


                // loop throught list and look for match
                Iterator itGroup = groupList.iterator();

                while (itGroup.hasNext()) {
                  DDNameValue nameValue = (DDNameValue) itGroup.next();

                  // if name matches, then...
                  if (group.equals(nameValue.getName())) {
                    // ... get the ID
                    groupID = nameValue.getId();
                  }
                }

                if (groupID == 0) {
                  errMsg = errMsg + "Account Team \"" + group + "\" not found in Group List,";
                  flagInsert = false;
                }
              }

              if ((CustomEntList != null) && (CustomEntList.size() > 0)) {
                Iterator it = CustomEntList.iterator();

                while (it.hasNext()) {
                  DDNameValue ddname = (DDNameValue) it.next();
                  String id = ddname.getName();

                  String type = null;

                  StringTokenizer st = new StringTokenizer(id, "*");

                  while (st.hasMoreTokens()) {
                    id = (String) st.nextToken();
                    type = (String) st.nextToken();
                  }

                  String name = ddname.getStrid();

                  String customEntityValue = (String) hCols.get(name);

                  if (customEntityValue != null) {
                    if ((type != null) && type.equals("MULTIPLE")) {
                      String tempEnt = customEntityValue;

                      int indexName = name.indexOf("(");


                      if (indexName > 0) {
                        customEntityValue = customEntityValue + "*" + name.substring(0, indexName);
                      }

                      boolean customFlag = CustomFieldValues.containsKey(customEntityValue);

                      if (! customFlag) {
                        errMsg = errMsg + "Custom Field \"" + tempEnt + "\" Mapped for Entity's Does Not Exist in the database ,";
                        flagInsert = false;
                      }
                    }
                  }
                }
              }

              if ((CustomIndList != null) && (CustomIndList.size() > 0)) {
                Iterator it = CustomIndList.iterator();

                while (it.hasNext()) {
                  DDNameValue ddname = (DDNameValue) it.next();
                  String id = ddname.getName();
                  String type = null;
                  StringTokenizer st = new StringTokenizer(id, "*");

                  while (st.hasMoreTokens()) {
                    id = (String) st.nextToken();
                    type = (String) st.nextToken();
                  }

                  String name = ddname.getStrid();
                  String customIndividualName = (String) hCols.get(name);

                  if (customIndividualName != null) {
                    if ((type != null) && type.equals("MULTIPLE")) {
                      String tempIndv = customIndividualName;

                      int indexName = name.indexOf("(");

                      if (indexName > 0) {
                        customIndividualName = customIndividualName + "*" + name.substring(0, indexName);
                      }

                      boolean customFlag = CustomFieldValues.containsKey(customIndividualName.trim());

                      if (!customFlag) {
                        errMsg = errMsg + "Custom Filed \"" + tempIndv + "\" mapped for Entity's Is Not Existing in the database ,";
                        flagInsert = false;
                      }
                    }
                  }
                }
              }

              if (!errMsg.equals("")) {
                errCounter++;
              }

              if (flagInsert) {
                int sourceId = 0;
                int sourceEn = 0;
                int entId = 0;

                boolean sourceFlag = sourceList.containsKey(sourceIndividual);

                if (sourceFlag) {
                  sourceId = Integer.parseInt((String) sourceList.get(sourceIndividual));
                } else {
                  if (sourceIndividual != null && !sourceIndividual.equals("")) {
                    try {
                      sourceId = remoteCommon.getSourceID(sourceIndividual);
                    } catch(Exception e) {
                      logger.error("[Exception] ListEJB.getImportList: ", e);
                    }
                  }
                }

                sourceFlag = sourceList.containsKey(sourceEntity);

                if (sourceFlag) {
                  sourceEn = Integer.parseInt((String) sourceList.get(sourceEntity));
                } else {
                  if (sourceEntity != null && !sourceEntity.equals("")) {
                    try {
                      sourceId = remoteCommon.getSourceID(sourceEntity);
                    } catch (Exception e) {
                      logger.error("[Exception] ListEJB.getImportList: ", e);
                      e.printStackTrace();
                    }
                  }
                }

                // Get the group ID from the database
                int groupID = 0;

                // loop throught list and look for match
                Iterator itGroup = groupList.iterator();

                while (itGroup.hasNext()) {
                  DDNameValue nameValue = (DDNameValue) itGroup.next();

                  // if name matches, then...
                  if (group.equals(nameValue.getName())) {
                    // ... get the ID
                    groupID = nameValue.getId();
                  }
                }

                int user = 0;

                // loop throught list and look for match
                boolean employeeFlag = employeeList.containsKey(manager);

                if (employeeFlag) {
                  user = Integer.parseInt((String) employeeList.get(manager));
                }

                if (!(website.startsWith("http://")) || (website.startsWith("https://"))) {
                  // added only http by default and not https
                  if ((website.trim()).equals("")) {
                    website = "";
                  } else {
                    website = "http://" + website;
                  }
                }

                // set Entity
                if (entity != "") {
                  boolean entityFlag = entityList.containsKey(entity);

                  if (entityFlag) {
                    entId = Integer.parseInt((String) entityList.get(entity));
                  } else {
                    dl.setSql("contact.addentity");
                    dl.setString(1, entityExternalID);
                    dl.setString(2, entity);
                    dl.setInt(3, sourceEn);
                    dl.setInt(4, 0);
                    dl.setInt(5, listid);
                    dl.setInt(6, indvID);
                    dl.setInt(7, indvID);
                    dl.setInt(8, user);
                    dl.setInt(9, groupID);
                    dl.executeUpdate();
                    entId = dl.getAutoGeneratedKey();
                    dl.clearParameters();


                    // apply the logged-in user's default privileges to this record
                    //remoteAuth.saveCurrentDefaultPermission("Entity", entId, indvID);
                    if (!newEntityList.contains(entId+"")) {
                      newEntityList.add(entId+"");
                    }

                    //Add the new Entity to the EntityList
                    entityList.put(entity, entId + "");
                  }

                  boolean addressFlag = primaryContactList.containsKey(entId +"");

                  if (!addressFlag) {
                    String Contact = (String) primaryContactList.get(entId + "");

                    if (Contact == null) {
                      entityPrimaryFlag = true;
                    }

                    if ((Contact != null) && Contact.equals("NO")) {
                      entityPrimaryFlag = true;
                    }
                  }

                  if ((CustomEntList != null) && (CustomEntList.size() > 0)) {
                    Iterator it = CustomEntList.iterator();

                    while (it.hasNext()) {
                      DDNameValue ddname = (DDNameValue) it.next();
                      String id = ddname.getName();

                      String type = null;

                      StringTokenizer st = new StringTokenizer(id, "*");

                      while (st.hasMoreTokens()) {
                        id = (String) st.nextToken();
                        type = (String) st.nextToken();
                      }

                      String name = ddname.getStrid();
                      String customEntityValue = (String) hCols.get(name);
                      String customName = name.substring(0, name.indexOf("("));

                      if (type != null) {
                        //Scalar Value
                        if (type.equals("SCALAR")) {
                          if (customEntityValue != null) {
                            batchQuery.add("insert into customfieldscalar (customfieldid,recordid,value) values (" + id + "," + entId + ",'" + customEntityValue + "')");
                          }
                        }

                        //Multiple Value
                        if (type.equals("MULTIPLE")) {
                          int indexName = name.indexOf("(");

                          if (indexName > 0) {
                            customEntityValue = customEntityValue + "*" + name.substring(0, indexName);
                          }

                          boolean customFlag = CustomFieldValues.containsKey(customEntityValue);

                          if (customFlag) {
                            String fieldId = (String) CustomFieldValues.get(customEntityValue);
                            String valueId = null;
                            st = null;
                            st = new StringTokenizer(fieldId, "*");

                            while (st.hasMoreTokens()) {
                              valueId = (String) st.nextToken();
                              fieldId = (String) st.nextToken();
                            }

                            if (valueId != null) {
                              if (fieldId.equals(id)) {
                                batchQuery.add( "insert into customfieldmultiple (customfieldid,recordid,valueid) values (" + id + "," + entId + "," + valueId + ")");
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }

                int individualID = 0;

                // create Individual
                dl.setSql("contact.createindividual");
                dl.setInt(1, entId);
                dl.setString(2, fName);
                dl.setString(3, lName);
                dl.setString(4, title);
                dl.setInt(5, indvID);

                if (entityPrimaryFlag) {
                  dl.setString(6, "YES");
                } else {
                  dl.setString(6, "NO");
                }

                dl.setString(7, mName);
                dl.setInt(8, sourceId);
                dl.setString(9, individualExternalID);
                dl.setInt(10, listid);
                dl.setInt(11, indvID);

                try {
                  dl.executeUpdate();
                  individualID = dl.getAutoGeneratedKey();
                  dl.clearParameters();

                  // apply the logged-in user's default privileges to this record
                  //remoteAuth.saveCurrentDefaultPermission("Individual", individualID, indvID);
                 
                  if (!newIndividualList.contains(individualID+"")) {
                    newIndividualList.add(individualID+"");
                  }
                 
                  if (entId != 0) {
                    primaryContactList.put(entId + "", "YES");
                  }

                  if (individualID == 0) {
                    errMsg = errMsg + "Failed to create Individual,";
                    errCounter++;
                  }
                } catch (Exception ex) {
                  errMsg = errMsg + "Failed to create Individual,";
                  errCounter++;
                  ex.printStackTrace();
                  throw new CreateException();
                } finally {
                  dl.clearParameters();
                }

                try {
                  if (! street1.equals("") || ! street2.equals("") || ! city.equals("") ||
                      ! state.equals("") || ! zip.equals("") || ! country.equals("") ||
                      ! website.equals("")) {
                    dl.setSql("contact.addaddress");
                    dl.setInt(1, 1);
                    dl.setString(2, street1);
                    dl.setString(3, street2);
                    dl.setString(4, city);
                    dl.setString(5, state);
                    dl.setString(6, zip);
                    dl.setString(7, country);
                    dl.setString(8, website);
                    dl.setInt(9, 0);
                    dl.executeUpdate();

                    int adrId = dl.getAutoGeneratedKey();
                    dl.clearParameters();

                    batchQuery.add("insert into addressrelate (Address, ContactType, Contact, AddressType, IsPrimary) values (" + adrId + ", 2, " + individualID + ", 1, 'YES')");

                    if (entityPrimaryFlag) {
                      batchQuery.add("insert into addressrelate (Address, ContactType, Contact, AddressType, IsPrimary) values (" + adrId + ", 1, " + entId + ", 1, 'YES')");
                    }
                  }
                } catch (Exception e) {
                  logger.error("[Exception] ListEJB.getImportList: ", e);
                }

                // set workPhone
                if ((workPhone != null) && (!workPhone.equals(""))) {
                  try {
                    dl.setSql("contact.addmoc");
                    dl.setInt(1, Constants.MOC_WORK);
                    dl.setString(2, workPhone);
                    dl.setString(3, ""); //moc.getNote()
                    dl.setString(4, "Work");
                    dl.setString(5, null); //moc.getMocOrder()
                    dl.executeUpdate();

                    int mocId = dl.getAutoGeneratedKey();
                    dl.clearParameters();

                    if (mocId != 0) {
                      batchQuery.add("insert into mocrelate (MOCID, ContactType, ContactID, isPrimary) values (" + mocId + ", 2, " + individualID + ", 'YES')");

                      if (entityPrimaryFlag) {
                        batchQuery.add("INSERT INTO mocrelate (MOCID, ContactType, ContactID, isPrimary) values (" + mocId + ", 1, " + entId + ", 'YES')");
                      }
                    }
                  } catch (Exception e) {
                    logger.error("[Exception] ListEJB.getImportList: ", e);
                  }
                }

                // set homePhone
                if ((homePhone != null) && (!homePhone.equals(""))) {
                  try {
                    dl.setSql("contact.addmoc");
                    dl.setInt(1, Constants.MOC_HOME);
                    dl.setString(2, homePhone);
                    dl.setString(3, ""); //moc.getNote()
                    dl.setString(4, "Home");
                    dl.setString(5, null); //moc.getMocOrder()
                    dl.executeUpdate();

                    int mocId = dl.getAutoGeneratedKey();
                    dl.clearParameters();

                    if (mocId != 0) {
                      batchQuery.add("insert into mocrelate (MOCID, ContactType, ContactID, isPrimary) values (" + mocId + ", 2, " + individualID + ", 'YES')");

                      if (entityPrimaryFlag) {
                        batchQuery.add( "insert into mocrelate (MOCID, ContactType, ContactID, isPrimary) values (" + mocId + ", 1, " + entId + ", 'YES')");
                      }
                    }
                  } catch (Exception e) {
                    logger.error("[Exception] ListEJB.getImportList: ", e);
                  }
                }

                // set faxPhone
                if ((faxPhone != null) && (!faxPhone.equals(""))) {
                  try {
                    dl.setSql("contact.addmoc");
                    dl.setInt(1, Constants.MOC_FAX);
                    dl.setString(2, faxPhone);
                    dl.setString(3, ""); //moc.getNote()
                    dl.setString(4, "Fax");
                    dl.setString(5, null); //moc.getMocOrder()
                    dl.executeUpdate();

                    int mocId = dl.getAutoGeneratedKey();
                    dl.clearParameters();

                    if (mocId != 0)
                    {
                      batchQuery.add("insert into mocrelate(MOCID,ContactType," + "ContactID,isPrimary) values(" + mocId + ",2," + individualID + ",'YES')");

                      if (entityPrimaryFlag) {
                        batchQuery.add( "insert into mocrelate(MOCID,ContactType," + "ContactID,isPrimary) values(" + mocId + ",1," + entId + ",'YES')");
                      }
                    }
                  } catch (Exception e) {
                    logger.error("[Exception] ListEJB.getImportList: ", e);
                  }
                }

                // set otherPhone
                if ((otherPhone != null) && (!otherPhone.equals(""))) {
                  try {
                    dl.setSql("contact.addmoc");
                    dl.setInt(1, Constants.MOC_OTHER);
                    dl.setString(2, otherPhone);
                    dl.setString(3, ""); //moc.getNote()
                    dl.setString(4, "Other");
                    dl.setString(5, null); //moc.getMocOrder()
                    dl.executeUpdate();

                    int mocId = dl.getAutoGeneratedKey();
                    dl.clearParameters();

                    if (mocId != 0) {
                      batchQuery.add("insert into mocrelate(MOCID,ContactType," + "ContactID,isPrimary) values(" + mocId + ",2," + individualID + ",'YES')");

                      if (entityPrimaryFlag) {
                        batchQuery.add( "insert into mocrelate(MOCID,ContactType," + "ContactID,isPrimary) values(" + mocId + ",1," + entId + ",'YES')");
                      }
                    }
                  } catch (Exception e) {
                    logger.error("[Exception] ListEJB.getImportList: ", e);
                  }
                }

                // set mainPhone
                if ((mainPhone != null) && (!mainPhone.equals(""))) {
                  try {
                    dl.setSql("contact.addmoc");
                    dl.setInt(1, Constants.MOC_MAIN);
                    dl.setString(2, mainPhone);
                    dl.setString(3, ""); //moc.getNote()
                    dl.setString(4, "Main");
                    dl.setString(5, null); //moc.getMocOrder()
                    dl.executeUpdate();

                    int mocId = dl.getAutoGeneratedKey();
                    dl.clearParameters();

                    if (mocId != 0) {
                      batchQuery.add("insert into mocrelate(MOCID,ContactType," + "ContactID,isPrimary) values(" + mocId + ",2," + individualID + ",'YES')");

                      if (entityPrimaryFlag) {
                        batchQuery.add( "insert into mocrelate(MOCID,ContactType," + "ContactID,isPrimary) values(" + mocId + ",1," + entId + ",'YES')");
                      }
                    }
                  } catch (Exception e) {
                    logger.error("[Exception] ListEJB.getImportList: ", e);
                  }
                }

                // set pagerPhone
                if ((pagerPhone != null) && (!pagerPhone.equals(""))) {
                  try {
                    dl.setSql("contact.addmoc");
                    dl.setInt(1, Constants.MOC_PAGER);
                    dl.setString(2, pagerPhone);
                    dl.setString(3, ""); //moc.getNote()
                    dl.setString(4, "Pager");
                    dl.setString(5, null); //moc.getMocOrder()
                    dl.executeUpdate();

                    int mocId = dl.getAutoGeneratedKey();
                    dl.clearParameters();

                    if (mocId != 0) {
                      batchQuery.add("insert into mocrelate(MOCID,ContactType," + "ContactID,isPrimary) values(" + mocId + ",2," + individualID + ",'YES')");

                      if (entityPrimaryFlag) {
                        batchQuery.add( "insert into mocrelate(MOCID,ContactType," + "ContactID,isPrimary) values(" + mocId + ",1," + entId + ",'YES')");
                      }
                    }
                  } catch (Exception e) {
                    logger.error("[Exception] ListEJB.getImportList: ", e);
                  }
                }

                // set mobilePhone
                if ((mobilePhone != null) && (!mobilePhone.equals(""))) {
                  try {
                    dl.setSql("contact.addmoc");
                    dl.setInt(1, Constants.MOC_MOBILE);
                    dl.setString(2, mobilePhone);
                    dl.setString(3, ""); //moc.getNote()
                    dl.setString(4, "Mobile");
                    dl.setString(5, null); //moc.getMocOrder()
                    dl.executeUpdate();

                    int mocId = dl.getAutoGeneratedKey();
                    dl.clearParameters();

                    if (mocId != 0) {
                      batchQuery.add("insert into mocrelate(MOCID,ContactType," + "ContactID,isPrimary) values(" + mocId + ",2," + individualID + ",'YES')");

                      if (entityPrimaryFlag) {
                        batchQuery.add( "insert into mocrelate(MOCID,ContactType," + "ContactID,isPrimary) values(" + mocId + ",1," + entId + ",'YES')");
                      }
                    }
                  } catch (Exception e) {
                    logger.error("[Exception] ListEJB.getImportList: ", e);
                  }
                }

                // set Email
                if ((email != null) && (!email.equals(""))) {
                  try {
                    dl.setSql("contact.addmoc");
                    dl.setInt(1, Constants.MOC_EMAIL);
                    dl.setString(2, email);
                    dl.setString(3, ""); //moc.getNote()
                    dl.setString(4, "Email");
                    dl.setString(5, ""); //moc.getMocOrder()
                    dl.executeUpdate();

                    int mocId = dl.getAutoGeneratedKey();
                    dl.clearParameters();

                    if (mocId != 0) {
                      batchQuery.add("insert into mocrelate(MOCID,ContactType," + "ContactID,isPrimary) values(" + mocId + ",2," + individualID + ",'YES')");

                      if (entityPrimaryFlag) {
                        batchQuery.add( "insert into mocrelate(MOCID,ContactType," + "ContactID,isPrimary) values(" + mocId + ",1," + entId + ",'YES')");
                      }
                    }
                  } catch (Exception e) {
                    logger.error("[Exception] ListEJB.getImportList: ", e);
                  }
                }

                if ((CustomIndList != null) && (CustomIndList.size() > 0)) {
                  Iterator it = CustomIndList.iterator();

                  while (it.hasNext()) {
                    DDNameValue ddname = (DDNameValue) it.next();

                    String id = ddname.getName();
                    String type = null;
                    StringTokenizer st = new StringTokenizer(id, "*");

                    while (st.hasMoreTokens()) {
                      id = (String) st.nextToken();
                      type = (String) st.nextToken();
                    }

                    String name = ddname.getStrid();
                    String customIndividualName = (String) hCols.get(name);

                    if (type != null) {
                      //Scalar Value
                      if (type.equals("SCALAR")) {
View Full Code Here


      Collection itemTypeCollection = dl.executeQuery();
      Iterator itemTypeIterator = itemTypeCollection.iterator();
      while (itemTypeIterator.hasNext())
      {
        HashMap itemTypeHM = (HashMap) itemTypeIterator.next();
        DDNameValue itemTypeDD =
          new DDNameValue(((Long) itemTypeHM.get("itemtypeid")).intValue(), (String) itemTypeHM.get("title"));
        vec.add(itemTypeDD);
      } //end of while loop (itemTypeIterator.hasNext())
    } //end of try block
    catch (Exception e)
    {
View Full Code Here

      Collection glAccountCollection = dl.executeQuery();
      Iterator glAccountIterator = glAccountCollection.iterator();
      while (glAccountIterator.hasNext())
      {
        HashMap glAccountHM = (HashMap) glAccountIterator.next();
        DDNameValue glAccountDD =
          new DDNameValue(((Long) glAccountHM.get("GLAccountsID")).intValue(), (String) glAccountHM.get("Title"));
        vec.add(glAccountDD);
      } //end of while loop (glAccountIterator.hasNext())
    } //end of try block
    catch (Exception e)
    {
View Full Code Here

      Collection taxClassCollection = dl.executeQuery();
      Iterator taxClassIterator = taxClassCollection.iterator();
      while (taxClassIterator.hasNext())
      {
        HashMap taxClassHM = (HashMap) taxClassIterator.next();
        DDNameValue taxClassDD =
          new DDNameValue(((Long) taxClassHM.get("taxclassid")).intValue(), (String) taxClassHM.get("title"));
        vec.add(taxClassDD);
      } //end of while loop (taxClassIterator.hasNext())
    } //end of try block
    catch (Exception e)
    {
View Full Code Here

        while (it.hasNext())
        {
          HashMap mapOutput = (HashMap)it.next();
          int literatureid = ((Number)mapOutput.get("literatureid")).intValue();
          String strTitle = (String)mapOutput.get("title");
          DDNameValue ddnamevalue = new DDNameValue(literatureid , strTitle);
          result.add(ddnamevalue);
        }
      }
    }
    catch(Exception e)
View Full Code Here

        while (it.hasNext())
        {
          HashMap mapOutput = (HashMap)it.next();
          int deliveryid = ((Number)mapOutput.get("deliveryid")).intValue();
          String name = (String)mapOutput.get("name");
          DDNameValue ddnamevalue = new DDNameValue(deliveryid , name);
          result.add(ddnamevalue);
        }
      }
    }
    catch(Exception e)
View Full Code Here

        while (it.hasNext())
        {
          HashMap mapOutput = (HashMap)it.next();
          int statusid = Integer.parseInt(mapOutput.get("statusid").toString());
          String name = (String)mapOutput.get("name");
          DDNameValue ddnamevalue = new DDNameValue(statusid , name);
          result.add(ddnamevalue);
        }
      }
    }
    catch(Exception e)
View Full Code Here

          int i = 0;
          Iterator it = col.iterator();
          while (it.hasNext()) {
            HashMap hm = (HashMap)it.next();
            String tempfileID = hm.get("fileid") + "#" + hm.get("title");
            pairs.add(new DDNameValue(tempfileID, (String)hm.get("title")));
            i++;
          }
        }
      } // else query String is decarded no need to get anydata as there are no
        // fileids
View Full Code Here

    if (colID.size() > 0)
    {
      Iterator itCur = colID.iterator();
      HashMap hmCur = (HashMap)itCur.next();

      DDNameValue curnameValueObj = new DDNameValue(catID, (String)hmCur.get("title"));
      vecDDNameValue.addElement(curnameValueObj);

      while (catID != 0)
      {

        dl.clearParameters();
        dl.setSql("kb.getparentinfo");
        dl.setInt(1, catID);
        Collection colParID = dl.executeQuery();

        Iterator iter = colParID.iterator();

        int parID = 0;
        String parName = "";
        String system = "";

        while (iter.hasNext())
        {
          HashMap hm = (HashMap)iter.next();

          parID = ((Long)hm.get("parentid")).intValue();
          parName = (String)hm.get("parenttitle");
        }
        catID = parID;

        if (parID != 0)
        {
          DDNameValue thisnameValueObj = new DDNameValue(parID, parName);

          vecDDNameValue.addElement(thisnameValueObj);
        }
      }
    }
View Full Code Here

      Collection results = cvdal.executeQuery();
      Iterator iter = results.iterator();
      while (iter.hasNext()) {
        HashMap row = (HashMap)iter.next();
        Number activityResourceID = (Number)row.get("ActivityResourceID");
        DDNameValue dnv = new DDNameValue(activityResourceID.toString() + "#"
            + (String)row.get("Name"), (String)row.get("Name"));
        dnv.setId(activityResourceID.intValue());
        resources.add(dnv);
      }
    } finally {
      cvdal.destroy();
      cvdal = null;
View Full Code Here

TOP

Related Classes of com.centraview.common.DDNameValue

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.