Hi List,

 I am wondering if anyone has encountered this before or not.

I was going through Javadoc of CMDB API and came across the class 
"CMDBQueryQualifier" which is one of the crucial classes involved in getting 
Graph API to work.

CMDBQueryItem(CMDBClassNameKey classNameKey,
              java.lang.String id,
              CMDBQueryQualifier constraint,
              java.util.ArrayList<java.lang.String> contentSelector)



Now, 
Direct Known Subclasses of CMDBQueryQualifier are
CMDBQueryQualifierAndOr, CMDBQueryQualifierOpNot, CMDBQueryQualifierSetOp, 
CMDBQueryQualifierSimpleOp
and CMDBQueryQualifierAndOr has the followingDirect Known Subclasses: 
CMDBQueryQualifierOpAnd, CMDBQueryQualifierOpOr
CMDBQueryQualifierOpAnd needs a right and left operand to work.
CMDBQueryQualifierOpAnd(CMDBQueryQualifier leftOp,
                        CMDBQueryQualifier rightOp)



          Constructs a CMDBQueryQualifierOpAnd object using the left
 and right operands.This is extremely tedious because for a simple query(like 
below) involving 2 operands, I have to do this

e.g 'ABC'=5 AND 'PQR'=0
 CMDBQueryQualifierSimpleOp cf1 = new 
CMDBQueryQualifierSimpleOp(CMDBQueryQualifierSimpleOp.CMDB_QUERY_QUAL_OP_EQUAL, 
"ABC", new CMDBQueryQualifierValueTypeValue(new Value(5)));
        CMDBQueryQualifierSimpleOp cf2 = new 
CMDBQueryQualifierSimpleOp(CMDBQueryQualifierSimpleOp.CMDB_QUERY_QUAL_OP_EQUAL, 
"DEF", new CMDBQueryQualifierValueTypeValue(new Value(0)));
         CMDBQueryQualifierOpAnd cf3 = new CMDBQueryQualifierOpAnd(cf1, cf2);


        CMDBQueryItem queryItem2 = new CMDBQueryItem(destination, 
destinationClassId, cf3, resultSetAttributes);
What if  key/value pairs in qualification increases? How do we deal with not 
going through pain of creating new objects every time qualification is changed? 
e.g. ('ABC'=5 AND 'PQR'=0) AND ( 'JKL'=8 AND 'RST'=10)
Now, I need to create 4 more objects:1. simple query for JKL that does (JKL=8)
2. simple query for RST that does (RST=10)
3. QueryQualifier AND for representing left and right side (JKL=8 AND RST=10)4. 
To represent AND operation between  #3 and (ABC=5 AND PQR=0)( variable cf3 in 
code above)


Am I missing anything or not looking at correct place, because I cant find my 
way out of using CMDBQueryQualifier constraint. It would have been much easier 
if API would just accept a String as the constraint or maybe something like 
below:
Constructor:
CMDBQueryQualifierOpAnd(ArrayList<CMDBQueryQualifierSimpleOp>)

The implementation of this constructor should automatically add AND between 
each SimpleOp object.

Actually, core QualifierInfo object would have made the job much easier.
  QualifierInfo qualByQuery = context.parseQualification(..);

Thoughts? How can we overcome this tedious behavior? 

I spent good amount of time looking at this, but hey, if anything is obvious 
and I missed it, please pardon me.


ThanksChintan.


_______________________________________________________________________________
UNSUBSCRIBE or access ARSlist Archives at www.arslist.org
"Where the Answers Are, and have been for 20 years"

Reply via email to