Search in sources :

Example 36 with Issue

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);
}
Also used : Issue(org.gephi.io.importer.api.Issue) TimestampSet(org.gephi.graph.api.types.TimestampSet)

Example 37 with Issue

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;
}
Also used : Issue(org.gephi.io.importer.api.Issue)

Example 38 with Issue

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;
}
Also used : Issue(org.gephi.io.importer.api.Issue)

Example 39 with Issue

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);
}
Also used : Issue(org.gephi.io.importer.api.Issue) EdgeDirection(org.gephi.io.importer.api.EdgeDirection)

Example 40 with Issue

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;
}
Also used : Issue(org.gephi.io.importer.api.Issue)

Aggregations

Issue (org.gephi.io.importer.api.Issue)52 NodeDraft (org.gephi.io.importer.api.NodeDraft)14 IOException (java.io.IOException)11 ColumnDraft (org.gephi.io.importer.api.ColumnDraft)10 EdgeDraft (org.gephi.io.importer.api.EdgeDraft)9 StringTokenizer (java.util.StringTokenizer)5 SQLException (java.sql.SQLException)4 ArrayList (java.util.ArrayList)4 XMLStreamException (javax.xml.stream.XMLStreamException)3 Interval (org.gephi.graph.api.Interval)3 EdgeProperties (org.gephi.io.importer.api.PropertiesAssociations.EdgeProperties)3 NodeProperties (org.gephi.io.importer.api.PropertiesAssociations.NodeProperties)3 Color (java.awt.Color)2 ResultSet (java.sql.ResultSet)2 ResultSetMetaData (java.sql.ResultSetMetaData)2 Statement (java.sql.Statement)2 Pattern (java.util.regex.Pattern)2 IntervalSet (org.gephi.graph.api.types.IntervalSet)2 TimestampSet (org.gephi.graph.api.types.TimestampSet)2 ElementDraft (org.gephi.io.importer.api.ElementDraft)2