Package com.centraview.common

Examples of com.centraview.common.CVDal



  public int addTimeSlip(int userId, TimeSlipVO tsvo)
  {
    int timeSlipId = 0;
        CVDal dl = new CVDal(dataSource);
    try
    {
      if(!CVUtility.isModuleVisible("Time Slips",userId, this.dataSource))
        throw new AuthorizationFailedException("Time Slips - addTimeSlip");

      dl.setSql("projecttimeslip.addtimeslip");
      dl.setInt(1,tsvo.getProjectID());
        dl.setInt(2,tsvo.getTaskID());
      dl.setString(3,tsvo.getDescription());
      dl.setDate(4,tsvo.getDate());
      dl.setTime(5,tsvo.getStart());
      dl.setTime(6,tsvo.getEnd());
      dl.setFloat(7,tsvo.getBreakTime());
      dl.setFloat(8,userId);
      dl.setFloat(9,tsvo.getHours());
      dl.setInt(10, tsvo.getTicketID());
      dl.setInt(11, tsvo.getTimesheetID());
      dl.executeUpdate();

      timeSlipId = dl.getAutoGeneratedKey();

            InitialContext ic = CVUtility.getInitialContext();
            AuthorizationLocalHome authorizationHome = (AuthorizationLocalHome)ic.lookup("local/Authorization");
            AuthorizationLocal authorizationLocal = authorizationHome.create();
            authorizationLocal.setDataSource(dataSource);
            authorizationLocal.saveCurrentDefaultPermission("Time Slips", timeSlipId, userId);
    }
    catch(Exception e)
    {
      System.out.println("[Exception][TimeSlipEJB.addTimeSlip] Exception Thrown: "+e);
      e.printStackTrace();
    } finally {
          dl.destroy();
          dl = null;
    }
    return timeSlipId;
  }
View Full Code Here


  }   // end getGarbageList() method


  public ValueListVO getHistoryList(int individualId, ValueListParameters parameters)
  {
    CVDal cvdal = new CVDal(this.dataSource);
    try {
      ArrayList list = new ArrayList();
     
      // permissionSwitch turns the permission parts of the query on and off.
      // if individualID is less than zero then the list is requested without limiting
      // rows based on record rights.  If it is true than the rights are used.
      boolean permissionSwitch = false;
      boolean applyFilter = false;
      String filter = parameters.getFilter();
     
      if (filter != null && filter.length() > 0) {
        String str = "CREATE TABLE historylistfilter " + filter;
        cvdal.setSqlQuery(str);
        cvdal.executeUpdate();
        cvdal.setSqlQueryToNull();
        applyFilter = true;
      }
      int numberOfRecords = 0;
      parameters.setTotalRecords(numberOfRecords);

      StringBuffer query = new StringBuffer("");
     
      query.append("SELECT h.historyid, h.date, CONCAT(u.firstName, ' ', u.lastName) AS user, ");
      query.append("ht.historytype AS action, m.name as recordtype, h.recordName ");
      query.append("FROM history h LEFT JOIN historytype ht ON (h.operation = ht.historytypeid) ");
      query.append("LEFT JOIN individual u ON (h.individualid = u.individualid) ");
      query.append("LEFT JOIN module m ON (h.recordtypeid = m.moduleid) ");
      if (applyFilter){ query.append(", historylistfilter hlf "); }
      query.append("ORDER BY " + String.valueOf(parameters.getSortColumn() + " " + parameters.getSortDirection()));
      query.append(parameters.getLimitParam());

      cvdal.setSqlQuery(query.toString());
      list = cvdal.executeQueryList(1);
      cvdal.setSqlQueryToNull();
     
      if (applyFilter){
        cvdal.setSqlQueryToNull();
        cvdal.setSqlQuery("DROP TABLE historylistfilter");
        cvdal.executeUpdate();
      }
      return new ValueListVO(list, parameters);
    } catch (Exception e) {
      System.out.println("[getReportList] Exception thrown."+ e);
      throw new EJBException(e);
    } finally {
      cvdal.destroy();
    }
  }   // end getHistoryList() method
View Full Code Here

 
  public ValueListVO getHistoryValueList(int individualId, ValueListParameters parameters)
  {
    ArrayList list = new ArrayList();
    String filter = parameters.getFilter();
    CVDal cvdl = new CVDal(this.dataSource);
    if (filter != null && filter.length() > 0)
    {
      String str = "CREATE TABLE historylistfilter " + filter;
      cvdl.setSqlQuery(str);
      cvdl.executeUpdate();
      cvdl.setSqlQueryToNull();
    }
    int numberOfRecords = 0;
    numberOfRecords = EJBUtil.buildListFilterTable(cvdl, "historylistfilter", individualId, 0, "history", "historyId", "owner", null, false);
    parameters.setTotalRecords(numberOfRecords);
    String query = this.buildReportListQuery(parameters);
    cvdl.setSqlQuery(query);
    list = cvdl.executeQueryList(1);
    cvdl.setSqlQueryToNull();
    cvdl.setSqlQuery("DROP TABLE historylistfilter");
    cvdl.executeUpdate();
    cvdl.setSqlQueryToNull();
    cvdl.setSqlQuery("DROP TABLE listfilter");
    cvdl.executeUpdate();
    cvdl.destroy();
    cvdl = null;
    return new ValueListVO(list, parameters);
  }
View Full Code Here

  public ArrayList getValidFields(String importType)
  {
    ArrayList validFields = new ArrayList();

    // these are the defined static fields
    CVDal cvdal = new CVDal(this.dataSource);
    try
    {
      String query = "SELECT f.name, f.fieldName FROM mailimportfields f LEFT JOIN mailimporttypes t ON (f.typeID=t.typeID) WHERE t.name=?";
      cvdal.setSqlQuery(query);
      cvdal.setString(1, importType);
      Collection results = cvdal.executeQuery();
      if (results != null && results.size() > 0)
      {
        Iterator iter = results.iterator();
        while (iter.hasNext())
        {
          HashMap row = (HashMap)iter.next();
          validFields.add(row);
        }
      }
      // add the list of custom fields to the valid fields arraylist
      validFields.addAll(this.getValidCustomFields("Both"));
    }catch(Exception e){
      System.out.println("[Exception][ImportUtils] Exception thrown in getValidFields(): " + e);
      e.printStackTrace();
    }finally{
      cvdal.destroy();
      cvdal = null;
    }
    return validFields;
  }   // end getValidFields() method
View Full Code Here

   */
  public MailFolderVO getEmailFolder(int emailFolderID)
  {
    MailFolderVO mailFolderVO = new MailFolderVO();
    mailFolderVO.setFolderID(-1);
    CVDal cvdal = new CVDal(this.dataSource);

    try {
      mailFolderVO = this.getEmailFolder(emailFolderID, cvdal);
    }catch(Exception e){
      logger.error("[getEmailFolder]: Exception", e);
    }finally{
      cvdal.destroy();
      cvdal = null;
    }
    return mailFolderVO;
  }   // end getEmailFolder(int) method
View Full Code Here

   */
  public MailFolderVO getEmailFolderByName(int accountID, String folderName)
  {
    MailFolderVO mailFolderVO = new MailFolderVO();
    mailFolderVO.setFolderID(-1);
    CVDal cvdal = new CVDal(this.dataSource);

    try {
      mailFolderVO = this.getEmailFolderByName(accountID, folderName, cvdal);
    }catch (Exception e){
      logger.error("[getEmailFolderByName]: Exception", e);
    }finally{
      cvdal.destroy();
      cvdal = null;
    }
    return mailFolderVO;
  }
View Full Code Here

   * @param accountID The AccountID to get the list of folders for.
   * @return A ArrayList with a list of FolderID as Key pairs.
   */
  public ArrayList getFolderIDs(int accountID)
  {
    CVDal cvdal = new CVDal(this.dataSource);
    ArrayList folderList = new ArrayList();
    try {
      String selectQuery = "SELECT FolderID FROM emailfolder WHERE AccountID=? ORDER BY Parent, Name, FolderID";
      cvdal.setSqlQuery(selectQuery);
      cvdal.setInt(1, accountID);
      Collection results = cvdal.executeQuery();
     
     
      if (results != null) {
        Iterator resultsIterator = results.iterator();
        while (resultsIterator.hasNext()) {
          HashMap resultsHashMap = (HashMap) resultsIterator.next();
          Number folderID = (Number) resultsHashMap.get("FolderID");
          folderList.add(folderID);
        }
      }
    } finally {
      cvdal.destroy();
    }
    return folderList;
  }   // end getFolderList(int,CVDal) method
View Full Code Here

   * @return A HashMap with FolderID/Name as the Key/Value pairs.
   */
  public HashMap getFolderList(int accountID)
  {
    HashMap folderList = new HashMap();
    CVDal cvdal = new CVDal(this.dataSource);

    try {
      folderList = this.getFolderList(accountID, cvdal);
    }catch(Exception e){
      logger.error("[getFolderList] Exception thrown.", e);
    }finally{
      cvdal.destroy();
      cvdal = null;
    }
    return folderList;
  }
View Full Code Here

   * @return The number of folders deleted (should always be 0 or 1).
   */
  public int deleteFolder(int individualID, int accountID, int folderID)
  {
    int numberDeleted = -1;
    CVDal cvdal = new CVDal(this.dataSource);

    try {
      numberDeleted = this.deleteFolder(individualID, accountID, folderID, cvdal);
    }catch(Exception e){
      System.out.println("[Exception] MailEJB.deleteFolder: " + e.toString());
      //e.printStackTrace();
    }finally{
      cvdal.destroy();
      cvdal = null;
    }
    return numberDeleted;
  }   // end deleteFolder(int,int,int) method
View Full Code Here

   * @return The number of messages moved (should always be 1 or 0).
   */
  public int moveMessageToFolder(int individualID, int messageID, int newFolderID)
  {
    int numberMoved = 0;
    CVDal cvdal = new CVDal(this.dataSource);
    try {
      // get old folder ID and the server type of the email message
      MailMessageVO messageVO = this.getEmailMessageVO(individualID, messageID);
      MailAccountVO accountVO = this.getMailAccountVO(messageVO.getEmailAccountID());

      int oldFolderID = messageVO.getEmailFolderID();
      String serverType = accountVO.getAccountType();

      if (serverType.equalsIgnoreCase(MailAccountVO.IMAP_TYPE)) {
        try {
          Session session = null;
          IMAPStore store = this.setupIMAPConnection(accountVO, session);
          MailFolderVO toFolderVO = getEmailFolder(newFolderID);
          MailFolderVO fromFolderVO = getEmailFolder(oldFolderID);

          String name = toFolderVO.getFolderFullName();
          if (name == null) {
            name = toFolderVO.getFolderName();
          }
          IMAPFolder toFolder = (IMAPFolder)store.getFolder(name);

          name = fromFolderVO.getFolderFullName();
          if (name == null) {
            name = fromFolderVO.getFolderName();
          }
          IMAPFolder fromFolder = (IMAPFolder)store.getFolder(name);

          fromFolder.open(IMAPFolder.READ_WRITE);
          Message msg = fromFolder.getMessageByUID(Long.parseLong(messageVO.getMessageUID()));
          fromFolder.copyMessages(new Message[] {msg}, toFolder);
          msg.setFlag(Flags.Flag.DELETED, true); //??
          fromFolder.close(true);
        } catch(Exception e) {
          System.out.println("Exception thrown in moveMessageToFolder()");
          e.printStackTrace();
          return(0);
        }
      }

      String insertQuery = "INSERT INTO emailmessagefolder (MessageID, FolderID) VALUES (?, ?)";
      cvdal.setSqlQuery(insertQuery);
      cvdal.setInt(1, messageID);
      cvdal.setInt(2, newFolderID);
      numberMoved = cvdal.executeUpdate();
      cvdal.setSqlQueryToNull();

      String deleteQuery = "DELETE FROM emailmessagefolder WHERE MessageID = ? AND FolderID = ?";
      cvdal.setSqlQuery(deleteQuery);
      cvdal.setInt(1, messageID);
      cvdal.setInt(2, oldFolderID);
      cvdal.executeUpdate();
      cvdal.setSqlQueryToNull();

    }catch(Exception e){
      System.out.println("[Exception][MailEJB] Exception thrown in moveMessageToFolder(): " + e);
      e.printStackTrace();
    }finally{
      cvdal.destroy();
      cvdal = null;
    }
    return numberMoved;
  }
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.