public void attachSQLiteDatabase(String sqliteDBFile) throws DBException { SQLiteAccess query = new SQLiteAccess(sqliteDBFile); Collection<String> tableList = query.getTableList(); List<String> infoTableList = CollectionUtil.select( tableList, new Predicate<String>() { public boolean apply(String input) { return isInfoTable(input); } }); List<String> dataTableList = CollectionUtil.select( tableList, new Predicate<String>() { public boolean apply(String input) { return !isInfoTable(input); } }); // HashMap<String, HashMap<String, String>> for (String infoTable : infoTableList) { for (DataModelInfo info : query.amoebaQuery(DataModelInfo.class, infoTable)) {} } for (String dataTable : dataTableList) { Relation relation = new Relation(); for (SQLiteDataTypeInfo dataType : query.getSQLiteDataTypeInfo(dataTable)) { relation.add(Relation.getDataType(dataType.getName(), dataType.getType())); } addRelation(relation); } }
public void load(SQLiteAccess query) throws DBException { TreeSet<NodeData> nodeList = CollectionUtil.sort(query.amoebaQuery(NodeData.class, "node")); TreeSet<EdgeData> edgeList = CollectionUtil.sort(query.amoebaQuery(EdgeData.class, "edge")); for (NodeData node : nodeList) { _graph.addNode(node.getName()); } for (EdgeData edge : edgeList) { _graph.addEdge( new Edge(edge.getSrc(), edge.getDest()), EdgeData.translate(edge.getRelationship())); } }
@SuppressWarnings("unchecked") public List<String> destinationOf(String nodeName) { Collection<Integer> nodeIDSet = _graph.getDestNodeIDSetOf(_graph.getNodeID(nodeName)); return CollectionUtil.collect( nodeIDSet, new Functor<Integer, String>() { public String apply(Integer nodeID) { return _graph.getNodeLabel(nodeID); } }); }