sparqlGraphLibrary/src/main/java/com/ge/research/semtk/belmont/NodeGroup.java
public void unOptionalizeConstrained() throws Exception {
		// loop through each nodeItem
		// System.out.println("unOptionalizeConstrained");
		
		// first check that all property items in the nodegroup are NOT optional if they have constraints
		for (Node n : this.nodes) {
			for (PropertyItem pItem : n.getPropertyItems()) {
				if (pItem.getValueConstraint() != null) {
					pItem.setOptMinus(PropertyItem.OPT_MINUS_NONE);
				}
			}
		}
		
		for (NodeItem nItem : this.getAllNodeItems()) {
			Node owningNode = this.getNodeItemParentSNode(nItem);
			for (Node rangeNode : nItem.getNodeList()) {
				HashSet<Node> upstream = this.getUpstreamSubGraph(owningNode, nItem, rangeNode);
				HashSet<Node> downstream = this.getDownstreamSubGraph(owningNode, nItem, rangeNode);
				int upConstrainedReturns = 0;
				int downConstrainedReturns = 0;
			
				for (Node n : upstream) {
					upConstrainedReturns += n.countConstrainedReturns();
				}
				for (Node n : downstream) {
					downConstrainedReturns += n.countConstrainedReturns();
				}
				
				// if subgraph has Constrained returns, make sure it is not optional
				if (upConstrainedReturns != 0 &&  nItem.getOptionalMinus(rangeNode) == NodeItem.OPTIONAL_REVERSE) {
					LocalLogger.logToStdOut("unoptionalize " + owningNode.getSparqlID() + "->" + nItem.getKeyName() + "->" + rangeNode.getSparqlID());
					nItem.setOptionalMinus(rangeNode, NodeItem.OPTIONAL_FALSE);
				}
				// repeat in downstream direction
				if (downConstrainedReturns != 0 && nItem.getOptionalMinus(rangeNode) == NodeItem.OPTIONAL_TRUE) {
					LocalLogger.logToStdOut("unoptionalize " + owningNode.getSparqlID() + "->" + nItem.getKeyName() + "->" + rangeNode.getSparqlID());
					nItem.setOptionalMinus(rangeNode, NodeItem.OPTIONAL_FALSE);
				}
			}
		}
	}
/**
	 * Make sure that any subtrees contain no constrained but optional returns.
	 * Walk any optionals as far from the leaf nodes as possible
	 * without affecting any unconstrianed optionals.
	 * @throws Exception
	 */
Make sure that any subtrees contain no constrained but optional returns.
Walk any optionals as far from the leaf nodes as possible
without affecting any unconstrianed optionals.
@throws Exception
Make sure that any subtrees contain no constrained but optional returns . Walk any optionals as far from the leaf nodes as possible without affecting any unconstrianed optionals . @throws Exception
public void unOptionalizeConstrained() throws Exception {
		for (Node n : this.nodes) {
			for (PropertyItem pItem : n.getPropertyItems()) {
				if (pItem.getValueConstraint() != null) {
					pItem.setOptMinus(PropertyItem.OPT_MINUS_NONE);
				}
			}
		}
		for (NodeItem nItem : this.getAllNodeItems()) {
			Node owningNode = this.getNodeItemParentSNode(nItem);
			for (Node rangeNode : nItem.getNodeList()) {
				HashSet<Node> upstream = this.getUpstreamSubGraph(owningNode, nItem, rangeNode);
				HashSet<Node> downstream = this.getDownstreamSubGraph(owningNode, nItem, rangeNode);
				int upConstrainedReturns = 0;
				int downConstrainedReturns = 0;
				for (Node n : upstream) {
					upConstrainedReturns += n.countConstrainedReturns();
				}
				for (Node n : downstream) {
					downConstrainedReturns += n.countConstrainedReturns();
				}
				if (upConstrainedReturns != 0 &&  nItem.getOptionalMinus(rangeNode) == NodeItem.OPTIONAL_REVERSE) {
					LocalLogger.logToStdOut("unoptionalize " + owningNode.getSparqlID() + "->" + nItem.getKeyName() + "->" + rangeNode.getSparqlID());
					nItem.setOptionalMinus(rangeNode, NodeItem.OPTIONAL_FALSE);
				}
				if (downConstrainedReturns != 0 && nItem.getOptionalMinus(rangeNode) == NodeItem.OPTIONAL_TRUE) {
					LocalLogger.logToStdOut("unoptionalize " + owningNode.getSparqlID() + "->" + nItem.getKeyName() + "->" + rangeNode.getSparqlID());
					nItem.setOptionalMinus(rangeNode, NodeItem.OPTIONAL_FALSE);
				}
			}
		}
	}
public void unOptionalizeConstrained ( ) throws Exception { for ( Node n : this . nodes ) { for ( PropertyItem pItem : n . getPropertyItems ( ) ) { if ( pItem . getValueConstraint ( ) != null ) { pItem . setOptMinus ( PropertyItem . OPT_MINUS_NONE ) ; } } } for ( NodeItem nItem : this . getAllNodeItems ( ) ) { Node owningNode = this . getNodeItemParentSNode ( nItem ) ; for ( Node rangeNode : nItem . getNodeList ( ) ) { HashSet < Node > upstream = this . getUpstreamSubGraph ( owningNode , nItem , rangeNode ) ; HashSet < Node > downstream = this . getDownstreamSubGraph ( owningNode , nItem , rangeNode ) ; int upConstrainedReturns = 0 ; int downConstrainedReturns = 0 ; for ( Node n : upstream ) { upConstrainedReturns += n . countConstrainedReturns ( ) ; } for ( Node n : downstream ) { downConstrainedReturns += n . countConstrainedReturns ( ) ; } if ( upConstrainedReturns != 0 && nItem . getOptionalMinus ( rangeNode ) == NodeItem . OPTIONAL_REVERSE ) { LocalLogger . logToStdOut ( "unoptionalize " + owningNode . getSparqlID ( ) + "->" + nItem . getKeyName ( ) + "->" + rangeNode . getSparqlID ( ) ) ; nItem . setOptionalMinus ( rangeNode , NodeItem . OPTIONAL_FALSE ) ; } if ( downConstrainedReturns != 0 && nItem . getOptionalMinus ( rangeNode ) == NodeItem . OPTIONAL_TRUE ) { LocalLogger . logToStdOut ( "unoptionalize " + owningNode . getSparqlID ( ) + "->" + nItem . getKeyName ( ) + "->" + rangeNode . getSparqlID ( ) ) ; nItem . setOptionalMinus ( rangeNode , NodeItem . OPTIONAL_FALSE ) ; } } } }
Make sure that any subtrees contain no constrained but optional returns.
Make sure that any subtrees contain no constrained but optional returns .
// loop through each nodeItem // System.out.println("unOptionalizeConstrained"); // first check that all property items in the nodegroup are NOT optional if they have constraints // if subgraph has Constrained returns, make sure it is not optional // repeat in downstream direction