From 56cc96ecacec779fe4b929eb8dc540e4fb1bba13 Mon Sep 17 00:00:00 2001 From: Bryce Willey Date: Wed, 8 Jul 2026 22:27:41 -0400 Subject: [PATCH] Slight refactor for new TrueFiling tables The mapping from XML element to the table name should live in the Code Database, not the CodeUpdater. --- .../litlab/efsp/ecfcodes/CodeDatabaseAPI.java | 5 ++ .../efsp/tyler/ecfcodes/CodeDatabase.java | 60 +++++++++++++++++ .../efsp/tyler/ecfcodes/CodeUpdater.java | 64 ++----------------- .../efsp/ecfcodes/tyler/CodeDatabaseTest.java | 3 +- 4 files changed, 71 insertions(+), 61 deletions(-) diff --git a/proxyserver/src/main/java/edu/suffolk/litlab/efsp/ecfcodes/CodeDatabaseAPI.java b/proxyserver/src/main/java/edu/suffolk/litlab/efsp/ecfcodes/CodeDatabaseAPI.java index 1f1fe0d8..ac6d4959 100644 --- a/proxyserver/src/main/java/edu/suffolk/litlab/efsp/ecfcodes/CodeDatabaseAPI.java +++ b/proxyserver/src/main/java/edu/suffolk/litlab/efsp/ecfcodes/CodeDatabaseAPI.java @@ -36,6 +36,11 @@ public CodeDatabaseAPI(Connection conn) { /** The jurisdiction (e.g illinois) that this database is working over */ public abstract Jurisdiction getJurisdiction(); + /** + * Maps the name of an ECF element to be substituted by a court-specific code list or extension. + */ + public abstract Map xmlElemToTableName(); + /** * Gets all court location identifiers (CLI) stored in the database. * diff --git a/proxyserver/src/main/java/edu/suffolk/litlab/efsp/tyler/ecfcodes/CodeDatabase.java b/proxyserver/src/main/java/edu/suffolk/litlab/efsp/tyler/ecfcodes/CodeDatabase.java index 9392cca7..2fa61aa3 100644 --- a/proxyserver/src/main/java/edu/suffolk/litlab/efsp/tyler/ecfcodes/CodeDatabase.java +++ b/proxyserver/src/main/java/edu/suffolk/litlab/efsp/tyler/ecfcodes/CodeDatabase.java @@ -46,6 +46,66 @@ public CodeDatabase(Jurisdiction jurisdiction, Connection conn) { this.jurisdiction = jurisdiction; } + // TODO(brycew-later): there's little more info on these mappings and how they combine. + // Is this actually an XPath? Should figure it out + private static final Map ecf4Map = + Map.ofEntries( + Map.entry("cext:BondTypeText", "bond"), + Map.entry("cext:Charge/cext:ChargeStatute/j:StatuteLevelText", "degree"), + Map.entry("cext:Charge\\cext:ChargePhaseText", "chargephase"), + Map.entry("cext:GeneralOffenseText", "generaloffense"), + Map.entry("cext:StatuteTypeText", "statutetype"), + Map.entry( + "cext:Charge/cext:ChargeStatute/j:StatuteCodeIdentification/nc:IdentificationID", + "statute"), + Map.entry("ecf:CaseParticipantRoleCode", "partytype"), + Map.entry("ecf:FilingStatusCode", "filingstatus"), + Map.entry("ecf:ServiceRecipientID/nc:IdentificationSourceText", "servicetype"), + Map.entry( + "ecf:PersonDriverLicense/nc:DriverLicenseIdentification/nc:IdentificationCategoryText", + "driverlicensetype"), + Map.entry("j:/ArrestCharge/j:ArrestLocation/nc:LocationName", "arrestlocation"), + Map.entry("j:RegisterActionDescriptionText", "filing"), + Map.entry( + "j:ArrestOfficial/j:EnforcementOfficialUnit/nc:OrganizationIdentification/nc:IdentificationID", + "lawenforcementunit"), + Map.entry( + "j:Citation\\nc:ActivityIdentification\\tyler:JurisdictionCode", + "citationjurisdiction"), + Map.entry("nc:CaseCategoryText", "casecategory"), + Map.entry("nc:LocationCountryName", "country"), + Map.entry("nc:BinaryFormatStandardName", "documenttype"), + Map.entry("nc:BinaryCategoryText", "filingcomponent"), + Map.entry("nc:LocationStateName", "state"), + Map.entry("nc:PersonNameSuffixText", "namesuffix"), + Map.entry("nc:BinaryLocationURI", "filetype"), + Map.entry("nc:DocumentIdentification/nc:IdentificationSourceText", "crossreference"), + Map.entry("nc:PrimaryLanguage\\nc:LanguageCode", "language"), + Map.entry("nc:PersonPhysicalFeature\\nc:PhysicalFeatureCategoryCode", "physicalfeature"), + Map.entry("nc:PersonHairColorCode", "haircolor"), + Map.entry("nc:PersonEyeColorCode", "eyecolor"), + Map.entry("nc:PersonEthnicityText", "ethnicity"), + Map.entry("nc:PersonRaceText", "race"), + Map.entry("nc:VehicleMakeCode", "vehiclemake"), + Map.entry("nc:VehicleColorPrimaryCode", "vehiclecolor"), + Map.entry("tyler:CaseTypeText", "casetype"), + Map.entry("tyler:DamageAmountCode", "damageamount"), + Map.entry("tyler:DisclaimerRequirementCode", "disclaimerrequirement"), + Map.entry("tyler:FilerTypeText", "filertype"), + Map.entry("tyler:CaseSubTypeText", "casesubtype"), + Map.entry("tyler:VehicleTypeCode", "vehicletype"), + Map.entry("tyler:MotionTypeCode", "motiontype"), + Map.entry("tyler:AnswerCode", "answer"), + Map.entry("tyler:QuestionCode", "question"), + Map.entry("tyler:RemedyCode", "procedureremedy"), + Map.entry("tyler:DataFieldConfigCode", "datafieldconfig"), + Map.entry("tyler:DocumentOptionalService", "optionalservices")); + + @Override + public Map xmlElemToTableName() { + return ecf4Map; + } + public static CodeDatabase fromDS(Jurisdiction jurisdiction, DataSource ds) { try { CodeDatabase cd = new CodeDatabase(jurisdiction, ds.getConnection()); diff --git a/proxyserver/src/main/java/edu/suffolk/litlab/efsp/tyler/ecfcodes/CodeUpdater.java b/proxyserver/src/main/java/edu/suffolk/litlab/efsp/tyler/ecfcodes/CodeUpdater.java index 8a3fe907..e150d616 100644 --- a/proxyserver/src/main/java/edu/suffolk/litlab/efsp/tyler/ecfcodes/CodeUpdater.java +++ b/proxyserver/src/main/java/edu/suffolk/litlab/efsp/tyler/ecfcodes/CodeUpdater.java @@ -74,62 +74,6 @@ public class CodeUpdater { private static final Logger log = LoggerFactory.getLogger(CodeUpdater.class); - // TODO(brycew-later): there's little more info on these mappings and how they combine besides: - // The name of an ECF element to be substituted by a court-specific codelist or extension - // Is this actually an XPath? Should figure it out - public static final Map ecf4ElemToTableName = - Map.ofEntries( - Map.entry("cext:BondTypeText", "bond"), - Map.entry("cext:Charge/cext:ChargeStatute/j:StatuteLevelText", "degree"), - Map.entry("cext:Charge\\cext:ChargePhaseText", "chargephase"), - Map.entry("cext:GeneralOffenseText", "generaloffense"), - Map.entry("cext:StatuteTypeText", "statutetype"), - Map.entry( - "cext:Charge/cext:ChargeStatute/j:StatuteCodeIdentification/nc:IdentificationID", - "statute"), - Map.entry("ecf:CaseParticipantRoleCode", "partytype"), - Map.entry("ecf:FilingStatusCode", "filingstatus"), - Map.entry("ecf:ServiceRecipientID/nc:IdentificationSourceText", "servicetype"), - Map.entry( - "ecf:PersonDriverLicense/nc:DriverLicenseIdentification/nc:IdentificationCategoryText", - "driverlicensetype"), - Map.entry("j:/ArrestCharge/j:ArrestLocation/nc:LocationName", "arrestlocation"), - Map.entry("j:RegisterActionDescriptionText", "filing"), - Map.entry( - "j:ArrestOfficial/j:EnforcementOfficialUnit/nc:OrganizationIdentification/nc:IdentificationID", - "lawenforcementunit"), - Map.entry( - "j:Citation\\nc:ActivityIdentification\\tyler:JurisdictionCode", - "citationjurisdiction"), - Map.entry("nc:CaseCategoryText", "casecategory"), - Map.entry("nc:LocationCountryName", "country"), - Map.entry("nc:BinaryFormatStandardName", "documenttype"), - Map.entry("nc:BinaryCategoryText", "filingcomponent"), - Map.entry("nc:LocationStateName", "state"), - Map.entry("nc:PersonNameSuffixText", "namesuffix"), - Map.entry("nc:BinaryLocationURI", "filetype"), - Map.entry("nc:DocumentIdentification/nc:IdentificationSourceText", "crossreference"), - Map.entry("nc:PrimaryLanguage\\nc:LanguageCode", "language"), - Map.entry("nc:PersonPhysicalFeature\\nc:PhysicalFeatureCategoryCode", "physicalfeature"), - Map.entry("nc:PersonHairColorCode", "haircolor"), - Map.entry("nc:PersonEyeColorCode", "eyecolor"), - Map.entry("nc:PersonEthnicityText", "ethnicity"), - Map.entry("nc:PersonRaceText", "race"), - Map.entry("nc:VehicleMakeCode", "vehiclemake"), - Map.entry("nc:VehicleColorPrimaryCode", "vehiclecolor"), - Map.entry("tyler:CaseTypeText", "casetype"), - Map.entry("tyler:DamageAmountCode", "damageamount"), - Map.entry("tyler:DisclaimerRequirementCode", "disclaimerrequirement"), - Map.entry("tyler:FilerTypeText", "filertype"), - Map.entry("tyler:CaseSubTypeText", "casesubtype"), - Map.entry("tyler:VehicleTypeCode", "vehicletype"), - Map.entry("tyler:MotionTypeCode", "motiontype"), - Map.entry("tyler:AnswerCode", "answer"), - Map.entry("tyler:QuestionCode", "question"), - Map.entry("tyler:RemedyCode", "procedureremedy"), - Map.entry("tyler:DataFieldConfigCode", "datafieldconfig"), - Map.entry("tyler:DocumentOptionalService", "optionalservices")); - /** * The path to the keystore file, containing the x509 cert used to sign headers to download zips. */ @@ -352,7 +296,7 @@ private boolean downloadCourtTables( policyResp.getRuntimePolicyParameters().getCourtCodelist().stream() .collect( Collectors.toMap( - (cc1) -> ecf4ElemToTableName.get(cc1.getECFElementName().getValue()), + (cc1) -> cd.xmlElemToTableName().get(cc1.getECFElementName().getValue()), // Tyler gives us URLs w/ spaces, which aren't valid. This makes them valid (cc1) -> cc1.getCourtCodelistURI() @@ -531,7 +475,7 @@ public boolean replaceSome( log.info("Downloading system tables for {}", cd.getJurisdiction()); boolean success = downloadSystemTables(baseUrl, cd, signer); - var tablesToDeleteDomain = ecf4ElemToTableName.values(); + var tablesToDeleteDomain = cd.xmlElemToTableName().values(); for (String table : tablesToDeleteDomain) { cd.createTableIfAbsent(table); cd.deleteFromTable(table); @@ -676,7 +620,9 @@ private static CodeDatabaseAPI makeCodeDatabase(Jurisdiction jurisdiction) { 10, 100); - return CodeDatabase.fromDS(jurisdiction, ds); + return switch (jurisdiction.getVendor()) { + case Jurisdiction.Vendor.TYLER -> CodeDatabase.fromDS(jurisdiction, ds); + }; } catch (Exception ex) { throw new RuntimeException(ex); } diff --git a/proxyserver/src/test/java/edu/suffolk/litlab/efsp/ecfcodes/tyler/CodeDatabaseTest.java b/proxyserver/src/test/java/edu/suffolk/litlab/efsp/ecfcodes/tyler/CodeDatabaseTest.java index 595a19bb..fa6591b3 100644 --- a/proxyserver/src/test/java/edu/suffolk/litlab/efsp/ecfcodes/tyler/CodeDatabaseTest.java +++ b/proxyserver/src/test/java/edu/suffolk/litlab/efsp/ecfcodes/tyler/CodeDatabaseTest.java @@ -13,7 +13,6 @@ import edu.suffolk.litlab.efsp.tyler.ecfcodes.CaseType; import edu.suffolk.litlab.efsp.tyler.ecfcodes.CodeDatabase; import edu.suffolk.litlab.efsp.tyler.ecfcodes.CodeTableConstants; -import edu.suffolk.litlab.efsp.tyler.ecfcodes.CodeUpdater; import edu.suffolk.litlab.efsp.tyler.ecfcodes.CourtLocationInfo; import edu.suffolk.litlab.efsp.tyler.ecfcodes.OptionalServiceCode; import edu.suffolk.litlab.efsp.tyler.ecfcodes.ServiceCodeType; @@ -62,7 +61,7 @@ public void tearDown() throws SQLException { @Test public void allNamespacesMapToTables() { - for (String table : CodeUpdater.ecf4ElemToTableName.values()) { + for (String table : cd.xmlElemToTableName().values()) { if (!table.equalsIgnoreCase("optionalservices")) { assertNotEquals( CodeTableConstants.getTableColumns(table).size(), 0, "Expected " + table + " to exist");