/*
 * ClassParser.java
 *
 */

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

import de.uni_stuttgart.vis.vowl.owl2vowl.model.Constants;
import de.uni_stuttgart.vis.vowl.owl2vowl.model.nodes.classes.BaseClass;
import de.uni_stuttgart.vis.vowl.owl2vowl.pipes.FormatText;
import org.semanticweb.owlapi.model.OWLAnnotation;
import org.semanticweb.owlapi.model.OWLAxiom;
import org.semanticweb.owlapi.model.OWLClass;
import org.semanticweb.owlapi.model.OWLClassExpression;

import java.util.Map;
import java.util.Set;

/**
 *
 */
public class ClassParser extends GeneralNodeParser {
	private Set<OWLClass> classes;

	public ClassParser(Set<OWLClass> classes) {
		this.classes = classes;
	}

	protected void execute() {
		Map<String, BaseClass> classMap = mapData.getClassMap();
		Map<String, OWLClass> owlClasses = mapData.getOwlClasses();

		for (OWLClass currentClass : classes) {
			isDeprecated = false;
			rdfsIsDefinedBy = "";
			owlVersionInfo = "";
			iri = currentClass.getIRI().toString();

			// If thing is found skip it! It only gets created where necessary.
			if (iri.equals(Constants.OWL_THING_CLASS_URI)) {
				continue;
			}

			Main.logger.info("Class: " + currentClass);
			for(OWLAxiom currentAxiom : currentClass.getReferencingAxioms(ontology)){
				Main.logger.info("\tAxiom: " + currentAxiom);

				for(OWLClassExpression nestExpr : currentAxiom.getNestedClassExpressions()) {
					Main.logger.info("\t\tNested: " + nestExpr);
				}
			}

			TypeFinder finder = new TypeFinder(GeneralParser.ontology, GeneralParser.factory);
			BaseClass theClass = finder.findVowlClass(currentClass);

			parseAnnotations(currentClass);

			// Setting data in VOWLClass
			theClass.setLabels(languageToLabel);
			theClass.setComments(comments);
			theClass.setName(languageToLabel.get("default"));
			theClass.setIri(iri);
			theClass.setDefinedBy(FormatText.cutQuote(rdfsIsDefinedBy));
			theClass.setOwlVersion(FormatText.cutQuote(owlVersionInfo));
			theClass.setNumberOfIndividuals(currentClass.getIndividuals(ontology).size());

			if (isDeprecated) {
				theClass.getAttributes().add(Constants.PROP_ATTR_DEPR);
			}

			owlClasses.put(currentClass.getIRI().toString(), currentClass);
			classMap.put(theClass.getIri(), theClass);
		}
	}
}

@@ -308,169 +308,9 @@
 del.
-OWLAnnotation;%0Aimport org.semanticweb.owlapi.model.OWLAxiom;%0Aimport org.semanticweb.owlapi.model.OWLClass;%0Aimport org.semanticweb.owlapi.model.OWLClassExpression
+*
 ;%0A%0Ai
@@ -1797,31 +1797,15 @@
 ));%0A
+%0A
 %09%09%09
-theClass.setNumberOf
+set
 Indi
@@ -1812,16 +1812,26 @@
 viduals(
+theClass, 
 currentC
@@ -1838,40 +1838,8 @@
 lass
-.getIndividuals(ontology).size()
 );%0A%0A
@@ -2044,13 +2044,314 @@
 s);%0A
-
 %09%09%7D%0A%09%7D
+%0A%0A%09private void setIndividuals(BaseClass theClass, OWLClass clazz) %7B%0A%09%09int size = 0;%0A%0A%09%09for (OWLOntology owlOntology : Main.manager.getOntologies()) %7B%0A%09%09%09Set%3COWLIndividual%3E individuals = clazz.getIndividuals(owlOntology);%0A%09%09%09size += individuals.size();%0A%09%09%7D%0A%0A%09%09theClass.setNumberOfIndividuals(size);%0A%09%7D
 %0A%7D%0A

Check all ontologies for individuals.