Beispiel #1
0
  public String getXML() {
    StringBuffer retval = new StringBuffer();

    retval.append(
        "    "
            + XMLHandler.addTagValue(
                "connection",
                databaseMeta == null
                    ? ""
                    : databaseMeta.getName())); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    retval.append(
        "    " + XMLHandler.addTagValue("rowlimit", rowLimit)); // $NON-NLS-1$ //$NON-NLS-2$
    retval.append("    " + XMLHandler.addTagValue("sql", sql)); // $NON-NLS-1$ //$NON-NLS-2$
    retval.append(
        "    " + XMLHandler.addTagValue("outer_join", outerJoin)); // $NON-NLS-1$ //$NON-NLS-2$
    retval.append("    " + XMLHandler.addTagValue("replace_vars", replacevars));
    retval.append(
        "    "
            + XMLHandler.addTagValue("sql_fieldname", sqlfieldname)); // $NON-NLS-1$ //$NON-NLS-2$
    retval.append(
        "    "
            + XMLHandler.addTagValue(
                "query_only_on_change", queryonlyonchange)); // $NON-NLS-1$ //$NON-NLS-2$

    return retval.toString();
  }
Beispiel #2
0
 @Override
 public void setInfo(
     Map<String, String[]> p, String id, List<? extends SharedObjectInterface> databases) {
   databaseMeta =
       DatabaseMeta.findDatabase(
           (List<DatabaseMeta>) databases,
           BaseStepMeta.parameterToLong(p.get(id + ".connection")));
   rowLimit = BaseStepMeta.parameterToInt(p.get(id + ".rowLimit"));
   sql = BaseStepMeta.parameterToString(p.get(id + ".sql"));
   outerJoin = BaseStepMeta.parameterToBoolean(p.get(id + ".outerJoin"));
   replacevars = BaseStepMeta.parameterToBoolean(p.get(id + ".replacevars"));
   sqlfieldname = BaseStepMeta.parameterToString(p.get(id + ".sqlfieldname"));
   queryonlyonchange = BaseStepMeta.parameterToBoolean(p.get(id + ".queryonlyonchange"));
 }
Beispiel #3
0
  public void saveRep(Repository rep, long id_transformation, long id_step) throws KettleException {
    try {
      rep.saveStepAttribute(
          id_transformation,
          id_step,
          "id_connection",
          databaseMeta == null ? -1 : databaseMeta.getID()); // $NON-NLS-1$
      rep.saveStepAttribute(id_transformation, id_step, "rowlimit", rowLimit); // $NON-NLS-1$
      rep.saveStepAttribute(id_transformation, id_step, "sql", sql); // $NON-NLS-1$
      rep.saveStepAttribute(id_transformation, id_step, "outer_join", outerJoin); // $NON-NLS-1$
      rep.saveStepAttribute(id_transformation, id_step, "replace_vars", replacevars);
      rep.saveStepAttribute(
          id_transformation, id_step, "sql_fieldname", sqlfieldname); // $NON-NLS-1$
      rep.saveStepAttribute(id_transformation, id_step, "query_only_on_change", queryonlyonchange);

      // Also, save the step-database relationship!
      if (databaseMeta != null)
        rep.insertStepDatabase(id_transformation, id_step, databaseMeta.getID());
    } catch (Exception e) {
      throw new KettleException(
          Messages.getString("DynamicSQLRowMeta.Exception.UnableToSaveStepInfo") + id_step,
          e); //$NON-NLS-1$
    }
  }
Beispiel #4
0
 public void readRep(
     Repository rep, long id_step, List<DatabaseMeta> databases, Map<String, Counter> counters)
     throws KettleException {
   try {
     long id_connection = rep.getStepAttributeInteger(id_step, "id_connection"); // $NON-NLS-1$
     databaseMeta = DatabaseMeta.findDatabase(databases, id_connection);
     rowLimit = (int) rep.getStepAttributeInteger(id_step, "rowlimit"); // $NON-NLS-1$
     sql = rep.getStepAttributeString(id_step, "sql"); // $NON-NLS-1$
     outerJoin = rep.getStepAttributeBoolean(id_step, "outer_join"); // $NON-NLS-1$
     replacevars = rep.getStepAttributeBoolean(id_step, "replace_vars");
     sqlfieldname = rep.getStepAttributeString(id_step, "sql_fieldname"); // $NON-NLS-1$
     queryonlyonchange =
         rep.getStepAttributeBoolean(id_step, "query_only_on_change"); // $NON-NLS-1$
   } catch (Exception e) {
     throw new KettleException(
         Messages.getString("DynamicSQLRowMeta.Exception.UnexpectedErrorReadingStepInfo"),
         e); //$NON-NLS-1$
   }
 }
Beispiel #5
0
  private void readData(Node stepnode, List<DatabaseMeta> databases) throws KettleXMLException {
    try {
      String con = XMLHandler.getTagValue(stepnode, "connection"); // $NON-NLS-1$
      databaseMeta = DatabaseMeta.findDatabase(databases, con);
      sql = XMLHandler.getTagValue(stepnode, "sql"); // $NON-NLS-1$
      outerJoin =
          "Y"
              .equalsIgnoreCase(
                  XMLHandler.getTagValue(stepnode, "outer_join")); // $NON-NLS-1$ //$NON-NLS-2$
      replacevars = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "replace_vars"));
      queryonlyonchange =
          "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "query_only_on_change"));

      rowLimit = Const.toInt(XMLHandler.getTagValue(stepnode, "rowlimit"), 0); // $NON-NLS-1$
      sqlfieldname = XMLHandler.getTagValue(stepnode, "sql_fieldname"); // $NON-NLS-1$

    } catch (Exception e) {
      throw new KettleXMLException(
          Messages.getString("DynamicSQLRowMeta.Exception.UnableToLoadStepInfo"), e); // $NON-NLS-1$
    }
  }
Beispiel #6
0
  public void analyseImpact(
      List<DatabaseImpact> impact,
      TransMeta transMeta,
      StepMeta stepMeta,
      RowMetaInterface prev,
      String[] input,
      String[] output,
      RowMetaInterface info)
      throws KettleStepException {

    RowMetaInterface out = prev.clone();
    getFields(
        out,
        stepMeta.getName(),
        new RowMetaInterface[] {
          info,
        },
        null,
        transMeta);
    if (out != null) {
      for (int i = 0; i < out.size(); i++) {
        ValueMetaInterface outvalue = out.getValueMeta(i);
        DatabaseImpact di =
            new DatabaseImpact(
                DatabaseImpact.TYPE_IMPACT_READ,
                transMeta.getName(),
                stepMeta.getName(),
                databaseMeta.getDatabaseName(),
                "", //$NON-NLS-1$
                outvalue.getName(),
                outvalue.getName(),
                stepMeta.getName(),
                sql,
                Messages.getString("DynamicSQLRowMeta.DatabaseImpact.Title") // $NON-NLS-1$
                );
        impact.add(di);
      }
    }
  }