/*
 * AnnotationParser.java
 *
 */

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

import de.uni_stuttgart.vis.vowl.owl2vowl.constants.Vowl_Lang;
import de.uni_stuttgart.vis.vowl.owl2vowl.parser.container.Annotation;
import de.uni_stuttgart.vis.vowl.owl2vowl.parser.container.MapData;
import org.semanticweb.owlapi.model.*;

import java.util.Map;

/**
 *
 */
public class AnnotationParser {

	public static Annotation getAnnotation(OWLAnnotation annotation, MapData mapData) {
		Annotation anno;

		if (annotation.getValue() instanceof OWLLiteral) {
			OWLLiteral val = (OWLLiteral) annotation.getValue();
			String language;

			if (val.isRDFPlainLiteral()) {
				if (val.getLang().isEmpty()) {
					language = Vowl_Lang.LANG_UNSET;
					mapData.getAvailableLanguages().add(Vowl_Lang.LANG_UNSET);
				} else {
					language = val.getLang();
					mapData.getAvailableLanguages().add(val.getLang());
				}
				anno = new Annotation(annotation.getProperty().toString(), val.getLiteral());
				anno.setLanguage(language);
				anno.setType(Annotation.TYPE_LABEL);
			} else {
				anno = new Annotation(annotation.getProperty().toString(), val.getLiteral());
				anno.setType(Annotation.TYPE_LABEL);
			}
		} else if (annotation.getValue() instanceof IRI) {
			anno = new Annotation(annotation.getProperty().toString(), annotation.getValue().toString());
			anno.setType(Annotation.TYPE_IRI);
		} else {
			anno = new Annotation(annotation.getProperty().toString(), annotation.getValue().toString());
			anno.setType(Annotation.TYPE_LABEL);
		}

		return anno;
	}

	// TODO
	public static Annotation getAnnotation(OWLDataPropertyAssertionAxiom axiom, MapData mapData) {
		System.out.println(axiom.getObject());
		System.out.println(axiom.getSubject());
		System.out.println(axiom.getProperty());

		System.out.println();

		return null;
	}
}

@@ -326,17 +326,185 @@
 i.model.
-*
+IRI;%0Aimport org.semanticweb.owlapi.model.OWLAnnotation;%0Aimport org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom;%0Aimport org.semanticweb.owlapi.model.OWLLiteral
 ;%0A%0Aimpor
@@ -515,19 +515,17 @@
 va.util.
-Map
+*
 ;%0A%0A/**%0A 
@@ -1731,16 +1731,513 @@
 no;%0A%09%7D%0A%0A
+%09public static Map%3CString, List%3CAnnotation%3E%3E processAndGet(Collection%3COWLAnnotation%3E set, MapData mapData) %7B%0A%09%09Map%3CString, List%3CAnnotation%3E%3E result = new LinkedHashMap%3CString, List%3CAnnotation%3E%3E();%0A%0A%09%09for (OWLAnnotation owlAnnotation : set) %7B%0A%09%09%09Annotation current = getAnnotation(owlAnnotation, mapData);%0A%09%09%09String key = current.getIdentifier();%0A%0A%09%09%09if (!result.containsKey(key)) %7B%0A%09%09%09%09result.put(key, new ArrayList%3CAnnotation%3E());%0A%09%09%09%7D%0A%0A%09%09%09result.get(key).add(current);%0A%09%09%7D%0A%0A%09%09return result;%0A%09%7D%0A%0A
 %09// TODO

Add method for processing a collection of annotaitons.,