Search in sources :

Example 1 with PropertiesAssociations

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();
}
Also used : ColumnDraft(org.gephi.io.importer.api.ColumnDraft) Issue(org.gephi.io.importer.api.Issue) SQLException(java.sql.SQLException) ElementDraft(org.gephi.io.importer.api.ElementDraft) PropertiesAssociations(org.gephi.io.importer.api.PropertiesAssociations) Statement(java.sql.Statement) ResultSetMetaData(java.sql.ResultSetMetaData) EdgeDraft(org.gephi.io.importer.api.EdgeDraft) ResultSet(java.sql.ResultSet) EdgeProperties(org.gephi.io.importer.api.PropertiesAssociations.EdgeProperties)

Example 2 with PropertiesAssociations

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();
}
Also used : ColumnDraft(org.gephi.io.importer.api.ColumnDraft) Issue(org.gephi.io.importer.api.Issue) SQLException(java.sql.SQLException) ElementDraft(org.gephi.io.importer.api.ElementDraft) PropertiesAssociations(org.gephi.io.importer.api.PropertiesAssociations) Statement(java.sql.Statement) NodeDraft(org.gephi.io.importer.api.NodeDraft) ResultSetMetaData(java.sql.ResultSetMetaData) NodeProperties(org.gephi.io.importer.api.PropertiesAssociations.NodeProperties) ResultSet(java.sql.ResultSet)

Aggregations

ResultSet (java.sql.ResultSet)2 ResultSetMetaData (java.sql.ResultSetMetaData)2 SQLException (java.sql.SQLException)2 Statement (java.sql.Statement)2 ColumnDraft (org.gephi.io.importer.api.ColumnDraft)2 ElementDraft (org.gephi.io.importer.api.ElementDraft)2 Issue (org.gephi.io.importer.api.Issue)2 PropertiesAssociations (org.gephi.io.importer.api.PropertiesAssociations)2 EdgeDraft (org.gephi.io.importer.api.EdgeDraft)1 NodeDraft (org.gephi.io.importer.api.NodeDraft)1 EdgeProperties (org.gephi.io.importer.api.PropertiesAssociations.EdgeProperties)1 NodeProperties (org.gephi.io.importer.api.PropertiesAssociations.NodeProperties)1