Oracle Content Management SDK

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. Most Attribute names have java constants in the java classes corresponding to the class object they belong to. ID and CLASSID attributes are an exception to that rule. Use those strings directly as attribute names, to search based on ID and CLASSID.

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 Multi Value Attributes the Specified search value is always treated as a Single-Value.

 
 // 
 // Usage examples
 //
 // Simple String attribute, case ignored
 // Name = 'Foo' condition
 //
 AttributeQualification aq1 = new AttributeQualification();
 aq1.setAttribute(PublicObject.NAME_ATTRIBUTE);
 aq1.setOperatorType(AttributeQualification.EQUAL);
 aq1.setValue("Foo");
 aq1.setCaseIgnored(true);
 //
 // String attribute, late bound
 // Name = ? condition. 
 //
 AttributeQualification aq1 = new AttributeQualification();
 aq1.setAttribute(PublicObject.NAME_ATTRIBUTE);
 aq1.setOperatorType(AttributeQualification.EQUAL);
 aq1.setValue(SearchQualification.LATE_BIND_OPER);
 //
 // Date attribute
 // CreateDate < today condition
 //
 AttributeQualification aq1 = new AttributeQualification();
 aq1.setAttribute(PublicObject.CREATEDATE_ATTRIBUTE);
 aq1.setOperatorType(AttributeQualification.LESS_THAN);
 Date today = new Date();
 AttribuetValue av = AttributeValue.newAttributeValue(today);
 aq1.setValue(av, session);    // session required for Date attribute
 aq1.setDateComparisionLevel(AttributeQualification.DATE_COMP_DAY);
 //
 // Object type Attribute, Eg. ACL
 // Condition - ACL = Public
 //
 AttributeQualification aq1 = new AttributeQualification();
 aq1.setAttribute(PublicObject.ACL_ATTRIBUTE);
 aq1.setOperatorType(AttributeQualification.EQUAL);
 AccessControlList publicAcl; // Let's assume this represents PUBLIC acl
 AttribuetValue av = AttributeValue.newAttributeValue(publicAcl);
 aq1.setValue(av);

 

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.
 
Fields inherited from class oracle.ifs.search.SearchQualification
LATE_BIND_OPER
 
Constructor Summary
AttributeQualification()
          Constructs an AttributeQualification.
 
Method Summary
 java.lang.String getAttributeClassname()
          Return the search class of this object.
 java.lang.String getAttributeName()
          Return the attribute name of this object.
 int getDateComparisonLevel()
          Returns the date comparison level.
 int getOperatorType()
          Gets the operator type of this attribute qualification.
 java.lang.String getValue()
          Returns the string representation of the comparison value.
 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 class name and attribute name for this AttributeQualification.
 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. Default date comparison level is setto DATE_COMP_SEC.
Method Detail

setAttribute

public void setAttribute(java.lang.String attrName)
Sets the Attribute Name. Uses the first Result class from search specification as the class name.
Parameters:
attrName - The attribute used for the condition.

setAttribute

public void setAttribute(java.lang.String className,
                         java.lang.String attrName)
Sets the class name and attribute name for this AttributeQualification. If the className is null, then it's default value is, name of the the first Result class. className should be name of valid iFS class. attrName should be the name of a valid attribute of that class.
Parameters:
className - the class of the attribute
attrName - the attribute name
See Also:
SearchSpecification, SearchClassSpecification

getAttributeClassname

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

getAttributeName

public java.lang.String getAttributeName()
Return the attribute name of this object.
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 the other variant which uses AttributeValue as parameter type. If value is SearchQualification.LATE_BIND_OPER, then the qualification is late bound and values will have to be supplied at search execution time.
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 scalar type, and it cannot be null.

Supplied attribute value is used to generate a appropriate query at search execution time. 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 any other failure
See Also:
AttributeValue

getValue

public java.lang.String getValue()
Returns the string representation of the comparison value.
Returns:
the comparison value.

setDateComparisonLevel

public void setDateComparisonLevel(int df)
Sets the date comparison value. The default is DATE_COMP_SEC.
Parameters:
df - date comparision level; see DATE_COMP_ constants.

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

Oracle Content Management SDK

(c) 2002 Copyright Oracle Corporation. All rights reserved.