Beispiel #1
0
  private ListMap sortNodesByAttributePrefix(
      Table nodeTable, String compareAttributeName, int numPrefixLetters) {
    ListMap nodesByAttributePrefix = new ListMap();
    // for each node in the node table...
    for (IntIterator nodeIndexIt = nodeTable.rows(); nodeIndexIt.hasNext(); ) {
      int nodeIndex = nodeIndexIt.nextInt();
      Tuple row = nodeTable.getTuple(nodeIndex);
      // get the attribute contents
      String comparisonAttributeContents = row.getString(compareAttributeName);
      if (comparisonAttributeContents == null) continue;
      // add the node index to our list map, in the bin with a key made from a prefix of the
      // attribute e.g. "do" for "donkey"
      String prefixKey = extractPrefixKey(comparisonAttributeContents, numPrefixLetters);
      nodesByAttributePrefix.put(prefixKey, new Integer(nodeIndex));
    }

    return nodesByAttributePrefix;
  }
  @Before
  public void setUp() {
    m_vis = new Visualization();
    m_t = TableTest.getTestCaseTable();
    m_g = GraphTest.getTestCaseGraph();

    m_t0 = m_t.getTuple(0);
    m_n0 = m_g.getNode(0);

    VisualTable vt = (VisualTable) m_vis.add("t", m_t);
    VisualGraph vg = (VisualGraph) m_vis.add("g", m_g);

    m_vt0 = vt.getItem(0);
    m_vn0 = (NodeItem) vg.getNode(0);

    TupleSet ts = m_vis.getFocusGroup(Visualization.FOCUS_ITEMS);
    ts.addTuple(m_vt0);
    ts.addTuple(m_vn0);
  }
Beispiel #3
0
  private Merger collectMerges(Table mergingTable, DatabaseTable toBeMerged, Connection connection)
      throws AlgorithmExecutionException {

    Merger merger = new Merger(toBeMerged, monitor);
    try {
      String[] primaryKeyColumns = toBeMerged.getPrimaryKeyColumns(connection);
      ColumnProjection primaryKeyColumnFilter = new NamedColumnProjection(primaryKeyColumns, true);

      ForeignKey[] foreignKeys = toBeMerged.getRelations(connection);
      for (ForeignKey foreignKey : foreignKeys) {
        // merge units are the units of work that will repoint the foreign keys referring to the
        // entities merged away to point at the primary entities
        merger.addMergeUnit(new MergeUnit(foreignKey));
      }

      TableIterator merges =
          mergingTable.iterator(
              mergingTable.rowsSortedBy(CreateMergingTable.MERGE_GROUP_IDENTIFIER_COLUMN, true));

      while (merges.hasNext()) {
        int row = merges.nextInt();
        Tuple tuple = mergingTable.getTuple(row);
        String groupIdentifier = tuple.getString(CreateMergingTable.MERGE_GROUP_IDENTIFIER_COLUMN);
        // for every key someone used for a merge group, there's an EntityGroup
        EntityGroup group =
            merger.getOrCreateEntityGroup(
                groupIdentifier, toBeMerged, primaryKeyColumnFilter, foreignKeys);
        try {
          group.addRecord(tuple);
        } catch (MergingErrorException e) {
          problems.add(e.getMessage());
        }
      }

      return merger;

    } catch (SQLException e) {
      throw new AlgorithmExecutionException("There was a problem creating the output data.", e);
    }
  }