Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[Shapes] - Improve compatibility with traits ans simple relational da…

…tabases
  • Loading branch information...
commit 3ae12f0061413a16a9091c4c33f8414b3172562d 1 parent ac53de0
@sotty sotty authored
Showing with 855 additions and 43 deletions.
  1. +1 −0  drools-shapes/drools-shapes-generator-plugin/src/main/java/org/drools/shapes/MetadataPlugin.java
  2. +16 −2 drools-shapes/drools-shapes-generator-plugin/src/main/java/org/drools/shapes/OntoModelCompiler.java
  3. +36 −5 drools-shapes/drools-shapes-generator-plugin/src/main/java/org/drools/shapes/ShapeCaster.java
  4. +2 −0  drools-shapes/drools-shapes-generator/src/main/java/org/drools/semantics/builder/model/OntoModel.java
  5. +22 −1 drools-shapes/drools-shapes-generator/src/main/java/org/drools/semantics/builder/model/PropertyRelation.java
  6. +26 −4 ...pes-generator/src/main/java/org/drools/semantics/builder/model/compilers/JarInterfaceModelCompilerImpl.java
  7. +4 −0 ...es-generator/src/main/java/org/drools/semantics/builder/model/compilers/JavaInterfaceModelCompilerImpl.java
  8. +19 −2 ...apes-generator/src/main/java/org/drools/semantics/builder/model/compilers/SemanticXSDModelCompilerImpl.java
  9. +10 −1 ...rools-shapes-generator/src/main/java/org/drools/semantics/builder/model/compilers/XSDModelCompilerImpl.java
  10. +126 −0 ...ols-shapes-generator/src/main/java/org/drools/semantics/builder/model/hierarchy/DatabaseModelProcessor.java
  11. +12 −2 .../drools-shapes-generator/src/main/java/org/drools/semantics/builder/model/hierarchy/NullModelProcessor.java
  12. +1 −4 ...es-generator/src/main/java/org/drools/semantics/builder/model/inference/AbstractModelInferenceStrategy.java
  13. +18 −3 ...-shapes-generator/src/main/java/org/drools/semantics/builder/model/inference/DelegateInferenceStrategy.java
  14. +6 −2 ...ools-shapes-generator/src/main/resources/org/drools/semantics/builder/model/compilers/bindings.xjb.template
  15. +8 −2 drools-shapes/drools-shapes-generator/src/main/resources/org/drools/semantics/templates/model/drl/trait.drlt
  16. +12 −1 ...rools-shapes-generator/src/main/resources/org/drools/semantics/templates/model/java/TraitInterface.template
  17. +4 −0 ...es/drools-shapes-generator/src/main/resources/org/drools/semantics/templates/model/java/genericAdd.template
  18. +5 −0 ...pes/drools-shapes-generator/src/main/resources/org/drools/semantics/templates/model/java/metaDescr.template
  19. +8 −2 ...-shapes-generator/src/main/resources/org/drools/semantics/templates/model/java/restrictedAddRemove.template
  20. +1 −1  drools-shapes/drools-shapes-generator/src/test/java/org/drools/semantics/lang/dl/DL_4_AreaTest.java
  21. +1 −1  drools-shapes/drools-shapes-generator/src/test/java/org/drools/semantics/lang/dl/DL_7_RuleTest.java
  22. +17 −3 drools-shapes/drools-shapes-generator/src/test/java/org/drools/semantics/lang/dl/DL_8_ModelTest.java
  23. +359 −0 drools-shapes/drools-shapes-generator/src/test/resources/ontologies/dbModel.owl
  24. +3 −1 drools-shapes/drools-shapes-utilities/src/main/java/org.drools.semantics/Thing.java
  25. +137 −5 drools-shapes/drools-shapes-utilities/src/main/java/org/w3/_2002/_07/owl/ThingImpl.java
  26. +1 −1  drools-shapes/drools-shapes-xsd-processor/src/main/resources/org/drools/shapes/xsd/drl/xsd2owl.drl
View
1  ...shapes/drools-shapes-generator-plugin/src/main/java/org/drools/shapes/MetadataPlugin.java
@@ -69,6 +69,7 @@ public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) thro
HashMap<String, Object> map = new HashMap<String, Object>();
map.put( "klassName", co.target.shortName );
map.put( "typeName", keyed.getAttribute( "name" ) );
+ map.put( "package", keyed.getAttribute( "package" ) );
map.put( "supertypeName", keyed.getAttribute( "parent" ) );
map.put( "propertyNames", propNames );
map.put( "typeNames", typeNames );
View
18 ...pes/drools-shapes-generator-plugin/src/main/java/org/drools/shapes/OntoModelCompiler.java
@@ -47,6 +47,7 @@
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException;
+import java.io.InputStream;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
@@ -269,7 +270,7 @@ public boolean existsResult() {
streamJavaInterfaces( false );
- streamXSDsWithBindings( true );
+ streamXSDsWithBindings( true, null );
mojo( options, variant );
List<Diagnostic<? extends JavaFileObject>> diagnostics = doCompile();
@@ -352,8 +353,11 @@ public boolean streamJavaInterfaces( boolean includeJar ) {
-
public boolean streamXSDsWithBindings( boolean includePersistenceConfiguration ) {
+ return streamXSDsWithBindings( includePersistenceConfiguration, null );
+ }
+
+ public boolean streamXSDsWithBindings( boolean includePersistenceConfiguration, String persistenceTemplatePath ) {
SemanticXSDModelCompiler xcompiler = (SemanticXSDModelCompiler) ModelCompilerFactory.newModelCompiler( ModelFactory.CompileTarget.XSDX );
SemanticXSDModel xmlModel = (SemanticXSDModel) xcompiler.compile( model );
@@ -366,6 +370,16 @@ public boolean streamXSDsWithBindings( boolean includePersistenceConfiguration )
success = xmlModel.streamBindings( getMetaInfDir() );
if ( includePersistenceConfiguration ) {
+ if ( persistenceTemplatePath != null ) {
+ File persistenceTemplate = new File( persistenceTemplatePath );
+ if ( persistenceTemplate.exists() ) {
+ InputStream is = new FileInputStream( persistenceTemplate );
+ byte[] data = new byte[ is.available() ];
+ is.read( data );
+ xmlModel.setPersistenceXml( new String( data ) );
+ is.close();
+ }
+ }
success = success && streamPersistenceConfigs( xcompiler, xmlModel );
}
View
41 ...ls-shapes/drools-shapes-generator-plugin/src/main/java/org/drools/shapes/ShapeCaster.java
@@ -33,8 +33,11 @@
import org.w3._2002._07.owl.Thing;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
@@ -83,6 +86,19 @@ public void setOutputDirectory(File outputDirectory) {
this.outputDirectory = outputDirectory;
}
+ /**
+ * @parameter
+ */
+ private String persistenceTemplate;
+
+ public String getPersistenceTemplate() {
+ return persistenceTemplate;
+ }
+
+ public void setPersistenceTemplate(String persistenceTemplate) {
+ this.persistenceTemplate = persistenceTemplate;
+ }
+
/**
* @parameter
@@ -295,7 +311,7 @@ public void execute() throws MojoExecutionException {
if ( isGenerateDefaultImplClasses() ) {
- compiler.streamXSDsWithBindings( true );
+ compiler.streamXSDsWithBindings( true, persistenceTemplate );
}
if ( isGenerateIndividuals() ) {
@@ -367,9 +383,20 @@ public void execute() throws MojoExecutionException {
private OntoModel processOntology( OntoModel.Mode mode ) throws MojoExecutionException {
+ InputStream ontologyStream = null;
File ontoFile = new File( ontology );
- if ( ! ontoFile.exists() ) {
- throw new MojoExecutionException( " Ontology file not found : " + ontology );
+ if ( ontoFile.exists() ) {
+ try {
+ ontologyStream = new FileInputStream( new File( ontology ) );
+ } catch ( FileNotFoundException e ) {
+ e.printStackTrace();
+ }
+ } else {
+ try {
+ ontologyStream = ResourceFactory.newClassPathResource( ontology ).getInputStream();
+ } catch ( IOException e ) {
+ //
+ }
}
DLFactory factory = DLFactoryBuilder.newDLFactoryInstance();
@@ -381,9 +408,13 @@ private OntoModel processOntology( OntoModel.Mode mode ) throws MojoExecutionExc
Resource[] res = new Resource[ n ];
int j = 0;
for ( String imp : ontologyImports ) {
- res[j++] = ResourceFactory.newFileResource( imp );
+ if ( new File( imp ).exists() ) {
+ res[j++] = ResourceFactory.newFileResource( imp );
+ } else {
+ res[j++] = ResourceFactory.newClassPathResource( imp );
+ }
}
- res[j] = ResourceFactory.newFileResource( ontology );
+ res[j] = ResourceFactory.newInputStreamResource( ontologyStream );
return factory.buildModel( getModelName(),
res,
View
2  ...s/drools-shapes-generator/src/main/java/org/drools/semantics/builder/model/OntoModel.java
@@ -16,6 +16,7 @@
package org.drools.semantics.builder.model;
+import org.drools.semantics.builder.model.hierarchy.DatabaseModelProcessor;
import org.drools.semantics.builder.model.hierarchy.FlatModelProcessor;
import org.drools.semantics.builder.model.hierarchy.HierarchicalModelProcessor;
import org.drools.semantics.builder.model.hierarchy.ModelHierarchyProcessor;
@@ -37,6 +38,7 @@
FLAT( new FlatModelProcessor() ),
VARIANT( new VariantModelProcessor() ),
OPTIMIZED( new OptimizedModelProcessor() ),
+ DATABASE( new DatabaseModelProcessor() ),
NONE( new NullModelProcessor() );
private ModelHierarchyProcessor processor;
View
23 ...s-shapes-generator/src/main/java/org/drools/semantics/builder/model/PropertyRelation.java
@@ -16,6 +16,7 @@
package org.drools.semantics.builder.model;
+import com.hp.hpl.jena.sparql.function.library.min;
import org.drools.definition.type.Position;
import org.drools.semantics.utils.NameUtils;
@@ -24,7 +25,7 @@
import java.util.List;
import java.util.Set;
-public class PropertyRelation extends Relation {
+public class PropertyRelation extends Relation implements Cloneable {
@Position(3)
protected String name;
@@ -140,6 +141,26 @@ public String getIri() {
}
+ public PropertyRelation clone() {
+ PropertyRelation rel = new PropertyRelation( this.subject, this.property, this.object, this.name );
+ rel.minCard = this.minCard;
+ rel.maxCard = this.maxCard;
+ rel.target = this.target;
+ rel.domain = this.domain;
+ rel.addableTarget = this.addableTarget;
+
+ rel.restricted = this.restricted;
+ rel.inherited = this.inherited;
+ rel.simple = this.simple;
+ rel.inverse = this.inverse;
+
+ rel.baseProperty = this.baseProperty;
+ rel.restrictedProperties = new ArrayList<PropertyRelation>( this.restrictedProperties );
+ rel.chains = new HashSet<List<PropertyRelation>>( this.chains );
+
+ return rel;
+ }
+
public PropertyRelation getBaseProperty() {
if ( baseProperty == this ) {
return this;
View
30 ...main/java/org/drools/semantics/builder/model/compilers/JarInterfaceModelCompilerImpl.java
@@ -21,14 +21,19 @@
import com.clarkparsia.empire.annotation.Namespaces;
import com.clarkparsia.empire.annotation.RdfProperty;
import com.clarkparsia.empire.annotation.RdfsClass;
+import org.drools.definition.type.PropertyReactive;
import org.drools.factmodel.BuildUtils;
+import org.drools.factmodel.traits.Trait;
import org.drools.semantics.utils.NameUtils;
import org.drools.semantics.builder.model.*;
import org.drools.semantics.utils.NamespaceUtils;
import org.mvel2.asm.*;
+import thewebsemantic.Namespace;
+import thewebsemantic.RdfType;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
+import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlID;
@@ -114,7 +119,20 @@ public void compile( Concept con, Object context, Map<String, Object> params ) {
}
av0.visitEnd();
}
-
+ {
+ av0 = cw.visitAnnotation( Type.getDescriptor( Namespace.class ), true);
+ av0.visit( "value", params.get( "namespace" ) );
+ }
+ {
+ av0 = cw.visitAnnotation( Type.getDescriptor( RdfType.class ), true);
+ av0.visit( "value", "" + params.get( "name" ) + params.get( "namespace" ) );
+ }
+ {
+ av0 = cw.visitAnnotation( Type.getDescriptor( Trait.class ), true);
+ }
+ {
+ av0 = cw.visitAnnotation( Type.getDescriptor( PropertyReactive.class ), true);
+ }
for ( String propKey : props.keySet() ) {
PropertyRelation rel = props.get( propKey );
@@ -150,14 +168,18 @@ public void compile( Concept con, Object context, Map<String, Object> params ) {
av0 = mv.visitAnnotation( Type.getDescriptor( RdfProperty.class ), true );
av0.visit( "value", "tns:" + propName );
av0.visitEnd();
- if ( rel.isSimple() ) {
+ if ( rel.getTarget().isPrimitive() ) {
av0 = mv.visitAnnotation( Type.getDescriptor( Basic.class ), true );
av0.visitEnd();
} else {
- av0 = mv.visitAnnotation( Type.getDescriptor( OneToMany.class ), true );
+ if ( rel.getMaxCard() == null || rel.getMaxCard() > 1 ) {
+ av0 = mv.visitAnnotation( Type.getDescriptor( OneToMany.class ), true );
+ } else {
+ av0 = mv.visitAnnotation( Type.getDescriptor( ManyToOne.class ), true );
+ }
{
AnnotationVisitor av1 = av0.visitArray( "cascade" );
- av1.visitEnum( null, Type.getDescriptor( CascadeType.class ), "PERSIST" );
+ av1.visitEnum( null, Type.getDescriptor( CascadeType.class ), "ALL" );
av1.visitEnd();
}
av0.visitEnd();
View
4 ...ain/java/org/drools/semantics/builder/model/compilers/JavaInterfaceModelCompilerImpl.java
@@ -47,6 +47,10 @@ public void compile( Concept con, Object context, Map<String, Object> params ) {
return;
}
+ if ( ( model.getMode() == OntoModel.Mode.NONE || model.getMode() == OntoModel.Mode.DATABASE ) && con.isAbstrakt() ) {
+ return;
+ }
+
CompiledTemplate template = registry.getNamedTemplate( templateName );
String name = con.getFullyQualifiedName();
View
21 .../main/java/org/drools/semantics/builder/model/compilers/SemanticXSDModelCompilerImpl.java
@@ -167,10 +167,13 @@ private Document createBindings( String ns, SemanticXSDModel sxsdModel ) {
String prefix = ((XSDModel) getModel()).mapNamespaceToPrefix( ns );
try {
String template = readFile( "bindings.xjb.template" );
+ Collection<Concept> cons = filterConceptsByNS( getModel().getConcepts(), ns );
+ cons = filterUnneedecConcepts( cons, model );
+
Map<String,Object> vars = new HashMap<String,Object>();
vars.put( "package", NameUtils.namespaceURIToPackage( ns ) );
vars.put( "namespace", ns );
- vars.put( "concepts", filterConceptsByNS( getModel().getConcepts(), ns ) );
+ vars.put( "concepts", cons );
vars.put( "flat", getModel().getMode() != OntoModel.Mode.HIERARCHY );
vars.put( "properties", propCache );
vars.put( "modelName", getModel().getName() );
@@ -192,6 +195,20 @@ private Document createBindings( String ns, SemanticXSDModel sxsdModel ) {
}
+ private Collection<Concept> filterUnneedecConcepts( Collection<Concept> cons, CompiledOntoModel model ) {
+ ArrayList<Concept> filtered = new ArrayList<Concept>( cons.size() );
+ for ( Concept c : cons ) {
+ if ( model.getMode() != OntoModel.Mode.FLAT && model.getMode() != OntoModel.Mode.NONE && model.getMode() != OntoModel.Mode.DATABASE ) {
+ filtered.add( c );
+ } else {
+ if ( ! c.isAbstrakt() ) {
+ filtered.add( c );
+ }
+ }
+ }
+ return filtered;
+ }
+
public void mergeNamespacedPackageInfo( SemanticXSDModel model ) {
for ( Namespace ns : model.getNamespaces() ) {
@@ -295,7 +312,7 @@ public void mergeIndex( File preexistingIndex, SemanticXSDModel model ) {
- private Object filterConceptsByNS( List<Concept> concepts, String ns ) {
+ private Collection<Concept> filterConceptsByNS( List<Concept> concepts, String ns ) {
List<Concept> filtered = new ArrayList<Concept>();
for ( Concept con : concepts ) {
if ( NamespaceUtils.compareNamespaces(con.getNamespace(), ns) ) {
View
11 ...ator/src/main/java/org/drools/semantics/builder/model/compilers/XSDModelCompilerImpl.java
@@ -102,7 +102,16 @@ public void compile( Concept con, Object context, Map<String, Object> params ) {
element,
el,
dependencies );
- getModel().addTrait( name, descr );
+
+ if ( model.getMode() != OntoModel.Mode.FLAT && model.getMode() != OntoModel.Mode.NONE && model.getMode() != OntoModel.Mode.DATABASE ) {
+ getModel().addTrait( name, descr );
+ } else {
+ if ( ! con.isAbstrakt() ) {
+ getModel().addTrait( name, descr );
+ }
+ }
+
+
View
126 ...or/src/main/java/org/drools/semantics/builder/model/hierarchy/DatabaseModelProcessor.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2013 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.semantics.builder.model.hierarchy;
+
+
+import org.drools.semantics.builder.model.Concept;
+import org.drools.semantics.builder.model.OntoModel;
+import org.drools.semantics.builder.model.PropertyRelation;
+import org.w3._2002._07.owl.Thing;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class DatabaseModelProcessor implements ModelHierarchyProcessor {
+
+ public void process( OntoModel model ) {
+ Concept thing = model.getConcept( Thing.IRI );
+ for ( Concept con : model.getConcepts() ) {
+
+ con.setChosenProperties(new HashMap(con.getProperties()));
+
+ Map<String, PropertyRelation> baseProps = con.getChosenProperties();
+ Set<Concept> superConcepts = con.getSuperConcepts();
+ for ( Concept sup : superConcepts ) {
+ Map<String,PropertyRelation> inheritedProperties = sup.getChosenProperties();
+ for ( String propKey : inheritedProperties.keySet() ) {
+ if ( ! baseProps.containsKey( propKey ) ) {
+ PropertyRelation rel = inheritedProperties.get( propKey ).clone();
+
+ List<PropertyRelation> localRestrictions = new ArrayList<PropertyRelation>( rel.getRestrictedProperties() );
+ for ( PropertyRelation pr : rel.getRestrictedProperties() ) {
+ if ( ! baseProps.containsValue( pr ) ) {
+ localRestrictions.remove( pr );
+ }
+ }
+
+ Integer min = 0;
+ Integer max = 0;
+ for ( PropertyRelation pr : localRestrictions ) {
+ min = min + pr.getMinCard();
+ max = ( max == null || pr.getMaxCard() == null ) ?
+ null : max + pr.getMaxCard();
+ }
+ rel.setMinCard( min );
+ rel.setMaxCard( max );
+
+ baseProps.put( propKey, rel );
+ }
+ }
+ }
+
+ for ( PropertyRelation prop : baseProps.values() ) {
+ if ( prop.getMaxCard() != null && prop.getMaxCard() <= 1 ) {
+ prop.setSimple( true );
+ }
+ }
+
+ if ( con != thing ) {
+ con.addSuperConcept( thing );
+ con.setChosenSuperConcept( thing );
+ thing.getChosenSubConcepts().add( con );
+ }
+ }
+
+
+
+ for ( Concept con : model.getConcepts() ) {
+ Collection<PropertyRelation> props = new ArrayList( con.getProperties().values() );
+ for ( PropertyRelation prop : props ) {
+ if ( ! prop.getRestrictedProperties().isEmpty() ) {
+ Integer i = 0;
+ for ( PropertyRelation restr : prop.getRestrictedProperties() ) {
+ if ( restr.getMaxCard() == null ) {
+ i = null;
+ break;
+ }
+ i = Math.max( i, restr.getMaxCard() );
+ }
+ prop.setMaxCard( i );
+ if ( i <= 1 ) {
+ prop.setSimple( true );
+ }
+ }
+ if ( prop.isRestricted() ) {
+ con.removeProperty( prop.getProperty() );
+ con.getChosenProperties().remove( prop.getProperty() );
+ model.removeProperty( prop );
+ }
+ }
+
+ List<Concept> supers = new ArrayList( con.getSuperConcepts() );
+ for ( Concept sup : supers ) {
+ if ( sup.isAbstrakt() ) {
+ con.getSuperConcepts().remove( sup );
+ con.getProperties().putAll( sup.getProperties() );
+ }
+ }
+ }
+
+ List<Concept> cons = new ArrayList( model.getConcepts() );
+ for ( Concept con : cons ) {
+ if ( con.isAbstrakt() ) {
+ model.removeConcept( con );
+ }
+ }
+
+ }
+}
View
14 ...erator/src/main/java/org/drools/semantics/builder/model/hierarchy/NullModelProcessor.java
@@ -17,12 +17,22 @@
package org.drools.semantics.builder.model.hierarchy;
+import org.drools.semantics.builder.model.Concept;
import org.drools.semantics.builder.model.OntoModel;
+import org.drools.semantics.builder.model.PropertyRelation;
+import org.w3._2002._07.owl.Thing;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
public class NullModelProcessor implements ModelHierarchyProcessor {
public void process( OntoModel model ) {
- // Does nothing
- }
+
+ }
}
View
5 ...ain/java/org/drools/semantics/builder/model/inference/AbstractModelInferenceStrategy.java
@@ -78,10 +78,7 @@ public OntoModel buildModel( String name,
populatedModel.buildAreaTaxonomy();
- if ( populatedModel.getMode() != OntoModel.Mode.NONE ) {
- //TODO Improve...
- populatedModel.getMode().getProcessor().process( populatedModel );
- }
+ populatedModel.getMode().getProcessor().process( populatedModel );
reportSessionStatus( kSession );
View
21 ...src/main/java/org/drools/semantics/builder/model/inference/DelegateInferenceStrategy.java
@@ -40,6 +40,7 @@
import org.semanticweb.owlapi.model.OWLAxiom;
import org.semanticweb.owlapi.model.OWLCardinalityRestriction;
import org.semanticweb.owlapi.model.OWLClass;
+import org.semanticweb.owlapi.model.OWLClassAssertionAxiom;
import org.semanticweb.owlapi.model.OWLClassExpression;
import org.semanticweb.owlapi.model.OWLClassExpressionVisitor;
import org.semanticweb.owlapi.model.OWLDataAllValuesFrom;
@@ -224,6 +225,7 @@ protected OntoModel buildIndividuals(OWLOntology ontoDescr, StatefulKnowledgeSes
String typeIri = individualTypesCache.get( iri.toQuotedString() );
Concept klass = hierachicalModel.getConcept( typeIri );
if ( klass == null ) {
+ System.out.println( "found individual with no class " + iri );
System.exit( -1 );
}
@@ -1197,10 +1199,22 @@ private boolean preProcessIndividuals( OWLOntology ontoDescr, OWLDataFactory fac
boolean dirty = false;
for ( OWLNamedIndividual ind : ontoDescr.getIndividualsInSignature( true ) ) {
- declareAnonymousIndividualSupertypes( ontoDescr, factory, ind );
-
OWLOntology defining = lookupDefiningOntology( ontoDescr, ind );
+
+ declareAnonymousIndividualSupertypes( defining, factory, ind );
+
+ System.out.println( "Defining ontology : " + defining );
+ for ( OWLAxiom ax : defining.getAxioms( AxiomType.CLASS_ASSERTION ) ) {
+ System.out.println( ax );
+ }
+
+ System.out.println("Getting types for individual " + ind.getIRI() );
Set<OWLClassExpression> types = ind.getTypes( defining );
+ System.out.println("Found types in defining ontology" + types );
+ if ( types.isEmpty() ) {
+ ind.getTypes( ontoDescr.getImportsClosure() );
+ System.out.println("Found types in all ontologies " + ontoDescr.getImportsClosure() + " >> " + types );
+ }
types = simplify( types, defining );
if ( types.size() > 1 ) {
@@ -1218,7 +1232,8 @@ private boolean preProcessIndividuals( OWLOntology ontoDescr, OWLDataFactory fac
if ( types.iterator().hasNext() ) {
individualTypesCache.put( ind.getIRI().toQuotedString(), types.iterator().next().asOWLClass().getIRI().toQuotedString() );
} else {
- System.out.println( "WARNING no type detected " );
+
+ System.out.println( "WARNING no type detected for individual " + ind.getIRI().toQuotedString() );
}
}
View
8 ...tor/src/main/resources/org/drools/semantics/builder/model/compilers/bindings.xjb.template
@@ -62,6 +62,8 @@
<annox:annotate>
<annox:annotate annox:class="com.clarkparsia.empire.annotation.RdfsClass" value="@{concept.namespace}@{concept.name}" />
<annox:annotate annox:class="com.clarkparsia.empire.annotation.Namespaces" value="tns @{namespace}" />
+ <annox:annotate annox:class="org.drools.factmodel.traits.Traitable" />
+ <annox:annotate annox:class="org.drools.definition.type.PropertyReactive" />
<annox:annotate annox:class="thewebsemantic.Namespace" value="@{namespace}" />
<annox:annotate annox:class="thewebsemantic.RdfType" value="@{concept.namespace}@{concept.name}" />
<annox:annotate annox:class="javax.xml.bind.annotation.XmlRootElement" name="@{concept.name}"/>
@@ -74,7 +76,7 @@
]]></ci:code>
- <meta:type name="@{concept.name}" parent="@{concept.chosenSuperConcept.name}">
+ <meta:type name="@{concept.name}" package="@{concept.package}" parent="@{concept.chosenSuperConcept.name}">
@foreach{ prop : concept.effectiveBaseProperties }
<meta:property name="@{prop.name}" type="@{prop.target.fullyQualifiedName}" simple="@{ concept.lookupProperty(prop.property).simple }">
@foreach{ subProp : concept.properties.values }
@@ -144,13 +146,15 @@
<annox:annotate>
<annox:annotate annox:class="com.clarkparsia.empire.annotation.RdfProperty" value="@{prop.iri}" />
<annox:annotate annox:class="thewebsemantic.RdfProperty" value="@{prop.iri}" />
+ @if{ ! prop.simple }
<annox:annotate annox:class="javax.persistence.JoinTable" name="@{concept.name.toUpperCase()}IMPL_@{prop.name.toUpperCase()}" />
+ @end{}
</annox:annotate>
@if{ ! prop.target.primitive }
+ @if{ prop.maxCard == null || prop.maxCard > 1 } <hj:many-to-many/> @else{} <hj:many-to-one/> @end{}
- <hj:many-to-many/>
<annox:annotate target="field">
<annox:annotate target="field"
View
10 ...s-shapes-generator/src/main/resources/org/drools/semantics/templates/model/drl/trait.drlt
@@ -3,7 +3,6 @@
* Copyright 2011 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@@ -22,7 +21,14 @@
// @{iri}
declare trait @{fullyQualifiedName} @if{ superConcepts.size > 0 } extends @foreach{ sup : superConcepts } @{ sup.fullyQualifiedName } @end{','} @end{}
-
+@propertyReactive
+@typesafe(false)
+ @if{ "org.w3._2002._07.owl.Thing".equals( fullyQualifiedName ) }
+ rdfId : com.clarkparsia.empire.SupportsRdfId.RdfKey
+ allTriples : org.openrdf.model.Graph
+ instanceTriples : org.openrdf.model.Graph
+ __IndividualName : java.lang.String
+ @end{}
@if{ properties.size > 0 } @foreach{ propKey : properties.keySet }
@code{ prop = properties[ propKey ] }
View
13 ...ator/src/main/resources/org/drools/semantics/templates/model/java/TraitInterface.template
@@ -26,6 +26,7 @@ import com.clarkparsia.empire.annotation.RdfProperty;
import javax.persistence.CascadeType;
import javax.persistence.OneToMany;
+import javax.persistence.ManyToOne;
import javax.persistence.Basic;
@@ -35,6 +36,8 @@ import javax.persistence.Basic;
@Namespaces({ "tns", "@{namespace}" })
@thewebsemantic.Namespace( "@{namespace}" )
@thewebsemantic.RdfType( "@{namespace}@{name}" )
+@org.drools.factmodel.traits.Trait
+@org.drools.definition.type.PropertyReactive
public interface @{name} extends org.drools.semantics.Thing @if{ implInterface != null} , @{ implInterface } @end{}
@if{ superConcepts.size > 0 } , @foreach{ sup : superConcepts } @{sup.package}.@{compactUpperCase( sup.name ) } @end{','} @end{}
{
@@ -57,7 +60,15 @@ public interface @{name} extends org.drools.semantics.Thing @if{ implInterface
// @{prop.property} -- @{prop.maxCard} --- @{prop.name}
- @if{ ! prop.restricted && ! prop.transient } @RdfProperty("@{prop.iri}") @thewebsemantic.RdfProperty("@{prop.iri}") @if{ ! prop.simple } @OneToMany( cascade = CascadeType.PERSIST ) @else{} @Basic( ) @end{} @end{}
+ @if{ ! prop.restricted && ! prop.transient } @RdfProperty("@{prop.iri}") @thewebsemantic.RdfProperty("@{prop.iri}")
+ @if{ prop.target.primitive }
+ @Basic( )
+ @elseif{ prop.maxCard == null || prop.maxCard > 1 }
+ @OneToMany( cascade = CascadeType.ALL )
+ @else{}
+ @ManyToOne( cascade = CascadeType.ALL )
+ @end{}
+ @end{}
public
@if{ prop.maxCard == 1 }
@{ map( prop.target.fullyQualifiedName, true ) }@if{ !prop.target.primitive }@end{}
View
4 ...enerator/src/main/resources/org/drools/semantics/templates/model/java/genericAdd.template
@@ -23,11 +23,15 @@
@if{ ! primitive }
@@javax.persistence.Transient
public void add@{ compactUpperCase(name) }( java.lang.Object x ) {
+ @if{ ! simple }
if ( x instanceof @{map( type, true ) } ) {
@{ getter( name, type, max ) }().add( ( @{ map( type, true ) } ) x );
} else {
//TODO : Trait it!
}
+ @else{}
+ @{ name } = ( @{map( type, true )} ) x;
+ @end{}
}
@end{}
View
5 ...generator/src/main/resources/org/drools/semantics/templates/model/java/metaDescr.template
@@ -6,6 +6,11 @@
return "@{typeName}";
}
+ @javax.persistence.Transient
+ public java.lang.String getFullName() {
+ return "@{package}.@{typeName}";
+ }
+
@javax.xml.bind.annotation.XmlTransient
private static java.util.List<java.lang.String> @{typeName}PropertyNames;
{
View
10 ...src/main/resources/org/drools/semantics/templates/model/java/restrictedAddRemove.template
@@ -24,7 +24,9 @@
@@javax.persistence.Transient
public void add@{ compactUpperCase( name ) }( @{ map( type, true ) } x ) {
- @if{ ! primitive }
+ @if{ simple }
+ @{ name } = ( @{ map( type, true ) } ) x;
+ @elseif{ ! primitive }
add@{ compactUpperCase( base ) }( (java.lang.Object) x );
@else{}
@{ getter( base, type ) }().add( x );
@@ -34,7 +36,11 @@
@@javax.persistence.Transient
public void remove@{ compactUpperCase( name ) }( java.lang.Object x ) {
- @{ getter( base, type ) }().remove( x );
+ @if{ simple }
+ @{ name } = null;
+ @else{}
+ @{ getter( base, type ) }().remove( x );
+ @end{}
}
View
2  ...pes/drools-shapes-generator/src/test/java/org/drools/semantics/lang/dl/DL_4_AreaTest.java
@@ -204,7 +204,7 @@ public void testArea2() {
try {
Resource res = ResourceFactory.newClassPathResource( "ontologies/hardware.owl" );
- OntoModel model = DLFactoryImpl.getInstance().buildModel( "hw", res, OntoModel.Mode.NONE );
+ OntoModel model = DLFactoryImpl.getInstance().buildModel( "hw", res, OntoModel.Mode.FLAT );
AreaTxn<Concept,PropertyRelation> areaTxn = model.getAreaTaxonomy();
View
2  ...pes/drools-shapes-generator/src/test/java/org/drools/semantics/lang/dl/DL_7_RuleTest.java
@@ -68,7 +68,7 @@ public void testPizzaOntologyRecognition() {
OntoModel pizzaModel = factory.buildModel( "pizza",
res,
- OntoModel.Mode.NONE,
+ OntoModel.Mode.FLAT,
DLFactory.defaultAxiomGenerators );
String drl = new TemplateRecognitionRuleBuilder().createDRL( pizza, pizzaModel );
View
20 ...es/drools-shapes-generator/src/test/java/org/drools/semantics/lang/dl/DL_8_ModelTest.java
@@ -702,7 +702,7 @@ public void testDataEnumRange() {
@Test
public void testKMR2Ontology() {
Resource res = ResourceFactory.newClassPathResource( "ontologies/kmr2/KMR_Ontology2.ttl" );
- OntoModel results = factory.buildModel( "kmr2", res, OntoModel.Mode.NONE, DLFactory.liteAxiomGenerators );
+ OntoModel results = factory.buildModel( "kmr2", res, OntoModel.Mode.FLAT, DLFactory.liteAxiomGenerators );
assertNotNull(results);
checkConceptEncoding(results);
@@ -713,7 +713,7 @@ public void testKMR2Ontology() {
@Test
public void testAnonymousClassIndividual() {
Resource res = ResourceFactory.newClassPathResource( "ontologies/anonClassIndividual.owl" );
- OntoModel results = factory.buildModel( "test", res, OntoModel.Mode.NONE, DLFactory.liteAxiomGenerators );
+ OntoModel results = factory.buildModel( "test", res, OntoModel.Mode.FLAT, DLFactory.liteAxiomGenerators );
assertNotNull(results);
checkConceptEncoding( results );
@@ -736,7 +736,7 @@ public void testAnonymousClassIndividual() {
@Test
public void testOutOfDomainProperty() {
Resource res = ResourceFactory.newClassPathResource( "ontologies/outOfDomainProperty.owl" );
- OntoModel results = factory.buildModel( "test", res, OntoModel.Mode.NONE, DLFactory.liteAxiomGenerators );
+ OntoModel results = factory.buildModel( "test", res, OntoModel.Mode.FLAT, DLFactory.liteAxiomGenerators );
assertNotNull(results);
checkConceptEncoding( results );
@@ -766,6 +766,20 @@ public void testPeopleOntology() {
}
+ @Test
+ @Ignore
+ public void testDatabaseModel() {
+ Resource res = ResourceFactory.newClassPathResource( "ontologies/dbModel.owl" );
+ OntoModel results = factory.buildModel( "DB", res, OntoModel.Mode.NONE, DLFactory.liteAxiomGenerators );
+ assertNotNull(results);
+
+ checkConceptEncoding( results );
+
+
+ }
+
+
+
private boolean checkConceptEncoding( OntoModel results ) {
boolean ans = true;
for ( Concept con : results.getConcepts() ) {
View
359 drools-shapes/drools-shapes-generator/src/test/resources/ontologies/dbModel.owl
@@ -0,0 +1,359 @@
+Prefix(owl:=<http://www.w3.org/2002/07/owl#>)
+Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
+Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)
+Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)
+Prefix(data:=<http://asu.bmi.edu/policy/dataModel#>)
+Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)
+
+
+Ontology(<http://asu.bmi.edu/policy/dataModel>
+
+Declaration(Class(data:AliquotPlateFrozen))
+SubClassOf(data:AliquotPlateFrozen ObjectMaxCardinality(1 data:partID))
+SubClassOf(data:AliquotPlateFrozen DataMaxCardinality(1 data:dateOfFrozen))
+Declaration(Class(data:AliquotStorage))
+SubClassOf(data:AliquotStorage ObjectMaxCardinality(1 data:partID))
+SubClassOf(data:AliquotStorage DataMaxCardinality(1 data:aliquotCode))
+SubClassOf(data:AliquotStorage DataMaxCardinality(1 data:disposition))
+SubClassOf(data:AliquotStorage DataMaxCardinality(1 data:enteredDate))
+SubClassOf(data:AliquotStorage DataMaxCardinality(1 data:sampleAvailable))
+SubClassOf(data:AliquotStorage DataMaxCardinality(1 data:sampleFormat))
+SubClassOf(data:AliquotStorage DataMaxCardinality(1 data:sampleSubType))
+SubClassOf(data:AliquotStorage DataMaxCardinality(1 data:sampleType))
+SubClassOf(data:AliquotStorage DataMaxCardinality(1 data:updatedBy))
+Declaration(Class(data:AliquotStorageComment))
+SubClassOf(data:AliquotStorageComment ObjectMaxCardinality(1 data:partID))
+SubClassOf(data:AliquotStorageComment DataMaxCardinality(1 data:comment))
+SubClassOf(data:AliquotStorageComment DataMaxCardinality(1 data:sampleSubType))
+SubClassOf(data:AliquotStorageComment DataMaxCardinality(1 data:sampleType))
+Declaration(Class(data:AliquotStorageInfo))
+SubClassOf(data:AliquotStorageInfo DataMaxCardinality(1 data:enteredDate))
+SubClassOf(data:AliquotStorageInfo DataMaxCardinality(1 data:freezer))
+SubClassOf(data:AliquotStorageInfo DataMaxCardinality(1 data:lastChangedOn))
+SubClassOf(data:AliquotStorageInfo DataMaxCardinality(1 data:rack))
+SubClassOf(data:AliquotStorageInfo DataMaxCardinality(1 data:slot))
+Declaration(Class(data:AliquotStoragePart))
+SubClassOf(data:AliquotStoragePart ObjectMaxCardinality(1 data:partID))
+SubClassOf(data:AliquotStoragePart DataMaxCardinality(1 data:studytime))
+Declaration(Class(data:CancerHistory))
+SubClassOf(data:CancerHistory ObjectMaxCardinality(1 data:partID))
+SubClassOf(data:CancerHistory DataMaxCardinality(1 data:ageDiagnosis))
+SubClassOf(data:CancerHistory DataMaxCardinality(1 data:chart))
+SubClassOf(data:CancerHistory DataMaxCardinality(1 data:comments))
+SubClassOf(data:CancerHistory DataMaxCardinality(1 data:confirmation))
+SubClassOf(data:CancerHistory DataMaxCardinality(1 data:dateCollected))
+SubClassOf(data:CancerHistory DataMaxCardinality(1 data:dateEntered))
+SubClassOf(data:CancerHistory DataMaxCardinality(1 data:dateOfDiagnosis))
+SubClassOf(data:CancerHistory DataMaxCardinality(1 data:dateOfFirstSymptom))
+SubClassOf(data:CancerHistory DataMaxCardinality(1 data:deleteFlag))
+SubClassOf(data:CancerHistory DataMaxCardinality(1 data:histology))
+SubClassOf(data:CancerHistory DataMaxCardinality(1 data:icd9))
+SubClassOf(data:CancerHistory DataMaxCardinality(1 data:icd9Other))
+SubClassOf(data:CancerHistory DataMaxCardinality(1 data:lastChangedOn))
+SubClassOf(data:CancerHistory DataMaxCardinality(1 data:laterality))
+SubClassOf(data:CancerHistory DataMaxCardinality(1 data:radiology))
+SubClassOf(data:CancerHistory DataMaxCardinality(1 data:stageM))
+SubClassOf(data:CancerHistory DataMaxCardinality(1 data:stageN))
+SubClassOf(data:CancerHistory DataMaxCardinality(1 data:stageT))
+SubClassOf(data:CancerHistory DataMaxCardinality(1 data:studyTime))
+Declaration(Class(data:CancerTreatment))
+SubClassOf(data:CancerTreatment ObjectMaxCardinality(1 data:historyID))
+SubClassOf(data:CancerTreatment DataMaxCardinality(1 data:comments))
+SubClassOf(data:CancerTreatment DataMaxCardinality(1 data:dateEntered))
+SubClassOf(data:CancerTreatment DataMaxCardinality(1 data:deleteFlag))
+SubClassOf(data:CancerTreatment DataMaxCardinality(1 data:firstTreatDate))
+SubClassOf(data:CancerTreatment DataMaxCardinality(1 data:lastChangedOn))
+SubClassOf(data:CancerTreatment DataMaxCardinality(1 data:lastTreatDate))
+SubClassOf(data:CancerTreatment DataMaxCardinality(1 data:treatment))
+SubClassOf(data:CancerTreatment DataMaxCardinality(1 data:treatmentOther))
+SubClassOf(data:CancerTreatment DataMaxCardinality(1 data:treatmentResponse))
+Declaration(Class(data:Custody))
+SubClassOf(data:Custody DataMaxCardinality(1 data:dateOfSign))
+SubClassOf(data:Custody DataMaxCardinality(1 data:nameFirst))
+SubClassOf(data:Custody DataMaxCardinality(1 data:nameLast))
+Declaration(Class(data:Demographics))
+SubClassOf(data:Demographics ObjectMaxCardinality(1 data:partID))
+SubClassOf(data:Demographics DataMaxCardinality(1 data:birthYear))
+SubClassOf(data:Demographics DataMaxCardinality(1 data:dateBioRepositoryBloodCollected))
+SubClassOf(data:Demographics DataMaxCardinality(1 data:dateBioRepositoryRecordUpdated))
+SubClassOf(data:Demographics DataMaxCardinality(1 data:dateEntered))
+SubClassOf(data:Demographics DataMaxCardinality(1 data:gender))
+SubClassOf(data:Demographics DataMaxCardinality(1 data:heightFeet))
+SubClassOf(data:Demographics DataMaxCardinality(1 data:heightInch))
+SubClassOf(data:Demographics DataMaxCardinality(1 data:lastChangedOn))
+SubClassOf(data:Demographics DataMaxCardinality(1 data:lostToFollowUp))
+SubClassOf(data:Demographics DataMaxCardinality(1 data:menstrualBeginAge))
+SubClassOf(data:Demographics DataMaxCardinality(1 data:race))
+SubClassOf(data:Demographics DataMaxCardinality(1 data:raceOther))
+Declaration(Class(data:FamilyCancerHistory))
+SubClassOf(data:FamilyCancerHistory ObjectMaxCardinality(1 data:partID))
+SubClassOf(data:FamilyCancerHistory DataMaxCardinality(1 data:ageDiagnosis))
+SubClassOf(data:FamilyCancerHistory DataMaxCardinality(1 data:cancerType))
+SubClassOf(data:FamilyCancerHistory DataMaxCardinality(1 data:cancerTypeOther))
+SubClassOf(data:FamilyCancerHistory DataMaxCardinality(1 data:confirmation))
+SubClassOf(data:FamilyCancerHistory DataMaxCardinality(1 data:dateCollected))
+SubClassOf(data:FamilyCancerHistory DataMaxCardinality(1 data:deleteFlag))
+SubClassOf(data:FamilyCancerHistory DataMaxCardinality(1 data:relativeType))
+SubClassOf(data:FamilyCancerHistory DataMaxCardinality(1 data:studyTime))
+Declaration(Class(data:PatientSample))
+SubClassOf(data:PatientSample DataMaxCardinality(1 data:comments))
+SubClassOf(data:PatientSample DataMaxCardinality(1 data:dateOfBloodDraw))
+SubClassOf(data:PatientSample DataMaxCardinality(1 data:dateOfUrineCollection))
+SubClassOf(data:PatientSample DataMaxCardinality(1 data:elisa4DegreeTime))
+SubClassOf(data:PatientSample DataMaxCardinality(1 data:timeOfBuffyCoat))
+SubClassOf(data:PatientSample DataMaxCardinality(1 data:timeOfFreeze))
+Declaration(Class(data:Plate))
+Declaration(Class(data:Sample))
+Declaration(Class(data:SmokeMentrualHistory))
+SubClassOf(data:SmokeMentrualHistory ObjectMaxCardinality(1 data:partID))
+SubClassOf(data:SmokeMentrualHistory DataMaxCardinality(1 data:comments))
+SubClassOf(data:SmokeMentrualHistory DataMaxCardinality(1 data:dateCollected))
+SubClassOf(data:SmokeMentrualHistory DataMaxCardinality(1 data:deleteFlag))
+SubClassOf(data:SmokeMentrualHistory DataMaxCardinality(1 data:menstrualStop))
+SubClassOf(data:SmokeMentrualHistory DataMaxCardinality(1 data:menstrualStopAge))
+SubClassOf(data:SmokeMentrualHistory DataMaxCardinality(1 data:smokeAgrDay))
+SubClassOf(data:SmokeMentrualHistory DataMaxCardinality(1 data:smokeBeginAgeRegular))
+SubClassOf(data:SmokeMentrualHistory DataMaxCardinality(1 data:smokeCurrentRegular))
+SubClassOf(data:SmokeMentrualHistory DataMaxCardinality(1 data:smokeQuitAge))
+SubClassOf(data:SmokeMentrualHistory DataMaxCardinality(1 data:smokeRegular1Year))
+SubClassOf(data:SmokeMentrualHistory DataMaxCardinality(1 data:studyTime))
+Declaration(Class(data:TissueDetail))
+SubClassOf(data:TissueDetail ObjectMaxCardinality(1 data:tissueID))
+SubClassOf(data:TissueDetail DataMaxCardinality(1 data:actionDate))
+SubClassOf(data:TissueDetail DataMaxCardinality(1 data:comments))
+SubClassOf(data:TissueDetail DataMaxCardinality(1 data:deletedYn))
+SubClassOf(data:TissueDetail DataMaxCardinality(1 data:location))
+SubClassOf(data:TissueDetail DataMaxCardinality(1 data:passageNum))
+SubClassOf(data:TissueDetail DataMaxCardinality(1 data:quantity))
+SubClassOf(data:TissueDetail DataMaxCardinality(1 data:sampleTypeR))
+Declaration(Class(data:TissueManagement))
+SubClassOf(data:TissueManagement ObjectMaxCardinality(1 data:partID))
+SubClassOf(data:TissueManagement DataMaxCardinality(1 data:comments))
+SubClassOf(data:TissueManagement DataMaxCardinality(1 data:deletedYn))
+SubClassOf(data:TissueManagement DataMaxCardinality(1 data:icd9))
+Declaration(ObjectProperty(data:historyID))
+ObjectPropertyDomain(data:historyID data:CancerTreatment)
+ObjectPropertyRange(data:historyID data:CancerHistory)
+Declaration(ObjectProperty(data:partID))
+ObjectPropertyDomain(data:partID ObjectUnionOf(data:AliquotPlateFrozen data:AliquotStorage data:AliquotStorageComment data:AliquotStoragePart data:CancerHistory data:Demographics data:FamilyCancerHistory data:SmokeMentrualHistory data:TissueManagement))
+ObjectPropertyRange(data:partID data:PatientSample)
+Declaration(ObjectProperty(data:tissueID))
+ObjectPropertyDomain(data:tissueID data:TissueDetail)
+ObjectPropertyRange(data:tissueID data:TissueManagement)
+Declaration(DataProperty(data:actionDate))
+DataPropertyDomain(data:actionDate data:TissueDetail)
+DataPropertyRange(data:actionDate xsd:dateTime)
+Declaration(DataProperty(data:ageDiagnosis))
+DataPropertyDomain(data:ageDiagnosis ObjectUnionOf(data:FamilyCancerHistory data:CancerHistory))
+DataPropertyRange(data:ageDiagnosis xsd:string)
+Declaration(DataProperty(data:aliquotCode))
+DataPropertyDomain(data:aliquotCode data:AliquotStorage)
+DataPropertyRange(data:aliquotCode xsd:string)
+Declaration(DataProperty(data:birthYear))
+DataPropertyDomain(data:birthYear data:Demographics)
+DataPropertyRange(data:birthYear xsd:string)
+Declaration(DataProperty(data:cancerType))
+DataPropertyDomain(data:cancerType data:FamilyCancerHistory)
+DataPropertyRange(data:cancerType xsd:string)
+Declaration(DataProperty(data:cancerTypeOther))
+DataPropertyDomain(data:cancerTypeOther data:FamilyCancerHistory)
+DataPropertyRange(data:cancerTypeOther xsd:string)
+Declaration(DataProperty(data:chart))
+DataPropertyDomain(data:chart data:CancerHistory)
+DataPropertyRange(data:chart xsd:string)
+Declaration(DataProperty(data:comment))
+DataPropertyDomain(data:comment data:AliquotStorageComment)
+DataPropertyRange(data:comment xsd:string)
+Declaration(DataProperty(data:comments))
+DataPropertyDomain(data:comments ObjectUnionOf(data:CancerHistory data:CancerTreatment data:PatientSample data:SmokeMentrualHistory data:TissueDetail data:TissueManagement))
+DataPropertyRange(data:comments xsd:string)
+Declaration(DataProperty(data:confirmation))
+DataPropertyDomain(data:confirmation ObjectUnionOf(data:FamilyCancerHistory data:CancerHistory))
+DataPropertyRange(data:confirmation xsd:string)
+Declaration(DataProperty(data:dateBioRepositoryBloodCollected))
+DataPropertyDomain(data:dateBioRepositoryBloodCollected data:Demographics)
+DataPropertyRange(data:dateBioRepositoryBloodCollected xsd:string)
+Declaration(DataProperty(data:dateBioRepositoryRecordUpdated))
+DataPropertyDomain(data:dateBioRepositoryRecordUpdated data:Demographics)
+DataPropertyRange(data:dateBioRepositoryRecordUpdated xsd:string)
+Declaration(DataProperty(data:dateCollected))
+DataPropertyDomain(data:dateCollected ObjectUnionOf(data:CancerHistory data:FamilyCancerHistory data:SmokeMentrualHistory))
+DataPropertyRange(data:dateCollected xsd:string)
+Declaration(DataProperty(data:dateEntered))
+DataPropertyDomain(data:dateEntered ObjectUnionOf(data:CancerHistory data:CancerTreatment data:Demographics))
+DataPropertyRange(data:dateEntered xsd:string)
+Declaration(DataProperty(data:dateOfBloodDraw))
+DataPropertyDomain(data:dateOfBloodDraw data:PatientSample)
+DataPropertyRange(data:dateOfBloodDraw xsd:string)
+Declaration(DataProperty(data:dateOfDiagnosis))
+DataPropertyDomain(data:dateOfDiagnosis data:CancerHistory)
+DataPropertyRange(data:dateOfDiagnosis xsd:string)
+Declaration(DataProperty(data:dateOfFirstSymptom))
+DataPropertyDomain(data:dateOfFirstSymptom data:CancerHistory)
+DataPropertyRange(data:dateOfFirstSymptom xsd:string)
+Declaration(DataProperty(data:dateOfFrozen))
+DataPropertyDomain(data:dateOfFrozen data:AliquotPlateFrozen)
+DataPropertyRange(data:dateOfFrozen xsd:string)
+Declaration(DataProperty(data:dateOfSign))
+DataPropertyDomain(data:dateOfSign data:Custody)
+DataPropertyRange(data:dateOfSign xsd:string)
+Declaration(DataProperty(data:dateOfUrineCollection))
+DataPropertyDomain(data:dateOfUrineCollection data:PatientSample)
+DataPropertyRange(data:dateOfUrineCollection xsd:string)
+Declaration(DataProperty(data:deleteFlag))
+DataPropertyDomain(data:deleteFlag ObjectUnionOf(data:CancerHistory data:CancerTreatment data:FamilyCancerHistory data:SmokeMentrualHistory))
+DataPropertyRange(data:deleteFlag xsd:boolean)
+Declaration(DataProperty(data:deletedYn))
+DataPropertyDomain(data:deletedYn ObjectUnionOf(data:TissueManagement data:TissueDetail))
+DataPropertyRange(data:deletedYn xsd:string)
+Declaration(DataProperty(data:disposition))
+DataPropertyDomain(data:disposition data:AliquotStorage)
+DataPropertyRange(data:disposition xsd:string)
+Declaration(DataProperty(data:elisa4DegreeTime))
+DataPropertyDomain(data:elisa4DegreeTime data:PatientSample)
+DataPropertyRange(data:elisa4DegreeTime xsd:string)
+Declaration(DataProperty(data:enteredDate))
+DataPropertyDomain(data:enteredDate ObjectUnionOf(data:AliquotStorageInfo data:AliquotStorage))
+DataPropertyRange(data:enteredDate xsd:dateTime)
+Declaration(DataProperty(data:firstTreatDate))
+DataPropertyDomain(data:firstTreatDate data:CancerTreatment)
+DataPropertyRange(data:firstTreatDate xsd:dateTime)
+Declaration(DataProperty(data:freezer))
+DataPropertyDomain(data:freezer data:AliquotStorageInfo)
+DataPropertyRange(data:freezer xsd:string)
+Declaration(DataProperty(data:gender))
+DataPropertyDomain(data:gender data:Demographics)
+DataPropertyRange(data:gender xsd:string)
+Declaration(DataProperty(data:heightFeet))
+DataPropertyDomain(data:heightFeet data:Demographics)
+DataPropertyRange(data:heightFeet xsd:string)
+Declaration(DataProperty(data:heightInch))
+DataPropertyDomain(data:heightInch data:Demographics)
+DataPropertyRange(data:heightInch xsd:string)
+Declaration(DataProperty(data:histology))
+DataPropertyDomain(data:histology data:CancerHistory)
+DataPropertyRange(data:histology xsd:string)
+Declaration(DataProperty(data:icd9))
+DataPropertyDomain(data:icd9 ObjectUnionOf(data:TissueManagement data:CancerHistory))
+DataPropertyRange(data:icd9 xsd:string)
+Declaration(DataProperty(data:icd9Other))
+DataPropertyDomain(data:icd9Other data:CancerHistory)
+DataPropertyRange(data:icd9Other xsd:string)
+Declaration(DataProperty(data:lastChangedOn))
+DataPropertyDomain(data:lastChangedOn ObjectUnionOf(data:AliquotStorageInfo data:CancerHistory data:CancerTreatment data:Demographics))
+DataPropertyRange(data:lastChangedOn xsd:dateTime)
+Declaration(DataProperty(data:lastTreatDate))
+DataPropertyDomain(data:lastTreatDate data:CancerTreatment)
+DataPropertyRange(data:lastTreatDate xsd:dateTime)
+Declaration(DataProperty(data:laterality))
+DataPropertyDomain(data:laterality data:CancerHistory)
+DataPropertyRange(data:laterality xsd:string)
+Declaration(DataProperty(data:location))
+DataPropertyDomain(data:location data:TissueDetail)
+DataPropertyRange(data:location xsd:string)
+Declaration(DataProperty(data:lostToFollowUp))
+DataPropertyDomain(data:lostToFollowUp data:Demographics)
+DataPropertyRange(data:lostToFollowUp xsd:string)
+Declaration(DataProperty(data:menstrualBeginAge))
+DataPropertyDomain(data:menstrualBeginAge data:Demographics)
+DataPropertyRange(data:menstrualBeginAge xsd:string)
+Declaration(DataProperty(data:menstrualStop))
+DataPropertyDomain(data:menstrualStop data:SmokeMentrualHistory)
+DataPropertyRange(data:menstrualStop xsd:string)
+Declaration(DataProperty(data:menstrualStopAge))
+DataPropertyDomain(data:menstrualStopAge data:SmokeMentrualHistory)
+DataPropertyRange(data:menstrualStopAge xsd:string)
+Declaration(DataProperty(data:nameFirst))
+DataPropertyDomain(data:nameFirst data:Custody)
+DataPropertyRange(data:nameFirst xsd:string)
+Declaration(DataProperty(data:nameLast))
+DataPropertyDomain(data:nameLast data:Custody)
+DataPropertyRange(data:nameLast xsd:string)
+Declaration(DataProperty(data:passageNum))
+DataPropertyDomain(data:passageNum data:TissueDetail)
+DataPropertyRange(data:passageNum xsd:boolean)
+Declaration(DataProperty(data:quantity))
+DataPropertyDomain(data:quantity data:TissueDetail)
+DataPropertyRange(data:quantity xsd:string)
+Declaration(DataProperty(data:race))
+DataPropertyDomain(data:race data:Demographics)
+DataPropertyRange(data:race xsd:string)
+Declaration(DataProperty(data:raceOther))
+DataPropertyDomain(data:raceOther data:Demographics)
+DataPropertyRange(data:raceOther xsd:string)
+Declaration(DataProperty(data:rack))
+DataPropertyDomain(data:rack data:AliquotStorageInfo)
+DataPropertyRange(data:rack xsd:string)
+Declaration(DataProperty(data:radiology))
+DataPropertyDomain(data:radiology data:CancerHistory)
+DataPropertyRange(data:radiology xsd:string)
+Declaration(DataProperty(data:relativeType))
+DataPropertyDomain(data:relativeType data:FamilyCancerHistory)
+DataPropertyRange(data:relativeType xsd:string)
+Declaration(DataProperty(data:sampleAvailable))
+DataPropertyDomain(data:sampleAvailable data:AliquotStorage)
+DataPropertyRange(data:sampleAvailable xsd:string)
+Declaration(DataProperty(data:sampleFormat))
+DataPropertyDomain(data:sampleFormat data:AliquotStorage)
+DataPropertyRange(data:sampleFormat xsd:string)
+Declaration(DataProperty(data:sampleSubType))
+DataPropertyDomain(data:sampleSubType ObjectUnionOf(data:AliquotStorageComment data:AliquotStorage))
+DataPropertyRange(data:sampleSubType xsd:string)
+Declaration(DataProperty(data:sampleType))
+DataPropertyDomain(data:sampleType ObjectUnionOf(data:AliquotStorageComment data:AliquotStorage))
+DataPropertyRange(data:sampleType xsd:string)
+Declaration(DataProperty(data:sampleTypeR))
+DataPropertyDomain(data:sampleTypeR data:TissueDetail)
+DataPropertyRange(data:sampleTypeR xsd:string)
+Declaration(DataProperty(data:slot))
+DataPropertyDomain(data:slot data:AliquotStorageInfo)
+DataPropertyRange(data:slot xsd:string)
+Declaration(DataProperty(data:smokeAgrDay))
+DataPropertyDomain(data:smokeAgrDay data:SmokeMentrualHistory)
+DataPropertyRange(data:smokeAgrDay xsd:string)
+Declaration(DataProperty(data:smokeBeginAgeRegular))
+DataPropertyDomain(data:smokeBeginAgeRegular data:SmokeMentrualHistory)
+DataPropertyRange(data:smokeBeginAgeRegular xsd:string)
+Declaration(DataProperty(data:smokeCurrentRegular))
+DataPropertyDomain(data:smokeCurrentRegular data:SmokeMentrualHistory)
+DataPropertyRange(data:smokeCurrentRegular xsd:string)
+Declaration(DataProperty(data:smokeQuitAge))
+DataPropertyDomain(data:smokeQuitAge data:SmokeMentrualHistory)
+DataPropertyRange(data:smokeQuitAge xsd:string)
+Declaration(DataProperty(data:smokeRegular1Year))
+DataPropertyDomain(data:smokeRegular1Year data:SmokeMentrualHistory)
+DataPropertyRange(data:smokeRegular1Year xsd:string)
+Declaration(DataProperty(data:stageM))
+DataPropertyDomain(data:stageM data:CancerHistory)
+DataPropertyRange(data:stageM xsd:string)
+Declaration(DataProperty(data:stageN))
+DataPropertyDomain(data:stageN data:CancerHistory)
+DataPropertyRange(data:stageN xsd:string)
+Declaration(DataProperty(data:stageT))
+DataPropertyDomain(data:stageT data:CancerHistory)
+DataPropertyRange(data:stageT xsd:string)
+Declaration(DataProperty(data:studyTime))
+DataPropertyDomain(data:studyTime ObjectUnionOf(data:CancerHistory data:FamilyCancerHistory data:SmokeMentrualHistory))
+DataPropertyRange(data:studyTime xsd:string)
+Declaration(DataProperty(data:studytime))
+DataPropertyDomain(data:studytime data:AliquotStoragePart)
+DataPropertyRange(data:studytime xsd:string)
+Declaration(DataProperty(data:timeOfBuffyCoat))
+DataPropertyDomain(data:timeOfBuffyCoat data:PatientSample)
+DataPropertyRange(data:timeOfBuffyCoat xsd:string)
+Declaration(DataProperty(data:timeOfFreeze))
+DataPropertyDomain(data:timeOfFreeze data:PatientSample)
+DataPropertyRange(data:timeOfFreeze xsd:string)
+Declaration(DataProperty(data:treatment))
+DataPropertyDomain(data:treatment data:CancerTreatment)
+DataPropertyRange(data:treatment xsd:string)
+Declaration(DataProperty(data:treatmentOther))
+DataPropertyDomain(data:treatmentOther data:CancerTreatment)
+DataPropertyRange(data:treatmentOther xsd:string)
+Declaration(DataProperty(data:treatmentResponse))
+DataPropertyDomain(data:treatmentResponse data:CancerTreatment)
+DataPropertyRange(data:treatmentResponse xsd:string)
+Declaration(DataProperty(data:updatedBy))
+DataPropertyDomain(data:updatedBy data:AliquotStorage)
+DataPropertyRange(data:updatedBy xsd:string)
+)
View
4 drools-shapes/drools-shapes-utilities/src/main/java/org.drools.semantics/Thing.java
@@ -7,6 +7,8 @@
public String get__IndividualName();
- public void set__IndividualName( String s );
+ public void set__IndividualName( String name );
+
+ public String getFullName();
}
View
142 drools-shapes/drools-shapes-utilities/src/main/java/org/w3/_2002/_07/owl/ThingImpl.java
@@ -9,6 +9,9 @@
package org.w3._2002._07.owl;
import java.io.Serializable;
+import java.util.BitSet;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Map;
import javax.persistence.Basic;
import javax.persistence.Column;
@@ -30,6 +33,13 @@
import com.clarkparsia.empire.annotation.Namespaces;
import com.clarkparsia.empire.annotation.RdfsClass;
import com.sun.xml.bind.CycleRecoverable;
+import org.drools.factmodel.traits.LogicalTypeInconsistencyException;
+import org.drools.factmodel.traits.TraitFieldTMS;
+import org.drools.factmodel.traits.TraitFieldTMSImpl;
+import org.drools.factmodel.traits.TraitType;
+import org.drools.factmodel.traits.TraitTypeMap;
+import org.drools.factmodel.traits.Traitable;
+import org.drools.factmodel.traits.TraitableBean;
import org.drools.semantics.NamedEntity;
import org.drools.semantics.UIdAble;
import org.jvnet.jaxb2_commons.lang.CopyStrategy;
@@ -85,9 +95,10 @@
@Entity(name = "ThingImpl")
@Table(name = "THINGIMPL")
@Inheritance(strategy = InheritanceType.JOINED)
+@Traitable
public class ThingImpl
extends UIdAble
- implements NamedEntity, Serializable, Cloneable, CycleRecoverable, CopyTo, Equals, HashCode, MergeFrom, Thing, EmpireGenerated {
+ implements NamedEntity, Serializable, Cloneable, CycleRecoverable, CopyTo, Equals, HashCode, MergeFrom, Thing, EmpireGenerated, TraitableBean<ThingImpl, ThingImpl>, TraitType {
// protected String dyEntryType;
@XmlAttribute( required = false, name = "idref" )
@@ -332,9 +343,12 @@ public String getSemanticTypeName() {
@XmlTransient
private Graph allTriples;
+
@XmlTransient
private Graph instanceTriples;
+
+ @javax.persistence.Transient
public Graph getAllTriples() {
return allTriples;
}
@@ -343,6 +357,7 @@ public void setAllTriples(Graph allTriples) {
this.allTriples = allTriples;
}
+ @javax.persistence.Transient
public Graph getInstanceTriples() {
return instanceTriples;
}
@@ -353,20 +368,19 @@ public void setInstanceTriples(Graph instanceTriples) {
// In compliance with the Traiting Thing interface,
- // these methods are not really needed
@Transient
public Map<String, Object> getFields() {
- throw new UnsupportedOperationException( ThingImpl.class.getName() + " is not supposed to be used as a trait proxy" );
+ throw new UnsupportedOperationException( ThingImpl.class.getName() + " should support a field accessor, TODO" );
}
@Transient
public org.drools.semantics.Thing getCore() {
- throw new UnsupportedOperationException( ThingImpl.class.getName() + " is not supposed to be used as a trait proxy" );
+ return this;
}
@Transient
public boolean isTop() {
- throw new UnsupportedOperationException( ThingImpl.class.getName() + " is not supposed to be used as a trait proxy" );
+ return false;
}
@Transient
@@ -379,4 +393,122 @@ public void set__IndividualName( String name ) {
setDyEntryId( name );
}
}
+
+ @Transient
+ public String getFullName() {
+ return Thing.class.getName();
+ }
+
+
+ @XmlTransient
+ private TraitFieldTMS __$$field_Tms$$;
+ @XmlTransient
+ private Map<String,Object> __$$dynamic_properties_map$$;
+ @XmlTransient
+ private Map<String, org.drools.factmodel.traits.Thing<ThingImpl>> __$$dynamic_traits_map$$;
+
+
+ @Transient
+ public Map<String, Object> _getDynamicProperties() {
+ return __$$dynamic_properties_map$$;
+ }
+
+ public void _setDynamicProperties(Map map) {
+ __$$dynamic_properties_map$$ = map;
+ }
+
+ public void _setTraitMap(Map map) {
+ __$$dynamic_traits_map$$ = map;
+ }
+
+ @Transient
+ public Map<String, org.drools.factmodel.traits.Thing<ThingImpl>> _getTraitMap() {
+ return __$$dynamic_traits_map$$;
+ }
+
+ public void addTrait(String type, org.drools.factmodel.traits.Thing proxy) throws LogicalTypeInconsistencyException {
+ ((TraitTypeMap) _getTraitMap()).putSafe(type, proxy);
+ }
+
+ @Transient
+ public org.drools.factmodel.traits.Thing getTrait(String type) {
+ return _getTraitMap().get( type );
+ }
+
+
+ public boolean hasTrait( String type ) {
+ return __$$dynamic_traits_map$$ != null && __$$dynamic_traits_map$$.containsKey( type );
+ }
+
+ public boolean hasTraits() {
+ return __$$dynamic_traits_map$$ != null && ! __$$dynamic_traits_map$$.isEmpty();
+ }
+
+ public Collection<org.drools.factmodel.traits.Thing<ThingImpl>> removeTrait( String type ) {
+ if ( __$$dynamic_traits_map$$ != null ) {
+ return ((TraitTypeMap)_getTraitMap()).removeCascade(type);
+ } else {
+ return null;
+ }
+ }
+
+ public Collection<org.drools.factmodel.traits.Thing<ThingImpl>> removeTrait( BitSet typeCode ) {
+ if ( __$$dynamic_traits_map$$ != null ) {
+ return ((TraitTypeMap)_getTraitMap()).removeCascade( typeCode );
+ } else {
+ return null;
+ }
+ }
+
+ @Transient
+ public Collection<String> getTraits() {
+ if ( __$$dynamic_traits_map$$ != null ) {
+ return _getTraitMap().keySet();
+ } else {
+ return Collections.emptySet();
+ }
+ }
+
+ @Transient
+ public Collection<org.drools.factmodel.traits.Thing> getMostSpecificTraits() {
+ if ( __$$dynamic_traits_map$$ == null ) {
+ return Collections.EMPTY_LIST;
+ }
+ return ((TraitTypeMap) __$$dynamic_traits_map$$).getMostSpecificTraits();
+ }
+
+ @Transient
+ public BitSet getCurrentTypeCode() {
+ if ( __$$dynamic_traits_map$$ == null ) {
+ return null;
+ }
+ return ((TraitTypeMap) __$$dynamic_traits_map$$).getCurrentTypeCode();
+ }
+
+ public void _setBottomTypeCode( BitSet bottomTypeCode ) {
+ ((TraitTypeMap) __$$dynamic_traits_map$$).setBottomCode( bottomTypeCode );
+ }
+
+ @Transient
+ public TraitFieldTMS _getFieldTMS() {
+ if ( __$$field_Tms$$ == null ) {
+ __$$field_Tms$$ = new TraitFieldTMSImpl();
+ }
+ return __$$field_Tms$$;
+ }
+
+ @Transient
+ public BitSet getTypeCode() {
+ throw new UnsupportedOperationException( "Shapes generated classes can't predict the type code at compile time" );
+ }
+
+ @Transient
+ public boolean isVirtual() {
+ return false;
+ }
+
+ @Transient
+ public String getTraitName() {
+ return getFullName();
+ }
}
View
2  ...apes/drools-shapes-xsd-processor/src/main/resources/org/drools/shapes/xsd/drl/xsd2owl.drl
@@ -44,7 +44,7 @@ end
function OWLDatatype mapXsdDatatype( QName qn, OWLDataFactory factory ) {
String px = qn.getNamespaceURI() + "#";
if ( px.equals( Namespaces.XSD.toString() ) ) {
- if ( "IDREF".equals( qn.getLocalPart() ) || "ID".equals( qn.getLocalPart() ) ) {
+ if ( "IDREF".equals( qn.getLocalPart() ) || "ID".equals( qn.getLocalPart() ) || "QName".equals( qn.getLocalPart() ) ) {
return OWL2DatatypeImpl.getDatatype( OWL2Datatype.getDatatype( IRI.create( px, "anyURI" ) ) );
} else if ( "anyType".equals( qn.getLocalPart() ) || "anySimpleType".equals( qn.getLocalPart() ) ) {
return factory.getTopDatatype();
Please sign in to comment.
Something went wrong with that request. Please try again.