edu.indiana.dde.mylead.common
Class MyLeadChainSet

java.lang.Object
  extended by edu.indiana.dde.mylead.common.MyLeadChainSet
All Implemented Interfaces:
ChainMember

public class MyLeadChainSet
extends java.lang.Object
implements ChainMember

This class is used to contain a number of chains and/or chain sets as a chain set. The chain and chain set members can be either a disjunctive set or a conjunctive set, but any chain sets contained within this chain set must be of the other type or the sets will be merged when the chain set is added.

For example, if this is a conjunctive chain set containing a number of chains, then all of the chains must hold true in a myLEAD query for this chain set to be true. If a chain set added to this set is also conjunctive, then since the sets are of the same type, the individual members of that set would be added to this set instead of just adding that set as a member of this set. On the other hand, if the set being added was a disjuctive chain set, then it would be the opposite type from this set and thus would be added directly as a member.

See Also:
ChainMember

Field Summary
static int TAGS_ALL
           
static int TAGS_AND_OMIT
           
static int TAGS_OMIT
           
static int TAGS_OR_OMIT
           
 
Constructor Summary
MyLeadChainSet(boolean isConjuctive)
          The constructor takes one parameter which is a flag to indicate if the chain set should be a conjuctive set (AND) of all the chains and/or chain sets contained within this chain set.
 
Method Summary
 void add(ChainMember member)
          This method adds a ChainMember to this chain set.
 int chainCount()
          This method returns the number of chains and/or chain sets included in this chain set.
 ChainMember getMember(int member)
          This method can be used to get a chain or chain set that is a member of this chain set.
 boolean isChainSet()
          Implementation of the only method in the ChainMember interface - always returns true for this class.
 boolean isConjunctive()
          This method returns a boolean flag to indicate whether this chain set is a conjunctive AND chain set.
 java.lang.String wrapChainSet(int tagOption)
          This method wraps up the queries of this chain set in a perform document fragment that will validate against the leadActivity.xsd schema that's used to validate myLEAD perform documents and the fragment will be wrapped in mlOrSet or mlAndSet tags - unless the chain set is an empty set in which case this method will return an empty String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAGS_ALL

public static final int TAGS_ALL
See Also:
Constant Field Values

TAGS_OR_OMIT

public static final int TAGS_OR_OMIT
See Also:
Constant Field Values

TAGS_AND_OMIT

public static final int TAGS_AND_OMIT
See Also:
Constant Field Values

TAGS_OMIT

public static final int TAGS_OMIT
See Also:
Constant Field Values
Constructor Detail

MyLeadChainSet

public MyLeadChainSet(boolean isConjuctive)
The constructor takes one parameter which is a flag to indicate if the chain set should be a conjuctive set (AND) of all the chains and/or chain sets contained within this chain set.

Parameters:
isConjuctive - boolean flag as to whether this is an AND or an OR chainset. If true, then an AND chain set.
Method Detail

chainCount

public int chainCount()
This method returns the number of chains and/or chain sets included in this chain set.

Returns:
integer count of the number of members in this chain set.

getMember

public ChainMember getMember(int member)
This method can be used to get a chain or chain set that is a member of this chain set.

Parameters:
member - integer with position of the member to return. must be in the range from zero to the chainCount-1.
Returns:
The ChainMember at the position specified if the position is valid - otherwise null.

isChainSet

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

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

isConjunctive

public boolean isConjunctive()
This method returns a boolean flag to indicate whether this chain set is a conjunctive AND chain set.

Returns:
boolean flag - conjunctive chain set if true.

add

public void add(ChainMember member)
This method adds a ChainMember to this chain set. The member could be either a chain or chain set. If the member is a chain set, we check if the conjunctive/disjunctive setting for the member is the same as the current chain set. If the conjunctive setting is the same for this chain set and the one being added, then we merge the chain sets together, otherwise it is added as a member of this set. If the member parameter is a chain, then it is just added as a member of this set.

Parameters:
member - The instance of ChainMember to be added to the chain set.

wrapChainSet

public java.lang.String wrapChainSet(int tagOption)
This method wraps up the queries of this chain set in a perform document fragment that will validate against the leadActivity.xsd schema that's used to validate myLEAD perform documents and the fragment will be wrapped in mlOrSet or mlAndSet tags - unless the chain set is an empty set in which case this method will return an empty String. If the set is at the top level of a query plan, then we need to omit the tags if:
(1) This chain set is an OR set,
(2) There are multiple query plans, and
(3) This chain set is at the top level of the query plan.
In the case where (1) is true, mlOrSet tags will be omitted if the tagOption setting is TAGS_OR_OMIT.
If the set is at the top level of the query plan as the contains chain set and there are also within chains, then the query plan will wrap itself in mlAndSet tags and this method then needs to omit the mlAndSet tags if the tagOption setting is TAGS_AND_OMIT.
Any chains within the chain set must be contains chains and not within chains since chain sets in the API are only used below the target. chains above the target are always disjunctive so they are neve in a set in this API.

Parameters:
tagOption - integer based on constants from this class that indicate when XML tags should be omitted.
Returns:
String with the XML fragment that forms a perform document for this query chain set.