Fix data integrity bug

Fix of bug that 'fixed' event start and end times in database for linked
parent / child event tables. Error was caused by a mix up between
ParentID and ParentUID fields.
This commit is contained in:
Douglas Gillespie 2024-02-05 13:34:15 +00:00
parent 66b73c45e2
commit e52701353a
5 changed files with 18 additions and 5 deletions

View File

@ -4,7 +4,7 @@
<groupId>org.pamguard</groupId> <groupId>org.pamguard</groupId>
<artifactId>Pamguard</artifactId> <artifactId>Pamguard</artifactId>
<name>Pamguard Java12+</name> <name>Pamguard Java12+</name>
<version>2.02.10</version> <version>2.02.10a</version>
<description>Pamguard for Java 12+, using Maven to control dependcies</description> <description>Pamguard for Java 12+, using Maven to control dependcies</description>
<url>www.pamguard.org</url> <url>www.pamguard.org</url>
<organization> <organization>

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.pamguard</groupId> <groupId>org.pamguard</groupId>
<artifactId>Pamguard</artifactId> <artifactId>Pamguard</artifactId>
<version>2.02.10</version> <version>2.02.10a</version>
<name>Pamguard Java12+</name> <name>Pamguard Java12+</name>
<description>Pamguard for Java 12+, using Maven to control dependcies</description> <description>Pamguard for Java 12+, using Maven to control dependcies</description>
<url>www.pamguard.org</url> <url>www.pamguard.org</url>

View File

@ -31,7 +31,7 @@ public class PamguardVersionInfo {
* Version number, major version.minorversion.sub-release. * Version number, major version.minorversion.sub-release.
* Note: can't go higher than sub-release 'f' * Note: can't go higher than sub-release 'f'
*/ */
static public final String version = "2.02.10"; static public final String version = "2.02.10a";
/** /**
* Release date * Release date

View File

@ -458,6 +458,7 @@ public class DetectionGroupProcess extends PamProcess {
detectionGroupDataBlock.saveViewerData(); detectionGroupDataBlock.saveViewerData();
int nUpdates = 0; int nUpdates = 0;
int nOK = 0; int nOK = 0;
int consecutiveOK = 0;
System.out.printf("Checking %d data units in %s ", detectionGroupDataBlock.getUnitsCount(), detectionGroupDataBlock.getDataName()); System.out.printf("Checking %d data units in %s ", detectionGroupDataBlock.getUnitsCount(), detectionGroupDataBlock.getDataName());
synchronized (detectionGroupDataBlock.getSynchLock()) { synchronized (detectionGroupDataBlock.getSynchLock()) {
ListIterator<DetectionGroupDataUnit> it = detectionGroupDataBlock.getListIterator(0); ListIterator<DetectionGroupDataUnit> it = detectionGroupDataBlock.getListIterator(0);
@ -466,11 +467,16 @@ public class DetectionGroupProcess extends PamProcess {
boolean ok = checkDataIntegrity(du, false); boolean ok = checkDataIntegrity(du, false);
if (ok) { if (ok) {
nUpdates++; nUpdates++;
consecutiveOK = 0;
} }
else { else {
nOK++; nOK++;
consecutiveOK++;
} }
System.out.printf("."); System.out.printf(".");
if (consecutiveOK % 80 == 0) {
System.out.printf("\n");
}
} }
} }
System.out.printf("\n%s: %d out of %d data units required corrections\n", detectionGroupDataBlock.getDataName(), nUpdates, nUpdates+nOK); System.out.printf("\n%s: %d out of %d data units required corrections\n", detectionGroupDataBlock.getDataName(), nUpdates, nUpdates+nOK);
@ -486,7 +492,7 @@ public class DetectionGroupProcess extends PamProcess {
subTabLogging = detectionGroupLogging.getSubLogging(); subTabLogging = detectionGroupLogging.getSubLogging();
PamConnection con = DBControlUnit.findConnection(); PamConnection con = DBControlUnit.findConnection();
String desc = String.format("Detection group UID %d at %s", du.getUID(), PamCalendar.formatDBDateTime(du.getTimeMilliseconds())); String desc = String.format("Detection group UID %d at %s", du.getUID(), PamCalendar.formatDBDateTime(du.getTimeMilliseconds()));
String idList = "( " + du.getUID() + " )"; String idList = "( " + du.getDatabaseIndex() + " )";
ArrayList<PamSubtableData> stData = subTabLogging.loadSubtableData(con, detectionGroupLogging, idList, null); ArrayList<PamSubtableData> stData = subTabLogging.loadSubtableData(con, detectionGroupLogging, idList, null);
if (stData == null) { if (stData == null) {
System.out.println("Error loading sub table data for event uid " + du.getUID()); System.out.println("Error loading sub table data for event uid " + du.getUID());

View File

@ -2002,7 +2002,7 @@ public abstract class SQLLogging {
* *
* @param con database connection * @param con database connection
* @param parentLogging super detection logging instance. * @param parentLogging super detection logging instance.
* @param uidList list of UID's in the parent data that have been loaded. * @param idList list of ID's in the parent data that have been loaded. Note Id, NOT UID
* @return list of all PamSubtableData items * @return list of all PamSubtableData items
*/ */
public ArrayList<PamSubtableData> loadSubtableData(PamConnection con, SQLLogging parentLogging, String idList, ViewLoadObserver loadObserver) { public ArrayList<PamSubtableData> loadSubtableData(PamConnection con, SQLLogging parentLogging, String idList, ViewLoadObserver loadObserver) {
@ -2034,6 +2034,13 @@ public abstract class SQLLogging {
return loadSubtableData(con, subtableResults, loadObserver); return loadSubtableData(con, subtableResults, loadObserver);
} }
/**
* Get a sub table result set. Note that this is based on ID, not UID
* @param con connection
* @param parentLogging parent logging system
* @param parentIdList ParentID list. Note that this is ID, not UID, <br>i.e. the query is WHERE ParentID IN ...
* @return child table result set
*/
private ResultSet createSubTableResultSet(PamConnection con, SQLLogging parentLogging, private ResultSet createSubTableResultSet(PamConnection con, SQLLogging parentLogging,
String parentIdList) { String parentIdList) {
String clause = String.format(" WHERE ParentID IN %s ORDER BY UTC, UTCMilliseconds", parentIdList); String clause = String.format(" WHERE ParentID IN %s ORDER BY UTC, UTCMilliseconds", parentIdList);