|
Last
revision of this document: |
This
is document contains the code for Class
JS_ErrDB_Project_Set_BOC.
This is the Client-Derivation for the
Business Object holding a set of 'Project' Business Objects.
For easy 'cut and paste' ;-)
package
js_errdb.boc;
import
java.util.Vector;
import
javax.swing.JTable;
import
js_base.frame.JSBS_StartFrame;
import
js_base.frame.JSBS_TaskFrame;
import js_base.utilities.JSBS_Formatter;
import
js_errdb.bo.*;
import
js_errdb.bos.JS_ErrDB_Project_Set_BOS;
/**
*
* @author kurt@javascout.biz
*
@date 2007-01-13
*
* @description
* Server-Side
Derivation of a Set of Business Objects reflecting 'Project's.
*
* This class has the following
functions:
* * Method(s)
to read (SELECT) a set of Objects.
* These
methods are only implemented for search criteria that may
* deliver more than one
database-record.
* *
A method that builds a 'table' with 'raw data' out of the read
data-set.
* The 'table' is a vector
containing vectors with formatted data.
* Usage
of this 'raw-data' is to flexible fill Jtables for display.
* *
A method to set values a JTable GUI-element.
*
* Within
this class the selection is made, if the application is running with
the database
* on
the same machine (Stand-Alone) or
* it is a
'client-server' application and the data is held on a
Java-Application-Server (JAS)
* and has to be
retrieved using the EJB (Enterprise Java Bean) mechanism.
*
* Not
yet implemented is a 'mobile'-version of the application.
* There,
data is held locally on the same machine (e.g. a notebook)
* and
synchronized as soon as the local machine has a connection to the
JAS.
* This requieres a balance between
performance and up-to-dateness.
* Therefore a
general scheme can not be implemented; for each Business Object
* a
unique decision is needed how the synchronization has to be done.
*
*
@change-log
* when who why
*
--------------------------------------------------------
*
*/
public
class JS_ErrDB_Project_Set_BOC
extends
JS_ErrDB_Project_Set_BO
{
/*
* Constants
with the symbolic names of the rows
* of the table
containing the raw data for display.
* In fact this
symbolic names are stored in the first row
* of the
'table' (vector
with index 0). */
public
static final String
CONST_ColumnName_LanguageCode
= "LanguageCode";
public
static final String
CONST_ColumnName_ProjectCode
= "ProjectCode";
public
static final String
CONST_ColumnName_TargetDirectory
= "TargetDirectory";
/*
*
Task-Frame that constructed this Client-Side BO.
* There,
the handles are defined to access the database (if
Stand-Alone-Version)
* or the JAS (if
Client-Server-Version). */
JSBS_TaskFrame
frmTask =
null;
/*
*
CONSTRUCTOR
* --------------------
* Takes
the task that constructed this class as a parameter and stores
it
* in the above defined variable. */
public
JS_ErrDB_Project_Set_BOC(JSBS_TaskFrame
parmfrmTask) {
frmTask
=
parmfrmTask;
}
/*
* METHODS
* ----------------------
*/
/*
* --------------------
*
Method to get all Project/Language Combinations which are valid
* at the current work-date (variable of
frmTask.structMinParm). */
public
void getAllValidProjectLanguageCombinations()
{
switch
(frmTask.frmCC.RunVersion)
{
/* Decide
what version the application runs.
*/
case JSBS_StartFrame.CONST_StandAlone:
/* Database
is running on the local machine; construct the 'Server-Side' BO
directly.
* Pass all necessary connection-structures
and this 'Client-Side' BO. */
JS_ErrDB_Project_Set_BOS
bosJS_ErrDB_Project_Set_BOS
=
new
JS_ErrDB_Project_Set_BOS(frmTask.structMinParm,
frmTask.frmCC.structJSBS_DB_ConnectionManager,
this);
/* Call
the method to perform the database-operation(s).
*/
bosJS_ErrDB_Project_Set_BOS.getAllValidProjectLanguageCombinations();
/* Transfer
the values as they include the Status and
* changes of
Common Attributes (performed by the BOS)
*/
getJS_ErrDB_Project_Set_BO(bosJS_ErrDB_Project_Set_BOS);
break;
case JSBS_StartFrame.CONST_FatClient:
break;
}
/* Bring
the data into the form of the 'raw-data-table'
* that
makes further processing easier
*/
buildRawDataVector();
}
/*
* --------------------
*
Method to format the data (if necessary) and
* store
it in vectors reflecting the form of a 'table'. */
private
void buildRawDataVector()
{
/*
Empty the vector with the raw data
*/
vecRawDisplayData.removeAllElements();
/*
Build the 'header' (first row) containing the symbolic names
*/
Vector
vecHeader = new
Vector();
vecHeader.addElement(CONST_ColumnName_RowNr);
vecHeader.addElement(CONST_ColumnName_ProjectCode);
vecHeader.addElement(CONST_ColumnName_LanguageCode);
vecHeader.addElement(CONST_ColumnName_TargetDirectory);
vecRawDisplayData.addElement(vecHeader);
/*
Build the 'rows' containing the formatted data */
int
locintVectorIndex;
int
locintVectorSize =
vecRecordSet.size();
for
(locintVectorIndex
= 0; locintVectorIndex
< locintVectorSize;
locintVectorIndex++)
{
Vector
vecData = new
Vector();
String
tmpstrRowNumber = JSBS_Formatter.toFormattedString(locintVectorIndex
+ 1,
3);
vecData.addElement(tmpstrRowNumber);
JS_ErrDB_Project_BO
tmpstructJS_ErrDB_Project_BO =
new
JS_ErrDB_Project_BO();
tmpstructJS_ErrDB_Project_BO.getJS_ErrDB_Project_BO(
(JS_ErrDB_Project_BO)
vecRecordSet.elementAt(locintVectorIndex));
vecData.addElement(tmpstructJS_ErrDB_Project_BO.ProjectCode);
vecData.addElement(tmpstructJS_ErrDB_Project_BO.LanguageCode);
vecData.addElement(tmpstructJS_ErrDB_Project_BO.TargetDirectory);
/*
Add the just created 'row'.
*/
vecRawDisplayData.addElement(vecData);
}
}
/*
* --------------------
*
Method to fill a GUI-element of type JTable with the data in
* the
raw-data-vector.
* The language-dependant-text of the
JTable-header,
* the selection which column is
displayed and the sequence of the columns
* is defined
in the file DisplayStrings.xml within a XML-structure.
* Parameter:
* * GUI-element of
type JTable which should be filled.
* * Task-Frame
to
handle up to the Start-Frame which holds the xml-structure
and
* to use the name to select the
parameter out of the file DisplayStrings.xml.
* * Array
with the column widths if the user changed the value set in
DisplayStrings.xml.
*/
public
void setToGUI(JTable
parmJTable,
JSBS_TaskFrame
parmTF,
String[]
parmArrayColumnWidth) {
/*
*
Get the name of the Task-Frame */
String
strFrameClassName = parmTF.getClass().getName();
/*
* Call the method implemented with the xml-structure and
let it do the work.
*/
parmTF.frmCC.structJSBS_XML_DisplayStrings.processJTable(
parmJTable,
strFrameClassName,
this.vecRawDisplayData,
parmArrayColumnWidth);
}
}