package de.uni_stuttgart.vis.vowl.owl2vowl.model.nodes;

import de.uni_stuttgart.vis.vowl.owl2vowl.constants.Node_Types;
import de.uni_stuttgart.vis.vowl.owl2vowl.export.JsonGeneratorVisitor;
import de.uni_stuttgart.vis.vowl.owl2vowl.model.BaseEntity;
import de.uni_stuttgart.vis.vowl.owl2vowl.model.edges.properties.BaseProperty;

import java.util.ArrayList;
import java.util.List;


public abstract class BaseNode extends BaseEntity {
	private List<BaseNode> disjoints = new ArrayList<BaseNode>();
	private List<BaseProperty> outGoingEdges = new ArrayList<BaseProperty>();
	private List<BaseProperty> inGoingEdges = new ArrayList<BaseProperty>();

	public BaseNode() {
	}

	public List<BaseNode> getDisjoints() {
		return disjoints;
	}

	public void setDisjoints(List<BaseNode> disjoints) {
		this.disjoints = disjoints;
	}

	public List<BaseProperty> getOutGoingEdges() {
		return outGoingEdges;
	}

	public List<BaseProperty> getInGoingEdges() {
		return inGoingEdges;
	}

	/**
	 * Returns the owl:Thing which is already connected to the node.
	 *
	 * @return Owl:Thing which has connection to this node. Else null.
	 */
	public BaseNode getConnectedThing() {
		for (BaseProperty out : getOutGoingEdges()) {
			String type = out.getRange().getType();

			if (type.equals(Node_Types.TYPE_THING)) {
				return out.getRange();
			}
		}

		for (BaseProperty in : getInGoingEdges()) {
			String type = in.getDomain().getType();

			if (type.equals(Node_Types.TYPE_THING)) {
				return in.getDomain();
			}
		}

		return null;
	}

	public boolean containsConnectedThing(BaseNode node) {
		for (BaseProperty out : getOutGoingEdges()) {
			BaseNode range = out.getRange();
			String type = range.getType();

			if (type.equals(Node_Types.TYPE_THING) && range.getId().equals(node.getId())) {
				return true;
			}
		}

		for (BaseProperty in : getInGoingEdges()) {
			BaseNode domain = in.getDomain();
			String type = domain.getType();

			if (type.equals(Node_Types.TYPE_THING) && domain.getId().equals(node.getId())) {
				return true;
			}
		}

		return false;
	}

	@Override
	public void accept(JsonGeneratorVisitor visitor) {
		super.accept(visitor);
		visitor.visit(this);
	}
}

@@ -370,19 +370,67 @@
 va.util.
-Lis
+HashSet;%0Aimport java.util.List;%0Aimport java.util.Se
 t;%0A%0A%0Apub
@@ -689,16 +689,86 @@
 erty%3E();
+%0A%09private Set%3CBaseNode%3E existingComplements = new HashSet%3CBaseNode%3E();
 %0A%0A%09publi
@@ -2288,11 +2288,94 @@
 his);%0A%09%7D
+%0A%0A%09public Set%3CBaseNode%3E getExistingComplements() %7B%0A%09%09return existingComplements;%0A%09%7D
 %0A%7D%0A

Add method for referenced complements.