org.alfresco.web.evaluator
Class BaseEvaluator

java.lang.Object
  extended by org.alfresco.web.evaluator.BaseEvaluator
All Implemented Interfaces:
Evaluator
Direct Known Subclasses:
ActiveWorkflowsEvaluator, AlwaysFalseEvaluator, ChainedMatchAllEvaluator, ChainedMatchOneEvaluator, ContainerTypeEvaluator, EditingEvaluator, GoogleDocsCheckInEvaluator, GoogleDocsEditingEvaluator, GoogleDocsLockedEvaluator, GoogleDocsOwnerEvaluator, HasAspectEvaluator, IsBrowserEvaluator, IsMimetypeEvaluator, IsPortletModeEvaluator, LocateActionEvaluator, LockedEvaluator, LockOwnerEvaluator, MetadataValueEvaluator, NodeTypeEvaluator, PropertyNotNullEvaluator, RulesEvaluator, SimpleWorkflowEvaluator, SiteBasedEvaluator, SitePresetEvaluator, TransferredNodeEvaluator, ValueEvaluator, ViewInExplorerEvaluator

public abstract class BaseEvaluator
extends java.lang.Object
implements Evaluator

Base class for all UI evaluators.


Field Summary
protected  java.util.HashMap args
           
protected  org.json.simple.JSONObject metadata
           
protected  boolean negateOutput
           
 
Constructor Summary
BaseEvaluator()
           
 
Method Summary
abstract  boolean evaluate(org.json.simple.JSONObject jsonObject)
          Evaluator implementations abstract method.
 boolean evaluate(java.lang.Object record)
          Optional entry point from Rhino script.
 boolean evaluate(java.lang.Object record, java.lang.Object metadata)
          Optional entry point from Rhino script.
 boolean evaluate(java.lang.Object record, java.lang.Object metadata, java.util.HashMap args)
          Main entry point from Rhino script.
 java.lang.String getArg(java.lang.String name)
          Get webscript argument by name
 java.util.HashMap getArgs()
          Simple getter for optional webscript args
 java.lang.String getContainerType(org.json.simple.JSONObject jsonObject)
          Get the container node type (e.g.
 java.lang.String getHeader(java.lang.String name)
          Get request header value
 boolean getIsLocked(org.json.simple.JSONObject jsonObject)
          Get a boolean value indicating whether the node is locked or not
 boolean getIsPortlet()
          Get flag indicating portlet or standalone mode
 java.lang.Object getJSONValue(org.json.simple.JSONObject jsonObject, java.lang.String accessor)
          Retrieve a JSON value given an accessor string containing dot notation (e.g.
 boolean getMatchesCurrentUser(org.json.simple.JSONObject jsonObject, java.lang.String propertyName)
          Checks whether the current user matches that of a given user property
 org.json.simple.JSONObject getMetadata()
          Get metadata
 org.json.simple.JSONArray getNodeAspects(org.json.simple.JSONObject jsonObject)
          Retrieve a JSONArray of aspects for a node
 java.lang.String getNodeType(org.json.simple.JSONObject jsonObject)
          Retrieves the type for a node
 java.lang.Object getProperty(org.json.simple.JSONObject jsonObject, java.lang.String propertyName)
          Retrieve a JSONArray of aspects for a node
 java.lang.String getSiteId(org.json.simple.JSONObject jsonObject)
          Get the site shortName applicable to this node (if requested via a site-based page context)
 java.lang.String getSitePreset(org.json.simple.JSONObject jsonObject)
          Get the site preset (e.g.
 java.lang.String getUserId()
          Get the current user associated with this request
 void setNegateOutput(boolean negateOutput)
          Sets optional negateOutput flag which applies when one of the main entry points is used
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

args

protected java.util.HashMap args

metadata

protected org.json.simple.JSONObject metadata

negateOutput

protected boolean negateOutput
Constructor Detail

BaseEvaluator

public BaseEvaluator()
Method Detail

setNegateOutput

public void setNegateOutput(boolean negateOutput)
Sets optional negateOutput flag which applies when one of the main entry points is used


evaluate

public final boolean evaluate(java.lang.Object record)
Optional entry point from Rhino script. Converts JSON String to a JSONObject and calls the overridable evaluate() method.

Parameters:
record - JSON String representing the record wrapping the node as received from a Rhino script
Returns:
boolean indicating evaluator result

evaluate

public final boolean evaluate(java.lang.Object record,
                              java.lang.Object metadata)
Optional entry point from Rhino script. Converts JSON String to a JSONObject and calls the overridable evaluate() method.

Parameters:
record - JSON String representing the record wrapping the node as received from a Rhino script
metadata - JSON String containing metadata which may be relevant to the evaluation
Returns:
boolean indicating evaluator result

evaluate

public final boolean evaluate(java.lang.Object record,
                              java.lang.Object metadata,
                              java.util.HashMap args)
Main entry point from Rhino script. Converts JSON String to a JSONObject and calls the overridable evaluate() method.

Parameters:
record - JSON String or JSONObject as received from a Rhino script
metadata - JSON String or JSONObject as received from a Rhino script
args - URL arguments passed to calling webscript
Returns:
boolean indicating evaluator result

evaluate

public abstract boolean evaluate(org.json.simple.JSONObject jsonObject)
Evaluator implementations abstract method.

Specified by:
evaluate in interface Evaluator
Parameters:
jsonObject - The object the evaluation is for
Returns:
boolean indicating evaluator result

getArgs

public final java.util.HashMap getArgs()
Simple getter for optional webscript args

Returns:
HashMap args map (may be null)

getArg

public final java.lang.String getArg(java.lang.String name)
Get webscript argument by name

Parameters:
name - Argument name
Returns:
string argument value or null

getMetadata

public final org.json.simple.JSONObject getMetadata()
Get metadata

Returns:
JSONObject metadata

getHeader

public final java.lang.String getHeader(java.lang.String name)
Get request header value

Parameters:
name - Header name to retrieve
Returns:
string value or null

getIsPortlet

public final boolean getIsPortlet()
Get flag indicating portlet or standalone mode

Returns:
boolean true for portlet mode, false otherwise

getNodeType

public final java.lang.String getNodeType(org.json.simple.JSONObject jsonObject)
Retrieves the type for a node

Parameters:
jsonObject - JSONObject containing a "node" object as returned from the ApplicationScriptUtils class.
Returns:
String containing the node type

getNodeAspects

public final org.json.simple.JSONArray getNodeAspects(org.json.simple.JSONObject jsonObject)
Retrieve a JSONArray of aspects for a node

Parameters:
jsonObject - JSONObject containing a "node" object as returned from the ApplicationScriptUtils class.
Returns:
JSONArray containing aspects on the node

getProperty

public final java.lang.Object getProperty(org.json.simple.JSONObject jsonObject,
                                          java.lang.String propertyName)
Retrieve a JSONArray of aspects for a node

Parameters:
jsonObject - JSONObject containing a "node" object as returned from the ApplicationScriptUtils class.
propertyName - Name of the property to retrieve
Returns:
Object property value

getUserId

public final java.lang.String getUserId()
Get the current user associated with this request

Returns:
String userId

getSiteId

public final java.lang.String getSiteId(org.json.simple.JSONObject jsonObject)
Get the site shortName applicable to this node (if requested via a site-based page context)

Parameters:
jsonObject - JSONObject containing a "node" object as returned from the ApplicationScriptUtils class.
Returns:
String siteId or null

getSitePreset

public final java.lang.String getSitePreset(org.json.simple.JSONObject jsonObject)
Get the site preset (e.g. "site-dashboard") applicable to this node (if requested via a site-based page context)

Parameters:
jsonObject - JSONObject containing a "node" object as returned from the ApplicationScriptUtils class.
Returns:
String site preset or null

getContainerType

public final java.lang.String getContainerType(org.json.simple.JSONObject jsonObject)
Get the container node type (e.g. "cm:folder") applicable to this node (if requested via a site-based page context)

Parameters:
jsonObject - JSONObject containing a "node" object as returned from the ApplicationScriptUtils class.
Returns:
String container type or null

getIsLocked

public final boolean getIsLocked(org.json.simple.JSONObject jsonObject)
Get a boolean value indicating whether the node is locked or not

Parameters:
jsonObject - JSONObject containing a "node" object as returned from the ApplicationScriptUtils class.
Returns:
True if the node is locked

getMatchesCurrentUser

public final boolean getMatchesCurrentUser(org.json.simple.JSONObject jsonObject,
                                           java.lang.String propertyName)
Checks whether the current user matches that of a given user property

Parameters:
jsonObject - JSONObject containing a "node" object as returned from the ApplicationScriptUtils class.
propertyName - String containing dotted notation path to value
Returns:
True if the property value matches the current user

getJSONValue

public final java.lang.Object getJSONValue(org.json.simple.JSONObject jsonObject,
                                           java.lang.String accessor)
Retrieve a JSON value given an accessor string containing dot notation (e.g. "node.isContainer")

Parameters:
jsonObject - JSONObject containing a "node" object as returned from the ApplicationScriptUtils class.
accessor - String containing dotted notation path to value
Returns:
Object value or null


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.