com.wewebu.ow.server.field
Class OwSearchCriteria

java.lang.Object
  extended by com.wewebu.ow.server.field.OwSearchCriteria
All Implemented Interfaces:
OwField, OwFieldDefinition, OwFormat
Direct Known Subclasses:
OwSearchCriteriaFieldDefOverride, OwStandardDecoratorSearchCriteria

public class OwSearchCriteria
extends Object
implements OwField, OwFieldDefinition, OwFormat

Search criteria tuple containing property, operator and value. Used to create SQL Statement or a search form entry.
Search are used with OwNetwork.doSearch(...) function.

To be implemented with the specific DMS system.

Alfresco Workdesk
Copyright (c) Alfresco Software, Inc.
All rights reserved.

For licensing information read the license.txt file or
go to: http://wiki.alfresco.com


Field Summary
static int ATTRIBUTE_ALLOWWILDCARD
          attribute bit flag used with m_iAttributes member: Allow the use of wildcards also for integer values, i.e.
static int ATTRIBUTE_HIDDEN
          attribute bit flag used with m_iAttributes member: A value that is hidden.
static int ATTRIBUTE_IGNORE_DATE
          attribute bit flag used with m_iAttributes member: Ignore the date part of a date value.
static int ATTRIBUTE_IGNORE_TIME
          attribute bit flag used with m_iAttributes member: Ignore the time part of a date value.
static int ATTRIBUTE_NONE
          attribute bit flag used with m_iAttributes member: No attributes.
static int ATTRIBUTE_READONLY
          attribute bit flag used with m_iAttributes member: A value that can not be changed
static int ATTRIBUTE_REQUIRED
          attribute bit flag used with m_iAttributes member: A required value that must be filled in.
protected  OwFieldDefinition m_FieldDefinition
          field definition defining this search criteria
protected  int m_iAttributes
          flag indicating if the criteria can be edited in a search template view or if it is hidden
protected  int m_iOp
          criteria operator which should be applied to the value as defined in OwSearchCriteria
protected  Object m_oDefaultValue
          the default value
protected  Object m_oValue
          compare value for the search
protected  OwSearchCriteria m_secondrangecriteria
          optional second child criteria for range searches
protected  String m_strInstruction
          the instruction to the search criteria
protected  String m_strUniqueName
          a unique name that identifies this criteria
protected  Collection m_wildcarddefinitions
          Collection of OwWildCardDefinition wildcard definition for this criteria, or null if no wildcards are allowed
 
Constructor Summary
OwSearchCriteria()
           
 
Method Summary
 boolean canValidate()
          check if validation is implemented
 boolean canWildCard()
          check if criteria allows the use of wildcards
 int getAttributes()
          get the flag indicating if the criteria can be edited in a search template view or if it is hidden
 String getClassName()
          get the name of the class
 List getComplexChildClasses()
          get child properties classes of a complex property class
 Object getDefaultValue()
          get the default search value
 String getDescription(Locale locale_p)
          get the description defined by the DMS System
 String getDisplayName(Locale locale_p)
          get the displayable name of the type as defined by the DMS System can be identical to getClassName
 OwEnumCollection getEnums()
          get a list of enum objects for the enum type (see isEnum)
 OwFieldDefinition getFieldDefinition()
          get the corresponding field definition of the field
 OwFormat getFormat()
          get the formatter object for string representation
 String getInstruction()
          get the instruction to the search criteria
 String getJavaClassName()
          get the java class name of java object associated with this property
 Object getMaxValue()
          get the max allowed value, or Integer len for String or null if not defined
 Object getMinValue()
          get the min allowed value, or Integer len for String or null if not defined
 Object getNativeType()
          get the native type which is defined by the underlying system WARNING: The returned object is opaque.
 Node getNodeFromValue(Object value_p, Document doc_p)
          create a XML serialization of the given field value
 int getOperator()
          get the criteria operator which should be applied to the value as defined in OwSearchCriteria
 String getOperatorDisplayName(Locale locale_p)
          convert a operator ID to a displayable name
 Collection getOperators()
          get a collection of possible filter / search operators for the field
 String getOriginalJavaClassName()
          get the original class name, in case data type was overridden by allow wildcard
 OwSearchCriteria getSecondRangeCriteria()
          get a optional second child criteria for range searches
 Format getTextFormat(int iFieldProviderType_p)
          get the optional formatter object for string representation, according to the given context type
 String getUniqueName()
          get a unique name that identifies this criteria
 Object getValue()
          get the compare value for the search
 Object getValueFromNode(Node node_p)
          create a value for the field described by this class with the given XML Node serialization
 Object getValueFromString(String text_p)
          create a value for the field described by this class with the given String serialization
 Collection getWildCardDefinitions()
          get the wildcard definitions for this criteria
 boolean ignoreDate()
          check if the format should ignore date part of date values
 boolean ignoreTime()
          check if the format should ignore time part of date values
 boolean isAllowWildcard()
          check if the criteria allows wildcard even if underlying type is number
 boolean isArray()
          check if property contains a list of values
 boolean isComplex()
          check if the property is a component that contains another child properties
 boolean isCriteriaOperatorRange()
          check if criteria has a second range criteria fo ranges
 boolean isDateType()
          check if criteria is a date criteria
 boolean isEnum()
          check if property is a enum type (see getEnums)
 boolean isHidden()
          check if the criteria can be edited in a search template view or if it is hidden
 boolean isIgnoreDate()
          check if the criteria ignores the date part
 boolean isIgnoreTime()
          check if the criteria ignores the time part
 boolean isReadonly()
          check if the criteria is visible but read-only
 boolean isRequired()
          check if the criteria must be set
 boolean isType(Class base_p)
          check if given java class name is base type
 void setInitialAndDefaultValue(Object oValue_p)
          set the initial/default value for the search
 void setOperator(int iOp_p)
          set the criteria operator which should be applied to the value as defined in OwSearchCriteria
 void setValue(Object oValue_p)
          set the compare value for the search
 void setWildCardDefinitions(Collection wildcarddefinitions_p)
          set the wildcard definitions for this criteria
 String toString()
           
 String validate(int fieldProviderType_p, Object object_p, Locale locale_p)
          validate the given value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ATTRIBUTE_NONE

public static final int ATTRIBUTE_NONE
attribute bit flag used with m_iAttributes member: No attributes.

See Also:
Constant Field Values

ATTRIBUTE_HIDDEN

public static final int ATTRIBUTE_HIDDEN
attribute bit flag used with m_iAttributes member: A value that is hidden.

See Also:
Constant Field Values

ATTRIBUTE_READONLY

public static final int ATTRIBUTE_READONLY
attribute bit flag used with m_iAttributes member: A value that can not be changed

See Also:
Constant Field Values

ATTRIBUTE_REQUIRED

public static final int ATTRIBUTE_REQUIRED
attribute bit flag used with m_iAttributes member: A required value that must be filled in.

See Also:
Constant Field Values

ATTRIBUTE_ALLOWWILDCARD

public static final int ATTRIBUTE_ALLOWWILDCARD
attribute bit flag used with m_iAttributes member: Allow the use of wildcards also for integer values, i.e. treat integers as string.

See Also:
Constant Field Values

ATTRIBUTE_IGNORE_TIME

public static final int ATTRIBUTE_IGNORE_TIME
attribute bit flag used with m_iAttributes member: Ignore the time part of a date value.

See Also:
Constant Field Values

ATTRIBUTE_IGNORE_DATE

public static final int ATTRIBUTE_IGNORE_DATE
attribute bit flag used with m_iAttributes member: Ignore the date part of a date value.

See Also:
Constant Field Values

m_FieldDefinition

protected OwFieldDefinition m_FieldDefinition
field definition defining this search criteria


m_iOp

protected int m_iOp
criteria operator which should be applied to the value as defined in OwSearchCriteria


m_oValue

protected Object m_oValue
compare value for the search


m_oDefaultValue

protected Object m_oDefaultValue
the default value


m_secondrangecriteria

protected OwSearchCriteria m_secondrangecriteria
optional second child criteria for range searches


m_iAttributes

protected int m_iAttributes
flag indicating if the criteria can be edited in a search template view or if it is hidden


m_strInstruction

protected String m_strInstruction
the instruction to the search criteria


m_wildcarddefinitions

protected Collection m_wildcarddefinitions
Collection of OwWildCardDefinition wildcard definition for this criteria, or null if no wildcards are allowed


m_strUniqueName

protected String m_strUniqueName
a unique name that identifies this criteria

Constructor Detail

OwSearchCriteria

public OwSearchCriteria()
Method Detail

getWildCardDefinitions

public Collection getWildCardDefinitions()
get the wildcard definitions for this criteria

Returns:
Collection of OwWildCardDefinition, or null if no wildcards are allowed

setWildCardDefinitions

public void setWildCardDefinitions(Collection wildcarddefinitions_p)
set the wildcard definitions for this criteria

Parameters:
wildcarddefinitions_p - Collection of OwWildCardDefinition, or null if no wildcards are allowed

getInstruction

public String getInstruction()
get the instruction to the search criteria


getOperator

public int getOperator()
get the criteria operator which should be applied to the value as defined in OwSearchCriteria


setOperator

public void setOperator(int iOp_p)
set the criteria operator which should be applied to the value as defined in OwSearchCriteria


getOperatorDisplayName

public String getOperatorDisplayName(Locale locale_p)
convert a operator ID to a displayable name

Parameters:
locale_p -
Returns:
display name for given operator

getSecondRangeCriteria

public OwSearchCriteria getSecondRangeCriteria()
get a optional second child criteria for range searches


isCriteriaOperatorRange

public boolean isCriteriaOperatorRange()
check if criteria has a second range criteria fo ranges

Returns:
boolean

getAttributes

public int getAttributes()
get the flag indicating if the criteria can be edited in a search template view or if it is hidden


isHidden

public boolean isHidden()
check if the criteria can be edited in a search template view or if it is hidden


isReadonly

public boolean isReadonly()
check if the criteria is visible but read-only


isRequired

public boolean isRequired()
check if the criteria must be set

Specified by:
isRequired in interface OwFieldDefinition
Returns:
true if property is required

isIgnoreTime

public boolean isIgnoreTime()
check if the criteria ignores the time part


isIgnoreDate

public boolean isIgnoreDate()
check if the criteria ignores the date part


isAllowWildcard

public boolean isAllowWildcard()
check if the criteria allows wildcard even if underlying type is number


canWildCard

public boolean canWildCard()
check if criteria allows the use of wildcards


getValue

public Object getValue()
get the compare value for the search

Specified by:
getValue in interface OwField
Returns:
Object value of field if field is scalar, or a java.io.List of objects if field is an array

setValue

public void setValue(Object oValue_p)
set the compare value for the search

Specified by:
setValue in interface OwField
Parameters:
oValue_p - value of field if field is scalar, or a java.io.List of objects if field is an array

setInitialAndDefaultValue

public void setInitialAndDefaultValue(Object oValue_p)
set the initial/default value for the search

Parameters:
oValue_p -

getFieldDefinition

public OwFieldDefinition getFieldDefinition()
                                     throws Exception
get the corresponding field definition of the field

Specified by:
getFieldDefinition in interface OwField
Returns:
OwFieldDefinition
Throws:
Exception

getUniqueName

public String getUniqueName()
get a unique name that identifies this criteria

Returns:
String unique name for the criteria

getClassName

public String getClassName()
Description copied from interface: OwFieldDefinition
get the name of the class

Specified by:
getClassName in interface OwFieldDefinition
Returns:
class name

getDefaultValue

public Object getDefaultValue()
                       throws Exception
get the default search value

Specified by:
getDefaultValue in interface OwFieldDefinition
Returns:
Object for single criteria, or Object[2] for range criteria
Throws:
Exception

getDisplayName

public String getDisplayName(Locale locale_p)
Description copied from interface: OwFieldDefinition
get the displayable name of the type as defined by the DMS System can be identical to getClassName

Specified by:
getDisplayName in interface OwFieldDefinition
Parameters:
locale_p - Locale to use
Returns:
type displayable name of property

getFormat

public OwFormat getFormat()
get the formatter object for string representation

Specified by:
getFormat in interface OwFieldDefinition
Returns:
Format, can be null to use the default format

getEnums

public OwEnumCollection getEnums()
                          throws Exception
Description copied from interface: OwFieldDefinition
get a list of enum objects for the enum type (see isEnum)

Specified by:
getEnums in interface OwFieldDefinition
Returns:
OwEnumCollection of OwEnum objects, which can be used in a select box.
Throws:
Exception

getJavaClassName

public String getJavaClassName()
Description copied from interface: OwFieldDefinition
get the java class name of java object associated with this property

Specified by:
getJavaClassName in interface OwFieldDefinition
Returns:
java class name

getOriginalJavaClassName

public String getOriginalJavaClassName()
get the original class name, in case data type was overridden by allow wildcard

Returns:
a String

getMaxValue

public Object getMaxValue()
                   throws Exception
Description copied from interface: OwFieldDefinition
get the max allowed value, or Integer len for String or null if not defined

Specified by:
getMaxValue in interface OwFieldDefinition
Throws:
Exception

getMinValue

public Object getMinValue()
                   throws Exception
Description copied from interface: OwFieldDefinition
get the min allowed value, or Integer len for String or null if not defined

Specified by:
getMinValue in interface OwFieldDefinition
Throws:
Exception

getNativeType

public Object getNativeType()
                     throws Exception
Description copied from interface: OwFieldDefinition
get the native type which is defined by the underlying system WARNING: The returned object is opaque. Using this object makes the client dependent on the underlying system

Specified by:
getNativeType in interface OwFieldDefinition
Returns:
Object native Type Object
Throws:
Exception

getNodeFromValue

public Node getNodeFromValue(Object value_p,
                             Document doc_p)
                      throws Exception
Description copied from interface: OwFieldDefinition
create a XML serialization of the given field value

Specified by:
getNodeFromValue in interface OwFieldDefinition
Parameters:
value_p - Object with field value
doc_p - DOM Document to add to
Returns:
DOM Node
Throws:
Exception

getValueFromNode

public Object getValueFromNode(Node node_p)
                        throws Exception
Description copied from interface: OwFieldDefinition
create a value for the field described by this class with the given XML Node serialization

Specified by:
getValueFromNode in interface OwFieldDefinition
Parameters:
node_p - the serialized value as a XML DOM Node
Returns:
Object the value of the field
Throws:
Exception

getValueFromString

public Object getValueFromString(String text_p)
                          throws Exception
create a value for the field described by this class with the given String serialization

Specified by:
getValueFromString in interface OwFieldDefinition
Parameters:
text_p - String the serialized value
Returns:
Object the value of the field
Throws:
Exception

isArray

public boolean isArray()
                throws Exception
Description copied from interface: OwFieldDefinition
check if property contains a list of values

Specified by:
isArray in interface OwFieldDefinition
Returns:
true if property is array, false if property is scalar
Throws:
Exception

isEnum

public boolean isEnum()
               throws Exception
Description copied from interface: OwFieldDefinition
check if property is a enum type (see getEnums)

Specified by:
isEnum in interface OwFieldDefinition
Returns:
true if property is a enum type
Throws:
Exception

getDescription

public String getDescription(Locale locale_p)
Description copied from interface: OwFieldDefinition
get the description defined by the DMS System

Specified by:
getDescription in interface OwFieldDefinition
Parameters:
locale_p - Locale to use
Returns:
type description of property

getOperators

public Collection getOperators()
                        throws Exception
Description copied from interface: OwFieldDefinition
get a collection of possible filter / search operators for the field

Specified by:
getOperators in interface OwFieldDefinition
Returns:
Collection of operators as defined with OwSearchOperator.CRIT_OP_..., or null if no operators are defined
Throws:
Exception

isType

public boolean isType(Class base_p)
               throws ClassNotFoundException
check if given java class name is base type

Parameters:
base_p - a Class
Returns:
boolean
Throws:
ClassNotFoundException

ignoreTime

public boolean ignoreTime()
Description copied from interface: OwFormat
check if the format should ignore time part of date values

Specified by:
ignoreTime in interface OwFormat

getTextFormat

public Format getTextFormat(int iFieldProviderType_p)
get the optional formatter object for string representation, according to the given context type

Specified by:
getTextFormat in interface OwFormat
Parameters:
iFieldProviderType_p - int as defined in OwFieldProvider.TYPE_...
Returns:
OwFormat, can be null to use the default format

isDateType

public boolean isDateType()
check if criteria is a date criteria

Returns:
a boolean

validate

public String validate(int fieldProviderType_p,
                       Object object_p,
                       Locale locale_p)
Description copied from interface: OwFormat
validate the given value

Specified by:
validate in interface OwFormat
Parameters:
fieldProviderType_p - int as defined in OwFieldProvider.TYPE_...
object_p - the value to validate
locale_p - Locale for String localize
Returns:
null if valid, a String user message if invalid

canValidate

public boolean canValidate()
Description copied from interface: OwFormat
check if validation is implemented

Specified by:
canValidate in interface OwFormat
Returns:
a boolean

ignoreDate

public boolean ignoreDate()
Description copied from interface: OwFormat
check if the format should ignore date part of date values

Specified by:
ignoreDate in interface OwFormat

isComplex

public boolean isComplex()
Description copied from interface: OwFieldDefinition
check if the property is a component that contains another child properties

Specified by:
isComplex in interface OwFieldDefinition
Returns:
true if the property can contains child properties
See Also:
OwFieldDefinition.getComplexChildClasses()

getComplexChildClasses

public List getComplexChildClasses()
                            throws Exception
Description copied from interface: OwFieldDefinition
get child properties classes of a complex property class

Specified by:
getComplexChildClasses in interface OwFieldDefinition
Returns:
Collection of OwFieldDefinition or null if isComplex is false
Throws:
Exception
See Also:
OwFieldDefinition.isComplex()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013 Alfresco Business Solutions. All Rights Reserved.