示例#1
0
 public Object insertEdge(mxCell v1, mxCell v2) {
   graph.getModel().beginUpdate();
   //		log.log(Level.INFO, "Inserting edge between " +
   //							((VertexValue) v1.getValue()).getId() +
   //							" and " +
   //							((VertexValue) v2.getValue()).getId());
   Object parent = graph.getDefaultParent();
   mxCell inserted;
   try {
     inserted = (mxCell) graph.insertEdge(parent, null, null, v1, v2);
     //			log.log(Level.INFO, "Edge inserted");
     EdgeValue value =
         new EdgeValue(
             ((VertexValue) v2.getValue())
                 .getInitialImmunity()); // na razie waga krawędzi to po prostu odporność
                                         // wierzchołka do którego ta krawędź prowadzi
     ((VertexValue) v1.getValue()).addNeighbour(v2); // dodajemy v2 jako sąsiednią krawędź v1
     //			log.log(Level.INFO, "Neighbour added to target vertex");
     inserted.setValue(value); // ustawiamy wartość dodanej krawędzi
     //			log.log(Level.INFO, "Edge value set");
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   } finally {
     graph.getModel().endUpdate();
   }
   return inserted;
 }
  @SuppressWarnings({"unchecked", "unchecked"})
  // private mxGraphModel ExtractGraphFromSTD_INPUT() {
  private DirectedGraph<Object, ObjectEdge> ExtractGraphFromSTD_INPUT() {
    ActivityPort stdInput = getInput("STD_INPUT");
    ActivityPort inputfile = getInput("INPUT_FILE_BASE");

    /* @Todo: Reads directly from STD_INPUT. Should (be better) read from file (lots of .log .dot, .dat are generated by vivado workflow */
    Collection<String> lines = UtilStr.SeparateComponents((String) stdInput.getValue(), "\n");
    String startString = "<<BEGIN>><<" + (String) inputfile.getValue() + "_graph_minimized>>";
    String stopString = "<<END>><<" + (String) inputfile.getValue() + "_graph_minimized>>";
    boolean reading = false;

    // rebuild circuit graph
    DirectedGraph<Object, ObjectEdge> graph =
        new DefaultDirectedGraph<Object, ObjectEdge>(ObjectEdge.class);
    Map<String, Object> vertexMap = new HashMap<String, Object>();

    // mxGraphModel circuitGraph = new mxGraphModel();
    // circuitGraph.setCreateIds(false);
    // circuitGraph.beginUpdate();
    // Object rootCell = circuitGraph.getRoot();
    for (String line : lines) {
      if (reading) {
        if (line.equals(stopString)) {
          reading = false;
          break;
        } else {
          // rebuild graph
          Collection<String> wordsCollection = UtilStr.SeparateComponents(line, " ");
          String[] words = wordsCollection.toArray(new String[wordsCollection.size()]);
          int index = 1;
          int i;
          switch (words[0]) {
            case "Vertex":
              mxCell vertexCell = new mxCell();
              vertexCell.setVertex(true);
              vertexCell.setId(words[1]);
              switch (words[2]) {
                case "cell":
                  PLDConfigurableElement pldCell = new PLDConfigurableElement("Cell_0");
                  pldCell.setName(words[5]);
                  pldCell.setInitialValue(words[4]);
                  pldCell.setComponentType(ElectricalComponentType.INTRACHIP);
                  pldCell.setDescription(words[3]);
                  i = 6;
                  while ((i < words.length) && !words[i].equals("=>")) {
                    // String name, Direction direction, Long address, Integer bit, Boolean
                    // mandatory
                    // PhysicalPortPin  pin = new PhysicalPortPin(words[i], Direction.UNKNOWN, 0L,
                    // 0, true);
                    CPSPort pin =
                        new CPSPort(
                            words[i],
                            Direction.UNKNOWN,
                            0L,
                            0,
                            true); // PhysicalPortPin(words[i], Direction.UNKNOWN, 0L, 0, true);
                    if (pldCell.getInterfaceComponent().getChannels().size() == 0) {
                      pldCell
                          .getInterfaceComponent()
                          .getChannels()
                          .add(new ChannelPrimitive("default chanel"));
                    }
                    ChannelAbstract channel =
                        pldCell.getInterfaceComponent().getChannels().iterator().next();
                    channel.getPorts().add(pin);
                    vertexMap.put(words[i], pin);
                    i++;
                  }
                  while (i < words.length - 1) {
                    i++;
                    words[i] = words[i].replaceAll("@", " ");
                    int indexOfEqualSignal = words[i].indexOf("=");
                    String property = words[i].substring(0, indexOfEqualSignal);
                    String propValue = words[i].substring(indexOfEqualSignal + 1);
                    // Boolean isConst, String name, String defaultValue, String type, Direction
                    // direction
                    DiscreteVariable attribute =
                        new DiscreteVariable(
                            false, property, propValue, "UNKNOWN", Direction.UNKNOWN);
                    pldCell.getExtraAttributes().add(attribute);
                  }
                  // pldCell.getInterfaceElectrical().setElectricalFeature(new ElectricalFeature());
                  vertexCell.setValue(pldCell);
                  vertexMap.put(words[1], pldCell);
                  System.out.println("Vertex cell: " + pldCell);
                  graph.addVertex(pldCell);
                  break;
                case "port":
                  // Vertex <NodoIdx> port <Direction> <Name>
                  // EX: Vertex node18 port IN SA
                  Long address = Long.parseLong(words[1].replace("node", ""));
                  Direction dir = Direction.valueOf(words[3]);
                  // String name, Direction direction, Long address, Integer bit, Boolean mandatory
                  PhysicalPortPin pin = new PhysicalPortPin(words[4], dir, address, 0, true);
                  i = 5; // to be ++
                  while (i < words.length - 1) {
                    i++;
                    words[i] = words[i].replaceAll("@", " ");
                    int indexOfEqualSignal = words[i].indexOf("=");
                    String property = words[i].substring(0, indexOfEqualSignal);
                    String propValue = words[i].substring(indexOfEqualSignal + 1);
                    // Boolean isConst, String name, String defaultValue, String type, Direction
                    // direction
                    DiscreteVariable attribute =
                        new DiscreteVariable(
                            false, property, propValue, "UNKNOWN", Direction.UNKNOWN);
                    pin.getExtraAttributes().add(attribute);
                  }
                  vertexCell.setValue(pin);
                  vertexMap.put(words[1], pin); // nodeX
                  vertexMap.put(words[4], pin); // real name
                  System.out.println("Vertex port: " + pin);
                  graph.addVertex(pin);
                  break;
                default:
                  break;
              }
              // circuitGraph.add(rootCell, vertexCell, index++);
              break;
            case "Edge":
              // mxCell edgeCell = new mxCell();
              // edgeCell.setEdge(true);
              // edgeCell.setId(circuitGraph.createId(edgeCell));
              // mxCell source = (mxCell) circuitGraph.getCell(words[1]);
              // assert source != null;
              // edgeCell.setSource(source);
              // mxCell target = (mxCell) circuitGraph.getCell(words[2]);
              // assert target != null;
              // edgeCell.setTarget(target);
              String sourcePinOrPortStr = words[3];
              PhysicalPortPin sourcePinPort, targetPinPort;
              if (sourcePinOrPortStr.indexOf(":") > -1) {
                // is a CELL:PIN (takes only the pin part)
                sourcePinOrPortStr =
                    sourcePinOrPortStr.substring(sourcePinOrPortStr.indexOf(":") + 1);
                sourcePinPort = (PhysicalPortPin) vertexMap.get(sourcePinOrPortStr);
                assert sourcePinPort != null;
                sourcePinPort.setDirection(
                    Direction.OUT); // it is an OUT PIN, so we can read from it
              } else {
                sourcePinPort = (PhysicalPortPin) vertexMap.get(sourcePinOrPortStr);
                assert sourcePinPort != null;
                sourcePinPort.setDirection(
                    Direction.IN); // it is an IN PORT, so we can read from it
              }
              String targetPinOrPortStr = words[4];
              if (targetPinOrPortStr.indexOf(":") > -1) { // is a CELL:PIN (takes only the pin part)
                targetPinOrPortStr =
                    targetPinOrPortStr.substring(targetPinOrPortStr.indexOf(":") + 1);
                targetPinPort = (PhysicalPortPin) vertexMap.get(targetPinOrPortStr);
                assert targetPinPort != null;
                targetPinPort.setDirection(Direction.IN); // it is an IN PIN, so we can write to it
              } else {
                targetPinPort = (PhysicalPortPin) vertexMap.get(targetPinOrPortStr);
                assert targetPinPort != null;
                targetPinPort.setDirection(
                    Direction.OUT); // it is an OUT PORT, so we can write to it
              }
              PhysicalCommunicationNet hardwareNet =
                  new PhysicalCommunicationNet(sourcePinPort, targetPinPort);
              // edgeCell.setValue(hardwareNet);
              //                            i = 5; // to be ++
              //                            while (i < words.length - 1) {
              //                                i++;
              //                                words[i] = words[i].replaceAll("@", " ");
              //                                int indexOfEqualSignal = words[i].indexOf("=");
              //                                String property = words[i].substring(0,
              // indexOfEqualSignal);
              //                                String propValue =
              // words[i].substring(indexOfEqualSignal + 1);
              //                                //Boolean isConst, String name, String defaultValue,
              // String type, Direction direction
              //                                DiscreteVariable attribute = new
              // DiscreteVariable(false, property, propValue, "UNKNOWN", Direction.UNKNOWN);
              //                                //pin.getExtraAttributes().add(attribute);
              //                                /**
              //                                 * @TODO: where net properties are inserted into? *
              //                                 */
              //                            }
              // circuitGraph.add(rootCell, edgeCell, index++);
              Object vSource = vertexMap.get(words[1]);
              Object vTarget = vertexMap.get(words[2]);
              System.out.println(
                  "Edge: "
                      + vSource
                      + " -> "
                      + vTarget
                      + "   << "
                      + sourcePinOrPortStr
                      + " -> "
                      + targetPinOrPortStr
                      + "  >>");
              ObjectEdge edge = graph.addEdge(vSource, vTarget);
              edge.setUserObject(hardwareNet);
              break;
            default:
              Logger.getGlobal()
                  .warning(
                      "Error: Line not recognized when expecting to rebuild the circuit graph: "
                          + line);
              break;
          }
        }
      } else if (line.equals(startString)) {
        reading = true;
      }
    }
    // circuitGraph.endUpdate();
    //        return circuitGraph;
    return graph;
  }
示例#3
0
  /**
   * This method is called when the user has created manually an edge in the graph, by dragging a
   * link between two spot cells. It checks whether the matching edge in the model exists, and tune
   * what should be done accordingly.
   *
   * @param cell the mxCell of the edge that has been manually created.
   */
  protected void addEdgeManually(mxCell cell) {
    if (cell.isEdge()) {
      final mxIGraphModel graphModel = graph.getModel();
      cell.setValue("New");
      model.beginUpdate();
      graphModel.beginUpdate();
      try {

        Spot source = graph.getSpotFor(cell.getSource());
        Spot target = graph.getSpotFor(cell.getTarget());

        if (DEBUG) {
          System.out.println(
              "[TrackScheme] #addEdgeManually: edge is between 2 spots belonging to the same frame. Removing it.");
          System.out.println(
              "[TrackScheme] #addEdgeManually: adding edge between source "
                  + source
                  + " at frame "
                  + source.getFeature(Spot.FRAME).intValue()
                  + " and target "
                  + target
                  + " at frame "
                  + target.getFeature(Spot.FRAME).intValue());
        }

        if (Spot.frameComparator.compare(source, target) == 0) {
          // Prevent adding edges between spots that belong to the same frame

          if (DEBUG) {
            System.out.println(
                "[TrackScheme] addEdgeManually: edge is between 2 spots belonging to the same frame. Removing it.");
          }
          graph.removeCells(new Object[] {cell});

        } else {
          // We can add it to the model

          // Put them right in order: since we use a oriented graph,
          // we want the source spot to precede in time.
          if (Spot.frameComparator.compare(source, target) > 0) {

            if (DEBUG) {
              System.out.println(
                  "[TrackScheme] #addEdgeManually: Source "
                      + source
                      + " succeed target "
                      + target
                      + ". Inverting edge direction.");
            }

            Spot tmp = source;
            source = target;
            target = tmp;
          }
          // We add a new jGraphT edge to the underlying model, if it does not exist yet.
          DefaultWeightedEdge edge = model.getTrackModel().getEdge(source, target);
          if (null == edge) {
            edge = model.addEdge(source, target, -1);
            if (DEBUG) {
              System.out.println(
                  "[TrackScheme] #addEdgeManually: Creating new edge: " + edge + ".");
            }
          } else {
            // Ah. There was an existing edge in the model we were trying to re-add there, from the
            // graph.
            // We remove the graph edge we have added,
            if (DEBUG) {
              System.out.println("[TrackScheme] #addEdgeManually: Edge pre-existed. Retrieve it.");
            }
            graph.removeCells(new Object[] {cell});
            // And re-create a graph edge from the model edge.
            cell = graph.addJGraphTEdge(edge);
            cell.setValue(String.format("%.1f", model.getTrackModel().getEdgeWeight(edge)));
            // We also need now to check if the edge belonged to a visible track. If not,
            // we make it visible.
            int ID = model.getTrackModel().trackIDOf(edge);
            // This will work, because track indices will be reprocessed only after the
            // graphModel.endUpdate()
            // reaches 0. So now, it's like we are dealing with the track indices priori to
            // modification.
            if (model.getTrackModel().isVisible(ID)) {
              if (DEBUG) {
                System.out.println(
                    "[TrackScheme] #addEdgeManually: Track was visible. Do nothing.");
              }
            } else {
              if (DEBUG) {
                System.out.println(
                    "[TrackScheme] #addEdgeManually: Track was invisible. Make it visible.");
              }
              importTrack(ID);
            }
          }
          graph.mapEdgeToCell(edge, cell);
        }

      } finally {
        graphModel.endUpdate();
        model.endUpdate();
        selectionModel.clearEdgeSelection();
      }
    }
  }
示例#4
0
  /**
   * Create links between all the spots currently in the {@link Model} selection. We update
   * simultaneously the {@link Model} and the {@link JGraphXAdapter}.
   */
  public void linkSpots() {

    // Sort spots by time
    TreeMap<Integer, Spot> spotsInTime = new TreeMap<Integer, Spot>();
    for (Spot spot : selectionModel.getSpotSelection()) {
      spotsInTime.put(spot.getFeature(Spot.FRAME).intValue(), spot);
    }

    // Find adequate column
    int targetColumn = getUnlaidSpotColumn();

    // Then link them in this order
    model.beginUpdate();
    graph.getModel().beginUpdate();
    try {
      Iterator<Integer> it = spotsInTime.keySet().iterator();
      Integer previousTime = it.next();
      Spot previousSpot = spotsInTime.get(previousTime);
      // If this spot belong to an invisible track, we make it visible
      Integer ID = model.getTrackModel().trackIDOf(previousSpot);
      if (ID != null && !model.getTrackModel().isVisible(ID)) {
        importTrack(ID);
      }

      while (it.hasNext()) {
        Integer currentTime = it.next();
        Spot currentSpot = spotsInTime.get(currentTime);
        // If this spot belong to an invisible track, we make it visible
        ID = model.getTrackModel().trackIDOf(currentSpot);
        if (ID != null && !model.getTrackModel().isVisible(ID)) {
          importTrack(ID);
        }
        // Check that the cells matching the 2 spots exist in the graph
        mxICell currentCell = graph.getCellFor(currentSpot);
        if (null == currentCell) {
          currentCell = insertSpotInGraph(currentSpot, targetColumn);
          if (DEBUG) {
            System.out.println(
                "[TrackScheme] linkSpots: creating cell "
                    + currentCell
                    + " for spot "
                    + currentSpot);
          }
        }
        mxICell previousCell = graph.getCellFor(previousSpot);
        if (null == previousCell) {
          int frame = previousSpot.getFeature(Spot.FRAME).intValue();
          int column = Math.max(targetColumn, getNextFreeColumn(frame));
          rowLengths.put(frame, column);
          previousCell = insertSpotInGraph(previousSpot, column);
          if (DEBUG) {
            System.out.println(
                "[TrackScheme] linkSpots: creating cell "
                    + previousCell
                    + " for spot "
                    + previousSpot);
          }
        }
        // Check if the model does not have already a edge for these 2 spots (that is
        // the case if the 2 spot are in an invisible track, which track scheme does not
        // know of).
        DefaultWeightedEdge edge = model.getTrackModel().getEdge(previousSpot, currentSpot);
        if (null == edge) {
          // We create a new edge between 2 spots, and pair it with a new cell edge.
          edge = model.addEdge(previousSpot, currentSpot, -1);
          mxCell cell = (mxCell) graph.addJGraphTEdge(edge);
          cell.setValue("New");
        } else {
          // We retrieve the edge, and pair it with a new cell edge.
          mxCell cell = (mxCell) graph.addJGraphTEdge(edge);
          cell.setValue(String.format("%.1f", model.getTrackModel().getEdgeWeight(edge)));
          // Also, if the existing edge belonged to an existing invisible track, we make it visible.
          ID = model.getTrackModel().trackIDOf(edge);
          if (ID != null && !model.getTrackModel().isVisible(ID)) {
            importTrack(ID);
          }
        }
        previousSpot = currentSpot;
      }
    } finally {
      graph.getModel().endUpdate();
      model.endUpdate();
    }
  }
  @Override
  public String encode(AbstractMeta meta) throws Exception {
    TransMeta transMeta = (TransMeta) meta;

    mxGraph graph = new mxGraph();
    graph.getModel().beginUpdate();
    mxCell parent = (mxCell) graph.getDefaultParent();
    Document doc = mxUtils.createDocument();

    try {
      Element e = super.encodeCommRootAttr(transMeta, doc);
      e.setAttribute("trans_version", transMeta.getTransversion());
      e.setAttribute("trans_type", transMeta.getTransformationType().getCode());
      e.setAttribute("trans_status", String.valueOf(transMeta.getTransstatus()));

      // variables
      Properties sp = new Properties();
      JSONArray jsonArray = new JSONArray();

      String[] keys = Variables.getADefaultVariableSpace().listVariables();
      for (int i = 0; i < keys.length; i++) {
        sp.put(keys[i], Variables.getADefaultVariableSpace().getVariable(keys[i]));
      }

      List<String> vars = transMeta.getUsedVariables();
      for (int i = 0; i < vars.size(); i++) {
        String varname = vars.get(i);
        if (!varname.startsWith(Const.INTERNAL_VARIABLE_PREFIX)
            && Const.indexOfString(varname, transMeta.listParameters()) < 0) {
          JSONObject param = new JSONObject();
          param.put("var_name", varname);
          param.put("var_value", sp.getProperty(varname, ""));
          jsonArray.add(param);
        }
      }

      for (String varname : Const.INTERNAL_JOB_VARIABLES) {
        String value = transMeta.getVariable(varname);
        if (!Const.isEmpty(value)) {

          JSONObject param = new JSONObject();
          param.put("var_name", varname);
          param.put("var_value", value);
          jsonArray.add(param);
        }
      }
      e.setAttribute("variables", jsonArray.toString());

      TransLogTable transLogTable = transMeta.getTransLogTable();
      JSONObject jsonObject = new JSONObject();
      jsonObject.put("connection", transLogTable.getConnectionName());
      jsonObject.put("schema", transLogTable.getSchemaName());
      jsonObject.put("table", transLogTable.getTableName());
      jsonObject.put("size_limit_lines", transLogTable.getLogSizeLimit());
      jsonObject.put("interval", transLogTable.getLogInterval());
      jsonObject.put("timeout_days", transLogTable.getTimeoutInDays());
      JSONArray fields = new JSONArray();
      for (LogTableField field : transLogTable.getFields()) {
        JSONObject jsonField = new JSONObject();
        jsonField.put("id", field.getId());
        jsonField.put("enabled", field.isEnabled());
        jsonField.put("name", field.getFieldName());
        jsonField.put("subjectAllowed", field.isSubjectAllowed());
        if (field.isSubjectAllowed()) {
          jsonField.put("subject", field.getSubject() == null ? "" : field.getSubject().toString());
        } else {
          jsonField.put("subject", "-");
        }
        jsonField.put("description", StringEscapeHelper.encode(field.getDescription()));
        fields.add(jsonField);
      }
      jsonObject.put("fields", fields);
      e.setAttribute("transLogTable", jsonObject.toString());

      StepLogTable stepLogTable = transMeta.getStepLogTable();
      jsonObject = new JSONObject();
      jsonObject.put("connection", stepLogTable.getConnectionName());
      jsonObject.put("schema", stepLogTable.getSchemaName());
      jsonObject.put("table", stepLogTable.getTableName());
      jsonObject.put("timeout_days", stepLogTable.getTimeoutInDays());
      fields = new JSONArray();
      for (LogTableField field : stepLogTable.getFields()) {
        JSONObject jsonField = new JSONObject();
        jsonField.put("id", field.getId());
        jsonField.put("enabled", field.isEnabled());
        jsonField.put("name", field.getFieldName());
        jsonField.put("description", StringEscapeHelper.encode(field.getDescription()));
        fields.add(jsonField);
      }
      jsonObject.put("fields", fields);
      e.setAttribute("stepLogTable", jsonObject.toString());

      PerformanceLogTable performanceLogTable = transMeta.getPerformanceLogTable();
      jsonObject = new JSONObject();
      jsonObject.put("connection", performanceLogTable.getConnectionName());
      jsonObject.put("schema", performanceLogTable.getSchemaName());
      jsonObject.put("table", performanceLogTable.getTableName());
      jsonObject.put("interval", performanceLogTable.getLogInterval());
      jsonObject.put("timeout_days", performanceLogTable.getTimeoutInDays());
      fields = new JSONArray();
      for (LogTableField field : performanceLogTable.getFields()) {
        JSONObject jsonField = new JSONObject();
        jsonField.put("id", field.getId());
        jsonField.put("enabled", field.isEnabled());
        jsonField.put("name", field.getFieldName());
        jsonField.put("description", StringEscapeHelper.encode(field.getDescription()));
        fields.add(jsonField);
      }
      jsonObject.put("fields", fields);
      e.setAttribute("performanceLogTable", jsonObject.toString());

      MetricsLogTable metricsLogTable = transMeta.getMetricsLogTable();
      jsonObject = new JSONObject();
      jsonObject.put("connection", metricsLogTable.getConnectionName());
      jsonObject.put("schema", metricsLogTable.getSchemaName());
      jsonObject.put("table", metricsLogTable.getTableName());
      jsonObject.put("timeout_days", metricsLogTable.getTimeoutInDays());
      fields = new JSONArray();
      for (LogTableField field : metricsLogTable.getFields()) {
        JSONObject jsonField = new JSONObject();
        jsonField.put("id", field.getId());
        jsonField.put("enabled", field.isEnabled());
        jsonField.put("name", field.getFieldName());
        jsonField.put("description", StringEscapeHelper.encode(field.getDescription()));
        fields.add(jsonField);
      }
      jsonObject.put("fields", fields);
      e.setAttribute("metricsLogTable", jsonObject.toString());

      jsonObject = new JSONObject();
      jsonObject.put(
          "connection",
          transMeta.getMaxDateConnection() == null
              ? ""
              : transMeta.getMaxDateConnection().getName());
      jsonObject.put("table", transMeta.getMaxDateTable());
      jsonObject.put("field", transMeta.getMaxDateField());
      jsonObject.put("offset", transMeta.getMaxDateOffset());
      jsonObject.put("maxdiff", transMeta.getMaxDateDifference());
      e.setAttribute("maxdate", jsonObject.toString());

      e.setAttribute("size_rowset", String.valueOf(transMeta.getSizeRowset()));
      e.setAttribute("sleep_time_empty", String.valueOf(transMeta.getSleepTimeEmpty()));
      e.setAttribute("sleep_time_full", String.valueOf(transMeta.getSleepTimeFull()));
      e.setAttribute("unique_connections", transMeta.isUsingUniqueConnections() ? "Y" : "N");
      e.setAttribute("feedback_shown", transMeta.isFeedbackShown() ? "Y" : "N");
      e.setAttribute("feedback_size", String.valueOf(transMeta.getFeedbackSize()));
      e.setAttribute(
          "using_thread_priorities", transMeta.isUsingThreadPriorityManagment() ? "Y" : "N");
      e.setAttribute(
          "capture_step_performance", transMeta.isCapturingStepPerformanceSnapShots() ? "Y" : "N");
      e.setAttribute(
          "step_performance_capturing_delay",
          String.valueOf(transMeta.getStepPerformanceCapturingDelay()));
      e.setAttribute(
          "step_performance_capturing_size_limit",
          transMeta.getStepPerformanceCapturingSizeLimit());

      super.encodeSlaveServers(e, transMeta);
      encodeClusterSchema(e, transMeta);
      encodePartitionSchema(e, transMeta);

      try {
        if (transMeta.getKey() != null) {
          e.setAttribute("key_for_session_key", XMLHandler.encodeBinaryData(transMeta.getKey()));
        } else {
          e.setAttribute("key_for_session_key", "");
        }
      } catch (Exception e1) {
        e1.printStackTrace();
        e.setAttribute("key_for_session_key", "");
      }
      e.setAttribute("is_key_private", transMeta.isPrivateKey() ? "Y" : "N");

      super.encodeNote(doc, graph, transMeta);

      super.encodeDatabases(e, transMeta);
      parent.setValue(e);

      // encode steps and hops
      HashMap<StepMeta, Object> cells = new HashMap<StepMeta, Object>();
      List<StepMeta> list = transMeta.getSteps();
      for (int i = 0; i < list.size(); i++) {
        StepMeta step = (StepMeta) list.get(i);
        Point p = step.getLocation();
        StepEncoder stepEncoder = (StepEncoder) PluginFactory.getBean(step.getStepID());

        PluginInterface plugin =
            PluginRegistry.getInstance().getPlugin(StepPluginType.class, step.getStepID());
        Object cell =
            graph.insertVertex(
                parent,
                null,
                stepEncoder.encodeStep(step),
                p.x,
                p.y,
                40,
                40,
                "icon;image=" + SvgImageUrl.getUrl(plugin));
        cells.put(step, cell);
      }

      for (int i = 0; i < transMeta.nrTransHops(); i++) {
        TransHopMeta transHopMeta = transMeta.getTransHop(i);

        Object v1 = cells.get(transHopMeta.getFromStep());
        Object v2 = cells.get(transHopMeta.getToStep());

        graph.insertEdge(parent, null, TransHopMetaCodec.encode(transHopMeta), v1, v2);
      }
    } finally {
      graph.getModel().endUpdate();
    }

    mxCodec codec = new mxCodec();
    return mxUtils.getPrettyXml(codec.encode(graph.getModel()));
  }