diff --git a/sadl3/com.ge.research.sadl.parent/com.ge.research.jena/lib/reasoner-api.jar b/sadl3/com.ge.research.sadl.parent/com.ge.research.jena/lib/reasoner-api.jar index 002f4800c..32bf7465a 100644 Binary files a/sadl3/com.ge.research.sadl.parent/com.ge.research.jena/lib/reasoner-api.jar and b/sadl3/com.ge.research.sadl.parent/com.ge.research.jena/lib/reasoner-api.jar differ diff --git a/sadl3/com.ge.research.sadl.parent/com.ge.research.jena/lib/reasoner-impl.jar b/sadl3/com.ge.research.sadl.parent/com.ge.research.jena/lib/reasoner-impl.jar index 35bd7188b..1ccfa7a91 100644 Binary files a/sadl3/com.ge.research.sadl.parent/com.ge.research.jena/lib/reasoner-impl.jar and b/sadl3/com.ge.research.sadl.parent/com.ge.research.jena/lib/reasoner-impl.jar differ diff --git a/sadl3/com.ge.research.sadl.parent/com.ge.research.sadl.jena/src/com/ge/research/sadl/jena/JenaBasedSadlModelValidator.java b/sadl3/com.ge.research.sadl.parent/com.ge.research.sadl.jena/src/com/ge/research/sadl/jena/JenaBasedSadlModelValidator.java index 612ef21ae..cb8599249 100644 --- a/sadl3/com.ge.research.sadl.parent/com.ge.research.sadl.jena/src/com/ge/research/sadl/jena/JenaBasedSadlModelValidator.java +++ b/sadl3/com.ge.research.sadl.parent/com.ge.research.sadl.jena/src/com/ge/research/sadl/jena/JenaBasedSadlModelValidator.java @@ -5,7 +5,6 @@ import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -30,7 +29,6 @@ import com.ge.research.sadl.reasoner.InvalidNameException; import com.ge.research.sadl.reasoner.InvalidTypeException; import com.ge.research.sadl.reasoner.TranslationException; -import com.ge.research.sadl.reasoner.ModelError.ErrorType; import com.ge.research.sadl.reasoner.utils.SadlUtils; import com.ge.research.sadl.sADL.BinaryOperation; import com.ge.research.sadl.sADL.BooleanLiteral; @@ -73,7 +71,6 @@ import com.hp.hpl.jena.ontology.Restriction; import com.hp.hpl.jena.ontology.UnionClass; import com.hp.hpl.jena.rdf.model.Literal; -import com.hp.hpl.jena.rdf.model.NodeIterator; import com.hp.hpl.jena.rdf.model.Property; import com.hp.hpl.jena.rdf.model.RDFNode; import com.hp.hpl.jena.rdf.model.Resource; @@ -218,7 +215,36 @@ public void setTypeCheckType(ConceptIdentifier typeCheckType) { } public RangeValueType getRangeValueType() { - return rangeValueType; + if(this.getCompoundTypes() != null){ + return getCompoundRangeValueType(this); + }else{ + return rangeValueType; + } + } + + private RangeValueType getCompoundRangeValueType(TypeCheckInfo tci){ + List types = this.getCompoundTypes(); + Iterator iter = types.iterator(); + RangeValueType rvt = null; + while(iter.hasNext()){ + TypeCheckInfo type = iter.next(); + RangeValueType rvt2 = null; + if(type.getCompoundTypes() != null){ + rvt2 = getCompoundRangeValueType(type); + }else{ + rvt2 = type.getRangeValueType(); + } + + if(rvt != null){ + if(rvt != rvt2){ + issueAcceptor.addError("Incompatable Range Types", tci.context); //TODO add new error message + } + }else{ + rvt = rvt2; + } + } + + return rvt; } protected void setContext(JenaBasedSadlModelValidator validator, EObject ctx) { @@ -735,7 +761,7 @@ else if(expression instanceof NumberLiteral || expression instanceof Unit){ Literal litval; if (expression instanceof Unit) { value = ((Unit)expression).getValue().getValue(); - String unit = ((Unit)expression).getUnit(); + //String unit = ((Unit)expression).getUnit(); ConceptName uqcn = new ConceptName(SadlConstants.SADL_IMPLICIT_MODEL_UNITTEDQUANTITY_URI); List impliedProperties = getImpliedProperties(theJenaModel.getOntResource(uqcn.getUri())); if (impliedProperties != null) { @@ -790,11 +816,11 @@ else if(expression instanceof ElementInList){ issueAcceptor.addError("Unable to get the List type", el); } else if (listtype.getRangeValueType() != RangeValueType.LIST) { - issueAcceptor.addError("Expected a List", el); + issueAcceptor.addError("Expected a List", el); } else { // the element's type is the type of the list but not necessarily a list - listtype.setRangeValueType((listtype.getTypeCheckType() != null && listtype.getTypeCheckType() instanceof ConceptName) ? ((ConceptName)listtype.getTypeCheckType()).getRangeValueType() : RangeValueType.CLASS_OR_DT); + listtype = convertListTypeToElementOfListType(listtype); } return listtype; } @@ -869,6 +895,25 @@ else if (expression instanceof SadlUnionType) { return null; } + private TypeCheckInfo convertListTypeToElementOfListType(TypeCheckInfo listtype) { + listtype.setRangeValueType((listtype.getTypeCheckType() != null && listtype.getTypeCheckType() instanceof ConceptName) ? ((ConceptName)listtype.getTypeCheckType()).getRangeValueType() : RangeValueType.CLASS_OR_DT); + + if(listtype.getCompoundTypes() == null){ + //not compound + ConceptIdentifier tct = listtype.getTypeCheckType(); + if(tct instanceof ConceptName){ + ((ConceptName) tct).setRangeValueType(RangeValueType.CLASS_OR_DT); + } + }else{ + Iterator tci_iter = listtype.getCompoundTypes().iterator(); + while(tci_iter.hasNext()){ + convertListTypeToElementOfListType(tci_iter.next()); + } + } + + return listtype; + } + protected TypeCheckInfo getType(Constant expression) throws DontTypeCheckException { //What do we do about the rest of the constants? /*'--' | 'a'? 'type' ;*/ @@ -1020,7 +1065,7 @@ else if (subjtype != null && (cnstval.equals("first element") || cnstval.equals( else if (!predtype.equals(OntConceptType.CLASS_PROPERTY) && !predtype.equals(OntConceptType.DATATYPE_PROPERTY) && !predtype.equals(OntConceptType.RDF_PROPERTY) && !predtype.equals(OntConceptType.ANNOTATION_PROPERTY)) { issueAcceptor.addError(SadlErrorMessages.EXPECTED_A.get("property in property chain"), predicate); - String preduri = declarationExtensions.getConceptUri(((Name)predicate).getName()); + //String preduri = declarationExtensions.getConceptUri(((Name)predicate).getName()); } } catch (CircularDefinitionException e) { e.printStackTrace(); @@ -1080,7 +1125,7 @@ private void addEffectiveRange(TypeCheckInfo predicateType, Expression subject){ metricsProcessor.addEffectiveRangeAndDomain(null, className, propertyName, rangeStr, isList); } else { - int i = 0; // TODO + //int i = 0; } } } @@ -1389,7 +1434,7 @@ else if(conceptType.equals(OntConceptType.INSTANCE)){ } ConceptName instConceptName = new ConceptName(conceptUri); instConceptName.setType(ConceptType.INDIVIDUAL); -// TODO could belong to multiple classes + // TODO could belong to multiple classes ExtendedIterator typeitr = individual.listRDFTypes(true); TypeCheckInfo compoundTci = null; TypeCheckInfo tci = null; @@ -1694,21 +1739,21 @@ private List getImpliedProperties(Resource first) { return retlst; } - private boolean isRangeKlugyDATASubclass(OntResource rsrc) { - if (rsrc.getURI().endsWith("#DATA")) { - return true; - } - if (rsrc.canAs(OntClass.class)){ - ExtendedIterator itr = rsrc.as(OntClass.class).listSuperClasses(); - while (itr.hasNext()) { - OntClass spr = itr.next(); - if (spr.isURIResource() && spr.getURI().endsWith("#DATA")) { - return true; - } - } - } - return false; - } +// private boolean isRangeKlugyDATASubclass(OntResource rsrc) { +// if (rsrc.getURI().endsWith("#DATA")) { +// return true; +// } +// if (rsrc.canAs(OntClass.class)){ +// ExtendedIterator itr = rsrc.as(OntClass.class).listSuperClasses(); +// while (itr.hasNext()) { +// OntClass spr = itr.next(); +// if (spr.isURIResource() && spr.getURI().endsWith("#DATA")) { +// return true; +// } +// } +// } +// return false; +// } protected TypeCheckInfo getVariableType(ConceptType variable, String conceptNm, String conceptUri, EObject expression) throws DontTypeCheckException, CircularDefinitionException { //Needs filled in for Requirements extension