Package com.centraview.common

Examples of com.centraview.common.CVDal


  /**
   * Drop in for new IMAP check all.
   */
  private void newIMAP(MailAccountVO accountVO)
  {
    CVDal cvdal = new CVDal(this.dataSource);
    IMAPStore store = null;
    try { //take this try/catch away
      Session session = null;
      store = this.setupIMAPConnection(accountVO, session);

      IMAPFolder root = (IMAPFolder)store.getDefaultFolder();
      IMAPFolder[] allFolders = (IMAPFolder[])root.list("*");
      HashMap folders = new HashMap();

      for (int i = 0; i < allFolders.length; i++) {
        if (allFolders[i].isSubscribed() || allFolders[i].getName().equals("INBOX")) {
          folders.put(allFolders[i].getFullName(), allFolders[i]);
        }
      }

      this.processIMAPFolders(folders, accountVO, cvdal);

      Iterator iter = folders.values().iterator();
      while (iter.hasNext()) {
        IMAPFolder current = (IMAPFolder)iter.next();
        MailFolderVO folderVO = this.getEmailFolderByName(accountVO.getAccountID(), current.getFullName(), cvdal);
        int folderID = folderVO.getFolderID();
        if (folderID == -1) {
          folderVO = this.getEmailFolderByName(accountVO.getAccountID(), current.getName(), cvdal);
          folderID = folderVO.getFolderID();
        }

        int type = current.getType();
        if ((type & IMAPFolder.HOLDS_MESSAGES) != 0) {
          current.open(Folder.READ_WRITE);
          Message msgs[] = current.getMessages();
          FetchProfile fp = new FetchProfile();
          fp.add(IMAPFolder.FetchProfileItem.FLAGS);
          fp.add(UIDFolder.FetchProfileItem.UID);
          current.fetch(msgs, fp);
          this.handleIMAPMessageArray(msgs, current, folderID, accountVO, store, cvdal);
        }
        if (current.isOpen()) {
          current.close(false);
        }
      }
    } catch (Exception e) {
      logger.error("[newIMAP] Exception thrown.", e);
    } finally {
      try {
        store.close();
      } catch (Exception e) {}
      cvdal.destroy();
    }
  }
View Full Code Here


  public boolean deleteHistoryRecord(int operation, int recordTypeID, int recordID){
    boolean recordDeleted = true;
    try{
      // Create the instance of CVDal
      CVDal cvdl = new CVDal(dataSource);

      //set the SQL Qyuery as well as RecordTypeID and RecordID
      cvdl.setSql("history.deleterecord");
      cvdl.setInt(1, operation);
      cvdl.setInt(2, recordTypeID);
      cvdl.setInt(3, recordID);
      cvdl.executeUpdate();
      cvdl.destroy();
      cvdl = null;
    }
    catch(Exception e){
      recordDeleted = false;
    }
View Full Code Here

   * @param sourceCollection A Collection of DDNameValues.
   * @see com.centraview.common.DDNameValue
   */
  private void updateSource(Collection sourceCollection)
  {
    CVDal cvdl = new CVDal(dataSource);
    try {
      if (sourceCollection != null) {
        StringBuffer stringBuffer = new StringBuffer();
        Iterator it = sourceCollection.iterator();
        while (it.hasNext()) {
          DDNameValue sourceObject = (DDNameValue) it.next();
          if (sourceObject.getName() != null && sourceObject.getId() == -1) {
            // create a new Source Record
            cvdl.setSqlQueryToNull();
            cvdl.setSqlQuery("INSERT INTO source (Name) VALUES (?)");
            cvdl.setString(1, sourceObject.getName());
            cvdl.executeUpdate();
            int newId = cvdl.getAutoGeneratedKey();
            stringBuffer.append(newId);
          } // end of if statement (sourceObject.getName() != null ...
          else if (sourceObject.getName() != null) {
            // update the existing Source Record
            cvdl.setSqlQueryToNull();
            cvdl.setSqlQuery("UPDATE source SET Name = ? WHERE SourceID = ?");
            cvdl.setString(1, sourceObject.getName());
            cvdl.setInt(2, sourceObject.getId());
            cvdl.executeUpdate();
            stringBuffer.append(sourceObject.getId());
          } // end of else if statement (sourceObject.getName() != null)
          if (stringBuffer.length() > 0 && it.hasNext()) {
            stringBuffer.append(", ");
          }
        } // end of while loop (it.hasNext())
        if (stringBuffer.length() > 0) {
          cvdl.setSqlQueryToNull();
          cvdl.setSqlQuery("DELETE FROM source WHERE SourceID NOT IN (" + stringBuffer + ")");
          cvdl.executeUpdate();
        } // end of if statement (stringBuffer.length() > 0)
      } // end of if statement (sourceValues != null)
    } catch (Exception e) {
      logger.error("[updateSource]: Exception", e);
    } finally {
      cvdl.destroy();
    } // end of finally block
  } // end of updateSource method
View Full Code Here

   * @param typeCollection A Collection of DDNameValues.
   * @see com.centraview.common.DDNameValue
   */
  private void updateTypes(Collection typeCollection)
  {
    CVDal cvdl = new CVDal(dataSource);
    try {
      if (typeCollection != null) {
        StringBuffer stringBuffer = new StringBuffer();
        Iterator it = typeCollection.iterator();
        while (it.hasNext()) {
          DDNameValue sourceObject = (DDNameValue) it.next();
          // System.out.println("[DEBUG] [AppSettingsEJB]: sourceObject: " +
          // sourceObject.toString());
          if (sourceObject.getName() != null && sourceObject.getId() == -1) {
            // create a new Source Record
            cvdl.setSqlQueryToNull();
            cvdl.setSqlQuery("INSERT INTO salestype (Name) VALUES (?)");
            cvdl.setString(1, sourceObject.getName());
            cvdl.executeUpdate();
            int newId = cvdl.getAutoGeneratedKey();
            stringBuffer.append(newId);
          } // end of if statement (sourceObject.getName() != null ...
          else if (sourceObject.getName() != null) {
            // update the existing Source Record
            cvdl.setSqlQueryToNull();
            cvdl.setSqlQuery("UPDATE salestype SET Name = ? WHERE SalesTypeID = ?");
            cvdl.setString(1, sourceObject.getName());
            cvdl.setInt(2, sourceObject.getId());
            cvdl.executeUpdate();
            stringBuffer.append(sourceObject.getId());
          } // end of else if statement (sourceObject.getName() != null)
          if (stringBuffer.length() > 0 && it.hasNext()) {
            stringBuffer.append(", ");
          }
        } // end of while loop (it.hasNext())
        if (stringBuffer.length() > 0) {
          cvdl.setSqlQueryToNull();
          cvdl.setSqlQuery("DELETE FROM salestype WHERE SalesTypeID NOT IN (" + stringBuffer + ")");
          cvdl.executeUpdate();
        } // end of if statement (stringBuffer.length() > 0)
      } // end of if statement (sourceValues != null)
    } // end of try block
    catch (Exception e) {
      logger.error("[updateTypes]: Exception", e);
    } finally {
      cvdl.destroy();
    } // end of finally block
  } // end of updateTypes method
View Full Code Here

  public int createLicense (LicenseVO licenseDetail)
  {
    int newLicenseID = 0;
    try
    {
      CVDal dataConnection = new CVDal(dataSource);
     
      dataConnection.setSqlQuery(
        "insert into license(LicenseKey, LastVerified, LicenseVerification)"
        + "values(?, NULL, NULL)");
       
      dataConnection.setString (1,licenseDetail.getLicenseKey());
      dataConnection.executeUpdate();
      newLicenseID = dataConnection.getAutoGeneratedKey();
      dataConnection.clearParameters();
      dataConnection.destroy();
      dataConnection = null;
     
    } //end of try block
    catch (Exception ex)
    {
View Full Code Here

  public LicenseVO getLicenseDetails (int licenseID)
  {
    LicenseVO licenseDetails = null;
    try
    {
      CVDal dataConnection = new CVDal(dataSource);
     
      dataConnection.setSqlQuery(
        "select LicenseID, LicenseKey, LastVerified , LicenseVerification "
        + "from license where LicenseID = ?" );
     
      dataConnection.setInt(1,licenseID);
      Collection resultsCollection = dataConnection.executeQuery();
      dataConnection.clearParameters();
      dataConnection.destroy();
      dataConnection = null;
     
      if (null != resultsCollection)
      {
        //No need to iterate through the collection
View Full Code Here

   * @param stageCollection A Collection of DDNameValues.
   * @see com.centraview.common.DDNameValue
   */
  private void updateStages(Collection stageCollection)
  {
    CVDal cvdl = new CVDal(dataSource);
    try {
      if (stageCollection != null) {
        StringBuffer stringBuffer = new StringBuffer();
        Iterator it = stageCollection.iterator();
        while (it.hasNext()) {
          DDNameValue sourceObject = (DDNameValue) it.next();
          // System.out.println("[DEBUG] [AppSettingsEJB]: sourceObject: " +
          // sourceObject.toString());
          if (sourceObject.getName() != null && sourceObject.getId() == -1) {
            // create a new Source Record
            cvdl.setSqlQueryToNull();
            cvdl.setSqlQuery("INSERT INTO salesstage (Name) VALUES (?)");
            cvdl.setString(1, sourceObject.getName());
            cvdl.executeUpdate();
            int newId = cvdl.getAutoGeneratedKey();
            stringBuffer.append(newId);
          } // end of if statement (sourceObject.getName() != null ...
          else if (sourceObject.getName() != null) {
            // update the existing Source Record
            cvdl.setSqlQueryToNull();
            cvdl.setSqlQuery("UPDATE salesstage SET Name = ? WHERE SalesStageID = ?");
            cvdl.setString(1, sourceObject.getName());
            cvdl.setInt(2, sourceObject.getId());
            cvdl.executeUpdate();
            stringBuffer.append(sourceObject.getId());
          } // end of else if statement (sourceObject.getName() != null)
          if (stringBuffer.length() > 0 && it.hasNext()) {
            stringBuffer.append(", ");
          }
        } // end of while loop (it.hasNext())
        if (stringBuffer.length() > 0) {
          cvdl.setSqlQueryToNull();
          cvdl.setSqlQuery("DELETE FROM salesstage WHERE SalesStageID NOT IN (" + stringBuffer + ")");
          cvdl.executeUpdate();
        } // end of if statement (stringBuffer.length() > 0)
      } // end of if statement (sourceValues != null)
    } // end of try block
    catch (Exception e) {
      logger.error("[updateStages]: Exception", e);
    } finally {
      cvdl.destroy();
    } // end of finally block
  } // end of updateStages method
View Full Code Here

 
  public void updateLicense(LicenseVO licenseDetail)
  {
    try
    {
      CVDal dataConnection = new CVDal(dataSource);
     
      dataConnection.setSqlQuery (
        "update license set LicenseKey = ?, licenseVerification = ?, "
        + "LastVerified = ? where LicenseID = ? ");
       
      dataConnection.setString (1, licenseDetail.getLicenseKey());
      dataConnection.setString (2, licenseDetail.getLicenseVerification());
      dataConnection.setRealTimestamp (3,
        new java.sql.Timestamp (licenseDetail.getLastVerified().getTime()));
      dataConnection.setInt (4, licenseDetail.getLicenseID());

      dataConnection.executeUpdate();
      dataConnection.clearParameters();
      dataConnection.destroy();
      dataConnection = null;
    } //end of try block
    catch (Exception ex)
    {
      System.out.println ("Exception in LicenseEJB.updateLicense:");
View Full Code Here

 
  public void deleteLicense (int licenseID)
  {
    try
    {
      CVDal dataConnection = new CVDal(dataSource);
     
      dataConnection.setSqlQuery ("delete from license where LicenseID = ? ");
      dataConnection.setInt (1, licenseID);
     
      dataConnection.executeUpdate();
      dataConnection.clearParameters();
      dataConnection.destroy();
      dataConnection = null;
    } //end of try block
    catch (Exception ex)
    {
      System.out.println ("Exception in LicenseEJB.deleteLicense:");
View Full Code Here

   * @param termsCollection A Collection of DDNameValues.
   * @see com.centraview.common.DDNameValue
   */
  private void updateTerms(Collection termsCollection)
  {
    CVDal cvdl = new CVDal(dataSource);
    try {
      if (termsCollection != null) {
        StringBuffer stringBuffer = new StringBuffer();
        Iterator it = termsCollection.iterator();
        while (it.hasNext()) {
          DDNameValue sourceObject = (DDNameValue) it.next();
          // System.out.println("[DEBUG] [AppSettingsEJB]: sourceObject: " +
          // sourceObject.toString());
          if (sourceObject.getName() != null && sourceObject.getId() == -1) {
            // create a new Source Record
            cvdl.setSqlQueryToNull();
            cvdl.setSqlQuery("INSERT INTO terms (TermName) VALUES (?)");
            cvdl.setString(1, sourceObject.getName());
            cvdl.executeUpdate();
            int newId = cvdl.getAutoGeneratedKey();
            stringBuffer.append(newId);
          } // end of if statement (sourceObject.getName() != null ...
          else if (sourceObject.getName() != null) {
            // update the existing Source Record
            cvdl.setSqlQueryToNull();
            cvdl.setSqlQuery("UPDATE terms SET TermName = ? WHERE TermID = ?");
            cvdl.setString(1, sourceObject.getName());
            cvdl.setInt(2, sourceObject.getId());
            cvdl.executeUpdate();
            stringBuffer.append(sourceObject.getId());
          } // end of else if statement (sourceObject.getName() != null)
          if (stringBuffer.length() > 0 && it.hasNext()) {
            stringBuffer.append(", ");
          }
        } // end of while loop (it.hasNext())
        if (stringBuffer.length() > 0) {
          cvdl.setSqlQueryToNull();
          cvdl.setSqlQuery("DELETE FROM terms WHERE TermID NOT IN (" + stringBuffer + ")");
          cvdl.executeUpdate();
        } // end of if statement (stringBuffer.length() > 0)
      } // end of if statement (sourceValues != null)
    }catch (Exception e) {
      logger.error("[updateTerms]: Exception", e);
    }finally {
      cvdl.destroy();
    } // end of finally block
  } // end of updateTerms method
View Full Code Here

TOP

Related Classes of com.centraview.common.CVDal

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.