|
Letzte
Bearbeitung dieses Dokuments: |
Code
Erklärungen
und Anwendungsbeispiele
Verwandte
Dokumentation
package
js_base.bos;
/*
*
de: Package mit Klassen für den Zugriff auf
Datenbanken.
* en: Package with classes to access
databases. */
import
java.sql.*;
/*
*
de: Package und Klasse für das Ermitteln des
System-Datums.
* en: Package and class to get the
system-date. */import
java.util.Date;
import
js_base.bo.*;
import
js_base.dba.*;
/*
*
de:
* JSBS-Package und Klasse mit der
Daten-Struktur mit den minimal notwendigen Parametern.
*
en:
* JSBS-package and class with the
data-structure containing the minimum set of parameters. */
import
js_base.structures.JSBS_MinimalParameters;
/**
*
* @author kurt(at)javascout[dot]biz
* @date
2013-02-07
*
* @description
*
de:
* Server-seitiger Teil des Business Object für
die 'PDFP'.
*
* Diese Klasse hat
die folgenden Aufgaben:
* * Implementierung der Logik
die in den Methoden zur Bearbeitung von persistenten Daten
*
des Business Objekts einfachere Methoden zur Steuerung von
Data-Base-Objects (DBA)
* (deren Code mit
SQL-Kommandos direkt auf die Datenbank zugreift) aufruft.
*
* Logik zum Entscheiden ob eine Transaktion vollständig
ausgeführt wurde und mit einem
* 'commit'
abgeschlossen werden kann oder während der Transaktion ein
Fehler aufgetreten ist
* alle bisherigen
Operationen auf die Datenbank durch ein 'Rollback' ungültig
gemacht werden
* müssen.
*
*
Eine Beschreibung der Variablen und des Anwender-bekannten Schlüssels
finden Sie in der
* geerbten Generellen BO-Klasse.
*
* en:
* Server-Side
Derivation of the Business Object for the 'PDFP'.
*
* This class has the following
function:
* * Implements the logic to break
down the methods to handle persistant data of the
*
Business Object to the more simple methods (close to the
SQL-statements of the DB-system)
* of
the Data-Base-Access objects.
* * Logic to
decide if a transaction was fulfilled completely and can be
committed
or failed at one
step and has to be 'rolled back' to assure the data-integrity.
*
* For the variables and the user-known key
please refer to the inherited BO-class.
*
*
@change-log
* when who why
*
--------------------------------------------------------
*
*/public
class
JSBS_PDFP_BOS
extends
JSBS_PDFP_BO
{
/*
*
VARIABLE / VARIABLES.
* -------------------- *//*
*
de:
*
Merker ob das Objekt dieser Klasse durch ein BOC (Client-Side-Klasse
eines Business Object)
*
oder durch ein EJB (Enterprise Java Bean) konstruiert wurde.
*
Diese Information wird benötigt wenn ein 'Commit' oder
'Rollback' ausgeführt werden soll.
*
'Commit' und 'Rollback' werden nur in den Objekten ausgeführt
die direkt von einem BOC oder EJB
*
konstruiert wurden – nicht in Objekten, die von einem anderen
BOS konstruiert wurden.
*
en:
* Flag if
the object of this class was constructed by a BOC (Client-Side-class
of a Business Object)
*
or by a EJB (Enterprise Java Bean).
*
This Information is needed when a 'Commit' or a 'Rollback' has to be
performed.
*
'Commit' and 'Rollback' are only done in objects that were
constructed by BOC or EJB -
*
not in objects that were constructed by another BOS. */
private
boolean
bolObjectConstructedByBOC_or_EJB
;
/*
*
de:
*
Referenz zur bestehenden Verbindung zur Datenbank.
*
Dieser Werte muss von der aufrufenden Methode als Parameter übergeben
werden
*
wenn diese Klasse 'konstruiert' wird.
*
en:
*
Referenc to the established connection to the database.
* This
value has to be passed by the calling method when this class is
constructed. */
private
Connection
structDBCon
=
null
;
/*
*
de:
*
Minimales Set von Parameter mit Informationen über Anwender,
Arbeitsplatz
*
und Datum des Client von dem die Datenbank-Operation angefordert
wurde.
*
Verwendet wird der Anwender-Name und das Arbeitsdatum des
Arbeitsplatzes auf
*
dem das Client-Programm ausgeführt wird.
*
Das Datum des Client-Programms kann unterschiedlich zum System-Datum
sein.
*
en:
* Minimal Parameters containing user-, workstation-
and date-information from
* where the request for the
database-operation originated.
* Used is the user-name
and the date the workstation is set to.
* The date of
the workstation might be different of the system-date. */
private
JSBS_MinimalParameters
structJSBS_MinimalParameters
=
null
;
/*
*
de:
*
Datenstruktur des DBA-Objektes mit dem die SQL-Kommandos gegen die
Datenbank
*
ausgeführt werden.
*
en:
*
Structure of the DBA object used to perform SQL-commands against the
database. */
private
JSBS_Parameter_DBA
structJSBS_Parameter_DBA
=
new
JSBS_Parameter_DBA();
/*
* --------------------
*
de:
* CONSTRUCTOR
* der verwendet wird wenn eine
bestehende (und geöffnete!) Verbindung zur Datenbank
*
(Connection) als Parameter übergeben wird.
*
en:
* CONSTRUCTOR
* when an existing (and
open!) Connection to the database-system is passed. */
public
JSBS_PDFP_BOS(JSBS_MinimalParameters
parmMinParm,
Connection
parmDBCon) {/*
*
de: Aufrufen der Methode, die das Kopieren der Parameter ausführt.
*
en: Call the method written to do the copying of the parameters.
*/
constructionWithDBConnection(parmMinParm,
parmDBCon);
/*
*
de: Setzen des Merkers dass das Objekt
nicht
von
einem BOC oder EJB konstruiert wurde.
* en: Set the flag
signalling that the object was not constructed by a BOC or EJB.
*/
bolObjectConstructedByBOC_or_EJB
= false;
}/*
* --------------------
*
de:
* CONSTRUCTOR
* der verwendet wird wenn eine
bestehende (und geöffnete!) Verbindung zur Datenbank
*
(Connection) als Parameter übergeben wird und
* die
Werte der Variablen aus dem übergebenen Business Object
übernommen werden müssen.
* en:
* CONSTRUCTOR
*
when an existing (and open!) Connection to the database-system is
passed and
* the values of the variables have to be taken
from a Business Object passed as parameter. */
public
JSBS_PDFP_BOS(JSBS_MinimalParameters
parmMinParm,
Connection
parmDBCon,
JSBS_PDFP_BO
parmJSBS_PDFP_BO) {/*
*
de: Aufrufen der Methode, die das Kopieren der Parameter ausführt.
*
en: Call the method written to do the copying of the parameters.
*/
constructionWithDBConnection(parmMinParm,
parmDBCon);/*
*
de: Setzen des Merkers dass das Objekt nicht
von
einem BOC oder EJB konstruiert wurde.
* en: Set the flag
signalling that the object was not constructed by a BOC or EJB.
*/
bolObjectConstructedByBOC_or_EJB
=
false
;
/*
de:
*
Methode (in der generellen Klasse dieses Business Objects [geerbte
Superklasse]) aufrufen
*
die die Werte des als Parameter übergebenen BO auf die Variablen
dieses BO kopiert.
*
en:
*
Call the method (in the General Class [superclass]) for this Business
Object to
* copy the values from the BO passed as
parameter to the variables of this Business Object.
*/
copyFromJSBS_PDFP_BO(parmJSBS_PDFP_BO);
}/*
* --------------------
*
de:
* CONSTRUCTOR
* der verwendet wird wenn eine
bestehende (und geöffnete!) Verbindung zur Datenbank
*
(Connection) als Parameter übergeben wird.
* In den
Parametern wird auch übergeben, ob das Objekt dieser Klasse
durch ein BOC oder EJB
* konstruiert wird.
*
en:
* CONSTRUCTOR
* when an existing (and
open!) Connection to the database-system is passed.
* There
is a parameter signalling that this object is constructed by a BOC or
EJB. */
public
JSBS_PDFP_BOS(JSBS_MinimalParameters
parmMinParm,
Connection
parmDBCon,
boolean
parmObjectConstructedByBOC_or_EJB)
{
/*
*
de: Aufrufen der Methode, die das Kopieren der Parameter ausführt.
*
en: Call the method written to do the copying of the parameters.
*/
constructionWithDBConnection(parmMinParm,
parmDBCon);
/*
*
de: Übernehmen des Werts des Parameters in den Merker.
*
en: Transfer the value from the parameter into the flag.
*/
bolObjectConstructedByBOC_or_EJB
=
parmObjectConstructedByBOC_or_EJB;
}/*
* --------------------
*
de:
* CONSTRUCTOR
* der verwendet wird wenn eine
bestehende (und geöffnete!) Verbindung zur Datenbank
*
(Connection) als Parameter übergeben wird und
* die
Werte der Variablen aus dem übergebenen Business Object
übernommen werden müssen.
* In den Parametern wird
auch übergeben, ob das Objekt dieser Klasse durch ein BOC oder
EJB
* konstruiert wird.
* en:
* CONSTRUCTOR
*
when an existing (and open!) Connection to the database-system is
passed and
* the values of the variables have to be taken
from a Business Object passed as parameter.
* There is a
parameter signalling that this object is constructed by a BOC or EJB.
*/
public
JSBS_PDFP_BOS(JSBS_MinimalParameters
parmMinParm,
Connection
parmDBCon,
JSBS_PDFP_BO
parmJSBS_PDFP_BO,
boolean
parmObjectConstructedByBOC_or_EJB)
{
/*
*
de: Aufrufen der Methode, die das Kopieren der Parameter ausführt.
*
en: Call the method written to do the copying of the parameters.
*/
constructionWithDBConnection(parmMinParm,
parmDBCon);/*
*
de: Übernehmen des Werts des Parameters in den Merker.
*
en: Transfer the value from the parameter into the flag.
*/
bolObjectConstructedByBOC_or_EJB
=
parmObjectConstructedByBOC_or_EJB;
/*
de:
*
Methode (in der generellen Klasse dieses Business Objects [geerbte
Superklasse]) aufrufen
*
die die Werte des als Parameter übergebenen BO auf die Variablen
dieses BO kopiert.
*
en:
*
Call the method (in the General Class [superclass]) for this Business
Objject to
* copy the values from the BO passed as
parameter to the variables of this Business Objject.
*/
copyFromJSBS_PDFP_BO(parmJSBS_PDFP_BO);
}/*
* --------------------
*
de:
*
METHODE zum Kopieren der Werte, die in den Parametern der
'Constructors'
*
übergeben wurden in die Variablen dieses Objekts.
*
en:
* METHOD to copy the values that were passed in the
parameters of the 'constructors'
*
into the variables of this Object. */
private
void
constructionWithDBConnection(
JSBS_MinimalParameters
parmMinParm,
Connection
parmDBConnection) {
structJSBS_MinimalParameters
=
new
JSBS_MinimalParameters(parmMinParm);
structDBCon
=
parmDBConnection;
}/*
* --------------------
* de:
*
METHODE um die Änderungen, die mit dieser Datenbank-Verbindung
gemacht wurden,
*
als 'gültig' zu markieren (commit).
*
Das 'commit' wird nur ausgeführt, wenn das Objekt durch ein BOC
oder EJB konstruiert
* wurde; d.h. der entsprechende
Parameter im 'Constructor' übergeben wurde.
*
Diese Regel ist eine Konvention damit auch innerhalb eines
BOS-Objekts wieder
*
BOS-Objekte konstruiert werden können. In diesen Objekten wird
aber kein 'commit' oder
*
'rollback' ausgeführt.
*
en:
*
METHOD to 'commit' the changes made with this database-connection.
* The commit is only done if the object was
constructed by a BOC or EJB;
* i.e. the adjacent
parameter was passed in the 'constructor'.
* This rule
is a convention that allows to 'construct' BOS objects within
* BOS-objects. Within these BOS-objects a'commit' or
'rollback' is not executed. */
private
void
commitDBConnection(
boolean
parmReadOnly)
{
/*
* de:
* Wenn
dieses BOS-Objekt nicht in einem BOC oder EJB konstruiert wurde, dann
wird diese
* Methode hier beendet.
* en:
* If
this BOS-object has not been constructed in a BOC or EJB, this method
will end here. */
if
(!
bolObjectConstructedByBOC_or_EJB
)
return
;
/*
* de:
* 'Commit'
nur ausführen wenn die DB-Verbindung nicht als 'autocommit'
geöffnet wurde.
* Ein Beenden der Methode bei
'autocommit' verbessert die Performanz.
* en:
* Perform
the 'commit' only if the DB-connection was not opened as
'autocommit'
* Ending the method when 'autocommit' was
chosen enhances the performance. */
if
(!
parmReadOnly) {
/*
* de:
* 'Commit'
innerhalb einer try/catch-Logik ausführen damit ein eventueller
Fehler beim
* 'commit' abgefangen werden kann.
* en:
* Run the 'commit' within the try/catch-logic to be
able to handle a potential error. */
try
{
structDBCon
.commit();}
catch
(SQLException
SQLExc) {
/*
* de:
* Fehler
im Datenbank-System während des 'commit';
* Fehler
an die aufrufende Methode zurück liefern.
* en:
* Error
of the database-system during 'commit'; report the error to the
calling method. */
StatusCode
=
CONST_DB_SYSTEM_ERROR
;
StatusMsg
=
SQLExc.getMessage();
/*
* de: Um
auf der sicheren Seite zu sein zusätzlich ein 'rollback'
ausführen.
* en: To be on the save side: perform a
'rollback'.
*/
rollbackDBConnection(parmReadOnly);
}
}
}/*
* --------------------
* de:
*
METHODE um die Änderungen, die mit dieser Datenbank-Verbindung
gemacht wurden,
*
'rückgängig' zu machen (rollback); d.h. die Änderungen
werden nicht gültig.
*
Das 'rollback' wird nur ausgeführt, wenn das Objekt durch ein
BOC oder EJB konstruiert
* wurde; d.h. der
entsprechende Parameter im 'Constructor' übergeben wurde.
*
Diese Regel ist eine Konvention damit auch innerhalb eines
BOS-Objekts wieder
*
BOS-Objekte konstruiert werden können. In diesen Objekten wird
aber kein 'commit' oder
*
'rollback' ausgeführt.
*
en:
*
METHOD to 'rollback' the changes made with this database-connection.
* The rollback is only done if the object was
constructed by a BOC or EJB;
* i.e. the adjacent
parameter was passed in the 'constructor'.
* This rule
is a convention that allows to 'construct' BOS objects within
* BOS-objects. Within these BOS-objects a'commit' or
'rollback' is not executed. */
private
void
rollbackDBConnection(
boolean
parmReadOnly)
{
/*
* de:
* Wenn
dieses BOS-Objekt nicht in einem BOC oder EJB konstruiert wurde, dann
wird diese
* Methode hier beendet.
* en:
* If
this BOS-object has not been constructed in a BOC or EJB, this method
will end here. */
if
(!
bolObjectConstructedByBOC_or_EJB
)
return
;
/*
* de:
* 'Rollback'
nur ausführen wenn die DB-Verbindung nicht als 'autocommit'
geöffnet wurde.
* Ein Beenden der Methode bei
'autocommit' verbessert die Performanz.
* en:
* Perform
the 'rollback' only if the DB-connection was not opened as
'autocommit'
* Ending the method when 'autocommit' was
chosen enhances the performance. */
if
(!
parmReadOnly) {
/*
* de:
* 'Commit'
innerhalb einer try/catch-Logik ausführen damit ein eventueller
Fehler beim
* 'commit' abgefangen werden kann.
* en:
* Run the 'commit' within the try/catch-logic to be
able to handle a potential error. */
try
{
structDBCon
.commit();}
catch
(SQLException
SQLExc) {
/*
* de:
* Fehler
im Datenbank-System während des 'commit';
* Fehler
an die aufrufende Methode zurück liefern.
* en:
* Error
of the database-system during 'commit'; report the error to the
calling method. */
StatusCode
=
CONST_DB_SYSTEM_ERROR
;
StatusMsg
=
SQLExc.getMessage();
/*
* de:
Um auf der sicheren Seite zu sein zusätzlich ein 'rollback'
ausführen.
* en: To be on the save side: perform a
'rollback'.
*/
rollbackDBConnection(parmReadOnly);
}
}
}/*
* --------------------
* de:
* METHODE
zum Übertragen der Variablen-weWerte dieses Business Object auf
die
* Variablen des Data-Base-Acces (DBA) Objekts das
diesem Business Objekt zugeordnet ist.
* en:
* METHOD
to transfer the values of the variables from this Business Object
* to the attributes of the Data-Base-Access (DBA)
Object that is assigned
* to this Business
Object. */
private
void
setDBAAttributes(JSBS_Parameter_DBA
parmJSBS_Parameter_DBA) {
/*
* de:
* Methode
der Superklasse (JSBS_BO) aufrufen um die Werte der Allgemeinen
Attribute
* (Common Attributes) zu übertragen.
* en:
* Call the method of the
superclass (JSBS_BO) to transfer the values of the
* Common
Attributes.
*/
setCommonDBAAttributes(parmJSBS_Parameter_DBA);
/*
* de:
Übertragen der geschäfts-spezifischen Attribute dieses
Business Object.
* en: Transfer the business specific
attributes of this Business Object.
*/
parmJSBS_Parameter_DBA.
ParameterName
=
this
.
CONST_PARAMETER_NAME
;
parmJSBS_Parameter_DBA.Value01
=
this
.
Hostname
;
parmJSBS_Parameter_DBA.Value02
=
this
.
TCPIP_Address
;
parmJSBS_Parameter_DBA.Value06
=
this
.
Value06
;
parmJSBS_Parameter_DBA.Value07
=
this
.
Value07
;
parmJSBS_Parameter_DBA.Value08
=
this
.
Value08
;
parmJSBS_Parameter_DBA.Value09
=
this
.
Value09
;
parmJSBS_Parameter_DBA.Value10
=
this
.
Value10
;
parmJSBS_Parameter_DBA.Value11
=
this
.
Value11
;
parmJSBS_Parameter_DBA.Value12
=
this
.
Value12
;
parmJSBS_Parameter_DBA.Value13
=
this
.
Value13
;
parmJSBS_Parameter_DBA.Value14
=
this
.
Value14
;
parmJSBS_Parameter_DBA.Value15
=
this
.
Value15
;
parmJSBS_Parameter_DBA.Value16
=
this
.
Value16
;
parmJSBS_Parameter_DBA.Value17
=
this
.
Value17
;
parmJSBS_Parameter_DBA.Value18
=
this
.
Value18
;
parmJSBS_Parameter_DBA.Value19
=
this
.
Value19
;
parmJSBS_Parameter_DBA.Value20
=
this
.
Value20
;
}/*
* --------------------
* de:
* METHODE
zum Speichern der Werte in den Variablen dieses Business Object in
der/den
* Datenbank-Tabelle/n; oder technisch
ausgedrückt: Werte 'persistent' machen.
* Innerhalb
der Methode wird entschieden
* ob dieses Objekt neu
ist und ein INSERT der Daten in die DB-Tabelle notwendig ist oder
* ob die geschäfts-spezifischen Werte geändert
wurden und ein UPDATE erforderlich ist.
* en:
* METHOD
to store the values of the variables from this Business Object
* into the database-table(s); or in a technical term:
make the data persistent.
* Within the method is
decided
* if this object is new and an INSERT into the
db-table is requiered or
* the business-values object
were changed and an UPDATE has to be done. */
public
void
store()
{
/*
* de:
* Festlegen, dass 'Update' Operationen auf die
Datenbank ausgeführt werden;
* 'autocommit' nicht
setzen.
* en:
* Define that there are
'Update' operations to the database: do not set 'autocommit'.
*/
boolean
bol_autocommit
=
false
;
/*
* de:
Status-Variablen auf 'OK' setzen.
* en: Set the
Status-variables to a state of 'OK'. */
this
.
StatusCode
=
CONST_OK
;
this
.
StatusMsg
=
""
;
/*
* de:
Entscheiden ob das Business Object neu erstellt (ObjectID ist 0) oder
verändert wurde.
* en: Decide if the Business
Object is newly created (ObjectID is 0) or updated. */
if
(
ObjectID
==
0) {
/*
* de:
* Speichern
eines neuen Objekts angefordert; prüfen, dass ein Datensatz mit
der
* gleichen Anwender-bekannten-Identifikation noch
nicht existiert für das aktuelle Datum.
* Abweichend
zum Muster muss auch ein alternativer Anwender bekannter
Schlüssel
* (TCP/IP-Adresse) geprüft werden
wenn der Hostname nicht existiert.
* en:
* Storing
of a new object requested; check that a dataset with the same
User-Known-Key
* does not already exist for the actual
date.
* Different to the template, an alternate
user-know key (TCP/IP-address) has to be checked
* if
the Hostnam does not exist. *//*
* de:
Merker, ob das BO einen Wert für den Hostname enthält.
* en:
Flag, if the BO contains a value for the Hostname. */
boolean
locboolIdentifiedByHostname
=
false
;
/*
* de:
* Merker, ob bereits ein BO mit der gleichen
Anwender-bekannten-Identifikation existiert.
* Der Wert
wird auf 'true' gesetzt damit nicht ein Datensatz eingefügt wird
bei dem Hostname
* und TCPIP_Address den Wert 'null'
enthalten.
* en:
* Flag, if a BO with
the same user-known-key already exists.
* The value is
set to 'true' to avoid that a dataset where Hostname and
TCPIP_Address contain
* a 'null' value, is inserted.
*/
boolean
locboolDataSetExists
=
true
;
/*
* de:
* Zuerst für die primäre
Anwender-bekannte-Identifikation (Hostname) prüfen, ob bereits
* ein Datensatz existiert.
* en:
* First verify if a dataset already exists for the
primary user-known-key (Hostname). */
if
(
this
.
Hostname
!=
null
)
{
if
(
this
.
Hostname
.trim().length()
> 0) {
locboolIdentifiedByHostname
=
true
;
locboolDataSetExists
=
structJSBS_Parameter_DBA
.selectByUserKnownKey(
structDBCon
,
structJSBS_MinimalParameters
,
this
.
CONST_PARAMETER_NAME
,
this
.
Hostname
);
}
}/*
* de:
* Wenn die primäre
Anwender-bekannte-Identifikation (Hostname) nicht zum Prüfen
verwendet
* werden kann, dann über die
TCPIP_Address auf bereits vorhandenen Datensatz prüfen.
* en:
* If the primary user-known-key (Hostname) can not be
used to verify then use the
* TCPIP_Address to check
for an existing dataset. */
if
(!locboolIdentifiedByHostname)
{
if
(
this
.
TCPIP_Address
!=
null
)
{
if
(
this
.
TCPIP_Address
.trim().length()
> 0) {
locboolDataSetExists
=
structJSBS_Parameter_DBA
.selectByValue02(
structDBCon
,
structJSBS_MinimalParameters
,
this
.
CONST_PARAMETER_NAME
,
this
.
TCPIP_Address
);
}
}
}
if
(locboolDataSetExists)
{
/*
* de:
Datensatz mit dem bekannten Schlüssel existiert bereits;
'Fehler' melden.
* en: Data-Set with the known key
already exists; report 'error'. */
StatusCode
=
CONST_DUPLICATE_KEY
;
StatusMsg
=
""
;
rollbackDBConnection(bol_autocommit);
return
;
}
else
{
/*
* de:
Prüfen ob ein Datenbankfehler aufgetreten ist.
* en:
Check if a database-error occured. */
if
(structJSBS_Parameter_DBA.
ErrorMsg
.length()
> 0) {
/*
* de:
Datenbankfehler aufgetreten; diese Methode nicht fortsetzen.
* en:
Database-Error happened; do not go on with this method.
*/
StatusCode
=
CONST_DB_SYSTEM_ERROR
;
StatusMsg
=
structJSBS_Parameter_DBA.ErrorMsg
;
rollbackDBConnection(bol_autocommit);
return
;
}
}/*
* de:
* Datensatz
mit dem Anwender-bekannten-Schlüssel existiert noch nicht; mit
INSERT fortsetzen.
* Der übergebene Parameter
signalisiert, dass dieses der erste Datensatz mit
dem
* Anwender-bekannten-Schlüssel
ist.
* en:
* Data-Set with the
User-Known-Key does not already exist; go ahead with INSERT.
* The
passed parameter signals that this is the first Data-Set with the
User-Known-Key. */
internalInsert(
true
);
/*
* de:
Prüfen ob das INSERT fehlerfrei war; sonst Fehlerbehandlung
beginnen.
* en: Verify if the INSERT was ok; otherwise
start error-handling. */
if
(
StatusCode
!=
CONST_OK
)
{
rollbackDBConnection(bol_autocommit);
return
;
}
}
else
{
/*
* de:
* Ändern eines bestehenden Datensatzes.
* Im
Unterschied zu einer Standard-Implementierung einer BOS-Klasse,
zeichnet dieses BOS
* die durchgeführten
Änderungen nicht auf. Eine Änderungs-Historie für die
Größe und Position
* eines Frames
(Fensters) ist sinnlos und kostet nur Speicherplatz.
* en:
* Update of an existing dataset.
* Different
to a standard-implementation of a BOS-class, this BOS does not record
a history of changes.
* A history of changes in the
Frame-Positon and -Size is meaningless and just costs storage-space.
*/
/*
* de: Einen UPDATE für dieses BOS ausführen.
* en: Do an UPDATE for this BOS.
*/
internalUpdate();
/*
* de:
Prüfen ob die Datenbank-Operation fehlerfrei war; wenn nicht ein
'rollback' ausführen.
* en: Verify if the
database-operation was error-free; if not do a rollback.
*/
if
(
StatusCode
!=
CONST_OK
)
{
/*
* de:
Ändern des bestehenden Datensatzes ergaben Fehler; an die
aufrufende Methode melden.
* en: Updating existing
record failed; report it to the calling method.
*/
StatusMsg
=
"Unexpected
Error during update of existing record: "
+
StatusMsg
;
/*
* de: Ein 'rollback' ausführen und dann die
Methode beenden.
* en: Do a rollback and then end the
method.
*/
rollbackDBConnection(bol_autocommit);
return
;
}/*
* de:
Alle Datenbank-Operation waren bis jetzt fehlerfrei; Änderungen
bestätigen ('commit').
* en: All
database-operations were error-free till now; commit the changes.
*/
commitDBConnection(bol_autocommit);
}
}/*
* --------------------
* de:
* METHODE
(nur zur Verwendung innerhalb dieser Klasse) um die
CommonAttributes
* (allgemeine Attribute) aufzubereiten
und dann das DBA-Objekt, das die Daten
* in die
Datenbank einträgt, aufzurufen.
* Der übergebene
Parameter signalisiert, ob dieser der erste Datensatz
eines
* Business Objects ist. In diesem Fall werden
ObjectID, CreatedAt und CreatedBy
* mit Werten
gefüllt.
* en:
* METHOD (just for
usage within this class) to prepare the CommonAttributes and
* then
call the DBA object to insert the data into the database.
* The
passed parameter signals if this is the first dataset of a Business
Object.
* In that case, the ObjectID, CreatedAt and
CreatedBy attributes are filled. */
private
void
internalInsert(
boolean
parmFirstInsert)
{
/*
* de:
Attribute, die die zeitliche Gültigkeit des BO festlegen, mit
Werten füllen.
* en: Set the attributes defining
the time-validity of the BO. */
ValidFrom
= JSBS_BO_Services.getNewValidFrom(
structJSBS_MinimalParameters
);
ValidTill
= JSBS_BO_Services.getGoodTillCancelled_SQLDate();
/*
* de:
* Anwender, der die Änderung ausgeführt hat
und die Systemzeit der Änderung festlegen.
* en:
* Set the user who made the change and the system-time
when the change was made. */
ChangedBy
=
structJSBS_MinimalParameters
.
strUserName
;
ChangedAt
=
new
Timestamp(
new
Date().getTime());
/*
* de:
* Ein
Surrogat (interner Schlüssel) für den Datensatz ermitteln
und prüfen,
* ob dieses Surrogat nicht bereits ein
Primärschlüssel in der Datenbank-Tabelle ist.
* Wenn
der Datensatz der erste für ein BO ist, ist das Surrogat auch
der ObjectID des BO.
* en:
* Get a
surrogate for the DataSetID (which is the ObjectID too
* if
it is the first dataset for a BO) and check if the generated
surrogate is already
* a primary key in the
database-table. */
int
intTrialCounter
= 9;
do
{
/*
* de:
Methode, die ein surrogat innerhalb eines großen Wertebereichs
erzeugt, aufrufen.
* en: Call the method that generates
a surrogate with a widespread range. */
DataSetID
=
JSBS_BO_Services.generateSurrogate();
/*
* de:
* Datenbankzugriff ausführen um zu prüfen,
ob das gerade generierte Surrogat bereits
* verwendet
wird.
* en:
* Make a database-access to
check if the just generated surrogate is already used.
*/
boolean
locbolDataSetExists
=
structJSBS_Parameter_DBA
.selectByDataSetID(
structDBCon
,
this
.
DataSetID
);
if
(locbolDataSetExists)
{
/*
* de:
Seltener Fall, dass das generierte Surrogat bereits verwendet wird;
nochmals versuchen.
* en: Rare case that the generated
surrogate is already a key; try again.
*/
intTrialCounter--;
continue
;
}
else
{
/*
* de:
Prüfen ob bei der Datenbank-Operation ein Fehler aufgetreten
ist.
* en: Check if there was an error at the database
operation. */
if
(
structJSBS_Parameter_DBA
.
ErrorMsg
.length()
> 0) {
/*
* de:
Das DBA-Objekt meldet einen Fehler; Fehler-Meldung in dieses Objekt
übernehmen.
* en: DBA object reports an error;
transfer the Error-Message to this object. */
StatusCode
=
CONST_DB_SYSTEM_ERROR
;
StatusMsg
=
structJSBS_Parameter_DBA
.
ErrorMsg
;
return
;
}
/*
* de:
* Ein
Datensatz mit dem generierten Surrogat als Primärschlüssel
existiert noch nicht -
* Verarbeitung
fortsetzen.
* Wenn das Business Object das erste Mal in
die Datenbanktabelle aufgenommen wird:
* Werte für
ObjectID, CreatedAt und CreatedBy festlegen.
* en:
* A
dataset with the generated surrogate as primary key does not already
exist -
* continue processing.
* When
the Business Object is inserted for the first time into the
database-table:
* set the values for ObjectID,
CreatedAt and CreatedBy. */
if
(parmFirstInsert)
{
ObjectID
=
DataSetID
;
CreatedAt
=
ChangedAt
;
CreatedBy
=
ChangedBy
;
}/*
* de:
Übertragen der Werte dieses Business Objects in das
DBA-Objekt.
* en: Transfer the values of this Business
Object to the DBA object.
*/
setDBAAttributes(
structJSBS_Parameter_DBA
);
/*
* de:
* Methode des DBA Objekts aufrufen und das INSERT in
die Datenbank auf niederer
* Ebene ausführen.
* en:
* Call the method of the DBA object to do the database
INSERT on the low level.
*/
structJSBS_Parameter_DBA
.insert(
structDBCon
);
/*
* de:
Prüfen ob das INSERT in die Datenbank fehlerfrei war.
* en:
Check if the database INSERT was error-free. */
if
(
structJSBS_Parameter_DBA
.
ErrorMsg
.length()
> 0) {
/*
* de:
Fehlermeldung ist nicht leer, Fehler auf dieses Objekt
übertragen.
* en: Error-Message is not empty;
transfer the error to this object. */
StatusCode
=
CONST_DB_SYSTEM_ERROR
;
StatusMsg
=
structJSBS_Parameter_DBA
.
ErrorMsg
;
return
;
}
else
{
/*
* de:
Fehlermeldung ist leer; d.h. kein Fehler wurde vom DBA zurück
gemeldet.
* en: Error-Message is empty; i.e. no error
is reported by the DBA. */
return
;
}
}
}
while
(intTrialCounter
> 0);
/*
* de:
* Alle
der 9 generierten Surrogate sind bereits Primärschlüssel in
der Tabelle;
* Datenbank scheinbar voll; Fehler
melden.
* en:
* All of the 9 generated
surrogates were already primary key in the table;
* database
obviously full; report error. */
StatusCode
=
CONST_DB_UNKNOWN_ERROR
;
StatusMsg
=
"No
surrogate found after 9 trials; database-table obviously
full."
;
}/*
* --------------------
* de:
* METHODE
(nur zur Verwendung innerhalb dieser Klasse) um das DBA
Objekt
* aufzurufen, den bestehenden Datensatz mit den
Werten aus diesem
* Business Object zu füllen und
die geänderten Werte auf die Datenbank-Tabelle
* zu
schreiben.
* en:
* METHOD (just for usage
within this class) to call the DBA object to
* update
the existing dataset with the values of this Business Object.
*/
private
void
internalUpdate()
{
/*
* de:
Werte dieses Business Objects auf das DBA Objekt übertragen.
* en:
Transfer the values of this Business Object to the DBA object.
*/
setDBAAttributes(
structJSBS_Parameter_DBA
);
/*
* de:
* Aufrufen
der Methode des DBA-Objekts und den UPDATE auf der Datenbank
* auf
niederer Ebene ausführen.
* en:
* Call
the method of the DBA object to do the database UPDATE on the low
level.
*/
structJSBS_Parameter_DBA
.update(
structDBCon
);
/*
* de:
Prüfen ob der UPDATE auf der Datenbank fehlerfrei war.
* en:
Check if the database UPDATE was error-free. */
if
(
structJSBS_Parameter_DBA
.
ErrorMsg
.length()
> 0) {
/*
* de:
Fehlermeldung des DBA ist nicht leer; Fehler auf dieses Objekt
übertragen.
* en: Error-Message of the DBA is not
empty; transfer the error to this object. */
StatusCode
=
CONST_DB_SYSTEM_ERROR
;
StatusMsg
=
structJSBS_Parameter_DBA
.
ErrorMsg
;
return
;
}
}/*
* --------------------
* de:
* METHODE
zum Selektieren eines Datensatzes mit dem Primärschlüssel
(DataSetID).
* Mit dem Primärschlüssel der
Tabelle kann nur ein Datensatz gefunden werden.
* en:
* METHOD
to get the dataset identified by the primary key (DataSetID).
* With
the primary key of the table, only one dataset can be found.
*/
public
void
selectByDataSetID(
double
parmDataSetID)
{
/*
* de:
* Festlegen,
dass nur 'Read' Operation auf die Datenbank ausgeführt
werden;
* 'autocommit' setzen.
* en:
* Define
that there are only 'Read' operations to the database; set
'autocommit'. */
boolean
bol_autocommit
=
true
;
/*
* de:
Status-Variablen auf 'OK' setzen.
* en: Reset the
Status-variables to a state of OK. */
this
.
StatusCode
=
CONST_OK
;
this
.
StatusMsg
=
""
;
/*
* de:
Datenbank-Operation ausführen.
* en: Perform the
database-operation. */
if
(
structJSBS_Parameter_DBA
.selectByDataSetID(
structDBCon
,
parmDataSetID)) {
/*
* de:
Angeforderter Datensatz vorhanden; Werte vom DBA auf dieses BO
übertragen.
* en: Requested dataset exists;
transfer the value from the DBA object to this BO.
*/
getDBAAttributes(
structJSBS_Parameter_DBA
);
/*
* de:
* Methode,
die entscheidet ob ein 'Commit' auszuführen ist und es wenn
notwendig
* ausführt, aufrufen und Methode
beenden.
* en:
* Call the method deciding
if a 'commit' is needed, and performing it,
* and end
the method.
*/
commitDBConnection(bol_autocommit);
return
;
}
else
{
/*
* de:
* Prüfen
ob die Operation fehlerfrei war und kein Datensatz gefunden
wurde
* oder ein Fehler aufgetreten
ist.
* en:
* Verify if the operation was
error-free and no dataset was found
* or an error
occured. */
if
(structJSBS_Parameter_DBA.
ErrorMsg
.length()
<= 0) {
/*
* de:
* Fehlermeldung
ist leer; das bedeutet, dass mit den Suchkriterien kein
* Datensatz
gefunden wurde.
* en:
* Error-Message is
empty; means that no dataset was found with the search criteria.
*/
StatusCode
=
CONST_NOT_FOUND
;
StatusMsg
=
""
;
/*
* de:
* Methode,
die entscheidet ob ein 'Rollback' auszuführen ist und es wenn
notwendig
* ausführt, aufrufen und Methode
beenden.
* en:
* Call the method deciding
if a 'rollback' is needed, and performing it,
* and
end the method.
*/
rollbackDBConnection(bol_autocommit);
return
;
}
else
{
/*
* de:
Fehlermeldung ist nicht leer; Fehlermeldung auf dieses BO
übertragen.
* en: Error-Message is not empty;
transfer the error-message to this BO. */
StatusCode
=
CONST_DB_SYSTEM_ERROR
;
StatusMsg
=
structJSBS_Parameter_DBA.
ErrorMsg
;
/*
* de:
* Methode,
die entscheidet ob ein 'Rollback' auszuführen ist und es wenn
notwendig
* ausführt, aufrufen und Methode
beenden.
* en:
* Call the method deciding
if a 'rollback' is needed, and performing it,
* and
end the method.
*/
rollbackDBConnection(bol_autocommit);
return
;
}
}
}
/*
* --------------------
*
de:
* METHODE zum Selektieren des Datensatzes der durch den
Anwender-bekannten Schlüssel
* (Hostname) festgelegt
ist.
* Per Definition kann zu einem Zeitpunkt nur ein
gültiger Datensatz gefunden werden.
* en:
* METHOD
to select the dataset identified by the User-Known-Key
* (Hostname).
* As there is only one
valid dataset for the given date only one dataset can be found.
*/
public
void
selectByHostname(String
parmHostname) {
/*
de:
* Per Definition gibt es in dieser Methode nur
'Lese'-Operation auf die Datenbank;
* aus Gründen der
Performanz wird deswegen 'autocommit' eingeschalten.
* en:
* Define that there are only 'Read' operations to the
database; set 'autocommit' to gain
* performance of the
database-system. */
boolean
bol_autocommit
=
true
;
/*
de: Status-Variable auf 'OK' setzen.
* en: Set the
Status-variables to a state of OK. */
this
.
StatusCode
=
CONST_OK
;
this
.
StatusMsg
=
""
;
/*
de: Datenbank-Operation ausführen.
* en: Perform the
database-operation. */
if
(
structJSBS_Parameter_DBA
.selectByUserKnownKey(
structDBCon
,
structJSBS_MinimalParameters
,
CONST_PARAMETER_NAME
,
parmHostname)) {/*
de: Gesuchter Datensatz existiert; übertragen der Werte vom DBA
in dieses BO.
* en: Requested dataset exists; transfer the
values from the DBA object to this BO.
*/
getDBAAttributes(
structJSBS_Parameter_DBA
);
/*
de:
* Commit ausführen (notwendig für einige
Datenbank-Systeme obwohl es keine Änderungen
* zu
bestätigen gibt weil die Verbindung mit 'readonly' eröffnet
wurde).
* en:
* Commit (necessary for some
DB-Systems although there is no commit as the Connection was
*
opened 'ReadOnly').
*/
commitDBConnection(bol_autocommit);
return
;
}
else
{
/*
de:
* Prüfen ob die Operation fehlerfrei war und nur
der gesuchte Datensatz nicht gefunden wurde
* oder ob ein
Fehler aufgetreten ist.
* en:
* Verify if the
operation was error-free and the searched dataset was not found
* or
an error occured. */
if
(
structJSBS_Parameter_DBA
.
ErrorMsg
.length()
<= 0) {
/*
de: Fehler-Nachricht ist 'leer'; bedeutet dass der gesuchte Datensatz
nicht gefunden wurde.
* en: Error-Message is empty; means
that no dataset was found with the search criteria.
*/
StatusCode
=
CONST_NOT_FOUND
;
StatusMsg
=
""
;
/* de:
*
Rollback ausführen (notwendig für einige Datenbank-Systeme
obwohl es keine Änderungen
* zu bestätigen gibt
weil die Verbindung mit 'readonly' eröffnet wurde).
*
en:
* Rollback (necessary for some DB-Systems although there
is no commit as the Connection was
* opened 'ReadOnly').
*/
rollbackDBConnection(bol_autocommit);
return
;
}
else
{
/*
de: Error-Message ist nicht leer; übertragen der Fehler-Meldung
auf dieses BO.
* en: Error-Message is not empty; transfer
the error-message to this BO. */
StatusCode
=
CONST_DB_SYSTEM_ERROR
;
StatusMsg
=
structJSBS_Parameter_DBA
.
ErrorMsg
;
/* de:
*
Rollback ausführen (notwendig für einige Datenbank-Systeme
obwohl es keine Änderungen
* zu bestätigen gibt
weil die Verbindung mit 'readonly' eröffnet wurde).
*
en:
* Rollback (necessary for some DB-Systems although there
is no commit as the Connection was
* opened 'ReadOnly').
*/
rollbackDBConnection(bol_autocommit);
return
;
}
}
}
/*
* --------------------
*
de:
* METHODE zum Selektieren des Datensatzes der durch die
TCP/IP-Adresse festgelegt ist.
* -----
*
Bemerkung:
* Die TCP/IP-Adresse wird alternativ als
eindeutige Identifikation verwendet wenn
* ein 'Hostname'
nicht aus dem Betriebssystem ermittelt werden kann.
* Per
Definition kann dabei zu einem Zeitpunkt nur ein gültiger
Datensatz gefunden werden.
* en:
* METHOD
to select the dataset identified by the TCP/IP-address.
*
-----
* Remark:
* The TCP/IP-address is used as
unique identification alternatively if a 'Hostname'
* can
not be derived from the operating-system.
* In that
case there is (per definition) only one valid dataset for the given
date;
* therefore only one dataset can be found.
*/
public
void
selectByTCPIP_Address(String
parmTCPIP_Address) {
/*
de:
* Per Definition gibt es in dieser Methode nur
'Lese'-Operation auf die Datenbank;
* aus Gründen der
Performanz wird deswegen 'autocommit' eingeschalten.
* en:
* Define that there are only 'Read' operations to the
database; set 'autocommit' to gain
* performance of the
database-system. */
boolean
bol_autocommit
=
true
;
/*
de: Status-Variable auf 'OK' setzen.
* en: Set the
Status-variables to a state of OK. */
this
.
StatusCode
=
CONST_OK
;
this
.
StatusMsg
=
""
;
/*
de: Datenbank-Operation ausführen.
* en: Perform the
database-operation. */
if
(
structJSBS_Parameter_DBA
.selectByValue02(
structDBCon
,
structJSBS_MinimalParameters
,
CONST_PARAMETER_NAME
,
parmTCPIP_Address)) {/*
de: Gesuchter Datensatz existiert; übertragen der Werte vom DBA
in dieses BO.
* en: Requested dataset exists; transfer the
values from the DBA object to this BO.
*/
getDBAAttributes(
structJSBS_Parameter_DBA
);
/*
de:
* Commit ausführen (notwendig für einige
Datenbank-Systeme obwohl es keine Änderungen
* zu
bestätigen gibt weil die Verbindung mit 'readonly' eröffnet
wurde).
* en:
* Commit (necessary for some
DB-Systems although there is no commit as the Connection was
*
opened 'ReadOnly').
*/
commitDBConnection(bol_autocommit);
return
;
}
else
{
/*
de:
* Prüfen ob die Operation fehlerfrei war und nur
der gesuchte Datensatz nicht gefunden wurde
* oder ob ein
Fehler aufgetreten ist.
* en:
* Verify if the
operation was error-free and the searched dataset was not found
* or
an error occured. */
if
(
structJSBS_Parameter_DBA
.
ErrorMsg
.length()
<= 0) {
/*
de: Fehler-Nachricht ist 'leer'; bedeutet dass der gesuchte Datensatz
nicht gefunden wurde.
* en: Error-Message is empty; means
that no dataset was found with the search criteria.
*/
StatusCode
=
CONST_NOT_FOUND
;
StatusMsg
=
""
;
/* de:
*
Rollback ausführen (notwendig für einige Datenbank-Systeme
obwohl es keine Änderungen
* zu bestätigen gibt
weil die Verbindung mit 'readonly' eröffnet wurde).
*
en:
* Rollback (necessary for some DB-Systems although there
is no commit as the Connection was
* opened 'ReadOnly').
*/
rollbackDBConnection(bol_autocommit);
return
;
}
else
{
/*
de: Error-Message ist nicht leer; übertragen der Fehler-Meldung
auf dieses BO.
* en: Error-Message is not empty; transfer
the error-message to this BO. */
StatusCode
=
CONST_DB_SYSTEM_ERROR
;
StatusMsg
=
structJSBS_Parameter_DBA
.
ErrorMsg
;
/* de:
*
Rollback ausführen (notwendig für einige Datenbank-Systeme
obwohl es keine Änderungen
* zu bestätigen gibt
weil die Verbindung mit 'readonly' eröffnet wurde).
*
en:
* Rollback (necessary for some DB-Systems although there
is no commit as the Connection was
* opened 'ReadOnly').
*/
rollbackDBConnection(bol_autocommit);
return
;
}
}
}/*
* --------------------
*
de:
* METHODE zum Übertragen der Attributs-Werte des
Data-Base-Access (DBA) Objekts
* das diesem Business-Object
thematisch am nächsten ist auf die Variablen dieses BO.
*
en:
* METHOD
to transfer the attribute-values from the Data-Base-Access (DBA)
Object
* that is closest to this Business Object to the
variables of this BO. */
public
void
getDBAAttributes(JSBS_Parameter_DBA
parmJSBS_Parameter_DBA) {
/*
*
de:
* Methode der geerbten Superklasse (JSBS_BO) aufrufen um
die Werte der
* Allgemeinen Attribute (Common Attributes) zu
übertragen.
* en:
* Call the method of
the inherited superclass (JSBS_BO) to transfer the values of the
* Common Attributes.
*/
getCommonDBAAttributes(parmJSBS_Parameter_DBA);
/*
*
de: Geschäftsbezogene Werte dieses Business Object
übertragen.
* en: Transfer the business specific values
of this Business Object. */
this
.
Hostname
=
parmJSBS_Parameter_DBA.
Value01
;
this
.
TCPIP_Address
=
parmJSBS_Parameter_DBA.
Value02
;
this
.
Value06
=
parmJSBS_Parameter_DBA.
Value06
;
this
.
Value07
=
parmJSBS_Parameter_DBA.
Value07
;
this
.
Value08
=
parmJSBS_Parameter_DBA.
Value08
;
this
.
Value09
=
parmJSBS_Parameter_DBA.
Value09
;
this
.
Value10
=
parmJSBS_Parameter_DBA.
Value10
;
this
.
Value11
=
parmJSBS_Parameter_DBA.
Value11
;
this
.
Value12
=
parmJSBS_Parameter_DBA.
Value12
;
this
.
Value13
=
parmJSBS_Parameter_DBA.
Value13
;
this
.
Value14
=
parmJSBS_Parameter_DBA.
Value14
;
this
.
Value15
=
parmJSBS_Parameter_DBA.
Value15
;
this
.
Value16
=
parmJSBS_Parameter_DBA.
Value16
;
this
.
Value17
=
parmJSBS_Parameter_DBA.
Value17
;
this
.
Value18
=
parmJSBS_Parameter_DBA.
Value18
;
this
.
Value19
=
parmJSBS_Parameter_DBA.
Value19
;
this
.
Value20
=
parmJSBS_Parameter_DBA.
Value20
;
}}
Die Methoden dieser Klasse werden nur von Methoden innerhalb des JavaScout Basis-Systems aufgerufen und sind nicht für eine allgemeine Verwendung gedacht.
Dokument |
Inhalt |
Dieser Leitfaden
enthält die notwendigen Tätigkeiten für die
Entwicklung eines StartFrame (auch als Command-Center
bekannt). |