|
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;
/*
*
de: Package mit den Klassen für das DBA-
(DataBase-Access-) Object.
* en: Package with the
classes for the DBA- (DataBase-Access-) object. */
import
js_base.dba.*;
/*
*
de: Package mit den Klassen für BO (Business-Objects) und
allgemeinen Status-Codes.
* en: Package with the
classes for BO (Business-Objects) and common status-codes. */
import
js_base.bo.*;
/*
*
de: Package mit den Klassen für den server-seitigen Teil
der BO (Business-Objects).
* en: Package with the
classes for the server-side part of BO (Business-Objects). */
import
js_base.bos.*;
/*
*
de:
* JSBS-Package und Klasse mit der
Daten-Struktur mit den minimal notwendigen Parametern.
*
Diese Struktur enthält das Arbeits-Datum des Client-Teils.
*
en:
* JSBS-package and class with the
data-structure containing the minimum set of parameters.
*
This structure contains the working-date of the
client-part. */
import
js_base.structures.JSBS_MinimalParameters;
/**
*
* @author kurt(at)javascout[biz]
* @date
2011-10-14
*
* @description
*
de:
* Server-seitiger Teil des Sets mit Business
Objects für das 'Country' / Land.
*
*
Eine Beschreibung der Variablen und des Anwender-bekannten Schlüssels
finden Sie in der
* geerbten Generellen BO-Klasse.
*
*
en:
* Server-Side
Derivation of a set with Business Objects for the 'Country'.
*
* For the variables and the user-known key
please refer to the inherited BO-class.
*
* @change-log
*
when who why
*
--------------------------------------------------------
*
*/public
class
JSBS_Country_BOS
extends
JSBS_Country_BO
{
/*
*
VARIABLE / VARIABLES.
* -------------------- *//*
*
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. */
public
JSBS_MinimalParameters
structJSBS_MinimalParameters
=
null
;
/*
*
de:
*
Referenz zur bestehenden Verbindung zur Datenbank.
*
Dieser Werte muss von der aufrufenden Methode als Parameter übergeben
werden
*
wenn diese Klasse 'konstruiert' wird.
*
en:
*
Reference to the established connection to the database.
* This
value has to be passed by the calling method when this class is
constructed. */
public
Connection
structDBCon
=
null
;
/*
*
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 an 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:
*
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_Country_BOS(JSBS_MinimalParameters
parmMinParm,
Connection
parmDBCon) {/*
*
de:
* Aufrufen der Methode, die das Übernehmen der
Parameter in die Variable dieser
* Klasse ausführt.
*
en:
* Call the method written to do the transfer of the
parameters to the variables
* of this class.
*/
constructionWithDBConnection(parmMinParm,
parmDBCon);
/*
*
de:
* Setzen des Merkers dass das Objekt nicht
von
einem BOC oder EJB konstruiert wurde.
* Überlegung zu
der Entscheidung, den Wert auf 'false' zu setzen – auch wenn das
unlogisch scheinen mag:
*
* + Wenn
dieses BOS-Objekt innerhalb eines anderen BOS konstruiert wird, ist
es zeitsparend und
* und einfacher
verständlich, diese 'Constructor' Methode ohne weiteren Parameter
aufzurufen.
* Mit
dem folgenden Kommando wird jenes Flag gesetzt, das ein zu frühes
Ausführen eines 'commit' oder
* 'rollback'
innerhalb einer Transaktion verhindert.
* + Wenn
dies BOS-Objekt innerhalb eines BOC oder EJB konstruiert wird, dann
ist zu erwarten, dass
* das BOC oder EJB
von einem Design-Pattern (Muster) kopiert wurde.
* In
dem Design-Pattern ist schon der Aufruf des passenden 'Constructors'
mit dieser Variable als
* Parameter
enthalten und damit wird die hier codierte 'Constructor'-Methode
nicht aufgerufen.
*
*
en:
* Set the flag signalling that the object was not
constructed by a BOC or EJB.
*
* Consideration
for the decision to set the value to 'false' – even that seems not
to be logically well-founded:
* + When this
BOS-object is constructed within another BOS it saves time and it is easier
to understand to call this
* method
without a further parameter.
* The
following code sets the flag to prevent a too early 'commit' or
'rollback' within a transaction.
* + If
this BOS was constructed within a BOC or EJB, then it can be
expected, that the constructing BOC
* or
EJB has been copied from a design-pattern.
* This
design-pattern already incorporates the call of the 'fitting'
constructor with this variable
* as
a parameter – therefore this constructor-method is not called
.
*/
bolObjectConstructedByBOC_or_EJB
=
false
;
}/*
* --------------------
*
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_Country_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) und ein BO der gleichen Klasse
(aus dem die Werte der Variablen übernommen werden)
* als
Parameter übergeben werden.
*
en:
* CONSTRUCTOR
* when an existing (and
open!) Connection to the database-system and a BO of the same class
(which
* values of the variables will be transferred to
this BO) is passed. */
public
JSBS_Country_BOS(JSBS_MinimalParameters
parmMinParm,
Connection
parmDBCon,
JSBS_Country_BO
parmJSBS_Country_BO) {/*
*
de:
* Aufrufen der Methode, die das Übernehmen der
Parameter in die Variable dieser
* Klasse ausführt.
*
en:
* Call the method written to do the transfer of the
parameters to the variables
* of this class.
*/
constructionWithDBConnection(parmMinParm,
parmDBCon);
/*
*
de:
* Aufrufen der Methode, die das Übernehmen der Werte
der Variablen aus dem als Parameter übergebenen
* Objekt
in die Variablen dieses Objekts ausführt.
*
en:
* Call the method written to do the transfer of the
variable-values of the object passed as parameter
* to the
variables of this object.
*/
copyFromJSBS_Country_BO(parmJSBS_Country_BO);
/*
*
de:
* Setzen des Merkers dass das Objekt nicht
von
einem BOC oder EJB konstruiert wurde.
* Überlegung zu
der Entscheidung, den Wert auf 'false' zu setzen – auch wenn das
unlogisch scheinen mag:
*
* + Wenn
dieses BOS-Objekt innerhalb eines anderen BOS konstruiert wird, ist
es zeitsparend und
* und einfacher
verständlich, diese 'Constructor' Methode ohne weiteren Parameter
aufzurufen.
* Mit
dem folgenden Kommando wird jenes Flag gesetzt, das ein zu frühes
Ausführen eines 'commit' oder
* 'rollback'
innerhalb einer Transaktion verhindert.
* + Wenn
dies BOS-Objekt innerhalb eines BOC oder EJB konstruiert wird, dann
ist zu erwarten, dass
* das BOC oder EJB
von einem Design-Pattern (Muster) kopiert wurde.
* In
dem Design-Pattern ist schon der Aufruf des passenden 'Constructors'
mit dieser Variable als
* Parameter
enthalten und damit wird die hier codierte 'Constructor'-Methode
nicht aufgerufen.
*
*
en:
* Set the flag signalling that the object was not
constructed by a BOC or EJB.
*
* Consideration
for the decision to set the value to 'false' – even that seems not
to be logically well-founded:
* + When this
BOS-object is constructed within another BOS it saves time and it is easier
to understand to call this
* method
without a further parameter.
* The
following code sets the flag to prevent a too early 'commit' or
'rollback' within a transaction.
* + If
this BOS was constructed within a BOC or EJB, then it can be
expected, that the constructing BOC
* or
EJB has been copied from a design-pattern.
* This
design-pattern already incorporates the call of the 'fitting'
constructor with this variable
* as
a parameter – therefore this constructor-method is not called
.
*/
bolObjectConstructedByBOC_or_EJB
=
false;
}/*
* --------------------
*
de:
* CONSTRUCTOR
* der verwendet wird wenn eine
bestehende (und geöffnete!) Verbindung zur Datenbank
*
(Connection) und ein BO der gleichen Klasse (aus dem die Werte der
Variablen übernommen werden)
* als Parameter übergeben
werden.
*
Als zusätzlicher Parameter wird ü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 and a
BO of the same class (which
* values of the variables will
be transferred to this BO) is passed.
* Additionally, there
is a parameter signalling that this object is constructed by a BOC or
EJB. */
public
JSBS_Country_BOS(JSBS_MinimalParameters
parmMinParm,
Connection
parmDBCon,
JSBS_Country_BO
parmJSBS_Country_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:
* Aufrufen der Methode, die das Übernehmen der Werte
der Variablen aus dem als Parameter übergebenen
* Objekt
in die Variablen dieses Objekts ausführt.
*
en:
* Call the method written to do the transfer of the
variable-values of the object passed as parameter
* to the
variables of this object.
*/
copyFromJSBS_Country_BO(parmJSBS_Country_BO);
/*
*
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 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()
{
/*
* de:
* Wenn
dieses BOS-Objekt nicht in einem BOC oder EJB konstruiert wurde, dann
wird diese
* Methode hier beendet weil das commit in
einer 'darüber liegenden' Methode ausgeführt wird.
* en:
* If
this BOS-object has not been constructed in a BOC or EJB, this method
will end here.
* The commit will be performed in a
method 'above'.. */
if
(!
bolObjectConstructedByBOC_or_EJB
)
return
;
/*
* 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
{
/*
* de:
* Prüfen
ob die Verbindung zur Datenbank im 'AutoCommit' Modus geöffnet
wurde. Dann ist ein
* explizites Commit nicht
notwendig.
* Ein Beenden der Methode bei 'autocommit'
verbessert die Performanz.
* en:
* Verify
if the DB-connection was not opened as 'autocommit'.
* In
that case a commit is not needed
* Ending the method
when 'autocommit' was chosen enhances the performance. */
if
(!
structDBCon
.getAutoCommit())
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
=
JSBS_BO.
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();
}
}/*
* --------------------
* 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.
*
Generell wäre ein 'rollback' nicht notwendig weil auf ein Set von
Business Objects
*
keine Veränderung ausgeführt wird.
*
Durch Fehler in der Methode die diese Klasse konstruiert kann es aber
vorkommen, dass
*
die 'Connection' zur Datenbank nicht mit 'autocommit' geöffnet wurde
und dann tritt bei
*
verschiedenen DB-Systemen ein Fehler auf wenn kein 'commit' oder
'rollback' ausgeführt
*
wird bevor die 'Connection' zur Datenbank wieder beendet wird.
*
Der Code in dieser Methode ist ein 'Sicherheitsnetz' um den Zugriff
auf die DB auf
*
jeden Fall korrekt zu beenden.
*
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.
* Generally, a 'rollback'
would not be necessary as there are no changes made
* toward
a set of business objects.
* As a faulty programming
might happen in the method that constructs this class,
* there
might be the 'connection' to the database was not opened with
'autocommit'.
* In that case, an error might be
signalled by some database-systems when the
* 'connection'
to the database ends without a previous 'commit' or
'rollback'.
* The code of this method is a 'safety-net'
to secure a correct end of the
* database-connection
in any case. */
private
void
rollbackDBConnection()
{
/*
* 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'
innerhalb einer try/catch-Logik ausführen damit ein eventueller
Fehler beim
* 'Rollback' abgefangen werden kann.
* en:
* Run the 'rollback' within the try/catch-logic to be
able to handle a potential error. */
try
{
/*
* de:
* Prüfen
ob die Verbindung zur Datenbank im 'AutoCommit' Modus geöffnet
wurde. Dann ist ein
* explizites Commit nicht
notwendig.
* Ein Beenden der Methode bei 'autocommit'
verbessert die Performanz.
* en:
* Verify
if the DB-connection was not opened as 'autocommit'.
* In
that case a commit is not needed
* Ending the method
when 'autocommit' was chosen enhances the performance. */
if
(!
structDBCon
.getAutoCommit())
structDBCon
.rollback();
}
catch
(SQLException
SQLExc) {
/*
* de:
* Fehler
im Datenbank-System während des 'rollback';
* Fehler
an die aufrufende Methode zurück liefern.
* en:
* Error
of the database-system during 'rollback'; report the error to the
calling method. */
StatusCode
=
JSBS_BO.
CONST_DB_SYSTEM_ERROR
;
StatusMsg
=
SQLExc.getMessage();
}
}/*
* --------------------
* de:
* METHODE
zum Übertragen der Variablen-Werte 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 des Namens der virtuellen Tabelle.
* en:
Transfer the name of the virtual table.
*/
parmJSBS_Parameter_DBA.
ParameterName
=
this
.
CONST_PARAMETER_NAME
;
/*
* de:
Übertragen der geschäfts-spezifischen Attribute dieses Business
Object.
* en: Transfer the business specific attributes
of this Business Object. */
parmJSBS_Parameter_DBA.Value01
=
this
.
ISOCountryCode
;
parmJSBS_Parameter_DBA.Value02
=
this
.
LanguageCodeForLabelling
;
/*
* de:
* Die Werte für die 20 Marker, die das Land für
einzelne 'Themenbereiche'
* (diese sind im
Anwendungsprogramm bestimmt; z.B. Adressen von Kunden,
* Adressen von Zulieferern)
* erlauben,
werden komprimiert in einem Attribut der Datenbank-Tabelle
gespeichert.
* Für das komprimieren wird eine eigenen
Methode aufgerufen.
* en:
* The values
for the 20 Marker (flags), permitting the Country for singular
'areas'
* (which are defined within the
application-program; e.g. adresses of customers,
* adresses of suppliers) are stored in a
compressed string within one attribute
* of the
database-table. */
parmJSBS_Parameter_DBA.Value03
=
compressMarkerSet();
/* *** */
parmJSBS_Parameter_DBA.Value06
=
this
.
CountryName
;
parmJSBS_Parameter_DBA.Value07
=
this
.
VAT_Rule
;
parmJSBS_Parameter_DBA.Value08
=
this
.
PostalCountryCode
;
}
/*
* --------------------
* 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:
* Die Standard-Werte für zeitliche Gültigkeit des BO
festlegen und die Methode
* aufrufen, die das Einfügen
in die Datenbank erledigt.
* en:
* Get
the values for the (default) time-validity of the BO and call the
method
* which does the real work to insert into the
database.
*/
internalInsert(parmFirstInsert,
JSBS_BO_Services.getNewValidFrom(
structJSBS_MinimalParameters
),
JSBS_BO_Services.getGoodTillCancelled_SQLDate());
}/*
* --------------------
* 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,
java.sql.Date
parmValidFrom,
java.sql.Date
parmValidTill) {
/*
* de:
Zeitliche Gültigkeit des BO aus den Parametern übernehmen.
* en:
Get the time-validity of the BO from the parameters.
*/
ValidFrom
= parmValidFrom;
ValidTill
= parmValidTill;
/*
* 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 within 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:
* Methode zum Eintragen des Datensatzes mit
vollständig aufbereiteten Attributs-Werten
* in die
DB-Tabelle aufrufen.
* en:
* Call the
method to insert a dataset with completly conditioned
attribute-values
* into the database-table.
*/
internalInsert();
/*
* de:
INSERT in die Datenbank-Tabelle abgeschlossen; Methode
beenden.
* en: INSERT into the database-table
completed; end this method. */
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) zum Einfügen
eines
* Datensatzes in die Datenbank-Tabelle wenn alle
Attributs-Werte vollständig
* aufbereitet
sind.
* en:
* METHOD (just for usage
within this class) to insert a dataset with completely
* conditioned
attribute-values into the database-table. */
private
void
internalInsert()
{
/*
* 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
;
}
/*
* de:
* Fehlermeldung ist leer; d.h. kein Fehler wurde vom
DBA zurück gemeldet.
* Methode beenden.
* en:
* Error-Message is empty; i.e. no error is reported by
the DBA.
* End this method.
*/
}/*
* --------------------
* de:
* METHODE
(nur zur Verwendung innerhalb dieser Klasse) um ein DBA Objekt
* mit
den Werten aus diesem Business Object zu füllen und die geänderten
Werte
* auf die Datenbank-Tabelle zu
schreiben.
* Diese Methode ist sehr einfach weil die
Geschäftslogik in der nach
* 'außen sichtbaren'
Methode 'store()' enthalten ist.
* en:
* METHOD
(just for usage within this class) to supply the DBA object with the
* values of this Business Object and write the changed
values to the database-table
* This method is pretty
simple as the business-logic is contained in the method
* 'store()'
which is 'visible from outside'. */
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
;
}
}/*
* --------------------
* 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.
* Diese
Methode ist speziell für den Abgleich von Daten bei einer
MobileClient-Version
* vorgesehen.
* Mit
dieser Methode wird ermöglicht zu prüfen, ob der Primärschlüssel
(DataSetID)
* des auf dem MobileClient einzufügenden
BO bereits auf der Datenbank-Tabelle existiert
* und
wenn nötig kann der DataSetID des bestehenden Datensatzes durch
einen neuen Wert
* ersetzt werden. Das kann notwendig
werden, wenn bei einem MobileClient während des
* asynchronen
Betriebs ein Primärschlüssel generiert wurde der auch auf dem
Server
* generiert wurde. In dieser Methode wird der
Fall geprüft und wenn notwendig wird in
* der Methode
'synchronizedStoreWithPrimaryKeyChange(...)' der Wert für den
DataSetID
* am MobileClient geändert.
* 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.
* This method is especially written for the
synchronization of data when
* a MobileClient-version
is used.
* This method allows to check if the
primary-key (DataSetID) of the BO to be inserted at
* the
database-table at the MobileClient already exists at the
database-table and,
* if needed, the value of the
DataSetID can be replaced by a new value.
* This might
be necessary when the MobileClient was running asynchronous and a
* primary-key was generated with the same value as a
primary-key on the server.
* Within this method, this
case is checked and, if needed, the DataSetID at
* the
MobileClient will be replaced within the method
* 'synchronizedStoreWithPrimaryKeyChange(...)'.
*/
public
synchronized void
synchronizedStore(
double
parmDataSetIDToSelect)
{
/*
* de:
Status-Variablen auf 'OK' setzen.
* en: Set the
Status-variables to a state of 'OK'. */
this
.
StatusCode
=
CONST_OK
;
this
.
StatusMsg
=
""
;
/*
* de:
* Prüfen ob der Primärschlüssel (DataSetID)
geändert werden soll und in diesem Fall
* die dafür
vorgesehene Methode aufrufen.
* en:
* Verify
if the primary-key (DataSetID) has to be changed and call the
provided
* method in that case. */
if
((parmDataSetIDToSelect
!= 0) && (
this
.
DataSetID
!=
parmDataSetIDToSelect))
{
synchronizedStoreWithPrimaryKeyChange(parmDataSetIDToSelect);
return
;
}/*
* de:
* Ein
eigenes BOS erstellen und damit prüfen, ob bereits ein Datensatz mit
gleichem Primärschlüssel
* existiert. Ein eigenes
BOS ist notwendig weil sonst beim Lesen die Werte in diesem
BOS
* überschrieben würden
* en:
* Create
an own BOS and use it to verify, if a dataset with the same
primary-key already
* exists. An own BOS is needes as
otherwise the values within this BOS would be overwritten.
*/
JSBS_Country_BOS
existingJSBS_Country_BOS =
new
JSBS_Country_BOS(
structJSBS_MinimalParameters
,
structDBCon
,
false
);
existingJSBS_Country_BOS.selectByDataSetID(
this
.
DataSetID
);
/*
* de:
* Abhängig davon, ob bereits ein Datensatz mit
gleichem Primärschlüssel existiert
* diesen Ändern
oder einen neuen Datensatz einfügen.
* en:
* Depending on an existing dataset with the same
primary-key, change this dataset
* or insert a new
dataset. */
switch
(existingJSBS_Country_BOS.
StatusCode
)
{
case
JSBS_BO.
CONST_OK
:
/*
de: BO mit gesuchtem DataSetID gefunden; dieses BO verändern.
*
en: BO with requested DataSetID found; change this BO. */
internalUpdate();
break
;
case
JSBS_BO.
CONST_NOT_FOUND
:
/*
de: BO mit gesuchtem DataSetID nicht gefunden; dieses BO in die
Datenbank einfügen.
* en: BO with requested DataSetID not
found; insert this BO into the database. */
internalInsert();
break
;
default
:
/*
* de:
Datenbankfehler aufgetreten; diese Methode nicht fortsetzen.
* en:
Database-Error happened; do not go on with this method.
*/
StatusCode
=
existingJSBS_Country_BOS
.StatusCode
;
StatusMsg
=
existingJSBS_Country_BOS
.StatusMsg
;
rollbackDBConnection();
return
;
}/*
* de:
Einfügen oder Ändern auf der Datenbank fehlerfrei.
* en:
Insert or Update on the database without an error.
*/
commitDBConnection();
}/*
* --------------------
* de:
* METHODE
zum Speichern der Werte in den Variablen dieses Business Object in
der/den
* Datenbank-Tabelle/n wobei auch der
Primärschlüssel (DataSetID) geändert wird.
* Diese
Methode ist speziell für den Abgleich von Daten bei einer
MobileClient-Version
* vorgesehen.
* Diese
Methode ist notwendig, wenn bei einem MobileClient während des
asynchronen
* Betriebs ein Primärschlüssel generiert
wurde der auch auf dem Server generiert wurde.
* In
diesem Fall muss auf dem MobileClient der Primärschlüssel
(DataSetID) geändert
* werden bevor der Datensatz vom
MobileClient auf den Server (oder umgekehrt)
* kopiert
wird.
* Diese Methode prüft, ob der neue
Primärschlüssel noch nicht verwendet wird.
* Falls
auch der neue Primärschlüssel bereits verwendet wird, wird die
Methode
* 'changePrimaryKey()' - in der der
Primärschlüssel geändert wird - aufgerufen.
* en:
* METHOD
to store the values of the variables from this Business Object
* into the database-table(s)with a change of the
primary-key (DataSetID).
* This method is especially
written for the synchronization of data when
* a
MobileClient-version is used.
* This method is needed
when during the asynchronous operation of a MobileClient
* a
primary-key was generated at the MobileClient and the same value was
generated
* at the server.
* At that
case, the primary-key (DataSetID) at the MobileClient has to be
changed
* before the dataset ist copied from the
MobileClient to the server or vice-versa.
* This method
verifies if the new primary-key is not already used.
* If
a dataset with the new primary-key already exists, the primary-key is
changed
* again by calling the method
'changePrimaryKey()'. */
private
synchronized void
synchronizedStoreWithPrimaryKeyChange(
double
parmDataSetIDToSelect)
{
/*
* de:
* Ein
eigenes BOS erstellen und damit prüfen, ob bereits ein Datensatz mit
gleichem Primärschlüssel
* existiert. Ein eigenes
BOS ist notwendig weil sonst beim Lesen die Werte in diesem
BOS
* überschrieben würden
* en:
* Create
an own BOS and use it to verify, if a dataset with the same
primary-key already
* exists. An own BOS is needes as
otherwise the values within this BOS would be overwritten.
*/
JSBS_Country_BOS
existingJSBS_Country_BOS =
new
JSBS_Country_BOS(
structJSBS_MinimalParameters
,
structDBCon
,
false
);
/*
* de:
* 'Ewige' for-Schleife zum Prüfen ob der neue
Primärschlüssel (this.DataSetID) noch nicht
* bei
einem Datensatz existiert bzw. Ändern des Primärschlüssels bei dem
Datensatz, der
*
den überprüften Primärschlüssel
verwendet.
* en:
* 'Eternal' for-loop to
verify if the new primary-key (this.DataSetID) does not exist
* on
another dataset. Otherwise change the primary-key at the dataset that
uses the
* primary-key the check was for.
*/
for
(;;)
{
/*
* de:
Mit der Abfrage prüfen, ob der Primärschlüssel schon verwendet
wird.
* en: Verify if the primary-key is already used.
*/
existingJSBS_Country_BOS.selectByDataSetID(
this
.
DataSetID
);
/*
* de:
* Abhängig davon, ob bereits ein Datensatz mit dem
Primärschlüssel existiert oder nicht,
* wird die
weitere Verarbeitung gesteuert.
* en:
*
Depending if a dataset with the primary-key already exists or not,
the further processing
*
is controlled. */
switch
(existingJSBS_Country_BOS.
StatusCode
)
{
case
JSBS_BO.
CONST_NOT_FOUND
:
/*
de:
* Datensatz mit dem gleichen Primärschlüssel
existiert nicht.
* Übertragen der Werte der Variablen
dieses BO auf die Attribute des DBA-Objektes.
* en:
*
Dataset with the same primary-key does not exist.
* Transfer
the values of the variables of this BO to the attributes of the
DBA-object. */
setDBAAttributes(
structJSBS_Parameter_DBA
);
/*
de:
* Aufrufen der Methode, die das SQL-UPDATE in der
Datenbank-Tabelle ausführt.
* en:
* Call the
method that performs the SQL-UPDATE in the database-table. */
structJSBS_Parameter_DBA
.update(
structDBCon
,
parmDataSetIDToSelect);
/*
de:
* Prüfen, ob bei der Datenbank-Operation ein Fehler
aufgetreten ist.
* en:
* Verify if an error
occured at the database operation. */
if
(structJSBS_Parameter_DBA.
ErrorMsg
.length()
> 0) {
/*
* de:
* DBA-Objekt meldet einen Fehler;
* Status-Code
setzen und Fehlermeldung aus dem DBA-Objekt übernehmen.
* en:
* DBA-object reports an error;
* set the
status-code and transfer the error-message from the DBA-object.
*/
StatusCode
=
CONST_DB_SYSTEM_ERROR
;
StatusMsg
= structJSBS_Parameter_DBA.
ErrorMsg
;
}
/*
de:
* UPDATE abgeschlossen, Methode beenden.
* en:
* UPDATE done; end the Method. */
return
;
/*
de:
* Seltener Fall, dass am MobileClient ein Datensatz mit
einem Primärschlüssel
* (DataSetID) existiert der gleich
ist wie der eines anderen BO am Server.
* Austauschen des
Wertes des DataSetID am BO auf dem MobileClient (dieses BO).
*
en:
* Rare case that a dataset on the MobileClient has the
same primary-key (DataSetID)
* as another BO alredy on the
server.
* Exchange the value of the DataSetID of the BO of
the MobileClient (this BO). */
case
JSBS_BO.
CONST_OK
:
/*
de: Methode aufrufen die die Änderung des DataSetID-Wertes
vornimmt.
* en: Call the method that performs the changing of
the value of the DataSetID. */
existingJSBS_Country_BOS.changePrimaryKey();
/*
de:
* Prüfen
ob in der aufgerufenen Methode ein Fehler aufgetreten ist.
*
In diesem Fall den Status übernehmen und diese Methode beenden.
*
en:
* Verify
if an error occured within the called method.
*
In that case transfer the status and end this method. */
if
(existingJSBS_Country_BOS.
StatusCode
!=
JSBS_BO.
CONST_OK
)
{
StatusCode
=
existingJSBS_Country_BOS
.StatusCode
;
StatusMsg
=
existingJSBS_Country_BOS
.StatusMsg
;
return
;
}
break
;
default
:
/*
* de:
Datenbankfehler aufgetreten; diese Methode nicht fortsetzen.
* en:
Database-Error happened; do not go on with this method.
*/
StatusCode
=
existingJSBS_Country_BOS
.StatusCode
;
StatusMsg
=
existingJSBS_Country_BOS
.StatusMsg
;
return
;
}
}
}/* ---------------------
* de:
* METHODE
zum Ändern des Primärschlüssels (DataSetID) bei einem bestehenden
Datensatz.
* Dieser sehr seltene Fall kann nur dann
eintreten wenn gleichzeitig auf dem mobilen Client
* und
dem Server der gleiche Primärschlüssel für verschiedene
Business-Objects vergeben wurde.
* Dann muss auf der
Datenbank des mobilen Clients der Primärschlüssel geändert
werden.
* en:
*
METHOD to change the primary-key (DataSetID) at an existing
dataset.
*
This very rare case might happen if simultaneously the same
primary-key was given to
*
different BO on the MobileClient and at the server. So the
primary-key has to bechanged
*
on the database of the MobileClient. */
protected
synchronized void
changePrimaryKey()
{
/*
* de:
*
Aufheben des bestehenden Primärschlüssels um später den zu
ändernden Datensatz wieder
* von der Datenbank lesen zu
können.
* en:
*
Keep the existing primary key to be able to reread the dataset to be
changed from
*
the database again later.
*/
double
dblOriginalDataSetID
= this.
DataSetID
;
/*
* de:
* Holen
eines Surrogates (künstlicher Schlüssel) über die entsprechende
Methode
* und Prüfen, ob das Surrogat bereits als Wert
für einen 'DataSetID' verwendet wurde.
* Dabei werden
maximal 9 Versuche durchgeführt einen 'ungebrauchten' Wert zu
finden.
* en:
*
Get a surrogate with the adjacent method and verify if the surrogate
is already
*
used as value for a 'DataSetID'. A maximum of 9 trials are done to
find an
*
'unused' value.
*/
int
intTrialCounter
= 9;
do
{
/*
de:
* Methode, die eine weit gestreute Zufallszahl
liefert, aufrufen.
* en:
*
Call the method that generates a random number in a widesoread range.
*/
DataSetID
=
JSBS_BO_Services.generateSurrogate();
/*
de:
* Datenbankzugriff zum Prüfen ob dieses Surrogat
bereits als Primärschlüssel benutzt wird.
* en:
*
Database-access to check if this surrogate is already used as a
primary-key.
*/
boolean
locbolDataSetExists
=
structJSBS_Parameter_DBA
.selectByDataSetID(
structDBCon
,
this
.
DataSetID
);
/*
de:
* Prüfen ob der seltene Fall eingetreten ist, dass
das Surrogat bereits verwendet wird.
* en:
*
Check for the rare case that this surrogate is already in use.
*/
if
(locbolDataSetExists)
{
/*
de:
* Reduzieren des Zählers der noch durchzuführenden
Versuche und
* wieder am Anfang der Schleife beginnen.
* en:
*
Reduce the counter for the remaining trials and start at the begin of
the loop.
*/
intTrialCounter--;
continue
;
}
else
{
/*
de:
* Vor dem weiterarbeiten prüfen ob nicht ein
Fehler beim DB-Zugriff aufgetreten ist.
* Ein Fehler
wird durch eine nicht leere Error-Message signalisiert.
* en:
* Check if an error occured at the
access to the database before processing is continued.
* An
error is signalled by a non-empty error-message. */
if
(
structJSBS_Parameter_DBA
.
ErrorMsg
.length()
> 0) {
/*
de:
* DBA-Objekt meldet einen Fehler.
* Status-Code
setzen und Fehler-Meldung aus dem DBA-Objekt
übernehmen.
* en:
* DBA-object reports
an error.
* Set the status-code an transfer the
error-message from the DBA-object.
*/
StatusCode
=
CONST_DB_SYSTEM_ERROR
;
StatusMsg
=
structJSBS_Parameter_DBA
.
ErrorMsg
;
/*
de: Verarbeitung abbrechen.
* en: End the processing.
*/
return
;
}/*
de:
* DBA-Objekt mit generiertem Surrogat existiert
noch nicht.
* Für dieses BO ein UPDATE auf der Datenbank
ausführen.
* en:
* DBA-object with the
generated surrogate does not already exist.
* Perform an
update on the database for this BO.
*/
setDBAAttributes(structJSBS_Parameter_DBA
);
/*
de:
* Aufrufen der Methode die das SQL-UPDATE in der
DB-Tabelle ausführt.
* en:
* Call the method
that performs the SQL-UPDATE on the database-table.
*/
structJSBS_Parameter_DBA
.update(
structDBCon
,
dblOriginalDataSetID);
/*
* de:
* Prüfen
ob bei der DB-Operation ein Fehler aufgetreten ist.
* en:
*
Check if an error occured during the database-operation.
*/
if
(
structJSBS_Parameter_DBA
.
ErrorMsg
.length()
> 0) {
/*
de:
* DBA-Objekt meldet einen Fehler.
* Status-Code
setzen und Fehler-Meldung aus dem DBA-Objekt
übernehmen.
* en:
* DBA-object reports
an error.
* Set the status-code an transfer the
error-message from the DBA-object.
*/
StatusCode
=
CONST_DB_SYSTEM_ERROR
;
StatusMsg
=
structJSBS_Parameter_DBA
.
ErrorMsg
;
}/*
de: UPDATE abgeschlossen; Methode beenden.
* en:
UPDATE done; end the method.
*/
return
;
}
}
while
(intTrialCounter
> 0);
}/*
* --------------------
* 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 of the object
were changed and an UPDATE has to be done. */
public
synchronized void
store()
{
/*
* de:
* Aufrufen der Methode in der geprüft wird, ob die Daten
des BO konsistent sind.
* en:
* Call the
method to check the consistency of the data of this BO.
*/
if
(!
isConsistentData())
return
;
/*
* de:
Status-Variablen auf 'OK' (fehlerfrei) setzen.
* en:
Set the Status-variables to a state of 'OK' (error-free).
*/
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
dem
* gleichen Anwender-bekannten-Schlüssel noch nicht
existiert für das aktuelle Datum.
* 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. */
boolean
locboolDataSetExists
=
structJSBS_Parameter_DBA
.selectByUserKnownKey(
structDBCon
,
structJSBS_MinimalParameters
,
this
.
CONST_PARAMETER_NAME
,
this
.
ISOCountryCode
,
this
.
LanguageCodeForLabelling
);
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();
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();
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();
return
;
}
}
else
{
/*
* de:
* Die
Änderung eines Wertes einer Geschäfts-relevanten-Variable ist
erfolgt.
* Das Gültigkeitsende
('ValidTill')
des
aktuell gültigen Datensatzes wird auf den Tag vor
* dem
Arbeitsdatum (ein Parameter aus dem minimalen Set der Parameter)
gesetzt.
* Das ist das Zeichen, dass der Datensatz
nicht länger gültig ist.
* Dann wird ein neuer
Datensatz mit dem gleichen ObjectID eingefügt,
* dessen
Gültigkeitsbeginn ('ValidFrom') das aktuelle Arbeitsdatum ist.
*
* en:
* Change of the value of a
business-relevant variable occured.
* The end of the
validity ('ValidTill') of the actually valid dataset is set to the
day
* before the working-date (a parameter from the minimum
set of parameters).
* That is an indication that the datasat
is no longer valid.
* Thereafter, a new dataset with the
same ObjectID and the actual work-date as
* start of the
validity ('ValidFrom'), which is the actual working-date, is inserted
*/
/*
* de:
* Zuerst
wird der aktuell gültige Datensatz gelesen um zu prüfen, ob ein
anderer
* Anwender in der Zwischenzeit eine Änderung
vorgenommen hat.
* Die Änderung könnte zwischen den
Zeitpunkten, als der gerade zu speichernde Datensatz
* gelesen
wurde (um die Daten anzuzeigen) und jetzt, wo die geänderten
Daten
* gespeichert werden sollen, passiert
sein.
*
* Zum Lesen des Vergleichs-BOS
wird ein neues BOS 'konstruiert' und dabei die
bestehende
* DB-Connection als Parameter übergeben.
*
* en:
* First, the actually valid dataset is
read to verify if another user made a change
* inbetween.
*
The change might have happened in the time between the dataset (which
changes are to be
* stored now) was read and now, where the
changed data has to be stored.
*
* To read the BOS
to compare, a new BOS is 'constructed' and the existing
DB-Connection
* is passed as a parameter.
*/
JSBS_Country_BOS existingJSBS_Country_BOS
=
new
JSBS_Country_BOS(
structJSBS_MinimalParameters
,
structDBCon
,
false
);
/*
* de:
* Datensatz
über den DatasetID lesen; das bringt den Datensatz der vor der
Ausführung
* der Änderung gelesen wurde.
*
en:
* Read
the dataset by the DataSetID; that gets the dataset as it was read
before the
*
changes were applied.
*/
existingJSBS_Country_BOS.selectByDataSetID(this
.
DataSetID
);
/*
* de:
* Mit
der aufgerufenen Methode muß ein Datensatz gefunden werden.
* Wenn
das nicht der Fall ist, dann eine Fehlerbehandlung durchführen.
*
en:
* A dataset must be found with the applied method. If
none is found an error-handling
*
must be done. */
if
(existingJSBS_Country_BOS.
StatusCode
!=
CONST_OK
)
{
/*
* de:
* Datensatz
nicht gefunden oder ein Fehler beim DB-Zugriff ist
aufgetreten.
* Status-Code in dieses Objekt übernehmen
und Fehlermeldung anpassen.
*
en:
* Dataset not found or an error occured when accessing
the database.
*
Transfer the Status-Code into this object and adapt the
error-message.
*/
this
.
StatusCode
=
existingJSBS_Country_BOS.
StatusCode
;
this
.
StatusMsg
=
"Unexpected
Error during re-read:"
+
existingJSBS_Country_BOS.StatusMsg
;
/*
* de:
* Rollback
ist nicht notwendig - aber in der aufgerufenen Methode ist auch
eine
* Prüfung ob die DB-Connection geschlossen werden
muss. Anschließend diese Methode beenden.
*
en:
* Rollback would not be neccesary - but in the called
method is a check, if the
* DB-Connection has to be closed,
too. End this method thereafter
*/
rollbackDBConnection();
return
;
}/*
* de:
* Datensatz
gefunden; so sollte es sein.
* Zuerst
prüfen ob die Gültigkeit des Datensatzes in der Zwischenzeit
beendet wurde.
* Das weist auf eine Veränderung des BO
hin.
*
en:
* Dataset
found; that should be the normal case.
*
First is a check if the validity ended inbetween.
That indicates a change of the BO. */
if
(
this
.differentValidTill(
existingJSBS_Country_BOS.ValidTill
)){
/*
* de:
* Anderer
Benutzer hat das BO inzwischen verändert.
*
en:
* Other
user changed the BO inbetween. */
this
.
StatusCode
=
CONST_CHANGED_INBETWEEN
;
this
.
StatusMsg
=
""
;
/*
* de:
* Rollback
ist nicht notwendig - aber in der aufgerufenen Methode ist auch
eine
* Prüfung ob die DB-Connection geschlossen werden
muss. Anschließend diese Methode beenden.
*
en:
* Rollback would not be neccesary - but in the called
method is a check, if the
* DB-Connection has to be closed,
too. End this method thereafter
*/
rollbackDBConnection();
return
;
}/*
* de:
* Noch
prüfen ob überhaupt ein Wert einer geschäfts-relevanten Variable
verändert wurde.
* Wenn keine Veränderung erfolgt ist
wird auch kein neuer Datensatz eingefügt.
*
en:
* Additionally
check if a value of a business-relevant variable was changed.
*
If no change happened, a new dataset will not be
inserted*/
if
(!
this
.isDifferent(existingJSBS_Country_BOS)){
/*
* de:
* Keine
Änderung eines Wertes einer geschäftsrelevanten Variable.
*
en:
* No
change of a value of a business-relevant variable.
*/
this
.
StatusCode
=
CONST_NOTHING_TO_UPDATE
;
this
.
StatusMsg
=
""
;
/*
* de:
* Rollback
ist nicht notwendig - aber in der aufgerufenen Methode ist auch
eine
* Prüfung ob die DB-Connection geschlossen werden
muss. Anschließend diese Methode beenden.
*
en:
* Rollback would not be neccesary - but in the called
method is a check, if the
* DB-Connection has to be closed,
too. End this method thereafter
*/
rollbackDBConnection();
return
;
}
/*
*
de:
* Gültigkeit des bestehenden Datensatzes als 'beendet'
markieren.
* Das wird durch einen Tag vor dem aktuellen
Arbeitsdatum im Attribut 'ValidTill' indiziert.
*
en:
* Mark the validity of the existing dataset as 'ended'.
* This is indicated by one day before the actual
working-date in the attribute 'ValidTill'.
*/
existingJSBS_Country_BOS.ValidTill
=
JSBS_BO_Services.getNewValidTill(structJSBS_MinimalParameters
);
/*
* de:
* Änderung
des bestehenden Datensatzes auf der DB-Tabelle durchführen.
*
en:
* Execute
the change of the existing dataset on the database-table.
*/
existingJSBS_Country_BOS.internalUpdate(
);
/*
* de:
* Prüfen
ob das Update fehlerfrei durchgeführt wurde.
* Wenn
das nicht der Fall ist, dann eine Fehlerbehandlung durchführen.
*
en:
* Check
if the update endet without an error.
*
If
that was not the case then do an error-handling.
*/
if
(existingJSBS_Country_BOS.
StatusCode
!=
CONST_OK
)
{
/*
* de:
* Datensatz
nicht gefunden oder ein Fehler beim DB-Zugriff ist
aufgetreten.
* Status-Code in dieses Objekt übernehmen
und Fehlermeldung anpassen.
*
en:
* Dataset
not found or an error occured during the access to the database.
*
Transfer the Status-Code into this object and adapt the
error-message. */
this
.
StatusCode
=
existingJSBS_Country_BOS.
StatusCode
;
this
.
StatusMsg
=
"Unexpected
Error during update of existing record: "
+
existingJSBS_Country_BOS.StatusMsg
;
/*
* de:
* Rollback
ausführen; in der aufgerufenen Methode wird (wenn notwendig) die
DB-Connection geschlossen.
* Anschließend Methode
beenden.
*
en:
* Perform a rollback; the DB-connection is closed (if
needed) within the called method.
*
End the method thereafter.
*/
rollbackDBConnection();
return
;
}
/*
*
de:
* Als letzte Datenbank-Operation einen neuen
Datensatz mit den aktuellen Werten in die
* Datenbank-Tabelle
einfügen. Der Parameter (false) teilt der Methode mit, dass der
* Datensatz eine Änderung eines bestehenden BO ist.
* en:
* As last database-operation,
insert a new dataset with the actual values into the
* datebase-table. The parameter (false) 'tells' the
method, that the inserted dataset
* is a change of an
existing BO. */
internalInsert(
false
);
/*
* 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:
* Status für dieses BO wurde in der
Methode 'internalInsert(...)' in die passenden Variablen
*
übertragen. Rollback einleiten und Methode beenden.
* en:
* Status for this BO was transferred to the associated
variables within the method
* 'internalInsert(...)'.
Do a rollback and end this method.
*/
rollbackDBConnection();
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();
}
}/*
* --------------------
* de:
* METHODE
zum Selektieren eines speziellen Datensatzes (als Teil eines BO) für
einen
* gegebenen DataSetID. Diese Methode wird zum Lesen
eines einzigen Datensatzes verwendet.
* Dieser Datensatz ist
Teil der Veränderungs-Historie des BO.
* en:
* METHOD
to select one specified dataset (as part of a BO) for a given
DataSetID.
* This Method is used to read a single
Dataset. This dataset is a part of the change-history
* of a
BO. */
public
synchronized void
selectByDataSetID(
double
parmDataSetID)
{
/*
* de:
Status-Variablen auf 'OK' setzen.
* en: Reset the
Status-variables to a state of OK. */
this
.
StatusCode
=
JSBS_BO.
CONST_OK
;
this
.
StatusMsg
=
""
;
/*
* de:
Datenbank-Operation ausführen.
* en: Perform the
database-operation. */
if
(structJSBS_Parameter_DBA.selectByDataSetID(
structDBCon
,
parmDataSetID)) {
/*
* de:
* Datensatz existiert und wurde fehlerfrei
gelesen.
* Methode aufrufen die die Werte des DBA auf
das BO überträgt.
* en:
* Dataset exists
and reading ended without an error.
* Call the method
that transfers the values from the DBA to the 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.
* End the
method thereafter. */
commitDBConnection();
return
;
}
else
{
/*
* de:
*
Kein entsprechender Datensatz gefunden oder ein Fehler ist beim
Datenbank-Zugriff aufgetreten.
* Ursache weiter
untersuchen.
* en:
* No fitting dataset found
or an error occured during the access to the database..
*
Investigate further for the cause.
*/
if
(structJSBS_Parameter_DBA.
ErrorMsg
.length()
< 1) {
StatusCode
=
JSBS_BO.
CONST_DB_SYSTEM_ERROR
;
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();
return
;
}
else
{
/*
* de:
*
DBA-Objekt meldet einen Fehler; Status-Code setzen und Fehler-Meldung
aus dem
* DBA-Objekt übernehmen.
* en:
*
DBA-object reports an error; set the status-code and transfer the
error-message
* from the DBA-object.
*/
StatusCode
=
JSBS_BO.
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();
return
;
}
}
}
/*
* --------------------
* de:
* METHODE
zum Selektieren jenes Datensatzes (als Teil eines BO, das durch den
Wert in 'parmObjectID'
* eindeutig identifiziert ist) der
zum aktuellen Arbeitsdatum gültig ist.
* en:
* METHOD
to select the dataset (as part of a BO which is unique identified by
the value in
* 'parmObjectID') which is valid at the actual
working-date. */
public
synchronized void
selectByObjectID(
double
parmObjectID)
{
/*
* de:
Status-Variablen auf 'OK' setzen.
* en: Reset the
Status-variables to a state of OK. */
this
.
StatusCode
=
JSBS_BO.
CONST_OK
;
this
.
StatusMsg
=
""
;
/*
* de:
Datenbank-Operation ausführen.
* en: Perform the
database-operation. */
if
(structJSBS_Parameter_DBA.selectByObjectID(
structDBCon
,
structJSBS_MinimalParameters
,
parmObjectID)) {
/*
* de:
* Datensatz existiert und wurde fehlerfrei
gelesen.
* Methode aufrufen die die Werte des DBA auf
das BO überträgt.
* en:
* Dataset exists
and reading ended without an error.
* Call the method
that transfers the values from the DBA to the 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.
* End the
method thereafter. */
commitDBConnection();
return
;
}
else
{
/*
* de:
*
Kein entsprechender Datensatz gefunden oder ein Fehler ist beim
Datenbank-Zugriff aufgetreten.
* Ursache weiter
untersuchen.
* en:
* No fitting dataset found
or an error occured during the access to the database..
*
Investigate further for the cause.
*/
if
(structJSBS_Parameter_DBA.
ErrorMsg
.length()
< 1) {
StatusCode
=
JSBS_BO.
CONST_DB_SYSTEM_ERROR
;
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();
return
;
}
else
{
/*
* de:
*
DBA-Objekt meldet einen Fehler; Status-Code setzen und Fehler-Meldung
aus dem
* DBA-Objekt übernehmen.
* en:
*
DBA-object reports an error; set the status-code and transfer the
error-message
* from the DBA-object.
*/
StatusCode
=
JSBS_BO.
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();
return
;
}
}
}
/*
* --------------------
* de:
* METHODE
zum Selektieren jenes Datensatzes (als Teil eines BO, das durch die
Werte in den
* Parametern eindeutig identifiziert ist) der
zum aktuellen Arbeitsdatum gültig ist.
* en:
* METHOD
to select the dataset (as part of a BO which is unique identified by
the values in
* the parameters) which is valid at the
actual working-date. */
public
synchronized void
selectByUserKnownKey(
String
parmISOCountryCode, String parmLanguageCodeForLabelling)
{
/*
* de:
Status-Variablen auf 'OK' setzen.
* en: Reset the
Status-variables to a state of OK. */
this
.
StatusCode
=
JSBS_BO.
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
,
parmISOCountryCode, parmLanguageCodeForLabelling)) {
/*
* de:
* Datensatz existiert und wurde fehlerfrei gelesen.
* Methode aufrufen die die Werte des
DBA auf das BO überträgt.
* en:
* Dataset exists and reading ended
without
an error.
* Call the method that transfers the values
from the DBA to the 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.
* End
the method thereafter.
*/
commitDBConnection();
return
;
}
else
{
/*
* de:
* Kein entsprechender Datensatz gefunden oder ein Fehler ist beim Datenbank-Zugriff aufgetreten.
* Ursache weiter untersuchen.
* en:
* No fitting dataset found or an error occured during the access to the database.
* Investigate further for the cause.
*/
if
(structJSBS_Parameter_DBA.
ErrorMsg
.length()
< 1) {
StatusCode
=
JSBS_BO.
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();
return
;
}
else
{
/*
* de:
* DBA-Objekt meldet einen Fehler; Status-Code setzen und Fehler-Meldung aus dem
* DBA-Objekt übernehmen.
* en:
* DBA-object reports an error; set the status-code and transfer the error-message
* from the DBA-object.
*/
StatusCode
=
JSBS_BO.
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();
return
;
}
}
}
/*
* --------------------
* de:
* METHODE
zum Selektieren jenes Datensatzes (als Teil eines BO, das in der Sortierreihenfolge
* nach dem BO kommt, das durch die Werte in den
Parametern eindeutig identifiziert ist
)
* der zum aktuellen Arbeitsdatum gültig ist
.
* en:
* METHOD to select the
dataset (as part of a BO, that is in the sort-order after the BO which
* is unique identified by the values in
the parameters
) which is valid at the actual working-date. */
public
synchronized void
selectNext(
String parmISOCountryCode, String parmLanguageCodeForLabelling)
{
/*
* de:
Status-Variablen auf 'OK' setzen.
* en: Reset the
Status-variables to a state of OK. */
this
.
StatusCode
=
JSBS_BO.
CONST_OK
;
this
.
StatusMsg
=
""
;
/*
* de:
Datenbank-Operation ausführen.
* en: Perform the
database-operation.
*/
if
(
structJSBS_Parameter_DBA.selectNext(
structDBCon
,
structJSBS_MinimalParameters
,
CONST_PARAMETER_NAME
,
parmISOCountryCode, parmLanguageCodeForLabelling)) {
/*
* de:
* Datensatz existiert und wurde fehlerfrei gelesen.
* Methode aufrufen die die Werte des
DBA auf das BO überträgt.
* en:
* Dataset exists and reading ended
without
an error.
* Call the method that transfers the values
from the DBA to the 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.
* End
the method thereafter.
*/
commitDBConnection();
return
;
}
else
{
/*
* de:
* Kein entsprechender Datensatz gefunden oder ein Fehler ist beim Datenbank-Zugriff aufgetreten.
* Ursache weiter untersuchen.
* en:
* No fitting dataset found or an error occured during the access to the database.
* Investigate further for the cause.
*/
if
(structJSBS_Parameter_DBA.
ErrorMsg
.length()
< 1) {
StatusCode
=
JSBS_BO.
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();
return
;
}
else
{
/*
* de:
* DBA-Objekt meldet einen Fehler; Status-Code setzen und Fehler-Meldung aus dem
* DBA-Objekt übernehmen.
* en:
* DBA-object reports an error; set the status-code and transfer the error-message
* from the DBA-object.
*/
StatusCode
=
JSBS_BO.
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();
return
;
}
}
}
/*
* --------------------
* de:
* METHODE
zum Selektieren jenes Datensatzes (als Teil eines BO, das in der Sortierreihenfolge
* vor dem BO kommt, das durch die Werte in den
Parametern eindeutig identifiziert ist
)
* der zum aktuellen Arbeitsdatum gültig ist
.
* en:
* METHOD to select the
dataset (as part of a BO, that is in the sort-order before the BO which
* is unique identified by the values in
the parameters
) which is valid at the actual working-date. */
public
synchronized void
selectPrevious(
String parmISOCountryCode, String parmLanguageCodeForLabelling)
{
/*
* de:
Status-Variablen auf 'OK' setzen.
* en: Reset the
Status-variables to a state of OK. */
this
.
StatusCode
=
JSBS_BO.
CONST_OK
;
this
.
StatusMsg
=
""
;
/*
* de:
Datenbank-Operation ausführen.
* en: Perform the
database-operation.
*/
if
(
structJSBS_Parameter_DBA.selectPrevious(
structDBCon
,
structJSBS_MinimalParameters
,
CONST_PARAMETER_NAME
,
parmISOCountryCode, parmLanguageCodeForLabelling)) {
/*
* de:
* Datensatz existiert und wurde fehlerfrei gelesen.
* Methode aufrufen die die Werte des
DBA auf das BO überträgt.
* en:
* Dataset exists and reading ended
without
an error.
* Call the method that transfers the values
from the DBA to the 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.
* End
the method thereafter.
*/
commitDBConnection();
return
;
}
else
{
/*
* de:
* Kein entsprechender Datensatz gefunden oder ein Fehler ist beim Datenbank-Zugriff aufgetreten.
* Ursache weiter untersuchen.
* en:
* No fitting dataset found or an error occured during the access to the database..
* Investigate further for the cause.
*/
if
(structJSBS_Parameter_DBA.
ErrorMsg
.length()
< 1) {
StatusCode
=
JSBS_BO.
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();
return
;
}
else
{
/*
* de:
* DBA-Objekt meldet einen Fehler; Status-Code setzen und Fehler-Meldung aus dem
* DBA-Objekt übernehmen.
* en:
* DBA-object reports an error; set the status-code and transfer the error-message
* from the DBA-object.
*/
StatusCode
=
JSBS_BO.
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();
return
;
}
}
}
/*
* --------------------
* de:
* METHODE
zum 'Deaktivieren' dieses BO.
* 'Deaktivieren' bedeutet,dass die Gültigkeit des aktuell gültigenen Datensatzes und
* eventuell in Zukunft gültiger Datensätze beendet wird.
* Dazu wird in den Datensätzen, deren Wert im Attribut 'ValidTill' (Gültig bis Datum)
* gleich oder größer als das aktuelle Datum (dieses wurde beim 'Konstruieren' dieses
* Objekts als Teil der Struktur 'JSBS_MinimalParameters' übergeben) ist, der Wert in
* 'ValidTill' auf den Tag vor dem aktuellen Tag gesetzt.
* Zur Dokumentation wer (welcher Anwender) zu welcher Systemzeit das 'Deaktivieren'
* ausgeführt hat, wird ein neuer Datensatz eingefügt der mit dem aktuellen Datum beginnt
* und am Tag vor dem aktuellen Datum endet.
* en:
* METHOD
to 'deactivate' this BO.
* 'Deactivate' means, that the validity of the actual valid dataset and datasets
* that are potentially valid in the future will end.
* To achieve that, all datasets with a value in the attribute 'ValidTill' (date) that
* is equal or greater than the actual date (this was passed as a part of the structure
* 'JSBS_MinimalParameters' at the 'construction' of this object), the value of
* 'ValidTill' is set to the date before the actual day.
* To document who (which user) did the 'deactivate' at which system-time, a new dataset,
* which starts with the actual day and ends the day before, is inserted
. */
public
synchronized void
deactivate() {
/*
* de:
Status-Variablen auf 'OK' setzen.
* en: Reset the
Status-variables to a state of OK. */
this
.
StatusCode
=
JSBS_BO.
CONST_OK
;
this
.
StatusMsg
=
""
;
/*
* de:
* Prüfen ob das BO überhaupt deaktiviert werden darf oder ob noch Referenzen darauf
* vorhanden sind.
* Ein eventueller Fehlercode wird in der Methode 'isReferenced' gesetzt.
* en:
* Verify, if th
is BO is allowed to be deactivated or if there are still references
* to it exist.
* An occured error-code is set within the method 'isReferenced'.
*/
if
(isReferenced()) {
/*
* de:
* Das BO darf nicht deaktiviert werden weil es noch von einem anderen BO referenziert
* wird. Status-Code (warum das BO nicht deaktiviert werden darf) und Status-Message
* (üblicherweise der Anwender-Bekannte-Schlüssel des referenzierenden BO) werden in
* der Methode 'isReferenced' mit Werten versorgt.
* Ein Rollback wäre zwar nicht notwendig - in der aufgerufenen Methode wird aber auch
* geprüft, ob die DB-Connection geschlossen werden muss.
* Anschließend die Methode beenden
.
* en:
* The BO is not allowed to be deactivated as it is referenced by another BO.
* The status-code (why the BO is not allowed to be deactivated) and the status-message
* (usually the user-known-key of the referencing BO) is set within the method
* 'isReferenced'.
* Rollback would not be needed - but in the called method there is a check if the
* DB-connection has to be closed, too.
* End the method thereafter.
*/
rollbackDBConnection();
return
;
}
else
{
/*
* de:
* DBA-Set für den Zugriff auf die Datenbank-Tabelle
'konstruieren'.
* Mit diesem DBA-Set werden alle Datensätze für den ObjectID selektiert.
* en:
* 'Construct' the DBA-set for the
access to the database-table.
* With this DBA-set, all datasets for the ObjectID will be selected.
*/
JSBS_Parameter_DBA_Set structJSBS_Parameter_DBA_Set =
new
JSBS_Parameter_DBA_Set();
/*
* de:
Datenbank-Operation ausführen.
* en: Perform the
database-operation.
*/
structJSBS
_Parameter_DBA_Set.selectAllByObjectID(
structDBCon
,
this
.ObjectID);
/*
* de:
* Über die Länge des Textes mit einer eventuellen
Fehler-Nachricht prüfen, ob die
* Datenbank-Abfrage mit einem Fehler beendet wurde.
* en:
* Use
the text with a possible error-message to verify if the
database-access endet with
* an error. */
if
(
structJSBS
_Parameter_DBA_Set.
ErrorMsg
.length() > 0) {
/*
* de:
* DBA-Set
Objekt meldet einen Fehler.
* Status-Code setzen und
die Fehlermeldung aus dem DBA-Set auf dieses BOS
übernehmen.
* en:
* DBA-set object
reports an error.
* Set the status-code and transfer
the error-message to this BOS.
*/
StatusCode
=
JSBS_BO.
CONST_DB_SYSTEM_ERROR
;
StatusMsg
=
struct
JSBS_Parameter_DBA_Set.
ErrorMsg
;
/*
* de:
* Methode,
die entscheidet ob ein 'Rollback' auszuführen ist (und es wenn
notwendig
* ausführt) und wenn notwendig die DB-Connection schließt, aufrufen und Methode
beenden.
* en:
* Call the method deciding
if a 'rollback' is needed (and performing it if needed) and also
* closing the DB-Connection if needed. End the method thereafter.
*/
rollbackDBConnection();
return
;
}
/*
* de:
* Kein Fehler beim Datenbank-Zugriff aufgetreten; Set mit den Datensätzen weiter bearbeiten.
* Dazu Hilfs-Variablen für die Bearbeitung des Vectors definieren.
* en:
* No error ocurred at the access to the database; continue processing the set with the dataset.
* To do this, define auxilliary variables first.
*/
int
intDBA_Set_Size
=
struct
JSBS_Parameter_DBA_Set
.
vecRecordSet
.size();
int
intDBA_Set_
Index;
/*
*
de:
* Ein BOS definieren dessen Methoden später für das ordnungsgemäße 'Beenden' eines
* Datensatzes verwendet werden können.
* en:
* Define a BOS which methods can be used later for a correct 'termination' of a
* dataset. */
JSBS_Country_BOS struct
JSBS_Country_BO
S =
new
JSBS_Country_BOS(
structJSBS_MinimalParameters
,
structDBCon
);
/*
*
de:
* Datumswerte, die für Vergleiche gebraucht werden im java.sql.Date Format erstellen
* bzw. Werte in anderen Formaten gleich umwandeln.
* en:
* Define date-values that are needed for comparisons in the java.sql.Date-format or
* convert values in other formats, respectively. */
j
ava.sql.Date dteWorkDate =
new
java.sql.Date(
structJSBS_MinimalParameters
.
calWorkDate
.getTime().getTime());
j
ava.sql.Date dteReadValidTill;
/*
*
de:
* In einer for-Schleife jeden Datensatz untersuchen und bei Bedarf 'beenden'.
* en:
* Use a for loop to inspect each dataset and 'end' it if needed. */
for
(
intDBA_Set_
Index
= 0;
intDBA_Set_
Index
<
intDBA_Set_
Size;
intDBA_Set_
Index
++)
{
/*
*
de:
* Den durch den Index gewählten Datensatz in eine eigene
Variable übertragen.
* Damit kann er leichter
verarbeitet werden.
* en:
* Move
the dataset selected by the index to an own variable.
* This
allows an easier processing. */
structJSBS_Parameter_DBA
=
(JSBS_Parameter_DBA)
struct
JSBS_Parameter_DBA
_Set.
vecRecordSet
.elementAt(
intDBA_Set_
Index
);
/*
*
de:
* Letzten Tag der Gültigkeit ('ValidTill') in eine eigene Variable übertragen.
* Damit wird eine spätere Verarbeitung einfacher.
* en:
* Transfer the last day of validity ('ValidTill') to an own variable.
* That makes later processing easier. */
dteReadValidTill =
structJSBS_Parameter_DBA
.ValidTill
;
/*
*
de:
* Nur jene Datensätze 'deaktivieren' die am oder nach dem aktuellen Arbeits-Datum enden.
* en:
* 'Deactivate' only those datasets that end at or after the actual working-date. */
if
(
struct
JSBS_Parameter_DBA
_Set.endsAfterWorkDate(dteWorkDate, dteReadValidTill)
)
{
/*
*
de:
* Werte des DBA in das vorher 'konstruierte' BOS übernehmen. Grund für die Weiterarbeit mit dem BOS:
* In der BOS-Klasse sind schon alle Methoden implementiert die die Gültigkeit eines BO
* ordnungsgemäß beenden.
*
en:
*
Transfer the values of the DBA into the BOS 'constructed' earlier. Reason for using the BOS
* for further processing: The BOS-class has all methods implemented that take care for a correct end of
* the validity of a BO. */
structJSBS_Country_BOS.getDBAAttributes(
structJSBS_Parameter_DBA
);
/*
*
de:
* Ende der Gültigkeit des Datensatzes in Abhängigkeit vom aktuellen Arbeitsdatum setzen.
*
en:
* Set the value for the end of the validity of the dataset depending on the actual work-date
. */
structJSBS_Country_BOS.
ValidTill
=
JSBS_BO_Services.getNewValidTill(
structJSBS_MinimalParameters
);
/*
*
de:
* Status-Code initialisieren weil dieser bei einer 'internen' Methode nicht initialisiert wird.
*
en:
*
Initialize the status-code as this is not done at an 'internal' method
. */
structJSBS_Country_BOS.
StatusCode
= JSBS_BO.
CONST_OK
;
/*
*
de:
* Methode zum Ändern des Datensatzes auf der Datenbank-Tabelle aufrufen.
*
en:
*
Call the method to change the dataset on the database-table
. */
structJSBS_Country_BOS.internalUpdate()
;
/*
*
de:
* Prüfen, ob beim Update ein Fehler aufgetreten ist.
*
en:
*
Check if an error occured at the update
. */
if
(
structJSBS_Country_BOS.
StatusCode
!= JSBS_BO.
CONST_OK
)
{
/*
* de:
* Fehler-Code und Fehler-Meldung auf dieses BO
übernehmen.
* en:
* DBA-set object
reports an error.
* Transfer the status-code and transfer
the error-message to this BOS.
*/
StatusCode
=
structJSBS_Country_BOS.
StatusCode
;
StatusMsg
=
structJSBS_Country_BOS.
Status
Msg
;
/*
* de:
* Methode,
die entscheidet ob ein 'Rollback' auszuführen ist (und es wenn
notwendig
* ausführt) und wenn notwendig die DB-Connection schließt, aufrufen und Methode
beenden.
* en:
* Call the method deciding
if a 'rollback' is needed (and performing it if needed) and also
* closing the DB-Connection if needed. End the method thereafter.
*/
rollbackDBConnection();
return
;
}
/*
*
de:
* Neuen Datensatz mit der Information wer wann das BO 'deaktiviert' hat, einfügen.
*
en:
* Insert a new dataset with the information when the BO was 'deactivated' and who did it
. */
structJSBS_Country_BOS.internalInsert(
false
,
JSBS_BO_Services.getNewValidFrom(
structJSBS_MinimalParameters
)
,
JSBS_BO_Services.getNewValidTill(
structJSBS_MinimalParameters
)
)
;
/*
*
de:
* Prüfen, ob beim Insert ein Fehler aufgetreten ist.
*
en:
*
Check if an error occured at the update
. */
if
(
structJSBS_Country_BOS.
StatusCode
!= JSBS_BO.
CONST_OK
)
{
/*
* de:
* Fehler-Code und Fehler-Meldung auf dieses BO
übernehmen.
* en:
* DBA-set object
reports an error.
* Transfer the status-code and transfer
the error-message to this BOS.
*/
StatusCode
=
structJSBS_Country_BOS.
StatusCode
;
StatusMsg
=
structJSBS_Country_BOS.
Status
Msg
;
/*
* de:
* Methode,
die entscheidet ob ein 'Rollback' auszuführen ist (und es wenn
notwendig
* ausführt) und wenn notwendig die DB-Connection schließt, aufrufen und Methode
beenden.
* en:
* Call the method deciding
if a 'rollback' is needed (and performing it if needed) and also
* closing the DB-Connection if needed. End the method thereafter.
*/
rollbackDBConnection();
return
;
}
/*
*
de: Ende des 'if' zum Bearbeiten noch gültiger Datensätze.
*
en: End of the 'if' to process still valid datasets.
*/
}
/*
*
de: Ende der 'for'-Schleife.
*
en: End of the 'for'-loop.
*/
}
/*
* de:
* Änderungen auf der Datenbank ohne Fehler. Methode die das Commit ausführt und wenn
* notwendig die DB-Connection schließt, aufrufen und Methode
beenden.
* en:
* Changes on the database without errors. Call the method that executes the commit and
* also closing the DB-Connection if needed. End the method thereafter.
*/
commitDBConnection();
return
;
}
}
/*
* --------------------
* de:
* METHODE
zum Prüfen, ob auf dieses BO in einem anderen BO eine Referenz vorhanden ist.
*
* DIESE METHODE MUSS IN DER KLASSE IHRES ANWENDUNGSPROGRAMMS ÜBERSCHRIEBEN WERDEN !
* Hier in dieser Basisklasse kann der Code noch nicht 'wissen', in welchen BO Ihres
* Anwendungsprogramms das Land referenziert wird.
* Deswegen muss in Ihrerm Anwendungsprogramm eine spezifische Klasse implementiert
* werden in der diese Methode ('isReferenced()') um die speziellen Prüfungen auf
* Referenzen für das Datenmodell Ihres Anwendungsprogramms erweitert wird.
*
* Diese Methode dient dazu, zu prüfen, ob das BO 'deaktiviert' werden darf oder nicht.
* Nicht deaktiviert werden darf das BO wenn in einem anderen BO eine Inkonsistenz entstehen
* würde.
*
* en:
* METHOD to verify if a reference to this BO exists in another BO.
*
* THIS METHOD HAS TO BE OVERWRITTEN IN THE CLASS OF YOUR APPLICATION-PROGRAM.
* Within this base-class, the does not 'know' in which BO of your application-program
* the Country is referenced.
* Therefore, a specific class has to be implemented within your application-program in
* which this method ('isReferenced()') is extended by specific verifications for the
* references of the data-model of your application.
*
* This method serves
the purpose to check, if this BO is allowed to be 'deactivated' or not.
* The deactivation
is prohibited if this would lead to an inconsitency in another BO
. */
public boolean
isReferenced() {
/*
* de:
* Spezielle Prüfung für den Haupt-Eintrag eines Landes. Dieser ist erkennbar an einer leeren
* Zeichenkette in der Variable 'LanguageCodeForLabelling'.
* Nur für diesen wird die Prüfung auf Referenzierung durchgeführt.
* Alle anderen Einträge definieren nur die Bezeichnung (CountryName) in einer anderen Sprache
* und können sofort 'deaktiviert' werden.
* en:
* Special verification for the main-entry of a Country. This is recognised by an empty string
* in the variable 'LanguageCodeForLabelling'.
* Only for such an entry the verification for a reference is done.
* All other entries just define the CountryName in another language and can be 'deactivated'
* immediately. */
if
(
this
.
LanguageCodeForLabelling
.trim().length() > 0)
return false
;
/*
* de:
* Besonderheit bei diesem BO ist, dass der 'Haupt-Eintrag' für ein Land nicht deaktiviert
* werden darf wenn dazu noch ein Eintrag für die Bezeichnung in anderer Sprache vorhanden ist.
* Der 'Haupt-Eintrag' ist daran erkennbar, dass der Wert im 'LanguageCodeForLabelling' eine
* leere Zeichenkette ist.
* Der Haupt-Eintrag enthält die Standard-Bezeichnung für das Land (im Attribut 'CountryName')
* und die Marker, für welche Themenbereiche im Anwendungsprogramm das Land erlaubt ist.
*
* en:
* Specific feature of this BO is, that the 'main-entry' for a Country may not be 'deactivated'
* as long as an entry for the naming of the Country in another language exists.
* The 'main-entry' is identified by an emptry string as value in 'LanguageCodeForLabelling'..
* The main-entry contains the default naming of the Country (in the attribute 'CountryName')
* and the Marker, for which areas in the application-program this Country is permitted. */
/*
*
de:
* Ein BOS-Set definieren dessen Methoden für das Abfragen weiterer Datensätze verwendet wird.
* en:
* Define a BOS-Set which methods are used to select further datasets. */
JSBS_Country_BOS_Set structreferencing
JSBS_Country_BOS_Set
=
new
JSBS_Country_BOS_Set(
structJSBS_MinimalParameters
,
structDBCon
);
/*
*
de:
* Abfragen aller aktuell oder in Zukunft gültigen Datensätze mit dem gleichen Landes-Code wie
* dieses BO.
* en:
* Select all datasets with the same Country-code as this BO that are valid now or in the future. */
structreferencing
JSBS_Country_BOS_Set.selectValidAndFutureByISOCountryCode(
this
.
ISOCountryCode
);
/*
* de:
* Abfragen ob die Datenbank-Operation fehlerfrei war und abhängig davon
* die weitere Verarbeitung vornehmen.
* en:
* Check if the database-operation endet without an error and depending
* on that continue processing. */
switch
(
structreferencing
JSBS_Country_BOS_Set
.
StatusCode
)
{
case
JSBS_BO.
CONST_OK
:
/*
de:
* BO mit gesuchtem ISOCountryCode gefunden.
* Weiter prüfen, ob nur ein Datensatz (der hier bearbeitete) oder mehrere gefunden wurden.
*
en:
* BO with requested ISOCountryCode found.
* Continue with a check if only one dataset (the one processed here) or several were found. */
if
(
structreferencing
JSBS_Country_BOS_Set
.
vecRecordSet
.size() > 1) {
/*
de:
* Neben dem gerade bearbeiteten BO für den Haupteintrag existiert noch ein weiterer Datensatz.
* Bedingt durch die Abfrage muss das ein Datensatz für die Bezeichnung in einer weiteren
* Sprache sein. Status-Code setzen; dieser ist in der geerbten BO-Klasse definiert
.
*
en:
* Additionally to the just processed BO for the main-entry another dataset exists.
* Conditioned by the selection, this must be a dataset for the naming in another language.
* Set the Status-Code; the value is defined within the inherited BO-class. */
StatusCode
=
JSBS_Country_BO
.CONST_DEACTIVATE_INHIBIT_REASON_AdditionalLanguageLabelling
;
/*
* de:
* Zur Information des Anwenders den Sprach-Code für die Bezeichnung aus dem
* zweiten BO der Liste extrahieren und in der Fehlermeldung zurück liefern.
* en:
* For an information of the user, extract the Country-code for the labelling
* of the language from the second BO within the list und return it in the
* error-message.
*/
JSBS_Country_BO structreferencing
JSBS_Country_BO
=
(
JSBS_Country_BO)
structreferencing
JSBS_Country_BOS_Set
.
vecRecordSet
.elementAt(1);
StatusMsg
=
structreferencing
JSBS_Country_BO
.LanguageCodeForLabelling
;
return true
;
}
break
;
case
JSBS_BO.
CONST_NOT_FOUND
:
/*
de:
* Sollte nicht vorkommen weil zumindest der gerade bearbeitet Datensatz gefunden
* werden sollte. Trotzdem nicht abbrechen.
* en:
* Should not happen as at least the just processed dataset should be found.
* Do not end the method however. */
break
;
default
:
/*
* de:
Datenbankfehler aufgetreten; diese Methode nicht fortsetzen.
* en:
Database-Error happened; do not go on with this method.
*/
StatusCode
=
structreferencing
JSBS_Country_BOS_Set
.StatusCode
;
StatusMsg
=
structreferencing
JSBS_Country_BOS_Set
.StatusMsg
;
return true
;
}/*
* de: Wenn keine Referenz gefunden wurde dann wird hier die Methode beendet.
* en: If a reference was not found the method is ended here.
*/
return false
;
}
/*
* --------------------
* de:
* METHODE
zum Prüfen auf Konsistenz der Werte dieses BO.
*
* Diese Methode hat die Funktion einer 'Notbremse' die verhindert, dass ein BO
* mit in sich widersprüchlichen Werten in die Datenbank eingefügt wird.
* Nachdem der Zusammenhang der Werte im BO für das Land einfach ist, wird
* hier nur eine einfache Korrektur der 'Marker' vorgenommen wenn das BO nicht
* der 'Haupt-Eintrag' für ein Land ist.
* Die Korrektur der Marker erfolgt hier weil es in der Benutzeroberfläche
* komplizierter ist - besonders wenn der Benutzer zwischen einem Haupt-Eintrag
* und einem Eintrag für die Bezeichnung eines Landes in einer anderen Sprache
* wechselt.
*
* en:
* METHOD to verify the consistency of the values of a BO.
*
* This method has the function of an 'emergency brake' to avoid that a BO with
* inconsistent values is inserted into the database.
* As the relation of the values within the BO for the Country is simple, only a
* simple correction of the 'Marker' ist done if the BO is not the 'main-entry' for
* a Country.
* The correction of the Marker is done here because it is more difficult within the
* user-interface - particularly to keep the choice of the Markers if the user changes
* between the main-entry and an entry for naming the Country in a different language
. */
public boolean
isConsistentData() {
/*
* de:
* Spezielle Prüfung ob dieses BO nicht der Haupt-Eintrag eines Landes ist sondern 'nur'
* die Bezeichnung ('CountryName') in einer anderen Sprache.
* Bei so einem Eintrag haben die Werte der Marker keine Bedeutung.
* en:
* Special verification if this BO is not the main-entry of a Country but 'only'
* the 'CountryName' in another language.
* Within such an entry the values of the markers are meaningless. */
if
(
this
.
LanguageCodeForLabelling
.trim().length() > 0) {
this
.
Marker01
=
false
;
this
.
Marker02
=
false
;
this
.
Marker03
=
false
;
this
.
Marker04
=
false
;
this
.
Marker05
=
false
;
this
.
Marker06
=
false
;
this
.
Marker07
=
false
;
this
.
Marker08
=
false
;
this
.
Marker09
=
false
;
this
.
Marker10
=
false
;
this
.
Marker11
=
false
;
this
.
Marker12
=
false
;
this
.
Marker13
=
false
;
this
.
Marker14
=
false
;
this
.
Marker15
=
false
;
this
.
Marker16
=
false
;
this
.
Marker17
=
false
;
this
.
Marker18
=
false
;
this
.
Marker19
=
false
;
this
.
Marker20
=
false
;
/*
* de:
* Prüfen ob für diese zusätzlich definierte Landes-Bezeichnung
* auch ein Haupt-Eintrag existiert.
* Der anschließende Code ist ein zusätzliches Sicherheitsnetz wenn die Prüfung bei
* der Eingabe der Daten lückenhaft war.
* en:
* Verify a main-entry exists for this additionally defined country-name.
* The following code is an additional safety-net if the verification during entry
* of the data did not completely check the consistency.
*/
/*
* de:
* Ein BOS definieren mit dem der Haupt-Eintrag selektiert wird.
* en:
* Define a BOS used to select the main-entry.
*/
JSBS_Country_BOS struct
JSBS_Country_BOS =
new
JSBS_Country_BOS(
structJSBS_MinimalParameters
,
structDBCon
,
true
);
struct
JSBS_Country_BOS.selectByUserKnownKey(
this
.
ISOCountryCode
,
""
);
/*
* de:
* Prüfen ob der Haupt-Eintrag existiert bzw. Fehler behandeln.
* en:
* Verify if the main-entry exist or process the error, respectively.
*/
switch
(struct
JSBS_Country_BOS.
StatusCode
) {
case
JSBS_BO.
CONST_OK
:
/*
* de:
* Erwarteter Status; Haupt-Eintrag für das Land exisitert.
* en:
* Expected status; main-entry for the country exists.
*/
break
;
case
JSBS_BO.
CONST_NOT_FOUND
:
/*
* de:
* Haupt-Eintrag für das Land exisitert nicht; der hier geprüfte Eintrag für eine
* zusätzliche Bezeichnung in einer anderen Sprache darf nicht gespeichert werden.
* Fehler-Meldung erstellen und diese Methode beenden.
* en:
* Main-entry for the country does not exist; the entry (checked here) for an additional
* country-name in another language is not allowed to be stored.
* Create the error-message and end this method.
*/
this
.
StatusCode
= JSBS_Country_BO.
CONST_ERROR_No_Default_Dataset_For_ISOCountryCode
;
this
.
StatusMsg
=
""
;
return false
;
default
:
/*
* de:
* Ein anderer Fehler ist beim Zugriff auf die Datenbank aufgetreten.
* Status-Code und -Meldung auf dieses BO übernehmen und diese Methode beenden.
* en:
* Another error occured during the .
*/
this
.
StatusCode
=
struct
JSBS_Country_BOS.
StatusCode
;
this
.
StatusMsg
=
struct
JSBS_Country_BOS.
StatusMsg
;
return false
;
}
}
/*
* de:
* Aufrufen der Methode der geerbten Klasse in der die Konsistenz der allgemeinen Attribute
* (Common Attributes) geprüft wird.
* en:
* Call the method of the inherited base-class that verifies the consistency of the
* Common Attributes.
*/
if
(!
super
.isConsistentData())
return false
;
/*
* de:
* In der Methode wurden keine Prüfungen durchgeführt; als 'Konsistent' beenden.
* en:
* No verifications were done within this method;end as 'consistent'.
*/
return true
;
}
}
Diese
Klasse ist dazu vorgesehen von einer, speziell für ein Anwendungsprogramm entwickelten Klasse, 'geerbt' zu werden.
In der erbenden Klasse werden zusätzliche Prüfungen auf Fremdschlüssel-Referenzen des Landes implementiert.
Die Entwicklung der erbenden Klasse ist in den unter Verwandte Dokumentation gelisteten Dokumenten beschrieben.
Dokument |
Inhalt |
Muster-Code für die BO-Klassen zur Implementierung des Landes (JSBS_Country_BOx) |
Dieses Dokument enthält Muster-Code und Anleitungen wie erbende Klassen für dieses BO codiert werden. Diese erbenden Klassen enthalten Prüfungen, ob ein Land als Fremdschlüssel in einem anderen BO des zu entwickelden Anwendugsprogramms verwendet wird. |
Dieses Dokument bietet einen Überblick, wie die Vererbung dieser Klasse eingesetzt werden kann. |