diff --git a/siaras/SkillserverInterface.jrag b/siaras/SkillserverInterface.jrag index 8e6f8c8152c07d6b828130a9dca3bf17fbbe8922..3502ff0b12b127cd7e307b215266df7913fc5e50 100644 --- a/siaras/SkillserverInterface.jrag +++ b/siaras/SkillserverInterface.jrag @@ -7,12 +7,17 @@ */ aspect SkillserverInterface { + public Thing Start.getIndividual(String id) { +// System.out.println("getIndividual: "+id); + return super.getIndividual(id); + } + public Thing ASTNode.getIndividual(String id) { // System.out.println("foo: "+this); for (int i=0; i<getNumChild(); i++) { Thing t = getChild(i).getIndividual(id); if (t!=null) { - System.out.println("Found: "+t); +// System.out.println("Found: "+t); return t; } } @@ -20,8 +25,9 @@ aspect SkillserverInterface { } public Thing Thing.getIndividual(String id) { - System.out.println("Looking for: "+id+" in: "+id()); - if (id.equals(id())) { +// System.out.println("Looking for: "+id+" in: "+id()); +// System.out.println("Looking in: "+id()); + if (id().contains(id)) { return this; } else { return super.getIndividual(id); @@ -31,21 +37,45 @@ aspect SkillserverInterface { aspect Misc { public String Thing.id() { - for (int i=0; i<getNumElement(); i++) { -// System.out.println(" Checking "+getElement(i)); - if (getElement(i).isIdentifier()) { - System.out.println(" Found identifier"); - Identifier ident = (Identifier) ((ClassUse) getElement(i)).decl(); - return ((StringElement) ident.getElement(0)).getLITERAL(); - } + if (getNumAttribute() > 0) { + return getAttribute(0).name(); + } else { + return "unknown_id"; } - return null; +// for (int i=0; i<getNumElement(); i++) { +// // System.out.println(" Checking "+getElement(i)); +// if (getElement(i).isIdentifier()) { +// // System.out.println(" Found identifier: "+((ComplexElement) getElement(i)).name()); +// Identifier ident = (Identifier) ((ClassUse) getElement(i)).decl(); +// System.out.println(" "+((ComplexElement) ident.getElement(0)).name()); +// return ident.value(); +// } +// } +// return "unknown_id"; } syn boolean Element.isIdentifier() = false; eq ComplexElement.isIdentifier() = name().equals("hasIdentifier"); // Ugly hack! eq Identifier.isIdentifier() = true; - eq ClassUse.isIdentifier() = decl().isIdentifier(); +// eq ClassUse.isIdentifier() { +// Thing decl = decl(); +// if (decl != null) { +// return decl.isIdentifier(); +// } else { +// System.out.println("Couldn't find decl for: "+name()); +// } +// return false; +// } + + syn lazy String Identifier.value() { + for (int i=0; i<getNumElement(); i++) { + if (getElement(i) instanceof StringElement) { + return ((StringElement) getElement(i)).getLITERAL(); + } + } + return "#valueNotFound"; + } + } @@ -96,8 +126,9 @@ aspect Decl { syn boolean Attribute.isEqualId(String id) = false; eq RdfId.isEqualId(String id) { - System.out.println(" Checking: "+name()); +// System.out.println(" Checking: "+name()); if (name().equals(id)) { + System.out.println(" "+name()+" == "+id); return true; } return false;