new SetupTool(opts)
Methods to configure the script and emit and read mapping files for conversion of human-readable court and jurisdiction descriptions into valid machine-readable data conformant to the Legal Resource Registry.
Parameters:
Name | Type | Description |
---|---|---|
opts |
Object | command-line options set by the |
Methods
addCourtJurisdictionMapEntry()
Attempt to match the (possibly reprocessed) spreadsheet court
and jurisdiction values in the jurisdictions
segment of the
default jurisdiction in the LRR, and add those that fail to an
object for reference.
Properties:
Name | Type | Description |
---|---|---|
courtJurisdictionMap |
Object | court and jurisdiction codes, keyed to the known (but invalid) values of court and jurisdiction derived from the spreadsheet |
- Source:
- See:
addCourtMapEntry(line)
Attempt to match the (possibly reprocessed) spreadsheet court value to a court registered in the LRR, and add those that fail to an array for reference.
Parameters:
Name | Type | Description |
---|---|---|
line |
Object | the content of a spreadsheet line, keyed to column nicknames |
Properties:
Name | Type | Description |
---|---|---|
courtMap |
Object | container for court name-to-code pairings to be edited by the operator |
checkCourtJurisdictionMap()
Check the jurisdiction values in courtJurisdictionMap
for validity of syntax and presence in the LRR. The court value
is not tested, as invalid court values are covered by a warning,
and will not block processing.
- Source:
- See:
Throws:
an error listing invalid jurisdictions
checkCourtMap()
Check that the code element of each name-to-code pair
in courtMap
satifies two conditions:
- the code is not empty; and
- the code is registered in the
courts
segment of the default jurisdiction in the LRR
Collect failures in two lists corresponding to the type of failure, and issue a helpful warning for the latter and throw a helpful error for the former.
checkDefaultJurisdictionCode()
Check that the jurisdictionCode
value read
from make-data-config.json
has been changed from the
sample value of "xx".
Throws:
a helpful error
extractCourtNameToKeyMap()
Build a one-to-one map of human-readable court names to machine-readable LRR court codes.
Properties:
Name | Type | Description |
---|---|---|
courtNameMap |
Object | container for the name-to-code mapping |
extractJurisdiction(line, currentJurisdictionCodeopt)
Attempt to match the spreadsheet jurisdiction
value
with a jurisdiction name. If a match is found, replace the spreadsheet
value with the corresponding LRR machine-readable code. (This match
attempt will succeed only in the rare event that the data collector
has provided Jurism-style jurisdiction values in the Jurisdiction column
of the spreadsheet.)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
line |
Object | the content of a spreadsheet line, keyed to column nicknames |
|
currentJurisdictionCode |
string |
<optional> |
jurisdiction code to use for the match attempt |
extractJurisdictionNames()
Compose human-readable descriptive names for all subjurisdictions of the default jurisdiction, and set them as keys mapped to their machine-readable LRR codes.
Properties:
Name | Type | Description |
---|---|---|
jurisdictionNames |
Object | a map of jurisdiction names to machine-readable codes |
getCurrentJurisdictionCode() → {string}
A spreadsheet entry may declare a jurisdiction other than the default. Extract the top-level jurisdiction from a jurisdiction code and return its value.
Returns:
- Type
- string
loadConfigFile()
Load the configuration file to set values need to run the script.
Parameters:
Name | Type | Description |
---|---|---|
obj.jurisdictionCode |
string | the short-code of the default jurisdiction |
obj.jurisdictionName |
string | the long-form name of the jurisdiction |
obj.jurisdictionDescPath |
string | the path to the Legal Resource Registry files on this system |
Properties:
Name | Type | Description |
---|---|---|
defaultJurisdiction |
string | the default jurisdiction (the short-code) |
inputFileName |
string | the input file name (derived from the long-form jurisdiction name) |
defaultJurisdictionPath |
string | the path to the default jurisdiction in the LRR (derived from the short-code) |
loadCourtJurisdictionMap()
Read the operator-edited jurisdiction map file for reference.
Properties:
Name | Type | Description |
---|---|---|
courtJurisdictionMap |
Object | court and jurisdiction codes, keyed to the known (but invalid) values of court and jurisdiction derived from the spreadsheet |
loadCourtMap()
Read the array of name-to-code pairs for courts in the default jurisdiction, sorting first by the length of the name to avoid false positives, then alphabetically just as a flourish.
Properties:
Name | Type | Description |
---|---|---|
courtMap |
Object | container for operator-edited court name-to-code pairings |
loadDataForCurrentJurisdiction(line)
Read the data file for the current jurisdiction
if it is not already set on the jurisObj
object containing
LRR data.
Parameters:
Name | Type | Description |
---|---|---|
line |
Object | the content of a spreadsheet line, keyed to column nicknames |
loadJurisObj()
Load the default jurisdiction data.
Properties:
Name | Type | Description |
---|---|---|
jurisObj |
Object | the runtime container for LRR data |
loadUseDocsOnItems()
If a file useDocsOnItems.txt
exists
in the data directory, read it as a newline-delimited
list of CultExp IDs and set their values in an
array on this class instance.
Properties:
Name | Type | Description |
---|---|---|
useDocsOnItems |
Array.<Object> | a resulting array of CultExp IDs |
resetCourtDetails(line)
Replace spreadsheet values for court, and optionally division, type, and human-readable jurisdiction with values from the operator-edited map file.
Parameters:
Name | Type | Description |
---|---|---|
line |
Object | the content of a spreadsheet line, keyed to column nicknames |
- Source:
- See:
resetCourtJurisdictionDetails(line)
Replace spreadsheet court and jurisdiction values with value from the operator-edited map file.
Parameters:
Name | Type | Description |
---|---|---|
line |
Object | the content of a spreadsheet line, keyed to column nicknames |
- Source:
- See:
setupConfigFile()
Write a sample config file to disk if no config file exists.
setupCourtJurisdictionMap()
Create an empty court-in-jurisdiction code map file if none is found.
Properties:
Name | Type | Description |
---|---|---|
(string} |
courtJurisdictionMapPath - path to the court-in-jurisdiction map file to be edited |
|
hasCourtJurisdictionMapFile |
boolean | flag indicating whether file has been freshly created. |
setupCourtMap()
Create an empty court code map file if none is found.
Properties:
Name | Type | Description |
---|---|---|
(string} |
courtMapPath - path to the court map file to be edited |
|
hasCourtMapFile |
boolean | flag indicating whether file has been freshly created. |
validateJurisdictionCode() → {boolean}
Check that a string conforms to the syntax of
a jurisdiction code, and matches a jurisdiction code
in the jurisdictions
segment of the LRR. Return true
if a match is found, otherwise false
.
Returns:
- Type
- boolean
validateLrrPath()
If the data file of the default jurisdiction does not exist in the Legal Resource Registry, throw an error. This is limited to path validation, and does not extend to validation of the LRR itself.