Package com.knowgate.dataobjs

Examples of com.knowgate.dataobjs.DBSubset


   * @return List of fare identifiers (id_fare column)
   * @throws SQLException
   * @since 4.0
   */
    public static List forWorkArea(JDCConnection oConn, String sGuWorkArea) throws SQLException {
    DBSubset oDbs = new DBSubset(DB.k_prod_fares_lookup, DB.vl_lookup,
                     DB.id_section+"='"+DB.id_fare+"' AND "+DB.gu_owner+"=? ORDER BY 1", 10);
      oDbs.load(oConn, new Object[]{sGuWorkArea});
      return oDbs.getColumnAsList(0);
    }
View Full Code Here


   */

  public DBSubset loadAtoms(JDCConnection oConn, int iWorkerThreads) throws SQLException {

    PreparedStatement oJobStmt;
    DBSubset  oJobsSet;
    int iJobCount;
    Properties oParams;
    DistributionList oDistribList;
    Date dtNow = new Date();
    Date dtExec;
    String sSQL;
    int iLoaded = 0;

    if (DebugFile.trace) {
       DebugFile.writeln("Begin AtomFeeder.loadAtoms([Connection], " + String.valueOf(iWorkerThreads) + ")");
       DebugFile.incIdent();
     }

    // Crea un DBSubset para recorrer los jobs pendientes de ejecución

    oJobsSet = new DBSubset(DB.k_jobs,
                            "gu_job,gu_job_group,gu_workarea,id_command,tx_parameters,id_status,dt_execution,dt_finished,dt_created,dt_modified",
                            DB.id_status + "=" + String.valueOf(Job.STATUS_PENDING) + " ORDER BY " +
                            DB.id_status + " DESC," + DB.dt_execution + " DESC", iWorkerThreads);

    oJobsSet.setMaxRows(iWorkerThreads);

    iJobCount = oJobsSet.load(oConn); // Devuelve la cuenta de jobs pendientes

    // Prepara la sentencia para actualizar el estado de los jobs a Running
    sSQL = "UPDATE " + DB.k_jobs + " SET " + DB.id_status + "=" + String.valueOf(Job.STATUS_RUNNING) + "," + DB.dt_execution + "=" + DBBind.Functions.GETDATE + " WHERE " + DB.gu_job + "=?";

    if (DebugFile.trace) DebugFile.writeln("Connection.prepareStatement(" + sSQL + ")");

    oJobStmt = oConn.prepareStatement(sSQL);

    // Para cada job, cargar su lista de miembros del tipo que corresponda y
    // cambiar el estado a Running
    for (int j=0; j<iJobCount; j++) {
      // leer los parámetros adicionales del job del campo tx_parameters
      oParams = parseParameters(oJobsSet.getString(4, j));

      // Generar un objeto temporal de tipo lista de distribución
      // para leer los valores de la lista de miembros
      if (oParams.getProperty("gu_list")!=null) {
        oDistribList = new DistributionList(oConn, oParams.getProperty("gu_list"));

        // Si la fecha de ejecución del job es null,
        // tomar la fecha actual como fecha de ejecución inmediata
        if (oJobsSet.isNull(DB.dt_execution,j))
          dtExec = dtNow;
        else
          dtExec = oJobsSet.getDate(DB.dt_execution,j);

        // Para cada tipo de lista usar el método de carga de miembros que corresponda
        switch (oDistribList.getShort(DB.tp_list)) {
          case DistributionList.TYPE_DYNAMIC:
            iLoaded += loadDynamicList(oConn, oJobsSet.getString(0, j), dtExec, oParams.getProperty("gu_list"), oDistribList.getString(DB.gu_query), oDistribList.getString(DB.gu_workarea), Atom.STATUS_PENDING);
            break;
          case DistributionList.TYPE_STATIC:
            iLoaded += loadStaticList(oConn, oJobsSet.getString(0, j), dtExec, oParams.getProperty("gu_list"), Atom.STATUS_PENDING);
            break;
          case DistributionList.TYPE_DIRECT:
            iLoaded += loadDirectList(oConn, oJobsSet.getString(0, j), dtExec, oParams.getProperty("gu_list"), Atom.STATUS_PENDING);
            break;
        } // end switch()
      }
      else
        iLoaded = 0;

      // Cambiar el estado del job cargado de Pending a Running

      if (DebugFile.trace) DebugFile.writeln("PrepareStatement.setString(1, '" + oJobsSet.getStringNull(0, j, "") + "')");

      oJobStmt.setString (1, oJobsSet.getString(0, j));

      if (DebugFile.trace) DebugFile.writeln("PrepareStatement.executeUpdate()");

      oJobStmt.executeUpdate();
    } // next (j)

    if (DebugFile.trace) DebugFile.writeln("PrepareStatement.close()");

    oJobStmt.close();

    if (DebugFile.trace) {
       DebugFile.decIdent();
       DebugFile.writeln("End AtomFeeder.loadAtoms() : " + String.valueOf(oJobsSet.getRowCount()));
     }

     return oJobsSet;
  } // loadAtoms()
View Full Code Here

  public DBSubset loadAtoms(JDCConnection oConn, String sJobId, short iInitialStatus) throws SQLException {
    PreparedStatement oCmdsStmt;
    PreparedStatement oJobStmt;
    ResultSet oCmdsSet;
    DBSubset  oJobsSet;
    int iJobCount;
    String aParams[];
    String aVariable[];
    Properties oParams;
    DistributionList oDistribList;
    Date dtNow = new Date();
    Date dtExec;
    String sSQL;
    int iLoaded = 0;

    if (DebugFile.trace) {
       DebugFile.writeln("Begin AtomFeeder.loadAtoms([Connection:"+oConn.pid()+"], " + sJobId + ")");
       DebugFile.incIdent();
     }

    // Crea un DBSubset para recorrer los jobs pendientes de ejecución

    oJobsSet = new DBSubset(DB.k_jobs,
                            "gu_job,gu_job_group,gu_workarea,id_command,tx_parameters,id_status,dt_execution,dt_finished,dt_created,dt_modified",
                            DB.gu_job + "='" + sJobId + "'", 1);


    iJobCount = oJobsSet.load(oConn); // Devuelve la cuenta de jobs pendientes

    // Prepara la sentencia para actualizar el estado de los jobs a Running
    sSQL = "UPDATE " + DB.k_jobs + " SET " + DB.id_status + "=" + String.valueOf(Job.STATUS_RUNNING) + "," + DB.dt_execution + "=" + DBBind.Functions.GETDATE + " WHERE " + DB.gu_job + "=?";

    if (DebugFile.trace) DebugFile.writeln("Connection.prepareStatement(" + sSQL + ") on connection with process id. "+oConn.pid());

    oJobStmt = oConn.prepareStatement(sSQL);

    // Para cada job, cargar su lista de miembros del tipo que corresponda y
    // cambiar el estado a Running
    if (1==iJobCount) {
      // leer los parámetros adicionales del job del campo tx_parameters
      oParams = parseParameters(oJobsSet.getString(4, 0));

      // Generar un objeto temporal de tipo lista de distribución
      // para leer los valores de la lista de miembros
      if (oParams.getProperty("gu_list")!=null) {
        oDistribList = new DistributionList(oConn, oParams.getProperty("gu_list"));

        // Si la fecha de ejecución del job es null,
        // tomar la fecha actual como fecha de ejecución inmediata
        if (oJobsSet.isNull(DB.dt_execution,0))
          dtExec = dtNow;
        else
          dtExec = oJobsSet.getDate(DB.dt_execution,0);

        // Para cada tipo de lista usar el método de carga de miembros que corresponda
        switch (oDistribList.getShort(DB.tp_list)) {
          case DistributionList.TYPE_DYNAMIC:
            iLoaded += loadDynamicList(oConn, oJobsSet.getString(0, 0), dtExec, oParams.getProperty("gu_list"), oDistribList.getString(DB.gu_query), oDistribList.getString(DB.gu_workarea), iInitialStatus);
            break;
          case DistributionList.TYPE_STATIC:
            iLoaded += loadStaticList(oConn, oJobsSet.getString(0, 0), dtExec, oParams.getProperty("gu_list"), iInitialStatus);
            break;
          case DistributionList.TYPE_DIRECT:
            iLoaded += loadDirectList(oConn, oJobsSet.getString(0, 0), dtExec, oParams.getProperty("gu_list"), iInitialStatus);
            break;
        } // end switch()
      }
      else
        iLoaded = 0;

      // Cambiar el estado del job cargado de Pending a Running

      if (DebugFile.trace) DebugFile.writeln("PrepareStatement.setString(1, '" + oJobsSet.getStringNull(0, 0, "") + "')");

      oJobStmt.setString (1, oJobsSet.getString(0, 0));

      if (DebugFile.trace) DebugFile.writeln("PrepareStatement.executeUpdate()");

      oJobStmt.executeUpdate();
    } // fi
View Full Code Here

    } // next (c)

    oRSet.close();
    oStmt.close();

    DBSubset oAddrs = new DBSubset(DB.k_addresses + " a," + DB.k_x_company_addr + " x",
                                   oColumnList.toString(), "a." + DB.gu_address + "=x." + DB.gu_address + " AND x." + DB.gu_company + "=? ORDER BY a." + DB.ix_address, 10);

    oAddrs.load(oConn, new Object[]{sCompanyGUID});

    String sAddresses = "\n  <company>" + sCompanyGUID + "</company>\n  <catalog>" + sCategoryGUID + "</catalog>\n  <addresses>\n" + oAddrs.toXML("    ", "address") + "\n  </addresses>";

    try { oXMLDoc.removeNode("pageset/company"); }
    catch (DOMException dome) {
      if (dome.code!=DOMException.NOT_FOUND_ERR) throw new DOMException(dome.code, dome.getMessage());
    }
View Full Code Here

       int iSkp;
       if (null==sSkp)
         iSkp = 0;
       else
         iSkp = Integer.parseInt(sSkp);
       DBSubset oDbs = new DBSubset (sTbl, sFld, sWhr, iMax);
       if (null!=sRow) oDbs.setRowDelimiter(sRow);
       if (null!=sCol) oDbs.setColumnDelimiter(sCol);
       oDbs.setMaxRows(iMax);
       try {
         oCon = oBnd.getConnection("HttpDataObjsServlet");
         if (null==oCon) {
           if (DebugFile.trace) DebugFile.decIdent();
           throw new ServletException("ERROR Unable to get database connection from pool "+sDbb);
         }
         if (oBnd.exists(oCon, DB.k_users, "U")) {
           if (Gadgets.checkEMail(sUsr)) {
             sUsr = ACLUser.getIdFromEmail(oCon, sUsr);
             if (null==sUsr)
               iAuth = ACL.USER_NOT_FOUND;
             else
               iAuth = ACL.autenticate(oCon, sUsr, sPwd, ACL.PWD_CLEAR_TEXT);
           } else {
             iAuth = ACL.autenticate(oCon, sUsr, sPwd, ACL.PWD_CLEAR_TEXT);
           }
         } else {
           iAuth = 0;
         } // fi (exists k_users)
         if (iAuth<0) {
           response.sendError(HttpServletResponse.SC_FORBIDDEN, ACL.getErrorMessage(iAuth));
         } else {
           oDbs.load(oCon, iSkp);
           response.setContentType("text/plain");
           response.setCharacterEncoding("UTF-8");
           response.getOutputStream().write(oDbs.toString().getBytes("UTF-8"));             
         }
         oCon.close("HttpDataObjsServlet");
         oCon = null;
       } catch (SQLException sqle) {
         if (null!=oCon) {
View Full Code Here

   * @throws SQLException
   * @see {@link Address}
   */
  public DBSubset getAddresses(JDCConnection oConn) throws SQLException {
    Object aUser[] = { get(DB.gu_user) };
    oAddresses = new DBSubset(DB.k_x_addr_user,DB.gu_address + "," + DB.ix_address + "," + DB.tp_location, DB.gu_user + "=?",10);

    oAddresses.load (oConn, aUser);
    return oAddresses;
  }
View Full Code Here

   * @return A {@link DBSubset} with a 1 column containing each group unique identifier (gu_acl_group).
   * @throws SQLException
   */
  public DBSubset getGroups(JDCConnection oConn) throws SQLException {
    Object aUser[] = { get(DB.gu_user) };
    oGroups = new DBSubset(DB.k_x_group_user,DB.gu_acl_group,DB.gu_user + "=?",10);

    oGroups.load (oConn, aUser);
    return oGroups;
  }
View Full Code Here

   * @since 4.0
   */
  public String[] getMailFolders (JDCConnection oConn)
    throws SQLException {
   
    DBSubset oCats = new DBSubset (DB.k_categories+" c, "+DB.k_cat_tree+" t",
                       DB.gu_category,
                       "c."+DB.gu_category+"=t."+DB.gu_child_cat+" AND t."+DB.gu_parent_cat+"=?", 10);
  int iCats = oCats.load(oConn, new Object[]{getMailRoot(oConn)});
  String[] aRetVal = new String[iCats];
  for (int c=0; c<iCats; c++) aRetVal[c] = oCats.getString(0,c);
  return aRetVal;
  } // getMailFolders
View Full Code Here

   * @since 4.0
   */
  public String[] getMailFolderNames (JDCConnection oConn)
    throws SQLException {
   
    DBSubset oCats = new DBSubset (DB.k_categories+" c, "+DB.k_cat_tree+" t",
                       DB.nm_category,
                       "c."+DB.gu_category+"=t."+DB.gu_child_cat+" AND t."+DB.gu_parent_cat+"=?", 10);
  int iCats = oCats.load(oConn, new Object[]{getMailRoot(oConn)});
  String[] aRetVal = new String[iCats];
  for (int c=0; c<iCats; c++) aRetVal[c] = oCats.getString(0,c);
  return aRetVal;
  } // getMailFolderNames
View Full Code Here

   */

  public static boolean delete(JDCConnection oConn, String sUserGUID) throws SQLException,IOException {
    boolean bRetVal;
    int iCats, iConts, iMsgs;
    DBSubset oCats, oProds, oConts, oMsgs;
    Statement oStmt;
    PreparedStatement oPtmt;
    ResultSet oRSet;
    CallableStatement oCall;

    if (DebugFile.trace) {
      DebugFile.writeln("Begin ACLUser.delete([Connection], " + sUserGUID + ")");
      DebugFile.incIdent();
    }

    // -----------------------------------------------------------------------------------
    // Verify that user exists before proceeding and, also, avoid deleting more registers
    // than should by a malicious inyection of SQL code at sUserGUID

    oPtmt = oConn.prepareStatement("SELECT "+DB.gu_user+" FROM "+DB.k_users+" WHERE "+DB.gu_user+"=?",
                                   ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
    oPtmt.setString(1, sUserGUID);
    oRSet = oPtmt.executeQuery();
    boolean bExists = oRSet.next();
    oRSet.close();
    oPtmt.close();

    if (!bExists) {
      if (DebugFile.trace) {
        DebugFile.writeln("user " + sUserGUID + " not found");
        DebugFile.decIdent();
        DebugFile.writeln("End ACLUser.delete() : false");
      }
      return false;
    }

    // ************
    // New for v5.0

    if (DBBind.exists(oConn, DB.k_activities, "U")) {
      oStmt = oConn.createStatement();
      oStmt.executeUpdate("UPDATE "+DB.k_x_activity_audience+" SET "+DB.gu_writer+"=NULL WHERE "+DB.gu_writer+"='"+sUserGUID+"'");
      oStmt.executeUpdate("UPDATE "+DB.k_activities+" SET "+DB.gu_writer+"=NULL WHERE "+DB.gu_writer+"='"+sUserGUID+"'");
    oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_sms_audit, "U")) {
      oStmt = oConn.createStatement();
      oStmt.executeUpdate("UPDATE "+DB.k_sms_audit+" SET "+DB.gu_writer+"=NULL WHERE "+DB.gu_writer+"='"+sUserGUID+"'");
    oStmt.close();
    }

    // End new for v5.0
    // ****************

    // ************
    // New for v4.0

    if (DBBind.exists(oConn, DB.k_working_calendar, "U")) {
      oStmt = oConn.createStatement();
      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_working_time + " WHERE " + DB.gu_calendar + " IN (SELECT " + DB.gu_calendar + " FROM " + DB.k_working_calendar + " WHERE " + DB.gu_user + "='" + sUserGUID + "'))");
      oStmt.executeUpdate("DELETE FROM " + DB.k_working_time + " WHERE " + DB.gu_calendar + " IN (SELECT " + DB.gu_calendar + " FROM " + DB.k_working_calendar + " WHERE " + DB.gu_user + "='" + sUserGUID + "')");
      oStmt.close();
      oStmt = oConn.createStatement();
      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_working_calendar + " WHERE " + DB.gu_user + "='" + sUserGUID + "')");
      oStmt.executeUpdate("DELETE FROM " + DB.k_working_calendar + " WHERE " + DB.gu_user + "='" + sUserGUID + "'");
      oStmt.close();
    }

    // ************
    // New for v3.0

    if (DBBind.exists(oConn, DB.k_user_pwd, "U")) {
      oStmt = oConn.createStatement();
      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_x_cat_objs + " WHERE " + DB.gu_object + " IN (SELECT "+DB.gu_pwd+" FROM "+DB.k_user_pwd+" WHERE " + DB.gu_user + "='" + sUserGUID + "'))");
      oStmt.executeUpdate("DELETE FROM " + DB.k_x_cat_objs + " WHERE " + DB.gu_object + " IN (SELECT "+DB.gu_pwd+" FROM "+DB.k_user_pwd+" WHERE " + DB.gu_user + "='" + sUserGUID + "')");
      oStmt.close();

      oStmt = oConn.createStatement();
      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_user_pwd + " WHERE " + DB.gu_user + "='" + sUserGUID + "')");
      oStmt.executeUpdate("DELETE FROM " + DB.k_user_pwd + " WHERE " + DB.gu_user + "='" + sUserGUID + "'");
      oStmt.close();
    } // fi

    if (DBBind.exists(oConn, DB.k_user_mail, "U")) {
      oStmt = oConn.createStatement();
      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_user_mail + " WHERE " + DB.gu_user + "='" + sUserGUID + "')");
      oStmt.executeUpdate("DELETE FROM " + DB.k_user_mail + " WHERE " + DB.gu_user + "='" + sUserGUID + "'");
      oStmt.close();
    }

    /* Actualizar los estados de negocio creados por el usuario */
    if (DBBind.exists(oConn, DB.k_business_states, "U")) {
      oStmt = oConn.createStatement();
      if (DebugFile.trace)
        DebugFile.writeln("UPDATE " + DB.k_business_states + " SET " + DB.gu_writer + "=NULL WHERE " + DB.gu_writer + "='" + sUserGUID + "'");
      oStmt.executeUpdate("UPDATE " + DB.k_business_states + " SET " + DB.gu_writer + "=NULL WHERE " + DB.gu_writer + "='" + sUserGUID + "'");
      oStmt.close();
    }

    /* Borrar la referencia este usuario desde los cuestionarios que haya rellenado */
    if (DBBind.exists(oConn, DB.k_pageset_answers, "U")) {
      oStmt = oConn.createStatement();
      if (DebugFile.trace)
        DebugFile.writeln("UPDATE " + DB.k_pageset_answers + " SET " + DB.gu_writer + "=NULL WHERE " + DB.gu_writer + "='" + sUserGUID + "'");
      oStmt.executeUpdate("UPDATE " + DB.k_pageset_answers + " SET " + DB.gu_writer + "=NULL WHERE " + DB.gu_writer + "='" + sUserGUID + "'");
      oStmt.close();
    }

    /* Desasociar las evaluaciones */
    if (DBBind.exists(oConn, DB.k_evaluations, "U")) {
      oStmt = oConn.createStatement();
      if (DebugFile.trace)
        DebugFile.writeln("UPDATE " + DB.k_evaluations + " SET " + DB.gu_writer + "=NULL WHERE " + DB.gu_writer + "='" + sUserGUID + "'");
      oStmt.executeUpdate("UPDATE " + DB.k_evaluations + " SET " + DB.gu_writer + "=NULL WHERE " + DB.gu_writer + "='" + sUserGUID + "'");
      oStmt.close();
    }

    /* Desasociar los partes de absentismo */
    if (DBBind.exists(oConn, DB.k_absentisms, "U")) {
      oStmt = oConn.createStatement();
      if (DebugFile.trace)
        DebugFile.writeln("UPDATE " + DB.k_absentisms + " SET " + DB.gu_writer + "=NULL WHERE " + DB.gu_writer + "='" + sUserGUID + "'");
      oStmt.executeUpdate("UPDATE " + DB.k_absentisms + " SET " + DB.gu_writer + "=NULL WHERE " + DB.gu_writer + "='" + sUserGUID + "'");
      oStmt.close();
    }

    // End new for v3.0
    // ****************

    // ************
    // New for v6.0

    /* Eliminar los permisos sobre cursos */
    if (DBBind.exists(oConn, DB.k_x_user_acourse, "U")) {
      oStmt = oConn.createStatement();
      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_x_user_acourse + " WHERE " + DB.gu_user + "='" + sUserGUID + "')");
      oStmt.executeUpdate("DELETE FROM " + DB.k_x_user_acourse + " WHERE " + DB.gu_user + "='" + sUserGUID + "'");
      oStmt.close();
    }

    // End new for v6.0
    // ****************

    // ************
    // New for v2.1

    /* Desasociar los e-mails */
    if (DBBind.exists(oConn, DB.k_inet_addrs, "U")) {
      oStmt = oConn.createStatement();

      if (DebugFile.trace)
        DebugFile.writeln("UPDATE " + DB.k_inet_addrs + " SET " + DB.gu_user + "=NULL WHERE " + DB.gu_user + "='" + sUserGUID + "'");

      oStmt.executeUpdate("UPDATE " + DB.k_inet_addrs + " SET " + DB.gu_user + "=NULL WHERE " + DB.gu_user + "='" + sUserGUID + "'");

      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_x_portlet_user, "U")) {
      oStmt = oConn.createStatement();

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_x_portlet_user + " WHERE " + DB.gu_user + "='" + sUserGUID + "')");

      oStmt.executeUpdate("DELETE FROM " + DB.k_x_portlet_user + " WHERE " + DB.gu_user + "='" + sUserGUID + "'");

      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_images, "U")) {

      oStmt = oConn.createStatement();

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(UPDATE " + DB.k_images + " SET " + DB.gu_writer + "=NULL WHERE " + DB.gu_writer + "='" + sUserGUID + "')");

      oStmt.executeUpdate("UPDATE " + DB.k_images + " SET "  + DB.gu_writer + "=NULL WHERE " + DB.gu_writer + "='" + sUserGUID + "'");

      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_bugs_lookup, "U")) {

      oStmt = oConn.createStatement();

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(UPDATE " + DB.k_bugs + " SET "  + DB.nm_assigned + "=NULL WHERE " + DB.nm_assigned + "='" + sUserGUID + "')");

      oStmt.executeUpdate("UPDATE " + DB.k_bugs + " SET "  + DB.nm_assigned + "=NULL WHERE " + DB.nm_assigned + "='" + sUserGUID + "'");

      oStmt.close();

      oStmt = oConn.createStatement();

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_bugs_lookup + " WHERE " + DB.vl_lookup + "='" + sUserGUID + "')");

      oStmt.executeUpdate("DELETE FROM " + DB.k_bugs_lookup + " WHERE " + DB.vl_lookup + "='" + sUserGUID + "'");

      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_x_duty_resource, "U")) {
      oStmt = oConn.createStatement();

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_x_duty_resource + " WHERE " + DB.nm_resource + "='" + sUserGUID + "')");

      oStmt.executeUpdate("DELETE FROM " + DB.k_x_duty_resource + " WHERE " + DB.nm_resource + "='" + sUserGUID + "'");

      oStmt.close();

      oStmt = oConn.createStatement();

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_duties_lookup + " WHERE " + DB.vl_lookup + "='" + sUserGUID + "')");

      oStmt.executeUpdate("DELETE FROM " + DB.k_duties_lookup + " WHERE " + DB.vl_lookup + "='" + sUserGUID + "'");

      oStmt.close();
    }

    // End new for v2.1
    // ****************

    // ************
    // New for v4.0

    oStmt = oConn.createStatement();
    if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(UPDATE " + DB.k_duties + " SET " + DB.gu_writer + "=NULL WHERE "+ DB.gu_writer + "='" + sUserGUID + "')");
    oStmt.executeUpdate("UPDATE " + DB.k_duties + " SET " + DB.gu_writer + "=NULL WHERE "+ DB.gu_writer + "='" + sUserGUID + "'");
    oStmt.close();

    // End new for v4.0
    // ****************

    // ************
    // New for v2.0

    if (DBBind.exists(oConn, DB.k_newsgroup_subscriptions, "U")) {
      oStmt = oConn.createStatement();

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_newsgroup_subscriptions + " WHERE " + DB.gu_user + "='" + sUserGUID + "')");

      oStmt.executeUpdate("DELETE FROM " + DB.k_newsgroup_subscriptions + " WHERE " + DB.gu_user + "='" + sUserGUID + "'");

      oStmt.close();
    }

    // End new for v2.0
    // ****************

    if (DBBind.exists(oConn, DB.k_newsmsgs, "U")) {
      oStmt = oConn.createStatement();

      // Remove user GUID from messages he validated
      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(UPDATE " + DB.k_newsmsgs + " SET " + DB.gu_validator + "=NULL WHERE " + DB.gu_validator + "='" + sUserGUID + "'");

      oStmt.executeUpdate("UPDATE " + DB.k_newsmsgs + " SET " + DB.gu_validator + "=NULL WHERE " + DB.gu_validator + "='" + sUserGUID + "'");

      // Delete forum messages written by this user without file attachments
      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_newsmsgs + " WHERE " + DB.gu_writer + "='" + sUserGUID + "' AND " + DB.gu_product + " IS NULL");

      oStmt.executeUpdate("DELETE FROM " + DB.k_newsmsgs + " WHERE " + DB.gu_writer + "='" + sUserGUID + "' AND " + DB.gu_product + " IS NULL");

      oStmt.close();

      // Delete forum messages written by this user with file attachments
      oMsgs = new DBSubset(DB.k_newsmsgs, DB.gu_msg, DB.gu_writer + "='" + sUserGUID + "'", 100);

      iMsgs = oMsgs.load(oConn);

      for (int m=0; m<iMsgs; m++)
        com.knowgate.forums.NewsMessage.delete(oConn, oMsgs.getString(0,m));

      oMsgs = null;
    } // fi (exists(k_newsmsgs,))

    if (DBBind.exists(oConn, DB.k_member_address, "U")) {
      oStmt = oConn.createStatement();

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(UPDATE " + DB.k_member_address + " SET " + DB.gu_writer + "=NULL WHERE " + DB.gu_writer + "='" + sUserGUID + "')");

      oStmt.executeUpdate("UPDATE " + DB.k_member_address + " SET " + DB.gu_writer + "=NULL WHERE " + DB.gu_writer + "='" + sUserGUID + "'");

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(UPDATE " + DB.k_member_address + " SET " + DB.gu_sales_man + "=NULL WHERE " + DB.gu_sales_man + "='" + sUserGUID + "')");

      oStmt.executeUpdate("UPDATE " + DB.k_member_address + " SET " + DB.gu_sales_man + "=NULL WHERE " + DB.gu_sales_man + "='" + sUserGUID + "'");

      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_companies_recent, "U")) {
      oStmt = oConn.createStatement();

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_companies_recent + " WHERE " + DB.gu_user + "='" + sUserGUID + "')");

      oStmt.executeUpdate("DELETE FROM " + DB.k_companies_recent + " WHERE " + DB.gu_user + "='" + sUserGUID + "'");

      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_companies, "U")) {
      oStmt = oConn.createStatement();

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(UPDATE " + DB.k_companies + " SET " + DB.gu_sales_man + "=NULL WHERE " + DB.gu_sales_man + "='" + sUserGUID + "')");

      oStmt.executeUpdate("UPDATE " + DB.k_companies + " SET " + DB.gu_sales_man + "=NULL WHERE " + DB.gu_sales_man + "='" + sUserGUID + "'");

      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_contacts_recent, "U")) {
      oStmt = oConn.createStatement();

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_contacts_recent + " WHERE " + DB.gu_user + "='" + sUserGUID + "')");

      oStmt.executeUpdate("DELETE FROM " + DB.k_contacts_recent + " WHERE " + DB.gu_user + "='" + sUserGUID + "'");

      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_contacts, "U")) {
      oConts = new DBSubset(DB.k_contacts, DB.gu_contact, DB.gu_writer + "='" + sUserGUID + "' AND " + DB.bo_private + "<>0", 100);
      iConts = oConts.load(oConn);

      for (int t=0; t<iConts; t++)
         com.knowgate.crm.Contact.delete(oConn, oConts.getString(0,t));

      oConts = null;

      oStmt = oConn.createStatement();

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(UPDATE " + DB.k_contacts + " SET " + DB.gu_writer + "=NULL WHERE " + DB.gu_writer + "='" + sUserGUID + "' AND " + DB.bo_private + "=0)");

      oStmt.executeUpdate("UPDATE " + DB.k_contacts + " SET " + DB.gu_writer + "=NULL WHERE " + DB.gu_writer + "='" + sUserGUID + "' AND " + DB.bo_private + "=0");

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(UPDATE " + DB.k_contact_notes + " SET " + DB.gu_writer + "=NULL WHERE " + DB.gu_writer + "='" + sUserGUID + "')");

      oStmt.executeUpdate("UPDATE " + DB.k_contact_notes + " SET " + DB.gu_writer + "=NULL WHERE " + DB.gu_writer + "='" + sUserGUID + "'");

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(UPDATE " + DB.k_contact_attachs + " SET " + DB.gu_writer + "=NULL WHERE " + DB.gu_writer + "='" + sUserGUID + "')");

      oStmt.executeUpdate("UPDATE " + DB.k_contact_attachs + " SET " + DB.gu_writer + "=NULL WHERE " + DB.gu_writer + "='" + sUserGUID + "'");

      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_oportunities, "U")) {
      oStmt = oConn.createStatement();

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_oportunities + " WHERE " + DB.gu_writer + "='" + sUserGUID + "' AND " + DB.bo_private + "<>0)");

      oStmt.executeUpdate("DELETE FROM " + DB.k_oportunities + " WHERE " + DB.gu_writer + "='" + sUserGUID + "' AND " + DB.bo_private + "<>0");

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(UPDATE " + DB.k_oportunities + " SET " + DB.gu_writer + "=NULL WHERE " + DB.gu_writer + "='" + sUserGUID + "' AND " + DB.bo_private + "=0)");

      oStmt.executeUpdate("UPDATE " + DB.k_oportunities + " SET " + DB.gu_writer + "=NULL WHERE " + DB.gu_writer + "='" + sUserGUID + "' AND " + DB.bo_private + "=0");

      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_sales_men, "U")) {
       if (DebugFile.trace) DebugFile.writeln("Connection.prepareCall({ call k_sp_del_sales_man ('" + sUserGUID + "') })");

       oCall = oConn.prepareCall("{call k_sp_del_sales_man ('" + sUserGUID + "')}");
       bRetVal = oCall.execute();
       oCall.close();
     }

    if (DBBind.exists(oConn, DB.k_products, "U")) {
      oProds = new DBSubset(DB.k_products, DB.gu_product, DB.gu_owner + "='" + sUserGUID + "'", 100);
      int iProds = oProds.load(oConn);

      for (int p=0; p<iProds; p++)
        new com.knowgate.hipergate.Product(oConn, oProds.getString(0, p)).delete(oConn);
      oProds = null;
    } // fi (exists(DB.k_products))

    // Delete categories associated with user
    if (DBBind.exists(oConn, DB.k_categories, "U")) {
      String sGuRootCat = null;
      oStmt = oConn.createStatement();
      ResultSet oRCat = oStmt.executeQuery("SELECT " + DB.gu_category + " FROM " + DB.k_users + " WHERE " + DB.gu_user + "='" + sUserGUID + "'");
      if (oRCat.next())
        sGuRootCat = oRCat.getString(1);
      oRCat.close();
      oStmt.close();
      if (sGuRootCat!=null) {
        oStmt = oConn.createStatement();
        oStmt.executeUpdate("UPDATE " + DB.k_users + " SET " + DB.gu_category + "=NULL WHERE " + DB.gu_user + "='" + sUserGUID + "'");
        oStmt.close();
        Category.delete(oConn, sGuRootCat);
      }

      oCats = new DBSubset(DB.k_categories, DB.gu_category, DB.gu_owner + "=?", 10);
      iCats = oCats.load(oConn, new Object[]{sUserGUID});

      for (int r=0; r<iCats; r++)
         Category.delete(oConn, oCats.getString(0,r));

      oCats = null;
    } // fi (exists(oConn, DB.k_categories))

    if (DBBind.exists(oConn, DB.k_phone_calls, "U")) {
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.