/*
 * IndividualVisitorImpl.java
 *
 */

package de.uni_stuttgart.vis.vowl.owl2vowl.parser.visitors;

import de.uni_stuttgart.vis.vowl.owl2vowl.parser.container.MapData;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.semanticweb.owlapi.model.*;

import java.util.HashSet;
import java.util.Set;

/**
 *
 */
public class IndividualVisitorImpl implements OWLIndividualVisitor {

	private static final Logger logger = LogManager.getRootLogger();
	private int setSize;
	private MapData mapData;
	private OWLOntology ontology;
	private Set<OWLClass> instances;

	public IndividualVisitorImpl(int size, MapData mapData, OWLOntology ontology) {
		setSize = size;
		this.mapData = mapData;
		this.ontology = ontology;
		instances = new HashSet<OWLClass>();
	}

	public Set<OWLClass> getInstances() {
		return instances;
	}

	@Override
	public void visit(OWLNamedIndividual owlNamedIndividual) {
		OWLClass owlClass = mapData.getOwlClasses().get(owlNamedIndividual.getIRI().toString());

		if (owlClass != null) {
			addInstance(owlClass);
		}
	}

	private void addInstance(OWLClass instance) {
		if (instance == null) {
			return;
		}

		setSize--;
		instances.add(instance);
	}

	@Override
	public void visit(OWLAnonymousIndividual owlAnonymousIndividual) {
		logger.info("Anonym Individual: " + owlAnonymousIndividual);
		// TODO implement what to do if exists.
	}

	public int getSetSize() {
		return setSize;
	}
}

@@ -141,32 +141,257 @@
 owl.
-parser.container.MapData
+model.individuals.NamedIndividual;%0Aimport de.uni_stuttgart.vis.vowl.owl2vowl.parser.container.MapData;%0Aimport de.uni_stuttgart.vis.vowl.owl2vowl.parser.helper.AnnotationParser;%0Aimport de.uni_stuttgart.vis.vowl.owl2vowl.parser.helper.ComparisonHelper
 ;%0Aim
@@ -820,16 +820,59 @@
 stances;
+%0A%09private Set%3CNamedIndividual%3E individuals;
 %0A%0A%09publi
@@ -1057,16 +1057,138 @@
 ass%3E();%0A
+%09%09individuals = new HashSet%3CNamedIndividual%3E();%0A%09%7D%0A%0A%09public Set%3CNamedIndividual%3E getIndividuals() %7B%0A%09%09return individuals;%0A
 %09%7D%0A%0A%09pub
@@ -1461,19 +1461,500 @@
 Class);%0A
-
 %09%09%7D
+ else %7B%0A%09%09%09addIndividual(owlNamedIndividual);%0A%09%09%7D%0A%09%7D%0A%0A%09private void addIndividual(OWLNamedIndividual owlNamedIndividual) %7B%0A%09%09NamedIndividual individual = new NamedIndividual();%0A%09%09individual.setIri(owlNamedIndividual.getIRI().toString());%0A%09%09individual.setName(ComparisonHelper.getIndividualName(owlNamedIndividual.getIRI().toString()));%0A%09%09individual.setAnnotations(AnnotationParser.processAndGet(owlNamedIndividual.getAnnotations(ontology), mapData));%0A%09%09individuals.add(individual);
 %0A%09%7D%0A%0A%09pr

Update individual visitor.