예제 #1
0
  /**
   * Find the periods in a calendar year it need not be a standard period (used in MRP)
   *
   * @param C_Year_ID Year
   * @param periodType Period Type
   * @param ctx context
   * @param trx trx
   * @return MPeriod[]
   */
  public static MPeriod[] getAllPeriodsInYear(int C_Year_ID, String periodType, Ctx ctx, Trx trx) {

    List<MPeriod> periods = new ArrayList<MPeriod>();
    String sql = "SELECT * FROM C_Period WHERE IsActive='Y'";

    sql = sql + " AND C_Year_ID = ?";

    if (periodType != null) sql = sql + " AND PeriodType = ? ";

    sql = sql + " order by StartDate ";

    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
      pstmt = DB.prepareStatement(sql, trx);
      pstmt.setInt(1, C_Year_ID);

      if (periodType != null) pstmt.setString(2, periodType);

      rs = pstmt.executeQuery();
      while (rs.next()) periods.add(new MPeriod(ctx, rs, trx));
    } catch (Exception e) {
      s_log.log(Level.SEVERE, sql, e);
    } finally {
      DB.closeResultSet(rs);
      DB.closeStatement(pstmt);
    }
    MPeriod[] retValue = new MPeriod[periods.size()];
    periods.toArray(retValue);
    return retValue;
  }
예제 #2
0
  /**
   * Find all the year records in a Calendar, it need not be a standard period (used in MRP)
   *
   * @param C_Calendar_ID calendar
   * @param ctx context
   * @param trx trx
   * @return MYear[]
   */
  public static MYear[] getAllYearsInCalendar(int C_Calendar_ID, Ctx ctx, Trx trx) {

    List<MYear> years = new ArrayList<MYear>();
    String sql = "SELECT * FROM C_Year WHERE " + "IsActive='Y' AND C_Calendar_ID = ? ";

    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
      pstmt = DB.prepareStatement(sql, trx);
      pstmt.setInt(1, C_Calendar_ID);
      rs = pstmt.executeQuery();
      while (rs.next()) years.add(new MYear(ctx, rs, trx));

    } catch (Exception e) {
      s_log.log(Level.SEVERE, sql, e);
    } finally {

      DB.closeResultSet(rs);
      DB.closeStatement(pstmt);
    }

    MYear[] retValue = new MYear[years.size()];
    years.toArray(retValue);
    return retValue;
  }
예제 #3
0
 /*
  * Update of user tree for ordered menu nodes (favorites, create new list)
  * favorites @param menuIDs List<Integer> ordered list of menuIDs to put in
  * the tree @param menuTree MTree the tree to be reordered @return true if
  * updated
  */
 private boolean updateUserTree(List<Integer> menuIDs, MTree menuTree) {
   CTreeNode root = menuTree.getRoot();
   if (root != null) {
     Enumeration<?> nodes = root.preorderEnumeration();
     while (nodes.hasMoreElements()) {
       CTreeNode nd = (CTreeNode) nodes.nextElement();
       if (!menuIDs.contains(nd.getNode_ID())) {
         MTreeNodeMM node = null;
         if ((node = MTreeNodeMM.get(menuTree, nd.getNode_ID())) != null) {
           if (!node.delete(true)) return false;
         }
       }
     }
   }
   int seq = 0;
   for (int id : menuIDs) {
     MTreeNodeMM node = null;
     if ((node = MTreeNodeMM.get(menuTree, id)) == null) {
       node = new MTreeNodeMM(menuTree, id);
     }
     node.setSeqNo(++seq);
     if (!node.save()) return false;
   }
   return true;
 }