org.tolven.app.bean
Class TrimBean

java.lang.Object
  extended by org.tolven.app.bean.TrimBean
All Implemented Interfaces:
TrimLocal, TrimRemote

public class TrimBean
extends java.lang.Object
implements TrimLocal, TrimRemote


Field Summary
 AccountDAOLocal accountBean
           
 
Constructor Summary
TrimBean()
           
 
Method Summary
 TrimEx evaluateAndParseTrim(byte[] trim, java.util.Map<java.lang.String,java.lang.Object> variables)
          Given a TRIM XML string, evaluate embedded expression language against the supplied map of variables and then parse and return the Trim object structure.
 TrimEx evaluateAndParseTrim(java.lang.String trimName, java.util.Map<java.lang.String,java.lang.Object> variables)
          Given a TRIM XML string, evaluate embedded expression language against the supplied map of variables and then parse and return the Trim object structure.
 Trim fastExtendTrim(Trim trim, Trim extendsTrim)
          Extend the supplied trim by applying the extendsTrim to it and return the original trim that has now been extended.
 java.util.List<TrimHeader> findActiveTrimHeaders()
          Return all active trim headers
 java.util.List<TrimHeader> findActiveTrimHeaders(java.lang.String name)
          This method should return either zero or one item in the list.
 ActRelationship findActRelationship(Act act, java.lang.String[] nodes, int index)
           
 ActRelationship findActRelationship(Trim trim, java.lang.String path)
          Find an ActRelationship node using a path specification, for example: nextStep,0;nextStep,0 means find the first occurrence of nextStep in the top-level act, and then find the first occurrence of nextStep in the act found in the first step.
 java.util.List<java.lang.String> findAllActiveTrimHeaderNames()
           
 TrimHeader findOptionalTrimHeader(java.lang.String name)
          Same a findTrimHeader but return null if the header is not found.
 TrimEx findTrim(java.lang.String name)
          Find a trim regardless of the menu or account
 TrimHeader findTrimHeader(java.lang.String name)
          Find a raw trim header.
 java.util.List<TrimHeader> findTrimHeaders(java.lang.String name)
          Find the specified TrimHeader and throw an exception if it is not found.
 java.util.List<TrimHeader> findTrimHeaderVersions(java.lang.String trimHeaderName)
           
 java.lang.String findTrimXML(java.lang.Long id)
           
 java.lang.String findTrimXml(java.lang.String name)
          Find a trim XML String regardless of the menu or account
 java.lang.String findTrimXml(TrimHeader trimheader)
           
 ValueSet findValueSet(long accountId, BindTo bindTo, java.lang.String valueSetName)
          Get the valueSet from a given Trim
 java.util.List<DataType> findValueSetContents(long accountId, ValueSet valueSet)
          Return a list of all contents of a valueSet (except binds which we dereference here).
 void invokeComputes(Act act, java.util.Map<java.lang.String,java.lang.Object> targets, AccountUser accountUser, java.util.Date now, Trim trim)
          General-purpose mechanism to invoke computations on a trim document prior to submission.
 void loadContext(java.util.Map<java.lang.String,java.lang.Object> map, java.lang.String context)
           
 void loadTrimXML(java.lang.String trimXML)
          Simple method to extract only certain attributes from a trim XML string.
 void loadTrimXML(java.lang.String trimXML, java.lang.String user, java.lang.String comment, java.lang.Boolean isAutoGenerated)
          Create a TrimHeader one or more menu-data items referencing a trimHeader.
 TrimEx parseTrim(byte[] trimXML, AccountUser accountUser, java.lang.String context, java.util.Date now, java.lang.String source)
          In addition to marshaling the TRIM XML to an Object graph, this method also evaluates any embedded EL and processes includes.
 TrimEx parseTrim(byte[] trimXML, ExpressionEvaluator ee)
           
 TrimEx parseTrim(java.io.Reader input, ExpressionEvaluator ee)
          Parse the supplied XML into an Object tree, starting with Trim at the top.
 TrimEx parseTrim(java.lang.String trimXML, ExpressionEvaluator ee)
          Evaluate supplied trim substituting Expression language as needed then marshal the resulting string the an object graph.
 long persistTrimHeader(TrimHeader trimHeader)
          Persist a new trim header and return its ID
 void setComment(TrimHeader trimheader, java.lang.String comment)
           
 void shortTrim(long msId, long trimHeaderId, java.lang.String code, java.lang.String description)
          Create a menu-data item based on a trim.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

accountBean

public AccountDAOLocal accountBean
Constructor Detail

TrimBean

public TrimBean()
Method Detail

fastExtendTrim

public Trim fastExtendTrim(Trim trim,
                           Trim extendsTrim)

Extend the supplied trim by applying the extendsTrim to it and return the original trim that has now been extended. This version of extend does not use clones which means it depends on neither the trim nor the etendsTrim being modified beyond this one operation.

This approach means parsed trim cannot be cached. The tradeoff being that cloning is not required.

Extending is very different from instantiation and binding which in fact prepares trim for actual use.

Parameters:
trim -
extendsTrim -
Returns:
The same trim as was input, but now with null entries replaced with corresponding entries from the extends trim.

parseTrim

public TrimEx parseTrim(java.io.Reader input,
                        ExpressionEvaluator ee)
                 throws javax.xml.bind.JAXBException
Parse the supplied XML into an Object tree, starting with Trim at the top. The resulting trim will also be expanded if it has an extends element.

Note: This method should, but does not, check for cycles on the extends element

Parameters:
is - InputStream containing menu.xml
Returns:
The resulting Trim object (and its child nodes)
Throws:
java.lang.Exception
javax.xml.bind.JAXBException

parseTrim

public TrimEx parseTrim(java.lang.String trimXML,
                        ExpressionEvaluator ee)
                 throws javax.xml.bind.JAXBException
Evaluate supplied trim substituting Expression language as needed then marshal the resulting string the an object graph.

Specified by:
parseTrim in interface TrimLocal
Returns:
The resulting Trim object (and its child nodes)
Throws:
javax.xml.bind.JAXBException

parseTrim

public TrimEx parseTrim(byte[] trimXML,
                        ExpressionEvaluator ee)
                 throws javax.xml.bind.JAXBException
Throws:
javax.xml.bind.JAXBException

loadContext

public void loadContext(java.util.Map<java.lang.String,java.lang.Object> map,
                        java.lang.String context)

parseTrim

public TrimEx parseTrim(byte[] trimXML,
                        AccountUser accountUser,
                        java.lang.String context,
                        java.util.Date now,
                        java.lang.String source)
                 throws javax.xml.bind.JAXBException
In addition to marshaling the TRIM XML to an Object graph, this method also evaluates any embedded EL and processes includes. The following variables are available to expressions embedded in the trim document:

Specified by:
parseTrim in interface TrimLocal
Parameters:
trimXML -
accountUser -
context -
now -
Returns:
Trim The parsed object graph
Throws:
javax.xml.bind.JAXBException

evaluateAndParseTrim

public TrimEx evaluateAndParseTrim(byte[] trim,
                                   java.util.Map<java.lang.String,java.lang.Object> variables)
                            throws javax.xml.bind.JAXBException
Given a TRIM XML string, evaluate embedded expression language against the supplied map of variables and then parse and return the Trim object structure.

Parameters:
trimXML -
variables -
Returns:
Throws:
javax.xml.bind.JAXBException

evaluateAndParseTrim

public TrimEx evaluateAndParseTrim(java.lang.String trimName,
                                   java.util.Map<java.lang.String,java.lang.Object> variables)
                            throws javax.xml.bind.JAXBException
Given a TRIM XML string, evaluate embedded expression language against the supplied map of variables and then parse and return the Trim object structure.

Specified by:
evaluateAndParseTrim in interface TrimLocal
Specified by:
evaluateAndParseTrim in interface TrimRemote
Parameters:
trimXML -
variables -
Returns:
Throws:
javax.xml.bind.JAXBException

persistTrimHeader

public long persistTrimHeader(TrimHeader trimHeader)
Description copied from interface: TrimRemote
Persist a new trim header and return its ID

Specified by:
persistTrimHeader in interface TrimRemote
Returns:

findTrimHeaders

public java.util.List<TrimHeader> findTrimHeaders(java.lang.String name)
Find the specified TrimHeader and throw an exception if it is not found.

Parameters:
name -
Returns:

findActiveTrimHeaders

public java.util.List<TrimHeader> findActiveTrimHeaders()
Return all active trim headers

Specified by:
findActiveTrimHeaders in interface TrimLocal
Returns:

findActiveTrimHeaders

public java.util.List<TrimHeader> findActiveTrimHeaders(java.lang.String name)
This method should return either zero or one item in the list. Unlike findTrimHeader, it does not throw an exception if there is no result found.

Parameters:
name -
Returns:

findTrimHeader

public TrimHeader findTrimHeader(java.lang.String name)
Description copied from interface: TrimLocal
Find a raw trim header. The trim body is not parsed.

Specified by:
findTrimHeader in interface TrimLocal
Specified by:
findTrimHeader in interface TrimRemote

findOptionalTrimHeader

public TrimHeader findOptionalTrimHeader(java.lang.String name)
Same a findTrimHeader but return null if the header is not found.

Specified by:
findOptionalTrimHeader in interface TrimLocal
Specified by:
findOptionalTrimHeader in interface TrimRemote
Parameters:
name -
Returns:

findAllActiveTrimHeaderNames

public java.util.List<java.lang.String> findAllActiveTrimHeaderNames()
Specified by:
findAllActiveTrimHeaderNames in interface TrimRemote

findTrim

public TrimEx findTrim(java.lang.String name)
                throws javax.xml.bind.JAXBException
Find a trim regardless of the menu or account

Specified by:
findTrim in interface TrimLocal
Specified by:
findTrim in interface TrimRemote
Throws:
javax.xml.bind.JAXBException

findTrimXML

public java.lang.String findTrimXML(java.lang.Long id)
                             throws javax.xml.bind.JAXBException
Specified by:
findTrimXML in interface TrimRemote
Throws:
javax.xml.bind.JAXBException

findTrimXml

public java.lang.String findTrimXml(java.lang.String name)
                             throws javax.xml.bind.JAXBException
Find a trim XML String regardless of the menu or account

Specified by:
findTrimXml in interface TrimLocal
Specified by:
findTrimXml in interface TrimRemote
Throws:
javax.xml.bind.JAXBException

findTrimXml

public java.lang.String findTrimXml(TrimHeader trimheader)
Specified by:
findTrimXml in interface TrimLocal
Specified by:
findTrimXml in interface TrimRemote

findValueSet

public ValueSet findValueSet(long accountId,
                             BindTo bindTo,
                             java.lang.String valueSetName)
                      throws java.lang.Exception
Get the valueSet from a given Trim

Parameters:
accountId -
bindTo -
valueSetName -
Returns:
Throws:
java.lang.Exception

findValueSetContents

public java.util.List<DataType> findValueSetContents(long accountId,
                                                     ValueSet valueSet)
                                              throws java.lang.Exception
Return a list of all contents of a valueSet (except binds which we dereference here).

Specified by:
findValueSetContents in interface TrimLocal
Parameters:
accountId -
trim -
Returns:
exploded values
Throws:
java.lang.Exception

loadTrimXML

public void loadTrimXML(java.lang.String trimXML)
                 throws javax.xml.bind.JAXBException
Simple method to extract only certain attributes from a trim XML string.

Specified by:
loadTrimXML in interface TrimLocal
Specified by:
loadTrimXML in interface TrimRemote
Parameters:
trimXML -
Throws:
javax.xml.stream.XMLStreamException
java.io.IOException
javax.xml.bind.JAXBException

loadTrimXML

public void loadTrimXML(java.lang.String trimXML,
                        java.lang.String user,
                        java.lang.String comment,
                        java.lang.Boolean isAutoGenerated)
                 throws javax.xml.bind.JAXBException
Create a TrimHeader one or more menu-data items referencing a trimHeader.

Specified by:
loadTrimXML in interface TrimLocal
Specified by:
loadTrimXML in interface TrimRemote
Parameters:
trimXML - The XML representation of the string
Throws:
javax.xml.bind.JAXBException

findTrimHeaderVersions

public java.util.List<TrimHeader> findTrimHeaderVersions(java.lang.String trimHeaderName)
Specified by:
findTrimHeaderVersions in interface TrimRemote

setComment

public void setComment(TrimHeader trimheader,
                       java.lang.String comment)
Specified by:
setComment in interface TrimRemote

shortTrim

public void shortTrim(long msId,
                      long trimHeaderId,
                      java.lang.String code,
                      java.lang.String description)
Create a menu-data item based on a trim.

Specified by:
shortTrim in interface TrimRemote
Parameters:
msId -
trimHeaderId -
code -
description -

findActRelationship

public ActRelationship findActRelationship(Act act,
                                           java.lang.String[] nodes,
                                           int index)

findActRelationship

public ActRelationship findActRelationship(Trim trim,
                                           java.lang.String path)
Find an ActRelationship node using a path specification, for example: nextStep,0;nextStep,0 means find the first occurrence of nextStep in the top-level act, and then find the first occurrence of nextStep in the act found in the first step.

Specified by:
findActRelationship in interface TrimLocal
Parameters:
trim -
path -
Returns:

invokeComputes

public void invokeComputes(Act act,
                           java.util.Map<java.lang.String,java.lang.Object> targets,
                           AccountUser accountUser,
                           java.util.Date now,
                           Trim trim)
                    throws java.lang.Exception
General-purpose mechanism to invoke computations on a trim document prior to submission. Each method may be called more than once and so should be careful to clean up previous runs. The arguments passed to the specified class are dom Node object so the handler will need to call JAXB unmarshall to get an object graph (or just navigate the generic nodes). Once instantiated for a specific trim, a single instance of the object specified by type is used. Thus, the instantiated class can retain state between nodes of the trim visited with that type.

Specified by:
invokeComputes in interface TrimLocal
Parameters:
act -
Throws:
java.lang.Exception