2015-07-13 55 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> 
相關問題