org.openeai.config
Class EnterpriseFields

java.lang.Object
  extended by org.openeai.OpenEaiObject
      extended by org.openeai.config.EnterpriseFields
All Implemented Interfaces:
java.lang.Cloneable, PubliclyCloneable

public class EnterpriseFields
extends OpenEaiObject
implements PubliclyCloneable

This class wraps the EnterpriseObjects XML documents and provides our Enterprise Message objects with all the information they need to serialized themselves to and from different formats as well as providing information relating to specific business rules associated to specific fields contained in the EnterpriseObjects document (formatting, translations etc.).

Think of this object AS the Java representation of the EnterpriseObjects XML document.

Version:
3.0 - 28 January 2003
Author:
Tod Jackson (tod@openeai.org), Steve Wheat (steve@openeai.org)
See Also:
EnterpriseFormatter, EnterpriseTranslator, Field

Field Summary
 
Fields inherited from class org.openeai.OpenEaiObject
logger
 
Constructor Summary
EnterpriseFields()
          Constructor
 
Method Summary
 void addFieldsForObject(java.lang.String objectName, java.util.HashMap fields)
          This method adds an ObjectDefinition (all fields and their rules for an object) to a HashMap that is keyed by object name.
 java.lang.Object clone()
           
 java.lang.String getApplicationValue(java.lang.String objectName, java.lang.String appName, java.lang.String fieldName, java.lang.String enterpriseValue)
          Returns the application specific value that corresponds to the enterprise value passed in.
 java.lang.String getEnterpriseObjectsUri()
          Returns the EnterpriseObjects document uri associated to this EnterpriseFields object.
 java.lang.String getEnterpriseValue(java.lang.String objectName, java.lang.String fieldName, java.lang.String appValue)
          Returns the "enterprise value" that corresponds to the application value passed in based on formatting rules specified in the EnterpriseObjects document.
 org.jdom.Element getEODocRoot()
           
 java.util.HashMap getFieldsForObject()
          Returns the HashMap of all fields this EnterpriseFields object knows about.
 java.util.HashMap getFieldsForObject(java.lang.String objectName)
          Returns the HashMap of all fields this EnterpriseFields object knows about that corresponds to a specific object name.
 java.util.List getKeyNamesForField(java.lang.String objectName)
          Returns a list of all key fields associated to an object.
 java.lang.String getTranslationType()
          Returns the translation type that should be used when converting from application specific to enterprise value as specified in the application's deployment document and that is associated to the message object being configured.
 boolean ignoreMissingFields()
          Returns the flag indicating whether or not missing field definitions will be allowed or not.
 boolean ignoreValidation()
          Returns the flag indicating whether or not "object" validation is turned on or not.
 void init(org.jdom.Document doc)
          This method reads through the supplied EnterpriseObjects XML Document and builds itself according to the contents found within that document.
 void reinitialize()
          Re-initializes this EnterpriseFields object by re-reading the EnterpriseObjects.xml document from the URI specified in the configuration document.
 void setEnterpriseObjectsUri(java.lang.String uri)
          Sets the EnterpriseObjects document uri associated to this EnterpriseFields object.
 void setFieldsForObject(java.util.HashMap fields)
          Sets the HashMap of all fields this EnterpriseFields object knows about.
 void setIgnoreMissingFields(boolean ignore)
          Sets the flag indicating whether or not this EnterpriseFields object will be allowed to work if some of the object definitions specified in an objects definition are missing from the EnterpriseObjects document.
 void setIgnoreValidation(boolean ignore)
          Sets a flag indicating whether or not "object" validation should be used when converting an application value to an enterprise value.
 void setTranslationType(java.lang.String translationType)
          Sets the translation type that should be used when converting from application specific to enterprise value as specified in the application's deployment document and that is associated to the message object being configured.
 
Methods inherited from class org.openeai.OpenEaiObject
getAppName, getDebug, getFromAddr, getMailHost, getMailService, getProperties, getToAddr, initializeLog4j, initializeLog4j, initializeLog4j, setAppName, setDebug, setFromAddr, setMailHost, setMailService, setProperties, setToAddr
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnterpriseFields

public EnterpriseFields()
Constructor

Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Specified by:
clone in interface PubliclyCloneable
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

init

public final void init(org.jdom.Document doc)
                throws EnterpriseFieldException
This method reads through the supplied EnterpriseObjects XML Document and builds itself according to the contents found within that document. Each "ObjectDefinition" Element found within the EnterpriseObjects document is added to this EnterpriseFields object. This includes building the EnterpriseFormatter associated to each field that is a child of the each object built as well as any EnterpriseTranslator associated to that field.

It recursively includes object definitions found in any included EnterpriseObject document references.

This method is called by AppConfig when a Message object is being configured.

Parameters:
doc - Document the JDOM Document that was associated to the object being configured in the application deployment document.
Throws:
EnterpriseFieldException - if errors occur building the EnterpriseFields object.

reinitialize

public final void reinitialize()
                        throws EnterpriseFieldException
Re-initializes this EnterpriseFields object by re-reading the EnterpriseObjects.xml document from the URI specified in the configuration document. This can be called by application developers if the object they're working with has "dynamic" field rules and translations that might change. These changes will be reflected in EnterpriseObjects.xml and when this method is called, they will be applied to this EntepriseFields object.

This is the same basic processing that occurs when the MessageObject is initially configured at application startup time.

Throws:
EnterpriseFieldException - if any errors occur initializing.

setEnterpriseObjectsUri

public final void setEnterpriseObjectsUri(java.lang.String uri)
Sets the EnterpriseObjects document uri associated to this EnterpriseFields object. This document contains the rules that will be use to build the EnterpriseFields object.

Parameters:
uri - String URI to the EnterpriseObjects document. Can be file system or web uri.

getEnterpriseObjectsUri

public final java.lang.String getEnterpriseObjectsUri()
Returns the EnterpriseObjects document uri associated to this EnterpriseFields object. This document contains the rules that will be use to build the EnterpriseFields object.

Returns:
String URI to the EnterpriseObjects document. Can be file system or web uri.

getEODocRoot

public org.jdom.Element getEODocRoot()

setTranslationType

public final void setTranslationType(java.lang.String translationType)
Sets the translation type that should be used when converting from application specific to enterprise value as specified in the application's deployment document and that is associated to the message object being configured.

Currently, two types are supported:

Parameters:
translationType - String the translation type associated to the EnterpriseTranslator that will be used to translate from application specific values to enterprise values. Valid types are: "application" and "all".

getTranslationType

public final java.lang.String getTranslationType()
Returns the translation type that should be used when converting from application specific to enterprise value as specified in the application's deployment document and that is associated to the message object being configured.

Currently, two types are supported:

Returns:
String the translation type associated to the EnterpriseTranslator that will be used to translate from application specific values to enterprise values. Valid types are: "application" and "all".

setIgnoreMissingFields

public final void setIgnoreMissingFields(boolean ignore)
Sets the flag indicating whether or not this EnterpriseFields object will be allowed to work if some of the object definitions specified in an objects definition are missing from the EnterpriseObjects document. This is used when a application value is being converted to an enterprise value. If this is true, missing object definition information will be allowed. This should ONLY ever be false in a Development environment. Even then, it's arguable whether it should EVER be set to true.

It was originally intended to allow development work to continue while the EnterpriseObjects document is finished up.

Parameters:
ignore - boolean true means allow missing fields, false means throw an error if any missing fields exist.

ignoreMissingFields

public final boolean ignoreMissingFields()
Returns the flag indicating whether or not missing field definitions will be allowed or not.

Returns:
boolean true means missing fields will be allowe, false means they won't and an error will occur if they do.

setIgnoreValidation

public final void setIgnoreValidation(boolean ignore)
Sets a flag indicating whether or not "object" validation should be used when converting an application value to an enterprise value. If this value is set to true in the MessageObject's Configuration, any value passed to a setter method on that object will be allowed. No formatting rules, translations or scrubbing will occur on that data. While typically, one would never set this to 'true' there are cases where this needs to be set to allow data into an object during testing and when making a copy of an object (@see org.openeai.moa.XmlEnterpriseObject#deepCopy())

Parameters:
ignore - boolean true means validation will be ignored and any value passed to a setter method will be allowed, false means all data passed to the setter methods will be ran through the object's EnterpriseFormatter to apply rules to and validate the data being passed.

ignoreValidation

public final boolean ignoreValidation()
Returns the flag indicating whether or not "object" validation is turned on or not. This method is called when application data is ran through the EnterpriseFields object to potentially convert the data from application value to Enterprise value.

Returns:
boolean true means validation will be ignored and any value passed to a setter method will be allowed, false means all data passed to the setter methods will be ran through the object's EnterpriseFormatter to apply rules to and validate the data being passed.

addFieldsForObject

public final void addFieldsForObject(java.lang.String objectName,
                                     java.util.HashMap fields)
This method adds an ObjectDefinition (all fields and their rules for an object) to a HashMap that is keyed by object name. For example, if the object being built is the BasicPerson object, there would be a BasicPerson entry added with a key of "BasicPerson" and a value consisting of another HashMap that is all the child Fields of that BasicPerson. This is all specified in the EnterpriseObjects document associated to the BasicPerson MessageObject in the configuration document for the application that the BasicPerson object is a part of. Additionally, there would be entries added for all other objects listed in that EnterpriseObjects document.

Parameters:
objectName - String the name of the object definition being added.
fields - HashMap a list of all Fields that are children of the object being added.
See Also:
Field

getFieldsForObject

public final java.util.HashMap getFieldsForObject()
Returns the HashMap of all fields this EnterpriseFields object knows about.

Returns:
HashMap the list of all fields associated to this EnterpriseFields object.

setFieldsForObject

public final void setFieldsForObject(java.util.HashMap fields)
Sets the HashMap of all fields this EnterpriseFields object knows about.


getFieldsForObject

public final java.util.HashMap getFieldsForObject(java.lang.String objectName)
Returns the HashMap of all fields this EnterpriseFields object knows about that corresponds to a specific object name. For example, if someone needs to get a list of all Field objects associated to the BasicPerson object, they'd call this method passing "BasicPerson" as the parm. This will return all child Field objects of BasicPerson.

Returns:
HashMap the list of all fields associated to this EnterpriseFields object.
See Also:
Field

getKeyNamesForField

public final java.util.List getKeyNamesForField(java.lang.String objectName)
Returns a list of all key fields associated to an object. A field is specified as a "key" field in the EnterpriseObjects document. This attribute is typically used so layout managers can returned a consistent image of an object when that object gets serialized etc. so that serialized representation of the object will always match other things being equal. Additionally, it is used often to determine in the case of Updates on objects with complex repeatable fields, which one of those repeatable child objects has changed. The key fields cannot change so it is able to find objects with matching key fields, and if they're different, it knows that particular child object needs to be updated.

Returns:
java.util.List the list of names of all key fields for the object name passed in.

getApplicationValue

public final java.lang.String getApplicationValue(java.lang.String objectName,
                                                  java.lang.String appName,
                                                  java.lang.String fieldName,
                                                  java.lang.String enterpriseValue)
                                           throws EnterpriseFieldException
Returns the application specific value that corresponds to the enterprise value passed in. If a Field has a translation associated to it, that data can be translated both from application to enterprise value and vice-versa. If not translation is associated to the field, the enterprise value is returned.

Parameters:
objectName - String the name of the parent object of the field for which data is being translated
appName - String the name of the target application that the enterprise value should be translated to
fieldName - String the name of the field that needs to have the data translated for it.
enterpriseValue - String the enterprise value that needs to be "reverse translated"
Returns:
String the application specific value that corresponds to the enterprise value passed in. If no translator is associated to the field, the enterprise value is returned.
Throws:
EnterpriseFieldException - if any errors occur converting the enterprise value to the application value
See Also:
EnterpriseFormatter, EnterpriseTranslator

getEnterpriseValue

public final java.lang.String getEnterpriseValue(java.lang.String objectName,
                                                 java.lang.String fieldName,
                                                 java.lang.String appValue)
                                          throws EnterpriseFieldException
Returns the "enterprise value" that corresponds to the application value passed in based on formatting rules specified in the EnterpriseObjects document. This is the method that takes the application value passed in, runs it through the EnterpriseFormattter object associated to the Field (specified by the field namd passed in) and returns the results of those rules being applied.

Parameters:
objectName - String the name of the parent object of which the field is a child.
fieldName - String the name of the field that has the EnterpriseFormatter that needs to be used to apply the rules.
appValue - String the application specific value that needs to have the formatting rules applied to it.
Returns:
String the enterprise value after all formatting rules have been applied.
Throws:
EnterpriseFieldException - if any formatting rule is broken
See Also:
EnterpriseFormatter, EnterpriseTranslator, Field


Copyright © 2002,2003 OpenEAI Software Foundation