Package org.openqreg.bean

Examples of org.openqreg.bean.VariableForImport


   * @return String containing SQL delete statements for helptexts
   */
  public String getSQLDeleteForHelptexts() {
    StringBuffer out = new StringBuffer();
    Iterator it = variables.iterator();
    VariableForImport var;
    while (it.hasNext()) {
      var = (VariableForImport) it.next();
      if (var.getName() != null && !var.getName().equals("")
          && var.getHelpTextID() != null
          && !var.getHelpTextID().equals("")
          && var.getTable() != null && !var.getTable().equals("")
          && isVariableType(var.getType())) {
        out.append("delete from text where id = ");
        out.append("'").append(var.getTable().toUpperCase()).append("_"
        ).append(var.getName().toUpperCase()).append("_H'");
        out.append(" and LANGUAGEID='").append(var.getLanguageid());
        out.append("';");
        out.append(nl);
      }
    }
    return out.toString();
View Full Code Here


   * @return String containing SQL delete statements for answer alternatives
   */
  public String getSQLDeleteForAlternatives() {
    StringBuffer out = new StringBuffer();
    Iterator it = variables.iterator();
    VariableForImport var;
    Vector alternatives = new Vector();
    while (it.hasNext()) {
      var = (VariableForImport) it.next();
      alternatives = var.getAlternatvies();
     
      try {
        Class clazz = Class.forName(var.getType());
     
        if (var.getName() != null && !var.getName().equals("")
            && alternatives != null && var.getTable() != null
            && !var.getTable().equals("")
            && (ListElement.class.isAssignableFrom(clazz))) {
 
          out.append("delete from LISTBOXTEXTROW where id = ");
          out.append("'" ).append( var.getTable().toUpperCase() ).append("_"
          ).append(var.getName().toUpperCase() ).append("_L'");
          out.append(" and LANGUAGEID='" + var.getLanguageid()+"';");
          out.append(nl);
        }
      }catch(ClassNotFoundException cnfe){
        log.log(Level.ERROR, "Unable to locate element class", cnfe);
      }
View Full Code Here

      boundry = "##endofrow##";
      nextBoundry = input.indexOf(boundry);
    }
    while (nextBoundry != -1) {
      rows++;
      VariableForImport var = new VariableForImport();
      String oneRow = input.substring(lastBoundry, nextBoundry);
      // logger.log(Level.INFO, "Input row: " + oneRow);
      arry = ValidationHelper.separateToArray(oneRow, separator);
      if (log.isDebugEnabled()) {
        log.log(Level.INFO, "populateFromFile(): reading row: "
            + arry[NAMECOLUMN]);

      }
      if (arry[NAMECOLUMN].trim().length() > 0) {
        if (arry[NAMECOLUMN] != null) {
          var.setName(arry[NAMECOLUMN].toString());
        }
        if (arry[DESCRIPTIONCOLUMN] != null) {
          var.setDescription(arry[DESCRIPTIONCOLUMN].toString()
              .replaceAll("&nbsp:", " "));
        }
       
        if (arry[TYPECOLUMN] != null){
          Class clazz = null;
         
          try {
            if(log.isDebugEnabled()){
              log.log(Level.INFO, "Row: "+ rows +"  Variable class: "+ arry[TYPECOLUMN]);
            }
            clazz = Class.forName(arry[TYPECOLUMN]);
         
            if(ListElement.class.isAssignableFrom(clazz)) {
             
              if(arry[ALTERNATIVESCOLUMN] != null){
             
                Vector alternatives = new Vector();
                Alternative alternative = new Alternative();
                String[] altrows = ValidationHelper.separateToArray(
                    arry[ALTERNATIVESCOLUMN].toString(), "\n");
               
                for (int r = 0; r < altrows.length; r++) {
                  String row = altrows[r].toString();
                  if (row.indexOf("=") != -1) {
                    alternative = new Alternative();
                    alternative.setValue(row.substring(0,
                        row.indexOf("=")).trim().replaceAll("\"",
                        ""));
                    alternative.setText(row.substring(
                        row.indexOf("=") + 1).trim().replaceAll(
                        "\"", ""));
                    alternatives.add(alternative);
                  }
                }
                alternatives.trimToSize();
                var.setAlternatvies(alternatives);
              }
           
              if(arry[ALTERNATIVESDATECOLUMN] != null) {
                Vector alternatives = var.getAlternatvies();
                Alternative alternative = new Alternative();
                String[] altrows = ValidationHelper.separateToArray(
                    arry[ALTERNATIVESDATECOLUMN].toString(), "\n");
                for (int r = 0; r < altrows.length; r++) {
                  String row = altrows[r].toString();
                  if (row.indexOf("=") != -1) {
                    alternative = (Alternative) alternatives.get(r);
                    int startPos = row.indexOf("=") + 1;
                    alternative.setStartDate(((row.substring(startPos,
                        row.indexOf("/")).trim()).replaceAll("\"",
                        "")).replaceAll("\\(", ""));
                    alternative.setEndDate(((row.substring(row
                        .indexOf("/") + 1).trim()).replaceAll("\"",
                        "")).replaceAll("\\)", ""));
                  }
                }
                alternatives.trimToSize();
                var.setAlternatvies(alternatives);
              }             
            }
          } catch (ClassNotFoundException cnfe) {
            log.log(Level.ERROR, "Unable to locate element class", cnfe);
          }
        }

        if (arry[HELPTEXTCOLUMN] != null) {
          var.setHelpTextID(arry[HELPTEXTCOLUMN].toString().trim()
              .replaceAll("\"", "")
              .replaceAll("&nbsp:", "&nbsp;"));
        }
        if (arry[TYPECOLUMN] != null) {
          var.setType(arry[TYPECOLUMN].toString());
        }

        if (arry[TABLECOLUMN] != null) {
          var.setTable(arry[TABLECOLUMN].toString());
        }
        // sets lang id for this variable
        var.setLanguageid(languageid);

        variables.add(var);
      }
//      lastBoundry = nextBoundry;
//      nextBoundry = input.indexOf(boundry, (lastBoundry + boundry
View Full Code Here

   * @return String containing SQL insert statements for description
   */
  public String getSQLInsertForDescriptions() {
    StringBuffer out = new StringBuffer();
    Iterator it = variables.iterator();
    VariableForImport var;

    while (it.hasNext()) {
      var = (VariableForImport) it.next();
      if (var.getName() != null && !var.getName().equals("")
          && var.getDescription() != null
          && !var.getDescription().equals("")
          && var.getTable() != null && !var.getTable().equals("")
          && isVariableType(var.getType())) {
        out
            .append("insert into text (ID, LANGUAGEID, TEXT, TSCREATED, TSUPDATED, CREATEDBY, UPDATEDBY) ");
        out.append("values (");
        out.append("'" + var.getTable().toUpperCase() + "_"
            + var.getName().toUpperCase() + "_D' ");
        out.append(", '" + var.getLanguageid());
        out.append("', '" + var.getDescription() + "' ");
        out
            .append(", localtimestamp, localtimestamp,'System','System');");
        out.append("\r\n");
      }
    }
View Full Code Here

   * @return String containing SQL insert statements for helptext
   */
  public String getSQLInsertForHelptexts() {
    StringBuffer out = new StringBuffer();
    Iterator it = variables.iterator();
    VariableForImport var;
    while (it.hasNext()) {
      var = (VariableForImport) it.next();
      if (var.getName() != null && !var.getName().equals("")
          && var.getHelpTextID() != null
          && !var.getHelpTextID().equals("")
          && var.getTable() != null && !var.getTable().equals("")
          && isVariableType(var.getType())) {
        out
            .append("insert into text (ID, LANGUAGEID, TEXT, TSCREATED, TSUPDATED, CREATEDBY, UPDATEDBY) ");
        out.append("values (");
        out.append("'" + var.getTable().toUpperCase() + "_"
            + var.getName().toUpperCase() + "_H' ");
        out.append(", '" + var.getLanguageid());
        out.append("', '" + var.getHelpTextID().replaceAll("\n", "<br>").replaceAll("'", "\\\\''")
            + "' ");
        out
            .append(", localtimestamp, localtimestamp,'System','System');");
        out.append(nl);
      }
View Full Code Here

   * @return String containing SQL insert statements for answer alternatives
   */
  public String getSQLInsertForAlternatives() {
    StringBuffer out = new StringBuffer();
    Iterator it = variables.iterator();
    VariableForImport var;
    Vector alternatives = new Vector();
    int counter = 0;
    Alternative alternative = new Alternative();
    while (it.hasNext()) {
      counter = 0;
      var = (VariableForImport) it.next();
      alternatives = var.getAlternatvies();
     
      try {
        Class clazz = Class.forName(var.getType());     
     
        if (var.getName() != null
            && !var.getName().equals("")
            && alternatives != null
            && var.getTable() != null
            && !var.getTable().equals("")
            && (ListElement.class.isAssignableFrom(clazz))) {
 
          out
              .append("insert into listboxtextrow (ID, LISTORDER, LANGUAGEID, TEXT, TEXTVALUE, SELECTED, TSCREATED, TSUPDATED, CREATEDBY, UPDATEDBY, VALIDFROM)");
          out.append(" values (");
          out.append("'" + var.getTable().toUpperCase() + "_"
              + var.getName().toUpperCase() + "_L' ");
          out
              .append(", 0, '"
                  + var.getLanguageid()
                  + "', '', '', 1, localtimestamp,localtimestamp, 'System', 'System', DATE '2004-01-01');");
          out.append(nl);
 
          for (int r = 0; r < alternatives.size(); r++) {
            counter++;
            alternative = (Alternative) alternatives.get(r);
            out
                .append("insert into listboxtextrow (ID, LISTORDER, LANGUAGEID, TEXT, TEXTVALUE, "
                    + "SELECTED, TSCREATED, TSUPDATED, CREATEDBY, UPDATEDBY, VALIDFROM, VALIDTO)");
            out.append("values (");
            out.append("'" + var.getTable().toUpperCase() + "_"
                + var.getName().toUpperCase() + "_L' ");
            out.append(", " + counter);
            out.append(", '" + var.getLanguageid());
            out
                .append("', '"
                    + alternative.getText()
                    + "', '"
                    + alternative.getValue()
View Full Code Here

   * @return String containing SQL delete statements for description
   */
  public String getSQLDeleteForDescriptions() {
    StringBuffer out = new StringBuffer();
    Iterator it = variables.iterator();
    VariableForImport var;
    while (it.hasNext()) {
      var = (VariableForImport) it.next();
      if (var.getName() != null && !var.getName().equals("")
          && var.getDescription() != null
          && !var.getDescription().equals("")
          && var.getTable() != null && !var.getTable().equals("")
          && isVariableType(var.getType())

      ) {
        out.append("delete from text where id = ");
        out.append("'").append(var.getTable().toUpperCase()).append("_"
        ).append(var.getName().toUpperCase()).append("_D'");
        out.append(" and LANGUAGEID='").append(var.getLanguageid());
        out.append("';");
        out.append(nl);
      }
    }
    return out.toString();
View Full Code Here

TOP

Related Classes of org.openqreg.bean.VariableForImport

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.