use of org.gephi.io.importer.api.PropertiesAssociations in project gephi by gephi.
the class ImporterEdgeList method getEdges.
private void getEdges(Connection connection) throws SQLException {
// Factory
ElementDraft.Factory factory = container.factory();
// Properties
PropertiesAssociations properties = database.getPropertiesAssociations();
Statement s = connection.createStatement();
ResultSet rs = null;
try {
rs = s.executeQuery(database.getEdgeQuery());
} catch (SQLException ex) {
report.logIssue(new Issue("Failed to execute Edge query", Issue.Level.SEVERE, ex));
return;
}
findEdgeAttributesColumns(rs);
ResultSetMetaData metaData = rs.getMetaData();
int columnsCount = metaData.getColumnCount();
int idColumn = edgeColumns.findIdIndex(metaData, properties);
while (rs.next()) {
EdgeDraft edge = edgeColumns.getEdgeDraft(factory, rs, idColumn);
for (int i = 0; i < columnsCount; i++) {
String columnName = metaData.getColumnLabel(i + 1);
EdgeProperties p = properties.getEdgeProperty(columnName);
if (p != null) {
injectEdgeProperty(p, rs, i + 1, edge);
} else {
// Inject edge attributes
ColumnDraft col = container.getEdgeColumn(columnName);
injectElementAttribute(rs, i + 1, col, edge);
}
}
injectTimeIntervalProperty(edge);
container.addEdge(edge);
}
rs.close();
s.close();
}
use of org.gephi.io.importer.api.PropertiesAssociations in project gephi by gephi.
the class ImporterEdgeList method getNodes.
private void getNodes(Connection connection) throws SQLException {
// Factory
ElementDraft.Factory factory = container.factory();
// Properties
PropertiesAssociations properties = database.getPropertiesAssociations();
Statement s = connection.createStatement();
ResultSet rs = null;
try {
rs = s.executeQuery(database.getNodeQuery());
} catch (SQLException ex) {
report.logIssue(new Issue("Failed to execute Node query", Issue.Level.SEVERE, ex));
return;
}
findNodeAttributesColumns(rs);
ResultSetMetaData metaData = rs.getMetaData();
int columnsCount = metaData.getColumnCount();
int idColumn = nodeColumns.findIdIndex(metaData, properties);
while (rs.next()) {
final NodeDraft node = nodeColumns.getNodeDraft(factory, rs, idColumn);
for (int i = 0; i < columnsCount; i++) {
String columnName = metaData.getColumnLabel(i + 1);
NodeProperties p = properties.getNodeProperty(columnName);
if (p != null) {
injectNodeProperty(p, rs, i + 1, node);
} else {
// Inject node attributes
ColumnDraft col = container.getNodeColumn(columnName);
injectElementAttribute(rs, i + 1, col, node);
}
}
injectTimeIntervalProperty(node);
container.addNode(node);
}
rs.close();
s.close();
}
Aggregations