我读到的关于Gephi-0.8.2的内容是我应该使用Neo4j-2.1.3,但我也注意到服务器不再可供下载。
将Gephi-0.8.2与Neo4j-2.1.8一起使用,我试图加载数据库图。我使用Import Traversal选项执行此操作,并在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 :(得分:1)
最后我决定使用Gephi 0.9。问题是这个版本的应用程序没有配备Neo4j服务器的驱动程序,所以我不得不创建它并为这个新驱动程序调整应用程序。
以下是我所做的更改,
1)模块DBDrivers .-
我为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());
}
});
}
2)模块ImportPluginUI .-
我在EdgeListPanel.java类文件的代码中做了一些更改,如下所示,
在构造函数中,我为Neo4j添加了extensión,
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();
}
});
}
在initDriverType()方法中,我启用了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;
}
以下方法是一种更通用的方法,然后旧方法是SQLite(),因为它让我传递我需要的任何前缀。在这种情况下,它们应该是“sqlite”和“neo4j”
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);
}
}
}
我在下面的内部类中使用它,
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();
}
3)模块ImportPlugin .-
在这个模块中,我必须调整类文件ImporterEdgeList.java,改变方法getNodes()和getEdges(),因为它们在实现Neo4j图形数据库时抛出了NullPointerException。这很简单,
ops = {"+": operator.add,
"-": operator.sub,
"*": operator.mul,
"/": operator.div}
就是这样。
这些更改后的Gephi 0.9针对Neo4j 2.1.8电影数据库和Neo4j 2.3.0-M01的相同示例数据库进行了测试,但未进行身份验证。
希望它有所帮助!
答案 1 :(得分:0)
要构建Gephi-0.9,最好使用最新的NetBeans IDE,并从https://github.com/gephi/gephi下载应用程序和源代码。
打开源代码,这是一个进入NetBeans IDE的maven项目,如果您愿意,可以提取相应的模块以将更改作为独立的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>