com.wewebu.ow.server.field
Class OwSearchNode

java.lang.Object
  extended by com.wewebu.ow.server.field.OwSearchNode
Direct Known Subclasses:
OwStandardDecoratorSearchNode

public class OwSearchNode
extends Object

Class for searches
Searches are trees of OwSearchNode Objects.
Each node can contain either a list of child OwSearchNode Objects of a search criteria element. The nodes are combined with SEARCH_OP_... operators "and" and "or". The Criteria is by the OwSearchCriteria.
Search are used with OwRepository.doSearch(com.wewebu.ow.server.field.OwSearchNode, com.wewebu.ow.server.field.OwSort, java.util.Collection, int, int) 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


Nested Class Summary
 class OwSearchNode.OwSearchList
          Deprecated. since 4.0.0.0
 class OwSearchNode.OwSearchMap
          Deprecated. since 4.0.0.0 don't use this class anymore
static class OwSearchNode.OwSearchNodeFieldProvider
           Field provider interface for searches.
 
Field Summary
static int FILTER_HIDDEN
          filter type for criteria traversing used in getCriteriaList
static int FILTER_NONE
          filter type for criteria traversing used in getCriteriaList
static int FILTER_NONPROPERTY
          filter type for criteria traversing used in getCriteriaList
static int FILTER_READONLY
          filter type for criteria traversing used in getCriteriaList
protected  LinkedList m_Childs
          the children of this search node which are combined using the m_iOp Operator
protected  OwSearchCriteria m_Criteria
          criteria instance for this search node, null if OwSearchNode has children
protected  int m_iNodeType
          the type of the branch can be one of the NODE_TYPE_...
protected  int m_iOp
          combination operator which should be applied to the child OwSearchNode elements as defined in OwSearchNode
static int NODE_TYPE_CBR
          node type searches for content based criteria
static int NODE_TYPE_COMBINATION
          node, which combines other nodes
static int NODE_TYPE_CRITERIA
          a criteria node
static int NODE_TYPE_PROPERTY
          node type searches for properties like the metadata of documents
static int NODE_TYPE_SPECIAL
          node type searches for special properties like resource path or class criteria
protected static String PERSIST_END_RANGE_NAME
          DOM name for persistence see get/setPersistentNode()
protected static String PERSIST_OPERATOR_ATTR_NAME
          DOM name for persistence see get/setPersistentNode()
protected static String PERSIST_SEARCH_NODE_NAME
          DOM name for persistence see get/setPersistentNode()
protected static String PERSIST_START_RANGE_NAME
          DOM name for persistence see get/setPersistentNode()
protected static String PERSIST_UNIQUE_NAME__ATTR_NAME
          DOM name for persistence see get/setPersistentNode()
static int SEARCH_OP_AND
          combination operator for the OwSearchNode child nodes of this OwSearchNode Node
static int SEARCH_OP_OR
          combination operator for the OwSearchNode child nodes of this OwSearchNode Node
static int SEARCH_OP_UNDEF
          combination operator for the OwSearchNode child nodes undefined
 
Constructor Summary
protected OwSearchNode()
          default constructor for overridden classes
  OwSearchNode(int iOp_p, int iNodeType_p)
          create combination search with children but no criteria
  OwSearchNode(OwFieldDefinition fieldDefinition_p, int iOp_p, Object oInitialAndDefaultValue_p, int iAttributes_p)
          create a search node with a criteria
  OwSearchNode(OwFieldDefinition fieldDefinition_p, int iOp_p, Object oInitialAndDefaultValue_p, int iAttributes_p, String strUniqueName_p, String strInstruction_p, Collection wildcarddefinitions_p)
          create a search node with a criteria
  OwSearchNode(OwFieldDefinition fieldDefinition_p, int iOp_p, Object oInitialAndDefaultValue_p, int iAttributes_p, String strUniqueName_p, String strInstruction_p, Collection wildcarddefinitions_p, Object minValue_p, Object maxValue_p, Object defaultValue_p, String sJavaClassName_p)
          decorator pattern to and override a search node with a criteria
  OwSearchNode(OwField field_p, int iOp_p, int iAttributes_p)
          create a search node with a criteria
  OwSearchNode(OwField field_p, int iOp_p, int iAttributes_p, String strUniqueName_p, String strInstruction_p, Collection wildcarddefinitions_p)
          create a search node with a criteria
  OwSearchNode(OwSearchCriteria criteria_p)
          criteria constructor
  OwSearchNode(OwSearchNode search_p)
          create a copy with child tree
 
Method Summary
 void add(OwSearchNode search_p)
          add a search node.
 Object clone()
          clone the search tree
 void dump(Writer w_p)
          dump the search tree
 OwSearchNode findSearchNode(int iNodeType_p)
          find the first occurrence of a search node
 List getChilds()
          get children of this search node which are combined using the m_iOp Operator
 OwSearchCriteria getCriteria()
          get the criteria of this node
 List getCriteriaList(int iFilter_p)
          get a list which contains all the criteria in the OwSearchNode Tree
 Map getCriteriaMap(int iFilter_p)
          get a map which maps all the criteria in the OwSearchNode Tree to their unique name
 OwFieldProvider getFieldProvider()
          get a field provider interface for the search
 int getNodeType()
          get the type of the branch can be one of the NODE_TYPE_...
 int getOperator()
          get the criteria operator which should be applied to the subnodes as defined in OwSearchCriteria
 Node getPersistentNode(Document doc_p)
          get a XML node that persists the current state of the criteria and that can be used with setPersistentNode() to recreate the state
 boolean isCriteriaNode()
          check if search node is a criteria node
 boolean isEmpty()
          check if any criteria are set
 boolean isValid()
          (overridable) check if search tree is valid, can be used to perform a search, or if required fields are missing, or if no criteria where submitted.
 void reset()
          clear all criteria and set to default values
 void setPersistentNode(Node persistentNode_p)
          set a XML node that persists the current state of the criteria
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FILTER_NONE

public static final int FILTER_NONE
filter type for criteria traversing used in getCriteriaList

See Also:
Constant Field Values

FILTER_HIDDEN

public static final int FILTER_HIDDEN
filter type for criteria traversing used in getCriteriaList

See Also:
Constant Field Values

FILTER_NONPROPERTY

public static final int FILTER_NONPROPERTY
filter type for criteria traversing used in getCriteriaList

See Also:
Constant Field Values

FILTER_READONLY

public static final int FILTER_READONLY
filter type for criteria traversing used in getCriteriaList

Since:
4.0.0.0
See Also:
Constant Field Values

NODE_TYPE_PROPERTY

public static final int NODE_TYPE_PROPERTY
node type searches for properties like the metadata of documents

See Also:
Constant Field Values

NODE_TYPE_SPECIAL

public static final int NODE_TYPE_SPECIAL
node type searches for special properties like resource path or class criteria

See Also:
Constant Field Values

NODE_TYPE_CBR

public static final int NODE_TYPE_CBR
node type searches for content based criteria

See Also:
Constant Field Values

NODE_TYPE_CRITERIA

public static final int NODE_TYPE_CRITERIA
a criteria node

See Also:
Constant Field Values

NODE_TYPE_COMBINATION

public static final int NODE_TYPE_COMBINATION
node, which combines other nodes

See Also:
Constant Field Values

m_iNodeType

protected int m_iNodeType
the type of the branch can be one of the NODE_TYPE_... definitions used to distinguish the search branches and make search creation easier


SEARCH_OP_UNDEF

public static final int SEARCH_OP_UNDEF
combination operator for the OwSearchNode child nodes undefined

See Also:
Constant Field Values

SEARCH_OP_AND

public static final int SEARCH_OP_AND
combination operator for the OwSearchNode child nodes of this OwSearchNode Node

See Also:
Constant Field Values

SEARCH_OP_OR

public static final int SEARCH_OP_OR
combination operator for the OwSearchNode child nodes of this OwSearchNode Node

See Also:
Constant Field Values

m_iOp

protected int m_iOp
combination operator which should be applied to the child OwSearchNode elements as defined in OwSearchNode


m_Criteria

protected OwSearchCriteria m_Criteria
criteria instance for this search node, null if OwSearchNode has children


m_Childs

protected LinkedList m_Childs
the children of this search node which are combined using the m_iOp Operator


PERSIST_SEARCH_NODE_NAME

protected static final String PERSIST_SEARCH_NODE_NAME
DOM name for persistence see get/setPersistentNode()

See Also:
Constant Field Values

PERSIST_UNIQUE_NAME__ATTR_NAME

protected static final String PERSIST_UNIQUE_NAME__ATTR_NAME
DOM name for persistence see get/setPersistentNode()

See Also:
Constant Field Values

PERSIST_OPERATOR_ATTR_NAME

protected static final String PERSIST_OPERATOR_ATTR_NAME
DOM name for persistence see get/setPersistentNode()

See Also:
Constant Field Values

PERSIST_START_RANGE_NAME

protected static final String PERSIST_START_RANGE_NAME
DOM name for persistence see get/setPersistentNode()

See Also:
Constant Field Values

PERSIST_END_RANGE_NAME

protected static final String PERSIST_END_RANGE_NAME
DOM name for persistence see get/setPersistentNode()

See Also:
Constant Field Values
Constructor Detail

OwSearchNode

public OwSearchNode(OwSearchCriteria criteria_p)
criteria constructor

Parameters:
criteria_p -

OwSearchNode

public OwSearchNode(OwFieldDefinition fieldDefinition_p,
                    int iOp_p,
                    Object oInitialAndDefaultValue_p,
                    int iAttributes_p,
                    String strUniqueName_p,
                    String strInstruction_p,
                    Collection wildcarddefinitions_p)
create a search node with a criteria

Parameters:
fieldDefinition_p - OwFieldDefinition of criteria
iOp_p - criteria operator which should be applied to the value as defined in OwSearchCriteria
oInitialAndDefaultValue_p - initial and default value, for range operators it is a two field array, first field for first range criteria, second field for second range criteria
iAttributes_p - int attributes as defined with ATTRIBUTE_...
strUniqueName_p - String a unique name that identifies this criteria
strInstruction_p - String instruction to be displayed, can be null
wildcarddefinitions_p - Collection of OwWildCardDefinition, or null if no wildcards are allowed

OwSearchNode

public OwSearchNode(OwFieldDefinition fieldDefinition_p,
                    int iOp_p,
                    Object oInitialAndDefaultValue_p,
                    int iAttributes_p,
                    String strUniqueName_p,
                    String strInstruction_p,
                    Collection wildcarddefinitions_p,
                    Object minValue_p,
                    Object maxValue_p,
                    Object defaultValue_p,
                    String sJavaClassName_p)
             throws Exception
decorator pattern to and override a search node with a criteria

Parameters:
fieldDefinition_p - OwFieldDefinition
iOp_p - criteria operator which should be applied to the value as defined in OwSearchCriteria
oInitialAndDefaultValue_p - initial and default value, for range operators it is a two field array, first field for first range criteria, second field for second range criteria
iAttributes_p - int attributes as defined with ATTRIBUTE_...
strUniqueName_p - String a unique name that identifies this criteria
strInstruction_p - String instruction to be displayed, can be null
wildcarddefinitions_p - Collection of OwWildCardDefinition, or null if no wildcards are allowed
minValue_p - Object value to override the inherited FieldDefinition with custom values
maxValue_p - Object value to override the inherited FieldDefinition with custom values
defaultValue_p - Object value to override the inherited FieldDefinition with custom values
sJavaClassName_p - String value to override the inherited FieldDefinition with custom values
Throws:
Exception

OwSearchNode

public OwSearchNode(OwField field_p,
                    int iOp_p,
                    int iAttributes_p,
                    String strUniqueName_p,
                    String strInstruction_p,
                    Collection wildcarddefinitions_p)
             throws Exception
create a search node with a criteria

Parameters:
field_p - OwField criteria as field
iOp_p - criteria operator which should be applied to the value as defined in OwSearchCriteria
iAttributes_p - int attributes as defined with ATTRIBUTE_...
strUniqueName_p - String a unique name that identifies this criteria
strInstruction_p - String instruction to be displayed, can be null
wildcarddefinitions_p - Collection of OwWildCardDefinition, or null if no wildcards are allowed
Throws:
Exception

OwSearchNode

public OwSearchNode(OwFieldDefinition fieldDefinition_p,
                    int iOp_p,
                    Object oInitialAndDefaultValue_p,
                    int iAttributes_p)
create a search node with a criteria

Parameters:
fieldDefinition_p - OwFieldDefinition of criteria
iOp_p - criteria operator which should be applied to the value as defined in OwSearchCriteria
oInitialAndDefaultValue_p - initial and default value, for range operators it is a two field array, first field for first range criteria, second field for second range criteria
iAttributes_p - int attributes as defined with ATTRIBUTE_...

OwSearchNode

public OwSearchNode(OwField field_p,
                    int iOp_p,
                    int iAttributes_p)
             throws Exception
create a search node with a criteria

Parameters:
field_p - OwField criteria as field
iOp_p - criteria operator which should be applied to the value as defined in OwSearchCriteria
iAttributes_p - int attributes as defined with ATTRIBUTE_...
Throws:
Exception

OwSearchNode

public OwSearchNode(int iOp_p,
                    int iNodeType_p)
create combination search with children but no criteria

Parameters:
iOp_p - combination operator which should be applied to the child OwSearchNode elements as defined in OwSearchNode
iNodeType_p - the type of the branch can be one of the NODE_TYPE_... definition

OwSearchNode

public OwSearchNode(OwSearchNode search_p)
             throws Exception
create a copy with child tree

Throws:
Exception

OwSearchNode

protected OwSearchNode()
default constructor for overridden classes

Method Detail

dump

public void dump(Writer w_p)
          throws Exception
dump the search tree

Throws:
Exception

clone

public Object clone()
             throws CloneNotSupportedException
clone the search tree

Overrides:
clone in class Object
Returns:
OwSearchNode copy
Throws:
CloneNotSupportedException

getOperator

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


getCriteriaList

public List getCriteriaList(int iFilter_p)
get a list which contains all the criteria in the OwSearchNode Tree

Parameters:
iFilter_p - int any combination of OwSearchNode.FILTER_...
Returns:
List which contains all the criteria in the OwSearchNode Tree

getCriteriaMap

public Map getCriteriaMap(int iFilter_p)
get a map which maps all the criteria in the OwSearchNode Tree to their unique name

Parameters:
iFilter_p - int any combination of OwSearchNode.FILTER_...
Returns:
Map which contains all the criteria in the OwSearchNode Tree

reset

public void reset()
           throws Exception
clear all criteria and set to default values

Throws:
Exception

getCriteria

public OwSearchCriteria getCriteria()
get the criteria of this node

Returns:
OwSearchCriteria or null if node contains children

getChilds

public List getChilds()
get children of this search node which are combined using the m_iOp Operator

Returns:
List of OwSearchNode Objects, or null if node contains a criteria

getNodeType

public int getNodeType()
get the type of the branch can be one of the NODE_TYPE_... definitions used to distinguish the search branches and make search creation easier

Returns:
int

isEmpty

public boolean isEmpty()
check if any criteria are set

Returns:
true = no criteria are set, false = at least one criteria is set

isCriteriaNode

public boolean isCriteriaNode()
check if search node is a criteria node

Returns:
true = criteria node, false = branch containing other OwSearchNode nodes.

add

public void add(OwSearchNode search_p)
         throws Exception
add a search node. This node must not contain a criteria

Parameters:
search_p - the search to add
Throws:
Exception

setPersistentNode

public void setPersistentNode(Node persistentNode_p)
                       throws Exception
set a XML node that persists the current state of the criteria

Parameters:
persistentNode_p - org.w3c.dom.Node XML node
Throws:
Exception

getPersistentNode

public Node getPersistentNode(Document doc_p)
                       throws Exception
get a XML node that persists the current state of the criteria and that can be used with setPersistentNode() to recreate the state

Throws:
Exception

getFieldProvider

public OwFieldProvider getFieldProvider()
get a field provider interface for the search

Returns:
OwFieldProvider

findSearchNode

public OwSearchNode findSearchNode(int iNodeType_p)
find the first occurrence of a search node

Returns:
OwSearchNode or null if not found

isValid

public boolean isValid()
                throws Exception
(overridable) check if search tree is valid, can be used to perform a search, or if required fields are missing, or if no criteria where submitted.

Returns:
true if valid
Throws:
Exception

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013 Alfresco Business Solutions. All Rights Reserved.