-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #998 from johnbrvc/i966_results_compare_fixes
Two approvals. Tested on multiple contest's data sets as well.
- Loading branch information
Showing
19 changed files
with
112,649 additions
and
7,094 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (C) 1989-2023 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau. | ||
// Copyright (C) 1989-2024 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau. | ||
package edu.csus.ecs.pc2.core.imports.clics; | ||
|
||
import java.util.logging.Level; | ||
|
@@ -13,7 +13,7 @@ | |
|
||
/** | ||
* Information about a comparison of two fields. | ||
* | ||
* | ||
* @author Douglas A. Lane, PC^2 team [email protected] | ||
*/ | ||
public class FieldCompareRecord { | ||
|
@@ -39,7 +39,7 @@ public class FieldCompareRecord { | |
public FieldCompareRecord(String fieldName, String valueOne, String valueTwo, String details) { | ||
this(fieldName, valueOne, valueTwo, details, null); | ||
} | ||
|
||
public FieldCompareRecord(String fieldName, String valueOne, String valueTwo, String details, String key) { | ||
super(); | ||
this.fieldName = fieldName; | ||
|
@@ -48,6 +48,9 @@ public FieldCompareRecord(String fieldName, String valueOne, String valueTwo, St | |
this.details = details; | ||
this.key = key; | ||
|
||
if(key == null) { | ||
this.key = "any"; | ||
} | ||
createComparisonState(valueOne, valueTwo); | ||
} | ||
|
||
|
@@ -106,18 +109,18 @@ public String getDetails() { | |
public void setDetails(String details) { | ||
this.details = details; | ||
} | ||
|
||
public String getKey() { | ||
return key; | ||
} | ||
|
||
public void setKey(String key) { | ||
this.key = key; | ||
} | ||
|
||
/** | ||
* Returns a JSON string representation of this SerializedFile object. | ||
* | ||
* | ||
* @return a String containing a JSON representation of this object, or null if an error occurs during creation of the JSON string | ||
*/ | ||
// TODO REFACTOR Move into a JSON Utility class | ||
|
@@ -137,7 +140,7 @@ public String toJSON() { | |
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return toJSON(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (C) 1989-2023 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau. | ||
// Copyright (C) 1989-2024 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau. | ||
package edu.csus.ecs.pc2.core.report; | ||
|
||
import java.util.Comparator; | ||
|
@@ -7,20 +7,37 @@ | |
import edu.csus.ecs.pc2.core.imports.clics.FieldCompareRecord; | ||
|
||
/** | ||
* Compare by key then by fieldName. | ||
* | ||
* Compare by State (type of error), then key then by fieldName. | ||
* | ||
* @author Douglas A. Lane, PC^2 team [email protected] | ||
*/ | ||
public class FieldCompareRecordComparator implements Comparator<FieldCompareRecord> { | ||
|
||
@Override | ||
public int compare(FieldCompareRecord o1, FieldCompareRecord o2) { | ||
|
||
if (o1.getKey().equals(o2.getKey())) { | ||
return StringUtilities.nullSafeCompareTo(o1.getFieldName(), o2.getFieldName()); | ||
} else { | ||
return StringUtilities.nullSafeCompareTo(o1.getKey(), o2.getKey()); | ||
// Reverse sort by state number, since we want the non-matches first, then the missings. | ||
int cmpResult = o2.getState().ordinal() - o1.getState().ordinal(); | ||
if(cmpResult == 0) { | ||
String k1 = o1.getKey(); | ||
String k2 = o2.getKey(); | ||
|
||
// Paranoia with the keys | ||
if(k1 == null){ | ||
if(k2 == null) { | ||
return(0); | ||
} | ||
return(-1); | ||
} else if(k2 == null) { | ||
return(1); | ||
} | ||
if (o1.getKey().equals(o2.getKey())) { | ||
cmpResult = StringUtilities.nullSafeNaturalCompareTo(o1.getFieldName(), o2.getFieldName(), false); | ||
} else { | ||
cmpResult = StringUtilities.nullSafeNaturalCompareTo(o1.getKey(), o2.getKey(), false); | ||
} | ||
} | ||
return(cmpResult); | ||
} | ||
|
||
} |
Oops, something went wrong.