From 77e30aa366a1209af817efd8a6beec4bbd2a23ae Mon Sep 17 00:00:00 2001
From: Anders Nilsson <anders.nilsson@cs.lth.se>
Date: Fri, 30 Mar 2007 16:41:00 +0200
Subject: [PATCH] Started added interface methods used from the SIARAS
 skillserver

---
 siaras/Ontology.java             | 63 ++++++++++++++++++++++++++++++++
 siaras/SkillserverInterface.jrag | 29 +++++++++++++++
 2 files changed, 92 insertions(+)
 create mode 100644 siaras/Ontology.java
 create mode 100644 siaras/SkillserverInterface.jrag

diff --git a/siaras/Ontology.java b/siaras/Ontology.java
new file mode 100644
index 0000000..f476435
--- /dev/null
+++ b/siaras/Ontology.java
@@ -0,0 +1,63 @@
+
+/* 
+ * Copyright (C) 2006  Anders Nilsson <anders.nilsson@cs.lth.se>
+ *
+ * This file is part of OntologyCompiler.
+ */
+
+import AST.Start;
+import AST.SiarasParser;
+import AST.ParseException;
+import java.io.*;
+import java.net.URL;
+
+public class Ontology extends Parser {
+	public static Start getAST(String ontologyURL) {
+		Start ast = null;
+// 		String outfile = null;
+// 		int i=0;
+// 		for (i=0; i<args.length; i++) {
+// 			if (args[i].equals("-o")) {
+// 				outfile = args[++i];
+//                 if (outfile.endsWith(".owl")) {
+//                   outfile = outfile.substring(0,outfile.indexOf('.'));
+//                 }
+// 			}
+// 		}
+		try {
+			Reader r = new StringReader((String)new URL(ontologyURL).getFile());
+			SiarasParser parser = new SiarasParser(r);
+
+			ast = parser.Start();
+		}
+        catch (ParseException e) {
+			System.out.println(e.getMessage());
+		}
+// 		catch (FileNotFoundException e) {
+// 			System.err.println("file " + ontologyURL + " not found");
+// 		}
+		catch (IOException e) {
+			System.out.println(e.getMessage());
+		}
+        return ast;
+
+// 		try {
+// 			// Generate OWL ontology, possibly transformed from Owl
+// 			// Full to OWL DL
+// 			if (outfile == null) {
+// 				outfile = "ontology";
+// 			}
+// 			PrintStream pStream = new PrintStream(new File(outfile+".owl"));
+// 			ast.genOntology("",pStream);
+//             // have to create a matching repository file, otherwise
+//             // Protege will complain severely.
+// 			pStream = new PrintStream(new File(outfile+".repository"));
+//             pStream.println("[Dublin Core DL Redirect]");
+// 		} catch (java.io.FileNotFoundException e) {
+// 			System.out.println("Could not create file: "+outfile);
+// 			e.printStackTrace();
+// 		}
+		
+
+	}
+}
diff --git a/siaras/SkillserverInterface.jrag b/siaras/SkillserverInterface.jrag
new file mode 100644
index 0000000..ca23da7
--- /dev/null
+++ b/siaras/SkillserverInterface.jrag
@@ -0,0 +1,29 @@
+/* -*-Java-*- */
+
+/* 
+ * Copyright (C) 2007  Anders Nilsson <anders.nilsson@cs.lth.se>
+ *
+ * This file is part of OntologyCompiler.
+ */
+
+aspect SkillserverInterface {
+    public Thing ASTNode.getIndividual(String id) {
+        System.out.println("foo");
+        for (int i=0; i<getNumChild(); i++) {
+            Thing t = getChild(i).getIndividual(id);
+            if (t!=null) {
+                return t;
+            }
+        }
+        return null;
+    }
+
+    public Thing Thing.getIndividual(String id) {
+        System.out.println("Looking for: "+id+" in: "+name());
+        if (id.equals(name())) {
+            return this;
+        } else {
+            return super.getIndividual(id);
+        }
+    }
+}
-- 
GitLab