From f87f24c6fd9196cdef315efa96b19b3df5532c69 Mon Sep 17 00:00:00 2001 From: ClarkeCode Date: Wed, 15 Mar 2023 01:23:37 -0400 Subject: Re-evaluated approach for dataloading --- docs/simulation/provinces.md | 74 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 14 deletions(-) (limited to 'docs') diff --git a/docs/simulation/provinces.md b/docs/simulation/provinces.md index 014735c..88eea50 100644 --- a/docs/simulation/provinces.md +++ b/docs/simulation/provinces.md @@ -10,10 +10,13 @@ classDiagram string tradeGood Int64 lifeRating bool hasLegalSlavery + Int64 fortLevel Int64 navalBaseLevel Int64 railroadLevel + string regionId + string continentId } ``` -## Dataloading +# Dataloading +To populate the Province structures, the following data files will be loaded in the following order: +1. `provinces.json` +2. `regions.json` +3. `continents.json` + +## 1. Provinces.json The `provinces.json` file shall look like: ```json { "provinces": [ - ... - ], - - "regions": [ - {"id": "", "name": "", "provinceIds": [...]}, - ... - ], - - "continents": [ - {"id": "", "name": "", "provinceIds": [...]}, + {"id": 123, "provinceName": "abc", ...}, ... ] } @@ -52,7 +52,53 @@ Where the `"provinces"` array contains valid province JSON objects which conform | fortLevel | int | optional | 0 | | navalBaseLevel | int | optional | 0 | | railroadLevel | int | optional | 0 | - -### Notes on values +### Notes on values: - The values of `fortLevel`, `navalBaseLevel`, and `railroadLevel` may not be negative -- The value of `tradeGood` may only be a Good Identifier string as defined in [goods.md](goods.md) or `"no_good"` \ No newline at end of file +- The value of `tradeGood` may only be a Good Identifier string as defined in [goods.md](goods.md) or `"no_good"` + + +## 2. Regions.json +The `regions.json` file shall look like: +```json +{ + "regions": [ + {"id": "abc", "provinceIds": [123, 456, ...]}, + ... + ] +} +``` +Where the `"regions"` array contains valid region JSON objects which conform to the following key-value pairs: +| Key | type | Required? | Default Value | +|--|--|--|--| +| id | string | required | N/A | +| provinceIds | Array[int] | required | N/A | +### Notes on values: +- The value of `id` may not be an empty string +- The value of `id` must be unique among all continents +- `provinceIds` may be an empty array; an empty array should be logged as a warning +- The content of `provinceIds` may only be Province Identifier integers as defined above +- A province may only belong to a single region, any attempts to re-assign a province's region during dataloading should be ignored and logged as an error + + + +## 3. Continents.json +The `continents.json` file shall look like: +```json +{ + "continents": [ + {"id": "abc", "provinceIds": [123, 456, ...]}, + ... + ] +} +``` +Where the `"continents"` array contains valid continent JSON objects which conform to the following key-value pairs: +| Key | type | Required? | Default Value | +|--|--|--|--| +| id | string | required | N/A | +| provinceIds | Array[int] | required | N/A | +### Notes on values: +- The value of `id` may not be an empty string +- The value of `id` must be unique among all continents +- `provinceIds` may be an empty array; an empty array should be logged as a warning +- The content of `provinceIds` may only be Province Identifier integers as defined in [provinces.md](provinces.md) +- A province may only belong to a single continent, any attempts to re-assign a province's continent during dataloading should be ignored and logged as an error -- cgit v1.2.3-56-ga3b1