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

import de.uni_stuttgart.vis.vowl.owl2vowl.model.data.VowlData;
import de.uni_stuttgart.vis.vowl.owl2vowl.model.entities.properties.AbstractProperty;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.semanticweb.owlapi.model.*;
import org.semanticweb.owlapi.util.OWLObjectVisitorAdapter;

/**
 * @author Eduard
 */
public class OwlSubclassAnonymVisitor extends OWLObjectVisitorAdapter {
	private VowlData vowlData;
	private OWLClass subclass;
	private Logger logger = LogManager.getLogger(OwlSubclassAnonymVisitor.class);

	public OwlSubclassAnonymVisitor(VowlData vowlData, OWLClass subclass) {
		this.vowlData = vowlData;
		this.subclass = subclass;
	}

	@Override
	protected void handleDefault(OWLObject axiom) {
		logger.info("Missed implementation for: " + axiom);
	}

	@Override
	public void visit(OWLObjectMinCardinality ce) {
		if (!ce.getFiller().isOWLThing() && !ce.getFiller().isOWLNothing()) {
			// TODO specification of a filler class
			logger.info("Specification of cardinalities not supported yet: " + ce);
			return;
		}

		OWLObjectProperty property = ce.getProperty().getNamedProperty();
		AbstractProperty vowlProperty = vowlData.getPropertyForIri(property.getIRI());
		vowlProperty.setMinCardinality(ce.getCardinality());
	}

	@Override
	public void visit(OWLDataAllValuesFrom ce) {
		logger.info(ce + " not supported yet.");
	}

	@Override
	public void visit(OWLDataExactCardinality ce) {
		logger.info(ce + " not supported yet.");
	}

	@Override
	public void visit(OWLDataMaxCardinality ce) {
		logger.info(ce + " not supported yet.");
	}

	@Override
	public void visit(OWLDataMinCardinality ce) {
		logger.info(ce + " not supported yet.");
	}

	@Override
	public void visit(OWLDataSomeValuesFrom ce) {
		logger.info(ce + " not supported yet.");
	}

	@Override
	public void visit(OWLDataHasValue ce) {
		logger.info(ce + " not supported yet.");
	}

	@Override
	public void visit(OWLObjectAllValuesFrom ce) {
		logger.info(ce + " not supported yet.");
	}

	@Override
	public void visit(OWLObjectSomeValuesFrom ce) {
		logger.info(ce + " not supported yet.");
	}

	@Override
	public void visit(OWLObjectMaxCardinality ce) {
		if (!ce.getFiller().isOWLThing() && !ce.getFiller().isOWLNothing()) {
			// TODO specification of a filler class
			logger.info("Specification of cardinalities not supported yet: " + ce);
			return;
		}

		OWLObjectProperty property = ce.getProperty().getNamedProperty();
		AbstractProperty vowlProperty = vowlData.getPropertyForIri(property.getIRI());
		vowlProperty.setMaxCardinality(ce.getCardinality());
	}

	@Override
	public void visit(OWLObjectHasSelf ce) {
		logger.info(ce + " not supported yet.");
	}

	@Override
	public void visit(OWLObjectHasValue ce) {
		logger.info(ce + " not supported yet.");
	}

	@Override
	public void visit(OWLObjectExactCardinality ce) {
		if (!ce.getFiller().isOWLThing() && !ce.getFiller().isOWLNothing()) {
			// TODO specification of a filler class
			logger.info("Specification of cardinalities not supported yet: " + ce);
			return;
		}

		OWLObjectProperty property = ce.getProperty().getNamedProperty();
		AbstractProperty vowlProperty = vowlData.getPropertyForIri(property.getIRI());
		vowlProperty.setExactCardinality(ce.getCardinality());
	}
}

@@ -1520,256 +1520,1106 @@
 %7B%0A%09%09
-logger.info(ce + %22 not supported yet.%22);%0A%09%7D%0A%0A%09@Override%0A%09public void visit(OWLDataMaxCardinality ce) %7B%0A%09%09logger.info(ce + %22 not supported yet.%22);%0A%09%7D%0A%0A%09@Override%0A%09public void visit(OWLDataMinCardinality ce) %7B%0A%09%09logger.info(ce + %22 not supported yet.%22
+OWLDataPropertyExpression property = ce.getProperty();%0A%0A%09%09if (property.isAnonymous()) %7B%0A%09%09%09logger.info(%22Anonymous dataproperty for exact cardinality.%22);%0A%09%09%09return;%0A%09%09%7D%0A%0A%09%09AbstractProperty vowlProperty = vowlData.getPropertyForIri(property.asOWLDataProperty().getIRI());%0A%09%09vowlProperty.setExactCardinality(ce.getCardinality());%0A%09%7D%0A%0A%09@Override%0A%09public void visit(OWLDataMaxCardinality ce) %7B%0A%09%09OWLDataPropertyExpression property = ce.getProperty();%0A%0A%09%09if (property.isAnonymous()) %7B%0A%09%09%09logger.info(%22Anonymous dataproperty for max cardinality.%22);%0A%09%09%09return;%0A%09%09%7D%0A%0A%09%09AbstractProperty vowlProperty = vowlData.getPropertyForIri(property.asOWLDataProperty().getIRI());%0A%09%09vowlProperty.setMaxCardinality(ce.getCardinality());%0A%09%7D%0A%0A%09@Override%0A%09public void visit(OWLDataMinCardinality ce) %7B%0A%09%09OWLDataPropertyExpression property = ce.getProperty();%0A%0A%09%09if (property.isAnonymous()) %7B%0A%09%09%09logger.info(%22Anonymous dataproperty for min cardinality.%22);%0A%09%09%09return;%0A%09%09%7D%0A%0A%09%09AbstractProperty vowlProperty = vowlData.getPropertyForIri(property.asOWLDataProperty().getIRI());%0A%09%09vowlProperty.setMinCardinality(ce.getCardinality()
 );%0A%09

Implement cardinalities for data props.