commit a2dfd926ea4e5d9e2270e2979726372afaedaa53
Author: Martin Matas <nouzovekonto@gmail.com>
Date:   Tue Apr 2 16:45:48 2019 +0200

    Fixed creation of attribute structure, documentation
    
    - structure of attributes was adjusted to produces string array, where first value is type of attribute and the second value is the value of attribute
    - documentation comments were added into implemented files

diff --git a/sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/BaseGraphFactory.java b/sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/BaseGraphFactory.java
index 7d1ea3c..91746c5 100644
--- a/sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/BaseGraphFactory.java
+++ b/sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/BaseGraphFactory.java
@@ -8,19 +8,48 @@ import cz.zcu.kiv.imiger.vo.*;
 import java.util.*;
 
 /**
+ * Factory provides generic implementation for creating instance of {@link Graph} from
+ * data retrieved using given instance of {@link BaseDOTLoader}.
+ *
  * Date: 31.03.2019
  *
  * @author Martin Matas
  */
 public abstract class BaseGraphFactory<V extends VertexDTO, E extends EdgeDTO> {
 
+	/**
+	 * List of vertex archetypes that must factory initialize.
+	 */
 	protected List<VertexArchetype> vertexArchetypes;
+
+	/**
+	 * List of edge archetypes that must factory initialize.
+	 */
 	protected List<EdgeArchetype> edgeArchetypes;
+
+	/**
+	 * List of defined attribute types retrieved from {@link BaseDOTLoader}.
+	 */
 	protected List<AttributeType> attributeTypes;
+
+	/**
+	 * List of defined vertices retrieved from {@link BaseDOTLoader}. {@link VertexDTO} is
+	 * specific vertex created with DOTLoader.
+	 */
 	protected List<VertexDTO> vertices;
-	protected List<EdgeDTO> edges;
 
+	/**
+	 * List of defined edges retrieved from {@link BaseDOTLoader}. {@link EdgeDTO} is
+	 * specific vertex created with DOTLoader.
+	 */
+	protected List<EdgeDTO> edges;
 
+	/**
+	 * Constructor initialize data that can be retrieved from {@link BaseDOTLoader}, the rest of
+	 * necessary attributes for creating graph must be initialized in children of this abstract class.
+	 *
+	 * @param dotLoader - instance of {@link BaseDOTLoader} which provides parsed data from DOT file
+	 */
 	protected BaseGraphFactory(BaseDOTLoader<V, E> dotLoader) {
 		vertices = new ArrayList<>();
 		edges = new ArrayList<>();
@@ -28,8 +57,18 @@ public abstract class BaseGraphFactory<V extends VertexDTO, E extends EdgeDTO> {
 		loadData(dotLoader);
 	}
 
+	/**
+	 * Must initialize necessary attributes for creating graph from data provided by {@link BaseDOTLoader}.
+	 *
+	 * @param dotLoader - instance of {@link BaseDOTLoader} which provides parsed data from DOT file
+	 */
 	protected abstract void loadData(BaseDOTLoader<V, E> dotLoader);
 
+	/**
+	 * Must create instance of {@link Graph} from created and retrieved data.
+	 *
+	 * @return - new graph created from prepared data
+	 */
 	public abstract Graph createGraph();
 
 }
diff --git a/sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/DOT.java b/sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/DOT.java
index 8282cff..f14ce1a 100644
--- a/sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/DOT.java
+++ b/sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/DOT.java
@@ -8,12 +8,28 @@ import cz.zcu.kiv.imiger.plugin.dot.loader.PaypalDOTLoader;
 import cz.zcu.kiv.imiger.spi.IModule;
 import cz.zcu.kiv.imiger.vo.Graph;
 
+/**
+ * IModule implementation for DOT converter.
+ */
 public class DOT implements IModule {
+
+    /**
+     * Returns name of this module.
+     *
+     * @return - name of this module
+     */
     @Override
     public String getModuleName() {
         return "DOT file";
     }
 
+    /**
+     * Retrieves DOT file which has to be converted to raw JSON that
+     * IMiGEr support.
+     *
+     * @param stringToConvert String to be converted to raw JSON.
+     * @return - raw JSON as string
+     */
     @Override
     public String getRawJson(String stringToConvert) {
         BaseDOTLoader<VertexDTO, EdgeDTO> loader = new PaypalDOTLoader(stringToConvert);
diff --git a/sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/GraphFactory.java b/sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/GraphFactory.java
index ed8a994..332ff72 100644
--- a/sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/GraphFactory.java
+++ b/sources/imiger-dot-converter/src/main/java/cz/zcu/kiv/imiger/plugin/dot/GraphFactory.java
@@ -8,23 +8,51 @@ import cz.zcu.kiv.imiger.vo.*;
 import java.util.*;
 
 /**
+ * Implements necessary methods for creating graph.
+ *
  * Date: 31.03.2019
  *
  * @author Martin Matas
  */
 public class GraphFactory extends BaseGraphFactory<VertexDTO, EdgeDTO> {
 
+	/**
+	 * Name of default edge archetype name field.
+	 */
 	private static final String EDGE_ARCHETYPE_NAME = "Edge";
+
+	/**
+	 * Name of default vertex archetype name field.
+	 */
 	private static final String VERTEX_ARCHETYPE_NAME = "Vertex";
+
+	/**
+	 * Value of default archetype text field.
+	 */
 	private static final String ARCHETYPE_TEXT = "";
+
+	/**
+	 * Index of default archetype in created archetype list.
+	 */
 	private static final int DEFAULT_ARCHETYPE_INDEX = 0;
 
+	/**
+	 * Retrieves data from {@link BaseDOTLoader} and defines archetypes for vertices and edges.
+	 *
+	 * @param dotLoader - instance of {@link BaseDOTLoader} which provides parsed data from DOT file
+	 */
 	public GraphFactory(BaseDOTLoader<VertexDTO,EdgeDTO> dotLoader) {
 		super(dotLoader);
 		prepareEdgeArchetypes();
 		prepareVertexArchetypes();
 	}
 
+	/**
+	 * Initialize attributes that can be filled with data from {@link BaseDOTLoader}. In case when
+	 * DOTLoader returns uninitialized lists, attributes will be initialized empty.
+	 *
+	 * @param dotLoader - instance of {@link BaseDOTLoader} which provides parsed data from DOT file
+	 */
 	@Override
 	protected void loadData(BaseDOTLoader<VertexDTO,EdgeDTO> dotLoader) {
 		List<VertexDTO> loadedVertices = dotLoader.getVertices();
@@ -44,6 +72,11 @@ public class GraphFactory extends BaseGraphFactory<VertexDTO, EdgeDTO> {
 		}
 	}
 
+	/**
+	 * Creates new graph from data which were prepared when instance was created.
+	 *
+	 * @return - new instance of graph
+	 */
 	@Override
 	public Graph createGraph() {
 		Graph graph = new Graph();
@@ -57,19 +90,33 @@ public class GraphFactory extends BaseGraphFactory<VertexDTO, EdgeDTO> {
 		return graph;
 	}
 
+	/**
+	 * Iterates through the list of vertices retrieved from {@link BaseDOTLoader} and for each of them
+	 * creates new graph vertex.
+	 *
+	 * @param graph - reference to the instance of new graph
+	 * @param vertices - vertices retrieved from {@link BaseDOTLoader}
+	 */
 	private void addVerticesToGraph(Graph graph, List<VertexDTO> vertices) {
 		for (VertexDTO v : vertices) {
 
-			List<String[]> attributes = sortAttributes(v.getAttributes(), attributeTypes);
+			List<String[]> attributes = checkAttributes(v.getAttributes(), attributeTypes);
 			Vertex vertex = new Vertex(v.getId(), v.getName(), DEFAULT_ARCHETYPE_INDEX, "", attributes);
 			graph.getVertices().add(vertex);
 		}
 	}
 
+	/**
+	 * Iterates through the list of edges retrieved from {@link BaseDOTLoader} and for each of them
+	 * creates new graph edge.
+	 *
+	 * @param graph - reference to the instance of new graph
+	 * @param edges - edges retrieved from {@link BaseDOTLoader}
+	 */
 	private void addEdgesToGraph(Graph graph, List<EdgeDTO> edges) {
 		for (EdgeDTO e : edges) {
 
-			List<String[]> attributes = sortAttributes(e.getAttributes(), attributeTypes);
+			List<String[]> attributes = checkAttributes(e.getAttributes(), attributeTypes);
 			SubedgeInfo subedgeInfo = new SubedgeInfo(e.getId(), DEFAULT_ARCHETYPE_INDEX, attributes);
 
 			List<SubedgeInfo> subedgeInfos = new ArrayList<>();
@@ -80,32 +127,43 @@ public class GraphFactory extends BaseGraphFactory<VertexDTO, EdgeDTO> {
 		}
 	}
 
-	private List<String[]> sortAttributes(Map<String, String> unsortedAttributes, List<AttributeType> attributeTypes) {
-		HashMap<String, List<String>> attributes = new HashMap<>();
-
-		attributeTypes.forEach(type -> {
-			attributes.put(type.getName(), new ArrayList<>());
-		});
-
-		for (Map.Entry<String, String> e: unsortedAttributes.entrySet()) {
-			if (attributes.containsKey(e.getKey())) {
-				attributes.get(e.getKey()).add(e.getValue());
+	/**
+	 * Iterates through the list of attributes and for each of them checks if the attribute type exists. Then for the
+	 * attribute creates key-value pair using {@link String[]}, where key is the attribute type and value is the
+	 * value of attribute.
+	 *
+	 * @param uncheckedAttributes - map of attributes retrieved from {@link BaseDOTLoader}, where key is unchecked
+	 *                            attribute type and value is the value of attribute
+	 * @param attributeTypes - list of attribute types retrieved from {@link BaseDOTLoader} against which will be unchecked
+	 *                       attributes validated
+	 * @return - list of checked attributes
+	 */
+	private List<String[]> checkAttributes(Map<String, String> uncheckedAttributes, List<AttributeType> attributeTypes) {
+		List<String[]> attributes = new ArrayList<>();
+		Set<String> attributesHashSet = new HashSet<>();
+
+		attributeTypes.forEach(t -> attributesHashSet.add(t.getName()));
+
+		for (Map.Entry<String, String> e: uncheckedAttributes.entrySet()) {
+			if (attributesHashSet.contains(e.getKey())) {
+				attributes.add(new String[]{e.getKey(), e.getValue()});
 			}
 		}
 
-		List<String[]> finalAttributes = new ArrayList<>();
-		attributes.forEach((k, v) -> {
-			finalAttributes.add(v.toArray(new String[0]));
-		});
-
-		return finalAttributes;
+		return attributes;
 	}
 
+	/**
+	 * Defines default edge archetype for edges.
+	 */
 	private void prepareEdgeArchetypes() {
 		edgeArchetypes= new ArrayList<>();
 		edgeArchetypes.add(new EdgeArchetype(EDGE_ARCHETYPE_NAME, ARCHETYPE_TEXT));
 	}
 
+	/**
+	 * Defines default vertex archetypes for vertices.
+	 */
 	private void prepareVertexArchetypes() {
 		vertexArchetypes = new ArrayList<>();
 		vertexArchetypes.add(new VertexArchetype(VERTEX_ARCHETYPE_NAME, ARCHETYPE_TEXT));
