Package com.knowgate.dataobjs

Examples of com.knowgate.dataobjs.DBSubset


   * @throws SQLException
   */
  public DBSubset getACLUsers(JDCConnection oConn) throws SQLException {
    Object aCatg[] = { get("id_category") };

    oACLUsers = new DBSubset(DB.k_x_cat_user_acl, DB.gu_user + "," + DB.acl_mask, DB.gu_category + "=?", 100);
    oACLUsers.load (oConn, aCatg);

    return oACLUsers;
  } // getACLUsers
View Full Code Here


      } // fi (gu_blockedby is null)
    } // next
    oUpdt.close();
  } // fi (aProds)

  DBSubset oChilds = getChilds(oConn);
 
  if (null!=oChilds) {
    int nChilds = oChilds.getRowCount();
    Category oChld = new Category();
    for (int c=0; c<nChilds; c++) {
      oChld.replace(DB.gu_category, oChilds.getString(0,c));
      oChld.checkOut(oConn, sUserId);
    } // next
  } // fi (oChilds)

    if (DebugFile.trace) {
View Full Code Here

      } // fi (gu_blockedby is null)
    } // next
    oUpdt.close();
  } // fi (aProds)

  DBSubset oChilds = getChilds(oConn);
 
  if (null!=oChilds) {
    int nChilds = oChilds.getRowCount();
    Category oChld = new Category();
    for (int c=0; c<nChilds; c++) {
      oChld.replace(DB.gu_category, oChilds.getString(0,c));
      oChld.checkIn(oConn, sUserId);
    } // next
  } // fi (oChilds)

    if (DebugFile.trace) {
View Full Code Here

   */
  public static String store(JDCConnection oConn, String sCategoryId, String sParentId, String sCategoryName, short iIsActive, int iDocStatus, String sOwner, String sIcon1, String sIcon2 ) throws SQLException {
    Category oCatg = new Category ();
    boolean isParentOfParent = false;
    Object aCatg[] = { null };
    DBSubset oNames;

    if (DebugFile.trace) {
      DebugFile.writeln("Begin Category.store([Connection], " + sCategoryId + ", " + sParentId + ", sCategoryName" + ", ...)" );
      DebugFile.incIdent();
      }

    oCatg.put (DB.gu_owner, sOwner);
    oCatg.put (DB.nm_category, sCategoryName);
    oCatg.put (DB.bo_active, iIsActive);
    oCatg.put (DB.id_doc_status, iDocStatus);

    if (null!=sIcon1) oCatg.put (DB.nm_icon, sIcon1);
    if (null!=sIcon2) oCatg.put (DB.nm_icon2, sIcon2);

      if (null!=sCategoryId) {
        oCatg.put (DB.gu_category, sCategoryId);

        // Verificar que la categoria no es padre de si misma
        if (null!=sParentId) {
          if (sCategoryId.equalsIgnoreCase(sParentId)) {
            if (DebugFile.trace) DebugFile.writeln("ERROR: Category " + sCategoryName + " is its own parent");
            throw new SQLException("Category tree circular reference");
          } // endif (sCategoryId==sParentId)

          // Si la categoria tiene padre (no es raiz) entonces
          // verificar que el padre no es a su vez un hijo de
          // la categoria para evitar la creacion de bucles.
          isParentOfParent = oCatg.isParentOf(oConn, sParentId);
        } // endif (sParentId)

      } // endif (null!=sCategoryId)

      if (isParentOfParent) {
        if (DebugFile.trace) DebugFile.writeln("ERROR: Category " + sCategoryName + " has a circular parentship relationship");
        throw new SQLException("Category tree circular reference");
      }

      // Si la categoria ya existia, entonces
      // borrar todos los nombres traducidos (etiquetas)
      if (null!=sCategoryId) {
        if (DebugFile.trace) DebugFile.writeln("Clearing labels...");
        aCatg[0] = oCatg.getString(DB.gu_category);
        oNames = new DBSubset (DB.k_cat_labels, DB.id_language+","+DB.tr_category+","+DB.url_category, DB.gu_category+"=?",1);
        oNames.clear (oConn, aCatg);
        if (DebugFile.trace) DebugFile.writeln("Labels cleared.");
      }
      else
        oCatg.remove(DB.gu_category);

View Full Code Here

     Category oCat = new Category(sCategoryGUID);

     // Delete any child category first
     // New for v2.1
     DBSubset oChlds = oCat.getChilds(oConn);
     int iChilds = oChlds.getRowCount();
     for (int c=0; c<iChilds; c++)
       Category.delete(oConn, oChlds.getString(0,c));

     Statement oStmt;
     Product oProd;
     DBSubset oObjs = oCat.getObjects(oConn);
     int iObjs = oObjs.getRowCount();
     boolean bRetVal;

    // recorre los objetos de esta categoría y los borra
    for (int o=0; o<iObjs; o++) {
      switch (oObjs.getInt(1, o)) {
        case com.knowgate.training.AcademicCourse.ClassId:
          // los cursos academicos no se borran cuando se borra la categoria
          // pero si se borran sus productos asociados en la tienda
        case com.knowgate.hipergate.Product.ClassId:
          oProd = new Product(oObjs.getString(0, o));
          if (oProd.exists(oConn)) {
            oProd.delete(oConn);         
          }
          break;
        case com.knowgate.crm.DistributionList.ClassId:
          com.knowgate.crm.DistributionList.delete(oConn, oObjs.getString(0, o));
          break;
        case com.knowgate.crm.Company.ClassId:
          com.knowgate.crm.Company.delete(oConn, oObjs.getString(0, o));
          break;
        case com.knowgate.forums.NewsGroup.ClassId:
          com.knowgate.forums.NewsGroup.delete(oConn, oObjs.getString(0, o));
          break;
        case com.knowgate.hipergate.Image.ClassId:
          Image oImg = new com.knowgate.hipergate.Image(oConn, oObjs.getString(0, o));
          oImg.delete(oConn);
          break;
        case com.knowgate.hipermail.DBMimeMessage.ClassId:
          com.knowgate.hipermail.DBMimeMessage.delete(oConn, sCategoryGUID, oObjs.getString(0, o));
          break;
        case com.knowgate.acl.PasswordRecord.ClassId:
          com.knowgate.acl.PasswordRecord.delete(oConn, oObjs.getString(0, o));
          break;
      }
    } // next (o)

    oObjs = null;

    if (DBBind.exists(oConn, DB.k_mime_msgs, "U")) {
      oObjs = new DBSubset(DB.k_mime_msgs, DB.gu_mimemsg, DB.gu_category + "='" + sCategoryGUID + "'", 1000);
      iObjs = oObjs.load(oConn);

      if (oConn.getDataBaseProduct()==JDCConnection.DBMS_POSTGRESQL) {
        PreparedStatement oDlte = oConn.prepareStatement("SELECT k_sp_del_mime_msg(?)");
        ResultSet oRSet;
        for (int m=0; m<iObjs; m++) {
          oDlte.setString(1, oObjs.getString(0,m));
          oRSet = oDlte.executeQuery();
          oRSet.close();
        }
        oDlte.close();
      }
      else {
        CallableStatement oCall = oConn.prepareCall("{ call k_sp_del_mime_msg(?) }");
        for (int m=0; m<iObjs; m++) {
          oCall.setString(1, oObjs.getString(0,m));
          oCall.execute();
        }
        oCall.close();
      }
    } // fi (exists(k_mime_msgs))
View Full Code Here

   * @throws SQLException
   * @since 3.0
   */
  public BugAttachment[] attachments(JDCConnection oConn)
    throws SQLException {
    DBSubset oAttachs = new DBSubset(DB.k_bugs_attach, DB.tx_file+","+DB.len_file, DB.gu_bug+"=?", 10);
    int iAttachs = oAttachs.load(oConn, new Object[]{getString(DB.gu_bug)});
    if (0==iAttachs)
      return null;
    else {
      BugAttachment[] aAttachs = new BugAttachment[iAttachs];
      for (int a=0; a<iAttachs; a++)
        aAttachs[a] = new BugAttachment(getString(DB.gu_bug),oAttachs.getString(1,a), oAttachs.getInt(2,a));
      return aAttachs;
    }
  } // attachments
View Full Code Here

   * @since 3.0
   */
  public BugChangeLog[] changeLog(JDCConnection oConn)
    throws SQLException {
    BugChangeLog[] aBcl;
    DBSubset oLog = new DBSubset(DB.k_bugs_changelog,
                                 DB.gu_bug+","+DB.pg_bug+","+DB.nm_column+","+DB.dt_modified+","+DB.gu_writer+","+DB.tx_oldvalue,
                                 DB.gu_bug+"=? ORDER BY 4", 10);
    int iLog = oLog.load(oConn, new Object[]{getString(DB.gu_bug)});
    if (0==iLog) {
      aBcl = null;
    } else {
      aBcl = new BugChangeLog[iLog];
      for (int l=0; l<iLog; l++) {
        aBcl[l] = new BugChangeLog();
        aBcl[l].putAll(oLog.getRowAsMap(l));
        aBcl[l].setWriter(oConn, oLog.getStringNull(4,l,null));
      } // next
    } // fi
    return aBcl;
  } // changeLog
View Full Code Here

   * @since 3.0
   */
  public BugChangeLog[] changeLog(JDCConnection oConn, String sColumnName)
    throws SQLException {
    BugChangeLog[] aBcl;
    DBSubset oLog = new DBSubset(DB.k_bugs_changelog,
                                 DB.gu_bug+","+DB.pg_bug+","+DB.nm_column+","+DB.dt_modified+","+DB.gu_writer+","+DB.tx_oldvalue,
                                 DB.gu_bug+"=? AND "+DB.nm_column+"=? ORDER BY 4", 10);
    int iLog = oLog.load(oConn, new Object[]{getString(DB.gu_bug), sColumnName});
    if (0==iLog) {
      aBcl = null;
    } else {
      aBcl = new BugChangeLog[iLog];
      for (int l=0; l<iLog; l++) {
        aBcl[l] = new BugChangeLog();
        aBcl[l].putAll(oLog.getRowAsMap(l));
        aBcl[l].setWriter(oConn, oLog.getStringNull(4,l,null));
      } // next
    } // fi
    return aBcl;
  } // changeLog
View Full Code Here

   * @since 3.0
   */
  public BugTrack[] getTrack(JDCConnection oConn)
    throws SQLException {
    BugTrack[] aTrk;
    DBSubset oTrk = new DBSubset(DB.k_bugs_track,
                                 DB.gu_bug+","+DB.pg_bug_track+","+DB.dt_created+","+DB.nm_reporter+","+DB.tx_rep_mail+","+DB.gu_writer+","+DB.tx_bug_track,
                                 DB.gu_bug+"=? ORDER BY 2 DESC", 20);
    int iTrk = oTrk.load(oConn, new Object[]{getString(DB.gu_bug)});
    if (0==iTrk) {
      aTrk = null;
    } else {
      aTrk = new BugTrack[iTrk];
      for (int l=0; l<iTrk; l++) {
        aTrk[l] = new BugTrack();
        aTrk[l].putAll(oTrk.getRowAsMap(l));
      } // next
    } // fi
    return aTrk;
  } // getTrack
View Full Code Here

    * <tr><td>Quotation GUID</td><td>Line Number</td><td>Product GUID</td><td>Product Name</td><td>Sale Price</td><td>Quantity Ordered</td><td>Unit for quantity</td><td>Total Price</td><td>% of Tax Rate</td><td>1 if tax included</td><td>Promotion Text</td><td>Additional Options</td><td>GUID of ordered item</td></tr>
    * </table>
    * @throws SQLException
    */
  public DBSubset getLines(JDCConnection oConn) throws SQLException {
     oLines = new DBSubset(DB.k_quotation_lines,
                           DB.gu_quotation + "," + DB.pg_line + "," +
                           DB.gu_product + "," + DB.nm_product + "," +
                           DB.pr_sale + "," + DB.nu_quantity + "," +
                           DB.id_unit + "," + DB.pr_total + "," +
                           DB.pct_tax_rate + "," + DB.is_tax_included + "," +
                           DB.tx_promotion + "," + DB.tx_options + "," +
                           DB.gu_item + ", '' AS " + DB.id_ref,
                           DB.gu_quotation + "=? ORDER BY 2", 10);

     oLines.load(oConn, new Object[]{getString(DB.gu_order)});
    
   DBSubset oProdDetail = new DBSubset (DB.k_products+" p"+","+DB.k_quotation_lines+" l",
                       "p."+DB.gu_product+",p."+DB.id_ref,
                       "p."+DB.gu_product+"=l."+DB.gu_product+" AND "+
                       "p."+DB.gu_owner+"=? AND "+
                       "l."+DB.gu_quotation + "=?", 50);
    
     int nProdCount = oProdDetail.load(oConn, new Object[]{getString(DB.gu_workarea),getString(DB.gu_quotation)});
    
     for (int p=0; p<nProdCount; p++) {
       int l = oLines.find(9, oProdDetail.get(0,p));
       if (!oProdDetail.isNull(1,p)) {
         oLines.setElementAt(oProdDetail.get(1,p),13,l);
       }
     } // next
    
     return oLines;
   } // getLines
View Full Code Here

TOP

Related Classes of com.knowgate.dataobjs.DBSubset

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.