Exemplo n.º 1
0
  // TODO Carregar campos a partir do XML de um .ktr
  @SuppressWarnings("unchecked")
  @Override
  public void loadXML(
      Node stepDomNode, List<DatabaseMeta> databases, Map<String, Counter> sequenceCounters)
      throws KettleXMLException {

    try {
      XStream xs = new XStream(new DomDriver());

      StringWriter sw = new StringWriter();
      Transformer t = TransformerFactory.newInstance().newTransformer();
      // IPC: se algum colocar um caracter, seja qual for, no getXML() o
      // getFirstChild() para de funcionar aqui!
      t.transform(
          new DOMSource(
              XMLHandler.getSubNode(stepDomNode, Field.DATA_ROOT_NODE.name()).getFirstChild()),
          new StreamResult(sw));

      Map<String, Object> data = (Map<String, Object>) xs.fromXML(sw.toString());

      endpointUri = (String) data.get(Field.ENDPOINT_URI.name());
      defaultGraph = (String) data.get(Field.DEFAULT_GRAPH.name());
      queryString = (String) data.get(Field.QUERY_STRING.name());
      prefixes = (List<List<String>>) data.get(Field.PREFIXES.name());

      varResult = (String) data.get(Field.VAR_RESULT.name());

    } catch (Throwable e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 2
0
  // Rogers (2012): Persistir campos no repositorio
  @Override
  public void saveRep(Repository repository, ObjectId idOfTransformation, ObjectId idOfStep)
      throws KettleException {

    repository.saveStepAttribute(
        idOfTransformation, idOfStep, Field.ENDPOINT_URI.name(), endpointUri);
    repository.saveStepAttribute(
        idOfTransformation, idOfStep, Field.DEFAULT_GRAPH.name(), defaultGraph);
    repository.saveStepAttribute(
        idOfTransformation, idOfStep, Field.QUERY_STRING.name(), queryString);
    repository.saveStepAttribute(
        idOfTransformation, idOfStep, Field.PREFIXES.name(), new XStream().toXML(prefixes));
    repository.saveStepAttribute(idOfTransformation, idOfStep, Field.VAR_RESULT.name(), varResult);
  }
Exemplo n.º 3
0
  // TODO Gerar XML para salvar um .ktr
  @Override
  public String getXML() throws KettleException {

    XStream xs = new XStream();

    Map<String, Object> data = new TreeMap<String, Object>();

    data.put(Field.ENDPOINT_URI.name(), endpointUri);
    data.put(Field.DEFAULT_GRAPH.name(), defaultGraph);
    data.put(Field.QUERY_STRING.name(), queryString);
    data.put(Field.PREFIXES.name(), prefixes);

    data.put(Field.VAR_RESULT.name(), varResult);

    return String.format("<%1$s>%2$s</%1$s>", Field.DATA_ROOT_NODE.name(), xs.toXML(data));
  }
Exemplo n.º 4
0
  // Rogers (2012): Carregar campos a partir do repositorio
  @SuppressWarnings("unchecked")
  @Override
  public void readRep(
      Repository repository,
      ObjectId stepIdInRepository,
      List<DatabaseMeta> databases,
      Map<String, Counter> sequenceCounters)
      throws KettleException {

    endpointUri = repository.getStepAttributeString(stepIdInRepository, Field.ENDPOINT_URI.name());
    defaultGraph =
        repository.getStepAttributeString(stepIdInRepository, Field.DEFAULT_GRAPH.name());
    queryString = repository.getStepAttributeString(stepIdInRepository, Field.QUERY_STRING.name());
    prefixes =
        (List<List<String>>)
            new XStream()
                .fromXML(
                    repository.getStepAttributeString(stepIdInRepository, Field.PREFIXES.name()));
    varResult = repository.getStepAttributeString(stepIdInRepository, Field.VAR_RESULT.name());
  }