/*
 * VowlData.java
 *
 */

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

import de.uni_stuttgart.vis.vowl.owl2vowl.model.nodes.AbstractNode;
import de.uni_stuttgart.vis.vowl.owl2vowl.model.nodes.classes.AbstractClass;
import org.semanticweb.owlapi.model.IRI;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * Contains all data WebVOWL needs.
 */
public class VowlData {

	private HashMap<IRI, AbstractClass> classMap = new HashMap<>();

	public Map<IRI, AbstractClass> getClassMap() {
		return Collections.unmodifiableMap(classMap);
	}

	public void addClass(AbstractClass vowlClass) {
		classMap.put(vowlClass.getIri(), vowlClass);
	}

	public AbstractNode getNodeForIri(IRI iri) {
		if (classMap.containsKey(iri)) {
			return classMap.get(iri);
		} else {
			throw new IllegalStateException("Can't find node for passed iri: " + iri);
		}
	}
}

@@ -416,20 +416,147 @@
 private 
-Hash
+Map%3CAbstractEntity, Integer%3E entityToId = new HashMap%3C%3E();%0A%09private Map%3CIRI, AbstractEntity%3E entityMap = new HashMap%3C%3E();%0A%09private 
 Map%3CIRI,
@@ -586,26 +586,40 @@
 p = new 
-HashMap%3C%3E(
+AllEntityMap%3C%3E(entityMap
 );%0A%0A%09pub
@@ -1017,13 +1017,850 @@
 i);%0A
-
 %09%09%7D%0A%09%7D
+%0A%0A%09protected AbstractEntity getEntityForIri(IRI iri) %7B%0A%09%09if (entityMap.containsKey(iri)) %7B%0A%09%09%09return classMap.get(iri);%0A%09%09%7D else %7B%0A%09%09%09throw new IllegalStateException(%22Can't find node for passed iri: %22 + iri);%0A%09%09%7D%0A%09%7D%0A%0A%09public int getIdForIri(IRI iri) %7B%0A%09%09return getIdForEntity(getEntityForIri(iri));%0A%09%7D%0A%0A%09public int getIdForEntity(AbstractEntity entity) %7B%0A%09%09if (!entityToId.containsKey(entity)) %7B%0A%09%09%09entityToId.put(entity, entityToId.keySet().size());%0A%09%09%7D%0A%0A%09%09return entityToId.get(entity);%0A%09%7D%0A%7D%0A%0Aclass AllEntityMap%3CK, V extends AbstractEntity%3E extends HashMap%3CK, V%3E %7B%0A%09private HashMap%3CK, V%3E mergeMap;%0A%0A%09public %3CVal extends AbstractEntity%3E AllEntityMap(Map%3CK, Val%3E mergeMap) %7B%0A%09%09this.mergeMap = (HashMap%3CK, V%3E) mergeMap;%0A%09%7D%0A%0A%09@Override%0A%09public V put(K key, V value) %7B%0A%09%09super.put(key, value);%0A%09%09mergeMap.put(key, value);%0A%09%09return value;%0A%09%7D
 %0A%7D%0A

Extend vowl data