2015-07-13 31 views
1

我读过的关于Gephi-0.8.2的一点是我应该使用Neo4j-2.1.3,但我也注意到服务器不再可供下载。Geo-0.8.2可以和Neo4j-2.1.8一起使用吗?

使用Gephi-0.8.2与Neo4j-2.1.8,我试图加载数据库的图形。我这样做是使用进口遍历选项,我得到了Gephi的日志文件中捕获以下异常,

WARNING [org.openide.filesystems.Ordering]: Found same position 600 for  
both Menu/File/org-gephi-desktop-importer-ImportDB.instance and 
Menu/File/org-gephi-desktop-neo4j-Neo4jMenuAction.instance 
WARNING  [org.netbeans.modules.autoupdate.updateproviders.AutoupdateCatalogFactory]: 
    Services/AutoupdateType/org_gephi_branding_update_center.instance: 
    url_key attribute deprecated in favor of url 
WARNING [org.netbeans.modules.autoupdate.updateproviders.AutoupdateCatalogFactory]: 
Services/AutoupdateType/org_gephi_branding_update_center_1.instance: 
url_key attribute deprecated in favor of url 
WARNING [org.netbeans.TopSecurityManager]: use of system property 
netbeans.user has been obsoleted in favor of InstalledFileLocator/Places 
at org.neo4j.kernel.info.SystemDiagnostics$7.dump 
(SystemDiagnostics.java:239) 
SEVERE [global] 
org.neo4j.graphdb.NotInTransactionException 
at org.neo4j.kernel.impl.persistence.PersistenceManager.getCurrentTransaction(PersistenceManager.java:297) 
at org.neo4j.kernel.impl.core.ThreadToStatementContextBridge.assertInTransaction(ThreadToStatementContextBridge.java:67) 
at org.neo4j.tooling.GlobalGraphOperations.assertInTransaction(GlobalGraphOperations.java:236) 
at org.neo4j.tooling.GlobalGraphOperations.getAllRelationshipTypes(GlobalGraphOperations.java:123) 
at org.neo4j.kernel.InternalAbstractGraphDatabase.getRelationshipTypes(InternalAbstractGraphDatabase.java:1074) 
at org.gephi.desktop.neo4j.ui.util.Neo4jUtils.relationshipTypeNames(Neo4jUtils.java:59) 
at org.gephi.desktop.neo4j.ui.TraversalImportPanel.initComponents(TraversalImportPanel.java:191) 
at org.gephi.desktop.neo4j.ui.TraversalImportPanel.<init>(TraversalImportPanel.java:55) 
at org.gephi.desktop.neo4j.Neo4jMenuAction$TraversalImportMenuAction.showTraversalDialog(Neo4jMenuAction.java:379) 
at org.gephi.desktop.neo4j.Neo4jMenuAction$TraversalImportMenuAction.actionPerformed(Neo4jMenuAction.java:334) 
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) 
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) 
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) 
at javax.swing.DefaultButtonModel.setPressed(Unknown Source) 
at javax.swing.AbstractButton.doClick(Unknown Source) 
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source) 
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source) 
at java.awt.Component.processMouseEvent(Unknown Source) 
at javax.swing.JComponent.processMouseEvent(Unknown Source) 
at java.awt.Component.processEvent(Unknown Source) 
at java.awt.Container.processEvent(Unknown Source) 
at java.awt.Component.dispatchEventImpl(Unknown Source) 
at java.awt.Container.dispatchEventImpl(Unknown Source) 
at java.awt.Component.dispatchEvent(Unknown Source) 
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) 
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) 
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) 
at java.awt.Container.dispatchEventImpl(Unknown Source) 
at java.awt.Window.dispatchEventImpl(Unknown Source) 
at java.awt.Component.dispatchEvent(Unknown Source) 
at java.awt.EventQueue.dispatchEventImpl(Unknown Source) 
at java.awt.EventQueue.access$300(Unknown Source) 
at java.awt.EventQueue$3.run(Unknown Source) 
at java.awt.EventQueue$3.run(Unknown Source) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown 
    Source) 
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown 
    Source) 
at java.awt.EventQueue$4.run(Unknown Source) 
at java.awt.EventQueue$4.run(Unknown Source) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) 
at java.awt.EventQueue.dispatchEvent(Unknown Source) 
    [catch] at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:158) 
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) 
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) 
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) 
at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
at java.awt.EventDispatchThread.run(Unknown Source) 

确实存在任何方式在这个环境中正常工作吗?我的系统是Windows 8.1专业版。

一切顺利,

非常感谢。

+0

是否进口graphdb工作? –

+0

是的,这是一种可能性,但我应该需要Neo4j的驱动程序。谢谢,让我试试看。 – oggie0563

回答

1

最后我决定了Gephi 0.9。问题是这个版本的应用程序没有与Neo4j服务器的驱动程序一起提供,所以我必须创建它并使该应用程序适应这个新驱动程序。

这里是改变我没有,

1)模块DBDrivers.-

我创建的驱动器,用于Neo4j的服务器如下,

package org.gephi.io.database.drivers; 

import java.sql.Connection; 
import java.sql.DriverManager; 
import java.sql.SQLException; 
import java.util.logging.Level; 
import java.util.logging.Logger; 

/** 
* 
* @author Jose Alvarez de Lara 
*/ 
public class Neo4jDriver implements SQLDriver { 

    public Neo4jDriver() { 
     try { 
      // load the Neo4j-JDBC driver using the current class loader 
      Class.forName("org.neo4j.jdbc.Driver"); 
     } catch (ClassNotFoundException ex) { 
      Logger.getLogger(Neo4jDriver.class.getName()).log(Level.SEVERE, null, ex); 
     } 
    } 

    public Connection getConnection(String connectionUrl, String username, String passwd) throws SQLException { 
     return DriverManager.getConnection(connectionUrl, null, null); 
    } 

    @Override 
    public String getPrefix() { 
     return "neo4j"; 
    } 

    @Override 
    public String toString() { 
     return "Neo4j"; 
    } 

    @Override 
    public boolean equals(Object obj) { 
     if (obj instanceof Neo4jDriver) { 
      return ((Neo4jDriver) obj).getPrefix().equals(getPrefix()); 
     } else { 
      return false; 
     } 
    } 

    @Override 
    public int hashCode() { 
     return getPrefix().hashCode(); 
    } 

} 

2)模块ImportPluginUI。 -

我在EdgeListPanel的代码中做了一些改变。 Java类文件女巫是如下,

在我添加的Neo4j延伸的构造,

public EdgeListPanel() { 
    databaseManager = new EdgeListDatabaseManager(); 
    initComponents(); 

    driverComboBox.addItemListener(new ItemListener() { 

     @Override 
     public void itemStateChanged(ItemEvent ie) { 
      initDriverType((SQLDriver) ie.getItem()); 
     } 
    }); 

    browseButton.setVisible(false); 
    browseButton.addActionListener(new ActionListener() { 

     @Override 
     public void actionPerformed(ActionEvent ae) { 
      String lastPath = NbPreferences.forModule(EdgeListPanel.class).get(LAST_PATH, ""); 
      final JFileChooser chooser = new JFileChooser(lastPath); 
      chooser.setAcceptAllFileFilterUsed(false); 
      chooser.setDialogTitle(NbBundle.getMessage(EdgeListPanel.class, "EdgeListPanel.sqliteFileChooser.title")); 
      DialogFileFilter dialogFileFilter = new DialogFileFilter(NbBundle.getMessage(EdgeListPanel.class, "EdgeListPanel.sqliteFileChooser.filefilter")); 
      dialogFileFilter.addExtension("sqlite"); 

      dialogFileFilter.addExtension("neo4j"); //add extensión for neo4j 

      dialogFileFilter.addExtension("db"); 
      chooser.addChoosableFileFilter(dialogFileFilter); 

      int returnFile = chooser.showSaveDialog(null); 
      if (returnFile != JFileChooser.APPROVE_OPTION) { 
       return; 
      } 
      File file = chooser.getSelectedFile(); 
      hostTextField.setText(file.getAbsolutePath()); 

      //Save last path 
      NbPreferences.forModule(EdgeListPanel.class).put(LAST_PATH, file.getParentFile().getAbsolutePath()); 
     } 
    }); 
} 

在initDriverType()方法我启用Neo4j的面板,

private void initDriverType(final SQLDriver driver) { 
    SwingUtilities.invokeLater(new Runnable() { 

     @Override 
     public void run() { 
      if (driver != null && driver.getPrefix().equals("sqlite")) { 
       hostLabel.setText(NbBundle.getMessage(EdgeListPanel.class, "EdgeListPanel.fileLabel.text")); 
       portTextField.setEnabled(false); 
       portLabel.setEnabled(false); 
       dbLabel.setEnabled(false); 
       dbTextField.setEnabled(false); 
       userLabel.setEnabled(false); 
       userTextField.setEnabled(false); 
       pwdLabel.setEnabled(false); 
       pwdTextField.setEnabled(false); 
       pwdTextField.setText(""); 
       userTextField.setText(""); 
       dbTextField.setText(""); 
       portTextField.setText(""); 
       browseButton.setVisible(true); 


      } else if (driver != null && driver.getPrefix().equals("neo4j")) { 
       hostLabel.setText(NbBundle.getMessage(EdgeListPanel.class, "EdgeListPanel.hostLabel.text")); 
       portTextField.setEnabled(true); 
       portLabel.setEnabled(true); 
       dbLabel.setEnabled(false); 
       dbTextField.setEnabled(false); 
       userLabel.setEnabled(false); 
       userTextField.setEnabled(false); 
       pwdLabel.setEnabled(false); 
       pwdTextField.setEnabled(false); 
       pwdTextField.setText(""); 
       userTextField.setText(""); 
       dbTextField.setText(""); 
       browseButton.setVisible(false); 


      } else { 
       hostLabel.setText(NbBundle.getMessage(EdgeListPanel.class, "EdgeListPanel.hostLabel.text")); 
       portTextField.setEnabled(true); 
       portLabel.setEnabled(true); 
       dbLabel.setEnabled(true); 
       dbTextField.setEnabled(true); 
       userLabel.setEnabled(true); 
       userTextField.setEnabled(true); 
       pwdLabel.setEnabled(true); 
       pwdTextField.setEnabled(true); 
       browseButton.setVisible(false); 
      } 
      group.validateAll(); 
     } 
    }); 
} 

以下方法是一个更通用的方法,然后是旧的isSqlite(),因为它允许我传递任何我需要的前缀。在这种情况下,它们应该是“源码”和“Neo4j的”

private static boolean isValidDriverPrefix(EdgeListPanel panel, String prefix) { 
    if (panel.databaseManager.getEdgeListDatabases().size() > 0) { 
     if (panel.databaseManager.getEdgeListDatabases().get(0).getSQLDriver().getPrefix().equals(prefix)) { 
      return true; 
     } 
     return false; 
    } else if (panel.getSelectedSQLDriver().getPrefix().equals(prefix)) { 
     return true; 
    } 
    return false; 
} 

我用它在以下内部类这一块,

private static class HostOrFileValidator implements Validator<String> { 

    private EdgeListPanel panel; 

    public HostOrFileValidator(EdgeListPanel panel) { 
     this.panel = panel; 
    } 

    @Override 
    public boolean validate(Problems problems, String compName, String model) { 
     if (isValidDriverPrefix(panel, "sqlite")) { 
      return Validators.FILE_MUST_BE_FILE.validate(problems, compName, model); 
     } else { 
      return Validators.REQUIRE_NON_EMPTY_STRING.validate(problems, compName, model); 
     } 
    } 
} 

private static class NotEmptyValidator implements Validator<String> { 

    private EdgeListPanel panel; 

    public NotEmptyValidator(EdgeListPanel panel) { 
     this.panel = panel; 
    } 

    @Override 
    public boolean validate(Problems problems, String compName, String model) { 
     if (isValidDriverPrefix(panel, "sqlite") || isValidDriverPrefix(panel, "neo4j")) { 
      return true; 
     } else { 
      return Validators.REQUIRE_NON_EMPTY_STRING.validate(problems, compName, model); 
     } 
    } 
} 

private static class PortValidator implements Validator<String> { 

    private EdgeListPanel panel; 

    public PortValidator(EdgeListPanel panel) { 
     this.panel = panel; 
    } 

    @Override 
    public boolean validate(Problems problems, String compName, String model) { 
     if (isValidDriverPrefix(panel, "sqlite")) { 
      return true; 
     } else { 
      return Validators.REQUIRE_NON_EMPTY_STRING.validate(problems, compName, model) 
        && Validators.REQUIRE_VALID_INTEGER.validate(problems, compName, model) 
        && Validators.numberRange(1, 65535).validate(problems, compName, model); 
     } 
    } 
} 

3)模块ImportPlugin.-

在这个模块中,我不得不修改类文件ImporterEdgeList.java,改变方法getNodes()和getEdges(),因为它们在实现Neo4j图形数据库时抛出了NullPointerException。这真的很简单,

private void getNodes(Connection connection) throws SQLException { 

    //Factory 
    ElementDraftFactory 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 count = 0; 
    while (rs.next()) { 
     String id = null; 
     for (int i = 0; i < columnsCount; i++) { 
      String columnName = metaData.getColumnLabel(i + 1); 
      NodeProperties p = properties.getNodeProperty(columnName); 

      if (p != null) { //Here p could be null 

       if (p.equals(NodeProperties.ID)) { 
        String ide = rs.getString(i + 1); 
        if (ide != null) { 
         id = ide; 
        } 
       } 
      } 
     } 
     NodeDraft node; 
     if (id != null) { 
      node = factory.newNodeDraft(id); 
     } else { 
      node = factory.newNodeDraft(); 
     } 

     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); 
     ++count; 
    } 
    rs.close(); 
    s.close(); 

} 

private void getEdges(Connection connection) throws SQLException { 

    //Factory 
    ElementDraftFactory 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 count = 0; 
    while (rs.next()) { 
     String id = null; 
     for (int i = 0; i < columnsCount; i++) { 
      String columnName = metaData.getColumnLabel(i + 1); 
      EdgeProperties p = properties.getEdgeProperty(columnName); 

      if (p != null) { //Here p could be null 

       if (p.equals(EdgeProperties.ID)) { 
        String ide = rs.getString(i + 1); 
        if (ide != null) { 
         id = ide; 
        } 
       } 
      } 
     } 
     EdgeDraft edge; 
     if (id != null) { 
      edge = factory.newEdgeDraft(id); 
     } else { 
      edge = factory.newEdgeDraft(); 
     } 
     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); 
     ++count; 
    } 
    rs.close(); 
    s.close(); 
} 

就这样。

这些变化后的Gephi 0.9针对Neo4j 2.1.8电影数据库和Neo4j 2.3.0-M01的同一个示例数据库在不需要验证时进行测试。

希望它有帮助!

+0

这里的https://gephi.wordpress.com/tag/database/博客文章,您可以找到所有关于Geo-0.8.2的Neo4j插件。这是一个很好的工作,很好的工作 – oggie0563

+0

,它显然不会恢复插件的功能,但是如果没有其他选项的话,这个工作就完成了。其实很容易申请。谢谢! –

0

要构建Gephi-0.9,您最好使用最新的NetBeans IDE,并从https://github.com/gephi/gephi下载应用程序和源代码。

打开源代码witch是一个Maven项目到NetBeans IDE中,如果您愿意,可以提取相应的模块以将更改作为独立的Maven项目进行。

完成后将... \ target \ nbm \ netbeans \ gephi文件夹的内容复制到Gephi-0.9应用程序的相应... \ gephi \ gephi文件夹中,然后就可以开始了。

这里是DBDrivers模块的pom.xml文件,

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
<modelVersion>4.0.0</modelVersion> 
<parent> 
    <artifactId>gephi-parent</artifactId> 
    <groupId>org.gephi</groupId> 
    <version>0.9-SNAPSHOT</version> 
    <relativePath>../..</relativePath> 
</parent> 

<groupId>org.gephi</groupId> 
<artifactId>db-drivers</artifactId> 
<version>0.9-SNAPSHOT</version> 
<packaging>nbm</packaging> 

<name>DBDrivers</name> 

<dependencies> 
    <dependency> 
     <groupId>org.xerial</groupId> 
     <artifactId>sqlite-jdbc</artifactId> 
     <version>3.7.2</version> 
    </dependency> 
    <dependency> 
     <groupId>mysql</groupId> 
     <artifactId>mysql-connector-java</artifactId> 
     <version>5.1.18</version> 
    </dependency> 
    <dependency> 
     <groupId>postgresql</groupId> 
     <artifactId>postgresql</artifactId> 
     <version>9.1-901-1.jdbc4</version> 
    </dependency> 
    <dependency> 
     <groupId>com.microsoft.sqlserver</groupId> 
     <artifactId>sqljdbc4</artifactId> 
     <version>3.0.1301.101</version> 
    </dependency> 
    <dependency> 
     <groupId>com.teradata</groupId> 
     <artifactId>teradata-jdbc</artifactId> 
     <version>14.00.00.21</version> 
    </dependency> 
    <dependency> 
     <groupId>com.teradata</groupId> 
     <artifactId>teradata-config</artifactId> 
     <version>14.00.00.21</version> 
    </dependency> 
    <dependency> 
     <groupId>org.neo4j</groupId> 
     <artifactId>neo4j-jdbc</artifactId> 
     <version>2.1.4</version> 
    </dependency> 
    <dependency> 
     <groupId>org.netbeans.api</groupId> 
     <artifactId>org-openide-util-lookup</artifactId> 
    </dependency> 
</dependencies> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>nbm-maven-plugin</artifactId> 
      <configuration> 
       <publicPackages> 
        <publicPackage>org.gephi.io.database.drivers</publicPackage> 
       </publicPackages> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>2.3.2</version> 
      <configuration> 
       <source>1.7</source> 
       <target>1.7</target> 
      </configuration> 
     </plugin> 
    </plugins> 
    </build> 
</project> 
相关问题