/*
 * VowlClassVisitor.java
 *
 */

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

import de.uni_stuttgart.vis.vowl.owl2vowl.constants.VowlAttribute;
import de.uni_stuttgart.vis.vowl.owl2vowl.model.data.VowlData;
import de.uni_stuttgart.vis.vowl.owl2vowl.model.nodes.AbstractNode;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.semanticweb.owlapi.model.*;
import org.semanticweb.owlapi.util.OWLClassExpressionVisitorAdapter;

import java.util.Set;

/**
 *
 */
public class VowlClassVisitor extends OWLClassExpressionVisitorAdapter {
	private final VowlData vowlData;
	private final OWLClass referencedClass;
	Logger logger = LogManager.getLogger(VowlClassVisitor.class);

	public VowlClassVisitor(VowlData vowlData, OWLClass referencedClass) {
		this.vowlData = vowlData;
		this.referencedClass = referencedClass;
	}

	@Override
	protected void handleDefault(OWLClassExpression c) {
		System.out.println("Not implemented VowlClassVisitor: " + c);
		logger.info("Not implemented for equivalents: " + c);
	}

	@Override
	public void visit(OWLObjectUnionOf ce) {
		System.out.println("Not implemented OWLObjectUnionOf: " + ce);
		logger.info("Not implemented for OWLObjectUnionOf: " + ce);
	}

	@Override
	public void visit(OWLObjectComplementOf ce) {
		if (ce.getOperand().isAnonymous()) {
			logger.info("Anonymous operand in object complement of.");
			return;
		}

		vowlData.getClassForIri(ce.getOperand().asOWLClass().getIRI()).setComplement(referencedClass.getIRI());
		vowlData.getClassForIri(referencedClass.getIRI()).setComplement(ce.getOperand().asOWLClass().getIRI());
		vowlData.getClassForIri(referencedClass.getIRI()).addAttribute(VowlAttribute.COMPLEMENT);
	}

	@Override
	public void visit(OWLObjectIntersectionOf ce) {
		Set<OWLClassExpression> operands = ce.getOperands();

		AbstractNode node = vowlData.getClassForIri(referencedClass.getIRI());

		for (OWLClassExpression operand : operands) {
			if (!operand.isAnonymous()) {
				node.addElementToIntersection(operand.asOWLClass().getIRI());
				node.addAttribute(VowlAttribute.INTERSECTION);
			} else {
				// TODO Anonymous undefined behaviour
				logger.info("Anonymous exists in intersections.");
			}
		}
	}
}

@@ -1423,32 +1423,27 @@
 %0A%0A%09%09
-vowlData.getClassForIri(
+IRI baseClassIri = 
 ce.g
@@ -1467,38 +1467,41 @@
 Class().getIRI()
-).setC
+;%0A%09%09IRI c
 omplement(refere
@@ -1493,17 +1493,22 @@
 mplement
-(
+Iri = 
 referenc
@@ -1515,34 +1515,34 @@
 edClass.getIRI()
-)
 ;
+%0A
 %0A%09%09vowlData.getC
@@ -1556,85 +1556,119 @@
 Iri(
-referencedClass.getIRI()).setComplement(ce.getOperand().asOWLClass().getIRI()
+baseClassIri).setComplement(complementIri);%0A%09%09vowlData.getClassForIri(complementIri).setComplement(baseClassIri
 );%0A%09
@@ -1696,32 +1696,21 @@
 Iri(
-referencedClass.getIRI()
+complementIri
 ).ad

Refactor object complement of