DLESE Tools
v1.6.0

org.dlese.dpc.schemedit.input
Class InputManager

java.lang.Object
  extended by org.dlese.dpc.schemedit.input.InputManager

public class InputManager
extends Object

Aids metadata editor in processing of requests, and more specifically in processing (incl. validating) metadata field values as they are passed in the Request object (see SchemEditValidator).

The request parameters corrsponding to metadata elements contain the xpath of the element, and are interspersed with other types of request parameters. The InputManager selects the parameters for metadata elements and creates a Map of InputField instances, keyed by xpath.

Example of a metadata request parameter:

Author:
ostwald

Constructor Summary
InputManager(HttpServletRequest request, MetaDataFramework framework)
          Constructor for the InputManager object
 
Method Summary
 boolean checkValidValue(InputField inputField)
          Validates the value for a given InputField against its dataType.
 void destroy()
          Description of the Method
 void displayAllParams()
          Debugging method to display all request parameters
 void displayAnyTypeFields()
          Displays the InputFields corresponding to metadata fields that are Elements.
 void displayAttributeFields()
          Displays the InputFields corresponding to metadata fields that are Attributes.
 void displayElementFields()
          Displays the InputFields corresponding to metadata fields that are Elements.
 void displayEntityErrorFields()
          Displays the InputFields corresponding to metadata fields that are Elements.
 void displayMultiValueFields()
          Displays the InputFields corresponding to metadata fields that allow for multiple values (for debugging).
 List getAnyTypeFields()
          Gets the anyTypeFields attribute of the InputManager object
 List getAttributeFields()
          Selects the InputFields corresponding to metadata Attributes.
static boolean getDebug()
           
 List getElementFields()
          Selects the InputFields corresponding to metadata Elements.
 List getEntityErrorFields()
          Gets the entityErrorFields managed by this InputManager
static String getIndexedParamName(String paramName, int index)
          Creates a parameterName with an index for use in processing multivalue fields, which in the request, have several values for a given path.
 InputField getInputField(String paramName)
          Gets the inputField for the given param
 Collection getInputFields()
          Get the InputField instances managed by this InputManager
 List getMultiValueFields()
          Selects the InputFields corresponding to metadata fields that allow for multiple values.
 SchemaHelper getSchemaHelper()
          Gets the schemaHelper attribute of the InputManager object
 SchemaNode getSchemaNode(String paramName)
          Gets the schemaNode corresponding to the xpath contained in the provided paramName.
protected  List getUrlSchemaPaths()
          Get the url schema paths for this framework configuration.
 boolean hasSchemaNode(String paramName)
          Filters request parameters holding field data from other request parameters.
static String paramNameToNormalizedXPath(String paramName)
          Extracts an xpath from a request parameter name, and normalizes it to remove all indexing information.
static String paramNameToXPath(String paramName)
          Extracts the xpath portion of a paramName and decodes the xpath by converting indexing information from javscript to xpath forms.
 void removeAnyTypeFields(List fieldsToRemove, DocMap docMap)
          Remove specified Anytype fields from the managedFields of this inputManager and also from the instanceDocument.
protected  ReferenceResolver.ResolverResults resolveReferences(String fieldValue)
          Identifies entity references and attempts to resolve them
static void setDebug(boolean bool)
           
static String stripFunctionCall(String paramName)
          Strips the function call from a request parameter name, leaving a xpath.
 String toString()
          NOT YET DOCUMENTED
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InputManager

public InputManager(HttpServletRequest request,
                    MetaDataFramework framework)
Constructor for the InputManager object

Parameters:
request - Description of the Parameter
framework - Description of the Parameter
Method Detail

getInputField

public InputField getInputField(String paramName)
Gets the inputField for the given param

Parameters:
paramName - NOT YET DOCUMENTED
Returns:
The inputField value

getUrlSchemaPaths

protected List getUrlSchemaPaths()
Get the url schema paths for this framework configuration.

Returns:
A list of xpaths (never null)

getInputFields

public Collection getInputFields()
Get the InputField instances managed by this InputManager

Returns:
The inputFields value

getEntityErrorFields

public List getEntityErrorFields()
Gets the entityErrorFields managed by this InputManager

Returns:
The entityErrorFields value

getSchemaNode

public SchemaNode getSchemaNode(String paramName)
Gets the schemaNode corresponding to the xpath contained in the provided paramName.

Parameters:
paramName - request parameter supplied by the Request object
Returns:
The schemaNode value

getSchemaHelper

public SchemaHelper getSchemaHelper()
Gets the schemaHelper attribute of the InputManager object

Returns:
The schemaHelper value

checkValidValue

public boolean checkValidValue(InputField inputField)
                        throws Exception
Validates the value for a given InputField against its dataType.

The work is done by SchemaHelper.checkValidValue(String,String), which is called with information extracted from the InputField parameter.

Parameters:
inputField - Description of the Parameter
Returns:
true if the inputField contains a valid value
Throws:
Exception - Contains error message if value is not valid

hasSchemaNode

public boolean hasSchemaNode(String paramName)
Filters request parameters holding field data from other request parameters.

Parameters:
paramName - paramName in the request that may correspond to a metadata field
Returns:
true if paramName corresponds to an entry in the SchemaNodeMap

paramNameToNormalizedXPath

public static String paramNameToNormalizedXPath(String paramName)
Extracts an xpath from a request parameter name, and normalizes it to remove all indexing information.

For example, the following parameter name of:

would return:

Parameters:
paramName - Description of the Parameter
Returns:
A schema-normalized xpath (that can access a schemaNode)

getIndexedParamName

public static String getIndexedParamName(String paramName,
                                         int index)
Creates a parameterName with an index for use in processing multivalue fields, which in the request, have several values for a given path.

This method creates an individual, indexed path for each value. For example, if there were several values for the paramName of

the indexedParamName created for the first value would be

Parameters:
paramName - Description of the Parameter
index - Description of the Parameter
Returns:
Description of the Return Value

paramNameToXPath

public static String paramNameToXPath(String paramName)
Extracts the xpath portion of a paramName and decodes the xpath by converting indexing information from javscript to xpath forms.

For example, for a paramName of

this method returns

Parameters:
paramName - Description of the Parameter
Returns:
Description of the Return Value

stripFunctionCall

public static String stripFunctionCall(String paramName)
Strips the function call from a request parameter name, leaving a xpath.

Request parameters corresponding to Input fields are of the form: function(xpath). Applying stripFunctionCall to "function(xpath)" yeilds xpath.

Parameters:
paramName - Description of the Parameter
Returns:
Description of the Return Value

getAttributeFields

public List getAttributeFields()
Selects the InputFields corresponding to metadata Attributes.

Returns:
The attributes value

getAnyTypeFields

public List getAnyTypeFields()
Gets the anyTypeFields attribute of the InputManager object

Returns:
The anyTypeFields value

getElementFields

public List getElementFields()
Selects the InputFields corresponding to metadata Elements.

Returns:
The elements value

getMultiValueFields

public List getMultiValueFields()
Selects the InputFields corresponding to metadata fields that allow for multiple values.

Returns:
The multiValueFields value

removeAnyTypeFields

public void removeAnyTypeFields(List fieldsToRemove,
                                DocMap docMap)
Remove specified Anytype fields from the managedFields of this inputManager and also from the instanceDocument.

Note: updates inputField xpath indexing as appropriate after fields have been removed from the instance doc.

Parameters:
fieldsToRemove - list of InputField instances
docMap - provides access to instanceDocument

resolveReferences

protected ReferenceResolver.ResolverResults resolveReferences(String fieldValue)
Identifies entity references and attempts to resolve them

Parameters:
fieldValue - NOT YET DOCUMENTED
Returns:
NOT YET DOCUMENTED

displayAttributeFields

public void displayAttributeFields()
Displays the InputFields corresponding to metadata fields that are Attributes.


displayElementFields

public void displayElementFields()
Displays the InputFields corresponding to metadata fields that are Elements.


displayAnyTypeFields

public void displayAnyTypeFields()
Displays the InputFields corresponding to metadata fields that are Elements.


displayEntityErrorFields

public void displayEntityErrorFields()
Displays the InputFields corresponding to metadata fields that are Elements.


displayMultiValueFields

public void displayMultiValueFields()
Displays the InputFields corresponding to metadata fields that allow for multiple values (for debugging).


displayAllParams

public void displayAllParams()
Debugging method to display all request parameters


toString

public String toString()
NOT YET DOCUMENTED

Overrides:
toString in class Object
Returns:
NOT YET DOCUMENTED

destroy

public void destroy()
Description of the Method


setDebug

public static void setDebug(boolean bool)

getDebug

public static boolean getDebug()

DLESE Tools
v1.6.0