OWL2Parser.java revision 478b7abe044f6dcc5bb0db7cd9155ddc1730ed1b
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiuimport org.semanticweb.owlapi.apibinding.OWLManager;
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiuimport org.semanticweb.owlapi.model.OWLException;
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiuimport org.semanticweb.owlapi.model.OWLOntology;
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiuimport org.semanticweb.owlapi.model.OWLOntologyManager;
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiuimport org.semanticweb.owlapi.util.OWLOntologyMerger;
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiuimport org.semanticweb.owlapi.model.IRI;
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiuimport org.semanticweb.owlapi.model.OWLAxiom;
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiuimport org.semanticweb.owlapi.io.OWLRendererException;
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiuimport uk.ac.manchester.cs.owl.owlapi.mansyntaxrenderer.ManchesterOWLSyntaxRenderer;
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiuimport uk.ac.manchester.cs.owl.owlapi.mansyntaxrenderer.ManchesterOWLSyntaxObjectRenderer;
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiuimport java.io.BufferedReader;
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiuimport java.io.PrintWriter;
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiuimport java.io.OutputStreamWriter;
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiuimport java.io.File;
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiuimport java.io.Writer;
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiuimport java.io.BufferedWriter;
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiuimport java.io.FileWriter;
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiuimport java.io.FileOutputStream;
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiuimport java.io.IOException;
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiuimport java.io.InputStreamReader;
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiuimport java.net.URI;
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiuimport java.util.ArrayList;
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiuimport java.util.Set;
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiuimport java.util.HashSet;
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiuimport java.net.URLConnection;
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiuimport java.util.Iterator;
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiuimport java.util.HashMap;
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiuimport java.util.Map;
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiupublic class OWL2Parser {
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu private static ArrayList<OWLOntology> loadedImportsList = new ArrayList<OWLOntology>();
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu private static ArrayList<IRI> importsIRI = new ArrayList<IRI>();
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu private static ArrayList<OWLOntology> haveImportsList = new ArrayList<OWLOntology>();
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu private static Map m = new HashMap();
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu private static Set s = new HashSet();
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu public static void main(String[] args) {
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu if (args.length < 1) {
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu System.out.println("Usage: processor <URI> [FILENAME]");
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu System.exit(1);
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu }
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu String filename = "";
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu BufferedWriter out;
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu // A simple example of how to load and save an ontology
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu try {
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu IRI iri = IRI.create(args[0]);
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu if (args.length == 2) {
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu filename = args[1];
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu out = new BufferedWriter(new FileWriter(filename));
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu } else {
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu out = new BufferedWriter(openForFile(null));
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu }
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu /* Load an ontology from a physical IRI */
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu IRI physicalIRI = IRI.create(args[0]);
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu // Now do the loading
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu OWLOntology ontology = manager.loadOntologyFromOntologyDocument(physicalIRI);
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu getImportsList(ontology, manager);
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu if(loadedImportsList.size() == 0)
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu {
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu parse(ontology,out);
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu }
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu else {
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu if(importsIRI.contains(ontology.getOntologyID().getOntologyIRI())) {
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu importsIRI.remove(importsIRI.lastIndexOf(ontology.getOntologyID().getOntologyIRI()));
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu }
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu if(loadedImportsList.contains(ontology))
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu {
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu Iterator<OWLOntology> itr_onto = loadedImportsList.iterator();
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu Iterator<IRI> itr_iri = importsIRI.iterator();
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu OWLOntologyManager mng = OWLManager.createOWLOntologyManager();
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu OWLOntologyMerger merger = new OWLOntologyMerger(manager);
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu String str = ontology.getOntologyID().getOntologyIRI().toQuotedString();
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu String notag = str.replaceAll("\\<","");
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu notag = notag.replaceAll("\\>","");
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu notag = notag.replaceAll("http:/","");
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu notag = notag.replaceAll("\\/.*?/","");;
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu notag = notag.replaceAll(".*?/","");;
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu Object aux[] = loadedImportsList.toArray();
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu String merged_name = "";
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu for (Object it : aux) {
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu Object aux_ont = it;
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu String mrg = aux_ont.toString();
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu mrg = mrg.replaceAll("\\<","");
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu mrg = mrg.replaceAll("\\>","");
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu mrg = mrg.replaceAll("\\[.*?]","");
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu mrg = mrg.replaceAll("Ontology\\(","");
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu mrg = mrg.replaceAll(" ","");
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu mrg = mrg.replaceAll("\\)","");
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu mrg = mrg + notag;
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu merged_name = merged_name + mrg;
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu }
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu IRI mergedOntologyIRI = IRI.create(merged_name);
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu OWLOntology merged = merger.createMergedOntology(manager, mergedOntologyIRI);
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu ManchesterOWLSyntaxRenderer rendi = new ManchesterOWLSyntaxRenderer (manager);
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu rendi.render(merged,out);
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu }
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu else
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu {
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu parseZeroImports(out);
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu }
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu }
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu } catch (IOException e) {
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu System.err.println("Error: can not build file: " + filename);
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu e.printStackTrace();
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu } catch (Exception ex) {
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu System.err.println("OWL parse error: " + ex.getMessage());
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu ex.printStackTrace();
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu }
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu }
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu private static void getImportsList(OWLOntology ontology,
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu OWLOntologyManager om) {
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu ArrayList<OWLOntology> unSavedImports = new ArrayList<OWLOntology>();
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu try {
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu if (om.getImports(ontology).isEmpty()) {
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu m.put(ontology,0);
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu }
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu else {
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu haveImportsList.add(ontology);
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu for (OWLOntology imported : om.getImports(ontology)) {
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu if (!importsIRI.contains(imported.getOntologyID().getOntologyIRI())) {
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu unSavedImports.add(imported);
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu loadedImportsList.add(imported);
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu importsIRI.add(imported.getOntologyID().getOntologyIRI());
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu if(!loadedImportsList.contains(ontology)) {
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu m.put(ontology,imported);
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu }
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu }
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu }
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu }
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu for (OWLOntology onto : unSavedImports) {
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu getImportsList(onto, om);
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu }
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu } catch (Exception e) {
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu System.err.println("Error getImportsList!");
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu e.printStackTrace();
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu }
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu }
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu private static Writer openForFile(String fileName)
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu {
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu return new OutputStreamWriter(System.out);
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu }
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu private static void parseZeroImports(BufferedWriter out)
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu {
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu Set all = getKeysByValue(0);
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu Iterator it = all.iterator();
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu while(it.hasNext())
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu {
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu OWLOntology onto = (OWLOntology)it.next();
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu parse(onto,out);
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu s.add(onto);
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu m.remove(onto);
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu parseImports(out);
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu }
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu }
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu public static void parseImports(BufferedWriter out)
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu {
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu Iterator iter = m.entrySet().iterator();
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu while(iter.hasNext()) {
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu Map.Entry pairs = (Map.Entry)iter.next();
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu if(checkset(pairs.getValue())) {
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu OWLOntology onto = (OWLOntology)pairs.getKey();
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu parse(onto,out);
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu s.add((OWLOntology)pairs.getKey());
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu m.remove(pairs.getKey());
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu parseImports(out);
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu }
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu }
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu }
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu public static Boolean checkset(Object it) {
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu Set aux = new HashSet();
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu aux.add(it);
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu if (s.containsAll(aux))
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu return true;
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu else
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu return false;
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu }
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu public static Set getKeysByValue(int value) {
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu Set keys = new HashSet();
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu Iterator it = m.entrySet().iterator();
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu while(it.hasNext()) {
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu Map.Entry pairs = (Map.Entry)it.next();
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu if(pairs.getValue().equals(value)) {
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu keys.add(pairs.getKey());
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu }
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu }
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu return keys;
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu }
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu public static void parse(OWLOntology onto, BufferedWriter out) {
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu try {
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu ManchesterOWLSyntaxRenderer rendi = new ManchesterOWLSyntaxRenderer (onto.getOWLOntologyManager());
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu rendi.render(onto,out);
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu } catch(OWLRendererException ex) {
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu System.err.println("Error by parse!");
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu ex.printStackTrace();
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu }
478b7abe044f6dcc5bb0db7cd9155ddc1730ed1bFrancisc Nicolae Bungiu }
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu}
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu
2578a6d217296401d347302c9104fee179bd0470Francisc Nicolae Bungiu