oracle.ifs.search
Class AttributeQualification


java.lang.Object

  |

  +--oracle.ifs.search.SearchQualification

        |

        +--oracle.ifs.search.AttributeQualification

All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class AttributeQualification
extends SearchQualification

An AttributeQualification encapsulates a condition on a Attribute. We support conditions on both single-valued & multi-valued attributes. Currently we only support the comparison operators <, <=, >, >=, =, <> . Additionally we support checks on null and the 'LIKE' operator only for Strings.

An AttributeQualification is specified by a AttributeName, Class, operator, and a Comparison Value. Additionally for date Attributes we support a Date Comparison Level, which allows users to specify how dates are compared. For e.g. sometimes it is useful to only compare the years or only the year and months etc.

Roughly, an AttributeQualification on a Single-Value Attribute translates to the SQL condition Class.Attr 'oper' value. While on a Multi_value Attribute it translates to, exists (select list of Class.Attr values where Attr.value 'oper' value)

Currently, for Multi-Value Attributes Clients can check whether a particular condition holds for the list of values. For e.g. if the client setups an AttributeQualifier for a MultiValue Attribute 'X' with the operator set to > and value 123;the ResultObjects of the search, will contain at least one 'X' value which is greater than 123. This covers the most common query about containment i.e. most often users want to check if a particular value is in the list of values. Hence for MV Attributes the Specified value is always treated as a Single-Value.

Below is an example of how to do a simple content search, using an AttributeQualification.


 // specify sort order
 String [] ctxClauseName = {"Test1"};     // order by SCORE
 // set DESCENDING sort order
 // order by SCORE DESCENDING, 'NAME' ASCENDING
 boolean [] sortOrders = {false, true};
 //
 SearchSortSpecification sortSpec =
   new SearchSortSpecification(
     new String[] {"DOCUMENT", "DOCUMENT"},
     new String[] {ContextQualification.ORDER_PREFIX + "." + ctxClauseName[0],
     "NAME"},
     sortOrders);
 //
 // get the 'PUBLIC' AccessControlList object
 Collection c = sess.getSystemAccessControlListCollection();
 AccessControlList acl = (AccessControlList) c.getItems("Public");
 //
 AttributeQualification aq1 = new AttributeQualification();
 aq1.setAttribute("ACL");
 aq1.setOperator(AttributeQualification.EQUAL);
 aq1.setValue(AttributeValue.newAttributeValue(acl));
 //
 AttributeQualification aq2 = new AttributeQualification();
 aq2.setAttribute("NAME");
 aq2.setOperatorType(AttributeQualification.LIKE);
 aq2.setValue("Hie%");
 //
 SearchClause sc = new SearchClause( aq1, aq2, SearchClause.AND );
 //
 // join with CONTENTOBJECT
 JoinQualification jq = new JoinQualification();
 jq.setLeftAttribute("DOCUMENT", "CONTENTOBJECT");
 jq.setRightAttribute("CONTENTOBJECT", null);
 //
 // add to the SearchClause
 sc = new SearchClause( sc, jq, SearchClause.AND );
 //
 // create a query expression using interMedia Text query syntax
 String searchWord1 = "hierarchy";
 String searchWord2 = "interfaces";
 String queryOperator = " & ";
 String queryExpr = searchWord1 + queryOperator + searchWord2;
 //
 // create a ContextQualification and specify the query expression
 ContextQualification cq = new ContextQualification();
 cq.setQuery(queryExpr);
 cq.setName(ctxClauseName[0]);
 //
 // add to the SearchClause
 sc = new SearchClause( sc, cq, SearchClause.AND );
 //
 ContextSearchSpecification cp = new ContextSearchSpecification();
 cp.setContextClassname("CONTENTOBJECT");
 cp.setSearchClassSpecification(new SearchClassSpecification(new String[]
                        {"DOCUMENT", "CONTENTOBJECT"}));
 cp.setSearchQualification(sc);
 cp.setSearchSortSpecification(sortSpec);
 //
 Search s = new Search(sess, cp);
 //
 s.open();
 ...
 s.close();

 

See Also:
Serialized Form

Field Summary
static int DATE_COMP_DAY
          Compare dates on the year, month and day.
static int DATE_COMP_HOUR
          Compare dates on the year, month, day and hour.
static int DATE_COMP_MIN
          Compare dates on the year, month, day, hour and minute.
static int DATE_COMP_MONTH
          Compare dates based on the year & month.
static int DATE_COMP_SEC
          Compare dates on the year, month, day, hour, minute and second.
static int DATE_COMP_YEAR
          Compare dates only based on the year.
static int EQUAL
          Represents an 'equality' comparison.
static int GREATER_THAN
          Represents an 'greater-than' comparison.
static int GREATER_THAN_EQUAL
          Represents an 'greater-than-equal' comparison.
static int IS_NOT_NULL
          Represents an 'is-not-null' comparison.
static int IS_NULL
          Represents an 'is-null' comparison.
static int LESS_THAN
          Represents an 'less-than' comparison.
static int LESS_THAN_EQUAL
          Represents an 'less-than-equal' comparison.
static int LIKE
          Represents an 'like' comparison.
static int NOT_EQUAL
          Represents an 'not_equal' comparison.
static int NOT_LIKE
          Represents a NOT LIKE operation.
 
Constructor Summary
AttributeQualification()
          Constructs an AttributeQualification.
 
Method Summary
 java.lang.String getAttributeClassname()
          Return the Search Class of this AttributeQualification.
 java.lang.String getAttributeName()
          Return the Attribute of this Qualification
 int getDateComparisonLevel()
          Returns the date comparison level.
 int getOperatorType()
          Gets the operator type of this attribute qualification.
 java.lang.String getValue()
          Returns the comparison value as a String.
 boolean isCaseIgnored()
          Returns true if this AttributeQualification is case insensitive.
 void setAttribute(java.lang.String attrName)
          Sets the Attribute Name.
 void setAttribute(java.lang.String className, java.lang.String attrName)
          Sets the Attribute Name & Class.
 void setCaseIgnored(boolean value)
          Sets up case sensitive behavior based on the parameter.
 void setDateComparisonLevel(int df)
          Sets the date comparison value.
 void setOperatorType(int oper)
          Set the comparision operator.
 void setOperatorType(java.lang.String oper)
          Sets the comparision operator.
 void setValue(AttributeValue av)
          Sets the comparison value.
 void setValue(AttributeValue av, LibrarySession sess)
          Sets the comparison Value.
 void setValue(java.lang.String value)
          Sets the comparison Value.
 
Methods inherited from class oracle.ifs.search.SearchQualification
clone
 

Field Detail


EQUAL


public static final int EQUAL
Represents an 'equality' comparison.

LESS_THAN


public static final int LESS_THAN
Represents an 'less-than' comparison.

LESS_THAN_EQUAL


public static final int LESS_THAN_EQUAL
Represents an 'less-than-equal' comparison.

GREATER_THAN


public static final int GREATER_THAN
Represents an 'greater-than' comparison.

GREATER_THAN_EQUAL


public static final int GREATER_THAN_EQUAL
Represents an 'greater-than-equal' comparison.

NOT_EQUAL


public static final int NOT_EQUAL
Represents an 'not_equal' comparison.

IS_NULL


public static final int IS_NULL
Represents an 'is-null' comparison.

IS_NOT_NULL


public static final int IS_NOT_NULL
Represents an 'is-not-null' comparison.

LIKE


public static final int LIKE
Represents an 'like' comparison. The '%' character has special meaning in the value. It represents 0 or more characters.

NOT_LIKE


public static final int NOT_LIKE
Represents a NOT LIKE operation.

DATE_COMP_YEAR


public static final int DATE_COMP_YEAR
Compare dates only based on the year.

DATE_COMP_MONTH


public static final int DATE_COMP_MONTH
Compare dates based on the year & month.

DATE_COMP_DAY


public static final int DATE_COMP_DAY
Compare dates on the year, month and day.

DATE_COMP_HOUR


public static final int DATE_COMP_HOUR
Compare dates on the year, month, day and hour.

DATE_COMP_MIN


public static final int DATE_COMP_MIN
Compare dates on the year, month, day, hour and minute.

DATE_COMP_SEC


public static final int DATE_COMP_SEC
Compare dates on the year, month, day, hour, minute and second. This is the default.
Constructor Detail

AttributeQualification


public AttributeQualification()
Constructs an AttributeQualification. Sets the Date Comparison Level to DATE_COMP_SEC.
Method Detail

setAttribute


public void setAttribute(java.lang.String attrName)
Sets the Attribute Name. Calls setAttribute(null, attrName).
Parameters:
attrName - The attribute used for the condition.
See Also:
setAttribute(String, String)

setAttribute


public void setAttribute(java.lang.String className,
                         java.lang.String attrName)
Sets the Attribute Name & Class. A null Class is taken to mean, use the first Result Class of the SearchSpecification. The className should be a valid iFS class, and attrName should be an attribute of the class.
Parameters:
className - The class of the attribute
attrName - The attribute used for the condition.
See Also:
SearchSpecification, SearchClassSpecification

getAttributeClassname


public java.lang.String getAttributeClassname()
                                       throws IfsException
Return the Search Class of this AttributeQualification.
Returns:
the Search Class.
Throws:
IfsException - if the operation fails

getAttributeName


public java.lang.String getAttributeName()
Return the Attribute of this Qualification
Returns:
the Attribute.

setOperatorType


public void setOperatorType(java.lang.String oper)
                     throws IfsException
Sets the comparision operator.
Parameters:
oper - comparison operator
Throws:
IfsException - if specified operator is not supported

setOperatorType


public void setOperatorType(int oper)
                     throws IfsException
Set the comparision operator.
Parameters:
oper - comaprison operator; must be one of AttributeQualification.EQUAL , AttributeQualification.GREATER_THAN , AttributeQualification.GREATER_THAN_EQUAL , AttributeQualification.IS_NOT_NULL , AttributeQualification.IS_NULL , AttributeQualification.LESS_THAN , AttributeQualification.LESS_THAN_EQUAL , AttributeQualification.LIKE
Throws:
IfsException - if specified operator is not supported.

getOperatorType


public int getOperatorType()
                    throws IfsException
Gets the operator type of this attribute qualification.
Returns:
the operator of the Qualification.
Throws:
IfsException - if the operation fails

setValue


public void setValue(java.lang.String value)
Sets the comparison Value. The preferred style is to use an AttributeValue. The value is parsed based on the type of the Attribute. For e.g. for Dates the value should be in the format of the Session's Locale. The value can be the SearchQualification.LATE_BIND_OPER.
Parameters:
value - comparison value

setValue


public void setValue(AttributeValue av)
              throws IfsException
Sets the comparison value. Calls setValue(av, null)
Parameters:
av - the comparison value specified as an AttrbuteValue
See Also:
setValue(AttributeValue, LibrarySession)

setValue


public void setValue(AttributeValue av,
                     LibrarySession sess)
              throws IfsException
Sets the comparison Value. The specified value must be a Single-Valued type, and it cannot be null. Converting a raw value to an AttributeValue is straightforward for e.g. AttributeValue.newAttributeValue("hello world")

At this point the value is converted to a String. For Dates if the session is null, an exception will be thrown, because a Locale is needed to convert dates to Strings.

Parameters:
av - the comparison Value as an AttributeValue
sess - the LibrarySession to use for converting values to strings.
Throws:
IfsException - 22002 if av is null
IfsException - 10400 if av is not of a supported type
IfsException - if string conversion fails.
See Also:
AttributeValue

getValue


public java.lang.String getValue()
Returns the comparison value as a String.
Returns:
the comparison value.

setDateComparisonLevel


public void setDateComparisonLevel(int df)
Sets the date comparison value. The default is DATE_COMP_SEC. If df is not valid, date comparison level is set to the default.
Parameters:
df - date comparison level. See DATE constants for a list of levels.

setCaseIgnored


public void setCaseIgnored(boolean value)
                    throws IfsException
Sets up case sensitive behavior based on the parameter. Default behavior is case sensitive.
Throws:
IfsException - if the operation fails

getDateComparisonLevel


public int getDateComparisonLevel()
Returns the date comparison level.
Returns:
date comparison level.

isCaseIgnored


public boolean isCaseIgnored()
                      throws IfsException
Returns true if this AttributeQualification is case insensitive.
Returns:
boolean true or false.
Throws:
IfsException - if the operation fails