org.tolven.app.bean
Class AppEvalAdaptor

java.lang.Object
  extended by org.tolven.app.bean.AppEvalAdaptor

public class AppEvalAdaptor
extends java.lang.Object

When processing a transaction, this class provides a connection between the Rule engine and the application (menu data and menuStructure). It is account-specific and there should never be more than one per account. It can be reused for multiple transactions. This object needs to be tied to a session bean instance in order to work, it is not a session bean on its own.

Author:
John Churin

Constructor Summary
AppEvalAdaptor()
          Constructor
 
Method Summary
 void addProviderToPatientLink(java.lang.Long patientLinkId, CopyTo copyTo)
           
 PatientLink confirmPatientLink(MenuData patient, java.lang.Long patientLinkId)
           
 MenuData createMenuData(MenuStructure ms, long documentId, MenuData... parents)
          Create a new menu data item given the menuStructure item
 MenuData createMenuData(java.lang.String path, long documentId, MenuData... parents)
          Create a new menu data item given a path name.
 MenuData createPlaceholder(Act act, MenuStructure msInstance, MenuData mdParent01)
           
 MenuData createPlaceholder(Act act, MenuStructure msInstance, MenuData mdParent01, Status status)
          Upon receiving a trim object, rules will probably want to create appropriate menuData placeholders (Trim instances).
 MenuData createPlaceholder(Act act, java.lang.String path, MenuData mdParent01)
           
 MenuData createPlaceholder(Act act, java.lang.String path, MenuData mdParent01, Status status)
           
 MenuData createPlaceholder(Trim trim, MenuStructure ms)
          New version of createPlaceholder that also populates menuData
 MenuData createReferenceMD(MenuData mdPlaceholder, MenuStructure ms)
           
 MenuData createReferenceMD(MenuData mdPlaceholder, MenuStructure ms, Act act, boolean ignoreDuplicates)
          Create a reference to the specified placeholder.
 MenuData createReferenceMD(MenuData mdReferenced, java.lang.String path)
          Create a reference to the specified menuData item
 boolean equals(java.lang.Object obj)
          Equality is the same as Account equality
 java.lang.Object evaluate(java.lang.String expression)
          Evaluate the supplied expression and return the value.
 void finalize(DocXML docXML)
           
 Plan findEmptyPlan(MenuData mdPlaceholder)
           
 MenuData findMenuData(MenuStructure ms, java.lang.String path)
          Find the menuData item defined by the specified menuStructure and having the path as specified.
 MenuData findMenuData(SETIISlot ids)
          Find a menuData item by looking at the id of the object
 MenuData findMenuDataItem(long id)
          Return a menuData item by its id
 java.util.List<MenuData> findReferencingMDs(MenuData mdPlaceholder, java.lang.String path)
          Given a placeholder and a path to a list, find the item(s) in the list pointing to the placeholder.
 Account getAccount()
          Return the account object associated with this running of the rules
 DocBase getDocument()
           
 java.util.Date getNow()
           
 java.lang.String getPersonName(Entity entity)
           
 java.lang.String getRoleReference(ActEx act, java.lang.String participationName, java.lang.String fieldName)
           
 java.lang.String getRootName()
          The root path is available to prepend to other paths when needed.
 Account getSourceAccount()
           
 int hashCode()
          Hash is the same as Account hash
 void inboundScan(Trim trim)
          An inbound scan prepares a trim for introduction into this account.
 void init(AccountDAOLocal accountDAOLocal, MenuLocal menuBean, DocumentLocal documentLocal, ProviderLocal providerLocal, CreatorLocal creatorBean, ShareLocal shareBean, org.drools.StatefulSession workingMemory)
          Associate this object with working memory as a global and thus allowing callbacks.
 void initEL()
          Initialize the ExpressionLanguage Evaluator It will do nothing if the context is already initialized.
 boolean isSaveTrim()
           
 void outboundScan(Trim trim)
          An outbound scan prepare a trim for the possibility that a reply will be received as a result of sending the message outbound.
 void persistMenuData(MenuData md)
          Save a new MenuData item in the database.
 java.lang.String rebindPatient(java.lang.String internalId)
          Rebind patient to local patient using patientLink info
 void removeReferencingMenuData(DocBase docBase)
          Remove all menuData items that reference this document.
 void removeReferencingMenuData(DocBase docBase, boolean removePlaceholders)
           
 void removeReferencingMenuData(long documentId, boolean removePlaceholders)
           
 void removeReferencingMenuData(TolvenIdEx tolvenId)
          Remove menuData specified in the passed in tolvenId
 void removeReplacedMenuData(TolvenIdEx tolvenId)
          Remove menuData specified in the passed in tolvenId
 void runRules(TolvenMessage tm, DocXML docXML, TrimEx trim)
           
 void send(CopyTo copyTo)
          Send this document to another account.
 void send(Message message)
          Send this document to another account.
 void sendToProvider(java.lang.Long providerId)
          Send this document to another account.
 void setSaveTrim(boolean saveTrim)
           
 void setupName(Entity person, MenuData md)
          Setup a MenuData item with the Entity Name
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AppEvalAdaptor

public AppEvalAdaptor()
Constructor

Method Detail

init

public void init(AccountDAOLocal accountDAOLocal,
                 MenuLocal menuBean,
                 DocumentLocal documentLocal,
                 ProviderLocal providerLocal,
                 CreatorLocal creatorBean,
                 ShareLocal shareBean,
                 org.drools.StatefulSession workingMemory)
Associate this object with working memory as a global and thus allowing callbacks. Also, associate it with a MenuBean that helps it do its work.

Parameters:
menuBean - a Menu bean
wm - rule working memory

findEmptyPlan

public Plan findEmptyPlan(MenuData mdPlaceholder)

runRules

public void runRules(TolvenMessage tm,
                     DocXML docXML,
                     TrimEx trim)

getNow

public java.util.Date getNow()

findMenuData

public MenuData findMenuData(MenuStructure ms,
                             java.lang.String path)
Find the menuData item defined by the specified menuStructure and having the path as specified. This method will throw an error if there is more than one MenuData item associated with this path. Therefore, this method is only useful for placeholders and perhaps trim items.

Parameters:
ms -
path -
Returns:

findMenuData

public MenuData findMenuData(SETIISlot ids)
Find a menuData item by looking at the id of the object

Parameters:
ids -
Returns:

findMenuDataItem

public MenuData findMenuDataItem(long id)
Return a menuData item by its id

Parameters:
id -
Returns:

initEL

public void initEL()
Initialize the ExpressionLanguage Evaluator It will do nothing if the context is already initialized.


evaluate

public java.lang.Object evaluate(java.lang.String expression)
Evaluate the supplied expression and return the value. The expression must be surrounded by a hash and curley braces as in
   #{trim.name}
 

Parameters:
expression -
Returns:
The result of evaluating the supplied expression.

findReferencingMDs

public java.util.List<MenuData> findReferencingMDs(MenuData mdPlaceholder,
                                                   java.lang.String path)
Given a placeholder and a path to a list, find the item(s) in the list pointing to the placeholder.

Parameters:
ms -
path -
Returns:

removeReferencingMenuData

public void removeReferencingMenuData(DocBase docBase)
Remove all menuData items that reference this document. This is usually done to remove traces of the document when it was mutable, such as on to do lists. This function is usually called within the transaction that creates the index items associated with the document in immutable form. the other purpose for this function is to "level-the-playing-field for external vs internally generated data. In other words, the rules can behave the same regardless of the origin of the data.

Parameters:
docBase -

removeReferencingMenuData

public void removeReferencingMenuData(DocBase docBase,
                                      boolean removePlaceholders)

removeReferencingMenuData

public void removeReferencingMenuData(long documentId,
                                      boolean removePlaceholders)

removeReferencingMenuData

public void removeReferencingMenuData(TolvenIdEx tolvenId)
Remove menuData specified in the passed in tolvenId

Parameters:
tolvenId -

removeReplacedMenuData

public void removeReplacedMenuData(TolvenIdEx tolvenId)
Remove menuData specified in the passed in tolvenId

Parameters:
tolvenId -

addProviderToPatientLink

public void addProviderToPatientLink(java.lang.Long patientLinkId,
                                     CopyTo copyTo)

confirmPatientLink

public PatientLink confirmPatientLink(MenuData patient,
                                      java.lang.Long patientLinkId)

rebindPatient

public java.lang.String rebindPatient(java.lang.String internalId)
Rebind patient to local patient using patientLink info

Parameters:
internalId -
Returns:

setupName

public void setupName(Entity person,
                      MenuData md)
Setup a MenuData item with the Entity Name

Parameters:
person -
md -

getPersonName

public java.lang.String getPersonName(Entity entity)

send

public void send(CopyTo copyTo)
          throws java.lang.Exception
Send this document to another account.

Parameters:
copyTo -
Throws:
java.lang.Exception

outboundScan

public void outboundScan(Trim trim)
An outbound scan prepare a trim for the possibility that a reply will be received as a result of sending the message outbound.

See Also:
ShareBean

inboundScan

public void inboundScan(Trim trim)
An inbound scan prepares a trim for introduction into this account. This means we look for matches by placeholder-id (which the inbound user can override).

See Also:
ShareBean

send

public void send(Message message)
          throws java.lang.Exception
Send this document to another account.

Parameters:
copyTo -
Throws:
java.lang.Exception

sendToProvider

public void sendToProvider(java.lang.Long providerId)
                    throws java.lang.Exception
Send this document to another account.

Parameters:
copyTo -
Throws:
java.lang.Exception

getAccount

public Account getAccount()
Return the account object associated with this running of the rules

Returns:

equals

public boolean equals(java.lang.Object obj)
Equality is the same as Account equality

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Hash is the same as Account hash

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

createPlaceholder

public MenuData createPlaceholder(Trim trim,
                                  MenuStructure ms)
New version of createPlaceholder that also populates menuData

Parameters:
trim -
ms -
Returns:

createPlaceholder

public MenuData createPlaceholder(Act act,
                                  java.lang.String path,
                                  MenuData mdParent01)

createPlaceholder

public MenuData createPlaceholder(Act act,
                                  MenuStructure msInstance,
                                  MenuData mdParent01)

createPlaceholder

public MenuData createPlaceholder(Act act,
                                  java.lang.String path,
                                  MenuData mdParent01,
                                  Status status)

createPlaceholder

public MenuData createPlaceholder(Act act,
                                  MenuStructure msInstance,
                                  MenuData mdParent01,
                                  Status status)
Upon receiving a trim object, rules will probably want to create appropriate menuData placeholders (Trim instances). This method does the routine work in creating this kind of menudata object.


finalize

public void finalize(DocXML docXML)

createReferenceMD

public MenuData createReferenceMD(MenuData mdPlaceholder,
                                  MenuStructure ms,
                                  Act act,
                                  boolean ignoreDuplicates)
Create a reference to the specified placeholder. If there's already an item in the specified path referencing this placeholder, don't add it again.

Parameters:
mdPlaceholder - The menu Item to be referenced
path - The path of the new item
mdPatient -
Returns:

createReferenceMD

public MenuData createReferenceMD(MenuData mdPlaceholder,
                                  MenuStructure ms)

createReferenceMD

public MenuData createReferenceMD(MenuData mdReferenced,
                                  java.lang.String path)
Create a reference to the specified menuData item

Parameters:
mdReferenced - The menu Item to be referenced
path - The path of the new item
Returns:

getRoleReference

public java.lang.String getRoleReference(ActEx act,
                                         java.lang.String participationName,
                                         java.lang.String fieldName)

createMenuData

public MenuData createMenuData(MenuStructure ms,
                               long documentId,
                               MenuData... parents)
Create a new menu data item given the menuStructure item

Parameters:
ms -
documentId -
Returns:

createMenuData

public MenuData createMenuData(java.lang.String path,
                               long documentId,
                               MenuData... parents)
Create a new menu data item given a path name.

Parameters:
path -
documentId - The associated document or 0 if none.
Returns:

getRootName

public java.lang.String getRootName()
The root path is available to prepend to other paths when needed. For example, if a given rule is shared between ephr and echr, then the rule can simply call this method to get the appropriate root name, and prepend it, along with a colon to the rest of the path.

Returns:
A string containing the name of the root node for this account. eg echr.

persistMenuData

public void persistMenuData(MenuData md)
Save a new MenuData item in the database. It will be assigned a unique Id at this time.

Parameters:
md -

getDocument

public DocBase getDocument()

getSourceAccount

public Account getSourceAccount()

isSaveTrim

public boolean isSaveTrim()

setSaveTrim

public void setSaveTrim(boolean saveTrim)