Commit 3eeed532 authored by Anders Nilsson's avatar Anders Nilsson
Browse files

Seems to be able to generate ontology with instances which do not make Protege scream in agony.

parent d1ac614c
......@@ -236,17 +236,17 @@ aspect GenRewrites {
// Rewrite isSkillOf/hasSkill/hasProperty/isPropertyOf to ClassUse.
// Should probably be auto-generated instead.
pStream.println(ind(1)+"rewrite ComplexElement {");
pStream.println(ind(2)+"when ((name().equals(\"hasSkill\")");
pStream.println(ind(2)+"|| name().equals(\"hasProperty\"))");
pStream.println("&& getNumAttribute() > 0 && getAttribute(0) instanceof RdfResource)");
pStream.println(ind(2)+"to ClassUse {");
pStream.println(ind(3)+"ClassUse use = new ClassUse();");
pStream.println(ind(3)+"String att = getAttribute(0).name();");
pStream.println(ind(3)+"use.setOwlIdentifier(new OwlIdentifier(att.substring(att.indexOf('#')+1,att.indexOf('_'))));");
pStream.println(ind(3)+"use.setAttributeList(getAttributeList());");
pStream.println(ind(3)+"use.setElementList(new List());");
pStream.println(ind(3)+"return use;");
pStream.println(ind(2)+"}");
// pStream.println(ind(2)+"when ((name().equals(\"hasSkill\")");
// pStream.println(ind(2)+"|| name().equals(\"hasProperty\"))");
// pStream.println("&& getNumAttribute() > 0 && getAttribute(0) instanceof RdfResource)");
// pStream.println(ind(2)+"to ClassUse {");
// pStream.println(ind(3)+"ClassUse use = new ClassUse();");
// pStream.println(ind(3)+"String att = getAttribute(0).name();");
// pStream.println(ind(3)+"use.setOwlIdentifier(new OwlIdentifier(att.substring(att.indexOf('#')+1,att.indexOf('_'))));");
// pStream.println(ind(3)+"use.setAttributeList(getAttributeList());");
// pStream.println(ind(3)+"use.setElementList(new List());");
// pStream.println(ind(3)+"return use;");
// pStream.println(ind(2)+"}");
pStream.println(ind(2)+"when (name().equals(\"rdf:RDF\") && !(this instanceof RdfDeclaration))");
pStream.println(ind(2)+"to RdfDeclaration {");
pStream.println(ind(3)+"return new RdfDeclaration(getOwlIdentifier(),getAttributeList(),getElementList());");
......@@ -316,11 +316,13 @@ aspect GenRewrites {
// Rearrange device nodes on the AST to get away from the
// current diagonal style from Protege
pStream.println(ind(1)+"rewrite "+name()+" {");
pStream.println(ind(2)+"when (!isTopElement())");
pStream.println(ind(2)+"when (!isTopElement() && getAttribute(0) instanceof RdfId)");
pStream.println(ind(2)+"to ClassUse {");
pStream.println(ind(3)+"ClassUse use = new ClassUse();");
pStream.println(ind(3)+"use.setOwlIdentifier(new OwlIdentifier(\""+name()+"\"));");
pStream.println(ind(3)+"use.setAttributeList(new List().add(new RdfResource(getAttribute(0).getValue())));");
pStream.println(ind(3)+"String id = getAttribute(0).getValue().getSTRING_LITERAL();");
pStream.println(ind(3)+"Value val = new Value(\"\\\"#\"+id.substring(1,id.length()));");
pStream.println(ind(3)+"use.setAttributeList(new List().add(new RdfResource(val)));");
pStream.println(ind(3)+"use.setElementList(new List());");
pStream.println(ind(3)+"getRdfDecl().addElement(this);");
pStream.println(ind(3)+"return use;");
......
......@@ -14,5 +14,20 @@ aspect Qualification {
getAttributeList(),
getElementList());
}
when ((name().equals("hasProperty") ||
name().equals("hasIdentifier") ||
name().equals("hasSubskill") ||
name().equals("hasSkill") ||
name().equals("hasSubskill") ||
name().equals("hasEditable") ||
name().equals("isPropertyOf") ||
name().equals("isSkillOf")) &&
getNumElement()==1 &&
getElement(0) instanceof ClassUse)
to ComplexElement {
setAttributeList(new List().add(((ComplexElement) getElement(0)).
getAttribute(0)));
setElementList(new List());
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment