commit f411c15b8809689bfa0068714012af527f3a99b9
Author: Vít Mazín <vit.mazin@seznam.cz>
Date:   Sun Mar 31 16:09:58 2019 +0200

    DOT loader which gives DTO objects for vertices and edges etc.

diff --git a/sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/loader/BaseDOTLoader.java b/sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/loader/BaseDOTLoader.java
index 8cc5d1a..8e268c6 100644
--- a/sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/loader/BaseDOTLoader.java
+++ b/sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/loader/BaseDOTLoader.java
@@ -4,20 +4,20 @@ import cz.zcu.kiv.imiger.plugin.dot.dto.EdgeDTO;
 import cz.zcu.kiv.imiger.plugin.dot.dto.VertexDTO;
 import cz.zcu.kiv.imiger.vo.AttributeType;
 
-import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 public abstract class BaseDOTLoader<V extends VertexDTO, E extends EdgeDTO> {
 
-    private final String dotInput;
+    protected final String dotInput;
 
     public BaseDOTLoader(String dotInput) {
         this.dotInput = dotInput;
     }
 
-    public abstract List<V> getVerticies();
+    public abstract List<V> getVertices();
 
     public abstract List<E> getEdges();
 
-    public abstract HashSet<AttributeType> getAttributeTypes();
+    public abstract Set<AttributeType> getAttributeTypes();
 }
diff --git a/sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/loader/PaypalDOTLoader.java b/sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/loader/PaypalDOTLoader.java
index b329a46..caae46d 100644
--- a/sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/loader/PaypalDOTLoader.java
+++ b/sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/loader/PaypalDOTLoader.java
@@ -1,30 +1,92 @@
 package cz.zcu.kiv.imiger.plugin.dot.loader;
 
+import com.paypal.digraph.parser.GraphEdge;
+import com.paypal.digraph.parser.GraphNode;
+import com.paypal.digraph.parser.GraphParser;
+import com.paypal.digraph.parser.GraphParserException;
 import cz.zcu.kiv.imiger.plugin.dot.dto.EdgeDTO;
 import cz.zcu.kiv.imiger.plugin.dot.dto.VertexDTO;
+import cz.zcu.kiv.imiger.vo.AttributeDataType;
 import cz.zcu.kiv.imiger.vo.AttributeType;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
-import java.util.HashSet;
-import java.util.List;
+import java.io.ByteArrayInputStream;
+import java.util.*;
 
 public class PaypalDOTLoader extends BaseDOTLoader<VertexDTO, EdgeDTO> {
+    private static Logger logger = LogManager.getLogger();
+
+    private GraphParser parser;
+    private final List<VertexDTO> vertices;
+    private final List<EdgeDTO> edges;
+    private final HashSet<AttributeType> attributeTypes;
+    private final HashMap<GraphNode, Integer> remappedVertices;
 
     public PaypalDOTLoader(String dotInput) {
         super(dotInput);
+        parser = null;
+
+        try {
+            parser = new GraphParser(new ByteArrayInputStream(super.dotInput.getBytes()));
+        } catch (GraphParserException ex) {
+            logger.warn("There was a mistake in input DOT file. Exception: " + ex.getMessage());
+        }
+        vertices = new ArrayList<>();
+        edges = new ArrayList<>();
+        attributeTypes = new HashSet<>();
+        remappedVertices = new HashMap<>();
+        processEdges();
+        processVertices();
     }
 
     @Override
-    public List<VertexDTO> getVerticies() {
-        return null;
+    public List<VertexDTO> getVertices() {
+        return vertices;
     }
 
     @Override
     public List<EdgeDTO> getEdges() {
-        return null;
+        return edges;
     }
 
     @Override
-    public HashSet<AttributeType> getAttributeTypes() {
-        return null;
+    public Set<AttributeType> getAttributeTypes() {
+        return attributeTypes;
+    }
+
+    private void processVertices() {
+        int id = 0;
+
+        for(GraphNode node : this.parser.getNodes().values()) {
+            HashMap<String, String> attrs = new HashMap<>();
+            for(Map.Entry<String, Object> entry : node.getAttributes().entrySet()) {
+                attrs.put(entry.getKey(), entry.getValue().toString());
+                attributeTypes.add(new AttributeType(entry.getKey(), AttributeDataType.STRING, ""));
+            }
+
+            VertexDTO vertex = new VertexDTO(node.getId(), id++, attrs);
+            this.remappedVertices.put(node, vertex.getId());
+
+            vertices.add(vertex);
+        }
+    }
+
+    private void processEdges() {
+        int id = 0;
+
+        for(GraphEdge edge : this.parser.getEdges().values()) {
+            HashMap<String, String> attrs = new HashMap<>();
+            for(Map.Entry<String, Object> entry : edge.getAttributes().entrySet()) {
+                attrs.put(entry.getKey(), entry.getValue().toString());
+                attributeTypes.add(new AttributeType(entry.getKey(), AttributeDataType.STRING, ""));
+            }
+
+            int from = remappedVertices.get(edge.getNode1());
+            int to = remappedVertices.get(edge.getNode2());
+            EdgeDTO edgeDTO = new EdgeDTO(edge.getId(), from, to, id++, attrs);
+
+            edges.add(edgeDTO);
+        }
     }
 }
