sparqlGraphLibrary/src/main/java/com/ge/research/semtk/belmont/runtimeConstraints/RuntimeConstraintManager.java
public void applyConstraintJson(JSONArray runtimeConstraints) throws Exception {
		// read out and apply the various RT constraints from the JSON. 
		// Throw an exception if anything seems amiss.
		
		// NOTE: we will be inferring the type of the operands by type of the constrained item.
		//       this is why we do not require the type in the incoming JSON. this might break one
		//       day if multiple primitive types become supported in ranges for properties.
		
		if(runtimeConstraints == null || runtimeConstraints.isEmpty()){
			return; // nothing to do
		}
		
		for(Object curr : runtimeConstraints){
			JSONObject constraintJson = (JSONObject) curr; 	// just a shortcut to avoid a multitude of casts.
			
			// check that the sparqlID exists skipped because it will be checked when a direct assignment is made.
			String sparqlId = getConstraintSparqlId(constraintJson);
			String operator = constraintJson.get(KEY_OPERATOR).toString();
			XSDSupportedType operandType;
			ArrayList<String> operands = new ArrayList<String>();   // however obvious, the operands will go here. 
			
			// get the object referenced by this sparql ID.
			if(this.rtcObjectHash.get(sparqlId) == null){
				throw new Exception("Cannot find runtime-constrainable item in nodegroup.  sparqlID: " + sparqlId);
			}
			if( this.rtcObjectHash.get(sparqlId).getObjectType().equals(SupportedTypes.NODE) ){
				// this was a node and the type should be URI.
				operandType = XSDSupportedType.NODE_URI;
			}			
			else if ( this.rtcObjectHash.get(sparqlId).getObjectType().equals(SupportedTypes.PROPERTYITEM) ){
				// check the property item itself to get the expected type.
				operandType = this.rtcObjectHash.get(sparqlId).getValueType();  // this should return the expected XSD type with no prefix. 
			}
			else{
				throw new Exception("Can't apply runtime constraints to object type " + this.rtcObjectHash.get(sparqlId).getObjectType() + " for sparqlID: " + sparqlId);
			}
			
			JSONArray opers = (JSONArray) constraintJson.get(KEY_OPERANDS);
			
			// step through the array and get the operands.
			try{
				for( Object currOpperand : opers){
					// add the next operand to the list if it passes the tests.
					// check the type are at least convertible. for this, we should reuse the code from the import spec handler.				
					ImportSpecHandler.validateDataType(currOpperand.toString(), operandType);
					operands.add( currOpperand.toString() );  // here we go. 
				}
			} catch(Exception eee){
				// we were passed a bad value that could not be cast to the suggested type.
				throw new Exception("Runtime constraint value for " + sparqlId + " type " + operandType + ": " + eee.getMessage());
			}
			
			SupportedOperations operationValue = null;
			
			// check the value of the operator for sanity
			try{
				operationValue = SupportedOperations.valueOf(operator);
					// do nothing. we just needed this check to make it all work
			}
			catch(Exception eee){
				throw new Exception("Runtime constraint operator " + operator + " for sparqlID " + sparqlId +  " is not supported");
			}
			
			// create the appropriate constraint and apply it.
			this.rtcObjectHash.get(sparqlId).applyConstraint(operationValue, operands);
			
		}
		
	}
/**
	 * Apply runtimeConstraints as value constraints to the nodegroup
	 * Typically used inside of SemTK during query execution
	 * @param runtimeConstraints
	 * @throws Exception
	 */
Apply runtimeConstraints as value constraints to the nodegroup
Typically used inside of SemTK during query execution
@param runtimeConstraints
@throws Exception
Apply runtimeConstraints as value constraints to the nodegroup Typically used inside of SemTK during query execution @param runtimeConstraints @throws Exception
public void applyConstraintJson(JSONArray runtimeConstraints) throws Exception {
		if(runtimeConstraints == null || runtimeConstraints.isEmpty()){
			return; 
		}
		for(Object curr : runtimeConstraints){
			JSONObject constraintJson = (JSONObject) curr; 	
			String sparqlId = getConstraintSparqlId(constraintJson);
			String operator = constraintJson.get(KEY_OPERATOR).toString();
			XSDSupportedType operandType;
			ArrayList<String> operands = new ArrayList<String>();   
			if(this.rtcObjectHash.get(sparqlId) == null){
				throw new Exception("Cannot find runtime-constrainable item in nodegroup.  sparqlID: " + sparqlId);
			}
			if( this.rtcObjectHash.get(sparqlId).getObjectType().equals(SupportedTypes.NODE) ){
				operandType = XSDSupportedType.NODE_URI;
			}			
			else if ( this.rtcObjectHash.get(sparqlId).getObjectType().equals(SupportedTypes.PROPERTYITEM) ){
				operandType = this.rtcObjectHash.get(sparqlId).getValueType();  
			}
			else{
				throw new Exception("Can't apply runtime constraints to object type " + this.rtcObjectHash.get(sparqlId).getObjectType() + " for sparqlID: " + sparqlId);
			}
			JSONArray opers = (JSONArray) constraintJson.get(KEY_OPERANDS);
			try{
				for( Object currOpperand : opers){
					ImportSpecHandler.validateDataType(currOpperand.toString(), operandType);
					operands.add( currOpperand.toString() );  
				}
			} catch(Exception eee){
				throw new Exception("Runtime constraint value for " + sparqlId + " type " + operandType + ": " + eee.getMessage());
			}
			SupportedOperations operationValue = null;
			try{
				operationValue = SupportedOperations.valueOf(operator);
			}
			catch(Exception eee){
				throw new Exception("Runtime constraint operator " + operator + " for sparqlID " + sparqlId +  " is not supported");
			}
			this.rtcObjectHash.get(sparqlId).applyConstraint(operationValue, operands);
		}
	}
public void applyConstraintJson ( JSONArray runtimeConstraints ) throws Exception { if ( runtimeConstraints == null || runtimeConstraints . isEmpty ( ) ) { return ; } for ( Object curr : runtimeConstraints ) { JSONObject constraintJson = ( JSONObject ) curr ; String sparqlId = getConstraintSparqlId ( constraintJson ) ; String operator = constraintJson . get ( KEY_OPERATOR ) . toString ( ) ; XSDSupportedType operandType ; ArrayList < String > operands = new ArrayList < String > ( ) ; if ( this . rtcObjectHash . get ( sparqlId ) == null ) { throw new Exception ( "Cannot find runtime-constrainable item in nodegroup.  sparqlID: " + sparqlId ) ; } if ( this . rtcObjectHash . get ( sparqlId ) . getObjectType ( ) . equals ( SupportedTypes . NODE ) ) { operandType = XSDSupportedType . NODE_URI ; } else if ( this . rtcObjectHash . get ( sparqlId ) . getObjectType ( ) . equals ( SupportedTypes . PROPERTYITEM ) ) { operandType = this . rtcObjectHash . get ( sparqlId ) . getValueType ( ) ; } else { throw new Exception ( "Can't apply runtime constraints to object type " + this . rtcObjectHash . get ( sparqlId ) . getObjectType ( ) + " for sparqlID: " + sparqlId ) ; } JSONArray opers = ( JSONArray ) constraintJson . get ( KEY_OPERANDS ) ; try { for ( Object currOpperand : opers ) { ImportSpecHandler . validateDataType ( currOpperand . toString ( ) , operandType ) ; operands . add ( currOpperand . toString ( ) ) ; } } catch ( Exception eee ) { throw new Exception ( "Runtime constraint value for " + sparqlId + " type " + operandType + ": " + eee . getMessage ( ) ) ; } SupportedOperations operationValue = null ; try { operationValue = SupportedOperations . valueOf ( operator ) ; } catch ( Exception eee ) { throw new Exception ( "Runtime constraint operator " + operator + " for sparqlID " + sparqlId + " is not supported" ) ; } this . rtcObjectHash . get ( sparqlId ) . applyConstraint ( operationValue , operands ) ; } }
Apply runtimeConstraints as value constraints to the nodegroup
 Typically used inside of SemTK during query execution
 @param runtimeConstraints
 @throws Exception
Apply runtimeConstraints as value constraints to the nodegroup Typically used inside of SemTK during query execution @param runtimeConstraints @throws Exception
// read out and apply the various RT constraints from the JSON.  // Throw an exception if anything seems amiss. // NOTE: we will be inferring the type of the operands by type of the constrained item. //       this is why we do not require the type in the incoming JSON. this might break one //       day if multiple primitive types become supported in ranges for properties. // nothing to do // just a shortcut to avoid a multitude of casts. // check that the sparqlID exists skipped because it will be checked when a direct assignment is made. // however obvious, the operands will go here.  // get the object referenced by this sparql ID. // this was a node and the type should be URI. // check the property item itself to get the expected type. // this should return the expected XSD type with no prefix.  // step through the array and get the operands. // add the next operand to the list if it passes the tests. // check the type are at least convertible. for this, we should reuse the code from the import spec handler.				 // here we go.  // we were passed a bad value that could not be cast to the suggested type. // check the value of the operator for sanity // do nothing. we just needed this check to make it all work // create the appropriate constraint and apply it.