use of org.gephi.io.importer.api.Issue in project gephi by gephi.
the class ElementDraftImpl method addTimestamp.
@Override
public void addTimestamp(double timestamp) {
if (!container.getTimeRepresentation().equals(TimeRepresentation.TIMESTAMP)) {
String message = NbBundle.getMessage(ElementDraftImpl.class, "ElementDraftException_NotTimestampRepresentation", id);
container.getReport().logIssue(new Issue(message, Issue.Level.SEVERE));
return;
}
if (timeSet == null) {
timeSet = new TimestampSet();
}
timeSet.add(timestamp);
}
use of org.gephi.io.importer.api.Issue in project gephi by gephi.
the class ElementFactoryImpl method newEdgeDraft.
@Override
public EdgeDraftImpl newEdgeDraft(String id) {
if (id == null) {
String message = NbBundle.getMessage(ElementFactoryImpl.class, "ElementFactoryException_NullEdgeId");
container.getReport().logIssue(new Issue(message, Issue.Level.CRITICAL));
}
EdgeDraftImpl edge = new EdgeDraftImpl(container, id);
return edge;
}
use of org.gephi.io.importer.api.Issue in project gephi by gephi.
the class ElementFactoryImpl method newNodeDraft.
@Override
public NodeDraftImpl newNodeDraft(String id) {
if (id == null) {
String message = NbBundle.getMessage(ElementFactoryImpl.class, "ElementFactoryException_NullNodeId");
container.getReport().logIssue(new Issue(message, Issue.Level.CRITICAL));
}
NodeDraftImpl node = new NodeDraftImpl(container, id);
return node;
}
use of org.gephi.io.importer.api.Issue in project gephi by gephi.
the class ImportContainerImpl method addEdge.
@Override
public void addEdge(EdgeDraft edgeDraft) {
checkElementDraftImpl(edgeDraft);
EdgeDraftImpl edgeDraftImpl = (EdgeDraftImpl) edgeDraft;
if (edgeDraftImpl.getSource() == null) {
String message = NbBundle.getMessage(ImportContainerImpl.class, "ImportContainerException_MissingNodeSource");
report.logIssue(new Issue(message, Level.SEVERE));
return;
}
if (edgeDraftImpl.getTarget() == null) {
String message = NbBundle.getMessage(ImportContainerImpl.class, "ImportContainerException_MissingNodeTarget");
report.logIssue(new Issue(message, Level.SEVERE));
return;
}
//Check if already exists
if (edgeMap.containsKey(edgeDraftImpl.getId())) {
String message = NbBundle.getMessage(ImportContainerImpl.class, "ImportContainerException_edgeExist", edgeDraftImpl.getId());
report.logIssue(new Issue(message, Level.WARNING));
return;
}
//Self loop
if (edgeDraftImpl.isSelfLoop() && !parameters.isSelfLoops()) {
String message = NbBundle.getMessage(ImportContainerImpl.class, "ImportContainerException_SelfLoop");
report.logIssue(new Issue(message, Level.SEVERE));
return;
}
//Check direction and defaut type
if (edgeDraftImpl.getDirection() != null) {
//Test if the given type match with parameters
switch(edgeDefault) {
case DIRECTED:
if (edgeDraftImpl.getDirection().equals(EdgeDirection.UNDIRECTED)) {
report.logIssue(new Issue(NbBundle.getMessage(ImportContainerImpl.class, "ImportContainerException_Bad_Edge_Type", edgeDefault, edgeDraftImpl.getId()), Level.SEVERE));
return;
}
break;
case UNDIRECTED:
if (edgeDraftImpl.getDirection().equals(EdgeDirection.DIRECTED)) {
report.logIssue(new Issue(NbBundle.getMessage(ImportContainerImpl.class, "ImportContainerException_Bad_Edge_Type", edgeDefault, edgeDraftImpl.getId()), Level.SEVERE));
return;
}
break;
}
}
//Get index
int index = edgeList.size();
//Type
int edgeType = getEdgeType(edgeDraftImpl.getType());
long sourceTargetLong = getLongId(edgeDraftImpl);
ensureLongSetArraySize(edgeType);
Long2ObjectMap<int[]> edgeTypeSet = edgeTypeSets[edgeType];
if (edgeTypeSet.containsKey(sourceTargetLong)) {
if (!parameters.isParallelEdges()) {
report.logIssue(new Issue(NbBundle.getMessage(ImportContainerImpl.class, "ImportContainerException_Parallel_Edge_Forbidden", edgeDraftImpl.getId()), Level.SEVERE));
return;
} else {
int[] edges = edgeTypeSet.get(sourceTargetLong);
int[] newEdges = new int[edges.length + 1];
newEdges[edges.length] = index;
System.arraycopy(edges, 0, newEdges, 0, edges.length);
edgeTypeSet.put(sourceTargetLong, newEdges);
if (!reportedParallelEdges) {
report.logIssue(new Issue(NbBundle.getMessage(ImportContainerImpl.class, "ImportContainerException_Parallel_Edge", edgeDraftImpl.getId()), Level.INFO));
reportedParallelEdges = true;
}
}
} else {
edgeTypeSet.put(sourceTargetLong, new int[] { index });
}
//Self loop
if (edgeDraftImpl.isSelfLoop()) {
selfLoops++;
}
//Direction
EdgeDirection direction = edgeDraftImpl.getDirection();
if (direction != null) {
//Counting
switch(direction) {
case DIRECTED:
directedEdgesCount++;
break;
case UNDIRECTED:
undirectedEdgesCount++;
break;
}
}
//Adding
edgeList.add(edgeDraftImpl);
edgeMap.put(edgeDraft.getId(), index);
}
use of org.gephi.io.importer.api.Issue in project gephi by gephi.
the class ImportContainerImpl method getEdgeType.
//Utility
private int getEdgeType(Object type) {
//Verify
if (type != null) {
Class cl = type.getClass();
if (!(cl.equals(Integer.class) || cl.equals(String.class) || cl.equals(Float.class) || cl.equals(Double.class) || cl.equals(Short.class) || cl.equals(Byte.class) || cl.equals(Long.class) || cl.equals(Character.class) || cl.equals(Boolean.class))) {
report.logIssue(new Issue(NbBundle.getMessage(ImportContainerImpl.class, "ImportContainerException_Unsupported_Edge_type"), Level.SEVERE));
type = null;
}
if (type != null && lastEdgeType != null && !lastEdgeType.equals(type.getClass())) {
report.logIssue(new Issue(NbBundle.getMessage(ImportContainerImpl.class, "ImportContainerException_Unsupported_Edge_type_Conflict", type.getClass().getSimpleName(), lastEdgeType.getSimpleName()), Level.SEVERE));
type = null;
}
}
if (type != null) {
lastEdgeType = type.getClass();
}
if (edgeTypeMap.containsKey(type)) {
return edgeTypeMap.getInt(type);
}
int id = edgeTypeMap.size();
edgeTypeMap.put(type, id);
return id;
}
Aggregations