|
Letzte Bearbeitung dieses Dokuments: |
Code
Erklärungen
und Anwendungsbeispiele
Verwandte
Dokumentation
package
js_base.boc;
/*
* de: Package und Klasse für das Bearbeiten eines
'Vector'.
* en: Package and class to manipulate a 'Vector'.
*/
import
java.util.Vector;
/*
* de: Package mit der Generellen Klasse für dieses BO.
* en: Package with the general class for this BO. */
import
js_base.bo.*;
/*
de:
* Package mit der Klasse für das StartFrame (aus dem
Parameter verwendet werden) und
* Methoden für die
Bearbeitung von JFrames.
* en:
* Package with the
class for the StartFrame (which delivers parameters needed) and
*
and methods to manipulate JFrames. */
import
js_base.frame.*;
/**
*
* @author kurt(at)javascout[dot]biz
* @date
2011-10-14
*
* @description
* de:
* Klasse für den Datenabgleich zwischen JAS (Java
Application Server) und lokaler Datenbank
* für Daten der Klasse JSBS_Country_BO
(Land).
*
* Diese Klasse ist notwendig wenn das Anwendungsprogramm
auch für die Version 'MobileClient'
* implementiert ist und damit die Daten zwischen lokaler
Datenbank des mobilen Client-Gerätes
* und den Daten auf dem JAS synchronisiert werden müssen.
*
-------------------
* en:
*
Class for the synchronization of date between JAS (Java
Application Server) and local databass
*
for data of class JSBS_Country_BO (
Country).
*
* This class is needed when the applicatio-program is
implemented for the version 'MobileClient',
* too. Then, the data between the local database on
the mobile client device and the database
* on the JAS have to be synchronized.
*
*
@change-log
*
when who why
*
--------------------------------------------------------
*
*/
public
class
JSBS_Country_BO_Synchronizer
extends Thread {
/* ---------------------
* VARIABLE dieser Klasse / VARIABLES of this
class.
* --------------------- */
/*
*
de:
* Referenz auf das Start-Frame (CommandCenter), das bei
der 'Konstruktion' eines Objekts
* dieser Klasse übergeben
wurde.
* Im StartFrame sind die Objekte für die Verbindungen zur
Datenbank und zum JAS enthalten.
* Weiters ist dort das aktuelle Arbeitsdatum definiert.
* en:
*
Reference to the Start-Frame (CommandCenter) that was passed during
the 'construction' an object
*
of this class.
* The StartFrame contains the objects for the connection to the
database and the JAS.
*
Further
it holds the actual working-date
. */
private
JSBS_StartFrame
frmCC
=
null
;
/*
*
de:
* Referenz auf das Task-Frame, das das Objekt dieser
Klasse 'konstruiert' hat.
* Dieses wird als Parameter beim 'Konstruieren' von BOC
(Client-side Teil der BO)
* benötigt.
* en:
*
Reference to the Task-Frame that 'constructed' an object of this
class.
* This reference is needed when BOC (client-side part of a BO)
are 'constructed'. */
private
JSBS_TaskFrame
frmTask
=
null
;
/*
*
de:
*
Vector mit den Allgemeinen Attributen (CommonAttributes) der BO, deren
Daten zwischen
*
lokaler Datenbank und JAS abgeglichen werden sollen.
*
Über die Allgemeinen Attribute kann erkannt werden ob ein Datensatz auf
dem JAS und der
* Datenbank am mobilen Client Gerät ident ist.
*
en:
*
Vector with the CommonAttributes of the BO, which data should be
synchronized between
* local database and JAS.
* The CommonAttributes indicate if a dataset on the JAS and
the database on the mobile
* client device is identical. */
private
Vector<JSBS_BO>
vecBO_List_ToProcess
=
new
Vector<JSBS_BO>
();
/*
*
CONSTRUCTOR
* --------------------
* de:
*
Übernehmen des jeweiligen Tasks der diese Klasse konstruiert hat
(und als Parameter übergeben
* wird) und speichern des Task
in den oberhalb definierten Variablen.
* Das Objekt des
Start-Frame (parmfrmStart) könnte zwar aus dem Task-Frame ermittelt
werden - aus
* Gründen der Komptibilität zu den
Design-Patterns (Muster) für die Entwicklung eines
*
Anwendungsprogramms werden aber beide Werte übergeben.
*
en:
* Takes
the task that constructed this class (which is passed as a parameter)
and stores it
* in the variabels defined above.
*
The object of the Start-Frame (parmfrmStart) could be derived from
the Task-Frame - for
* the compatibility to the
design-pattern (templates) for the development of an application-
*
program, both values are passed. */
public
JSBS_Country_BO_Synchronizer(JSBS_StartFrame
parmfrmStart, JSBS_TaskFrame parmfrmTask) {
frmCC
= parmfrmStart;
frmTask
= parmfrmTask;
}
/*
*
METHODEN / METHODS
* ----------------------
*/
/*
* --------------------
* de:
* METHODE
zum Übergeben eines einzelnen BO an diese Klasse und Starten des
* Abgleichs von dessen Daten auf der lokalen Datenbank mit den
Daten auf dem JAS.
*
* en:
* METHOD
to pass a single BO to this class and start the synchronization of its
* data on the local database with the data on the JAS. */
public
void
passBO(JSBS_Country_BO
parmJSBS_Country_BO
)
{
/*
* de:
* Prüfen ob der zu bearbeitende Parameter nicht 'null' ist;
sonst diese Methode beenden.
* en:
* Check if the Parameter to
be processed is not 'null'; otherwise end this method.
*/
if
(
parmJSBS_Country_BO
==
null
)
return
;
/*
* de:
* Ein neues BO 'konstruieren' und die Werte des BO aus dem
Parameter kopieren.
* Ein neues BO ist deswegen notwendig weil im Parameter nur die
Referenz auf das
* BO übergeben wird.
* Weil diese Klasse einen nebenläufigen Prozess enthält kann das
BO im übergebenen
* Parameter schon 'verschwunden' sein wenn es bearbeitet werden
soll.
* en:
* 'Construct' a new BO and copy the values from the BO passed in
the parameter.
* A new BO is needes as this class contains a thread (running in
parallel) and the
* BO in the parameter might be already 'disappeared' at the time
it should be processed. */
JSBS_BO
locJSBS_BO =
new
JSBS_BO();
locJSBS_BO.copyFromJSBS_BO
(
parmJSBS_Country_BO
);
/*
* de:
* Gerade konstruiertes BO in den Vector mit den zu
synchronisierenden BO einfügen.
* Der Befehl wird 'synchronized' ausgeführt damit im
nebenläufigen Prozess
* (Methode 'run()') nicht gleichzeitig eine Abfrage auf die
Anzahl der Elemente
* im Vector erfolgen kann. Sonst würde ein falscher Wert und
Index verwendet.
* en:
* Insert the just constructed BO into the Vector with the BO to
be synchronized.
* The command is executed 'synchronized' to avoid a concurrent
query for the
* number of elements in the vector. Otherwise a wrong value and
index would be used.
*/
synchronized
(
vecBO_List_ToProcess
) {
vecBO_List_ToProcess
.addElement(locJSBS_BO
);
}
/*
* de:
* Prüfen ob der nebenläufige Prozess bereits gestartet ist und
wenn nötig den
* nebenläufigen Prozess starten.
* en:
* Check if the thread is
already started and start it if neccessary.
*/
if
(!
this
.isAlive())
this
.run()
;
}
/*
* --------------------
* de:
* METHODE
zum Übergeben einer Liste von BO (BO-Set) an diese Klasse und Starten
des
* Abgleichs von dessen Daten auf der lokalen Datenbank mit den
Daten auf dem JAS.
*
* en:
* METHOD
to pass a list of BO (BO-set) to this class and start the
synchronization
* of its data on the local database with the data on the JAS. */
public
void
passBOList(JSBS_Country_BO_Set
parmJSBS_Country_BO_Set
)
{
/*
* Prüfen ob der zu bearbeitende Parameter nicht 'null' ist;
sonst diese Methode beenden.
* en:
* Check if the Parameter to
be processed is not 'null'; otherwise end this method.
*/
if
(
parmJSBS_Country_BO_Set
==
null
)
return
;
if
(
parmJSBS_Country_BO_Set.
vecRecordSet
==
null
)
return
;
/*
*
de:
* Größe (Anzahl der BO) des Vectors der im Parameter übergeben
wurde feststellen
* und Index
zum Durchsuchen definieren.
* en:
* Determine
the size (number of BO) of the vector passed as parameter
* and define the index to search the
vector. */
int
intVectorSize
= parmJSBS_Country_BO_Set.
vecRecordSet
.size();
int
intVectorIndex;
/*
*
de:
*
Mit
einer for-Schleife alle BO des als Parameter übergebenen
Objekts in den
*
Vector mit den CommonAttributes übernehmen.
* en:
*
Use
a for-loop to transfer
all BO within the object passed as parameter
*
into the vector with the CommonAttributes.
*/
for
(intVectorIndex
= 0; intVectorIndex < intVectorSize; intVectorIndex++)
{
/*
*
de:
* Neues BO mit den CommonAttributes definieren und die Werte aus
dem indizierten BO.
* in das neue BO kopieren.
* en:
*
Define a new BO with the CommonAttributes and copy the values of the
indexed BO.
* into the new BO. */
JSBS_BO
locJSBS_BO
=
new
JSBS_BO();
locJSBS_
BO.copyFromJSBS_BO((JSBS_BO)
parmJSBS_Country_BO_Set.
vecRecordSet
.elementAt(intVectorIndex));
/*
* de:
* Gerade konstruiertes BO in den Vector mit den zu
synchronisierenden BO einfügen.
* Der Befehl wird 'synchronized' ausgeführt damit im
nebenläufigen Prozess
* (Methode 'run()') nicht gleichzeitig eine Abfrage auf die
Anzahl der Elemente
* im Vector erfolgen kann. Sonst würde ein falscher Wert und
Index verwendet.
* en:
* Insert the just constructed BO into the Vector with the BO to
be synchronized.
* The command is executed 'synchronized' to avoid a concurrent
query for the
* number of elements in the vector. Otherwise a wrong value and
index would be used.
*/
synchronized
(
vecBO_List_ToProcess
) {
vecBO_List_ToProcess
.addElement(locJSBS_BO
);
}
}
/*
* de:
* Prüfen ob der nebenläufige Prozess bereits gestartet ist und
wenn nötig den
* nebenläufigen Prozess starten.
* en:
* Check if the thread is
already started and start it if neccessary.
*/
if
(!
this
.isAlive())
this
.run()
;
}
/*
* --------------------
*
de:
* METHODE, die nebenläufig ausgeführt wird (Thread).
* Dabei werden alle Elemente des Vectors mit den
CommonAttribute-BO verarbeitet.
* Für jedes CommonAttribute-BO wird verglichen, ob die Datensätze
dieses BO gleichzeitig
* auf der Datenbank des JAS und der lokalen Datenbank des
MobileClient vorhanden sind.
* Fehlende Datensätze werden (in die jeweilige Richtung) kopiert.
* Nach dem Synchronisieren eines BO wird der Eintrag aus der
Liste (vecBO_List_To_Process)
* entfernt. Diese Methode wird beendet wenn kein Eintrag mehr in
der Liste vorhanden ist.
* Diese Methode 'run()' muss in einem Thread unbedingt vorhanden
sein !
* --------------------
* en:
*
METHOD that is run as a thread (parallel process).
* Within this method, all elements of the vector with the
CommonAttribute-BO are processed.
* For each CommonAttribute-BO is compared, if the datasets of
this BO are present on the
* database of the JAS and on the local database of the
MobileClient. Missing datasets are
* copied (in the needed direction).
* After synchronising a BO, the entry in the list
(vecBO_List_To_Process) is removed. This
* method ends when no more entries are present in the list.
* This method 'run()' is mandatory within a Thread ! */
public
void
run()
{
/*
*
de: Diese Methode muss unbedingt eine try/catch-Logik enthalten.
*
en: A try/catch-logic is mandatory for this method.
*/
try
{
/*
* de:
* Variable für die Anzahl der Elemente im Vector definieren.
* Die Anzahl wird innerhalb der for-Schleife abgefragt.
* en:
* Define a variable for the number of elements within the vector.
*/
int
intVectorSize;
/*
* de:
* 'Endlose' for-Schleife beginnen.
* Die Schleife wird abgebrochen wenn der Vector kein Element mehr
enthält.
* Durch den nebenläufigen Prozess können aber während des
Ausführens der for-Schleife
* weiter Elemente in den Vector eingefügt werden - daher wird das
Abbruch-Kriterium
* erst am Ende der for-Schleife geprüft.
* en:
* Start an 'endless' for-loop.
* The loop ends when no
more element is within the vector.
* With the parallel process, elements can be added during the
for-loop is running.
* Therefore the termination-criteria is checked at the end of the
loop.
*/
for
(;;)
{
/*
* de:
* Anzahl der Elemente im Vector abfragen.
* Der Befehl wird 'synchronized' ausgeführt damit nicht
gleichzeitig ein weiteres
* Element eingefügt oder entfernt werden kann.
* en:
* Get the number of elements within the vector.
* The command is executed 'synchronized' to avoid a concurrent
entry or removal of
* an element.
*/
synchronized
(
vecBO_List_ToProcess
) {
intVectorSize
=
vecBO_List_ToProcess
.size(
);
}
/*
de:
* Wenn im
Vector kein Element mehr vorhanden ist wird die for-Schleife beendet.
* Und damit
auch die Methode 'run()'
.
*
en:
* If no more
element is within the vector then the for-loop is terminated.
* That causes
a termination of the method 'run()', too
.
*/
if
(intVectorSize <= 0)
break
;
/*
*
de: Methode aufrufen in der das erste BO im Vector (mit Index 0)
synchronisiert wird.
*
en: Call the method for synchronizing the first BO (with index 0)
within the vector.
*/
synchronizeBO()
;
}
}
catch
(Exception
e) {
/*
de:
* Es ist
ziemlich unwahrscheinlich, dass in einem so einfachen Thread ein Fehler
auftritt.
* Sollte ein
Fehler doch passieren bleibt dieser unbehandelt weil damit nur das
Abgleichen
* der Daten
zwischen Datenbank des JAS und lokaler Datenbank unterbrochen wird.
* Dies wird
bei einem neuerlichen Abgleich nachgeholt und ist damit im
Anwendungsprogramm
* vorgesehen.
*
en:
*
The change
that an error appears in such a simple thread is very low.
* If an error
should happen anyway, it is not handled. The only effect of an error is,
that
* the
synchronization of data on the JAS and data on the local database is
stopped.
* This is done
at a new synchronization and therefore a feature of the
application-program
.
*/
}
}
/*
* --------------------
*
de:
* METHODE zum Aufrufen des nebenläufigen Prozess
(Thread) zum Abgleichen von BO wenn das
*
Anwendungsprogramm in der Version 'MobileClient' läuft.
* Dabei wird das erste Element aus dem Vector (Index 0)
ausgelesen und für dieses BO
* werden alle Datensätze (historisch, aktuell gültig, in der
Zukunft gültig) von der
* lokalen Datenbank und der Datenbank des JAS gelesen.
* Wurde das BO auf einer Seite verändert dann werden die
Datensätze zwischen JAS und
* MobileClient synchronisiert.
*
* en:
*
METHOD to call the thread to synchronize BO if the
application-programm runs with the
* version 'MobileClient'.
* To do this, the first element of the vector (index 0) is read
and for this BO all
* datasets (historic, actually valid, valid in the future) are
read from the database
* of the JAS and from the local database.
* If the BO was changed on one side, the datasets will be
synchronized beween JAS and
* MobileClient.
*/
private
void
synchronizeBO()
{
/*
* de:
* Variable für die Allgemeinen Attribute (CommonAttributes) eines
BO aus dem Vector.
* en:
* Variable for the CommonAttributes of one BO out of the vector. */
JSBS_BO locBO
;
/*
* de:
* Prüfen ob überhaupt ein Element im Vector enthalten ist; sonst
diese Methode gleich
* beenden.
Anschließend
das erste Element (Index 0) im Vector auslesen.
* Der Befehl wird 'synchronized' ausgeführt damit nicht
gleichzeitig ein weiteres
* Element eingefügt oder entfernt werden kann.
* en:
* Verify if at least one element is within the vector; otherwise
terminate this
* method immediately. Read
the first element (index 0) out of the vector thereafter.
* The command is executed 'synchronized' to avoid a concurrent
entry or removal of
* an element.
*/
synchronized
(
vecBO_List_ToProcess
) {
if
(
vecBO_List_ToProcess
.size(
)
<= 0)
return
;
locBO
=
(JSBS_BO)
vecBO_List_ToProcess
.elementAt(0
);
}
/*
* de:
* BOC-Variable für das Lesen von der
lokalen Datenbank konstruieren.
* en:
* Construct the BOC-variable to read
from the local database. */
JSBS_Country_BOC_Set
structJSBS_Country_BOC_Set_DB =
new
JSBS_Country_BOC_Set(
frmCC
,
frmTask
);
/*
* de:
* Alle Datensätze für dieses BO von der lokalen Datenbank lesen.
* en:
* Read all datasets for this BO from the local database. */
structJSBS_Country_BOC_Set_DB.selectAllByObjectID(locBO.
ObjectID
);
/*
* de:
* Prüfen ob die Datenbank-Operation fehlerfrei war. Dazu den
Status-Code des BOC abfragen.
* en:
* Verify if the database operation ended without an error. To do
this evaluate the
* status-code of the BOC
.
*/
switch
(
structJSBS_Country_BOC_Set_DB
.
StatusCode
) {
case
JSBS_BO.
CONST_OK
:
/*
* de:
* Verarbeitung wie erwartet; Daten ohne Fehler gelesen.
* en:
* Processing ended as expected; data read without an error. */
break
;
case
JSBS_BO.
CONST_NOT_FOUND
:
/*
* de:
* Noch keine Daten vorhanden; das ist kein Fehler.
* en:
* No data present; that is not an error. */
break
;
default
:
/*
* de:
* Ein anderer Fehler ist beim Lesen der Daten aufgetreten.
* Fehlerbehandlungsmethode des Task-Frame aufrufen und Methode
beenden.
* en:
* Another error occured when reading the data.
* Call the error-handler of the Task-Frame and end the method. */
frmTask
.handleErrorEvent(
this
.getClass().getName(),
"synchronizeBO_DB"
,
Integer.toString(
structJSBS_Country_BOC_Set_DB
.
StatusCode
)
,
structJSBS_Country_BOC_Set_DB
.
StatusMsg
);
return
;
}
/*
* de:
* BOC-Variable für das Lesen von der
Datenbank des JAS konstruieren.
* en:
* Construct the BOC-variable to read
from the database of the JAS. */
JSBS_Country_BOC_Set
structJSBS_Country_BOC_Set_JAS =
new
JSBS_Country_BOC_Set(
frmCC
,
frmTask
);
/*
* de:
* Alle Datensätze für dieses BO von der Datenbank des JAS lesen.
* en:
* Read all datasets for this BO from the database of the JAS. */
structJSBS_Country_BOC_Set_JAS.selectAllByObjectID(locBO.
ObjectID
);
/*
* de:
* Prüfen ob die Datenbank-Operation fehlerfrei war. Dazu den
Status-Code des BOC abfragen.
* en:
* Verify if the database operation ended without an error. To do
this evaluate the
* status-code of the BOC
.
*/
switch
(
structJSBS_Country_BOC_Set_
JAS
.
StatusCode
) {
case
JSBS_BO.
CONST_OK
:
/*
* de:
* Verarbeitung wie erwartet; Daten ohne Fehler gelesen.
* en:
* Processing ended as expected; data read without an error. */
break
;
case
JSBS_BO.
CONST_NOT_FOUND
:
/*
* de:
* Noch keine Daten vorhanden; das ist kein Fehler.
* en:
* No data present; that is not an error. */
break
;
default
:
/*
* de:
* Ein anderer Fehler ist beim Lesen der Daten aufgetreten.
* Fehlerbehandlungsmethode des Task-Frame aufrufen und Methode
beenden.
* en:
* Another error occured when reading the data.
* Call the error-handler of the Task-Frame and end the method. */
frmTask
.handleErrorEvent(
this
.getClass().getName(),
"synchronizeBO_JAS"
,
Integer.toString(
structJSBS_Country_BOC_Set_
JAS
.
StatusCode
)
,
structJSBS_Country_BOC_Set_
JAS
.
StatusMsg
);
return
;
}
/*
* de:
* Variable für die jeweiligen Datensätze des BO aus den Listen
(mit einzelnen, historischen
* Datensätzen eines BO) von lokaler Datenbank und JAS.
* en:
* variables for the particular datasets of the BO from the lists
(with single, historic datasets
* of a BO)
from local database and JAS
.
*/
JSBS_Country_BO
locBO_DB
;
JSBS_Country_BO
locBO_
JAS;
/*
* de:
* Variable für die Anzahl der Elemente in den jeweiligen Vectors
(Sets) und Variable für die Indizes.
* en:
* Variables for the number of elements within each vector (set)
and variables for the indizes.
*/
int
intDBVectorSize =
structJSBS_Country_BOC_Set_DB.
vecRecordSet
.size();
int
intDBVectorIndex;
int
intJASVectorSize;
int
intJASVectorIndex;
/*
* de:
* Merker ob ein Datensatz des untersuchten BO bereits synchron
auf beiden Datenbanken existiert.
* en:
* Flag to signal if a dataset of the inspected BO already exists
synchronized on both databases.
*/
boolean
bolAlreadySynchronized
;
/*
* de:
* for-Schleife für das Bearbeiten der einzelnen Datensätze des BO
auf der lokalen Datenbank.
* Die Untersuchung wird beim 'ältesten' Datensatz (Element des
Vectors mit dem höchsten Index)
* begonnen weil bereits geprüfte Datensätze aus dem Vector
entfernt werden.
* en:
* for-loop to process the singular datasets of the BO on the
local database.
* The inspection starts at the 'olest' dataset (element in the
vector with the highest index)
* as already inspected datasets will be removed from the vector.
*/
for
(intDBVectorIndex =
intDBVectorSize - 1; intDBVectorIndex >= 0; intDBVectorIndex--) {
/*
* de:
* Herausholen eines einzelnen Datensatzes aus dem Vector; damit
wird die weitere Verarbeitung leichter.
* en:
* Get a single dataset out of the vector; that simplifies the
further processing.
*/
locBO_DB
= (JSBS_Country_BO)
structJSBS_Country_BOC_Set_
DB.
vecRecordSet
.elementAt(intDBVectorIndex)
;
/*
* de:
* Setzen des Merkers für das Festhalten, ob der Datensatz von der
lokalen Datenbank auch bereits
* auf der Datenbank des JAS vorhanden ist.
* en:
* Set the flag to keep track if the dataset from the local
database exists on the database of
* the JAS, too.
*/
bolAlreadySynchronized
=
false
;
/*
* de:
* Ermitteln der Anzahl der Elemente im Vector (Set) mit den
Datensätzen vom JAS.
* Dieses Ermitteln muss bei jedem Durchlauf der for-Schleife neu
erfolgen weil bereits
* synchronisierte Datensätze aus dem Vector mit den Datensätzen
vom JAS gelöscht werden.
* en:
* Determine the number of elements within the vector (set) with
the datasets from the JAS.
* This has to be done at each start of the for-loop as already
synchronized datasets are
* removed from the vector with the datasets from the JAS.
*/
intJASVectorSize
=
structJSBS_Country_BOC_Set_JAS.
vecRecordSet
.size();
/*
* de:
* for-Schleife für das Bearbeiten der einzelnen Datensätze des BO
auf der Datenbank des JAS.
* Die Untersuchung wird beim 'ältesten' Datensatz (Element des
Vectors mit dem höchsten Index)
* begonnen weil bereits geprüfte Datensätze aus dem Vector
entfernt werden.
* en:
* for-loop to process the singular datasets of the BO on the
database of the JAS.
* The inspection starts at the 'olest' dataset (element in the
vector with the highest index)
* as already inspected datasets will be removed from the vector.
*/
for
(intJASVectorIndex =
intJASVectorSize - 1; intJASVectorIndex >= 0; intJASVectorIndex--) {
/*
* de:
* Herausholen eines einzelnen Datensatzes aus dem Vector; damit
wird die weitere Verarbeitung leichter.
* en:
* Get a single dataset out of the vector; that simplifies the
further processing.
*/
locBO_JAS
= (JSBS_Country_BO)
structJSBS_Country_BOC_Set_
JAS.
vecRecordSet
.elementAt(intJASVectorIndex)
;
/*
* de:
* Prüfen ob die Datensätze auf der lokalen Datenbank und der
Datenbank des JAS bereits gleich sind.
* en:
* Check if the datasets on the local database and the database of
the JAS are already equal.
*/
bolAlreadySynchronized
= ! locBO_JAS.isDifferent(locBO_DB);
if
(
bolAlreadySynchronized)
{
/*
* de:
* Datensätze auf beiden Seiten komplett gleich; aus dem
jeweiligen Vector entfernen und diese
* (innere) for-Schleife beenden.
* en:
* Datasets completely equal on both sides; remove from each
particular vector and terminate
* this (inner) for-loop.
*/
structJSBS_Country_BOC_Set_
DB.
vecRecordSet
.removeElementAt(intDBVectorIndex)
;
structJSBS_Country_BOC_Set_
JAS.
vecRecordSet
.removeElementAt(intJASVectorIndex)
;
break
;
}
/*
* de:
* Mit diesem 'if' wird
geprüft, ob der DataSetID gleich ist - im Umkehrschluss muss damit bei
* mindestem einem Attribut der Wert unterschiedlich sein.
* en:
* With this 'if' is checked if the DataSetID is equal - as a
reverse conclusion the value of
* at least one attribute must be different.
*/
if
(
locBO_DB.
DataSetID
==
locBO_JAS
.
DataSetID
) {
/*
* de:
* Prüfen, welcher Datensatz
später verändert wurde und die Werte von diesem auf die 'andere
* Seite' übertragen.
* en:
* Check which dataset was changed later in time and transfer the
value of this dataset to
* the 'other side'.
*/
if
(
locBO_DB.
ChangedAt
.after(
locBO_JAS
.
ChangedAt
))
synchronizeFromDB(locBO_DB);
else
synchronizeFromJAS(locBO_JAS);
/*
* de:
* Datensätze synchronisiert. Merker setzen, Element aus dem
jeweiligen Vector entfernen und
* diese (innere) for-Schleife beenden.
* en:
* Datasets synchronized. Set the flag, remove the element from
each particular vector
* and terminate this (inner) for-loop.
*/
bolAlreadySynchronized
=
true
;
structJSBS_Country_BOC_Set_
DB.
vecRecordSet
.removeElementAt(intDBVectorIndex)
;
structJSBS_Country_BOC_Set_
JAS.
vecRecordSet
.removeElementAt(intJASVectorIndex)
;
break
;
}
/*
de:
Ende der inneren for-Schleife
.
* en: End of the inner for-loop.
*/
}
/*
* de:
* Abfragen ob für den Datensatz auf der lokalen Datenbank kein
Gegenpart auf dem JAS
* gefunden wurde.
* en:
* Check if a equivalent dataset on the JAS was not found on the
local database.
*/
if
(!
bolAlreadySynchronized) {
/*
* de:
* Datensatz von der lokalen Datenbank auf die Datenbank des JAS
kopieren und aus dem
* Vector mit dem Set der lokalen Datenbank entfernen.
* en:
* Copy the dataset from the local database to the database on the
JAS and remove from
* the vector with the set of the local database.
*/
synchronizeFromDB(locBO_DB)
;
structJSBS_Country_BOC_Set_
DB.
vecRecordSet
.removeElementAt(intDBVectorIndex)
;
}
/*
de:
Ende der äußeren for-Schleife
.
* en: End of the outer for-loop.
*/
}
/*
* de:
* Die jetzt noch im Set des JAS enthaltenen Datensätze fehlen auf
der Datenbank des
* MobileClient und werden jetzt dort eingefügt.
* Zuerst die Anzahl der Elemente im Vector ermitteln.
* en:
* The datasets still in the set of the JAS are missing at the
database of the MobileClient
* and will be inserted now.
* First, get the number of elements in the vector.
*/
intJASVectorSize
=
structJSBS_Country_BOC_Set_JAS.
vecRecordSet
.size();
/*
* de:
* for-Schleife zum Auslesen der verbliebenen Elemente im Vector
der Datensätze vom
* JAS. Jeder Datensatz wird von der Datenbank des JAS auf die
lokale Datenbank kopiert.
* en:
* for-loop to read the remaining elements in the vector for the
datasets from the JAS.
* Each dataset will be copied from the database on the JAS to the
local database.
*/
for
(intJASVectorIndex
= intJASVectorSize - 1; intJASVectorIndex >= 0; intJASVectorIndex--)
{
locBO_JAS =
(JSBS_Country_BO
)
structJSBS_Country_BOC_Set_JAS.
vecRecordSet
.elementAt(
intJASVectorIndex
);
synchronizeFromJAS(locBO_JAS
);
}
/*
* de:
* Das gerade synchronisierte BO (im Vector das erste Element mit
Index 0) aus dem Vector
* entfernen
.
* Der Befehl wird 'synchronized' ausgeführt damit nicht
gleichzeitig ein weiteres
* Element eingefügt oder die Anzahl der Elemente geprüft werden
kann.
* en:
* Remove the just synchronized BO (the first element in the
vector with index 0)
* from the vector.
* The command is executed 'synchronized' to avoid a concurrent
entry of an element
* or the operation to count the elements in the vector.
*/
synchronized
(
vecBO_List_ToProcess
) {
vecBO_List_ToProcess
.removeElementAt(0
);
}
}
/*
* --------------------
*
de:
* METHODE zum Kopieren der Daten des als Parameter übergebenen
Datensatzes (als Teil
* der
Zeitreihe eines BO) auf die Datenbank des JAS (Java Application Server)
.
*
* en:
*
METHOD to copy the data of the dataset (as part of the time series of a
BO) passed
*
in the parameter
to the
database of the JAS (Java Application Server)
.
*/
private
void
synchronizeFromDB(JSBS_Country_BO
parmJSBS_Country_BO)
{
/*
* de:
* Merken des DataSetID auf der lokalen Datenbank für den Fall,
dass der Wert auf der
*
JAS-Seite geändert wird.
*
Die Änderung kann vorkommen wenn während des asynchronen Betriebs des
MobileClient
*
der gleiche Wert auch auf dem JAS (an ein unterschiedliches BO)
vergeben wurde
.
* en:
* Keep the DataSetID on the local database for the case, that the
value is changed
* on the JAS-side.
* A change might occur if, during the asynchronous operation of
the MobileClient,
* the same value was assigned on the JAS (to a different BO), too. */
double
dblOriginalDataSetID
= parmJSBS_Country_BO.
DataSetID
;
/*
* de:
* BOC-Variable für das Speichern auf dem
JAS konstruieren.
* en:
* Construct the BOC-variable to store
on the JAS. */
JSBS_Country_BOC
structJSBS_Country_BOC =
new
JSBS_Country_BOC(
frmCC
,
frmTask
);
/*
* de:
* Werte aus dem Parameter auf das gerade konstruierte BOC
übertragen und
* Speichern auf dem JAS.
* en:
* Transfer the values from the parameter to the just constructed
BOC and
* store on the JAS. */
structJSBS_Country_BOC.copyFromJSBS_Country_BO(parmJSBS_Country_BO
);
structJSBS_Country_BOC.synchronizedStore_JAS(
);
/*
* de:
* Prüfen ob die Datenbank-Operation fehlerfrei war. Dazu den
Status-Code des BOC abfragen.
* en:
* Verify if the database operation ended without an error. To do
this evaluate the
* status-code of the BOC
.
*/
switch
(
structJSBS_Country_BOC
.
StatusCode
) {
case
JSBS_BO.
CONST_OK
:
/*
* de: Verarbeitung wie erwartet; Daten ohne Fehler
gespeichert.
* en: Processing ended as expected; data stored without an
error. */
break
;
default
:
/*
* de:
* Ein anderer Fehler ist beim Lesen der Daten aufgetreten.
* Fehlerbehandlungsmethode des Task-Frame aufrufen und Methode
beenden.
* en:
* Another error occured when reading the data.
* Call the error-handler of the Task-Frame and end the method. */
frmTask
.handleErrorEvent(
this
.getClass().getName(),
"synchronizeFromDB_JAS"
,
Integer.toString(
structJSBS_Country_BOC
.
StatusCode
)
,
structJSBS_Country_BOC
.
StatusMsg
);
return
;
}
/*
* de:
* Prüfen, ob der Wert des DataSetID auf dem JAS geändert wurde.
* In diesem Fall wird der Wert des DataSetID auf der lokalen
Datenbank jenem auf dem
* JAS angepasst.
* en:
* Verify, if the value of the DataSetID was changed on the JAS.
* In that case the value of the DataSetID on the local database
will be changed to
* that on the JAS. */
if
(dblOriginalDataSetID
!=
structJSBS_Country_BOC
.
DataSetID
) {
/*
* de: Ändern des Datensatzes auf der lokalen Datenbank.
* en: Dhange the dataset on the local database. */
structJSBS_Country_BOC.synchronizedStore_DB(
dblOriginalDataSetID
);
/*
* de:
* Prüfen ob die Datenbank-Operation fehlerfrei war. Dazu den
Status-Code des BOC abfragen.
* en:
* Verify if the database operation ended without an error. To do
this evaluate the
* status-code of the BOC
.
*/
switch
(
structJSBS_Country_BOC
.
StatusCode
) {
case
JSBS_BO.
CONST_OK
:
/*
* de:
* Verarbeitung wie erwartet; Daten ohne Fehler gelesen.
* en:
* Processing ended as expected; data read without an error. */
break
;
default
:
/*
* de:
* Ein anderer Fehler ist beim Lesen der Daten aufgetreten.
* Fehlerbehandlungsmethode des Task-Frame aufrufen und Methode
beenden.
* en:
* Another error occured when reading the data.
* Call the error-handler of the Task-Frame and end the method. */
frmTask
.handleErrorEvent(
this
.getClass().getName(),
"synchronizeFromDB_DB"
,
Integer.toString(
structJSBS_Country_BOC
.
StatusCode
)
,
structJSBS_Country_BOC
.
StatusMsg
);
return
;
}
}
}
/*
* --------------------
*
de:
* METHODE zum Kopieren der Daten des als Parameter übergebenen
Datensatzes (als Teil
* der
Zeitreihe eines BO) auf die lokale Datenbank des mobilen Client Gerätes
.
*
* en:
*
METHOD to copy the data of the dataset (as part of the time series of a
BO) passed
*
in the parameter
to the local
database of the mobile client device
.
*/
private
void
synchronizeFromJAS(JSBS_Country_BO
parmJSBS_Country_BO)
{
/*
* de:
* BOC-Variable für das Speichern auf der
lokalen Datenbank konstruieren.
* en:
* Construct the BOC-variable to store
on the local database. */
JSBS_Country_BOC
structJSBS_Country_BOC =
new
JSBS_Country_BOC(
frmCC
,
frmTask
);
/*
* de:
* Werte aus dem Parameter auf das gerade konstruierte BOC
übertragen und
* Speichern auf der lokalen Datenbank.
* en:
* Transfer the values from the parameter to the just constructed
BOC and
* store on the local database. */
structJSBS_Country_BOC.copyFromJSBS_Country_BO(parmJSBS_Country_BO
);
structJSBS_Country_BOC.synchronizedStore_DB(
0);
/*
* de:
* Prüfen ob die Datenbank-Operation fehlerfrei war. Dazu den
Status-Code des BOC abfragen.
* en:
* Verify if the database operation ended without an error. To do
this evaluate the
* status-code of the BOC
.
*/
switch
(
structJSBS_Country_BOC
.
StatusCode
) {
case
JSBS_BO.
CONST_OK
:
/*
* de: Verarbeitung wie erwartet; Daten ohne Fehler
gespeichert.
* en: Processing ended as expected; data stored without an
error. */
break
;
default
:
/*
* de:
* Ein anderer Fehler ist beim Lesen der Daten aufgetreten.
* Fehlerbehandlungsmethode des Task-Frame aufrufen und Methode
beenden.
* en:
* Another error occured when reading the data.
* Call the error-handler of the Task-Frame and end the method. */
frmTask
.handleErrorEvent(
this
.getClass().getName(),
"synchronizeFromJAS"
,
Integer.toString(
structJSBS_Country_BOC
.
StatusCode
)
,
structJSBS_Country_BOC
.
StatusMsg
);
return
;
}
}
}
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 |
|
|