提交 b91ecc8d 编写于 作者: E Eduardo Ramos

Fix #1802 Exception with no-merge strategy in some cases. Incompatible edge should not be created

上级 8d5864d0
......@@ -228,27 +228,32 @@ public class DefaultProcessor extends AbstractProcessor {
Edge edge = graph.getEdge(source, target, edgeType);
//Undirected and directed edges are incompatible, check for them or we could get an exception:
boolean canCreateEdge = true;
if (edge == null) {
if (createDirected) {
//The edge may exist with opposite source-target but undirected. In that case we can't create a directed one:
edge = graph.getEdge(target, source, edgeType);
if (edge != null && edge.isDirected()) {
edge = null;//Actually it's directed so we can create the opposite directed edge
}
if (edgesMergeStrategy == EdgeMergeStrategy.NO_MERGE) {
//Undirected and directed edges are incompatible, check for them or we could get an exception:
final Edge incompatibleEdge = findIncompatibleEdge(graph, source, target, createDirected, edgeType);
if (incompatibleEdge == null) {
//Force create, no merge
edge = null;
} else {
edge = graph.getEdge(target, source, edgeType);
String message = NbBundle.getMessage(
DefaultProcessor.class, "DefaultProcessor.error.incompatibleEdges",
String.format(
"[%s -> %s; %s, type %s]",
sourceId, targetId, createDirected ? "Directed" : "Undirected", type
),
String.format(
"[%s -> %s; %s; type: %s; id: %s]",
incompatibleEdge.getSource().getId(), incompatibleEdge.getTarget().getId(),
incompatibleEdge.isDirected() ? "Directed" : "Undirected",
incompatibleEdge.getTypeLabel(),
incompatibleEdge.getId()
)
);
report.logIssue(new Issue(message, Issue.Level.WARNING));
Progress.progress(progressTicket);
continue;
}
if (edge != null) {
canCreateEdge = false;
}
}
if (canCreateEdge && edgesMergeStrategy == EdgeMergeStrategy.NO_MERGE) {
edge = null;//Force create, no merge
}
boolean newEdge = edge == null;
......@@ -286,6 +291,32 @@ public class DefaultProcessor extends AbstractProcessor {
Progress.finish(progressTicket);
}
private Edge findIncompatibleEdge(Graph graph, Node source, Node target, boolean directed, int edgeType) {
Edge edge = graph.getEdge(source, target, edgeType);
if (edge == null) {
if (directed) {
//The edge may exist with opposite source-target but undirected. In that case we can't create a directed one:
edge = graph.getEdge(target, source, edgeType);
if (edge != null && edge.isDirected()) {
//Actually it's directed so we can create the opposite directed edge, not incompatible
edge = null;
}
} else {
//Undirected but opposite edges are not compatible, check for it
edge = graph.getEdge(target, source, edgeType);
}
} else {
if (edge.isDirected() == directed) {
//Same directedness, not incompatible
edge = null;
}
}
return edge;
}
private Object toElementId(ElementIdType elementIdType, String idString) {
Object id;
switch (elementIdType) {
......
Manifest-Version: 1.0
AutoUpdate-Essential-Module: true
OpenIDE-Module-Localizing-Bundle: org/gephi/io/processor/plugin/Bundle.properties
OpenIDE-Module-Specification-Version: ${gephi.modules.specification.version}
OpenIDE-Module-Specification-Version: 0.9.2.1
OpenIDE-Module-Display-Category: Plugin
OpenIDE-Module-Name: Processor Plugin
\ No newline at end of file
......@@ -10,4 +10,5 @@ AbstractProcessor.error.columnTypeMismatch=Existing column ''{0}'' in graph with
AbstractProcessor.error.columnDefaultValueTypeMismatch=Column ''{0}'' default value ''{1}'' with type ''{2}'' is not compatible with the column type ''{3}''. Using null as default value.
AbstractProcessor.error.unavailableColumnType=Attribute type ''{0}'' is unavailable for current time representation: {1}. Cannot add column with id ''{2}''.
DefaultProcessor.error.configurationChangeForbidden=Cannot change graph configuration when the graph is not empty. Original configuration: {0}, new wanted configuration: {1}
\ No newline at end of file
DefaultProcessor.error.configurationChangeForbidden=Cannot change graph configuration when the graph is not empty. Original configuration: {0}, new wanted configuration: {1}
DefaultProcessor.error.incompatibleEdges=No merge strategy was chosen but the edge {0} cannot be created because it can''t exist at the same time with edge {1} (incompatible). Skipping new edge.
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册