Import Node's Attributes

Get help with your data
Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
jhon22aq
Posts:1
Joined:17 May 2011 11:28
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
Import Node's Attributes

Post by jhon22aq » 17 May 2011 11:47

Hi,
I'm currently using Gephi source code for a school project. I have a database conform to the Edge List format where nodes NODE(ID,LABEL,TYPE) are different kinds of entities. Each node type has a table associated with it (eg USER(ID,AGE,...), CONTENT(ID,DIMENSION,...)) where I store attributes.
Is there a way to import these attributes in Gephi. I tried to add attributes to nodes after the graph has been created using this code

Code: Select all

            stmt = connection.createStatement();
            rs = stmt.executeQuery(attributeQuery);
           ResultSetMetaData rsMetaData = (ResultSetMetaData) rs.getMetaData();
             AttributeColumn attrcolumn;
            int numberOfColumns = rsMetaData.getColumnCount();
            ArrayList<String> attributesIDs = new ArrayList<String>();
            for (int i = 1; i <= numberOfColumns; i++) {
                String attributeID = rsMetaData.getColumnName(i);
                int attributeType = rsMetaData.getColumnType(i);
                 attrcolumn = model.getNodeTable().getColumn(attributeID);
                if (attrcolumn == null){
                    //Add column
                    attrcolumn = model.getNodeTable().addColumn(attributeID, AttributeType.STRING);
                }
                attributesIDs.add(attributeID);
            }
            //OverWrite values to nodes
            while (rs.next()) {
                Node n = graphModel.getGraph().getNode(rs.getString("ID"));
                for(int j=1; j<attributesIDs.size(); j++){
                    if (!attributesIDs.get(j).equalsIgnoreCase("ID"))
                         n.getNodeData().getAttributes().setValue(
                                              model.getNodeTable().getColumn(
                                                   attributesIDs.get(j)).getIndex(), rs.getInt(j+1));
                }

Is there an easier way?

Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable