/*
 * DataPropertyVisitor.java
 *
 */

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

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.entities.nodes.AbstractNode;
import de.uni_stuttgart.vis.vowl.owl2vowl.model.entities.nodes.classes.NullClass;
import de.uni_stuttgart.vis.vowl.owl2vowl.model.entities.nodes.datatypes.DatatypeReference;
import de.uni_stuttgart.vis.vowl.owl2vowl.model.entities.properties.VowlDatatypeProperty;
import de.uni_stuttgart.vis.vowl.owl2vowl.model.entities.properties.VowlObjectProperty;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.semanticweb.owlapi.model.*;

/**
 *
 */
public class DataPropertyVisitor extends PropertyVisitor {
	private Logger logger = LogManager.getLogger(DataPropertyVisitor.class);

	public DataPropertyVisitor(VowlData vowlData, OWLProperty owlObjectProperty) {
		super(vowlData, owlObjectProperty);
	}

	@Override
	public void visit(OWLFunctionalDataPropertyAxiom axiom) {
		VowlDatatypeProperty prop = vowlData.getDatatypePropertyForIri(owlObjectProperty.getIRI());
		prop.addAttribute(VowlAttribute.FUNCTIONAL);
	}

	@Override
	public void visit(OWLDataPropertyRangeAxiom axiom) {
		VowlDatatypeProperty prop = vowlData.getDatatypePropertyForIri(owlObjectProperty.getIRI());

		if (!axiom.getRange().isDatatype()) {
			logger.info("DataPropertyRange is no datatype: " + axiom);
			return;
		}

		AbstractNode node = axiom.getRange().accept(new DomainRangeVisitor(owlObjectProperty, vowlData));

		if ((node instanceof NullClass)) {
			logger.info("Skipped anonymous data range: " + axiom.getRange());
			return;
		}

		DatatypeReference reference = (DatatypeReference) node;

		prop.addRange(reference.getIri());
		reference.addInGoingProperty(prop.getIri());
	}

	@Override
	public void visit(OWLDataPropertyDomainAxiom axiom) {
		VowlDatatypeProperty prop = vowlData.getDatatypePropertyForIri(owlObjectProperty.getIRI());
		IRI domainIri;

		if (axiom.getDomain().isAnonymous()){
			AbstractNode anonymClass = axiom.getDomain().accept(new DomainRangeVisitor(owlObjectProperty, vowlData));
			if (!(anonymClass instanceof NullClass)) {
				domainIri = anonymClass.getIri();
			} else {
				logger.info("Skipped anonymous object domain: " + axiom.getDomain());
				return;
			}
		} else {
			if (axiom.getDomain().asOWLClass().isOWLThing()) {
				return;
			}

			domainIri = axiom.getDomain().asOWLClass().getIRI();
		}

		prop.addDomain(domainIri);
		vowlData.getClassForIri(domainIri).addOutGoingProperty(prop.getIri());
	}

	@Override
	public void visit(OWLSubDataPropertyOfAxiom axiom) {
		logger.info("Sub Data property axiom not supported yet.");
		System.out.println("Sub Data property axiom not supported yet.");
	}
}

@@ -479,16 +479,102 @@
 erence;%0A
+import de.uni_stuttgart.vis.vowl.owl2vowl.model.entities.properties.AbstractProperty;%0A
 import d
@@ -2957,11 +2957,527 @@
 t.%22);%0A%09%7D
+%0A%0A%09@Override%0A%09public void visit(OWLEquivalentDataPropertiesAxiom axiom) %7B%0A%09%09AbstractProperty base = vowlData.getPropertyForIri(owlObjectProperty.getIRI());%0A%0A%09%09for (OWLDataPropertyExpression expr : axiom.getProperties()) %7B%0A%09%09%09if (expr.isAnonymous()) %7B%0A%09%09%09%09// TODO anonymous behaviour%0A%09%09%09%09logger.info(%22Anonysmous equivalent prop: %22 + expr);%0A%09%09%09%09continue;%0A%09%09%09%7D%0A%0A%09%09%09if (expr.asOWLDataProperty().getIRI().equals(base.getIri())) %7B%0A%09%09%09%09continue;%0A%09%09%09%7D%0A%0A%09%09%09base.addEquivalentElement(expr.asOWLDataProperty().getIRI());%0A%09%09%7D%0A%09%7D
 %0A%7D%0A

Add equivalent data property