コード例 #1
0
ファイル: CoreCfg.java プロジェクト: jmulet/pdaweb
  // Stuff from database
  // DefaultConstructor
  public CoreCfg() {
    actions = new ArrayList<String>();

    // Read information from WEBXML PARAMS
    core_mysqlHost = (String) FacesUtil.getWebXmlParam("pdaweb.mysqlHost");
    core_mysqlDBPrefix = (String) FacesUtil.getWebXmlParam("pdaweb.mysqlDBPrefix");
    core_mysqlUser = (String) FacesUtil.getWebXmlParam("pdaweb.mysqlUser");
    core_mysqlParams =
        StringUtils.noNull((String) FacesUtil.getWebXmlParam("pdaweb.mysqlParams"))
            .replaceAll("$", "&");
    String tmp = (String) FacesUtil.getWebXmlParam("pdaweb.mysqlPwd");
    tmp = StringUtils.noNull(tmp).trim();
    core_mysqlPasswd = tmp;
    osName = System.getProperty("os.name");

    // Initialize main database it is initialized with the PREFIX database name
    // Then we switch to the current year using setCatalog(dbThisYear);
    startFitxesDB();

    // And constructs the configMap from database
    // This has been updated since now reads info from the PREFIX database
    // and not from year to year
    readDatabaseCfg();

    lastLogins = new ArrayList<String>();

    initializeSGD();
  }
コード例 #2
0
 public void setPeriods(String cmds) {
   if (cmds.trim().isEmpty()) {
     return;
   }
   ArrayList<String> list =
       StringUtils.parseStringToArray(cmds, ",", StringUtils.CASE_INSENSITIVE);
   listmodel1.removeAllElements();
   for (int i = 0; i < list.size(); i++) {
     String interval = list.get(i);
     // System.out.println("detectat::"+interval);
     String2Date s2d = new String2Date(interval);
     jDateChooser1.setDate(s2d.getInici());
     jCalendar1.setDate(s2d.date1);
     jDateChooser2.setDate(s2d.getFinal());
     listmodel1.addElement(
         new DataCtrl(s2d.getInici()).getDiaMesComplet()
             + " a "
             + new DataCtrl(s2d.getFinal()).getDiaMesComplet());
     updateEntry();
   }
   jList1.setSelectedIndex(0);
   if (listmodel1.getSize() > 1) {
     jButton2.setEnabled(true);
   }
 }
コード例 #3
0
  public String getAllPeriods() {

    String txt = "";
    if (esborra) {
      return txt;
    }

    for (int i = 0; i < listmodel1.size(); i++) {
      String item = (String) listmodel1.get(i);
      String date1 = StringUtils.BeforeFirst(item, "a").trim();
      String date2 = StringUtils.AfterFirst(item, "a").trim();
      if (date1.equals(date2)) {
        txt += date1 + ", ";
      } else {
        txt += item + ", ";
      }
    }

    return StringUtils.BeforeLast(txt, ",");
  }
コード例 #4
0
    public String2Date(String input) {
      String iniString = "";
      String finString = "";
      if (input.contains("a")) {
        iniString = StringUtils.BeforeFirst(input, "a").trim();
        finString = StringUtils.AfterFirst(input, "a").trim();
      } else {
        iniString = input.trim();
        finString = iniString;
      }
      SimpleDateFormat df = null;
      if (input.contains("-")) {
        df = new SimpleDateFormat("dd-MM-yyyy");
      } else {
        df = new SimpleDateFormat("dd/MM/yyyy");
      }

      try {
        date1 = df.parse(iniString);
        date2 = df.parse(finString);
      } catch (ParseException ex) {
        Logger.getLogger(PeriodSelect.class.getName()).log(Level.SEVERE, null, ex);
      }
    }
コード例 #5
0
ファイル: CoreCfg.java プロジェクト: jmulet/pdaweb
  /**
   * updated to read from the new common database Creates the map containing values of the
   * configuration table in db
   */
  public void readDatabaseCfg() {

    // Populate with default values (this is already done in  ICoreData
    //        configTableMap.put("anyIniciCurs", 2012);
    //        configTableMap.put("sgdDBPrefix", "curso");
    //        configTableMap.put("sgdUser", "root");
    //        configTableMap.put("sgdPasswd", "");
    //        configTableMap.put("sgdHost", "localhost");
    //        configTableMap.put("versionDB", "3.1");
    //        configTableMap.put("minVersion", "3.0");
    //        configTableMap.put("maxDiesAntelacio", 15);
    //        configTableMap.put("refreshTime", 360);
    //        configTableMap.put("adminPwd", "");
    //        configTableMap.put("allowWebAdmin", false);
    //        configTableMap.put("prefPwd", "");
    //        configTableMap.put("guardPwd", "");
    //        configTableMap.put("idObservAcumulAL", -1);
    //        configTableMap.put("pdawebSU", "");
    //        configTableMap.put("simbolCastigDimecres", "CD");
    //        configTableMap.put("sgdEnableLogger", false);
    //        configTableMap.put("simbolAmonLleu", "AL");
    //        configTableMap.put("simbolAmonLleuHist", "ALH");
    //        configTableMap.put("simbolAmonGreu", "AG");
    //        configTableMap.put("simbolExpulsio", "EX");
    //        configTableMap.put("hardJustificacio", false);
    //        configTableMap.put("enableRegSystemInfo", false);

    if (getMysql().isClosed()) {
      return;
    } // do nothing if there is no connection

    String SQL = "SELECT property, value, castTo FROM `" + core_mysqlDBPrefix + "`.configuracio";
    try {
      Statement st = getMysql().createStatement();
      ResultSet rs = getMysql().getResultSet(SQL, st);
      while (rs != null && rs.next()) {
        String str = StringUtils.noNull(rs.getString("value")).trim();
        Object obj;
        String type = StringUtils.noNull(rs.getString("castTo")).trim();
        if (type.equalsIgnoreCase("int")) {
          int parsed = Integer.parseInt(str);
          obj = new Integer(parsed);
        } else if (type.equalsIgnoreCase("Boolean")) {
          if (str.equalsIgnoreCase("true")
              || str.equalsIgnoreCase("yes")
              || str.equalsIgnoreCase("y")) {
            obj = true;
          } else {
            obj = false;
          }
        } else {
          obj = str;
        }

        configTableMap.put(rs.getString("property"), obj);
      }
      if (rs != null) {
        rs.close();
        st.close();
      }
    } catch (SQLException ex) {
      Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
    }

    // From now on choose the correct database as default
    if (configTableMap != null && configTableMap.containsKey("anyIniciCurs")) {

      // Create Alias for the most used variables

      coreDB_sgdHost = (String) configTableMap.get("sgdHost");
      coreDB_sgdUser = (String) configTableMap.get("sgdUser");
      coreDB_sgdPasswd = (String) configTableMap.get("sgdPasswd");
      coreDB_sgdParams = (String) configTableMap.get("sgdDBParams");
      coreDB_sgdDB =
          (String) configTableMap.get("sgdDBPrefix") + configTableMap.get("anyIniciCurs");
      core_pwdSU = (String) configTableMap.get("adminPwd");

      core_pwdPREF = (String) configTableMap.get("prefPwd");
      core_pwdGUARD = (String) configTableMap.get("guardPwd");

      int any = (Integer) configTableMap.get("anyIniciCurs");
      core_mysqlDB = core_mysqlDBPrefix + any;

      getMysql().setCatalog(core_mysqlDB);
      anyAcademic = any;
    }
  }
コード例 #6
0
ファイル: EsborraSig.java プロジェクト: jmulet/guardies-mod
  // ESBORRA
  private void jButton1ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed
    if (jCheckBox2.isSelected() && jTextField1.getText().length() == 0) {
      jTextField1.setFocusable(true);
      return;
    }

    DataCtrl cd = new DataCtrl(jDateChooser1.getDate());

    if (jCheckBox1.isSelected()) {

      // Confirmació
      int conf =
          JOptionPane.showConfirmDialog(
              this,
              "Estau a punt d'esborrar les "
                  + "signatures del dia "
                  + cd.getDiaMesComplet()
                  + "\nVoleu continuar?",
              "Confirmacio",
              JOptionPane.YES_NO_OPTION);

      if (conf != 0) {
        return;
      }

      // Tot el dia
      String SQL1 = "DELETE FROM sig_data where data='" + cd.getDataSQL() + "'";
      int nup = coreCfg.getMysql().executeUpdate(SQL1);
      jTextArea1.append("sig_data: esborrades " + nup + "entrades\n");
      SQL1 = "DELETE FROM sig_signatures where data='" + cd.getDataSQL() + "'";
      nup = coreCfg.getMysql().executeUpdate(SQL1);
      jTextArea1.append("sig_signatures: esborrades " + nup + "entrades\n");
      SQL1 = "DELETE FROM sig_signatures_tarda where data='" + cd.getDataSQL() + "'";
      nup = coreCfg.getMysql().executeUpdate(SQL1);
      jTextArea1.append("sig_signatures_tarda: esborrades " + nup + "entrades\n");
      jTextArea1.append("Fet!\n");

      checkSignatures();
    } else {
      // Una franja
      // Determina inici i fi de la franja
      int ini = -1;
      int fin = -1;

      String sini = StringUtils.BeforeFirst(jTextField1.getText(), "-");
      String sfin = StringUtils.AfterFirst(jTextField1.getText(), "-");

      try {
        ini = Integer.parseInt(sini);
        fin = Integer.parseInt(sfin);
      } catch (java.lang.NumberFormatException e) {
        //
      }

      if (ini <= 0 || fin <= 0) {
        return;
      }

      if (fin < ini) {
        int ini0 = ini;
        ini = fin;
        fin = ini0;
      }

      // Confirmació
      int conf =
          JOptionPane.showConfirmDialog(
              this,
              "Estau a punt de convertir "
                  + "signatures ``?´´ del dia "
                  + cd.getDiaMesComplet()
                  + "\nen la franja "
                  + ini
                  + "a - "
                  + fin
                  + "a hores.\nVoleu continuar?",
              "Confirmacio",
              JOptionPane.YES_NO_OPTION);

      int newStatus = 1;
      if (jCheckBox4.isSelected()) {
        newStatus = -1;
      }

      if (conf != 0) {
        return;
      }

      for (int i = ini; i <= fin; i++) {
        if (i < 8) {
          String SQL1 =
              "UPDATE sig_signatures SET h"
                  + i
                  + "="
                  + newStatus
                  + " where data='"
                  + cd.getDataSQL()
                  + "' AND h"
                  + i
                  + "=0";
          int nup = coreCfg.getMysql().executeUpdate(SQL1);
          jTextArea1.append(" > sig_signatures: hora=" + i + ": convertits=" + nup + "\n");
        } else if (i >= 8 && i < 15) {
          String SQL1 =
              "UPDATE sig_signatures_tarda SET h"
                  + (i - 7)
                  + "="
                  + newStatus
                  + " where data='"
                  + cd.getDataSQL()
                  + "' AND h"
                  + (i - 7)
                  + "=0";
          int nup = coreCfg.getMysql().executeUpdate(SQL1);
          jTextArea1.append(" > sig_signatures_tarda: hora=" + i + ": convertits=" + nup + "\n");
        }
      }
      jTextArea1.append("Fet!\n");
    }
  } // GEN-LAST:event_jButton1ActionPerformed