Skip to content
Snippets Groups Projects
Commit e691adb1 authored by Anders Nilsson's avatar Anders Nilsson
Browse files

Implemented just enough to be able to find and print out the geometry reference, if exists.

parent 61c4200e
No related branches found
No related tags found
No related merge requests found
/* -*-Java-*- */
/*
* Copyright (C) 2007 Anders Nilsson <anders.nilsson@cs.lth.se>
*
* This file is part of OntologyCompiler.
*/
aspect Geometry {
syn lazy String Thing.getGeometryRef() = "NotApplicable";
eq Product.getGeometryRef(){
// // if (getNumAttribute() > 0) {
// // return getAttribute(0).name();
// // } else {
// // return "unknown_id";
// // }
for (int i=0; i<getNumElement(); i++) {
// System.out.println(" Checking "+getElement(i));
if (getElement(i).isGeometryRef()) {
System.out.println("Found Geometry ref");
// System.out.println(" Found identifier: "+((ComplexElement) getElement(i)).getAttribute(0).name());
Geometry g = (Geometry) ((ClassUse) getElement(i)).decl();
// System.out.println(" "+((ComplexElement) ident.getElement(0)).name());
// return ident.value();
return g.getValue();
}
}
return "_No_GeometryRef_";
}
syn boolean Element.isGeometryRef() = false;
eq ComplexElement.isGeometryRef() = name().equals("hasGeometry"); // Ugly hack!
eq Geometry.isGeometryRef() = true;
}
\ No newline at end of file
......@@ -5,9 +5,7 @@
* This file is part of OntologyCompiler.
*/
import AST.Start;
import AST.SiarasParser;
import AST.ParseException;
import AST.*;
import java.io.*;
import java.net.*;
......@@ -41,26 +39,26 @@ public class GeometryDemo extends Parser {
}
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();
// }
}
public static void main(String[] args) {
Console con = System.console();
con.readLine("\n\nParse ontology from file: %s",(Object) args[0]);
Start ast = getAST(args[0]);
ast.getIndividual("Teapot_1").dumpTree("",System.out);
con.readLine("\n\nFind the Teapot instance");
Product p = (Product) ast.getIndividual("Teapot_1");
p.dumpTree("",System.out);
// p.prettyPrint("",System.out);
con.readLine("\n\nFind the geometry reference");
String s = p.getGeometryRef();
System.out.println("Geometry model: "+s);
}
}
......@@ -15,6 +15,7 @@ aspect Qualification {
getElementList());
}
when ((name().equals("hasProperty") ||
name().equals("hasGeometry") ||
name().equals("hasIdentifier") ||
name().equals("hasSubskill") ||
name().equals("hasSkill") ||
......@@ -31,6 +32,7 @@ aspect Qualification {
setElementList(new List());
}
when ((name().equals("hasProperty") ||
name().equals("hasGeometry") ||
name().equals("hasIdentifier") ||
name().equals("hasSubskill") ||
name().equals("hasSkill") ||
......
......@@ -51,7 +51,7 @@ aspect SkillserverInterface {
public Thing Thing.getIndividual(String id) {
// System.out.println(" "+name());
// System.out.println("Looking for: "+id+" in: "+id()+" ("+name()+")");
System.out.println("Looking in: "+id()+" "+" ("+name()+")");
// System.out.println("Looking in: "+id()+" "+" ("+name()+")");
// if (id().contains(id) &&
// (this instanceof Device)) {
if (id.equals(id())) {
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment