public class AttributeQualification extends SearchQualification
<, <=, >, >=, =, <>
. 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);
Modifier and Type | Field and Description |
---|---|
static int |
CONTAINS_WORD
Represents a ' '||translate(...)||' ' LIKE ...
|
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 |
DOES_NOT_CONTAIN_WORD
Represents a ' '||translate(...)||' ' NOT LIKE ...
|
static int |
ENDS_WITH
Represents a ENDS WITH operation.
|
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 |
IOC_CONTAINS_WORD
Deprecated.
9.2.5.0: use
CONTAINS_WORD |
static int |
IOC_LIKE
Deprecated.
9.2.5.0: use
LIKE_WITH_ESCAPE |
static int |
IOC_NOT_CONTAINS_WORD
Deprecated.
9.2.5.0: use
DOES_NOT_CONTAIN_WORD |
static int |
IOC_NOT_LIKE
Deprecated.
9.2.5.0: use
NOT_LIKE_WITH_ESCAPE |
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 |
LIKE_WITH_ESCAPE
Represents a LIKE ...
|
protected String |
m_Attribute
Represents the Name of the Attribute.
|
protected int |
m_AttributeDataType
Represents the Attribute's dataType.
|
protected String |
m_AttributeId
Stores the Attribute's objectid.
|
protected String |
m_AttributeMultiValueTableSuffix
Stores the Attribute's multi-value tbale name.
|
protected AttributeValue |
m_AVValue
Comparison Value as an AttributeValue.
|
protected String |
m_Class
Represents the Search Class.
|
protected int |
m_CompOper
Represents the type of comparison to be performed.
|
protected int |
m_DateCompLevel
Represents the date comparison level.
|
protected Date |
m_DateValue
Represents the Date value.
|
protected Character |
m_EscapeClause
The character to use as the escape clause.
|
protected boolean |
m_IgnoreCase
Represents case sensitiveness of the search.
|
protected static Hashtable |
m_Opers
Mapping from operator Strings to integer values.
|
protected static Hashtable |
m_ReverseOpers
Mapping from integer values to operator Strings.
|
protected String |
m_SQLValue
Represents the value converted to SQL.
|
protected String |
m_Value
Represents the comparison Value.
|
static int |
NOT_EQUAL
Represents an 'not_equal' comparison.
|
static int |
NOT_LIKE
Represents a NOT LIKE operation.
|
static int |
NOT_LIKE_WITH_ESCAPE
Represents a NOT LIKE ...
|
protected static String |
QUALIFIER_NAME
Name used in Exception strings.
|
static int |
STARTS_WITH
Represents a STARTS WITH operation.
|
LATE_BIND_OPER
Constructor and Description |
---|
AttributeQualification()
Constructs an AttributeQualification.
|
Modifier and Type | Method and Description |
---|---|
protected void |
accept(oracle.ifs.search.SearchQualificationVisitor v)
Accepts a SearchQualificationVisitor.
|
String |
getAttributeClassname()
Return the search class of this object.
|
String |
getAttributeName()
Return the attribute name of this object.
|
int |
getDateComparisonLevel()
Returns the date comparison level.
|
Character |
getEscapeClauseCharacter()
Returns the escape clause character to use for LIKE operations.
|
protected int |
getNotNullOperator() |
protected int |
getNullOperator() |
protected String |
getNullSearchValue() |
int |
getOperatorType()
Gets the operator type of this attribute qualification.
|
String |
getValue()
Returns the string representation of the comparison value.
|
boolean |
isCaseIgnored()
Returns true if this AttributeQualification is case insensitive.
|
protected boolean |
isLateBound()
Checks if Qualification is Late Bound.
|
static String |
operatorTypeName(int operator)
Gets the String corresponding to the integer operator.
|
void |
setAttribute(String attrName)
Sets the Attribute Name.
|
void |
setAttribute(String className,
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 |
setEscapeClauseCharacter(Character escape)
Sets the escape clause character to use for LIKE operations.
|
void |
setOperatorType(int oper)
Set the comparision operator.
|
void |
setOperatorType(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(String value)
Sets the comparison Value.
|
void |
setValueLateBound()
Sets the value to indicate that it will be specified
at search execution time.
|
protected static String |
toSQL(String table,
String attr,
int oper,
String value,
boolean ignoreCase)
Helper function used by SQLGenerator for generating the SQL of the Search.
|
protected String |
toSQL(String table,
String attr,
String value)
Helper function used by SQLGenerator for generating the SQL of the Search.
|
protected static void |
validateOperator(int oper)
Checks if operator is valid.
|
clone
protected static String QUALIFIER_NAME
protected String m_Attribute
protected int m_AttributeDataType
Attribute
protected String m_Class
protected String m_Value
protected String m_SQLValue
SearchValidator
protected Date m_DateValue
SearchValidator
protected int m_CompOper
protected int m_DateCompLevel
protected boolean m_IgnoreCase
protected Character m_EscapeClause
protected AttributeValue m_AVValue
AttributeValue
protected String m_AttributeMultiValueTableSuffix
protected String m_AttributeId
public static final int EQUAL
public static final int LESS_THAN
public static final int LESS_THAN_EQUAL
public static final int GREATER_THAN
public static final int GREATER_THAN_EQUAL
public static final int NOT_EQUAL
public static final int IS_NULL
public static final int IS_NOT_NULL
public static final int LIKE
public static final int NOT_LIKE
public static final int ENDS_WITH
public static final int STARTS_WITH
public static final int LIKE_WITH_ESCAPE
public static final int NOT_LIKE_WITH_ESCAPE
public static final int CONTAINS_WORD
public static final int DOES_NOT_CONTAIN_WORD
public static final int IOC_LIKE
LIKE_WITH_ESCAPE
public static final int IOC_NOT_LIKE
NOT_LIKE_WITH_ESCAPE
public static final int IOC_CONTAINS_WORD
CONTAINS_WORD
public static final int IOC_NOT_CONTAINS_WORD
DOES_NOT_CONTAIN_WORD
public static final int DATE_COMP_YEAR
public static final int DATE_COMP_MONTH
public static final int DATE_COMP_DAY
public static final int DATE_COMP_HOUR
public static final int DATE_COMP_MIN
public static final int DATE_COMP_SEC
protected static final Hashtable m_Opers
protected static final Hashtable m_ReverseOpers
public AttributeQualification()
public void setAttribute(String attrName)
attrName
- The attribute used for the condition.public void setAttribute(String className, String attrName)
className
- the class of the attributeattrName
- the attribute nameSearchSpecification
,
SearchClassSpecification
public String getAttributeClassname() throws IfsException
IfsException
- if the operation failspublic String getAttributeName()
public void setOperatorType(String oper) throws IfsException
oper
- comparison operatorIfsException
- if specified operator is not supportedpublic void setOperatorType(int oper) throws IfsException
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
IfsException
- if specified operator is not supported.public int getOperatorType() throws IfsException
IfsException
- if the operation failspublic static String operatorTypeName(int operator) throws IfsException
operator
- integer representing the 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
IfsException
- if the operation failspublic void setValue(String value)
value
- comparison valuepublic void setValue(AttributeValue av) throws IfsException
av
- the comparison value specified as an AttrbuteValueIfsException
setValue(AttributeValue, LibrarySession)
public void setValueLateBound() throws IfsException
IfsException
public void setValue(AttributeValue av, LibrarySession sess) throws IfsException
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.
av
- the comparison Value as an AttributeValuesess
- the LibrarySession to use for converting values to strings.IfsException
- 22002 if av is null
or IfsException 10400 if av is not of a supported type
or IfsException if any other failureAttributeValue
public String getValue()
public void setDateComparisonLevel(int df)
df
- date comparision level; see DATE_COMP_ constants.public void setCaseIgnored(boolean value) throws IfsException
value
- if true, the searches will be case insensitive.IfsException
- if the operation failspublic int getDateComparisonLevel()
public boolean isCaseIgnored() throws IfsException
IfsException
- if the operation failspublic void setEscapeClauseCharacter(Character escape) throws IfsException
A null value indicates that no escape clause will be emitted.
escape
- the escape clause character to emit for LIKE
operationsIfsException
- if the operation failspublic Character getEscapeClauseCharacter() throws IfsException
A null value indicates that no escape clause will be emitted.
IfsException
- if the operation failsprotected String toSQL(String table, String attr, String value)
table.attr 'oper' value
table
- table being searchedattr
- attribute being searchedvalue
- value being compared.SQLGenerator
protected String getNullSearchValue()
protected int getNullOperator()
protected int getNotNullOperator()
protected static String toSQL(String table, String attr, int oper, String value, boolean ignoreCase)
table
- table being searchedattr
- attribute being searchedoper
- comparison operatorvalue
- value being compared.ignoreCase
- If the data type is string, set this to true or false.SQLGenerator
protected static void validateOperator(int oper) throws IfsException
oper
- comparison operIfsException
- 22103 if operator is not valid.protected void accept(oracle.ifs.search.SearchQualificationVisitor v) throws IfsException
accept
in class SearchQualification
v
- SearchQualificationVisitorIfsException
- thrown if Visitor code throws.protected boolean isLateBound()
isLateBound
in class SearchQualification
Copyright © 2023. All rights reserved.