edu.indiana.dde.mylead.common
Class MyLeadQueryChain

java.lang.Object
  extended byedu.indiana.dde.mylead.common.MyLeadQueryChain
All Implemented Interfaces:
ChainMember, MyLeadContextQuery

public class MyLeadQueryChain
extends java.lang.Object
implements ChainMember, MyLeadContextQuery

The purpose of this class is to build a chain of MyLeadQuery objects that would be included either above the query's target object or below the target object. Chains of objects above the target are referred to as "within" chains because the target is within these objects, while chains of objects below the target are referred to as "contains" chains because these chains consist of objects contained in the target. Chains can be combined into chain sets when there is more than one chain to consider.

If the user is building a query to find files contained within a collection that meets certain conditions, which in turn are contained within an experiment meeting certain conditions, then a single chain can describe the hierarchy of experiments and collections the target files should be within. If there are alternate experiment - collection chains the files may be contained within, then the chains would form a disjunctive (OR) chain set.

See Also:
ChainMember

Constructor Summary
MyLeadQueryChain()
          This default constructor sets the type of the chain to default to a "contains" chain which means that the chain is contained within the target.
MyLeadQueryChain(boolean isContainChain)
          This version of the constructor takes a boolean parameter which indicates whether the chain is a "contains" or "within" chain.
 
Method Summary
 void addChild(MyLeadQuery childQuery, boolean directChild)
          This method is passed an instance of MyLeadQuery which is added to the query as the next child in the query chain for a "contains" type query.
 void addParent(MyLeadQuery parentQuery, boolean directParent)
          This method is passed an instance of MyLeadQuery which is added to the query as the top parent in the query chain for a "within" type query.
 boolean isChainSet()
          This method is the only method in the ChainMember interface and is used to determine whether an object is a chain set or not - for this class it always returns false.
 java.lang.String wrapChain()
          This method wraps up the queries in this chain in a perform document fragment that will validate against the LeadChainType in the leadActivity.xsd schema that's used to validate myLEAD perform documents.
 java.lang.String wrapQuery()
          This method is called if this MyLeadQuery is the entire query portion of a myLEAD query and thus is the entire LeadQueryType in the leadActivity.xsd schema's leadQuery.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MyLeadQueryChain

public MyLeadQueryChain()
This default constructor sets the type of the chain to default to a "contains" chain which means that the chain is contained within the target.


MyLeadQueryChain

public MyLeadQueryChain(boolean isContainChain)
This version of the constructor takes a boolean parameter which indicates whether the chain is a "contains" or "within" chain. If the parameter is true, then the chain is treated as a "contains" chain which means the chain is contained within the target. If false, then the chain is a "within" chain which means the target is within the chain so the chain is higher in the hierarchy.

Parameters:
isContainChain - boolean value that indicates whether the chain is a "contains" type chain.
Method Detail

isChainSet

public boolean isChainSet()
This method is the only method in the ChainMember interface and is used to determine whether an object is a chain set or not - for this class it always returns false. When getting a member out of a chain set it's necessary to be able to determine if it is a single chain or a chain set.

Specified by:
isChainSet in interface ChainMember
Returns:
boolean flag that indicates this is a chain - always returns false for this class.

addChild

public void addChild(MyLeadQuery childQuery,
                     boolean directChild)
              throws org.globus.mcs.client.MCSException
This method is passed an instance of MyLeadQuery which is added to the query as the next child in the query chain for a "contains" type query. For example, a file query can be added as the child of a collection query.
If this method is called on a "within" query and it's the first query in the chain, then the type of the chain is switched to a "contains" type query. If there are already queries in the chain and this method is called on a "within" type query, then an exception is thrown and the query is not added.

Parameters:
childQuery - An instance of the MyLeadQuery class to be added as the next level down in the chain.
directChild - boolean flag as to whether this child query is directly contained within the next query up in the chain or can be an indirect child such as a file being an indirect child of a project that has levels in between containing collections or experiments.
Throws:
org.globus.mcs.client.MCSException - If any error occurs then this exception is thrown.
See Also:
MCSException

addParent

public void addParent(MyLeadQuery parentQuery,
                      boolean directParent)
               throws org.globus.mcs.client.MCSException
This method is passed an instance of MyLeadQuery which is added to the query as the top parent in the query chain for a "within" type query. For example, a project query can be added as the parent of a collection query.
If this method is called on a "contains" query and it's the first query in the chain, then the type of the chain is switched to a "within" type query. If there are already queries in the chain and this method is called on a "contains" type query, then an exception is thrown and the query is not added.

Parameters:
parentQuery - An instance of the MyLeadQuery class to be added as the next level up in the chain.
directParent - boolean flag as to whether this parent query is a direct parent of the next query down in the chain or can be an indirrect parent such as a project being an indirect parent of a file that has levels in between containing collections or experiments.
Throws:
org.globus.mcs.client.MCSException - If any error occurs then this exception is thrown.
See Also:
MCSException

wrapQuery

public java.lang.String wrapQuery()
This method is called if this MyLeadQuery is the entire query portion of a myLEAD query and thus is the entire LeadQueryType in the leadActivity.xsd schema's leadQuery. This is essentially the same as wrapping a chain in a call to the wrapChain method, but the result needs to be wrapped in <query> tags.

Specified by:
wrapQuery in interface MyLeadContextQuery
Returns:
String containing the XML fragment for the query.

wrapChain

public java.lang.String wrapChain()
This method wraps up the queries in this chain in a perform document fragment that will validate against the LeadChainType in the leadActivity.xsd schema that's used to validate myLEAD perform documents. If there are no queries in this chain, then the return value is a blank String.

Returns:
String with the XML fragment that forms a perform document for this query chain.