|
Last
revision of this document: |
This
document
* describes the mission of the
General Class of a Business Object and
* gives a To-Do-List for
the steps necessary to code the class.
Business
Object, Overview describes the inheritance structure
(subclassing) of Business Objects.
It gives an overview how the
subclasses for a business-entity cooperate.
Mission
of the General Class:The
General Class of the Business Object, designed for a business entity,
comprehends
* variables,
* constants for Stati that might
occur when a method is performed and
* methods that are needed
both on the subclass for the Client-Side and on the subclass for the
Server-Side.
To-Do-List
to implement the class:Please
obey, that all General Classes for Business Objects are put into a
package (suggestion: application.bo) that is different for
those for Client-Side Classes (suggestion: application.boc)
and Server-Side Classes (suggestion:
application.bos).
This is done to
simplify the packaging-script when the application is versioned to
run as Client/Server.
The General Classes are needed on both the
Client-Application as on the EJB (Enterprise Java Bean) that is
running under a JAS (Java Application Server).
The Client-Side
Classes are only needed on the Client Application (and packed into
the JAR-file for it) while the Server-Side Classes are only needed
within the EJB.
A
fast way to get the code is to copy from an existing class and modify
it.
A class with working code (from the tutorial Develop
a Fat-Client in Java) is JS_ErrDB_Project_BO.
Steps
to code the class:
Create a plain java-class under the package 'application.bo'.
Inherit
from the class JSBS_BO
:
Example:
public
class JS_ErrDB_Project_BO extends
JSBS_BO {
Code
the variables specific for the business entity the Business
Object reflects.
Example:
/*
*
Project-Code, that is the shortcut for the Project. */
public
String ProjectCode =
"";
Code
the method to copy the variables from another object of this
class.
This method is needed to transfer the data from the
Server-Side Object to the Client-Side object.
This is necessary
as the Server-Side Object exists only as long as the
database-operation lasts and the data is transferred to the
client.
(It is handled as a 'transaction' like it was with CICS,
IMS/DC, etc. - if some old folks can remember ;-)
)
Example:/*
* --------------------
*
Method to copy the values from another object into this object.
*/
public
void getJS_ErrDB_Project_BO(JS_ErrDB_Project_BO
parmJS_ErrDB_Project_BO)
{/*
* Use
the method of the super-class to copy the Common
Attributes,
* StatusCode and StatusMsg.
*/super.getJSBS_BO(parm);JS_ErrDB_Project_BO
ProjectCode
=
parmJS_ErrDB_Project_BO.;ProjectCode }LanguageCode
=
parm;JS_ErrDB_Project_BO.LanguageCode TargetDirectory
=
parm;JS_ErrDB_Project_BO.TargetDirectory
If
a variable is another Business Object, use the copy-method of this
object to
copy.
Example: InvoicePositions.);getJS_HSepp_InvoicePositionList_BO(parmJS_HSepp_Invoice_BO.InvoicePositions
Code
the method to check if a Business variable
(variables
that are not Common Attributes) is different from that of another
object.
This method is needed to check if a change to the
Business Object was made.
This will save some
database-access-time if the user did not change something and
requests a 'store'.
Example:/*
* --------------------
*
Method to compare two Business Objects and check if
* at
least one of the Business Attributes is different. */
public
boolean isDifferent(JS_ErrDB_Project_BO
parmJS_ErrDB_Project_BO)
{/*
* Use
the method of the super-class to copy the Common
Attributes,
* StatusCode and StatusMsg. */if
(this.ProjectCode
!= parm)
JS_ErrDB_Project_BO.ProjectCodereturn
true; if
(this.LanguageCode
!= parm)
JS_ErrDB_Project_BO.LanguageCodereturn
true; if
(this.TargetDirectory
!=
parm)
JS_ErrDB_Project_BO.TargetDirectoryreturn
true;return
false;
}
If
a variable is another Business Object, use the copy-method of this
object to
copy.
Example: InvoicePositions.);getJS_HSepp_InvoicePositionList_BO(parmJS_HSepp_Invoice_BO.InvoicePositions
The
next implementation steps (for this class) may arise as the
specifications are more detailed analyzed.
If you are going to
have a feedback how the basic implementation works (e.g. to see and
correct semantical misconceptions), it is recommended to start coding
the Client-Side Class of the Business Object.
To to this,
please follow
this link.
Code
the constants specific
for the Business Object.
The requierement mostly arises when the
Server-Side subclass for the Business Object are developed and
coded.
Code the constants as the demand for them arises.
Code
the methods specific
for the Business Object.
There is no general guideline which
additional methods are needed..
Related
Documents:A
simplified overview how data is written to / read from a
database:
Using
Business Objects to handle data-storage and retrieval.