diff --git a/tools/exampleData/Certification.csv b/doc/exampleData/Certification.csv similarity index 100% rename from tools/exampleData/Certification.csv rename to doc/exampleData/Certification.csv diff --git a/tools/exampleData/Certification_20190327.csv b/doc/exampleData/Certification_20190327.csv similarity index 100% rename from tools/exampleData/Certification_20190327.csv rename to doc/exampleData/Certification_20190327.csv diff --git a/tools/exampleData/EUCountries.csv b/doc/exampleData/EUCountries.csv similarity index 100% rename from tools/exampleData/EUCountries.csv rename to doc/exampleData/EUCountries.csv diff --git a/tools/exampleData/FAOCountriesNOCS_EXPORT.csv b/doc/exampleData/FAOCountriesNOCS_EXPORT.csv similarity index 100% rename from tools/exampleData/FAOCountriesNOCS_EXPORT.csv rename to doc/exampleData/FAOCountriesNOCS_EXPORT.csv diff --git a/tools/exampleData/FAOSTAT_data_11-9-2017.csv b/doc/exampleData/FAOSTAT_data_11-9-2017.csv similarity index 100% rename from tools/exampleData/FAOSTAT_data_11-9-2017.csv rename to doc/exampleData/FAOSTAT_data_11-9-2017.csv diff --git a/tools/exampleData/FAOStatData_20180209.csv b/doc/exampleData/FAOStatData_20180209.csv similarity index 100% rename from tools/exampleData/FAOStatData_20180209.csv rename to doc/exampleData/FAOStatData_20180209.csv diff --git a/tools/exampleData/FRACountries.csv b/doc/exampleData/FRACountries.csv similarity index 100% rename from tools/exampleData/FRACountries.csv rename to doc/exampleData/FRACountries.csv diff --git a/tools/exampleData/climaticDomain.csv b/doc/exampleData/climaticDomain.csv similarity index 100% rename from tools/exampleData/climaticDomain.csv rename to doc/exampleData/climaticDomain.csv diff --git a/tools/exampleData/fra-2015-forest-areas.csv b/doc/exampleData/fra-2015-forest-areas.csv similarity index 100% rename from tools/exampleData/fra-2015-forest-areas.csv rename to doc/exampleData/fra-2015-forest-areas.csv diff --git a/tools/exampleData/panEuropeanQualitativeQuestionnaire.csv b/doc/exampleData/panEuropeanQualitativeQuestionnaire.csv similarity index 100% rename from tools/exampleData/panEuropeanQualitativeQuestionnaire.csv rename to doc/exampleData/panEuropeanQualitativeQuestionnaire.csv diff --git a/src/test/bulkDownloadComparison/compareFiles.ts b/src/test/bulkDownloadComparison/compareFiles.ts deleted file mode 100644 index eabf7b53df..0000000000 --- a/src/test/bulkDownloadComparison/compareFiles.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { CountryIso } from 'meta/area' - -import { getFileName } from 'test/bulkDownloadComparison/getFileName' -import { readCSV } from 'test/bulkDownloadComparison/readCSV' -import { RawFile, RawFileRow, Value, ValueDiff } from 'test/bulkDownloadComparison/types' -import { parseValue } from 'test/dataExportComparison/parseValue' - -const skip: Array = ['regions', 'name', '4a_fo_unknown', '3a_prim_no_unknown'] - -const reduceArray = (file: RawFile): Value => - file.reduce((previousValue: Value, currentValue: RawFileRow) => { - const { iso3, year, ...rest } = currentValue - - // eslint-disable-next-line no-param-reassign - if (!previousValue[iso3]) previousValue[iso3] = {} - // eslint-disable-next-line no-param-reassign - if (!previousValue[iso3][year]) previousValue[iso3][year] = {} - - // eslint-disable-next-line no-param-reassign - previousValue[currentValue.iso3][currentValue.year] = rest - - return previousValue - }, {} as Value) - -export const compareFiles = async (outPath: string, fileName: string): Promise> => { - const localFilename = `${outPath}/local/${getFileName(fileName)}` - const localFile = await readCSV(localFilename) - const legacyFileName = `${outPath}/legacy/${getFileName(fileName)}` - const legacyFile = await readCSV(legacyFileName) - - // Expect legacy data is the correct - // Source of truth, compare against: - const legacy = reduceArray(legacyFile) - - // Expect to be same as legacy - const local = reduceArray(localFile) - - const countryIsos = Object.keys(legacy) as Array - const years = Object.keys(legacy[countryIsos[0]]) - const variables = Object.keys(legacy[countryIsos[0]][years[0]]).filter((variable) => { - return !skip.includes(variable) - }) - - const diff: ValueDiff[] = [] - countryIsos.forEach((countryIso) => { - years.forEach((year) => { - variables.forEach((variableName) => { - const valueLegacy = legacy[countryIso][year][variableName] - const valueLocal = local[countryIso][year][variableName] - const error = Math.abs(parseValue(valueLocal) - parseValue(valueLegacy)) >= 0.01 - if (error) { - diff.push({ - fileName, - countryIso, - year, - variableName, - valueLegacy, - valueLocal, - }) - } - }) - }) - }) - - return diff -} diff --git a/src/test/bulkDownloadComparison/downloadFile.ts b/src/test/bulkDownloadComparison/downloadFile.ts deleted file mode 100644 index b8b13ce54f..0000000000 --- a/src/test/bulkDownloadComparison/downloadFile.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { createWriteStream, existsSync, mkdir } from 'fs' -import axios from 'axios' - -export const downloadFile = async (fileUrl: string, outputLocationPath: string, fileName: string): Promise => { - if (!existsSync(outputLocationPath)) { - mkdir(outputLocationPath, { recursive: true }, (err) => { - if (err) throw err - }) - } - - const path = `${outputLocationPath}/${fileName}.zip` - const writer = createWriteStream(path) - - // Workaround for: - // Jest has detected the following 1 open handle potentially keeping Jest from exiting - // eslint-disable-next-line @typescript-eslint/no-empty-function - await process.nextTick(() => {}) - - return axios({ - method: 'get', - url: fileUrl, - responseType: 'stream', - }).then((response) => { - return new Promise((resolve, reject) => { - response.data.pipe(writer) - let error: Error = null - writer.on('error', (err: Error) => { - error = err - writer.close() - reject(err) - }) - writer.on('close', () => { - if (!error) { - resolve(path) - } - }) - }) - }) -} diff --git a/src/test/bulkDownloadComparison/getFileName.ts b/src/test/bulkDownloadComparison/getFileName.ts deleted file mode 100644 index 25ee3b4ed3..0000000000 --- a/src/test/bulkDownloadComparison/getFileName.ts +++ /dev/null @@ -1,10 +0,0 @@ -// Get csv file name with timestamp -export const getFileName = (name: string): string => { - const date = new Date() - const year = date.getFullYear() - const month = - (date.getMonth() + 1).toString().length > 1 ? date.getMonth() + 1 : `0${(date.getMonth() + 1).toString()}` - const day = date.getDate().toString().length > 1 ? date.getDate() : `0${date.getDate().toString()}` - const timestamp = `${year}_${month}_${day}` - return `${name}_${timestamp}.csv` -} diff --git a/src/test/bulkDownloadComparison/index.ts b/src/test/bulkDownloadComparison/index.ts deleted file mode 100644 index 405e3e1619..0000000000 --- a/src/test/bulkDownloadComparison/index.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { readdirSync, rmSync } from 'fs' -import * as fs from 'fs/promises' -import * as extract from 'extract-zip' -import * as JSON2CSV from 'json2csv' - -import { compareFiles } from 'test/bulkDownloadComparison/compareFiles' -import { downloadFile } from 'test/bulkDownloadComparison/downloadFile' -import { getFileName } from 'test/bulkDownloadComparison/getFileName' - -const fileNames = ['Annual', 'FRA_Years', 'Intervals'] - -const outPath = `${__dirname}/tmp` - -afterAll(() => { - rmSync(`${outPath}`, { recursive: true, force: true }) -}) - -describe('Bulk Download comparison', () => { - test('compare ', async () => { - // Download files - const legacyUrl = 'https://fra-data.fao.org/api/export/bulk-download' - const localUrl = 'http://localhost:9001/api/file/bulk-download?assessmentName=fra&cycleName=2020&countryIso=WO' - const legacy = await downloadFile(legacyUrl, outPath, 'legacy') - const local = await downloadFile(localUrl, outPath, 'local') - - // Extract files - await extract(local, { dir: `${outPath}/local` }) - await extract(legacy, { dir: `${outPath}/legacy` }) - - // Check all needed files exist - const localFiles = readdirSync(`${outPath}/local`, { withFileTypes: true }) - .filter((item) => !item.isDirectory()) - .map((item) => item.name) - const legacyFiles = readdirSync(`${outPath}/legacy`, { withFileTypes: true }) - .filter((item) => !item.isDirectory()) - .map((item) => item.name) - const expectedFileNames = fileNames.map((fileName: string) => getFileName(fileName)).concat('README.txt') - expect(localFiles).toEqual(expectedFileNames) - expect(legacyFiles).toEqual(expectedFileNames) - - // Get diff output - const diffs = (await Promise.all(fileNames.map((fileName) => compareFiles(outPath, fileName)))).flat() - - const csv = await JSON2CSV.parseAsync(diffs) - await fs.writeFile(`./diffs.csv`, csv) - }) -}) diff --git a/src/test/bulkDownloadComparison/jest.config.js b/src/test/bulkDownloadComparison/jest.config.js deleted file mode 100644 index def3872703..0000000000 --- a/src/test/bulkDownloadComparison/jest.config.js +++ /dev/null @@ -1,11 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires -const path = require('path') -// eslint-disable-next-line @typescript-eslint/no-var-requires -const sharedConfig = require('../../../jest.config') - -module.exports = { - ...sharedConfig, - rootDir: path.resolve(__dirname, '..', '..', '..'), - testMatch: ['/src/test/bulkDownloadComparison/index.ts'], - testTimeout: 300000000, -} diff --git a/src/test/bulkDownloadComparison/readCSV.ts b/src/test/bulkDownloadComparison/readCSV.ts deleted file mode 100644 index 9e420104f7..0000000000 --- a/src/test/bulkDownloadComparison/readCSV.ts +++ /dev/null @@ -1,32 +0,0 @@ -import * as fs from 'fs' -import * as fastCsv from 'fast-csv' - -import { RawFile, RawFileRow } from 'test/bulkDownloadComparison/types' - -export const readCSV = async (fileName: string, options?: fastCsv.ParserOptions): Promise => { - const opts = { - objectMode: true, - delimiter: ',', - headers: true, - ignoreEmpty: true, - ...options, - } - - return new Promise((resolve, reject) => { - const data: RawFile = [] - - const readableStream = fs.createReadStream(fileName) - - fastCsv - .parseStream(readableStream, opts) - .on('error', (error: Error) => { - reject(error) - }) - .on('data', (row: RawFileRow) => { - data.push(row) - }) - .on('end', () => { - resolve(data) - }) - }) -} diff --git a/src/test/bulkDownloadComparison/types.ts b/src/test/bulkDownloadComparison/types.ts deleted file mode 100644 index 5753cc2e15..0000000000 --- a/src/test/bulkDownloadComparison/types.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { CountryIso } from 'meta/area' - -type VariableName = string -type Year = string -type ValueLegacy = string -type ValueLocal = string - -// Read csv to RawFile -export type RawFileRow = Record & { iso3: CountryIso; year: Year; variable: VariableName } -export type RawFile = Array - -export type Value = Record>> - -export type ValueDiff = { - fileName: string - countryIso: CountryIso - variableName: VariableName - year: Year - valueLegacy: ValueLegacy - valueLocal: ValueLocal -} diff --git a/src/tools/compareDashboardData/getData.ts b/src/tools/compareDashboardData/getData.ts deleted file mode 100644 index 2b04c6c6b2..0000000000 --- a/src/tools/compareDashboardData/getData.ts +++ /dev/null @@ -1,62 +0,0 @@ -import axios from 'axios' -import { tables } from 'tools/compareDashboardData/tables' - -import { AreaCode, Areas } from 'meta/area' -import { RecordAssessmentDatas } from 'meta/data' - -const target = 'https://fra-data.fao.org' -const source = 'http://localhost:9000' -const api = '/api/cycle-data/table/table-data' - -const assessmentName = 'fra' -const cycleName = '2020' -const commonParams = { - assessmentName, - cycleName, -} - -const getProdData = async (countryIso: AreaCode) => { - const allDatas = await Promise.all( - Object.keys(tables).map(async (tableName) => { - const isoCountry = Areas.isISOCountry(countryIso) - const params = { - ...commonParams, - countryIso, - countryISOs: [countryIso], - tableNames: isoCountry ? [tableName] : ['value_aggregate'], - aggregate: !isoCountry, - ...tables[tableName], - } - const url = `${target}${api}` - const { data } = await axios.get(url, { params }) - return data - }) - ) - - return { - [assessmentName]: { - [cycleName]: allDatas.reduce((acc, d) => { - return RecordAssessmentDatas.mergeRecordTableData(acc, d[assessmentName][cycleName]) - }, {}), - }, - } -} -const getLocalData = async (countryIso: AreaCode) => { - const params = { - ...commonParams, - countryIso, - countryISOs: [countryIso], - tableNames: Object.keys(tables), - } - const url = `${source}${api}` - return axios.get(url, { params }) -} - -export const getData = async (countryIso: AreaCode) => { - const prod = await getProdData(countryIso) - const { data: local } = await getLocalData(countryIso) - return { - prod, - local, - } -} diff --git a/src/tools/compareDashboardData/index.ts b/src/tools/compareDashboardData/index.ts deleted file mode 100644 index a4b55e0c47..0000000000 --- a/src/tools/compareDashboardData/index.ts +++ /dev/null @@ -1,116 +0,0 @@ -import 'tsconfig-paths/register' -import 'dotenv/config' - -import { getData } from 'tools/compareDashboardData/getData' -import { APIUtil } from 'tools/utils/API' -import { CSV } from 'tools/utils/CSV' -import { Numbers } from 'utils/numbers' -import { Promises } from 'utils/promises' - -import { AreaCode, Areas } from 'meta/area' -import { VariableName } from 'meta/assessment' -import { RecordAssessmentData } from 'meta/data' - -import { Logger } from 'server/utils/logger' - -import { tables } from './tables' - -type CSVData = { - areaCode: AreaCode - variableName: VariableName - columnName: string - valueProd: string - valueLocal: string - diff: string -} - -const _toArray = (data1: RecordAssessmentData, data2: RecordAssessmentData, areaCode: AreaCode) => { - const isCountry = Areas.isISOCountry(areaCode) - const arr: Array = [] - - Object.keys(data1).forEach((assessmentName) => - Object.keys(data1[assessmentName]).forEach((cycleName) => { - const cycleData = data1[assessmentName][cycleName] - Object.keys(cycleData).forEach((areaCode: AreaCode) => { - const areaData = cycleData[areaCode] - Object.keys(areaData).forEach((tableName) => { - const tableData = areaData[tableName] - Object.keys(tableData).forEach((columnName) => { - const columnData = tableData[columnName] - Object.keys(columnData).forEach((variableName) => { - if (tableName === 'originalDataPointValue') { - return - } - const meta = tables[tableName] - - if (!meta.columns.includes(columnName) || !meta.variables.includes(variableName)) { - return - } - - const valueLocal = columnData[variableName]?.raw - const valueProd = - data2[assessmentName][cycleName][areaCode][isCountry ? tableName : 'value_aggregate']?.[columnName]?.[ - variableName - ]?.raw - - if (!valueLocal || !valueProd) { - return - } - - const diff = Numbers.sub(valueLocal, valueProd).toString() - arr.push({ - areaCode, - columnName, - variableName, - valueLocal, - valueProd, - diff, - }) - }) - }) - }) - }) - }) - ) - - return arr -} - -const exec = async () => { - const { regionGroups, countries } = await APIUtil.getCountries({ - source: 'http://localhost:9000', - assessmentName: 'fra', - cycleName: '2020', - }) - - const countryISOs = countries.map((c) => c.countryIso).filter((c) => !c.startsWith('X')) - - const regionCodes = Object.values(regionGroups) - .flatMap((rg) => rg.regions.map((r) => r.regionCode)) - .filter((r) => r !== 'AT') - - const arr = ( - await Promises.each([...countryISOs, ...regionCodes], async (areaCode) => { - const { local, prod } = await getData(areaCode) - - return _toArray(local, prod, areaCode) - }) - ).flat() - // Enable this line to hide values without diff - // .filter((d) => !Numbers.eq(d.diff, '0')) - - if (arr.length === 0) { - Logger.debug('No differences found') - } else { - await CSV.write(arr, 'compareDashboardData') - } -} - -const start = new Date().getTime() -Logger.debug(`========== START COMPARE DASHBOARD DATA ${start}`) - -exec().then(() => { - const end = new Date().getTime() - Logger.debug(`========== END ${end} ELAPSED ${(end - start) / 1000}s`) - process.exit(0) -}) diff --git a/src/tools/compareDashboardData/tables.ts b/src/tools/compareDashboardData/tables.ts deleted file mode 100644 index 3757d34a89..0000000000 --- a/src/tools/compareDashboardData/tables.ts +++ /dev/null @@ -1,30 +0,0 @@ -export type Tables = Record; columns: Array }> -export const tables: Tables = { - carbonStock: { - variables: ['carbon_stock_biomass_total', 'carbon_stock_total'], - columns: ['1990', '2000', '2010', '2020'], - }, - extentOfForest: { variables: ['forestArea', 'totalLandArea'], columns: ['1990', '2000', '2010', '2020'] }, - forestAreaWithinProtectedAreas: { - variables: ['forest_area_within_protected_areas', 'forestArea'], - columns: ['2020'], - }, - forestCharacteristics: { - variables: ['plantedForest', 'naturalForestArea'], - columns: ['1990', '2000', '2010', '2020'], - }, - forestOwnership: { variables: ['other_or_unknown', 'private_ownership', 'public_ownership'], columns: ['2015'] }, - growingStockTotal: { variables: ['growing_stock_total'], columns: ['1990', '2000', '2010', '2020'] }, - primaryDesignatedManagementObjective: { - variables: [ - 'production', - 'multiple_use', - 'conservation_of_biodiversity', - 'protection_of_soil_and_water', - 'social_services', - 'other', - ], - columns: ['1990', '2000', '2010', '2020'], - }, - specificForestCategories: { variables: ['primary_forest'], columns: ['2020'] }, -} diff --git a/src/tools/screenshotDashboardCharts/index.ts b/src/tools/dashboardChartScreenshots/index.ts similarity index 100% rename from src/tools/screenshotDashboardCharts/index.ts rename to src/tools/dashboardChartScreenshots/index.ts diff --git a/src/tools/generateCache/index.ts b/src/tools/generateCache/index.ts index a1e21eef71..e64ae82112 100644 --- a/src/tools/generateCache/index.ts +++ b/src/tools/generateCache/index.ts @@ -11,6 +11,8 @@ const exec = async () => { const assessments = await AssessmentController.getAll({}) + await AssessmentController.generateMetaCache() + await Promise.all( assessments.map(async (assessment) => { // assessment and cycles metadata cache diff --git a/src/tools/generateMetaCache/index.ts b/src/tools/generateMetaCache/index.ts deleted file mode 100644 index 520786f19d..0000000000 --- a/src/tools/generateMetaCache/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -import 'tsconfig-paths/register' -import 'dotenv/config' - -import { AssessmentController } from 'server/controller/assessment' -import { DB } from 'server/db' -import { Logger } from 'server/utils/logger' - -const close = async () => { - await DB.$pool.end() -} - -const exec = async () => { - await AssessmentController.generateMetaCache() - await close() -} - -Logger.info('Meta cache generation starting') -exec().then(() => { - Logger.info('Meta cache generated') -}) diff --git a/src/tools/generatePasswordHash.ts b/src/tools/generatePasswordHash.ts new file mode 100644 index 0000000000..34a7be652c --- /dev/null +++ b/src/tools/generatePasswordHash.ts @@ -0,0 +1,6 @@ +import { passwordHash } from 'server/api/auth/utils/passwordUtils' +import { Logger } from 'server/utils/logger' + +if (process.argv[2]) passwordHash(process.argv[2]).then(Logger.info) +else Logger.info('usage: ts-node generatePasswordHash.ts \nEx: ts-node generatePasswordHash.ts 123') +export {} diff --git a/tools/geo/FRA_236_ISO_GEE.geojson b/src/tools/geo/FRA_236_ISO_GEE.geojson similarity index 100% rename from tools/geo/FRA_236_ISO_GEE.geojson rename to src/tools/geo/FRA_236_ISO_GEE.geojson diff --git a/tools/geo/FRA_236_ISO_GEE_Bounds.geojson b/src/tools/geo/FRA_236_ISO_GEE_Bounds.geojson similarity index 100% rename from tools/geo/FRA_236_ISO_GEE_Bounds.geojson rename to src/tools/geo/FRA_236_ISO_GEE_Bounds.geojson diff --git a/tools/geo/boundsImport.ts b/src/tools/geo/boundsImport.ts similarity index 92% rename from tools/geo/boundsImport.ts rename to src/tools/geo/boundsImport.ts index b46ba417e2..5801a623e2 100644 --- a/tools/geo/boundsImport.ts +++ b/src/tools/geo/boundsImport.ts @@ -3,16 +3,17 @@ import * as path from 'path' import { config } from 'dotenv' import * as pgPromise from 'pg-promise' -import { CountryIso } from '../../src/meta/area' -import { DB } from '../../src/server/db' +import { CountryIso } from 'meta/area' + +import { DB } from 'server/db' type Response = { features: Array<{ - geometry: any + geometry: never properties: { iso3: CountryIso - bounds: any - centroid: any + bounds: never + centroid: never } }> } diff --git a/tools/geo/forestEstimationsImport.ts b/src/tools/geo/forestEstimationsImport.ts similarity index 97% rename from tools/geo/forestEstimationsImport.ts rename to src/tools/geo/forestEstimationsImport.ts index def0d66596..09509acad8 100644 --- a/tools/geo/forestEstimationsImport.ts +++ b/src/tools/geo/forestEstimationsImport.ts @@ -2,10 +2,11 @@ import * as fs from 'fs/promises' import * as path from 'path' import { config } from 'dotenv' import * as pgPromise from 'pg-promise' +import { Objects } from 'utils/objects' -import { CountryIso } from '../../src/meta/area' -import { DB } from '../../src/server/db' -import { Objects } from '../../src/utils/objects' +import { CountryIso } from 'meta/area' + +import { DB } from 'server/db' type Response = { features: Array<{ diff --git a/tools/heroku/copy-env-vars.sh b/src/tools/heroku/copy-env-vars.sh similarity index 100% rename from tools/heroku/copy-env-vars.sh rename to src/tools/heroku/copy-env-vars.sh diff --git a/tools/add-user.sh b/tools/add-user.sh deleted file mode 100755 index 38a61b9fe5..0000000000 --- a/tools/add-user.sh +++ /dev/null @@ -1,120 +0,0 @@ -#!/bin/bash - -set -e - -USAGE="USAGE:\nadd-user.sh -l -n \"\" -c -r [-e ] [-c -r ...]\n" - -COUNTRIES=() -ROLES=() - -while getopts ":l::c::r::n::e:" opt; do - case $opt in - l) - LOGIN_EMAIL="$OPTARG" - ;; - n) - USERS_NAME="$OPTARG" - ;; - c) - COUNTRIES+=("$OPTARG") - ;; - r) - ROLES+=("$OPTARG") - ;; - e) - OTHER_EMAIL="$OPTARG" - ;; - \?) - echo "Invalid option: -$OPTARG" >&2 - exit 1 - ;; - :) - echo "Option -$OPTARG requires an argument." >&2 - exit 1 - ;; - esac -done - -COUNTRY_AMOUNT="${#COUNTRIES[@]}" -ROLE_AMOUNT="${#ROLES[@]}" - -if (( ROLE_AMOUNT != COUNTRY_AMOUNT )); then - echo "You should give the same amount of roles and countries" - echo "Instead you gave $COUNTRY_AMOUNT countries and $ROLE_AMOUNT roles" - exit 1 -fi - -if (( COUNTRY_AMOUNT < 1 )); then - printf "$USAGE" - exit 1 -fi - -if [ -z "$LOGIN_EMAIL" ]; then - printf "$USAGE" - exit 1 -fi - -if [ -z "$USERS_NAME" ]; then - printf "$USAGE" - exit 1 -fi - -if [ -z "$OTHER_EMAIL" ]; then - OTHER_EMAIL="$LOGIN_EMAIL" -fi - -for ROLE in "${ROLES[@]}" -do - case "$ROLE" in - COLLABORATOR|NATIONAL_CORRESPONDENT|REVIEWER) - ;; - *) - echo "Not a valid role $ROLE" - exit 1 - ;; - esac -done - -MIGRATION_NAME="${LOGIN_EMAIL//@}" - -echo "User $FRA_USER Country ${COUNTRIES[@]}" -echo "$MIGRATION_NAME" - -MIGRATION_SQL_FILE=`yarn run create-migration "add-user-$MIGRATION_NAME" | grep -Eo "(server.*up.sql)"` - -echo "Adding user $LOGIN_EMAIL to Migration file $MIGRATION_SQL_FILE" - -cat << EOF > "$MIGRATION_SQL_FILE" -INSERT INTO fra_user (email, name, login_email, lang) -VALUES ('$OTHER_EMAIL', '$USERS_NAME', '$LOGIN_EMAIL', 'en'); - -EOF - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -I=0 -for COUNTRY in "${COUNTRIES[@]}" -do - set +e - cat "$DIR/../node_modules/i18n-iso-countries/codes.json" | grep "\"$COUNTRY\"" - if [[ $? != 0 ]]; then - echo "ERROR: $COUNTRY is not a valid ISO 3166-1 alpha-3 code (https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3" - exit 1 - fi - set -e - - ROLE=`echo ${ROLES[$I]}` - echo "Adding role $ROLE for country $COUNTRY" - cat << EOF >> "$MIGRATION_SQL_FILE" -INSERT INTO user_country_role (user_id, country_iso, role) -VALUES ((SELECT last_value - FROM fra_user_id_seq), '$COUNTRY', '$ROLE'); - -EOF - I=$((I+1)) -done - -echo "These are your new migration files:" -git status | grep migrations -echo "Review them, if ok, commit and push" - diff --git a/tools/certifiedAreasCountryUdater.js b/tools/certifiedAreasCountryUdater.js deleted file mode 100644 index 1509998085..0000000000 --- a/tools/certifiedAreasCountryUdater.js +++ /dev/null @@ -1,62 +0,0 @@ -const R = require('ramda') -const Promise = require('bluebird') -const fs = Promise.promisifyAll(require('fs')) -const csv = Promise.promisifyAll(require('csv')) -const countryConfig = require('../server/controller/country/countryConfig') - -const exampleUsage = - 'node certifiedAreasCountryUdater.js exampleData/Certification.csv /tmp/countryConfigWithCertifiedAreas.json' - -if (process.argv.length < 4) { - console.log(`Usage: ${process.argv[0]} `) - console.log(`example:\n${exampleUsage}`) - process.exit() -} - -const inputCsvFile = process.argv[2] -console.log('reading file', inputCsvFile) -const outputFile = process.argv[3] - -const countryIsoCol = 0 - -const getCertifiedAreas = async (fileName) => { - const rawData = await fs.readFileAsync(fileName, { encoding: 'utf-8' }) - const parsedData = await csv.parseAsync(rawData) - const data = R.slice(2, undefined, parsedData) - - const years = R.pipe(R.head, R.tail)(parsedData) - // R.pipe( - // R.slice(1, 2), - // R.head, - // R.slice(1, undefined), - // )(parsedData) - - const getYearValues = (obj) => R.pipe((years) => years.map((y, i) => ({ [`${y}`]: obj[i + 1] })), R.mergeAll)(years) - - const rowObjects = R.pipe( - R.map((row) => ({ - [`${row[countryIsoCol]}`]: { - certifiedAreas: { - ...getYearValues(row), - }, - }, - })), - R.mergeAll - )(data) - - return rowObjects -} - -const update = async (inputCsvFile, outputFile) => { - try { - const inputData = await getCertifiedAreas(inputCsvFile) - const merged = R.mergeDeepLeft(inputData, countryConfig) - fs.writeFileSync(outputFile, JSON.stringify(merged, null, ' '), 'utf8') - console.log('Wrote merged values into: ', outputFile) - console.log('You should manually copy them over the countryConfig values') - } catch (e) { - console.log(e) - } -} - -update(inputCsvFile, outputFile) diff --git a/tools/climaticDomain.js b/tools/climaticDomain.js deleted file mode 100644 index 59509687ac..0000000000 --- a/tools/climaticDomain.js +++ /dev/null @@ -1,49 +0,0 @@ -const Promise = require('bluebird') -const R = require('ramda') -const countryConfig = require('../server/controller/country/countryConfig') - -const fs = Promise.promisifyAll(require('fs')) -const csv = Promise.promisifyAll(require('csv')) - -const exampleUsage = 'node faostatUpdater.js exampleData/climaticDomain.csv /tmp/countryConfigWithClimaticDomain.json' - -if (process.argv.length < 4) { - console.log(`Usage: ${process.argv[0]} `) - console.log(`example:\n${exampleUsage}`) - process.exit() -} - -const climaticDomainCsvFile = process.argv[2] -console.log('reading file', climaticDomainCsvFile) -const outputFile = process.argv[3] - -const update = async (climaticDomainCsvFile, outputFile) => { - try { - const rawClimaticDomainData = await fs.readFileAsync(climaticDomainCsvFile, { encoding: 'utf-8' }) - const parsedClimaticDomainData = await csv.parseAsync(rawClimaticDomainData) - const climaticDomainData = R.slice(1, undefined, parsedClimaticDomainData) - const countryClimaticDomainData = R.reduce( - (result, row) => { - const climaticDomainPercents2015 = { - tropical: Number(row[2]), - subtropical: Number(row[3]), - temperate: Number(row[4]), - boreal: Number(row[5]) + Number(row[6]), - } - return R.assoc(row[1], { climaticDomainPercents2015 }, result) - }, - {}, - climaticDomainData - ) - - const merged = R.mergeDeepLeft(countryClimaticDomainData, countryConfig) - await fs.writeFileAsync(outputFile, JSON.stringify(merged, null, ' '), 'utf8') - - console.log('Wrote merged values into: ', outputFile) - console.log('You should manually copy them over the countryConfig values') - } catch (e) { - console.log(e) - } -} - -update(climaticDomainCsvFile, outputFile) diff --git a/tools/countryChecker.js b/tools/countryChecker.js deleted file mode 100644 index 8e8affc3ac..0000000000 --- a/tools/countryChecker.js +++ /dev/null @@ -1,38 +0,0 @@ -const promise = require('bluebird') -const R = require('ramda') -const csv = promise.promisifyAll(require('csv')) -const fs = promise.promisifyAll(require('fs')) - -if (process.argv.length < 4) { - console.log(`Usage: ${process.argv[0]} `) - process.exit() -} - -const countryDataDiff = (dataset1, dataset2) => { - const moreInDataset1 = R.difference( - R.pluck(0, dataset1), - R.pluck(0, dataset2) - ) - const dataset1ObjectWithNames = R.fromPairs(dataset1) - return R.map(iso => [iso, dataset1ObjectWithNames[iso]], moreInDataset1) -} - -const compareWithFaoStat = async (countryDbExportFile, faostatCsvFile) => { - try { - const countryData = await fs.readFileAsync(countryDbExportFile, {encoding: 'utf-8'}) - const dbCountries = await csv.parseAsync(countryData) - const faostatRawData = await fs.readFileAsync(faostatCsvFile, {encoding: 'utf-8'}) - const parsedFaostatData = await csv.parseAsync(faostatRawData) - const faoStatCountryIsoAndName = R.pipe( - R.slice(1, undefined), - R.map(row => [R.nth(-2, row), R.nth(1, row)]), - R.uniqWith(([iso, name], [iso2, name2]) => iso === iso2) - )(parsedFaostatData) - console.log('These countries are in faostat data but not in DB') - console.log(countryDataDiff(faoStatCountryIsoAndName, dbCountries)) - console.log('These countries are in DB but not in faostat') - console.log(countryDataDiff(dbCountries, faoStatCountryIsoAndName)) - } catch (e) { console.log(e) } -} - -compareWithFaoStat(process.argv[2], process.argv[3]) diff --git a/tools/countryConfigToSql.js b/tools/countryConfigToSql.js deleted file mode 100644 index b8a314f1b5..0000000000 --- a/tools/countryConfigToSql.js +++ /dev/null @@ -1,5 +0,0 @@ -const countryConfig = require('../server/controller/country/countryConfig') - -const toSql = (key, value) => `UPDATE country SET config = '${value}' WHERE country_iso = '${key}';` - -Object.entries(countryConfig).forEach(([key, config]) => console.log(toSql(key, JSON.stringify(config)), '\n')) diff --git a/tools/createTraditionalTable.js b/tools/createTraditionalTable.js deleted file mode 100644 index bac013d70c..0000000000 --- a/tools/createTraditionalTable.js +++ /dev/null @@ -1,15 +0,0 @@ -/* - * To create table definition (CREATE TABLE... clause) use this script: - * - * ~/$ node tools/createTraditionalTable.js - * - * For spec names, see tableMappings.js (const mappings = ...) - */ -const sqlCreator = require('../server/dataTable/dataTableSqlCreator') - -if (process.argv.length < 3) { - console.log(`Usage: ${process.argv[0]} `) - process.exit() -} -const createSql = sqlCreator.createTableDefinition(process.argv[2]) -console.log(createSql) diff --git a/tools/dataMigration/_DBNames.ts b/tools/dataMigration/_DBNames.ts deleted file mode 100644 index 0b7d1e0df2..0000000000 --- a/tools/dataMigration/_DBNames.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const DBNames = { - getAssessmentSchema: (assessmentName: string): string => `assessment_${assessmentName}`.toLowerCase(), - getCycleSchema: (assessmentName: string, cycleName: string): string => - `assessment_${assessmentName}_${cycleName}`.toLowerCase(), -} diff --git a/tools/dataMigration/dataTable/dataTableSqlCreator.ts b/tools/dataMigration/dataTable/dataTableSqlCreator.ts deleted file mode 100644 index 48458afff9..0000000000 --- a/tools/dataMigration/dataTable/dataTableSqlCreator.ts +++ /dev/null @@ -1,78 +0,0 @@ -import * as R from 'ramda' -import * as assert from 'assert' -import * as tableMappings from './tableMappings' - -export const fixedFraTableColumns = [ - { name: 'country_iso', type: 'varchar(3) REFERENCES country(country_iso) NOT NULL' }, - { name: 'row_name', type: 'text' }, -] - -// @ts-ignore -export const columnNames = (columns: any) => R.pluck('name', columns) - -export const createInsert = (tableName: any, columnNamesStr: any, valuePlaceholdersStr: any, row: any) => [ - `INSERT INTO ${tableName} (${columnNamesStr}) VALUES (${valuePlaceholdersStr})`, - row, -] - -export const createColumnNames = (mapping: any) => - R.map((columnName: any) => `"${columnName}"`, [...columnNames(fixedFraTableColumns), ...columnNames(mapping.columns)]) - -export const createRowData = (countryIso: any, mapping: any, rowIndex: any, rawRow: any) => { - // These values are there for all fra tables - const fixedValues = [countryIso, mapping.getRowName(rowIndex)] - return [...fixedValues, ...rawRow] -} - -export function getMapping(tableSpecName: any): { [key: string]: any } { - return tableMappings.getMapping(tableSpecName) -} - -export const createSelect = (countryIso: any, tableSpecName: any, schemaName = 'public'): [string, string[]] => { - const mapping = getMapping(tableSpecName) - return [ - `SELECT ${createColumnNames(mapping)} FROM ${schemaName}.${mapping.tableName} WHERE country_iso = $1`, - [countryIso], - ] -} - -export const createDelete = (countryIso: any, tableSpecName: any): [string, string[]] => { - const mapping = getMapping(tableSpecName) - return [`DELETE FROM ${mapping.tableName} WHERE country_iso = $1;`, [countryIso]] -} - -export const createInserts = (countryIso: string, tableSpecName: string, tableData: any) => { - const mapping = getMapping(tableSpecName) - assert(mapping, `Could not find mapping for ${tableSpecName}`) - const tableSpecificColumnCount = tableData[0].length - const columnNames = createColumnNames(mapping) - const { tableName } = mapping - const columnNamesStr = R.join(',', columnNames) - const valuePlaceholdersStr = R.join( - ',', - R.map((idx: any) => `$${idx + 1}`, R.range(0, tableSpecificColumnCount + fixedFraTableColumns.length)) - ) - return R.addIndex(R.map)( - (row: any, rowIndex: any) => - createInsert(tableName, columnNamesStr, valuePlaceholdersStr, createRowData(countryIso, mapping, rowIndex, row)), - tableData - ) -} - -// Currently assumes all dynamic columns are of the same type (might have to change that later) -export const createTableDefinition = (tableSpecName: any) => { - const mapping = getMapping(tableSpecName) - const columnNames = createColumnNames(mapping) - // @ts-ignore - const dataTypes = [...R.pluck('type', fixedFraTableColumns), ...R.pluck('type', mapping.columns)] - assert( - dataTypes.length === columnNames.length, - 'Data types and column names arrays should be of the same length! Check your mapping' - ) - const columns = R.zip(columnNames, dataTypes) - const columnsStr = R.join( - ',\n', - R.map(([name, dataType]) => `${name} ${dataType}`, columns) - ) - return `CREATE TABLE ${mapping.tableName} (\n${columnsStr}, \nPRIMARY KEY (country_iso, row_name));` -} diff --git a/tools/dataMigration/dataTable/mappings/fra/annualReforestation.ts b/tools/dataMigration/dataTable/mappings/fra/annualReforestation.ts deleted file mode 100644 index 619f2667ea..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/annualReforestation.ts +++ /dev/null @@ -1,12 +0,0 @@ -export default { - tableName: 'annual_reforestation', - rows: { - names: ['reforestation'], - }, - columns: [ - { name: '1990_2000', type: 'numeric' }, - { name: '2000_2010', type: 'numeric' }, - { name: '2010_2015', type: 'numeric' }, - { name: '2015_2020', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/areaAffectedByFire.ts b/tools/dataMigration/dataTable/mappings/fra/areaAffectedByFire.ts deleted file mode 100644 index 3c191fa706..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/areaAffectedByFire.ts +++ /dev/null @@ -1,26 +0,0 @@ -export default { - tableName: 'area_affected_by_fire', - rows: { - names: ['total_land_area_affected_by_fire', 'of_which_on_forest'], - }, - columns: [ - { name: '2000', type: 'numeric' }, - { name: '2001', type: 'numeric' }, - { name: '2002', type: 'numeric' }, - { name: '2003', type: 'numeric' }, - { name: '2004', type: 'numeric' }, - { name: '2005', type: 'numeric' }, - { name: '2006', type: 'numeric' }, - { name: '2007', type: 'numeric' }, - { name: '2008', type: 'numeric' }, - { name: '2009', type: 'numeric' }, - { name: '2010', type: 'numeric' }, - { name: '2011', type: 'numeric' }, - { name: '2012', type: 'numeric' }, - { name: '2013', type: 'numeric' }, - { name: '2014', type: 'numeric' }, - { name: '2015', type: 'numeric' }, - { name: '2016', type: 'numeric' }, - { name: '2017', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/areaAffectedByFirePrint1.ts b/tools/dataMigration/dataTable/mappings/fra/areaAffectedByFirePrint1.ts deleted file mode 100644 index 0f5b848a37..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/areaAffectedByFirePrint1.ts +++ /dev/null @@ -1,17 +0,0 @@ -export default { - tableName: 'area_affected_by_fire', - rows: { - names: ['total_land_area_affected_by_fire', 'of_which_on_forest'], - }, - columns: [ - { name: '2000', type: 'numeric' }, - { name: '2001', type: 'numeric' }, - { name: '2002', type: 'numeric' }, - { name: '2003', type: 'numeric' }, - { name: '2004', type: 'numeric' }, - { name: '2005', type: 'numeric' }, - { name: '2006', type: 'numeric' }, - { name: '2007', type: 'numeric' }, - { name: '2008', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/areaAffectedByFirePrint2.ts b/tools/dataMigration/dataTable/mappings/fra/areaAffectedByFirePrint2.ts deleted file mode 100644 index 5e3076b09d..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/areaAffectedByFirePrint2.ts +++ /dev/null @@ -1,17 +0,0 @@ -export default { - tableName: 'area_affected_by_fire', - rows: { - names: ['total_land_area_affected_by_fire', 'of_which_on_forest'], - }, - columns: [ - { name: '2009', type: 'numeric' }, - { name: '2010', type: 'numeric' }, - { name: '2011', type: 'numeric' }, - { name: '2012', type: 'numeric' }, - { name: '2013', type: 'numeric' }, - { name: '2014', type: 'numeric' }, - { name: '2015', type: 'numeric' }, - { name: '2016', type: 'numeric' }, - { name: '2017', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/areaOfPermanentForestEstate.ts b/tools/dataMigration/dataTable/mappings/fra/areaOfPermanentForestEstate.ts deleted file mode 100644 index ecb5b72203..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/areaOfPermanentForestEstate.ts +++ /dev/null @@ -1,14 +0,0 @@ -export default { - tableName: 'area_of_permanent_forest_estate', - rows: { - names: ['area_of_permanent_forest_estate'], - }, - columns: [ - { name: 'applicable', type: 'text' }, - { name: '1990', type: 'numeric' }, - { name: '2000', type: 'numeric' }, - { name: '2010', type: 'numeric' }, - { name: '2015', type: 'numeric' }, - { name: '2020', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/biomassStock.ts b/tools/dataMigration/dataTable/mappings/fra/biomassStock.ts deleted file mode 100644 index 4eb925fe4f..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/biomassStock.ts +++ /dev/null @@ -1,18 +0,0 @@ -export default { - tableName: 'biomass_stock', - section: 'biomassStock', - rows: { - names: ['forest_above_ground', 'forest_below_ground', 'forest_deadwood'], - }, - columns: [ - { name: '1990', type: 'numeric' }, - { name: '2000', type: 'numeric' }, - { name: '2010', type: 'numeric' }, - { name: '2015', type: 'numeric' }, - { name: '2016', type: 'numeric' }, - { name: '2017', type: 'numeric' }, - { name: '2018', type: 'numeric' }, - { name: '2019', type: 'numeric' }, - { name: '2020', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/carbonStock.ts b/tools/dataMigration/dataTable/mappings/fra/carbonStock.ts deleted file mode 100644 index 8c891fab17..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/carbonStock.ts +++ /dev/null @@ -1,24 +0,0 @@ -export default { - tableName: 'carbon_stock', - section: 'carbonStock', - rows: { - names: [ - 'carbon_forest_above_ground', - 'carbon_forest_below_ground', - 'carbon_forest_deadwood', - 'carbon_forest_litter', - 'carbon_forest_soil', - ], - }, - columns: [ - { name: '1990', type: 'numeric' }, - { name: '2000', type: 'numeric' }, - { name: '2010', type: 'numeric' }, - { name: '2015', type: 'numeric' }, - { name: '2016', type: 'numeric' }, - { name: '2017', type: 'numeric' }, - { name: '2018', type: 'numeric' }, - { name: '2019', type: 'numeric' }, - { name: '2020', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/carbonStockSoilDepth.ts b/tools/dataMigration/dataTable/mappings/fra/carbonStockSoilDepth.ts deleted file mode 100644 index ae5d79597e..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/carbonStockSoilDepth.ts +++ /dev/null @@ -1,8 +0,0 @@ -export default { - tableName: 'carbon_stock_soil_depth', - section: 'carbonStock', - rows: { - names: ['soil_depth'], - }, - columns: [{ name: 'soil_depth', type: 'numeric' }], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/climaticDomain.ts b/tools/dataMigration/dataTable/mappings/fra/climaticDomain.ts deleted file mode 100644 index cfd52ebdae..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/climaticDomain.ts +++ /dev/null @@ -1,10 +0,0 @@ -export default { - tableName: 'climatic_domain', - section: 'extentOfForest', - rows: { - names: ['boreal', 'temperate', 'sub_tropical', 'tropical'], - }, - columns: [ - { name: 'percentOfForestArea2015', type: 'numeric' }, // "Override" in the UI - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/degradedForest.ts b/tools/dataMigration/dataTable/mappings/fra/degradedForest.ts deleted file mode 100644 index 4e0af79e3e..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/degradedForest.ts +++ /dev/null @@ -1,10 +0,0 @@ -export default { - tableName: 'degraded_forest', - rows: { - names: ['does_country_monitor', 'national_definition', 'how_monitored'], - }, - columns: [ - { name: 'monitors_yes_no', type: 'text' }, - { name: 'explanation', type: 'text' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/disturbances.ts b/tools/dataMigration/dataTable/mappings/fra/disturbances.ts deleted file mode 100644 index a22527e8bb..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/disturbances.ts +++ /dev/null @@ -1,26 +0,0 @@ -export default { - tableName: 'disturbances', - rows: { - names: ['insects', 'diseases', 'severe_weather_events', 'other'], - }, - columns: [ - { name: '2000', type: 'numeric' }, - { name: '2001', type: 'numeric' }, - { name: '2002', type: 'numeric' }, - { name: '2003', type: 'numeric' }, - { name: '2004', type: 'numeric' }, - { name: '2005', type: 'numeric' }, - { name: '2006', type: 'numeric' }, - { name: '2007', type: 'numeric' }, - { name: '2008', type: 'numeric' }, - { name: '2009', type: 'numeric' }, - { name: '2010', type: 'numeric' }, - { name: '2011', type: 'numeric' }, - { name: '2012', type: 'numeric' }, - { name: '2013', type: 'numeric' }, - { name: '2014', type: 'numeric' }, - { name: '2015', type: 'numeric' }, - { name: '2016', type: 'numeric' }, - { name: '2017', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/disturbancesPrint1.ts b/tools/dataMigration/dataTable/mappings/fra/disturbancesPrint1.ts deleted file mode 100644 index ac7d1cd331..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/disturbancesPrint1.ts +++ /dev/null @@ -1,17 +0,0 @@ -export default { - tableName: 'disturbances', - rows: { - names: ['insects', 'diseases', 'severe_weather_events', 'other'], - }, - columns: [ - { name: '2000', type: 'numeric' }, - { name: '2001', type: 'numeric' }, - { name: '2002', type: 'numeric' }, - { name: '2003', type: 'numeric' }, - { name: '2004', type: 'numeric' }, - { name: '2005', type: 'numeric' }, - { name: '2006', type: 'numeric' }, - { name: '2007', type: 'numeric' }, - { name: '2008', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/disturbancesPrint2.ts b/tools/dataMigration/dataTable/mappings/fra/disturbancesPrint2.ts deleted file mode 100644 index 89d5c493b3..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/disturbancesPrint2.ts +++ /dev/null @@ -1,17 +0,0 @@ -export default { - tableName: 'disturbances', - rows: { - names: ['insects', 'diseases', 'severe_weather_events', 'other'], - }, - columns: [ - { name: '2009', type: 'numeric' }, - { name: '2010', type: 'numeric' }, - { name: '2011', type: 'numeric' }, - { name: '2012', type: 'numeric' }, - { name: '2013', type: 'numeric' }, - { name: '2014', type: 'numeric' }, - { name: '2015', type: 'numeric' }, - { name: '2016', type: 'numeric' }, - { name: '2017', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/employment.ts b/tools/dataMigration/dataTable/mappings/fra/employment.ts deleted file mode 100644 index 540cdf3bfa..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/employment.ts +++ /dev/null @@ -1,26 +0,0 @@ -export default { - tableName: 'employment', - rows: { - names: [ - 'employment_in_forestry_and_logging', - 'of_which_silviculture_and_other_forestry_activities', - 'of_which_logging', - 'of_which_gathering_of_non_wood_forest_products', - 'of_which_support_services_to_forestry', - ], - }, - columns: [ - { name: '1990_total', type: 'numeric' }, - { name: '1990_female', type: 'numeric' }, - { name: '1990_male', type: 'numeric' }, - { name: '2000_total', type: 'numeric' }, - { name: '2000_female', type: 'numeric' }, - { name: '2000_male', type: 'numeric' }, - { name: '2010_total', type: 'numeric' }, - { name: '2010_female', type: 'numeric' }, - { name: '2010_male', type: 'numeric' }, - { name: '2015_total', type: 'numeric' }, - { name: '2015_female', type: 'numeric' }, - { name: '2015_male', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/employmentPrint1.ts b/tools/dataMigration/dataTable/mappings/fra/employmentPrint1.ts deleted file mode 100644 index 3f8d6c74dc..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/employmentPrint1.ts +++ /dev/null @@ -1,20 +0,0 @@ -export default { - tableName: 'employment', - rows: { - names: [ - 'employment_in_forestry_and_logging', - 'of_which_silviculture_and_other_forestry_activities', - 'of_which_logging', - 'of_which_gathering_of_non_wood_forest_products', - 'of_which_support_services_to_forestry', - ], - }, - columns: [ - { name: '1990_total', type: 'numeric' }, - { name: '1990_female', type: 'numeric' }, - { name: '1990_male', type: 'numeric' }, - { name: '2000_total', type: 'numeric' }, - { name: '2000_female', type: 'numeric' }, - { name: '2000_male', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/employmentPrint2.ts b/tools/dataMigration/dataTable/mappings/fra/employmentPrint2.ts deleted file mode 100644 index 93253b8230..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/employmentPrint2.ts +++ /dev/null @@ -1,20 +0,0 @@ -export default { - tableName: 'employment', - rows: { - names: [ - 'employment_in_forestry_and_logging', - 'of_which_silviculture_and_other_forestry_activities', - 'of_which_logging', - 'of_which_gathering_of_non_wood_forest_products', - 'of_which_support_services_to_forestry', - ], - }, - columns: [ - { name: '2010_total', type: 'numeric' }, - { name: '2010_female', type: 'numeric' }, - { name: '2010_male', type: 'numeric' }, - { name: '2015_total', type: 'numeric' }, - { name: '2015_female', type: 'numeric' }, - { name: '2015_male', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/forestAreaChange.ts b/tools/dataMigration/dataTable/mappings/fra/forestAreaChange.ts deleted file mode 100644 index 5b6664df60..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/forestAreaChange.ts +++ /dev/null @@ -1,12 +0,0 @@ -export default { - tableName: 'forest_area_change', - rows: { - names: ['forest_expansion', 'afforestation', 'natural_expansion', 'deforestation'], - }, - columns: [ - { name: '1990_2000', type: 'numeric' }, - { name: '2000_2010', type: 'numeric' }, - { name: '2010_2015', type: 'numeric' }, - { name: '2015_2020', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/forestAreaWithinProtectedAreas.ts b/tools/dataMigration/dataTable/mappings/fra/forestAreaWithinProtectedAreas.ts deleted file mode 100644 index 3be47f4fa7..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/forestAreaWithinProtectedAreas.ts +++ /dev/null @@ -1,21 +0,0 @@ -export default { - tableName: 'forest_area_within_protected_areas', - rows: { - names: [ - 'forest_area_within_protected_areas', - 'forest_area_with_long_term_management_plan', - 'of_which_in_protected_areas', - ], - }, - columns: [ - { name: '1990', type: 'numeric' }, - { name: '2000', type: 'numeric' }, - { name: '2010', type: 'numeric' }, - { name: '2015', type: 'numeric' }, - { name: '2016', type: 'numeric' }, - { name: '2017', type: 'numeric' }, - { name: '2018', type: 'numeric' }, - { name: '2019', type: 'numeric' }, - { name: '2020', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/forestOwnership.ts b/tools/dataMigration/dataTable/mappings/fra/forestOwnership.ts deleted file mode 100644 index 923086a6cb..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/forestOwnership.ts +++ /dev/null @@ -1,19 +0,0 @@ -export default { - tableName: 'forest_ownership', - rows: { - names: [ - 'private_ownership', - 'of_which_by_individuals', - 'of_which_by_private_businesses', - 'of_which_by_communities', - 'public_ownership', - 'other_or_unknown', - ], - }, - columns: [ - { name: '1990', type: 'numeric' }, - { name: '2000', type: 'numeric' }, - { name: '2010', type: 'numeric' }, - { name: '2015', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/forestPolicy.ts b/tools/dataMigration/dataTable/mappings/fra/forestPolicy.ts deleted file mode 100644 index c69fc35ceb..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/forestPolicy.ts +++ /dev/null @@ -1,15 +0,0 @@ -export default { - tableName: 'forest_policy', - rows: { - names: [ - 'policies_supporting_SFM', - 'legislations_supporting_SFM', - 'platform_for_stakeholder_participation', - 'existence_of_traceability_system', - ], - }, - columns: [ - { name: 'national_yes_no', type: 'text' }, - { name: 'sub_national_yes_no', type: 'text' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/graduationOfStudents.ts b/tools/dataMigration/dataTable/mappings/fra/graduationOfStudents.ts deleted file mode 100644 index 1154363ffd..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/graduationOfStudents.ts +++ /dev/null @@ -1,20 +0,0 @@ -export default { - tableName: 'graduation_of_students', - rows: { - names: ['doctoral_degree', 'masters_degree', 'bachelors_degree', 'technician_certificate', 'total'], - }, - columns: [ - { name: '1990_total', type: 'numeric' }, - { name: '1990_female', type: 'numeric' }, - { name: '1990_male', type: 'numeric' }, - { name: '2000_total', type: 'numeric' }, - { name: '2000_female', type: 'numeric' }, - { name: '2000_male', type: 'numeric' }, - { name: '2010_total', type: 'numeric' }, - { name: '2010_female', type: 'numeric' }, - { name: '2010_male', type: 'numeric' }, - { name: '2015_total', type: 'numeric' }, - { name: '2015_female', type: 'numeric' }, - { name: '2015_male', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/graduationOfStudentsPrint1.ts b/tools/dataMigration/dataTable/mappings/fra/graduationOfStudentsPrint1.ts deleted file mode 100644 index 8cbbc1aa51..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/graduationOfStudentsPrint1.ts +++ /dev/null @@ -1,14 +0,0 @@ -export default { - tableName: 'graduation_of_students', - rows: { - names: ['doctoral_degree', 'masters_degree', 'bachelors_degree', 'technician_certificate', 'total'], - }, - columns: [ - { name: '1990_total', type: 'numeric' }, - { name: '1990_female', type: 'numeric' }, - { name: '1990_male', type: 'numeric' }, - { name: '2000_total', type: 'numeric' }, - { name: '2000_female', type: 'numeric' }, - { name: '2000_male', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/graduationOfStudentsPrint2.ts b/tools/dataMigration/dataTable/mappings/fra/graduationOfStudentsPrint2.ts deleted file mode 100644 index efc9a65d4c..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/graduationOfStudentsPrint2.ts +++ /dev/null @@ -1,14 +0,0 @@ -export default { - tableName: 'graduation_of_students', - rows: { - names: ['doctoral_degree', 'masters_degree', 'bachelors_degree', 'technician_certificate', 'total'], - }, - columns: [ - { name: '2010_total', type: 'numeric' }, - { name: '2010_female', type: 'numeric' }, - { name: '2010_male', type: 'numeric' }, - { name: '2015_total', type: 'numeric' }, - { name: '2015_female', type: 'numeric' }, - { name: '2015_male', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/growingStockComposition.ts b/tools/dataMigration/dataTable/mappings/fra/growingStockComposition.ts deleted file mode 100644 index ba55fa2dde..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/growingStockComposition.ts +++ /dev/null @@ -1,35 +0,0 @@ -export default { - tableName: 'growing_stock_composition', - rows: { - names: [ - 'native_rank1', - 'native_rank2', - 'native_rank3', - 'native_rank4', - 'native_rank5', - 'native_rank6', - 'native_rank7', - 'native_rank8', - 'native_rank9', - 'native_rank10', - 'remaining_native', - 'total_native_placeholder', // Will contain no data in DB - 'introduced_tree_species_heading_placeholder', // Will contain no data in DB - 'introduced_rank1', - 'introduced_rank2', - 'introduced_rank3', - 'introduced_rank4', - 'introduced_rank5', - 'remaining_introduced_placeholder', // Will contain no data in DB - ], - }, - columns: [ - { name: 'scientific_name', type: 'text' }, - { name: 'common_name', type: 'text' }, - { name: '1990', type: 'numeric' }, - { name: '2000', type: 'numeric' }, - { name: '2010', type: 'numeric' }, - { name: '2015', type: 'numeric' }, - { name: '2020', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/holderOfManagementRights.ts b/tools/dataMigration/dataTable/mappings/fra/holderOfManagementRights.ts deleted file mode 100644 index 58ad67e382..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/holderOfManagementRights.ts +++ /dev/null @@ -1,12 +0,0 @@ -export default { - tableName: 'holder_of_management_rights', - rows: { - names: ['public_administration', 'individuals', 'private_businesses', 'communities', 'other'], - }, - columns: [ - { name: '1990', type: 'numeric' }, - { name: '2000', type: 'numeric' }, - { name: '2010', type: 'numeric' }, - { name: '2015', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/index.ts b/tools/dataMigration/dataTable/mappings/fra/index.ts deleted file mode 100644 index c35b86056f..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/index.ts +++ /dev/null @@ -1,83 +0,0 @@ -import extent from '../../../../../.src.legacy/common/model/dataTable/contentCheck/extent' -import forestGrowingStockBiomassCarbon from '../../../../../.src.legacy/common/model/dataTable/contentCheck/forestGrowingStockBiomassCarbon' -import periodicChangeRate from '../../../../../.src.legacy/common/model/dataTable/contentCheck/periodicChangeRate' -import annualReforestation from './annualReforestation' -import areaAffectedByFire from './areaAffectedByFire' -import areaAffectedByFirePrint1 from './areaAffectedByFirePrint1' -import areaAffectedByFirePrint2 from './areaAffectedByFirePrint2' -import areaOfPermanentForestEstate from './areaOfPermanentForestEstate' -import biomassStock from './biomassStock' -import carbonStock from './carbonStock' -import carbonStockSoilDepth from './carbonStockSoilDepth' -import climaticDomain from './climaticDomain' -import degradedForest from './degradedForest' -import disturbances from './disturbances' -import disturbancesPrint1 from './disturbancesPrint1' -import disturbancesPrint2 from './disturbancesPrint2' -import employment from './employment' -import employmentPrint1 from './employmentPrint1' -import employmentPrint2 from './employmentPrint2' -import forestAreaChange from './forestAreaChange' -import forestAreaWithinProtectedAreas from './forestAreaWithinProtectedAreas' -import forestOwnership from './forestOwnership' -import forestPolicy from './forestPolicy' -import graduationOfStudents from './graduationOfStudents' -import graduationOfStudentsPrint1 from './graduationOfStudentsPrint1' -import graduationOfStudentsPrint2 from './graduationOfStudentsPrint2' -import growingStockComposition from './growingStockComposition' -import holderOfManagementRights from './holderOfManagementRights' -import nonWoodForestProductsRemovals from './nonWoodForestProductsRemovals' -import nonWoodForestProductsRemovalsCurrency from './nonWoodForestProductsRemovalsCurrency' -import otherLandWithTreeCover from './otherLandWithTreeCover' -import primaryDesignatedManagementObjective from './primaryDesignatedManagementObjective' -import specificForestCategories from './specificForestCategories' -import sustainableDevelopmentAgencyIndicator from './sustainableDevelopmentAgencyIndicator' -import sustainableDevelopmentAgencySubIndicator1 from './sustainableDevelopmentAgencySubIndicator1' -import sustainableDevelopmentAgencySubIndicator2 from './sustainableDevelopmentAgencySubIndicator2' -import sustainableDevelopmentAgencySubIndicator3 from './sustainableDevelopmentAgencySubIndicator3' -import sustainableDevelopmentAgencySubIndicator4 from './sustainableDevelopmentAgencySubIndicator4' -import totalAreaWithDesignatedManagementObjective from './totalAreaWithDesignatedManagementObjective' - -export default { - specificForestCategories, - forestAreaChange, - primaryDesignatedManagementObjective, - areaAffectedByFire, - areaAffectedByFirePrint1, - areaAffectedByFirePrint2, - growingStockComposition, - holderOfManagementRights, - nonWoodForestProductsRemovals, - nonWoodForestProductsRemovalsCurrency, - degradedForest, - employment, - employmentPrint1, - employmentPrint2, - graduationOfStudents, - graduationOfStudentsPrint1, - graduationOfStudentsPrint2, - forestOwnership, - forestAreaWithinProtectedAreas, - totalAreaWithDesignatedManagementObjective, - annualReforestation, - disturbances, - disturbancesPrint1, - disturbancesPrint2, - biomassStock, - carbonStock, - carbonStockSoilDepth, - areaOfPermanentForestEstate, - forestPolicy, - otherLandWithTreeCover, - climaticDomain, - sustainableDevelopmentAgencyIndicator, - sustainableDevelopmentAgencySubIndicator1, - sustainableDevelopmentAgencySubIndicator2, - sustainableDevelopmentAgencySubIndicator3, - sustainableDevelopmentAgencySubIndicator4, - - // contentCheck - extent, - periodicChangeRate, - forestGrowingStockBiomassCarbon, -} diff --git a/tools/dataMigration/dataTable/mappings/fra/nonWoodForestProductsRemovals.ts b/tools/dataMigration/dataTable/mappings/fra/nonWoodForestProductsRemovals.ts deleted file mode 100644 index e26ea02ffe..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/nonWoodForestProductsRemovals.ts +++ /dev/null @@ -1,14 +0,0 @@ -export default { - tableName: 'non_wood_forest_products_removals', - rows: { - names: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'all_other_plant_products', 'all_other_animal_products'], - }, - columns: [ - { name: 'product_name', type: 'text' }, - { name: 'key_species', type: 'text' }, - { name: 'quantity', type: 'numeric' }, - { name: 'unit', type: 'text' }, - { name: 'value', type: 'numeric' }, - { name: 'category', type: 'text' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/nonWoodForestProductsRemovalsCurrency.ts b/tools/dataMigration/dataTable/mappings/fra/nonWoodForestProductsRemovalsCurrency.ts deleted file mode 100644 index 67c0c5b284..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/nonWoodForestProductsRemovalsCurrency.ts +++ /dev/null @@ -1,6 +0,0 @@ -export default { - tableName: 'non_wood_forest_products_removals_currency', - section: 'nonWoodForestProductsRemovals', - rows: { names: ['currency'] }, - columns: [{ name: 'currency', type: 'text' }], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/otherLandWithTreeCover.ts b/tools/dataMigration/dataTable/mappings/fra/otherLandWithTreeCover.ts deleted file mode 100644 index 01b281ed17..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/otherLandWithTreeCover.ts +++ /dev/null @@ -1,13 +0,0 @@ -export default { - tableName: 'other_land_with_tree_cover', - rows: { - names: ['palms', 'tree_orchards', 'agroforestry', 'trees_in_urban_settings', 'other'], - }, - columns: [ - { name: '1990', type: 'numeric' }, - { name: '2000', type: 'numeric' }, - { name: '2010', type: 'numeric' }, - { name: '2015', type: 'numeric' }, - { name: '2020', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/primaryDesignatedManagementObjective.ts b/tools/dataMigration/dataTable/mappings/fra/primaryDesignatedManagementObjective.ts deleted file mode 100644 index 4c1856a921..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/primaryDesignatedManagementObjective.ts +++ /dev/null @@ -1,22 +0,0 @@ -export default { - tableName: 'primary_designated_management_objective', - section: 'designatedManagementObjective', - rows: { - names: [ - 'production', - 'protection_of_soil_and_water', - 'conservation_of_biodiversity', - 'social_services', - 'multiple_use', - 'other', - 'no_unknown', - ], - }, - columns: [ - { name: '1990', type: 'numeric' }, - { name: '2000', type: 'numeric' }, - { name: '2010', type: 'numeric' }, - { name: '2015', type: 'numeric' }, - { name: '2020', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/specificForestCategories.ts b/tools/dataMigration/dataTable/mappings/fra/specificForestCategories.ts deleted file mode 100644 index 58e1c189a7..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/specificForestCategories.ts +++ /dev/null @@ -1,13 +0,0 @@ -export default { - tableName: 'specific_forest_categories', - rows: { - names: ['primary_forest', 'temporarily_unstocked', 'bamboo', 'mangroves', 'rubber_wood'], - }, - columns: [ - { name: '1990', type: 'numeric' }, - { name: '2000', type: 'numeric' }, - { name: '2010', type: 'numeric' }, - { name: '2015', type: 'numeric' }, - { name: '2020', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/sustainableDevelopmentAgencyIndicator.ts b/tools/dataMigration/dataTable/mappings/fra/sustainableDevelopmentAgencyIndicator.ts deleted file mode 100644 index 716b4885a5..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/sustainableDevelopmentAgencyIndicator.ts +++ /dev/null @@ -1,8 +0,0 @@ -export default { - tableName: 'sustainable_development_indicator', - section: 'sustainableDevelopment', - rows: { - names: ['agency_name'], - }, - columns: [{ name: 'agency_name', type: 'text' }], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/sustainableDevelopmentAgencySubIndicator1.ts b/tools/dataMigration/dataTable/mappings/fra/sustainableDevelopmentAgencySubIndicator1.ts deleted file mode 100644 index 08837c4606..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/sustainableDevelopmentAgencySubIndicator1.ts +++ /dev/null @@ -1,8 +0,0 @@ -export default { - tableName: 'sustainable_development_sub_indicator1', - section: 'sustainableDevelopment', - rows: { - names: ['agency_name'], - }, - columns: [{ name: 'agency_name', type: 'text' }], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/sustainableDevelopmentAgencySubIndicator2.ts b/tools/dataMigration/dataTable/mappings/fra/sustainableDevelopmentAgencySubIndicator2.ts deleted file mode 100644 index 12636a0e54..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/sustainableDevelopmentAgencySubIndicator2.ts +++ /dev/null @@ -1,8 +0,0 @@ -export default { - tableName: 'sustainable_development_sub_indicator2', - section: 'sustainableDevelopment', - rows: { - names: ['agency_name'], - }, - columns: [{ name: 'agency_name', type: 'text' }], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/sustainableDevelopmentAgencySubIndicator3.ts b/tools/dataMigration/dataTable/mappings/fra/sustainableDevelopmentAgencySubIndicator3.ts deleted file mode 100644 index 4be02df973..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/sustainableDevelopmentAgencySubIndicator3.ts +++ /dev/null @@ -1,8 +0,0 @@ -export default { - tableName: 'sustainable_development_sub_indicator3', - section: 'sustainableDevelopment', - rows: { - names: ['agency_name'], - }, - columns: [{ name: 'agency_name', type: 'text' }], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/sustainableDevelopmentAgencySubIndicator4.ts b/tools/dataMigration/dataTable/mappings/fra/sustainableDevelopmentAgencySubIndicator4.ts deleted file mode 100644 index 009ea7a173..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/sustainableDevelopmentAgencySubIndicator4.ts +++ /dev/null @@ -1,8 +0,0 @@ -export default { - tableName: 'sustainable_development_sub_indicator4', - section: 'sustainableDevelopment', - rows: { - names: ['agency_name'], - }, - columns: [{ name: 'agency_name', type: 'text' }], -} diff --git a/tools/dataMigration/dataTable/mappings/fra/totalAreaWithDesignatedManagementObjective.ts b/tools/dataMigration/dataTable/mappings/fra/totalAreaWithDesignatedManagementObjective.ts deleted file mode 100644 index cdafd81bd3..0000000000 --- a/tools/dataMigration/dataTable/mappings/fra/totalAreaWithDesignatedManagementObjective.ts +++ /dev/null @@ -1,14 +0,0 @@ -export default { - tableName: 'total_area_with_designated_management_objective', - section: 'designatedManagementObjective', - rows: { - names: ['production', 'protection_of_soil_and_water', 'conservation_of_biodiversity', 'social_services', 'other'], - }, - columns: [ - { name: '1990', type: 'numeric' }, - { name: '2000', type: 'numeric' }, - { name: '2010', type: 'numeric' }, - { name: '2015', type: 'numeric' }, - { name: '2020', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/index.ts b/tools/dataMigration/dataTable/mappings/panEuropean/index.ts deleted file mode 100644 index 986a00f1b9..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/index.ts +++ /dev/null @@ -1,93 +0,0 @@ -import table11a from './table1_1a' -import table11b from './table1_1b' -import table12a from './table1_2a' -import table12b from './table1_2b' -import table12c from './table1_2c' -import table13a1 from './table1_3a1' -import table13a2 from './table1_3a2' -import table13b from './table1_3b' -import table14a from './table1_4a' -import table14b from './table1_4b' -import table24 from './table2_4' -import table25 from './table2_5' -import table25oth from './table2_5oth' -import table31 from './table3_1' -import table32 from './table3_2' -import table33 from './table3_3' -import table34 from './table3_4' -import table41 from './table4_1' -import table42a from './table4_2a' -import table42b from './table4_2b' -import table43a from './table4_3a' -import table43b from './table4_3b' -import table44a from './table4_4a' -import table44b from './table4_4b' -import table44c from './table4_4c' -import table45 from './table4_5' -import table48 from './table4_8' -import table49 from './table4_9' -import table51 from './table5_1' -import table61 from './table6_1' -import table62 from './table6_2' -import table63 from './table6_3' -import table64a from './table6_4a' -import table64b from './table6_4b' -import table64c from './table6_4c' -import table65a from './table6_5a' -import table65b from './table6_5b' -import table66 from './table6_6' -import table67 from './table6_7' -import table68 from './table6_8' -import table69 from './table6_9' -import table610a from './table6_10a' -import table610b from './table6_10b' -import table610c from './table6_10c' -import table610d from './table6_10d' - -export default { - table_1_1a: table11a, - table_1_1b: table11b, - table_1_2a: table12a, - table_1_2b: table12b, - table_1_2c: table12c, - table_1_3a1: table13a1, - table_1_3a2: table13a2, - table_1_3b: table13b, - table_1_4a: table14a, - table_1_4b: table14b, - table_2_4: table24, - table_2_5: table25, - table_2_5oth: table25oth, - table_3_1: table31, - table_3_2: table32, - table_3_3: table33, - table_3_4: table34, - table_4_1: table41, - table_4_2a: table42a, - table_4_2b: table42b, - table_4_3a: table43a, - table_4_3b: table43b, - table_4_4a: table44a, - table_4_4b: table44b, - table_4_4c: table44c, - table_4_5: table45, - table_4_8: table48, - table_4_9: table49, - table_5_1: table51, - table_6_1: table61, - table_6_2: table62, - table_6_3: table63, - table_6_4a: table64a, - table_6_4b: table64b, - table_6_4c: table64c, - table_6_5a: table65a, - table_6_5b: table65b, - table_6_6: table66, - table_6_7: table67, - table_6_8: table68, - table_6_9: table69, - table_6_10a: table610a, - table_6_10b: table610b, - table_6_10c: table610c, - table_6_10d: table610d, -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table1_1a.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table1_1a.ts deleted file mode 100644 index 1c8e2bc1fc..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table1_1a.ts +++ /dev/null @@ -1,57 +0,0 @@ -export default { - tableName: 'table_1_1a', - schemaName: 'pan_european', - section: 'panEuropean_1_1_a', - rows: { - names: [ - 'forest_2025', - 'forest_2020', - 'forest_2015', - 'forest_2010', - 'forest_2005', - 'forest_2000', - 'forest_1990', - - '_of_which_available_for_wood_supply_2025', - '_of_which_available_for_wood_supply_2020', - '_of_which_available_for_wood_supply_2015', - '_of_which_available_for_wood_supply_2010', - '_of_which_available_for_wood_supply_2005', - '_of_which_available_for_wood_supply_2000', - '_of_which_available_for_wood_supply_1990', - - 'other_wooded_land_2025', - 'other_wooded_land_2020', - 'other_wooded_land_2015', - 'other_wooded_land_2010', - 'other_wooded_land_2005', - 'other_wooded_land_2000', - 'other_wooded_land_1990', - - 'total_forest_and_other_wooded_land_2025', - 'total_forest_and_other_wooded_land_2020', - 'total_forest_and_other_wooded_land_2015', - 'total_forest_and_other_wooded_land_2010', - 'total_forest_and_other_wooded_land_2005', - 'total_forest_and_other_wooded_land_2000', - 'total_forest_and_other_wooded_land_1990', - - 'other_land_2025', - 'other_land_2020', - 'other_land_2015', - 'other_land_2010', - 'other_land_2005', - 'other_land_2000', - 'other_land_1990', - - '_of_which_with_tree_cover_2025', - '_of_which_with_tree_cover_2020', - '_of_which_with_tree_cover_2015', - '_of_which_with_tree_cover_2010', - '_of_which_with_tree_cover_2005', - '_of_which_with_tree_cover_2000', - '_of_which_with_tree_cover_1990', - ], - }, - columns: [{ name: 'area', type: 'numeric' }], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table1_1b.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table1_1b.ts deleted file mode 100644 index d67b7f01c6..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table1_1b.ts +++ /dev/null @@ -1,16 +0,0 @@ -export default { - tableName: 'table_1_1b', - schemaName: 'pan_european', - section: 'panEuropean_1_1_b', - rows: { - names: ['predominantly_coniferous_forest', 'predominantly_broadleaved_forest', 'mixed_forest'], - }, - columns: [ - { name: 'forest_area_1990', type: 'numeric' }, - { name: 'forest_area_2000', type: 'numeric' }, - { name: 'forest_area_2005', type: 'numeric' }, - { name: 'forest_area_2010', type: 'numeric' }, - { name: 'forest_area_2015', type: 'numeric' }, - { name: 'forest_area_2020', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table1_2a.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table1_2a.ts deleted file mode 100644 index 604997bd81..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table1_2a.ts +++ /dev/null @@ -1,45 +0,0 @@ -export default { - tableName: 'table_1_2a', - schemaName: 'pan_european', - section: 'panEuropean_1_2_a', - rows: { - names: [ - 'forest_2025', - 'forest_2020', - 'forest_2015', - 'forest_2010', - 'forest_2005', - 'forest_2000', - 'forest_1990', - - '_of_which_available_for_wood_supply_2025', - '_of_which_available_for_wood_supply_2020', - '_of_which_available_for_wood_supply_2015', - '_of_which_available_for_wood_supply_2010', - '_of_which_available_for_wood_supply_2005', - '_of_which_available_for_wood_supply_2000', - '_of_which_available_for_wood_supply_1990', - - 'other_wooded_land_2025', - 'other_wooded_land_2020', - 'other_wooded_land_2015', - 'other_wooded_land_2010', - 'other_wooded_land_2005', - 'other_wooded_land_2000', - 'other_wooded_land_1990', - - 'total_forest_and_other_wooded_land_2025', - 'total_forest_and_other_wooded_land_2020', - 'total_forest_and_other_wooded_land_2015', - 'total_forest_and_other_wooded_land_2010', - 'total_forest_and_other_wooded_land_2005', - 'total_forest_and_other_wooded_land_2000', - 'total_forest_and_other_wooded_land_1990', - ], - }, - columns: [ - { name: 'total', type: 'numeric' }, - { name: 'coniferous', type: 'numeric' }, - { name: 'broadleaved', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table1_2b.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table1_2b.ts deleted file mode 100644 index 3eed4edca2..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table1_2b.ts +++ /dev/null @@ -1,16 +0,0 @@ -export default { - tableName: 'table_1_2b', - schemaName: 'pan_european', - section: 'panEuropean_1_2_b', - rows: { - names: ['predominantly_coniferous_forest', 'predominantly_broadleaved_forest', 'mixed_forest'], - }, - columns: [ - { name: 'growing_stock_1990', type: 'numeric' }, - { name: 'growing_stock_2000', type: 'numeric' }, - { name: 'growing_stock_2005', type: 'numeric' }, - { name: 'growing_stock_2010', type: 'numeric' }, - { name: 'growing_stock_2015', type: 'numeric' }, - { name: 'growing_stock_2020', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table1_2c.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table1_2c.ts deleted file mode 100644 index 0a91a66a9a..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table1_2c.ts +++ /dev/null @@ -1,31 +0,0 @@ -export default { - tableName: 'table_1_2c', - schemaName: 'pan_european', - section: 'panEuropean_1_2_c', - rows: { - names: [ - 'no1_ranked_in_terms_of_volume', - 'no2_ranked_in_terms_of_volume', - 'no3_ranked_in_terms_of_volume', - 'no4_ranked_in_terms_of_volume', - 'no5_ranked_in_terms_of_volume', - 'no6_ranked_in_terms_of_volume', - 'no7_ranked_in_terms_of_volume', - 'no8_ranked_in_terms_of_volume', - 'no9_ranked_in_terms_of_volume', - 'no10_ranked_in_terms_of_volume', - 'remaining', - 'total', - ], - }, - columns: [ - { name: 'scientific_name', type: 'text' }, - { name: 'common_name', type: 'text' }, - { name: 'growing_stock_in_forest_1990', type: 'numeric' }, - { name: 'growing_stock_in_forest_2000', type: 'numeric' }, - { name: 'growing_stock_in_forest_2005', type: 'numeric' }, - { name: 'growing_stock_in_forest_2010', type: 'numeric' }, - { name: 'growing_stock_in_forest_2015', type: 'numeric' }, - { name: 'growing_stock_in_forest_2020', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table1_3a1.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table1_3a1.ts deleted file mode 100644 index bc24196359..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table1_3a1.ts +++ /dev/null @@ -1,50 +0,0 @@ -export default { - tableName: 'table_1_3a1', - schemaName: 'pan_european', - section: 'panEuropean_1_3_a1', - rows: { - names: [ - 'forest_even_aged_stands_of_which_2020', - 'forest_even_aged_stands_of_which_2015', - 'forest_even_aged_stands_of_which_2010', - 'forest_even_aged_stands_of_which_2005', - 'forest_even_aged_stands_of_which_2000', - 'forest_even_aged_stands_of_which_1990', - - 'available_for_wood_supply_of_which_2020', - 'available_for_wood_supply_of_which_2015', - 'available_for_wood_supply_of_which_2010', - 'available_for_wood_supply_of_which_2005', - 'available_for_wood_supply_of_which_2000', - 'available_for_wood_supply_of_which_1990', - - 'predominantly_coniferous_forest_2020', - 'predominantly_coniferous_forest_2015', - 'predominantly_coniferous_forest_2010', - 'predominantly_coniferous_forest_2005', - 'predominantly_coniferous_forest_2000', - 'predominantly_coniferous_forest_1990', - - 'predominantly_broadleaved_forest_2020', - 'predominantly_broadleaved_forest_2015', - 'predominantly_broadleaved_forest_2010', - 'predominantly_broadleaved_forest_2005', - 'predominantly_broadleaved_forest_2000', - 'predominantly_broadleaved_forest_1990', - - 'mixed_forest_2020', - 'mixed_forest_2015', - 'mixed_forest_2010', - 'mixed_forest_2005', - 'mixed_forest_2000', - 'mixed_forest_1990', - ], - }, - columns: [ - { name: 'total_area', type: 'numeric' }, - { name: 'regeneration_phase', type: 'numeric' }, - { name: 'intermediate_phase', type: 'numeric' }, - { name: 'mature_phase', type: 'numeric' }, - { name: 'unspecified', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table1_3a2.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table1_3a2.ts deleted file mode 100644 index 3b9f45b712..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table1_3a2.ts +++ /dev/null @@ -1,43 +0,0 @@ -export default { - tableName: 'table_1_3a2', - schemaName: 'pan_european', - section: 'panEuropean_1_3_a2', - rows: { - names: [ - 'forest_available_for_wood_supply_even_aged_stands_of_which_2020', - 'forest_available_for_wood_supply_even_aged_stands_of_which_2015', - 'forest_available_for_wood_supply_even_aged_stands_of_which_2010', - 'forest_available_for_wood_supply_even_aged_stands_of_which_2005', - 'forest_available_for_wood_supply_even_aged_stands_of_which_2000', - 'forest_available_for_wood_supply_even_aged_stands_of_which_1990', - - 'predominantly_coniferous_forest_2020', - 'predominantly_coniferous_forest_2015', - 'predominantly_coniferous_forest_2010', - 'predominantly_coniferous_forest_2005', - 'predominantly_coniferous_forest_2000', - 'predominantly_coniferous_forest_1990', - - 'predominantly_broadleaved_forest_2020', - 'predominantly_broadleaved_forest_2015', - 'predominantly_broadleaved_forest_2010', - 'predominantly_broadleaved_forest_2005', - 'predominantly_broadleaved_forest_2000', - 'predominantly_broadleaved_forest_1990', - - 'mixed_forest_2020', - 'mixed_forest_2015', - 'mixed_forest_2010', - 'mixed_forest_2005', - 'mixed_forest_2000', - 'mixed_forest_1990', - ], - }, - columns: [ - { name: 'total_volume', type: 'numeric' }, - { name: 'regeneration_phase', type: 'numeric' }, - { name: 'intermediate_phase', type: 'numeric' }, - { name: 'mature_phase', type: 'numeric' }, - { name: 'unspecified', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table1_3b.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table1_3b.ts deleted file mode 100644 index fdbc6bdf43..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table1_3b.ts +++ /dev/null @@ -1,31 +0,0 @@ -export default { - tableName: 'table_1_3b', - schemaName: 'pan_european', - section: 'panEuropean_1_3_b', - rows: { - names: [ - 'forest_uneven_aged_stands_2020', - 'forest_uneven_aged_stands_2015', - 'forest_uneven_aged_stands_2010', - 'forest_uneven_aged_stands_2005', - 'forest_uneven_aged_stands_2000', - 'forest_uneven_aged_stands_1990', - - '_of_which_forest_available_for_wood_supply_2020', - '_of_which_forest_available_for_wood_supply_2015', - '_of_which_forest_available_for_wood_supply_2010', - '_of_which_forest_available_for_wood_supply_2005', - '_of_which_forest_available_for_wood_supply_2000', - '_of_which_forest_available_for_wood_supply_1990', - ], - }, - columns: [ - { name: 'area', type: 'numeric' }, - { name: 'total_volume', type: 'numeric' }, - { name: 'less_or_equal_20_cm', type: 'numeric' }, - { name: '_21_40_cm', type: 'numeric' }, - { name: '_41_60_cm', type: 'numeric' }, - { name: 'greater_60_cm', type: 'numeric' }, - { name: 'unspecified', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table1_4a.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table1_4a.ts deleted file mode 100644 index cd8ede6d23..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table1_4a.ts +++ /dev/null @@ -1,39 +0,0 @@ -export default { - tableName: 'table_1_4a', - schemaName: 'pan_european', - section: 'panEuropean_1_4_a', - rows: { - names: [ - 'forest_2025', - 'forest_2020', - 'forest_2015', - 'forest_2010', - 'forest_2005', - 'forest_2000', - 'forest_1990', - - 'other_wooded_land_2025', - 'other_wooded_land_2020', - 'other_wooded_land_2015', - 'other_wooded_land_2010', - 'other_wooded_land_2005', - 'other_wooded_land_2000', - 'other_wooded_land_1990', - - 'total_forest_and_other_wooded_land_2025', - 'total_forest_and_other_wooded_land_2020', - 'total_forest_and_other_wooded_land_2015', - 'total_forest_and_other_wooded_land_2010', - 'total_forest_and_other_wooded_land_2005', - 'total_forest_and_other_wooded_land_2000', - 'total_forest_and_other_wooded_land_1990', - ], - }, - columns: [ - { name: 'above_ground', type: 'numeric' }, - { name: 'below_ground', type: 'numeric' }, - { name: 'deadwood', type: 'numeric' }, - { name: 'litter', type: 'numeric' }, - { name: 'soil_carbon', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table1_4b.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table1_4b.ts deleted file mode 100644 index 6499fc3fba..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table1_4b.ts +++ /dev/null @@ -1,17 +0,0 @@ -export default { - tableName: 'table_1_4b', - schemaName: 'pan_european', - section: 'panEuropean_1_4_b', - rows: { - names: [ - 'harvested_wood_products_2025', - 'harvested_wood_products_2020', - 'harvested_wood_products_2015', - 'harvested_wood_products_2010', - 'harvested_wood_products_2005', - 'harvested_wood_products_2000', - 'harvested_wood_products_1990', - ], - }, - columns: [{ name: 'total_carbon_stock_in_hwp', type: 'numeric' }], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table2_4.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table2_4.ts deleted file mode 100644 index 0400f7e7af..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table2_4.ts +++ /dev/null @@ -1,58 +0,0 @@ -export default { - tableName: 'table_2_4', - schemaName: 'pan_european', - section: 'panEuropean_2_4', - rows: { - names: [ - 'forest_2022', - 'forest_2021', - 'forest_2020', - 'forest_2019', - 'forest_2018', - 'forest_2017', - 'forest_2016', - 'forest_2015', - 'forest_2014', - 'forest_2013', - 'forest_2012', - 'forest_2011', - 'forest_2010', - 'forest_2009', - 'forest_2008', - 'forest_2007', - 'forest_2006', - 'forest_2005', - 'forest_2004', - 'forest_2003', - 'forest_2002', - 'forest_2001', - 'forest_2000', - 'forest_1990', - - 'other_wooded_land_2020', - 'other_wooded_land_2015', - 'other_wooded_land_2010', - 'other_wooded_land_2005', - 'other_wooded_land_2000', - 'other_wooded_land_1990', - - 'total_forest_and_other_wooded_land_2020', - 'total_forest_and_other_wooded_land_2015', - 'total_forest_and_other_wooded_land_2010', - 'total_forest_and_other_wooded_land_2005', - 'total_forest_and_other_wooded_land_2000', - 'total_forest_and_other_wooded_land_1990', - ], - }, - columns: [ - { name: 'total_area_with_damage', type: 'numeric' }, - { name: 'insects_and_disease', type: 'numeric' }, - { name: 'wildlife_and_grazing', type: 'numeric' }, - { name: 'forest_operations', type: 'numeric' }, - { name: 'other', type: 'numeric' }, - { name: 'primarily_damaged_by_abiotic_agents', type: 'numeric' }, - { name: 'primarily_damaged_by_fire_total', type: 'numeric' }, - { name: 'of_which_human_induced', type: 'numeric' }, - { name: 'unspecified_mixed_damage', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table2_5.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table2_5.ts deleted file mode 100644 index 8e15ed4a3e..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table2_5.ts +++ /dev/null @@ -1,44 +0,0 @@ -export default { - tableName: 'table_2_5', - schemaName: 'pan_european', - section: 'panEuropean_2_5', - rows: { - names: [ - 'header_2025', - 'agentName', - - 'forest_2020', - 'forest_2015', - 'forest_2010', - 'forest_2005', - 'forest_2000', - 'forest_1990', - - 'other_wooded_land_2020', - 'other_wooded_land_2015', - 'other_wooded_land_2010', - 'other_wooded_land_2005', - 'other_wooded_land_2000', - 'other_wooded_land_1990', - - 'total_forest_and_other_wooded_land_2020', - 'total_forest_and_other_wooded_land_2015', - 'total_forest_and_other_wooded_land_2010', - 'total_forest_and_other_wooded_land_2005', - 'total_forest_and_other_wooded_land_2000', - 'total_forest_and_other_wooded_land_1990', - ], - }, - columns: [ - { name: 'total_area_of_degraded_land', type: 'numeric' }, - { name: 'grazing', type: 'numeric' }, - { name: 'repeated_fires', type: 'numeric' }, - { name: 'air_pollution', type: 'numeric' }, - { name: 'desertification', type: 'numeric' }, - { name: 'other_1', type: 'numeric' }, - { name: 'other_2', type: 'numeric' }, - { name: 'other_3', type: 'numeric' }, - { name: 'unknown', type: 'numeric' }, - { name: 'former_degraded_land_restored', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table2_5oth.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table2_5oth.ts deleted file mode 100644 index c625acbcf5..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table2_5oth.ts +++ /dev/null @@ -1,13 +0,0 @@ -export default { - tableName: 'table_2_5oth', - schemaName: 'pan_european', - section: 'panEuropean_2_5_oth', - rows: { - names: ['area_primarily_degraded_by'], - }, - columns: [ - { name: 'other_1', type: 'text' }, - { name: 'other_2', type: 'text' }, - { name: 'other_3', type: 'text' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table3_1.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table3_1.ts deleted file mode 100644 index 592324221e..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table3_1.ts +++ /dev/null @@ -1,29 +0,0 @@ -export default { - tableName: 'table_3_1', - schemaName: 'pan_european', - section: 'panEuropean_3_1', - rows: { - names: [ - 'forest_2020', - 'forest_2015', - 'forest_2010', - 'forest_2005', - 'forest_2000', - 'forest_1990', - - '_of_which_forest_available_for_wood_supply_2020', - '_of_which_forest_available_for_wood_supply_2015', - '_of_which_forest_available_for_wood_supply_2010', - '_of_which_forest_available_for_wood_supply_2005', - '_of_which_forest_available_for_wood_supply_2000', - '_of_which_forest_available_for_wood_supply_1990', - ], - }, - columns: [ - { name: 'gross_annual_increment', type: 'numeric' }, - { name: 'natural_losses', type: 'numeric' }, - { name: 'net_annual_increment', type: 'numeric' }, - { name: 'fellings_total', type: 'numeric' }, - { name: '_of_which_of_natural_losses', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table3_2.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table3_2.ts deleted file mode 100644 index 366e0042e5..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table3_2.ts +++ /dev/null @@ -1,51 +0,0 @@ -export default { - tableName: 'table_3_2', - schemaName: 'pan_european', - section: 'panEuropean_3_2', - rows: { - names: [ - 'roundwood_2022', - 'roundwood_2021', - 'roundwood_2020', - 'roundwood_2019', - 'roundwood_2018', - 'roundwood_2017', - 'roundwood_2016', - 'roundwood_2015', - 'roundwood_2014', - 'roundwood_2013', - 'roundwood_2012', - 'roundwood_2011', - 'roundwood_2010', - 'roundwood_2009', - 'roundwood_2008', - 'roundwood_2007', - 'roundwood_2006', - 'roundwood_2005', - 'roundwood_2004', - 'roundwood_2003', - 'roundwood_2002', - 'roundwood_2001', - 'roundwood_2000', - 'roundwood_1999', - 'roundwood_1998', - 'roundwood_1997', - 'roundwood_1996', - 'roundwood_1995', - 'roundwood_1994', - 'roundwood_1993', - 'roundwood_1992', - 'roundwood_1991', - 'roundwood_1990', - 'roundwood_1989', - 'roundwood_1988', - ], - }, - columns: [ - { name: 'total_volume', type: 'numeric' }, - { name: 'industrial_roundwood_volume', type: 'numeric' }, - { name: 'industrial_roundwood_market_value', type: 'numeric' }, - { name: 'woodfuel_volume', type: 'numeric' }, - { name: 'woodfuel_market_value', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table3_3.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table3_3.ts deleted file mode 100644 index 3851df694a..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table3_3.ts +++ /dev/null @@ -1,30 +0,0 @@ -export default { - tableName: 'table_3_3', - schemaName: 'pan_european', - section: 'panEuropean_3_3', - rows: { - names: [ - '_01st', - '_02nd', - '_03rd', - '_04th', - '_05th', - '_06th', - '_07th', - '_08th', - '_09th', - '_10th', - 'all_other_plant_products', - 'all_other_animal_products', - 'total', - ], - }, - columns: [ - { name: 'name_of_groups_of_product', type: 'text' }, - { name: 'key_species', type: 'text' }, - { name: 'total_harvested_non_wood_goods_unit', type: 'text' }, - { name: 'total_harvested_non_wood_goods_quantity', type: 'numeric' }, - { name: 'market_value_1000_national_currency', type: 'numeric' }, - { name: 'nwfp_category', type: 'text' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table3_4.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table3_4.ts deleted file mode 100644 index 1824bb950d..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table3_4.ts +++ /dev/null @@ -1,28 +0,0 @@ -export default { - tableName: 'table_3_4', - schemaName: 'pan_european', - section: 'panEuropean_3_4', - rows: { - names: [ - '_01st', - '_02nd', - '_03rd', - '_04th', - '_05th', - '_06th', - '_07th', - '_08th', - '_09th', - '_10th', - 'remaining_total', - 'total', - ], - }, - columns: [ - { name: 'name_of_service_product', type: 'text' }, - { name: 'unit', type: 'text' }, - { name: 'service_provision_amount_of_service_product', type: 'numeric' }, - { name: 'service_provision_value_1000_national_currency', type: 'numeric' }, - { name: 'forest_service_category', type: 'text' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table4_1.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table4_1.ts deleted file mode 100644 index 28baf0bf61..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table4_1.ts +++ /dev/null @@ -1,35 +0,0 @@ -export default { - tableName: 'table_4_1', - schemaName: 'pan_european', - section: 'panEuropean_4_1', - rows: { - names: [ - 'forest_2020', - 'forest_2015', - 'forest_2010', - 'forest_2005', - 'forest_2000', - 'forest_1990', - - 'other_wooded_land_2020', - 'other_wooded_land_2015', - 'other_wooded_land_2010', - 'other_wooded_land_2005', - 'other_wooded_land_2000', - 'other_wooded_land_1990', - - 'total_forest_and_other_wooded_land_2020', - 'total_forest_and_other_wooded_land_2015', - 'total_forest_and_other_wooded_land_2010', - 'total_forest_and_other_wooded_land_2005', - 'total_forest_and_other_wooded_land_2000', - 'total_forest_and_other_wooded_land_1990', - ], - }, - columns: [ - { name: 'area_with_number_of_tree_species_occurring_1', type: 'numeric' }, - { name: 'area_with_number_of_tree_species_occurring_2_3', type: 'numeric' }, - { name: 'area_with_number_of_tree_species_occurring_4_5', type: 'numeric' }, - { name: 'area_with_number_of_tree_species_occurring_6_pl', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table4_2a.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table4_2a.ts deleted file mode 100644 index 2e2b7f91bc..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table4_2a.ts +++ /dev/null @@ -1,13 +0,0 @@ -export default { - tableName: 'table_4_2a', - schemaName: 'pan_european', - section: 'panEuropean_4_2_a', - rows: { - names: ['forest_2025', 'forest_2020', 'forest_2015', 'forest_2010', 'forest_2005', 'forest_2000', 'forest_1990'], - }, - columns: [ - { name: 'natural_expansion_and_natural_regeneration', type: 'numeric' }, - { name: 'afforestation_and_regeneration_by_planting_and_or_seeding', type: 'numeric' }, - { name: 'coppice', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table4_2b.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table4_2b.ts deleted file mode 100644 index 847ff32a75..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table4_2b.ts +++ /dev/null @@ -1,15 +0,0 @@ -export default { - tableName: 'table_4_2b', - schemaName: 'pan_european', - section: 'panEuropean_4_2_b', - rows: { - names: ['forest_2025', 'forest_2020', 'forest_2015', 'forest_2010', 'forest_2005', 'forest_2000', 'forest_1990'], - }, - columns: [ - { name: 'afforestation', type: 'numeric' }, - { name: 'natural_expansion', type: 'numeric' }, - { name: 'natural_regeneration', type: 'numeric' }, - { name: 'planting_and_seeding', type: 'numeric' }, - { name: 'coppice', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table4_3a.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table4_3a.ts deleted file mode 100644 index 5a87490a1c..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table4_3a.ts +++ /dev/null @@ -1,37 +0,0 @@ -export default { - tableName: 'table_4_3a', - schemaName: 'pan_european', - section: 'panEuropean_4_3_a', - rows: { - names: [ - 'forest_2025', - 'forest_2020', - 'forest_2015', - 'forest_2010', - 'forest_2005', - 'forest_2000', - 'forest_1990', - - 'other_wooded_land_2025', - 'other_wooded_land_2020', - 'other_wooded_land_2015', - 'other_wooded_land_2010', - 'other_wooded_land_2005', - 'other_wooded_land_2000', - 'other_wooded_land_1990', - - 'total_forest_and_other_wooded_land_2025', - 'total_forest_and_other_wooded_land_2020', - 'total_forest_and_other_wooded_land_2015', - 'total_forest_and_other_wooded_land_2010', - 'total_forest_and_other_wooded_land_2005', - 'total_forest_and_other_wooded_land_2000', - 'total_forest_and_other_wooded_land_1990', - ], - }, - columns: [ - { name: 'undisturbed_by_man', type: 'numeric' }, - { name: 'semi_natural', type: 'numeric' }, - { name: 'plantations', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table4_3b.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table4_3b.ts deleted file mode 100644 index 7bc209de39..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table4_3b.ts +++ /dev/null @@ -1,17 +0,0 @@ -export default { - tableName: 'table_4_3b', - schemaName: 'pan_european', - section: 'panEuropean_4_3_b', - rows: { - names: ['forest_2025', 'forest_2020', 'forest_2015', 'forest_2010', 'forest_2005', 'forest_2000', 'forest_1990'], - }, - columns: [ - { name: 'naturally_established', type: 'numeric' }, - { name: 'naturalised_introduced_species', type: 'numeric' }, - { name: 'established_by_planting_and_or_seeding', type: 'numeric' }, - { name: 'coppice', type: 'numeric' }, - { name: 'unknown_origin', type: 'numeric' }, - { name: 'native_species', type: 'numeric' }, - { name: 'introduced_species', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table4_4a.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table4_4a.ts deleted file mode 100644 index 7cd00751fb..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table4_4a.ts +++ /dev/null @@ -1,36 +0,0 @@ -export default { - tableName: 'table_4_4a', - schemaName: 'pan_european', - section: 'panEuropean_4_4_a', - rows: { - names: [ - 'forest_2025', - 'forest_2020', - 'forest_2015', - 'forest_2010', - 'forest_2005', - 'forest_2000', - 'forest_1990', - - 'other_wooded_land_2025', - 'other_wooded_land_2020', - 'other_wooded_land_2015', - 'other_wooded_land_2010', - 'other_wooded_land_2005', - 'other_wooded_land_2000', - 'other_wooded_land_1990', - - 'total_forest_and_other_wooded_land_2025', - 'total_forest_and_other_wooded_land_2020', - 'total_forest_and_other_wooded_land_2015', - 'total_forest_and_other_wooded_land_2010', - 'total_forest_and_other_wooded_land_2005', - 'total_forest_and_other_wooded_land_2000', - 'total_forest_and_other_wooded_land_1990', - ], - }, - columns: [ - { name: 'total', type: 'numeric' }, - { name: '_of_which_invasive', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table4_4b.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table4_4b.ts deleted file mode 100644 index 07e6620da8..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table4_4b.ts +++ /dev/null @@ -1,35 +0,0 @@ -export default { - tableName: 'table_4_4b', - schemaName: 'pan_european', - section: 'panEuropean_4_4_b', - rows: { - names: [ - '_01', - '_02', - '_03', - '_04', - '_05', - '_06', - '_07', - '_08', - '_09', - '_10', - '_11', - '_12', - '_13', - '_14', - '_15', - '_16', - '_17', - '_18', - '_19', - '_20', - ], - }, - columns: [ - { name: 'scientific_name_of_introduced_tree_species', type: 'text' }, - { name: 'forest_area_occupied_2005', type: 'numeric' }, - { name: 'forest_area_occupied_2010', type: 'numeric' }, - { name: 'forest_area_occupied_2015', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table4_4c.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table4_4c.ts deleted file mode 100644 index 3147e9c813..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table4_4c.ts +++ /dev/null @@ -1,35 +0,0 @@ -export default { - tableName: 'table_4_4c', - schemaName: 'pan_european', - section: 'panEuropean_4_4_c', - rows: { - names: [ - '_01', - '_02', - '_03', - '_04', - '_05', - '_06', - '_07', - '_08', - '_09', - '_10', - '_11', - '_12', - '_13', - '_14', - '_15', - '_16', - '_17', - '_18', - '_19', - '_20', - ], - }, - columns: [ - { name: 'scientific_name_of_invasive_tree_species', type: 'text' }, - { name: 'forest_area_affected_2005', type: 'numeric' }, - { name: 'forest_area_affected_2010', type: 'numeric' }, - { name: 'forest_area_affected_2015', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table4_5.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table4_5.ts deleted file mode 100644 index ae3f828fdc..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table4_5.ts +++ /dev/null @@ -1,41 +0,0 @@ -export default { - tableName: 'table_4_5', - schemaName: 'pan_european', - section: 'panEuropean_4_5', - rows: { - names: [ - 'forest_2020', - 'forest_2015', - 'forest_2010', - 'forest_2005', - 'forest_2000', - 'forest_1990', - - 'other_wooded_land_2020', - 'other_wooded_land_2015', - 'other_wooded_land_2010', - 'other_wooded_land_2005', - 'other_wooded_land_2000', - 'other_wooded_land_1990', - - 'total_forest_and_other_wooded_land_2020', - 'total_forest_and_other_wooded_land_2015', - 'total_forest_and_other_wooded_land_2010', - 'total_forest_and_other_wooded_land_2005', - 'total_forest_and_other_wooded_land_2000', - 'total_forest_and_other_wooded_land_1990', - - 'volumeOfDeadwoodInFOWLBySpeciesGroups', - - 'coniferous_2020', - 'coniferous_2015', - 'broadleaved_2020', - 'broadleaved_2015', - ], - }, - columns: [ - { name: 'total', type: 'numeric' }, - { name: 'standing', type: 'numeric' }, - { name: 'lying', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table4_8.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table4_8.ts deleted file mode 100644 index 7c8bd8d137..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table4_8.ts +++ /dev/null @@ -1,64 +0,0 @@ -export default { - tableName: 'table_4_8', - schemaName: 'pan_european', - section: 'panEuropean_4_8', - rows: { - names: [ - 'trees_2020', - 'trees_2015', - 'trees_2010', - 'trees_2005', - 'trees_2000', - 'trees_1990', - - 'birds_2020', - 'birds_2015', - 'birds_2010', - 'birds_2005', - 'birds_2000', - 'birds_1990', - - 'mammals_2020', - 'mammals_2015', - 'mammals_2010', - 'mammals_2005', - 'mammals_2000', - 'mammals_1990', - - 'other_vertebrates_2020', - 'other_vertebrates_2015', - 'other_vertebrates_2010', - 'other_vertebrates_2005', - 'other_vertebrates_2000', - 'other_vertebrates_1990', - - 'invertebrates_2020', - 'invertebrates_2015', - 'invertebrates_2010', - 'invertebrates_2005', - 'invertebrates_2000', - 'invertebrates_1990', - - 'vascular_plants_2020', - 'vascular_plants_2015', - 'vascular_plants_2010', - 'vascular_plants_2005', - 'vascular_plants_2000', - 'vascular_plants_1990', - - 'cryptogams_and_fungi_2020', - 'cryptogams_and_fungi_2015', - 'cryptogams_and_fungi_2010', - 'cryptogams_and_fungi_2005', - 'cryptogams_and_fungi_2000', - 'cryptogams_and_fungi_1990', - ], - }, - columns: [ - { name: 'total_of_taxa', type: 'numeric' }, - { name: 'vulnerable', type: 'numeric' }, - { name: 'endangered', type: 'numeric' }, - { name: 'critically_endangered', type: 'numeric' }, - { name: 'extinct_in_the_wild', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table4_9.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table4_9.ts deleted file mode 100644 index 2a308465cf..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table4_9.ts +++ /dev/null @@ -1,38 +0,0 @@ -export default { - tableName: 'table_4_9', - schemaName: 'pan_european', - section: 'panEuropean_4_9', - rows: { - names: [ - 'forest_2025', - 'forest_2020', - 'forest_2015', - 'forest_2010', - 'forest_2005', - 'forest_2000', - 'forest_1990', - - 'other_wooded_land_2025', - 'other_wooded_land_2020', - 'other_wooded_land_2015', - 'other_wooded_land_2010', - 'other_wooded_land_2005', - 'other_wooded_land_2000', - 'other_wooded_land_1990', - - 'total_forest_and_other_wooded_land_2025', - 'total_forest_and_other_wooded_land_2020', - 'total_forest_and_other_wooded_land_2015', - 'total_forest_and_other_wooded_land_2010', - 'total_forest_and_other_wooded_land_2005', - 'total_forest_and_other_wooded_land_2000', - 'total_forest_and_other_wooded_land_1990', - ], - }, - columns: [ - { name: 'mcpfe_class_1_1', type: 'numeric' }, - { name: 'mcpfe_class_1_2', type: 'numeric' }, - { name: 'mcpfe_class_1_3', type: 'numeric' }, - { name: 'mcpfe_class_2', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table5_1.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table5_1.ts deleted file mode 100644 index a9cfeabef6..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table5_1.ts +++ /dev/null @@ -1,37 +0,0 @@ -export default { - tableName: 'table_5_1', - schemaName: 'pan_european', - section: 'panEuropean_5_1', - rows: { - names: [ - 'forest_2025', - 'forest_2020', - 'forest_2015', - 'forest_2010', - 'forest_2005', - 'forest_2000', - 'forest_1990', - - 'other_wooded_land_2025', - 'other_wooded_land_2020', - 'other_wooded_land_2015', - 'other_wooded_land_2010', - 'other_wooded_land_2005', - 'other_wooded_land_2000', - 'other_wooded_land_1990', - - 'total_forest_and_other_wooded_land_2025', - 'total_forest_and_other_wooded_land_2020', - 'total_forest_and_other_wooded_land_2015', - 'total_forest_and_other_wooded_land_2010', - 'total_forest_and_other_wooded_land_2005', - 'total_forest_and_other_wooded_land_2000', - 'total_forest_and_other_wooded_land_1990', - ], - }, - columns: [ - { name: 'soil_water_and_other_forest_ecosystem_functions', type: 'numeric' }, - { name: 'infrastructure_and_managed_natural_resources', type: 'numeric' }, - { name: 'total', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table6_1.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table6_1.ts deleted file mode 100644 index f7d467c001..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table6_1.ts +++ /dev/null @@ -1,39 +0,0 @@ -export default { - tableName: 'table_6_1', - schemaName: 'pan_european', - section: 'panEuropean_6_1', - rows: { - names: [ - 'in_public_ownership_2020', - 'in_public_ownership_2015', - 'in_public_ownership_2010', - 'in_public_ownership_2005', - 'in_public_ownership_2000', - 'in_public_ownership_1990', - - 'in_private_ownership_2020', - 'in_private_ownership_2015', - 'in_private_ownership_2010', - 'in_private_ownership_2005', - 'in_private_ownership_2000', - 'in_private_ownership_1990', - - 'other_types_of_ownership_unknown_2020', - 'other_types_of_ownership_unknown_2015', - 'other_types_of_ownership_unknown_2010', - 'other_types_of_ownership_unknown_2005', - 'other_types_of_ownership_unknown_2000', - 'other_types_of_ownership_unknown_1990', - ], - }, - columns: [ - { name: 'total_forest_area', type: 'numeric' }, - { name: 'total_number_of_holdings', type: 'numeric' }, - { name: 'less_10_ha_area', type: 'numeric' }, - { name: 'less_10_ha_number', type: 'numeric' }, - { name: '_11_500_ha_area', type: 'numeric' }, - { name: '_11_500_ha_number', type: 'numeric' }, - { name: 'more_500_ha_area', type: 'numeric' }, - { name: 'more_500_ha_number', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table6_10a.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table6_10a.ts deleted file mode 100644 index 42e308e314..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table6_10a.ts +++ /dev/null @@ -1,21 +0,0 @@ -export default { - tableName: 'table_6_10a', - schemaName: 'pan_european', - section: 'panEuropean_6_10_a', - rows: { - names: [ - 'total_forest_and_other_wooded_land_2020', - 'total_forest_and_other_wooded_land_2015', - 'total_forest_and_other_wooded_land_2010', - 'total_forest_and_other_wooded_land_2005', - 'total_forest_and_other_wooded_land_2000', - 'total_forest_and_other_wooded_land_1990', - ], - }, - columns: [ - { name: 'area_available_for_public_recreation_total', type: 'numeric' }, - { name: 'area_available_for_public_recreation_percent', type: 'numeric' }, - { name: 'area_designated_or_managed_for_public_recreation_total', type: 'numeric' }, - { name: 'area_designated_or_managed_for_public_recreation_percent', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table6_10b.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table6_10b.ts deleted file mode 100644 index ab4a95a8a0..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table6_10b.ts +++ /dev/null @@ -1,17 +0,0 @@ -export default { - tableName: 'table_6_10b', - schemaName: 'pan_european', - section: 'panEuropean_6_10_b', - rows: { - names: [ - 'total_forest_and_other_wooded_land_2020', - 'total_forest_and_other_wooded_land_2015', - 'total_forest_and_other_wooded_land_2010', - 'total_forest_and_other_wooded_land_2005', - ], - }, - columns: [ - { name: 'area_available_for_public_recreation', type: 'numeric' }, - { name: 'area_designated_and_or_managed_for_public_recreation', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table6_10c.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table6_10c.ts deleted file mode 100644 index 460a0b96e2..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table6_10c.ts +++ /dev/null @@ -1,12 +0,0 @@ -export default { - tableName: 'table_6_10c', - schemaName: 'pan_european', - section: 'panEuropean_6_10_c', - rows: { - names: ['area_available_for_public_recreation_2020', 'area_available_for_public_recreation_2015'], - }, - columns: [ - { name: 'forest_roads_and_paths_available_for_public_recreation', type: 'numeric' }, - { name: '_of_which_designated_for_hiking_biking_cross_country_skiing_etc', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table6_10d.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table6_10d.ts deleted file mode 100644 index e114ae3822..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table6_10d.ts +++ /dev/null @@ -1,35 +0,0 @@ -export default { - tableName: 'table_6_10d', - schemaName: 'pan_european', - section: 'panEuropean_6_10_d', - rows: { - names: [ - 'no1_area_available_for_public_recreation', - 'no2_area_available_for_public_recreation', - 'no3_area_available_for_public_recreation', - 'no4_area_available_for_public_recreation', - 'no5_area_available_for_public_recreation', - 'no6_area_available_for_public_recreation', - 'no7_area_available_for_public_recreation', - 'no8_area_available_for_public_recreation', - 'no9_area_available_for_public_recreation', - 'no10_area_available_for_public_recreation', - 'no11_area_available_for_public_recreation', - 'no12_area_available_for_public_recreation', - 'no13_area_available_for_public_recreation', - 'no14_area_available_for_public_recreation', - 'no15_area_available_for_public_recreation', - 'no16_area_available_for_public_recreation', - 'no17_area_available_for_public_recreation', - 'no18_area_available_for_public_recreation', - 'no19_area_available_for_public_recreation', - 'no20_area_available_for_public_recreation', - ], - }, - columns: [ - { name: 'facility', type: 'text' }, - { name: 'measurement_unit', type: 'text' }, - { name: 'extent_multiplicity', type: 'numeric' }, - { name: 'facility_category', type: 'text' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table6_2.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table6_2.ts deleted file mode 100644 index b6aa66e8e0..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table6_2.ts +++ /dev/null @@ -1,33 +0,0 @@ -export default { - tableName: 'table_6_2', - schemaName: 'pan_european', - section: 'panEuropean_6_2', - rows: { - names: [ - 'forestry_2020', - 'forestry_2015', - 'forestry_2010', - 'forestry_2005', - 'forestry_2000', - 'forestry_1990', - - 'manufacture_of_wood_and_articles_in_wood_2020', - 'manufacture_of_wood_and_articles_in_wood_2015', - 'manufacture_of_wood_and_articles_in_wood_2010', - 'manufacture_of_wood_and_articles_in_wood_2005', - 'manufacture_of_wood_and_articles_in_wood_2000', - 'manufacture_of_wood_and_articles_in_wood_1990', - - 'manufacture_of_paper_and_paper_products_2020', - 'manufacture_of_paper_and_paper_products_2015', - 'manufacture_of_paper_and_paper_products_2010', - 'manufacture_of_paper_and_paper_products_2005', - 'manufacture_of_paper_and_paper_products_2000', - 'manufacture_of_paper_and_paper_products_1990', - ], - }, - columns: [ - { name: 'million_national_currency', type: 'numeric' }, - { name: 'percent_of_total_gva', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table6_3.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table6_3.ts deleted file mode 100644 index 85be630a5c..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table6_3.ts +++ /dev/null @@ -1,12 +0,0 @@ -export default { - tableName: 'table_6_3', - schemaName: 'pan_european', - section: 'panEuropean_6_3', - rows: { - names: ['forestry_2020', 'forestry_2015', 'forestry_2010', 'forestry_2005', 'forestry_2000', 'forestry_1990'], - }, - columns: [ - { name: 'factor_income', type: 'numeric' }, - { name: 'net_operating_surplus', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table6_4a.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table6_4a.ts deleted file mode 100644 index 69d2c88dd5..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table6_4a.ts +++ /dev/null @@ -1,21 +0,0 @@ -export default { - tableName: 'table_6_4a', - schemaName: 'pan_european', - section: 'panEuropean_6_4_a', - rows: { - names: [ - 'forestry_isic_nace_02_2020', - 'forestry_isic_nace_02_2015', - 'forestry_isic_nace_02_2010', - 'forestry_isic_nace_02_2005', - 'forestry_isic_nace_02_2000', - 'forestry_isic_nace_02_1990', - ], - }, - columns: [ - { name: 'planting_of_trees_to_provide_regular_income', type: 'numeric' }, - { name: 'equipment_and_buildings', type: 'numeric' }, - { name: 'other_gross_fixed_capital_formation', type: 'numeric' }, - { name: 'total', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table6_4b.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table6_4b.ts deleted file mode 100644 index f323c6e317..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table6_4b.ts +++ /dev/null @@ -1,16 +0,0 @@ -export default { - tableName: 'table_6_4b', - schemaName: 'pan_european', - section: 'panEuropean_6_4_b', - rows: { - names: [ - 'forestry_isic_nace_02_2020', - 'forestry_isic_nace_02_2015', - 'forestry_isic_nace_02_2010', - 'forestry_isic_nace_02_2005', - 'forestry_isic_nace_02_2000', - 'forestry_isic_nace_02_1990', - ], - }, - columns: [{ name: 'fixed_capital_consumption', type: 'numeric' }], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table6_4c.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table6_4c.ts deleted file mode 100644 index 08e4f46c42..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table6_4c.ts +++ /dev/null @@ -1,16 +0,0 @@ -export default { - tableName: 'table_6_4c', - schemaName: 'pan_european', - section: 'panEuropean_6_4_c', - rows: { - names: [ - 'forestry_isic_nace_02_2020', - 'forestry_isic_nace_02_2015', - 'forestry_isic_nace_02_2010', - 'forestry_isic_nace_02_2005', - 'forestry_isic_nace_02_2000', - 'forestry_isic_nace_02_1990', - ], - }, - columns: [{ name: 'capital_transfers', type: 'numeric' }], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table6_5a.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table6_5a.ts deleted file mode 100644 index 53372d6d3c..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table6_5a.ts +++ /dev/null @@ -1,36 +0,0 @@ -export default { - tableName: 'table_6_5a', - schemaName: 'pan_european', - section: 'panEuropean_6_5_a', - rows: { - names: [ - 'forestry_2020', - 'forestry_2015', - 'forestry_2010', - 'forestry_2005', - 'forestry_2000', - 'forestry_1990', - - 'manufacture_of_wood_and_articles_in_wood_2020', - 'manufacture_of_wood_and_articles_in_wood_2015', - 'manufacture_of_wood_and_articles_in_wood_2010', - 'manufacture_of_wood_and_articles_in_wood_2005', - 'manufacture_of_wood_and_articles_in_wood_2000', - 'manufacture_of_wood_and_articles_in_wood_1990', - - 'manufacture_of_paper_and_paper_products_2020', - 'manufacture_of_paper_and_paper_products_2015', - 'manufacture_of_paper_and_paper_products_2010', - 'manufacture_of_paper_and_paper_products_2005', - 'manufacture_of_paper_and_paper_products_2000', - 'manufacture_of_paper_and_paper_products_1990', - ], - }, - columns: [ - { name: 'total', type: 'numeric' }, - { name: 'gender_male', type: 'numeric' }, - { name: 'gender_female', type: 'numeric' }, - { name: 'age_group_15_49', type: 'numeric' }, - { name: 'age_group_50_plus', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table6_5b.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table6_5b.ts deleted file mode 100644 index 9b2028c997..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table6_5b.ts +++ /dev/null @@ -1,36 +0,0 @@ -export default { - tableName: 'table_6_5b', - schemaName: 'pan_european', - section: 'panEuropean_6_5_b', - rows: { - names: [ - 'forestry_2020', - 'forestry_2015', - 'forestry_2010', - 'forestry_2005', - 'forestry_2000', - 'forestry_1990', - - 'manufacture_of_wood_and_articles_in_wood_2020', - 'manufacture_of_wood_and_articles_in_wood_2015', - 'manufacture_of_wood_and_articles_in_wood_2010', - 'manufacture_of_wood_and_articles_in_wood_2005', - 'manufacture_of_wood_and_articles_in_wood_2000', - 'manufacture_of_wood_and_articles_in_wood_1990', - - 'manufacture_of_paper_and_paper_products_2020', - 'manufacture_of_paper_and_paper_products_2015', - 'manufacture_of_paper_and_paper_products_2010', - 'manufacture_of_paper_and_paper_products_2005', - 'manufacture_of_paper_and_paper_products_2000', - 'manufacture_of_paper_and_paper_products_1990', - ], - }, - columns: [ - { name: 'education_0_2', type: 'numeric' }, - { name: 'education_3_4', type: 'numeric' }, - { name: 'education_5_6', type: 'numeric' }, - { name: 'employees', type: 'numeric' }, - { name: 'self_employed', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table6_6.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table6_6.ts deleted file mode 100644 index f65808b102..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table6_6.ts +++ /dev/null @@ -1,21 +0,0 @@ -export default { - tableName: 'table_6_6', - schemaName: 'pan_european', - section: 'panEuropean_6_6', - rows: { - names: [ - 'forestry_isic_nace_02_2020', - 'forestry_isic_nace_02_2015', - 'forestry_isic_nace_02_2010', - 'forestry_isic_nace_02_2005', - 'forestry_isic_nace_02_2000', - 'forestry_isic_nace_02_1990', - ], - }, - columns: [ - { name: 'fatal_occupational_accidents_number', type: 'numeric' }, - { name: 'fatal_occupational_accidents_per_1000_workers', type: 'numeric' }, - { name: 'non_fatal_occupational_accidents_number', type: 'numeric' }, - { name: 'non_fatal_occupational_accidents_per_1000_workers', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table6_7.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table6_7.ts deleted file mode 100644 index 38605ca9f1..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table6_7.ts +++ /dev/null @@ -1,36 +0,0 @@ -export default { - tableName: 'table_6_7', - schemaName: 'pan_european', - section: 'panEuropean_6_7', - rows: { - names: ['wood_consumption'], - }, - columns: [ - { name: '_1992', type: 'numeric' }, - { name: '_1993', type: 'numeric' }, - { name: '_1994', type: 'numeric' }, - { name: '_1995', type: 'numeric' }, - { name: '_1996', type: 'numeric' }, - { name: '_1997', type: 'numeric' }, - { name: '_1998', type: 'numeric' }, - { name: '_1999', type: 'numeric' }, - { name: '_2000', type: 'numeric' }, - { name: '_2001', type: 'numeric' }, - { name: '_2002', type: 'numeric' }, - { name: '_2003', type: 'numeric' }, - { name: '_2004', type: 'numeric' }, - { name: '_2005', type: 'numeric' }, - { name: '_2006', type: 'numeric' }, - { name: '_2007', type: 'numeric' }, - { name: '_2008', type: 'numeric' }, - { name: '_2009', type: 'numeric' }, - { name: '_2010', type: 'numeric' }, - { name: '_2011', type: 'numeric' }, - { name: '_2012', type: 'numeric' }, - { name: '_2013', type: 'numeric' }, - { name: '_2014', type: 'numeric' }, - { name: '_2015', type: 'numeric' }, - { name: '_2016', type: 'numeric' }, - { name: '_2017', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table6_8.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table6_8.ts deleted file mode 100644 index 0fbca8dd15..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table6_8.ts +++ /dev/null @@ -1,41 +0,0 @@ -export default { - tableName: 'table_6_8', - schemaName: 'pan_european', - section: 'panEuropean_6_8', - rows: { - names: [ - 'exports_of_forest_products_quantity', - 'exports_of_forest_products_value', - 'import * as s_of_forest_products_quantity', - 'import * as s_of_forest_products_value', - ], - }, - columns: [ - { name: '_1992', type: 'numeric' }, - { name: '_1993', type: 'numeric' }, - { name: '_1994', type: 'numeric' }, - { name: '_1995', type: 'numeric' }, - { name: '_1996', type: 'numeric' }, - { name: '_1997', type: 'numeric' }, - { name: '_1998', type: 'numeric' }, - { name: '_1999', type: 'numeric' }, - { name: '_2000', type: 'numeric' }, - { name: '_2001', type: 'numeric' }, - { name: '_2002', type: 'numeric' }, - { name: '_2003', type: 'numeric' }, - { name: '_2004', type: 'numeric' }, - { name: '_2005', type: 'numeric' }, - { name: '_2006', type: 'numeric' }, - { name: '_2007', type: 'numeric' }, - { name: '_2008', type: 'numeric' }, - { name: '_2009', type: 'numeric' }, - { name: '_2010', type: 'numeric' }, - { name: '_2011', type: 'numeric' }, - { name: '_2012', type: 'numeric' }, - { name: '_2013', type: 'numeric' }, - { name: '_2014', type: 'numeric' }, - { name: '_2015', type: 'numeric' }, - { name: '_2016', type: 'numeric' }, - { name: '_2017', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/mappings/panEuropean/table6_9.ts b/tools/dataMigration/dataTable/mappings/panEuropean/table6_9.ts deleted file mode 100644 index 4d42f1d769..0000000000 --- a/tools/dataMigration/dataTable/mappings/panEuropean/table6_9.ts +++ /dev/null @@ -1,33 +0,0 @@ -export default { - tableName: 'table_6_9', - schemaName: 'pan_european', - section: 'panEuropean_6_9', - rows: { - names: [ - 'total_primary_energy_supply', - 'total_renewable_energy_supply', - 'total_energy_supply_from_wood', - 'energy_from_direct_wood_fibre_sources', - 'of_which_from_forests', - 'of_which_from_other_wooded_land', - 'energy_from_co_products', - 'of_which_solid_residues', - 'energy_from_processed_wood_based_fuels', - 'of_which_import * as ed', - 'energy_from_post_consumer_recovered_wood', - 'energy_from_unknown_unspecified_sources', - ], - }, - columns: [ - { name: 'tj_2007', type: 'numeric' }, - { name: '_1000_metric_tonnes_dry_matter_2007', type: 'numeric' }, - { name: 'tj_2009', type: 'numeric' }, - { name: '_1000_metric_tonnes_dry_matter_2009', type: 'numeric' }, - { name: 'tj_2011', type: 'numeric' }, - { name: '_1000_metric_tonnes_dry_matter_2011', type: 'numeric' }, - { name: 'tj_2013', type: 'numeric' }, - { name: '_1000_metric_tonnes_dry_matter_2013', type: 'numeric' }, - { name: 'tj_2015', type: 'numeric' }, - { name: '_1000_metric_tonnes_dry_matter_2015', type: 'numeric' }, - ], -} diff --git a/tools/dataMigration/dataTable/tableMappings.ts b/tools/dataMigration/dataTable/tableMappings.ts deleted file mode 100644 index 857d82963c..0000000000 --- a/tools/dataMigration/dataTable/tableMappings.ts +++ /dev/null @@ -1,65 +0,0 @@ -import * as R from 'ramda' -import * as assert from 'assert' - -import fra from './mappings/fra' -import panEuropean from './mappings/panEuropean' - -export const mappings: { [key: string]: any } = { - ...fra, - ...panEuropean, -} - -export const getRowIndex = (name: any, names: any) => { - const idx = R.findIndex((x: any) => x === name, names) - return idx === -1 ? -1 : idx -} - -export const getRowName = (idx: any, names: any) => names[idx] - -export const getColumnName = (idx: any, columns: any) => R.path([idx, 'name'], columns) - -export const getColumnIndex = (name: any, columns: any) => R.findIndex((x: any) => x.name === name, columns) - -export const Mapping = (mapping: any): TableMapping => - R.merge(mapping, { - getRowName: (idx: any) => getRowName(idx, mapping.rows.names), - getRowIndex: (name: any) => getRowIndex(name, mapping.rows.names), - getFullRowCount: () => mapping.rows.names.length, - getColumn: (idx: any) => mapping.columns[idx], - getColumnName: (idx: any) => getColumnName(idx, mapping.columns), - getColumnIndex: (name: any) => getColumnIndex(name, mapping.columns), - getFullColumnCount: () => mapping.columns.length, - }) as TableMapping - -export const assertSanity = (mappingObj: any) => { - const errMsg = 'Malformed FRA table mapping' - assert(mappingObj.getFullRowCount() > 0, errMsg) - assert(mappingObj.getFullColumnCount() > 0, errMsg) - assert(mappingObj, errMsg) - assert(mappingObj.rows.names.length > 0, errMsg) - assert(mappingObj.columns.length > 0, errMsg) -} - -export type ColumnMapping = { name: string; type: string } -export type TableMapping = { - tableName: string - rows: { - names: Array - } - columns: Array - getRowName: (idx: number) => string - getRowIndex: (name: string) => number - getFullRowCount: () => number - getColumn: (idx: number) => ColumnMapping - getColumnName: (idx: number) => string - getColumnIndex: (name: string) => number - getFullColumnCount: () => number -} - -export const getMapping = (tableSpecName: string): TableMapping => { - const mappingData = mappings[tableSpecName] - if (!mappingData) throw new Error(`Could not find mapping for tableSpecName ${tableSpecName}`) - const mappingObj = Mapping(mappingData) - assertSanity(mappingObj) - return mappingObj -} diff --git a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/array.ts b/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/array.ts deleted file mode 100755 index eab410367e..0000000000 --- a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/array.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { ArrayExpression, ExpressionContext, ExpressionNodeEvaluator } from '@openforis/arena-core' - -export class ArrayEvaluator extends ExpressionNodeEvaluator { - evaluate(expressionNode: ArrayExpression): any { - const { elements } = expressionNode - - return `[${elements.map((element) => this.evaluator.evaluateNode(element, this.context)).join(',')}]` - } -} diff --git a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/binary.ts b/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/binary.ts deleted file mode 100755 index c434731029..0000000000 --- a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/binary.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { BinaryExpression, ExpressionContext, ExpressionNodeEvaluator } from '@openforis/arena-core' - -export class Binary extends ExpressionNodeEvaluator { - evaluate(expressionNode: BinaryExpression): any { - const { left, right, operator } = expressionNode - const evaluateLeft = this.evaluator.evaluateNode(left, this.context) - const evaluateRight = this.evaluator.evaluateNode(right, this.context) - return `${evaluateLeft} ${operator} ${evaluateRight}` - } -} diff --git a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/call.ts b/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/call.ts deleted file mode 100755 index 2a1c485f6f..0000000000 --- a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/call.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { - CallExpression, - ExpressionContext, - ExpressionNode, - ExpressionNodeEvaluator, - ExpressionNodeType, -} from '@openforis/arena-core' - -export class CallEvaluator extends ExpressionNodeEvaluator { - evaluate(expressionNode: CallExpression): any { - const { callee } = expressionNode - - return `${this.evaluator.evaluateNode( - callee as unknown as ExpressionNode, - this.context - )}(${expressionNode.arguments.map((arg) => this.evaluator.evaluateNode(arg, this.context)).join(',')})` - } -} diff --git a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/compound.ts b/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/compound.ts deleted file mode 100755 index b64d88a23c..0000000000 --- a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/compound.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { CompoundExpression, ExpressionContext, ExpressionNodeEvaluator } from '@openforis/arena-core' - -export class CompoundEvaluator extends ExpressionNodeEvaluator { - // eslint-disable-next-line class-methods-use-this - evaluate(): any { - throw new Error(`compound not supported`) - } -} diff --git a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/conditional.ts b/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/conditional.ts deleted file mode 100755 index 4d43d7f6b1..0000000000 --- a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/conditional.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { ConditionalExpression, ExpressionNodeEvaluator } from '@openforis/arena-core' - -import { Context } from './context' - -export class ConditionalEvaluator extends ExpressionNodeEvaluator { - evaluate(expressionNode: ConditionalExpression): any { - const { alternate, consequent, test } = expressionNode - - const evaluateTest = this.evaluator.evaluateNode(test, this.context) - const evaluateConsequent = this.evaluator.evaluateNode(consequent, this.context) - const evaluateAlternate = this.evaluator.evaluateNode(alternate, this.context) - - return `${evaluateTest} ? ${evaluateConsequent} : ${evaluateAlternate}` - } -} diff --git a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/context.ts b/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/context.ts deleted file mode 100644 index 46bb287047..0000000000 --- a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/context.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { ExpressionContext } from '@openforis/arena-core' - -import { AssessmentMetaCache } from '../../../../../src/meta/assessment/assessmentMetaCache' -import { Row } from '../../../../../src/meta/assessment/row' - -export interface Context extends ExpressionContext { - assessmentMetaCache: AssessmentMetaCache - row: Row - tableName: string - type: 'calculations' | 'validations' -} diff --git a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/identifier.ts b/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/identifier.ts deleted file mode 100755 index 77e5b109ed..0000000000 --- a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/identifier.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { ExpressionNodeEvaluator, IdentifierExpression } from '@openforis/arena-core' - -import { Context } from './context' - -export class IdentifierEvaluator extends ExpressionNodeEvaluator { - // eslint-disable-next-line class-methods-use-this - evaluate(expressionNode: IdentifierExpression): any { - const { name } = expressionNode - return name - } -} diff --git a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/index.ts b/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/index.ts deleted file mode 100644 index b6ffce1f4c..0000000000 --- a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/index.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { ExpressionNodeType, JavascriptExpressionEvaluator } from '@openforis/arena-core' - -import { ArrayEvaluator } from './array' -import { Binary } from './binary' -import { CallEvaluator } from './call' -import { CompoundEvaluator } from './compound' -import { ConditionalEvaluator } from './conditional' -import { Context } from './context' -import { IdentifierEvaluator } from './identifier' -import { LiteralEvaluator } from './literal' -import { MemberEvaluator } from './member' -import { SequenceEvaluator } from './sequence' -import { ThisEvaluator } from './this' -import { UnaryEvaluator } from './unary' - -export const evalDependencies = (expression: string, context: Context): void => { - const evaluators = { - // @ts-ignore - [ExpressionNodeType.Array]: ArrayEvaluator, - // @ts-ignore - [ExpressionNodeType.Binary]: Binary, - // @ts-ignore - [ExpressionNodeType.Call]: CallEvaluator, - // @ts-ignore - [ExpressionNodeType.Compound]: CompoundEvaluator, - // @ts-ignore - [ExpressionNodeType.Identifier]: IdentifierEvaluator, - // @ts-ignore - [ExpressionNodeType.Literal]: LiteralEvaluator, - // @ts-ignore - [ExpressionNodeType.Logical]: Binary, - // @ts-ignore - [ExpressionNodeType.Member]: MemberEvaluator, - // @ts-ignore - [ExpressionNodeType.This]: ThisEvaluator, - // @ts-ignore - [ExpressionNodeType.Unary]: UnaryEvaluator, - // @ts-ignore - [ExpressionNodeType.Conditional]: ConditionalEvaluator, - // @ts-ignore - [ExpressionNodeType.Sequence]: SequenceEvaluator, - } - const evaluator = new JavascriptExpressionEvaluator([], evaluators) - evaluator.evaluate(expression, context) -} diff --git a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/literal.ts b/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/literal.ts deleted file mode 100755 index 955d90248d..0000000000 --- a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/literal.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { ExpressionContext, ExpressionNodeEvaluator, LiteralExpression } from '@openforis/arena-core' - -export class LiteralEvaluator extends ExpressionNodeEvaluator { - // eslint-disable-next-line class-methods-use-this - evaluate(expressionNode: LiteralExpression): any { - // @ts-ignore (raw must be added as key to LiteralExpression in @arena-core - return expressionNode.raw - } -} diff --git a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/member.ts b/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/member.ts deleted file mode 100755 index 3e436ccf7f..0000000000 --- a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/member.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { ExpressionNodeEvaluator, MemberExpression } from '@openforis/arena-core' - -import { VariableCache } from '../../../../../src/meta/assessment/assessmentMetaCache' -import { Row } from '../../../../../src/meta/assessment/row' -import { Context } from './context' - -const includesVariableCache = (variables: Array, variable: VariableCache): boolean => - Boolean(variables.find((v) => v.variableName === variable.variableName && v.tableName === variable.tableName)) - -const excludeDependant = (row: Row, tableName: string, variableName: string): boolean => - Boolean(row.props?.dependantsExclude?.find((v) => v.tableName === tableName && v.variableName === variableName)) - -export class MemberEvaluator extends ExpressionNodeEvaluator { - evaluate(expressionNode: MemberExpression): string { - const { object, property } = expressionNode - - const { assessmentMetaCache, row, tableName, type } = this.context - - // @ts-ignore - const objectName = object?.object?.name ?? object.name - // @ts-ignore - const propertyName = object?.property?.name ?? property.name - - if (assessmentMetaCache.variablesByTable[objectName]) { - const dependantTable = assessmentMetaCache[type].dependants?.[objectName] ?? {} - const dependants = dependantTable[propertyName] ?? [] - const dependant: VariableCache = { variableName: row.props.variableName, tableName } - if (!excludeDependant(row, objectName, propertyName) && !includesVariableCache(dependants, dependant)) { - assessmentMetaCache[type].dependants = { - ...assessmentMetaCache[type].dependants, - // @ts-ignore - [objectName]: { - ...dependantTable, - // @ts-ignore - [propertyName]: [...dependants, dependant], - }, - } - } - - const dependencyTable = assessmentMetaCache[type].dependencies?.[tableName] ?? {} - const dependencies = dependencyTable[row.props.variableName] ?? [] - // @ts-ignore - const dependency: VariableCache = { variableName: propertyName, tableName: objectName } - if (!includesVariableCache(dependencies, dependency)) { - assessmentMetaCache[type].dependencies = { - ...assessmentMetaCache[type].dependencies, - [tableName]: { - ...dependencyTable, - [row.props.variableName]: [...dependencies, dependency], - }, - } - } - - const evaluateObject = this.evaluator.evaluateNode(object, this.context) - const evaluateProperty = this.evaluator.evaluateNode(property, this.context) - return `${evaluateObject}.${evaluateProperty}` - } - return `${objectName}.${propertyName}` - } -} diff --git a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/sequence.ts b/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/sequence.ts deleted file mode 100755 index f4160207f3..0000000000 --- a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/sequence.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { ExpressionNodeEvaluator, SequenceExpression } from '@openforis/arena-core' - -import { Context } from './context' - -export class SequenceEvaluator extends ExpressionNodeEvaluator { - evaluate(expressionNode: SequenceExpression): any { - const { expression } = expressionNode - - const result = this.evaluator.evaluateNode(expression, this.context) - - return result - } -} diff --git a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/this.ts b/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/this.ts deleted file mode 100755 index 582578533a..0000000000 --- a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/this.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { ExpressionContext, ExpressionNodeEvaluator, ThisExpression } from '@openforis/arena-core' - -export class ThisEvaluator extends ExpressionNodeEvaluator { - // eslint-disable-next-line class-methods-use-this - evaluate(): any { - return 'this' - } -} diff --git a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/unary.ts b/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/unary.ts deleted file mode 100755 index ca275884cf..0000000000 --- a/tools/dataMigration/generateMetaCache/dependencyEvaluator/evalDependencies/unary.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { ExpressionContext, ExpressionNodeEvaluator, UnaryExpression } from '@openforis/arena-core' - -export class UnaryEvaluator extends ExpressionNodeEvaluator { - evaluate(expressionNode: UnaryExpression): any { - const { argument, operator } = expressionNode - const evaluateArg = this.evaluator.evaluateNode(argument, this.context) - return `${operator} ${evaluateArg}` - } -} diff --git a/tools/dataMigration/generateMetaCache/dependencyEvaluator/index.ts b/tools/dataMigration/generateMetaCache/dependencyEvaluator/index.ts deleted file mode 100644 index 8433bd99f6..0000000000 --- a/tools/dataMigration/generateMetaCache/dependencyEvaluator/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { evalDependencies } from './evalDependencies' - -export const DependencyEvaluator = { - evalDependencies, -} diff --git a/tools/dataMigration/generateMetaCache/index.ts b/tools/dataMigration/generateMetaCache/index.ts deleted file mode 100644 index 39b72ab82b..0000000000 --- a/tools/dataMigration/generateMetaCache/index.ts +++ /dev/null @@ -1,131 +0,0 @@ -import { Cycle } from '../../../src/meta/assessment' -import { Assessment } from '../../../src/meta/assessment/assessment' -import { AssessmentMetaCache, VariablesCache } from '../../../src/meta/assessment/assessmentMetaCache' -import { Col } from '../../../src/meta/assessment/col' -import { Row } from '../../../src/meta/assessment/row' -import { BaseProtocol } from '../../../src/server/db' -import { Objects } from '../../../src/utils/objects' -import { DBNames } from '../_DBNames' -import { DependencyEvaluator } from './dependencyEvaluator' - -type Props = { - assessment: Assessment - cycle: Cycle -} - -export const generateMetaCache = async (props: Props, client: BaseProtocol): Promise => { - const { assessment, cycle } = props - const schema = DBNames.getAssessmentSchema(assessment.props.name) - - const variablesByTable = await client.one( - ` - with data as ( - select t.props ->> 'name' as table_name, - jsonb_object_agg( - r.props ->> 'variableName', - jsonb_build_object( - 'variableName', r.props ->> 'variableName', 'tableName', t.props ->> 'name' - )) as variables - from ${schema}.row r - left join ${schema}."table" t on r.table_id = t.id - where r.props ->> 'variableName' is not null - and t.props -> 'cycles' ? '${cycle.uuid}' - and r.props -> 'cycles' ? '${cycle.uuid}' - group by t.props ->> 'name' - ) - select jsonb_object_agg(data.table_name, data.variables) as cache - from data - `, - [], - ({ cache }) => cache - ) - - const assessmentMetaCache: AssessmentMetaCache = { - calculations: { - dependants: {}, - dependencies: {}, - }, - validations: { - dependants: {}, - dependencies: {}, - }, - variablesByTable: { - ...variablesByTable, - }, - } - - const rows = await client.map }>( - ` - select r.*, - t.props ->> 'name' as table_name, - jsonb_agg(c.*) as cols - from ${schema}.row r - left join ${schema}."table" t - on r.table_id = t.id - left join ${schema}.col c on r.id = c.row_id - where (r.props -> 'calculateFn' is not null and r.props -> 'calculateFn' ->> '${cycle.uuid}' is not null) - or (r.props -> 'validateFns' is not null and r.props -> 'validateFns' ->> '${cycle.uuid}' is not null) - or (c.props -> 'calculateFn' is not null and c.props -> 'calculateFn' ->> '${cycle.uuid}' is not null) - or (c.props -> 'validateFns' is not null and c.props -> 'validateFns' ->> '${cycle.uuid}' is not null) - group by r.id, r.uuid, r.props, t.props ->> 'name'`, - [], - (row) => { - return { - ...Objects.camelize(row), - cols: row.cols.map((col: Col) => { - return { - ...Objects.camelize(col), - props: { - ...Objects.camelize(col.props), - calculateFn: col.props.calculateFn, - validateFns: col.props.validateFns, - }, - } - }), - props: { - ...Objects.camelize(row.props), - calculateFn: row.props.calculateFn, - linkToSection: row.props.linkToSection, - validateFns: row.props.validateFns, - chart: row.props.chart, - }, - } - } - ) - - rows.forEach(({ tableName, ...row }) => { - const context = { row, tableName, assessmentMetaCache } - if (row.props.calculateFn?.[cycle.uuid]) { - DependencyEvaluator.evalDependencies(row.props.calculateFn[cycle.uuid], { ...context, type: 'calculations' }) - } else { - row.cols.forEach((col) => { - if (col.props.calculateFn?.[cycle.uuid]) { - DependencyEvaluator.evalDependencies(col.props.calculateFn[cycle.uuid], { ...context, type: 'calculations' }) - } - }) - } - - if (row.props.validateFns?.[cycle.uuid]) { - row.props.validateFns[cycle.uuid].forEach((validateFn) => - DependencyEvaluator.evalDependencies(validateFn, { ...context, type: 'validations' }) - ) - } else { - row.cols.forEach((col) => { - if (col.props.validateFns?.[cycle.uuid]) { - col.props.validateFns?.[cycle.uuid].forEach((validateFn) => { - DependencyEvaluator.evalDependencies(validateFn, { ...context, type: 'validations' }) - }) - } - }) - } - }) - - return client.query( - ` - update assessment - set meta_cache = jsonb_set(meta_cache, '{${cycle.uuid}}', $1::jsonb) - where id = $2 - `, - [JSON.stringify(assessmentMetaCache), assessment.id] - ) -} diff --git a/tools/dataMigration/index.ts b/tools/dataMigration/index.ts deleted file mode 100644 index d18e39d75c..0000000000 --- a/tools/dataMigration/index.ts +++ /dev/null @@ -1,152 +0,0 @@ -import * as path from 'path' -import { config } from 'dotenv' - -import { FRA } from '../../.src.legacy/core/assessment' -import { Assessment as AssessmentLegacy } from '../../.src.legacy/core/assessment/assessment' -import { SectionSpec } from '../../.src.legacy/webapp/sectionSpec' -import { Assessment } from '../../src/meta/assessment/assessment' -import { Cycle } from '../../src/meta/assessment/cycle' -import { BaseProtocol, DB } from '../../src/server/db' -import { - getCreateSchemaCycleDDL, - getCreateSchemaDDL, -} from '../../src/server/repository/assessment/assessment/getCreateSchemaDDL' -import { FraSpecs } from '../../src/test/sectionSpec/fraSpecs' -import { migrateAggregates } from './migrateData/migrateAggregates' -import { migrateOdps } from './migrateData/migrateOdps' -import { migrateTablesData } from './migrateData/migrateTablesData' -import { DBNames } from './_DBNames' -import { generateMetaCache } from './generateMetaCache' -import { migrateActivityLog } from './migrateActivityLog' -import { migrateAreas } from './migrateAreas' -import { migrateMetadata } from './migrateMetadata' -import { migrateRepository } from './migrateRepository' -import { migrateReview } from './migrateReview' -import { migrateUsers } from './migrateUsers' -import { migrateUsersAuthProvider } from './migrateUsersAuthProvider' -import { migrateUsersInvitation } from './migrateUsersInvitation' -import { migrateUsersResetPassword } from './migrateUsersResetPassword' -import { migrateUsersRole } from './migrateUsersRole' - -config({ path: path.resolve(__dirname, '..', '..', '.env') }) - -const createCycle = async (assessment: Assessment, cycleName: string, client: BaseProtocol): Promise => { - await DB.query( - getCreateSchemaCycleDDL( - DBNames.getAssessmentSchema(assessment.props.name), - DBNames.getCycleSchema(assessment.props.name, cycleName) - ) - ) - - return client.one( - `insert into assessment_cycle (assessment_id, name) - values ($1, $2) - returning *`, - [assessment.id, cycleName] - ) -} - -export const migrate = async (props: { - assessmentName: string - assessmentLegacy: AssessmentLegacy - cycleNames: Array - spec: Record -}): Promise => { - const startTime = new Date() - const hhmmss = startTime.toLocaleTimeString('en-GB', { hour12: false }) - // eslint-disable-next-line no-console - console.log('========== START ', hhmmss) - const { assessmentName, assessmentLegacy, cycleNames, spec } = props - - // delete old assessment - await DB.query(`drop schema if exists ${DBNames.getAssessmentSchema(assessmentName)} cascade;`) - await Promise.all( - cycleNames.map((cycleName) => - DB.query(`drop schema if exists ${DBNames.getCycleSchema(assessmentName, cycleName)} cascade;`) - ) - ) - - await DB.query( - `delete - from assessment - where props ->> 'name' = $1`, - [assessmentName] - ) - - const client = DB - // await DB.tx(async (client) => { - // insert assessment - const assessment = await client.one( - `insert into assessment (props) - values ($1::jsonb) - returning *;`, - [JSON.stringify({ name: assessmentName })] - ) - - // create schema - const schema = DBNames.getAssessmentSchema(assessment.props.name) - await DB.query(getCreateSchemaDDL(schema)) - assessment.cycles = await Promise.all(cycleNames.map((cycleName) => createCycle(assessment, cycleName, client))) - - // Set fra/2020 to published - const defaultCycle = assessment.cycles.find((c) => c.name === '2020') - await client.query('update public.assessment_cycle set published = true where id = $1', [defaultCycle.id]) - await client.query('update public.assessment set props = $2:json::jsonb where id = $1', [ - assessment.id, - { - ...assessment.props, - defaultCycle: defaultCycle.uuid, - }, - ]) - - await migrateMetadata({ assessment, assessmentLegacy, spec, client }) - await migrateRepository({ assessment, client }) - - await Promise.all( - cycleNames.map((cycleName, index: number) => - migrateAreas({ client, schema: DBNames.getCycleSchema(assessment.props.name, cycleName), index }) - ) - ) - - await migrateUsers({ client }) - await migrateUsersAuthProvider({ client }) - await migrateUsersRole({ assessment, client }) - await migrateUsersInvitation({ client }) - await migrateUsersResetPassword({ client }) - await Promise.all( - assessment.cycles.map(async (cycle) => { - await migrateTablesData({ assessment, cycle }, client) - await generateMetaCache({ assessment, cycle }, client) - }) - ) - await migrateOdps({ assessment }, client) - await migrateAggregates({ assessment }, client) - await migrateReview({ assessment }, client) - await migrateActivityLog({ assessment }, client) - - await client.query( - `delete - from settings; - insert into settings (default_assessment_id) - values ($1)`, - [assessment.id] - ) - const endTime = new Date() - const totalTime = endTime.getTime() - startTime.getTime() - // eslint-disable-next-line no-console - console.log('========== END ', endTime.toLocaleTimeString('en-GB', { hour12: false }), ' - ', totalTime / 1000, 's') - // }) -} - -const assessmentName = 'fra' -const cycleNames = ['2020', '2025'] - -migrate({ assessmentName, cycleNames, spec: FraSpecs, assessmentLegacy: FRA }) - .then(() => { - process.exit(0) - }) - .catch((e) => { - // eslint-disable-next-line no-console - console.error(e) - process.exit(1) - }) diff --git a/tools/dataMigration/migrateActivityLog.ts b/tools/dataMigration/migrateActivityLog.ts deleted file mode 100644 index 8ae68cd077..0000000000 --- a/tools/dataMigration/migrateActivityLog.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { Cycle } from '../../src/meta/assessment' -import { Assessment } from '../../src/meta/assessment/assessment' -import { BaseProtocol } from '../../src/server/db' - -export const migrateActivityLog = async (props: { assessment: Assessment }, client: BaseProtocol): Promise => { - const { assessment } = props - - const cycle = assessment.cycles.find((cycle: Cycle) => cycle.name === '2020') - - const query = ` - insert into public.activity_log ( - time, message, country_iso, section, target, user_id, assessment_uuid, cycle_uuid - ) - select time, - case - when message = 'acceptInvitation' then 'invitationAccept' - when message = 'addInvitation' then 'invitationAdd' - when message = 'createComment' then 'messageCreate' - when message = 'createIssue' then 'messageCreate' - when message = 'createOdp' then 'originalDataPointCreate' - when message = 'deleteComment' then 'messageMarkDeleted' - when message = 'deleteOdp' then 'originalDataPointRemove' - when message = 'fileRepositoryDelete' then 'assessmentFileDelete' - when message = 'fileRepositoryUpload' then 'assessmentFileCreate' - when message = 'markAsResolved' then 'topicStatusChange' - when message = 'saveDescriptions' then 'descriptionUpdate' - when message = 'saveTraditionalTable' then 'nodeValueUpdate' - when message = 'updateAssessmentStatus' then 'assessmentStatusUpdate' - when message = 'generateFraValues' then 'nodeValueEstimate' - when message = 'removeInvitation' then 'invitationRemove' - when message = 'removeUser' then 'userRemove' - when message = 'updateUser' then 'userUpdate' - when message = 'saveFraValues' then 'originalDataPointUpdate' - when message = 'persistGrowingStockValues' then 'nodeValueUpdate' - else message - end - as "message", - country_iso, - section, - target, - u.id, - '${assessment.uuid}' as assessment_uuid, - '${cycle.uuid}' as cycle_uuid - from _legacy.fra_audit a - join public.users u on (user_email = email) - where a.message in ('acceptInvitation', - 'addInvitation', - 'createComment', - 'createIssue', - 'createOdp', - 'deleteComment', - 'deleteOdp', - 'fileRepositoryDelete', - 'fileRepositoryUpload', - 'markAsResolved', - 'saveDescriptions', - 'saveTraditionalTable', - 'updateAssessmentStatus', - 'generateFraValues', - 'removeInvitation', - 'removeUser', - 'updateUser', - 'saveFraValues', - 'persistGrowingStockValues' - );` - - await client.query(query) -} diff --git a/tools/dataMigration/migrateAreas.ts b/tools/dataMigration/migrateAreas.ts deleted file mode 100644 index 38f0a67997..0000000000 --- a/tools/dataMigration/migrateAreas.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { BaseProtocol } from '../../src/server/db' - -type Props = { - client: BaseProtocol - schema: string - index: number -} - -export const migrateAreas = async (props: Props): Promise => { - const { client, schema, index } = props - const isPanEuropean = schema.includes('paneuropean') - const countryCondition = `cr.region_code ${isPanEuropean ? '=' : '!='} 'FE'` - - await client.query(` - insert into ${schema}.country (country_iso, props) - select c.country_iso, - c.config || jsonb_build_object( - 'status', ${index === 0 ? 'a.status' : `'editing'`}, - 'desk_study', ${index === 0 ? 'a.desk_study' : false}, - 'forestCharacteristics', - jsonb_build_object('useOriginalDataPoint', (dcc.config ->> 'useOriginalDataPointsInFoc')::boolean) - ) as props - from public.country c - left join _legacy.assessment a on (c.country_iso = a.country_iso) - left join _legacy.dynamic_country_configuration dcc on (c.country_iso = dcc.country_iso) - ${ - isPanEuropean - ? ` - left join _legacy.country_region cr on (c.country_iso = cr.country_iso) - where ${countryCondition} - ` - : '' - } - order by country_iso; - `) - - await client.query(` - insert into ${schema}.country_region (country_iso, region_code) - select cr.country_iso, cr.region_code - from _legacy.country_region cr - where ${countryCondition} - `) - - await client.query(` - insert into ${schema}.region_group (name, "order") - select name, "order" - from _legacy.region_group - order by "order"; - `) - - await client.query(` - insert into ${schema}.region (region_code, region_group_id) - select cr.region_code, - rg.id as region_group_id - from region cr - left join _legacy.region r_l - on cr.region_code = r_l.region_code - left join _legacy.region_group rg_l on r_l.region_group = rg_l.id - left join ${schema}.region_group rg on rg_l.name = rg.name - where ${countryCondition} - order by cr.region_code; - `) -} diff --git a/tools/dataMigration/migrateData/_createDataViews.ts b/tools/dataMigration/migrateData/_createDataViews.ts deleted file mode 100644 index ecf1480720..0000000000 --- a/tools/dataMigration/migrateData/_createDataViews.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { Assessment } from '../../../src/meta/assessment/assessment' -import { Col } from '../../../src/meta/assessment/col' -import { Cycle } from '../../../src/meta/assessment/cycle' -import { Table, TableNames } from '../../../src/meta/assessment/table' -import { BaseProtocol, Tables } from '../../../src/server/db' -import { DBNames } from '../_DBNames' -import { getCols } from './_repos' - -const getColLinkedNodeUnion = (props: { col: Col & { variableName?: string }; cycle: Cycle }): string => { - const { col, cycle } = props - const { assessmentName, cycleName, tableName, variableName, colName } = col.props.linkedNodes[cycle.uuid] - - const viewName = [TableNames.extentOfForest, TableNames.forestCharacteristics].includes(tableName as TableNames) - ? Tables.getTableDataWithOdpViewName({ tableName }) - : tableName - - return ` - union - select e.country_iso - , '${col.variableName}' as variable_name - , '${col.props.colName}' as col_name - , e.value - from ${DBNames.getCycleSchema(assessmentName, cycleName)}.${viewName} e - where e.col_name = '${colName}' - and e.variable_name = '${variableName}' - ` -} - -export const getCreateViewDDL = async ( - props: { - assessment: Assessment - cycle: Cycle - table: Table - }, - client: BaseProtocol -): Promise => { - const { assessment, cycle, table } = props - - const schema = DBNames.getAssessmentSchema(assessment.props.name) - const schemaCycle = DBNames.getCycleSchema(assessment.props.name, cycle.name) - - const cols = await getCols(client, schema, table) - const colsLinkedNodes = cols.filter((col) => Boolean(col.props.linkedNodes?.[cycle.uuid])) - - const query = ` - create or replace view ${schemaCycle}.${table.props.name} as - ( - select n.country_iso, - r.props ->> 'variableName' as variable_name, - c.props ->> 'colName' as col_name, - n.value - from ${schemaCycle}.node n - left join ${schema}.row r - on r.uuid = n.row_uuid - left join ${schema}.col c - on c.uuid = n.col_uuid - left join ${schema}."table" t - on t.id = r.table_id - where t.props ->> 'name' = '${table.props.name}' - and r.props ->> 'type' in ('data', 'calculated') - -- ======= exclude linked node from view generation - and c.props -> 'linkedNodes' -> '${cycle.uuid}' is null - ${ - colsLinkedNodes.length - ? `${colsLinkedNodes.map((col) => getColLinkedNodeUnion({ col, cycle })).join(` - `)}` - : '' - } - order by 1, 2, 3 - - ); - ` - - return query -} diff --git a/tools/dataMigration/migrateData/_getNodeInserts.ts b/tools/dataMigration/migrateData/_getNodeInserts.ts deleted file mode 100644 index a5bb3dfecd..0000000000 --- a/tools/dataMigration/migrateData/_getNodeInserts.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { Assessment } from '../../../src/meta/assessment/assessment' -import { Col } from '../../../src/meta/assessment/col' -import { Cycle } from '../../../src/meta/assessment/cycle' -import { NodeValue } from '../../../src/meta/assessment/node' -import { RowType } from '../../../src/meta/assessment/row' -import { Table } from '../../../src/meta/assessment/table' -import { BaseProtocol } from '../../../src/server/db' -import { DBNames } from '../_DBNames' -import * as sqlCreator from '../dataTable/dataTableSqlCreator' -import { getCols, getRows } from './_repos' - -const columnsSwap: Record = { - unspecified_mixed_damage_2025: 'unspecified_mixed_damage', -} - -// eslint-disable-next-line camelcase -export type NodeRow = { country_iso: string; row_uuid: string; col_uuid: string; value: NodeValue } - -export interface DatumLegacy extends Record { - // eslint-disable-next-line camelcase - country_iso: string - // eslint-disable-next-line camelcase - row_name: string -} - -export const _getNodeInserts = async ( - props: { - assessment: Assessment - cycle: Cycle - countryISOs: Array - table: Table - legacySchema: string - }, - client: BaseProtocol -): Promise> => { - const { assessment, cycle, countryISOs, table, legacySchema } = props - const schema = DBNames.getAssessmentSchema(assessment.props.name) - const rows = await getRows(client, schema, table) - const cols = await getCols(client, schema, table) - const rowsData = rows.filter((row) => row.props.type === RowType.data) - // const colIndexes = getColIndexes(rowsData, cols) - const { name: tableName, columnNames } = table.props - - const values: Array = [] - await Promise.all( - countryISOs.map(async (countryIso) => { - const [selectQuery, selectParams] = sqlCreator.createSelect(countryIso, tableName, legacySchema) - let data = (await client.manyOrNone(selectQuery, selectParams)) as Array - if (data.length === 0) data = [] - - rowsData.forEach((row) => { - const rowName = row.props.variableName - columnNames[cycle.uuid].forEach((colName) => { - const col: Col = cols.find((c) => c.rowId === row.id && c.props.colName === colName) - const dataRow = data.find((d) => d.row_name === rowName) - if (dataRow && col) { - const datum = dataRow[columnsSwap[col.props.colName] ?? col.props.colName] - values.push({ - country_iso: countryIso, - col_uuid: col.uuid, - row_uuid: row.uuid, - value: { raw: datum ? String(datum) : null }, - }) - } - }) - }) - }) - ) - - return values -} diff --git a/tools/dataMigration/migrateData/_getNodeInsertsDegradedForest.ts b/tools/dataMigration/migrateData/_getNodeInsertsDegradedForest.ts deleted file mode 100644 index 9119b3333d..0000000000 --- a/tools/dataMigration/migrateData/_getNodeInsertsDegradedForest.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { Assessment } from '../../../src/meta/assessment/assessment' -import { Col } from '../../../src/meta/assessment/col' -import { Cycle } from '../../../src/meta/assessment/cycle' -import { RowType } from '../../../src/meta/assessment/row' -import { Table } from '../../../src/meta/assessment/table' -import { BaseProtocol } from '../../../src/server/db' -import { DBNames } from '../_DBNames' -import * as sqlCreator from '../dataTable/dataTableSqlCreator' -import { getMapping } from '../dataTable/tableMappings' -import { DatumLegacy, NodeRow } from './_getNodeInserts' -import { getCols, getRows } from './_repos' - -export const _getNodeInsertsDegradedForest = async ( - props: { - assessment: Assessment - cycle: Cycle - countryISOs: Array - table: Table - }, - client: BaseProtocol -): Promise> => { - const { assessment, cycle, countryISOs, table } = props - const schema = DBNames.getAssessmentSchema(assessment.props.name) - const mapping = getMapping(table.props.name) - const rows = await getRows(client, schema, table) - const cols = await getCols(client, schema, table) - const rowsData = rows.filter((row) => row.props.type === RowType.data) - // const colIndexes = getColIndexes(rowsData, cols) - const { name: tableName, columnNames } = table.props - - const values: Array = [] - await Promise.all( - countryISOs.map(async (countryIso) => { - const [selectQuery, selectParams] = sqlCreator.createSelect(countryIso, tableName, '_legacy') - let data = (await client.manyOrNone(selectQuery, selectParams)) as Array - if (data.length === 0) data = [] - - rowsData.forEach((row) => { - const rowName = row.props.variableName - columnNames[cycle.uuid].forEach((colName, colIndex) => { - const col: Col = cols.find((c) => c.rowId === row.id && c.props.colName === colName) - const dataRow = data.find((d) => d.row_name === rowName) - if (dataRow && col) { - const columnMapping = mapping.columns[rowName === 'national_definition' ? 1 : colIndex] - const datum = dataRow[columnMapping.name] - values.push({ - country_iso: countryIso, - col_uuid: col.uuid, - row_uuid: row.uuid, - value: { raw: datum ? String(datum) : null }, - }) - } - }) - }) - }) - ) - return values -} diff --git a/tools/dataMigration/migrateData/_repos.ts b/tools/dataMigration/migrateData/_repos.ts deleted file mode 100644 index a0a2839c62..0000000000 --- a/tools/dataMigration/migrateData/_repos.ts +++ /dev/null @@ -1,150 +0,0 @@ -import { AssessmentNames } from '../../../src/meta/assessment/assessmentName' -import { Col, ColType } from '../../../src/meta/assessment/col' -import { Row, RowType } from '../../../src/meta/assessment/row' -import { Table } from '../../../src/meta/assessment/table' -import { BaseProtocol } from '../../../src/server/db' -import { Objects } from '../../../src/utils/objects' - -export const getRows = (client: BaseProtocol, schema: string, table: Table): Promise> => - client.map( - `select * - from ${schema}.row - where table_id = $1 - and props ->> 'type' in ('${RowType.data}', '${RowType.calculated}');`, - [table.id], - (row) => { - return { - ...Objects.camelize(row), - props: { - ...Objects.camelize(row.props), - calculateFn: row.props.calculateFn, - linkToSection: row.props.linkToSection, - validateFns: row.props.validateFns, - chart: row.props.chart, - }, - } - } - ) - -export const getCols = (client: BaseProtocol, schema: string, table: Table): Promise> => - client.map( - `select c.*,r.props->>'variableName' as variable_name - from ${schema}.col c - left join ${schema}.row r - on c.row_id = r.id - where r.table_id = $1 - and c.props ->> 'colType' not in ('${ColType.header}', '${ColType.noticeMessage}')`, - [table.id], - (col) => { - return { - ...Objects.camelize(col), - props: { - ...Objects.camelize(col.props), - calculateFn: col.props.calculateFn, - linkedNodes: col.props.linkedNodes, - validateFns: col.props.validateFns, - }, - } - } - ) - -export const skipPanEuropean = (tableName: string, cycleName: string, assessmentName: string): boolean => { - if (tableName === 'table_2_5' && cycleName === '2025' && assessmentName === AssessmentNames.panEuropean) { - return false - } - return true -} - -export const isBasicTable = (tableName: string): boolean => - tableName && - tableName.trim() !== '' && - ![ - 'extentOfForest_forestAreaStatusAndTrend', - 'extentOfForest_forestAreaStatusAndTrend_Description', - 'biomassStock_biomassStockStatus', - 'biomassStock_biomassStockStatus_Description', - 'growingStock_growingStockStatus', - 'growingStock_growingStockStatus_Description', - 'contactPersons', - 'extentOfForest', - 'forestCharacteristics', - 'growingStockAvg', - 'growingStockTotal', - 'degradedForest', - 'degradedForest2025', - 'degradedForestMonitoring2025', - 'sustainableDevelopment15_1_1', - 'sustainableDevelopment15_2_1_1', - 'sustainableDevelopment15_2_1_2', - 'sustainableDevelopment15_2_1_3', - 'sustainableDevelopment15_2_1_4', - 'sustainableDevelopment15_2_1_5', - 'primaryForestByClimaticDomain', - 'growingStockComposition2025', - 'forestRestoration', - 'biomassStockAvg', - 'biomassStockTotal', - 'carbonStockAvg', - 'carbonStockTotal', - 'country_comments_1_1_1', - 'country_comments_1_1_2', - 'country_comments_1_1_3', - 'country_comments_1_2_1', - 'country_comments_1_2_2', - 'country_comments_1_2_3', - 'country_comments_1_3a_1', - 'country_comments_1_3a_2', - 'country_comments_1_3a_3', - 'country_comments_1_3b_1', - 'country_comments_1_3b_2', - 'country_comments_1_4_1', - 'country_comments_1_4_2', - 'country_comments_2_4_1', - 'country_comments_2_4_2', - 'country_comments_2_5_1', - 'country_comments_2_5_2', - 'country_comments_3_1_1', - 'country_comments_3_1_2', - 'country_comments_3_2_1', - 'country_comments_3_2_2', - 'country_comments_3_3_1', - 'country_comments_3_4_1', - 'country_comments_3_4_2', - 'country_comments_4_1_1', - 'country_comments_4_1_2', - 'country_comments_4_2_1', - 'country_comments_4_2_2', - 'country_comments_4_3_1', - 'country_comments_4_3_2', - 'country_comments_4_3_3', - 'country_comments_4_4_1', - 'country_comments_4_4_2', - 'country_comments_4_4_3', - 'country_comments_4_5_1', - 'country_comments_4_5_2', - 'country_comments_4_8_1', - 'country_comments_4_8_2', - 'country_comments_4_9_1', - 'country_comments_4_9_2', - 'country_comments_5_1_1', - 'country_comments_5_1_2', - 'country_comments_6_1_1', - 'country_comments_6_1_2', - 'country_comments_6_2_1', - 'country_comments_6_3_1', - 'country_comments_6_4_1', - 'country_comments_6_5_1', - 'country_comments_6_5_2', - 'country_comments_6_6_1', - 'country_comments_6_6_2', - 'country_comments_6_9_1', - 'country_comments_6_9_2', - 'country_comments_6_10_1', - 'country_comments_6_10_2', - 'reasonability_check_3_1', - 'reasonability_check_3_2', - 'reasonability_check_1_2', - 'reasonability_check_1_4', - 'reasonability_check_4_5', - 'reasonability_check_2_4', - ].includes(tableName) diff --git a/tools/dataMigration/migrateData/getNodeInsertsTableWithODP.ts b/tools/dataMigration/migrateData/getNodeInsertsTableWithODP.ts deleted file mode 100644 index 235f400822..0000000000 --- a/tools/dataMigration/migrateData/getNodeInsertsTableWithODP.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { Assessment } from '../../../src/meta/assessment/assessment' -import { NodeValue } from '../../../src/meta/assessment/node' -import { Table } from '../../../src/meta/assessment/table' -import { BaseProtocol } from '../../../src/server/db' -import { Objects } from '../../../src/utils/objects' -import { DBNames } from '../_DBNames' -import { NodeRow } from './_getNodeInserts' -import { getCols, getRows } from './_repos' - -export const getNodeInsertsTableWithODP = async ( - props: { - assessment: Assessment - table: Table - variables: Array - tableNameLegacy: string - estimated?: boolean - }, - client: BaseProtocol -): Promise> => { - const { assessment, table, variables, tableNameLegacy, estimated } = props - const schema = DBNames.getAssessmentSchema(assessment.props.name) - const rows = await getRows(client, schema, table) - const cols = await getCols(client, schema, table) - - const valuesLegacy = await client.map( - `select * - from _legacy.${tableNameLegacy}`, - [], - // @ts-ignore - Objects.camelize - ) - - const values: Array = [] - - valuesLegacy.forEach((valueLegacy) => { - variables.forEach((variable) => { - const row = rows.find((row) => row.props.variableName === variable) - const col = cols.find((col) => col.rowId === row.id && col.props.colName === String(valueLegacy.year)) - - const value: NodeValue = { raw: valueLegacy[variable] ? String(valueLegacy[variable]) : undefined } - if (estimated) value.estimated = valueLegacy[`${variable}Estimated`] - - values.push({ - country_iso: valueLegacy.countryIso, - col_uuid: col.uuid, - row_uuid: row.uuid, - value, - }) - }) - }) - - return values -} diff --git a/tools/dataMigration/migrateData/migrateAggregates.ts b/tools/dataMigration/migrateData/migrateAggregates.ts deleted file mode 100644 index fbfd2c3ec4..0000000000 --- a/tools/dataMigration/migrateData/migrateAggregates.ts +++ /dev/null @@ -1,37 +0,0 @@ -import * as pgPromise from 'pg-promise' - -import { Assessment } from '../../../src/meta/assessment/assessment' -import { BaseProtocol } from '../../../src/server/db' -import { DBNames } from '../_DBNames' - -export const migrateAggregates = async (props: { assessment: Assessment }, client: BaseProtocol): Promise => { - const { assessment } = props - const pgp = pgPromise() - - const queries = assessment.cycles.map((cycle) => { - const schemaCycle = DBNames.getCycleSchema(assessment.props.name, cycle.name) - return ` - - insert into ${schemaCycle}.value_aggregate - select country_iso, - case - when row_name = 'forest_area' then 'forestArea' - when row_name = 'land_area' then 'totalLandArea' - when row_name = 'natural_forest_area' then 'naturalForestArea' - when row_name = 'planted_forest' then 'plantedForest' - else row_name end - as variable_name, - unnest(array ['1990', '2000', '2010','2015','2020']) as col_name, - unnest(array [ - jsonb_build_object('raw', "1990"::text), - jsonb_build_object('raw', "2000"::text), - jsonb_build_object('raw', "2010"::text), - jsonb_build_object('raw', "2015"::text), - jsonb_build_object('raw', "2020"::text) - ]) as value - from _legacy.country_aggregate - order by 1, 2, 3; - ` - }) - await client.query(pgp.helpers.concat(queries)) -} diff --git a/tools/dataMigration/migrateData/migrateFRATablesData.ts b/tools/dataMigration/migrateData/migrateFRATablesData.ts deleted file mode 100644 index df481f8747..0000000000 --- a/tools/dataMigration/migrateData/migrateFRATablesData.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { Assessment, Cycle } from '../../../src/meta/assessment' -import { Table } from '../../../src/meta/assessment/table' -import { BaseProtocol } from '../../../src/server/db' -import { _getNodeInsertsDegradedForest } from './_getNodeInsertsDegradedForest' -import { getNodeInsertsTableWithODP } from './getNodeInsertsTableWithODP' - -export const migrateFRATablesData = async ( - props: { assessment: Assessment; cycle: Cycle; countryISOs: string[]; tables: Table[]; values: any[] }, - client: BaseProtocol -): Promise => { - const { assessment, cycle, countryISOs, tables, values } = props - - const tableDegradedForest = tables.find((t) => t.props.name === 'degradedForest') - const tableExtentOfForest = tables.find((t) => t.props.name === 'extentOfForest') - const tableForestCharacteristics = tables.find((t) => t.props.name === 'forestCharacteristics') - const tableGrowingStockAvg = tables.find((t) => t.props.name === 'growingStockAvg') - const tableGrowingStockTotal = tables.find((t) => t.props.name === 'growingStockTotal') - - // non-basic tables insert - if (cycle.name === '2020') - values.push( - ...(await _getNodeInsertsDegradedForest({ assessment, cycle, countryISOs, table: tableDegradedForest }, client)) - ) - values.push( - ...(await getNodeInsertsTableWithODP( - { - assessment, - table: tableExtentOfForest, - tableNameLegacy: 'eof_fra_values', - variables: ['forestArea', 'otherWoodedLand'], - estimated: true, - }, - client - )) - ) - values.push( - ...(await getNodeInsertsTableWithODP( - { - assessment, - table: tableForestCharacteristics, - tableNameLegacy: 'foc_fra_values', - variables: [ - 'naturalForestArea', - 'plantationForestArea', - 'plantationForestIntroducedArea', - 'otherPlantedForestArea', - ], - estimated: true, - }, - client - )) - ) - - values.push( - ...(await getNodeInsertsTableWithODP( - { - assessment, - table: tableGrowingStockAvg, - tableNameLegacy: 'growing_stock_avg', - variables: [ - 'naturallyRegeneratingForest', - 'plantationForest', - 'otherPlantedForest', - 'otherWoodedLand', - 'plantedForest', - 'forest', - ], - }, - client - )) - ) - values.push( - ...(await getNodeInsertsTableWithODP( - { - assessment, - table: tableGrowingStockTotal, - tableNameLegacy: 'growing_stock_total', - variables: [ - 'naturallyRegeneratingForest', - 'plantationForest', - 'otherPlantedForest', - 'otherWoodedLand', - 'plantedForest', - 'forest', - ], - }, - client - )) - ) -} diff --git a/tools/dataMigration/migrateData/migrateOdps.ts b/tools/dataMigration/migrateData/migrateOdps.ts deleted file mode 100644 index fe7a87b109..0000000000 --- a/tools/dataMigration/migrateData/migrateOdps.ts +++ /dev/null @@ -1,42 +0,0 @@ -import * as pgPromise from 'pg-promise' - -import { Assessment } from '../../../src/meta/assessment/assessment' -import { BaseProtocol } from '../../../src/server/db' -import { getCreateSchemaCycleOriginalDataPointViewDDL } from '../../../src/server/repository/assessment/assessment/getCreateSchemaDDL' -import { DBNames } from '../_DBNames' - -export const migrateOdps = async (props: { assessment: Assessment }, client: BaseProtocol): Promise => { - const { assessment } = props - const pgp = pgPromise() - - const queries = assessment.cycles.map((cycle) => { - const schemaCycle = DBNames.getCycleSchema(assessment.props.name, cycle.name) - return ` - insert into ${schemaCycle}.original_data_point (id, - country_iso, - year, - data_source_additional_comments, - data_source_methods, - data_source_references, - description, - national_classes, - id_legacy - ) - select id, - country_iso, - year, - data_source_additional_comments, - data_source_methods, - data_source_references, - description, - national_classes, - id_legacy - from _legacy.original_data_point - where year is not null; - select setval('${schemaCycle}.original_data_point_id_seq', (select max(id) from _legacy.original_data_point), true); - - ${getCreateSchemaCycleOriginalDataPointViewDDL(schemaCycle)} - ` - }) - await client.query(pgp.helpers.concat(queries)) -} diff --git a/tools/dataMigration/migrateData/migrateTablesData.ts b/tools/dataMigration/migrateData/migrateTablesData.ts deleted file mode 100644 index 8346e99fe3..0000000000 --- a/tools/dataMigration/migrateData/migrateTablesData.ts +++ /dev/null @@ -1,74 +0,0 @@ -import * as pgPromise from 'pg-promise' - -import { Assessment } from '../../../src/meta/assessment/assessment' -import { Cycle } from '../../../src/meta/assessment/cycle' -import { Table } from '../../../src/meta/assessment/table' -import { BaseProtocol } from '../../../src/server/db' -import { Objects } from '../../../src/utils/objects' -import { DBNames } from '../_DBNames' -import { getCreateViewDDL } from './_createDataViews' -import { _getNodeInserts } from './_getNodeInserts' -// import { _getNodeInsertsDegradedForest } from './_getNodeInsertsDegradedForest' -import { isBasicTable, skipPanEuropean } from './_repos' -import { migrateFRATablesData } from './migrateFRATablesData' -// import { getNodeInsertsTableWithODP } from './getNodeInsertsTableWithODP' - -export const migrateTablesData = async ( - props: { assessment: Assessment; cycle: Cycle }, - client: BaseProtocol, - legacySchema = '_legacy' -): Promise => { - const { assessment, cycle } = props - const schema = DBNames.getAssessmentSchema(assessment.props.name) - - const countryISOs = await client.map( - ` - select * - from public.country`, - [], - (o) => o.country_iso - ) - - const tables = await client.map( - `select t.* - from ${schema}."table" t - where t.props -> 'cycles' ? '${cycle.uuid}' - order by t.id`, - [], - // @ts-ignore - (table) => { - const { props, ...rest } = table - return { - ...Objects.camelize(rest), - props, - } - } - ) - - // get node insert values - const values = ( - await Promise.all( - tables - .filter((table) => isBasicTable(table.props.name)) - .filter((table) => skipPanEuropean(table.props.name, cycle.name, assessment.props.name)) - .map(async (table) => _getNodeInserts({ assessment, cycle, countryISOs, table, legacySchema }, client)) - ) - ).flat() - - if (!schema.includes('paneuropean')) { - await migrateFRATablesData({ assessment, cycle, countryISOs, tables, values }, client) - } - - // insert nodes - const schemaCycle = DBNames.getCycleSchema(assessment.props.name, cycle.name) - const pgp = pgPromise() - const cs = new pgp.helpers.ColumnSet(['country_iso', 'row_uuid', 'col_uuid', { name: 'value', cast: 'jsonb' }], { - table: { table: 'node', schema: schemaCycle }, - }) - const query = pgp.helpers.insert(values, cs) - await client.none(query) - // create data views - const queries = await Promise.all(tables.map((table) => getCreateViewDDL({ assessment, cycle, table }, client))) - - await client.query(pgp.helpers.concat(queries)) -} diff --git a/tools/dataMigration/migrateMetadata/getCol.ts b/tools/dataMigration/migrateMetadata/getCol.ts deleted file mode 100644 index 08958c5454..0000000000 --- a/tools/dataMigration/migrateMetadata/getCol.ts +++ /dev/null @@ -1,129 +0,0 @@ -import { Assessment, Col, ColLinkedNode, ColStyle, ColType, CycleUuid, Label, Row } from '../../../src/meta/assessment' -import { ColSpec } from '../../../src/test/sectionSpec' -import { getCycleUuids, getLabels } from './utils' - -const _getCalculateFn = (colSpec: ColSpec, cycles: string[], assessment: Assessment): Record => { - const calculateFn = colSpec.migration?.calculateFn - - if (!calculateFn) return undefined - - if (typeof calculateFn === 'string') { - return cycles.reduce>((calcFnAgg, cycle) => ({ ...calcFnAgg, [cycle]: calculateFn }), {}) - } - - return Object.entries(calculateFn).reduce>( - (acc, [cycleName, _calculateFn]) => ({ - ...acc, - [assessment.cycles.find((c) => c.name === cycleName).uuid]: _calculateFn, - }), - {} - ) -} - -// Return validateFns prop in format Record> -const _getValidateFns = (colSpec: ColSpec, cycles: string[], assessment: Assessment): Record> => { - const validateFns = colSpec.migration?.validateFns - - if (!validateFns) return undefined - - if (Array.isArray(validateFns)) { - return cycles.reduce>>( - (valiteFnsAgg, cycle) => ({ ...valiteFnsAgg, [cycle]: validateFns }), - {} - ) - } - - return Object.entries(validateFns).reduce>>( - (acc, [cycleName, _validateFns]) => ({ - ...acc, - [assessment.cycles.find((c) => c.name === cycleName).uuid]: _validateFns, - }), - {} - ) -} - -export const getCol = (props: { - assessment: Assessment - colSpec: ColSpec - row: Row -}): Col & { forceColName?: boolean } => { - const { assessment, colSpec, row } = props - const cycles = getCycleUuids({ assessment, migration: colSpec.migration, parentCycleUuids: row.props.cycles }) - const style = cycles.reduce>( - (styleAgg, cycle) => ({ - ...styleAgg, - [cycle]: colSpec.migration?.style - ? colSpec.migration.style[assessment.cycles.find((c) => c.uuid === cycle).name] - : { colSpan: colSpec.colSpan, rowSpan: colSpec.rowSpan }, - }), - {} - ) - let variableNo - if (colSpec.migration?.variableNo) { - variableNo = Object.entries(colSpec.migration.variableNo).reduce>( - (acc, [cycleName, varNo]) => ({ ...acc, [assessment.cycles.find((c) => c.name === cycleName).uuid]: varNo }), - {} - ) - } else if (colSpec.variableNo) { - variableNo = cycles.reduce>( - (styleAgg, cycle) => ({ ...styleAgg, [cycle]: colSpec.variableNo }), - {} - ) - } - - let linkedNodes - if (colSpec.migration?.linkedNodes) { - linkedNodes = Object.entries(colSpec.migration.linkedNodes).reduce>( - (acc, [cycleName, linkedNode]) => ({ - ...acc, - [assessment.cycles.find((c) => c.name === cycleName).uuid]: linkedNode, - }), - {} - ) - } - - const col: Col & { forceColName?: boolean } = { - props: { - cycles, - colType: colSpec.type as unknown as ColType, - index: colSpec.idx, - colName: colSpec.colName, - variableNo, - calculateFn: _getCalculateFn(colSpec, cycles, assessment), - validateFns: _getValidateFns(colSpec, cycles, assessment), - style, - classNames: {}, - inputPlaceholder: colSpec.inputPlaceholder, - linkedNodes, - }, - rowId: row.id, - } - - // label migration - const colSpecLabel = colSpec.label ? String(colSpec.label) : undefined - if (colSpecLabel || colSpec.labelKey || colSpec.labelParams || colSpec.labelPrefixKey || colSpec.migration?.label) { - const label: Label = { - key: colSpec.labelKey, - params: colSpec.labelParams, - label: colSpecLabel, - prefixKey: colSpec.labelPrefixKey, - } - col.props.labels = getLabels({ assessment, label, migration: colSpec.migration }) - } - - // select/multiselect migration - if (colSpec.options) { - col.props.select = { - labelKeyPrefix: colSpec.optionsLabelKeyPrefix, - options: colSpec.options.map((o) => ({ - name: o.optionName, - hidden: o.hidden, - type: o.type === 'header' ? 'header' : undefined, - })), - } - } - if (colSpec.migration?.forceColName) { - col.forceColName = colSpec.migration.forceColName - } - return col -} diff --git a/tools/dataMigration/migrateMetadata/getRow.ts b/tools/dataMigration/migrateMetadata/getRow.ts deleted file mode 100644 index 2da7f44565..0000000000 --- a/tools/dataMigration/migrateMetadata/getRow.ts +++ /dev/null @@ -1,105 +0,0 @@ -import { Assessment, Row, RowType, Table } from '../../../src/meta/assessment' -import { ChartProps } from '../../../src/meta/assessment/row' -import { RowSpec } from '../../../src/test/sectionSpec' -import { getCycleUuids } from './utils' - -// Return calculateFn prop in format Record -const _getCalculateFn = (rowSpec: RowSpec, cycles: string[], assessment: Assessment): Record => { - const calculateFn = rowSpec.migration?.calcFormula - - if (!calculateFn) return undefined - - if (typeof calculateFn === 'string') { - return cycles.reduce>((calcFnAgg, cycle) => ({ ...calcFnAgg, [cycle]: calculateFn }), {}) - } - - return Object.entries(calculateFn).reduce>( - (acc, [cycleName, _calculateFn]) => ({ - ...acc, - [assessment.cycles.find((c) => c.name === cycleName).uuid]: _calculateFn, - }), - {} - ) -} - -// Return validateFns prop in format Record> -const _getValidateFns = (rowSpec: RowSpec, cycles: string[], assessment: Assessment): Record> => { - const validateFns = rowSpec.migration?.validateFns - - if (!validateFns) return undefined - - if (Array.isArray(validateFns)) { - return cycles.reduce>>( - (valiteFnsAgg, cycle) => ({ ...valiteFnsAgg, [cycle]: validateFns }), - {} - ) - } - - return Object.entries(validateFns).reduce>>( - (acc, [cycleName, _validateFns]) => ({ - ...acc, - [assessment.cycles.find((c) => c.name === cycleName).uuid]: _validateFns, - }), - {} - ) -} - -// Return chartProps prop in format Record -const _getChartProps = (rowSpec: RowSpec, assessment: Assessment): Record => { - const { chartProps } = rowSpec - - if (Array.isArray(rowSpec.migration?.chart?.cycles)) { - const cycles = rowSpec.migration?.chart?.cycles.map( - (cycleName) => assessment.cycles.find((c) => c.name === cycleName).uuid - ) - return cycles?.reduce>( - (chartPropsAgg, cycle) => ({ ...chartPropsAgg, [cycle]: chartProps }), - {} - ) - } - - return assessment.cycles.reduce>( - (chartPropsAgg, cycle) => ({ ...chartPropsAgg, [cycle.uuid]: chartProps }), - {} - ) -} - -export const getRow = (props: { assessment: Assessment; rowSpec: RowSpec; table: Table }): Row => { - const { assessment, rowSpec, table } = props - // const linkToSection = rowSpec.cols?.[0]?.linkToSection - const cycles = getCycleUuids({ assessment, parentCycleUuids: table.props.cycles, migration: rowSpec.migration }) - - const row: Row = { - props: { - cycles, - index: rowSpec.idx, - // linkToSection, - type: rowSpec.type as unknown as RowType, - variableName: rowSpec.variableName ?? rowSpec.variableExport, - calculateFn: _getCalculateFn(rowSpec, cycles, assessment), - readonly: rowSpec.migration?.readonly, - validateFns: _getValidateFns(rowSpec, cycles, assessment), - dependantsExclude: rowSpec.migration?.dependantsExclude, - categoryLevel: rowSpec.migration?.categoryLevel, - }, - cols: [], - tableId: table.id, - } - if (rowSpec.chartProps) { - row.props.chart = _getChartProps(rowSpec, assessment) - } - - if (rowSpec.labelKey) { - row.props.label = { ...row.props.label, key: rowSpec.labelKey } - } - if (rowSpec.labelPrefixKey) { - row.props.label = { ...row.props.label, prefix: rowSpec.labelPrefixKey } - } - if (rowSpec.labelParams) { - row.props.label = { ...row.props.label, params: rowSpec.labelParams } - } - if (rowSpec.migration?.format) { - row.props.format = rowSpec.migration.format - } - return row -} diff --git a/tools/dataMigration/migrateMetadata/getSection.ts b/tools/dataMigration/migrateMetadata/getSection.ts deleted file mode 100644 index 0645713967..0000000000 --- a/tools/dataMigration/migrateMetadata/getSection.ts +++ /dev/null @@ -1,138 +0,0 @@ -import { Assessment } from '../../../src/meta/assessment/assessment' -import { AssessmentNames } from '../../../src/meta/assessment/assessmentName' -import { CycleUuid } from '../../../src/meta/assessment/cycle' -import { Description } from '../../../src/meta/assessment/description' -import { Section, SubSection } from '../../../src/meta/assessment/section' -import { DescriptionsSpec, SectionSpec } from '../../../src/test/sectionSpec' -import { getCycleUuids, getLabels } from './utils' - -export const getSection = (props: { assessment: Assessment; index: number; labelKey: string }): Section => { - const { assessment, index, labelKey } = props - const cycleUuids = getCycleUuids({ assessment }) - return { - props: { - anchors: cycleUuids.reduce((acc, cycleUuid) => ({ ...acc, [cycleUuid]: String(index === 0 ? '' : index) }), {}), - cycles: cycleUuids, - labels: getLabels({ assessment, label: { key: labelKey } }), - index, - }, - } -} - -const panEuropeanDescription = (descriptions: DescriptionsSpec): Description => { - return { - comments: true, - nationalData: { - dataSources: { - linkedVariables: descriptions.linkedVariables, - table: {}, - }, - }, - } -} - -const transformDescription = (descriptions: DescriptionsSpec, cycleName: string): Description => { - const is2025 = cycleName === '2025' - - const description: Description = {} - - if (descriptions.analysisAndProcessing) { - description.analysisAndProcessing = { - estimationAndForecasting: true, - reclassification: true, - } - } - - if (descriptions.comments) { - description.comments = true - } - - if (descriptions.introductoryText) { - description.introductoryText = true - } - - if (descriptions.nationalData) { - description.nationalData = { - dataSources: { - table: is2025 ? {} : undefined, - text: { - readOnly: is2025, - }, - }, - nationalClassification: true, - originalData: true, - } - } - - return description -} - -const getDescriptions = (props: { - assessment: Assessment - descriptions: DescriptionsSpec -}): Record => { - const { assessment, descriptions } = props - const { - props: { name }, - cycles, - } = assessment - const isPanEuropean = name === AssessmentNames.panEuropean - - if (isPanEuropean) { - return cycles.reduce( - (acc, cycle) => ({ - ...acc, - [cycle.uuid]: panEuropeanDescription(descriptions), - }), - {} - ) - } - - return cycles.reduce( - (acc, cycle) => ({ - ...acc, - [cycle.uuid]: transformDescription(descriptions, cycle.name), - }), - {} - ) -} - -export const getSubSection = (props: { assessment: Assessment; spec: SectionSpec; index: number }): SubSection => { - const { assessment, spec, index } = props - const isPanEuropean = assessment.props.name === 'panEuropean' - - const anchors = assessment.cycles.reduce>((acc, cycle) => { - const accUpdate = { ...acc } - if (spec.migration?.anchors) { - const anchor = spec.migration.anchors[cycle.name] - if (anchor) { - accUpdate[cycle.uuid] = anchor - } - } else { - accUpdate[cycle.uuid] = spec.sectionAnchor - } - return accUpdate - }, {}) - - const section: SubSection = { - props: { - anchors, - name: spec.sectionName, - cycles: getCycleUuids({ assessment, migration: spec.migration }), - index, - labels: getLabels({ - assessment, - label: { key: `${isPanEuropean ? 'panEuropean.' : ''}${spec.sectionName}.${spec.sectionName}` }, - migration: spec.migration, - }), - showTitle: spec.showTitle, - descriptions: getDescriptions({ assessment, descriptions: spec.descriptions }), - }, - } - if (spec.dataExport?.included) { - section.props.dataExport = spec.dataExport.included - } - if (spec.migration?.hidden) section.props.hidden = spec.migration.hidden - - return section -} diff --git a/tools/dataMigration/migrateMetadata/getTable.ts b/tools/dataMigration/migrateMetadata/getTable.ts deleted file mode 100644 index bab80669d2..0000000000 --- a/tools/dataMigration/migrateMetadata/getTable.ts +++ /dev/null @@ -1,88 +0,0 @@ -import { Assessment } from '../../../src/meta/assessment/assessment' -import { Table, TableColumnNames } from '../../../src/meta/assessment/table' -import { TableSection } from '../../../src/meta/assessment/tableSection' -import { TableSpec } from '../../../src/test/sectionSpec' -import { TableMapping } from '../dataTable/tableMappings' -import { getCycleUuids } from './utils' - -const fraYears = ['1990', '2000', '2010', '2015', '2016', '2017', '2018', '2019', '2020'] -const sustainableDevelopment15 = [...fraYears].splice(1) -// eslint-disable-next-line camelcase -const sustainableDevelopment15_2_1_1 = [ - '2000-2010', - '2010-2015', - '2015-2016', - '2016-2017', - '2017-2018', - '2018-2019', - '2019-2020', -] -const columnsMap: Record> = { - extentOfForest: fraYears, - climaticDomain: ['percentOfForestArea2015Default', 'percentOfForestArea2015'], - forestCharacteristics: fraYears, - growingStockAvg: fraYears, - growingStockTotal: fraYears, - degradedForest: ['answer'], - sustainableDevelopment15_1_1: sustainableDevelopment15, - // eslint-disable-next-line camelcase - sustainableDevelopment15_2_1_1, - sustainableDevelopment15_2_1_2: sustainableDevelopment15, - sustainableDevelopment15_2_1_3: sustainableDevelopment15, - sustainableDevelopment15_2_1_4: sustainableDevelopment15, - sustainableDevelopment15_2_1_5: sustainableDevelopment15, -} - -const getColumnNames = (assessment: Assessment, columnNames?: Array): TableColumnNames => - columnNames - ? assessment.cycles.reduce( - (acc, cycle) => ({ ...acc, [cycle.uuid]: columnNames.map((c) => String(c)) }), - {} - ) - : undefined - -export const getTable = (props: { - assessment: Assessment - tableSpec: TableSpec - tableSection: TableSection - mapping?: TableMapping -}): Table => { - const { assessment, tableSpec, tableSection, mapping } = props - const { name, dataExport, secondary, unit, columnsExport, columnsExportAlways } = tableSpec - - let columnNames = columnsMap[name] - if (!columnNames && mapping) columnNames = mapping.columns.map((col) => col.name) - const columnNamesMigration = tableSpec.migration?.columnNames - ? Object.entries(tableSpec.migration.columnNames).reduce>>( - (acc, [cycleName, columns]) => ({ - ...acc, - [assessment.cycles.find((c) => c.name === cycleName).uuid]: columns, - }), - {} - ) - : undefined - - const table: Table = { - props: { - cycles: getCycleUuids({ - assessment, - parentCycleUuids: tableSection.props.cycles, - migration: tableSpec.migration, - }), - name, - columnNames: columnNamesMigration ?? getColumnNames(assessment, columnNames), - unit, - odp: Boolean(tableSpec.odp), - secondary, - dataExport, - columnsExport: columnNamesMigration ?? getColumnNames(assessment, columnsExport), - columnsExportAlways: getColumnNames(assessment, columnsExportAlways), - }, - rows: [], - tableSectionId: tableSection.id, - } - if (tableSpec.print?.pageBreakAfter) { - table.props.print = { pageBreakAfter: tableSpec.print.pageBreakAfter } - } - return table -} diff --git a/tools/dataMigration/migrateMetadata/getTableSection.ts b/tools/dataMigration/migrateMetadata/getTableSection.ts deleted file mode 100644 index 6a38ea872e..0000000000 --- a/tools/dataMigration/migrateMetadata/getTableSection.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { Assessment, SubSection, TableSection } from '../../../src/meta/assessment' -import { SectionTableSpec } from '../../../src/test/sectionSpec' -import { getCycleUuids, getLabels } from './utils' - -export const getTableSection = (props: { - assessment: Assessment - subSection: SubSection - tableSectionSpec: SectionTableSpec -}): TableSection => { - const { assessment, subSection, tableSectionSpec } = props - - const tableSection: TableSection = { - props: { - cycles: getCycleUuids({ - assessment, - parentCycleUuids: subSection.props.cycles, - migration: tableSectionSpec.migration, - }), - descriptions: getLabels({ - assessment, - label: { key: tableSectionSpec.descriptionKey }, - migration: {}, - }), - labels: getLabels({ - assessment, - label: { key: tableSectionSpec.titleKey }, - migration: tableSectionSpec.migration, - }), - }, - tables: [], - } - return tableSection -} diff --git a/tools/dataMigration/migrateMetadata/index.ts b/tools/dataMigration/migrateMetadata/index.ts deleted file mode 100644 index 2c040d305e..0000000000 --- a/tools/dataMigration/migrateMetadata/index.ts +++ /dev/null @@ -1,194 +0,0 @@ -import * as pgPromise from 'pg-promise' - -import { Assessment as AssessmentLegacy } from '../../../.src.legacy/core/assessment' -import { Assessment } from '../../../src/meta/assessment/assessment' -import { ColProps, ColType } from '../../../src/meta/assessment/col' -import { RowProps } from '../../../src/meta/assessment/row' -import { SectionProps } from '../../../src/meta/assessment/section' -import { TableProps } from '../../../src/meta/assessment/table' -import { TableSectionProps } from '../../../src/meta/assessment/tableSection' -import { BaseProtocol } from '../../../src/server/db' -import { SectionSpec } from '../../../src/test/sectionSpec' -import { DBNames } from '../_DBNames' -import { getMapping } from '../dataTable/tableMappings' -import { isBasicTable } from '../migrateData/_repos' -import { getCol } from './getCol' -import { getRow } from './getRow' -import { getSection, getSubSection } from './getSection' -import { getTable } from './getTable' -import { getTableSection } from './getTableSection' -import { migrateClimaticDomain } from './migrateClimaticDomain' -import { migrateDegradedForest } from './migrateDegradedForest' - -type Props = { - assessment: Assessment - assessmentLegacy: AssessmentLegacy - // schema: string - spec: Record - client: BaseProtocol -} - -type SectionInsert = { id: number; parent_id: number | null; props: SectionProps } -type TableSectionInsert = { id: number; section_id: number; props: TableSectionProps } -type TableInsert = { id: number; table_section_id: number; props: TableProps } -type RowInsert = { id: number; table_id: number; props: RowProps } -type ColInsert = { id: number; row_id: number; props: ColProps } - -export const migrateMetadata = async (props: Props): Promise => { - const { assessment, assessmentLegacy, spec, client } = props - - const schema = DBNames.getAssessmentSchema(assessment.props.name) - - const sectionsInsert: Array = [] - const tableSectionsInsert: Array = [] - const tablesInsert: Array = [] - const rowsInsert: Array = [] - const colsInsert: Array = [] - - let sectionId = 0 - let tableSectionId = 0 - let tableId = 0 - let rowId = 0 - let colId = 0 - - await Promise.all( - Object.entries(assessmentLegacy.sections).map(async ([index, sectionLegacy]) => { - const section = getSection({ labelKey: sectionLegacy.label, index: Number(index), assessment }) - const sectionInsert: SectionInsert = { id: (sectionId += 1), parent_id: null, props: section.props } - sectionsInsert.push(sectionInsert) - - await Promise.all( - Object.values(sectionLegacy.children).map(async (subSectionLegacy, i) => { - const subSectionSpec = spec[subSectionLegacy.name] - const subSection = getSubSection({ assessment, spec: subSectionSpec, index: Number(i) }) - const subSectionInsert = { id: (sectionId += 1), parent_id: sectionInsert.id, props: subSection.props } - sectionsInsert.push(subSectionInsert) - - await Promise.all( - subSectionSpec.tableSections.map(async (tableSectionSpec) => { - const tableSection = getTableSection({ assessment, subSection, tableSectionSpec }) - const tableSectionInsert = { - id: (tableSectionId += 1), - section_id: subSectionInsert.id, - props: tableSection.props, - } - tableSectionsInsert.push(tableSectionInsert) - - await Promise.all( - tableSectionSpec.tableSpecs.map(async (tableSpec) => { - const mapping = isBasicTable(tableSpec.name) ? getMapping(tableSpec.name) : null - const table = getTable({ assessment, tableSpec, tableSection, mapping }) - const tableInsert = { - id: (tableId += 1), - table_section_id: tableSectionInsert.id, - props: table.props, - } - tablesInsert.push(tableInsert) - - let rowIdx = 0 - await Promise.all( - tableSpec.rows.map(async (rowSpec) => { - const row = getRow({ assessment, rowSpec, table }) - if (mapping && mapping.rows.names[rowIdx] && rowSpec.type === 'data') { - row.props.variableName = mapping.rows.names[rowIdx] - rowIdx += 1 - } - - const rowInsert = { - id: (rowId += 1), - table_id: tableInsert.id, - props: row.props, - } - rowsInsert.push(rowInsert) - - let colIdx = 0 - await Promise.all( - rowSpec.cols.map(async (colSpec) => { - const col = getCol({ assessment, colSpec, row }) - const colName = rowSpec.migration?.colNames?.[colIdx] - const colNameOrig = col.props.colName - const withColNameMigration = col.props.colType !== 'header' && colName - if (withColNameMigration) { - col.props.colName = colName - colIdx += 1 - } else if ( - mapping && - rowSpec.type === 'data' && - [ - ColType.decimal, - ColType.integer, - ColType.selectYesNo, - ColType.select, - ColType.text, - ColType.textarea, - ColType.taxon, - ].includes(col.props.colType) - ) { - const columnMapping = mapping.columns[colIdx] - col.props.colName = columnMapping?.name - colIdx += 1 - } - if (col.forceColName || !col.props.colName) col.props.colName = colNameOrig - - const colInsert = { - id: (colId += 1), - row_id: rowInsert.id, - props: col.props, - } - colsInsert.push(colInsert) - }) - ) - }) - ) - }) - ) - }) - ) - }) - ) - }) - ) - - const pgp = pgPromise() - // insert sections - const sectionsCS = new pgp.helpers.ColumnSet(['id', 'parent_id', { name: 'props', cast: 'jsonb' }], { - table: { table: 'section', schema }, - }) - await client.none(pgp.helpers.insert(sectionsInsert, sectionsCS)) - // insert table sections - const tableSectionsCS = new pgp.helpers.ColumnSet(['id', 'section_id', { name: 'props', cast: 'jsonb' }], { - table: { table: 'table_section', schema }, - }) - await client.none(pgp.helpers.insert(tableSectionsInsert, tableSectionsCS)) - // insert tables - const tablesCS = new pgp.helpers.ColumnSet(['id', 'table_section_id', { name: 'props', cast: 'jsonb' }], { - table: { table: 'table', schema }, - }) - await client.none(pgp.helpers.insert(tablesInsert, tablesCS)) - // insert rows - const rowsCS = new pgp.helpers.ColumnSet(['id', 'table_id', { name: 'props', cast: 'jsonb' }], { - table: { table: 'row', schema }, - }) - await client.none(pgp.helpers.insert(rowsInsert, rowsCS)) - // insert cols - const colsCS = new pgp.helpers.ColumnSet(['id', 'row_id', { name: 'props', cast: 'jsonb' }], { - table: { table: 'col', schema }, - }) - await client.none(pgp.helpers.insert(colsInsert, colsCS)) - // update pk id sequence - await client.query(` - SELECT pg_catalog.setval(pg_get_serial_sequence('${schema}.section', 'id'), - (SELECT MAX(id) FROM ${schema}.section) + 1); - SELECT pg_catalog.setval(pg_get_serial_sequence('${schema}.table_section', 'id'), - (SELECT MAX(id) FROM ${schema}.table_section) + 1); - SELECT pg_catalog.setval(pg_get_serial_sequence('${schema}.table', 'id'), - (SELECT MAX(id) FROM ${schema}.table) + 1); - SELECT pg_catalog.setval(pg_get_serial_sequence('${schema}.row', 'id'), - (SELECT MAX(id) FROM ${schema}.row) + 1); - SELECT pg_catalog.setval(pg_get_serial_sequence('${schema}.col', 'id'), - (SELECT MAX(id) FROM ${schema}.col) + 1); - `) - - await migrateDegradedForest({ assessment }, client) - await migrateClimaticDomain({ assessment }, client) -} diff --git a/tools/dataMigration/migrateMetadata/migrateClimaticDomain.ts b/tools/dataMigration/migrateMetadata/migrateClimaticDomain.ts deleted file mode 100644 index efefe54eb0..0000000000 --- a/tools/dataMigration/migrateMetadata/migrateClimaticDomain.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { Assessment } from '../../../src/meta/assessment/assessment' -import { BaseProtocol } from '../../../src/server/db' -import { DBNames } from '../_DBNames' - -export const migrateClimaticDomain = async (props: { assessment: Assessment }, client: BaseProtocol): Promise => { - const { assessment } = props - const assessmentSchema = DBNames.getAssessmentSchema(assessment.props.name) - - await client.query( - ` - update ${assessmentSchema}.col - set props = jsonb_set(props, '{colName}', '"percentOfForestArea2015Default"') - where id in ( - select c.id - from ${assessmentSchema}.col c - left join ${assessmentSchema}.row r on r.id = c.row_id - left join ${assessmentSchema}."table" t on t.id = r.table_id - where t.props ->> 'name' = 'climaticDomain' - and c.props ->> 'index' = '-1' - ); - - update ${assessmentSchema}.col - set props = jsonb_set(props, '{index}', '1') - where id in ( - select c.id - from ${assessmentSchema}.col c - left join ${assessmentSchema}.row r on r.id = c.row_id - left join ${assessmentSchema}."table" t on t.id = r.table_id - where t.props ->> 'name' = 'climaticDomain' - and c.props ->> 'colName' = 'percentOfForestArea2015' - ); - - update ${assessmentSchema}.col - set props = jsonb_set(props, '{index}', '0') - where id in ( - select c.id - from ${assessmentSchema}.col c - left join ${assessmentSchema}.row r on r.id = c.row_id - left join ${assessmentSchema}."table" t on t.id = r.table_id - where t.props ->> 'name' = 'climaticDomain' - and c.props ->> 'colName' = 'percentOfForestArea2015Default' - ); - ` - ) -} diff --git a/tools/dataMigration/migrateMetadata/migrateDegradedForest.ts b/tools/dataMigration/migrateMetadata/migrateDegradedForest.ts deleted file mode 100644 index 2366d13192..0000000000 --- a/tools/dataMigration/migrateMetadata/migrateDegradedForest.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { Assessment } from '../../../src/meta/assessment/assessment' -import { BaseProtocol } from '../../../src/server/db' -import { DBNames } from '../_DBNames' - -export const migrateDegradedForest = async (props: { assessment: Assessment }, client: BaseProtocol): Promise => { - const { assessment } = props - const schema = DBNames.getAssessmentSchema(assessment.props.name) - await client.query(` - update ${schema}.col c - set props = props || '{"index":0, "colName":"answer"}' - where c.id in ( - select cc.id - from ${schema}.col cc - left join ${schema}.row r - on cc.row_id = r.id - left join ${schema}."table" t - on r.table_id = t.id - where t.props ->> 'name' = 'degradedForest' - and cc.props ->> 'colType' in ('select', 'textarea') - ); - - update ${schema}.row r - set props = props || '{"variableName":"does_country_monitor"}' - where r.table_id = (select t.id from ${schema}."table" t where t.props ->> 'name' = 'degradedForest') - and r.props ->> 'index' = '0' - ; - - update ${schema}.row r - set props = props || '{"variableName":"national_definition"}' - where r.table_id = (select t.id from ${schema}."table" t where t.props ->> 'name' = 'degradedForest') - and r.props ->> 'index' = '1' - ; - - update ${schema}.row r - set props = props || '{"variableName":"how_monitored"}' - where r.table_id = (select t.id from ${schema}."table" t where t.props ->> 'name' = 'degradedForest') - and r.props ->> 'index' = '2' - ; - `) -} diff --git a/tools/dataMigration/migrateMetadata/utils.ts b/tools/dataMigration/migrateMetadata/utils.ts deleted file mode 100644 index 66d0debe86..0000000000 --- a/tools/dataMigration/migrateMetadata/utils.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { Assessment, CycleName, CycleUuid, Label } from '../../../src/meta/assessment' - -export const getCycleUuids = (props: { - assessment: Assessment - migration?: { cycles?: Array } - parentCycleUuids?: Array -}): Array => { - const { assessment, migration, parentCycleUuids } = props - if (parentCycleUuids && !migration?.cycles) { - return parentCycleUuids - } - - return assessment.cycles - .filter((cycle) => (migration?.cycles ? migration?.cycles.includes(cycle.name) : true)) - .map((c) => c.uuid) -} - -export const getLabels = (props: { - assessment: Assessment - label?: Label - migration?: { label?: Record } -}): Record => { - const { assessment, label, migration } = props - - if (migration?.label) { - return assessment.cycles.reduce>((acc, cycle) => { - const cycleLabel = migration.label[cycle.name] - if (cycleLabel) { - return { ...acc, [cycle.uuid]: cycleLabel } - } - return acc - }, {}) - } - - if (label) { - return assessment.cycles.reduce>((acc, cycle) => ({ ...acc, [cycle.uuid]: label }), {}) - } - - throw new Error('label or migration must be specified') -} diff --git a/tools/dataMigration/migrateRepository.ts b/tools/dataMigration/migrateRepository.ts deleted file mode 100644 index 8f0599a59d..0000000000 --- a/tools/dataMigration/migrateRepository.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Assessment } from '../../src/meta/assessment/assessment' -import { BaseProtocol } from '../../src/server/db' -import { DBNames } from './_DBNames' - -type Props = { - assessment: Assessment - client: BaseProtocol -} - -export const migrateRepository = async (props: Props): Promise => { - const { assessment, client } = props - - const schema = DBNames.getAssessmentSchema(assessment.props.name) - - await client.query( - ` - delete from ${schema}.file; - - insert into ${schema}.file (country_iso, file_name, file) - select country_iso, file_name, file - from _legacy.repository; - ` - ) -} diff --git a/tools/dataMigration/migrateReview/getIssuesLegacy.ts b/tools/dataMigration/migrateReview/getIssuesLegacy.ts deleted file mode 100644 index 89d7bbf192..0000000000 --- a/tools/dataMigration/migrateReview/getIssuesLegacy.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { BaseProtocol } from '../../../src/server/db' -import { Objects } from '../../../src/utils/objects' - -export type IssueLegacy = { - id: number - countryIso: string - section: string - status: 'opened' | 'resolved' - target: Array -} - -export const getIssuesLegacy = (props: { odp: boolean }, client: BaseProtocol): Promise> => - client.map( - `select i.id, - i.country_iso, - i.section, - i.status, - i.target -> 'params' as target - from _legacy.issue i - where i.section ${props.odp ? `='odp'` : `not in ('odp', 'panEuropeanIndicators')`} - order by 1, 2, 3`, - [], - // @ts-ignore - Objects.camelize - ) diff --git a/tools/dataMigration/migrateReview/getOdpTopics.ts b/tools/dataMigration/migrateReview/getOdpTopics.ts deleted file mode 100644 index 8118e66755..0000000000 --- a/tools/dataMigration/migrateReview/getOdpTopics.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { Assessment } from '../../../src/meta/assessment/assessment' -import { Cycle } from '../../../src/meta/assessment/cycle' -import { BaseProtocol } from '../../../src/server/db' -import { Objects } from '../../../src/utils/objects' -import { DBNames } from '../_DBNames' -import { getIssuesLegacy } from './getIssuesLegacy' -import { MessageTopicRow } from './messageTopicRow' - -export const getOdpTopics = async ( - props: { assessment: Assessment; cycle: Cycle }, - client: BaseProtocol -): Promise> => { - const { assessment, cycle } = props - const cycleSchema = DBNames.getCycleSchema(assessment.props.name, cycle.name) - const values: Array = [] - const ids = await client.one>( - ` - select jsonb_object_agg(o.id_legacy,o.id) as data from ${cycleSchema}.original_data_point o; - `, - [], - ({ data }) => data - ) - - const issues = await getIssuesLegacy({ odp: true }, client) - issues.forEach((issue) => { - const { id, countryIso, status, target } = issue - const [idLegacy, ...otherTarget] = target - let [name] = otherTarget.splice(otherTarget.length - 1, 1) - if (name === 'value') name = 'extentOfForest' - if (name === 'forest_charasteristics') name = 'forestCharacteristics' - name = Objects.camelize(name) - - const odpId = ids[idLegacy] - const key = [odpId, ...otherTarget, name].join('-') - - values.push({ - id, - country_iso: countryIso, - key, - status, - type: 'review', - }) - }) - - return values -} diff --git a/tools/dataMigration/migrateReview/getTableRows.ts b/tools/dataMigration/migrateReview/getTableRows.ts deleted file mode 100644 index be197893ec..0000000000 --- a/tools/dataMigration/migrateReview/getTableRows.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Assessment } from '../../../src/meta/assessment/assessment' -import { BaseProtocol } from '../../../src/server/db' -import { DBNames } from '../_DBNames' - -// tableName -> rowIndex -> rowUuid - -export type TableRows = Record> - -export const getTableRows = async (props: { assessment: Assessment }, client: BaseProtocol): Promise => { - const { assessment } = props - const assessmentSchema = DBNames.getAssessmentSchema(assessment.props.name) - return client.one( - ` - with t as ( - select t.props ->> 'name' as table_name, - jsonb_object_agg(r.props ->> 'index', r.uuid) as rows - from ${assessmentSchema}.row r - left join ${assessmentSchema}."table" t - on r.table_id = t.id - where r.props ->> 'variableName' is not null - group by 1) - select jsonb_object_agg(t.table_name, t.rows) as data - from t - ; - `, - [], - ({ data }) => data - ) -} diff --git a/tools/dataMigration/migrateReview/getTableTopics.ts b/tools/dataMigration/migrateReview/getTableTopics.ts deleted file mode 100644 index 3d09a59e3c..0000000000 --- a/tools/dataMigration/migrateReview/getTableTopics.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { Assessment } from '../../../src/meta/assessment/assessment' -import { BaseProtocol } from '../../../src/server/db' -import { getIssuesLegacy } from './getIssuesLegacy' -import { getTableRows } from './getTableRows' -import { MessageTopicRow } from './messageTopicRow' - -export const getTableTopics = async ( - props: { assessment: Assessment }, - client: BaseProtocol -): Promise> => { - const values: Array = [] - const tableRows = await getTableRows(props, client) - const issues = await getIssuesLegacy({ odp: false }, client) - issues.forEach((issue) => { - if (issue.target.length === 3) { - const { id, countryIso, status, target } = issue - const [tableName, , rowIndex] = target - const key = tableRows[tableName][rowIndex] - - if (!values.find((v) => v.country_iso === countryIso && v.key === key)) { - values.push({ - id, - country_iso: countryIso, - key, - status, - type: 'review', - }) - } - // else { - // console.log('========= duplicate topic ', countryIso, tableName, rowIndex) - // } - } - }) - - return values -} diff --git a/tools/dataMigration/migrateReview/index.ts b/tools/dataMigration/migrateReview/index.ts deleted file mode 100644 index d9a646c09f..0000000000 --- a/tools/dataMigration/migrateReview/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { migrateReview } from './migrateReview' diff --git a/tools/dataMigration/migrateReview/messageTopicRow.ts b/tools/dataMigration/migrateReview/messageTopicRow.ts deleted file mode 100644 index c1a82244d8..0000000000 --- a/tools/dataMigration/migrateReview/messageTopicRow.ts +++ /dev/null @@ -1,7 +0,0 @@ -export type MessageTopicRow = { - id: number - country_iso: string - key: string - status: string - type: string -} diff --git a/tools/dataMigration/migrateReview/migrateReview.ts b/tools/dataMigration/migrateReview/migrateReview.ts deleted file mode 100644 index 8b8c20afa3..0000000000 --- a/tools/dataMigration/migrateReview/migrateReview.ts +++ /dev/null @@ -1,52 +0,0 @@ -import * as pgPromise from 'pg-promise' - -import { Assessment } from '../../../src/meta/assessment/assessment' -import { BaseProtocol } from '../../../src/server/db' -import { DBNames } from '../_DBNames' -import { getOdpTopics } from './getOdpTopics' -import { getTableTopics } from './getTableTopics' - -export const migrateReview = async (props: { assessment: Assessment }, client: BaseProtocol): Promise => { - const { assessment } = props - const cycle = assessment.cycles.find((cycle) => cycle.name === '2020') - - const tableTopics = await getTableTopics(props, client) - const odpTopics = await getOdpTopics({ assessment, cycle }, client) - - const schemaCycle = DBNames.getCycleSchema(assessment.props.name, cycle.name) - const pgp = pgPromise() - const cs = new pgp.helpers.ColumnSet(['id', 'country_iso', 'key', 'status', 'type'], { - table: { table: 'message_topic', schema: schemaCycle }, - }) - const query = pgp.helpers.insert([...tableTopics, ...odpTopics], cs) - await client.query(query) - await client.query( - `select setval('${schemaCycle}.message_topic_id_seq', (select max(id) from ${schemaCycle}.message_topic), true);` - ) - - await client.query(` - insert into ${schemaCycle}.message (topic_id, user_id, message, deleted, created_time) - select c.issue_id as topic_id, - u.id as user_id, - c.message, - c.deleted, - c.added_time as created_time - from _legacy.fra_comment c - left join _legacy.fra_user fu on c.user_id = fu.id - left join users u on lower(trim(fu.email)) = lower(trim(u.email)) - join ${schemaCycle}.message_topic t on t.id = c.issue_id; - `) - - await client.query(` - insert into ${schemaCycle}.message_topic_user (topic_id, user_id, last_open_time) - select ui.issue_id as topic_id, - u.id as user_id, - ui.read_time as last_open_time - from _legacy.user_issue ui - left join _legacy.fra_user fu - on ui.user_id = fu.id - left join users u - on lower(trim(fu.email)) = lower(trim(u.email)) - join ${schemaCycle}.message_topic t on t.id = ui.issue_id; - `) -} diff --git a/tools/dataMigration/migrateUsers.ts b/tools/dataMigration/migrateUsers.ts deleted file mode 100644 index 9cfdb81232..0000000000 --- a/tools/dataMigration/migrateUsers.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { BaseProtocol } from '../../src/server/db' - -export const migrateUsers = async (props: { client: BaseProtocol }): Promise => { - const { client } = props - - await client.query( - ` - delete - from _legacy.user_country_role - where user_id = ( - select id - from _legacy.fra_user - where email = 'akabroj2@yahoo.fr' - and lang = 'en' - ); - delete - from _legacy.fra_user - where email = 'akabroj2@yahoo.fr' - and lang = 'en'; - - update _legacy.fra_audit - set user_login_email = 'agrimediambient@gmail.com' - where user_email = 'agrimediambient@ordino.ad'; - - update _legacy.fra_user - set name = 'Sergi Riba Mazas', - position = 'Agriculture, Environment and sustainibility Department Chief', - institution = 'Comú of Ordino' - where login_email = 'agrimediambient@gmail.com'; - - delete - from _legacy.user_country_role - where user_id = ( - select id - from _legacy.fra_user - where login_email = 'agrimediambient@ordino.ad' - ); - delete - from _legacy.fra_user - where login_email = 'agrimediambient@ordino.ad'; - - delete - from users; - - insert into users (email, profile_picture_file, profile_picture_filename, status, props) - select u_l.email, - u_l.profile_picture_file, - u_l.profile_picture_filename, - case - when u_l.active then 'active'::users_status - else 'invitationPending'::users_status - end as status, - jsonb_build_object('name', u_l.name, 'lang', u_l.lang) as props - from _legacy.fra_user u_l; - ` - ) -} diff --git a/tools/dataMigration/migrateUsersAuthProvider.ts b/tools/dataMigration/migrateUsersAuthProvider.ts deleted file mode 100644 index 6a7d60abbb..0000000000 --- a/tools/dataMigration/migrateUsersAuthProvider.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { BaseProtocol } from '../../src/server/db' - -export const migrateUsersAuthProvider = async (props: { client: BaseProtocol }): Promise => { - const { client } = props - - await client.query( - ` - delete - from users_auth_provider; - - insert into users_auth_provider (user_id, provider, props) - select us.id, - u.type::varchar::auth_provider as provider, - case - when u.type = 'google' then jsonb_build_object('email', u.login_email) - when u.type = 'local' then jsonb_build_object('password', u.password) - else '{}'::jsonb - end as props - from _legacy.fra_user u - left join users us on us.email = u.email - ; - ` - ) -} diff --git a/tools/dataMigration/migrateUsersInvitation.ts b/tools/dataMigration/migrateUsersInvitation.ts deleted file mode 100644 index dc836eb8a7..0000000000 --- a/tools/dataMigration/migrateUsersInvitation.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { BaseProtocol } from '../../src/server/db' - -export const migrateUsersInvitation = async (props: { client: BaseProtocol }): Promise => { - const { client } = props - - await client.query( - ` - with i as ( - select fui.country_iso, - fui.role, - fui.invitation_uuid, - fui.invited, - fui.accepted, - ur.id - from _legacy.fra_user_invitation fui - left join users u - on lower(trim(u.email)) = lower(trim(fui.email)) - left join users_role ur - on u.id = ur.user_id - and ur.role::varchar = fui.role - and ur.country_iso = fui.country_iso - ) - update users_role u - set invitation_uuid = i.invitation_uuid, - invited_at = i.invited, - accepted_at = i.accepted - from i - where u.id = i.id - ; - ` - ) -} diff --git a/tools/dataMigration/migrateUsersResetPassword.ts b/tools/dataMigration/migrateUsersResetPassword.ts deleted file mode 100644 index 232fa14927..0000000000 --- a/tools/dataMigration/migrateUsersResetPassword.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { BaseProtocol } from '../../src/server/db' - -export const migrateUsersResetPassword = async (props: { client: BaseProtocol }): Promise => { - const { client } = props - - await client.query( - ` - delete - from users_reset_password; - - insert into users_reset_password (uuid, changed_at, created_at, user_id) - select r.uuid, - r.password_changed_time, - r.created_time, - u.id - from _legacy.fra_user_reset_password r - left join _legacy.fra_user fu on fu.id = r.user_id - left join users u on fu.email = u.email - ; - ` - ) -} diff --git a/tools/dataMigration/migrateUsersRole.ts b/tools/dataMigration/migrateUsersRole.ts deleted file mode 100644 index a2df7c63b1..0000000000 --- a/tools/dataMigration/migrateUsersRole.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { Assessment } from '../../src/meta/assessment/assessment' -import { BaseProtocol } from '../../src/server/db' - -type Props = { - assessment: Assessment - client: BaseProtocol -} - -export const migrateUsersRole = async (props: Props): Promise => { - const { assessment, client } = props - const cycle2020 = assessment.cycles.find((c) => c.name === '2020') - - await client.query( - ` - delete - from users_role; - - drop materialized view if exists _temp; - - create materialized view _temp as - with r as (select cca.user_id, - cca.country_iso, - jsonb_array_elements((cca.tables -> 'tables')::jsonb) as tables - from _legacy.collaborators_country_access cca), - d as (select r.country_iso, - r.tables ->> 'section'::varchar as section_name, - r.tables ->> 'tableNo'::varchar as table_no, - s.uuid as section_uuid, - u.id as user_id, - u_l.email, - u_l.id as user_id_legacy - from r - left join assessment_fra.section s - on r.tables -> 'tableNo' = s.props -> 'anchors' -> '${cycle2020.uuid}' - left join _legacy.fra_user u_l on r.user_id = u_l.id - left join users u on u_l.email = u.email), - q as (select d.country_iso, - d.user_id, - d.user_id_legacy, - d.email, - jsonb_object_agg( - case - when d.section_name = 'all' then 'all' - when d.section_name = 'none' then 'none' - else - d.section_uuid::varchar end, - '{ "tableData": true, "descriptions": true }'::jsonb - ) - as sections - from d - group by d.country_iso, - d.user_id, - d.user_id_legacy, - d.email) - select q.country_iso, - q.user_id, - q.user_id_legacy, - q.email, - case - when q.sections -> 'all' is not NULL then '"all"'::jsonb - when q.sections -> 'none' is not NULL then '"none"'::jsonb - else q.sections - end as sections - from q - ; - - insert into users_role (user_id, assessment_id, country_iso, cycle_uuid, role, permissions, props, invitation_uuid, - invited_at, accepted_at) - select us.id, - case when r.role = 'ADMINISTRATOR' then null else ${assessment.id} end as assessment_id, - case when r.role = 'ADMINISTRATOR' then null else r.country_iso end as country_iso, - case when r.role = 'ADMINISTRATOR' then null else '${assessment.cycles[0].uuid}'::uuid end as cycle_uuid, - r.role::user_role, - case - when t.sections is not null then jsonb_build_object('sections', t.sections) - else '{}'::jsonb - end - as permissions, - case - when u.institution is not null and u.position is not null then jsonb_build_object('organization', u.institution, 'professionalTitle', u.position) - when u.institution is not null then jsonb_build_object('organization', u.institution) - when u.position is not null then jsonb_build_object('professionalTitle', u.position) - else '{}'::jsonb - end - as props, - null as invitation_uuid, - null as invited_at, - null as accepted_at - from _legacy.fra_user u - left join _legacy.user_country_role r on u.id = r.user_id - left join users us on lower(trim(us.email)) = lower(trim(u.email)) - left join _temp t on u.id = t.user_id_legacy and r.country_iso = t.country_iso - ; - - drop materialized view _temp; - ` - ) -} diff --git a/tools/dataMigration/panEuropean.ts b/tools/dataMigration/panEuropean.ts deleted file mode 100644 index e861833875..0000000000 --- a/tools/dataMigration/panEuropean.ts +++ /dev/null @@ -1,147 +0,0 @@ -import 'tsconfig-paths/register' -import 'dotenv/config' - -import * as path from 'path' -import { config } from 'dotenv' - -import { PanEuropean } from '../../.src.legacy/core/assessment' -import { Assessment as AssessmentLegacy } from '../../.src.legacy/core/assessment/assessment' -import { SectionSpec } from '../../.src.legacy/webapp/sectionSpec' -import { Assessment } from '../../src/meta/assessment/assessment' -import { Cycle } from '../../src/meta/assessment/cycle' -import { BaseProtocol, DB } from '../../src/server/db' -import { - getCreateSchemaCycleDDL, - getCreateSchemaDDL, -} from '../../src/server/repository/assessment/assessment/getCreateSchemaDDL' -import { PanEuropeanSpecs } from '../../src/test/sectionSpec/PanEuropeanSpecs' -import { migrateTablesData } from './migrateData/migrateTablesData' -import { DBNames } from './_DBNames' -import { generateMetaCache } from './generateMetaCache' -import { migrateAreas } from './migrateAreas' -import { migrateMetadata } from './migrateMetadata' - -config({ path: path.resolve(__dirname, '..', '..', '.env') }) - -const createCycle = async (assessment: Assessment, cycleName: string, client: BaseProtocol): Promise => { - await DB.query( - getCreateSchemaCycleDDL( - DBNames.getAssessmentSchema(assessment.props.name), - DBNames.getCycleSchema(assessment.props.name, cycleName) - ) - ) - - return client.one( - `insert into assessment_cycle (assessment_id, name) - values ($1, $2) - returning *`, - [assessment.id, cycleName] - ) -} - -export const migrate = async (props: { - assessmentName: string - legacySchemaName: string - assessmentLegacy: AssessmentLegacy - cycleNames: Array - spec: Record -}): Promise => { - // eslint-disable-next-line no-console - console.log('========== START ', new Date().getTime()) - const { assessmentName, legacySchemaName, assessmentLegacy, cycleNames, spec } = props - - // eslint-disable-next-line no-console - console.log('========== 1. delete old assessment') - // ==== 1. delete old assessment - await DB.query(`drop schema if exists ${DBNames.getAssessmentSchema(assessmentName)} cascade;`) - await Promise.all( - cycleNames.map((cycleName) => - DB.query(`drop schema if exists ${DBNames.getCycleSchema(assessmentName, cycleName)} cascade;`) - ) - ) - - await DB.query( - `delete - from assessment - where props ->> 'name' = $1`, - [assessmentName] - ) - const client = DB - // await DB.tx(async (client) => { - - // eslint-disable-next-line no-console - console.log('========== 2. create assessment') - // ==== 2. create assessment - const assessment = await client.one( - `insert into assessment (props) - values ($1::jsonb) - returning *;`, - [JSON.stringify({ name: assessmentName })] - ) - - // create schema - const schema = DBNames.getAssessmentSchema(assessment.props.name) - await DB.query(getCreateSchemaDDL(schema)) - // ==== 2 END. create assessment - - // ==== 3. create cycles - // eslint-disable-next-line no-console - console.log('========== 3. create cycles') - assessment.cycles = await Promise.all(cycleNames.map((cycleName) => createCycle(assessment, cycleName, client))) - - // Set cycle 2020 to published - const defaultCycle = assessment.cycles.find((c) => c.name === '2020') - await client.query('update public.assessment_cycle set published = true where id = $1', [defaultCycle.id]) - await client.query('update public.assessment set props = $2:json::jsonb where id = $1', [ - assessment.id, - { - ...assessment.props, - defaultCycle: defaultCycle.uuid, - }, - ]) - // ==== 3 END. create cycles - - // ==== 4. migrate metadata - // eslint-disable-next-line no-console - console.log('========== 4. migrate metadata') - await migrateMetadata({ assessment, assessmentLegacy, spec, client }) - // ==== 4 END. migrate metadata - - await Promise.all( - cycleNames.map((cycleName, index: number) => - migrateAreas({ client, schema: DBNames.getCycleSchema(assessment.props.name, cycleName), index }) - ) - ) - - // ==== 5. migrate data - // eslint-disable-next-line no-console - console.log('========== 5. migrate data') - await Promise.all( - assessment.cycles.map(async (cycle) => { - // eslint-disable-next-line no-console - console.log(`========== 5.1. migrate tables data ${cycle.name}`) - await migrateTablesData({ assessment, cycle }, client, legacySchemaName) - // eslint-disable-next-line no-console - console.log(`========== 5.2. generateMetaCache ${cycle.name}`) - await generateMetaCache({ assessment, cycle }, client) - }) - ) - // ==== 5 END. migrate data - // }) -} - -const assessmentName = 'panEuropean' -const cycleNames = ['2020', '2025'] -const legacySchemaName = '_legacy_pan_european' - -migrate({ assessmentName, cycleNames, legacySchemaName, spec: PanEuropeanSpecs, assessmentLegacy: PanEuropean }) - .then(() => { - // eslint-disable-next-line no-console - console.log('========== END ', new Date().getTime()) - process.exit(0) - }) - .catch((e) => { - // eslint-disable-next-line no-console - console.error(e) - process.exit(1) - }) diff --git a/tools/faoStat.js b/tools/faoStat.js deleted file mode 100644 index 2497bf537b..0000000000 --- a/tools/faoStat.js +++ /dev/null @@ -1,36 +0,0 @@ -const promise = require('bluebird') -const fs = promise.promisifyAll(require('fs')) -const csv = promise.promisifyAll(require('csv')) -const R = require('ramda') - -const countryIsoCol = 6 -const yearCol = 3 -const areaCol = 5 -const estimateCol = 7 - -const getFaostatValues = async (fileName) => { - const rawFaostatData = await fs.readFileAsync(fileName, {encoding: 'utf-8'}) - const parsedFaostatData = await csv.parseAsync(rawFaostatData) - const faoStatData = R.slice(1, undefined, parsedFaostatData) - const rowObjects = R.map( - row => ({ - countryIso: row[countryIsoCol], - year: row[yearCol], - area: row[areaCol], - estimate: row[estimateCol] === 'EST' - }), - faoStatData - ) - const groupedByCountry = R.reduce( - (result, row) => R.assocPath( - [row.countryIso, 'faoStat', row.year], - {area: row.area, estimate: row.estimate}, - result - ), - {}, - rowObjects - ) - return groupedByCountry -} - -module.exports.getFaostatValues = getFaostatValues diff --git a/tools/faostatUpdater.js b/tools/faostatUpdater.js deleted file mode 100644 index 055208525c..0000000000 --- a/tools/faostatUpdater.js +++ /dev/null @@ -1,58 +0,0 @@ -const R = require('ramda') -const csv = require('csv') -const fs = require('fs') -const faoStat = require('./faoStat') -const countryConfig = require('../server/controller/country/countryConfig') - -const exampleUsage = - 'node faostatUpdater.js exampleData/FAOSTAT_data_11-9-2017.csv /tmp/countryConfigWithUpdatedFaostat.json' - -if (process.argv.length < 4) { - console.log(`Usage: ${process.argv[0]} `) - console.log(`example:\n${exampleUsage}`) - process.exit() -} - -const faoStatCsvFile = process.argv[2] -console.log('reading file', faoStatCsvFile) -const outputFile = process.argv[3] - -const addFaostatValuesForYearsUntil2020 = (faostatData) => { - return R.reduce( - (result, countryRow) => { - const iso = countryRow[0] - const faoStat = R.path([1, 'faoStat'], countryRow) - if (!faoStat) return result - const lastRecordedYear = R.pipe( - R.keys, - R.sort((a, b) => b - a), - R.head - )(faoStat) - const yearsToRepeat = R.range(Number(lastRecordedYear) + 1, 2021) - const repeatValue = R.path([lastRecordedYear, 'area'], faoStat) - const repeatedPairs = R.map( - (year) => [`${year}`, { area: repeatValue, estimate: true, repeated: true }], - yearsToRepeat - ) - const faoStatWithRepeatedValues = R.merge(R.fromPairs(repeatedPairs), faoStat) - return R.assocPath([iso, 'faoStat'], faoStatWithRepeatedValues, result) - }, - faostatData, - R.toPairs(faostatData) - ) -} - -const update = async (faoStatCsvFile, outputFile) => { - try { - const faostatData = await faoStat.getFaostatValues(faoStatCsvFile) - const faoStatWithRepeatedYearsInTheFuture = addFaostatValuesForYearsUntil2020(faostatData) - const merged = R.mergeDeepLeft(faoStatWithRepeatedYearsInTheFuture, countryConfig) - fs.writeFileSync(outputFile, JSON.stringify(merged, null, ' '), 'utf8') - console.log('Wrote merged values into: ', outputFile) - console.log('You should manually copy them over the countryConfig values') - } catch (e) { - console.log(e) - } -} - -update(faoStatCsvFile, outputFile) diff --git a/tools/faostatUpdater20180209.js b/tools/faostatUpdater20180209.js deleted file mode 100644 index cdeec582b0..0000000000 --- a/tools/faostatUpdater20180209.js +++ /dev/null @@ -1,49 +0,0 @@ -const Promise = require('bluebird') -const R = require('ramda') -const countryConfig = require('../server/controller/country/countryConfig') - -const fs = Promise.promisifyAll(require('fs')) -const csv = Promise.promisifyAll(require('csv')) - -const exampleUsage = - 'node faostatUpdater.js exampleData/FAOSTAT_data_11-9-2017.csv /tmp/countryConfigWithUpdatedFaostat.json' - -if (process.argv.length < 4) { - console.log(`Usage: ${process.argv[0]} `) - console.log(`example:\n${exampleUsage}`) - process.exit() -} - -const faoStatCsvFile = process.argv[2] -console.log('reading file', faoStatCsvFile) -const outputFile = process.argv[3] - -const update = async (faoStatCsvFile, outputFile) => { - try { - const rawFaostatData = await fs.readFileAsync(faoStatCsvFile, { encoding: 'utf-8' }) - const parsedFaostatData = await csv.parseAsync(rawFaostatData) - const faoStatData = R.slice(1, undefined, parsedFaostatData) - const countryFaoStataData = R.reduce( - (result, row) => { - const faoStat = R.reduce( - (countryObj, year) => R.assoc(year, { area: Number(row[4]), estimate: year !== 2015 }, countryObj), - {}, - R.range(1980, 2021) - ) - return R.assoc(row[0], { faoStat }, result) - }, - {}, - faoStatData - ) - - const merged = R.mergeDeepLeft(countryFaoStataData, countryConfig) - await fs.writeFileAsync(outputFile, JSON.stringify(merged, null, ' '), 'utf8') - - console.log('Wrote merged values into: ', outputFile) - console.log('You should manually copy them over the countryConfig values') - } catch (e) { - console.log(e) - } -} - -update(faoStatCsvFile, outputFile) diff --git a/tools/flagFileNameUpdater.js b/tools/flagFileNameUpdater.js deleted file mode 100644 index ce9219a632..0000000000 --- a/tools/flagFileNameUpdater.js +++ /dev/null @@ -1,35 +0,0 @@ -const R = require('ramda') -const Promise = require('bluebird') -const fs = Promise.promisifyAll(require('fs')) -const csv = Promise.promisifyAll(require('csv')) - -const countriesInputCsvFile = 'exampleData/FAOCountriesNOCS_EXPORT.csv' -const flagDir = '../../web-resources/img/flags/1x1' -console.log('reading file', countriesInputCsvFile) - -const doIt = async () => { - - const rawCountries = await fs.readFileAsync(countriesInputCsvFile, {encoding: 'utf-8'}) - const parsedCountries = await csv.parseAsync(rawCountries) - const countries = R.pipe( - R.slice(1, undefined), - R.map(c => ({ - iso3: c[1], - iso2: c[2], - listNameEn: c[3] - })) - )(parsedCountries) - R.forEach (country => { - console.log(country) - const oldfileName = flagDir + '/' + country.iso2.toLowerCase() + '.svg' - const newFileName = flagDir + '/' + country.iso3 + '.svg' - if (fs.existsSync(oldfileName)) { - console.log('renaming', oldfileName, 'to', newFileName) - fs.renameSync(oldfileName, newFileName) - } else { - console.log('Could not find', oldfileName) - } - }, countries) -} - -doIt().then(() => console.log('done')).catch(err=>console.log('error', err)) diff --git a/tools/fraCountriesSqlCreator.js b/tools/fraCountriesSqlCreator.js deleted file mode 100644 index 290ff7b061..0000000000 --- a/tools/fraCountriesSqlCreator.js +++ /dev/null @@ -1,99 +0,0 @@ -String.prototype.replaceAll = function (search, replacement) { - return this.split(search).join(replacement) -} -const R = require('ramda') -const Promise = require('bluebird') -const fs = Promise.promisifyAll(require('fs')) -const csv = Promise.promisifyAll(require('csv')) - -const exampleUsage = - 'node certifiedAreasCountryUdater.js ./exampleData/FAOCountriesNOCS_EXPORT.csv ./exampleData/FRACountries.csv ./exampleData/EUCountries.csv /tmp/countriesSQL.sql' - -if (process.argv.length < 4) { - console.log(`Usage: ${process.argv[0]} `) - console.log(`example:\n${exampleUsage}`) - process.exit() -} - -const countriesInputCsvFile = process.argv[2] -console.log('reading file', countriesInputCsvFile) -const fraCountriesInputCsvFile = process.argv[3] -const euCountriesInputCsvFile = process.argv[4] -const outputFile = process.argv[5] - -const readCsv = async fileName => { - const rawFile = await fs.readFileAsync(fileName, {encoding: 'utf-8'}) - const csvFile = await csv.parseAsync(rawFile) - return csvFile -} - -const getCountryISOs = async fileName => { - const parsedCountries = await readCsv(fileName) - return R.pipe( - R.slice(1, undefined), - R.map(c => c[0]) - )(parsedCountries) -} - -const getCountrySqlUpdates = async (countriesFileName, fraCountriesFileName, euCountriesFileName) => { - const fraCountries = await getCountryISOs(fraCountriesFileName) - const euCountries = await getCountryISOs(euCountriesFileName) - - const allCountries = await readCsv(countriesFileName) - const countries = R.pipe( - R.slice(1, undefined), - R.map(c => ({ - iso3: c[1], - iso2: c[2], - listNameEn: c[3], - fullNameEn: c[4], - listNameEs: c[5], - fullNameEs: c[6], - listNameFr: c[7], - fullNameFr: c[8], - listNameRu: c[9], - fullNameRu: c[10], - panEuropean: R.contains(c[1], euCountries) - })), - R.filter(c => R.contains(c.iso3, fraCountries)) - )(allCountries) - - console.log(countries[1]) - - const sqls = - R.map(c => ` - UPDATE - country - SET - list_name_en = '${c.listNameEn.replaceAll(`'`, `''`)}', - full_name_en = '${c.fullNameEn.replaceAll(`'`, `''`)}', - list_name_es = '${c.listNameEs.replaceAll(`'`, `''`)}', - full_name_es = '${c.fullNameEs.replaceAll(`'`, `''`)}', - list_name_fr = '${c.listNameFr.replaceAll(`'`, `''`)}', - full_name_fr = '${c.fullNameFr.replaceAll(`'`, `''`)}', - list_name_ru = '${c.listNameRu.replaceAll(`'`, `''`)}', - full_name_ru = '${c.fullNameRu.replaceAll(`'`, `''`)}', - WHERE - country_iso = '${c.iso3}'; - `) - (countries) - - return sqls -} - -const writeSqlUpdates = async (countries, outputFile) => { - const stream = await fs.createWriteStream(outputFile) - return stream.once('open', fd => { - R.forEach(c => stream.write(c), countries) - stream.end() - }) -} - -const update = async (countriesInputCsvFile, fraCountriesInputCsvFile, euCountriesInputCsvFile, outputFile) => { - try { - const sqlUpdates = await getCountrySqlUpdates(countriesInputCsvFile, fraCountriesInputCsvFile, euCountriesInputCsvFile) - await writeSqlUpdates(sqlUpdates, outputFile) - } catch (e) { console.log(e) } -} - -update(countriesInputCsvFile, fraCountriesInputCsvFile, euCountriesInputCsvFile, outputFile) diff --git a/tools/fraReport/countries.csv b/tools/fraReport/countries.csv deleted file mode 100644 index 9341b658c8..0000000000 --- a/tools/fraReport/countries.csv +++ /dev/null @@ -1,236 +0,0 @@ -ABW,en,TRUE -AFG,en,FALSE -AGO,fr,FALSE -AIA,en,TRUE -ALB,en,TRUE -AND,fr,FALSE -ARE,en,TRUE -ARG,es,FALSE -ARM,en,FALSE -ASM,en,FALSE -ATG,en,TRUE -AUS,en,FALSE -AUT,en,FALSE -AZE,en,FALSE -BDI,fr,FALSE -BEL,fr,FALSE -BEN,fr,FALSE -BES,en,TRUE -BFA,fr,FALSE -BGD,en,FALSE -BGR,en,FALSE -BHR,en,TRUE -BHS,en,FALSE -BIH,en,TRUE -BLM,fr,TRUE -BLR,en,FALSE -BLZ,en,FALSE -BMU,en,TRUE -BOL,es,FALSE -BRA,en,FALSE -BRB,en,FALSE -BRN,en,FALSE -BTN,en,FALSE -BWA,en,FALSE -CAF,fr,FALSE -CAN,en,FALSE -CHE,fr,FALSE -CHL,es,FALSE -CHN,en,FALSE -CIV,fr,FALSE -CMR,fr,FALSE -COD,fr,FALSE -COG,fr,FALSE -COK,en,FALSE -COL,es,FALSE -COM,fr,FALSE -CPV,fr,FALSE -CRI,es,FALSE -CUB,es,FALSE -CUW,en,TRUE -CYM,en,TRUE -CYP,en,FALSE -CZE,en,FALSE -DEU,en,FALSE -DJI,fr,FALSE -DMA,en,FALSE -DNK,en,FALSE -DOM,es,FALSE -DZA,fr,FALSE -ECU,es,FALSE -EGY,en,FALSE -ERI,en,FALSE -ESH,en,TRUE -ESP,es,FALSE -EST,en,FALSE -ETH,en,FALSE -FIN,en,FALSE -FJI,en,FALSE -FLK,en,TRUE -FRA,fr,FALSE -FRO,en,FALSE -FSM,en,FALSE -GAB,fr,FALSE -GBR,en,FALSE -GEO,en,FALSE -GGY,en,TRUE -GHA,en,FALSE -GIB,en,TRUE -GIN,fr,FALSE -GLP,fr,FALSE -GMB,en,FALSE -GNB,fr,TRUE -GNQ,es,FALSE -GRC,en,FALSE -GRD,en,FALSE -GRL,en,FALSE -GTM,es,FALSE -GUF,fr,FALSE -GUM,en,FALSE -GUY,en,FALSE -HND,es,FALSE -HRV,en,FALSE -HTI,fr,FALSE -HUN,en,FALSE -IDN,en,FALSE -IMN,en,TRUE -IND,en,FALSE -IRL,en,FALSE -IRN,en,FALSE -IRQ,en,FALSE -ISL,en,FALSE -ISR,en,FALSE -ITA,en,FALSE -JAM,en,FALSE -JEY,en,TRUE -JOR,en,FALSE -JPN,en,FALSE -KAZ,en,FALSE -KEN,en,FALSE -KGZ,en,FALSE -KHM,en,FALSE -KIR,en,TRUE -KNA,en,TRUE -KOR,en,FALSE -KWT,en,TRUE -LAO,en,FALSE -LBN,fr,FALSE -LBR,en,FALSE -LBY,en,TRUE -LCA,en,FALSE -LIE,fr,FALSE -LKA,en,FALSE -LSO,en,FALSE -LTU,en,FALSE -LUX,fr,FALSE -LVA,en,FALSE -MAF,fr,TRUE -MAR,fr,FALSE -MCO,fr,TRUE -MDA,en,FALSE -MDG,fr,FALSE -MDV,en,FALSE -MEX,es,FALSE -MHL,en,FALSE -MKD,en,TRUE -MLI,fr,FALSE -MLT,en,FALSE -MMR,en,FALSE -MNE,en,FALSE -MNG,en,FALSE -MNP,en,FALSE -MOZ,en,FALSE -MRT,fr,FALSE -MSR,en,TRUE -MTQ,fr,FALSE -MUS,en,FALSE -MWI,en,FALSE -MYS,en,FALSE -MYT,fr,FALSE -NAM,en,FALSE -NCL,fr,TRUE -NER,fr,FALSE -NFK,en,TRUE -NGA,en,FALSE -NIC,es,FALSE -NIU,en,FALSE -NLD,en,FALSE -NOR,en,FALSE -NPL,en,FALSE -NRU,en,TRUE -NZL,en,FALSE -OMN,en,FALSE -PAK,en,FALSE -PAN,es,FALSE -PCN,en,TRUE -PER,es,FALSE -PHL,en,FALSE -PLW,en,FALSE -PNG,en,FALSE -POL,en,FALSE -PRI,en,FALSE -PRK,en,TRUE -PRT,en,FALSE -PRY,es,FALSE -PSE,en,TRUE -PYF,fr,TRUE -QAT,en,TRUE -REU,fr,FALSE -ROU,en,FALSE -RUS,en,FALSE -RWA,fr,TRUE -SAU,en,TRUE -SDN,en,FALSE -SEN,fr,FALSE -SGP,en,FALSE -SHN,fr,TRUE -SJM,en,FALSE -SLB,en,FALSE -SLE,en,FALSE -SLV,es,FALSE -SMR,en,TRUE -SOM,en,FALSE -SPM,fr,TRUE -SRB,en,FALSE -SSD,en,FALSE -STP,fr,FALSE -SUR,en,FALSE -SVK,en,FALSE -SVN,en,FALSE -SWE,en,FALSE -SWZ,en,FALSE -SXM,en,TRUE -SYC,en,FALSE -SYR,en,FALSE -TCA,en,TRUE -TCD,fr,FALSE -TGO,fr,FALSE -THA,en,FALSE -TJK,en,FALSE -TKL,en,TRUE -TKM,en,TRUE -TLS,en,FALSE -TON,en,FALSE -TTO,en,FALSE -TUN,fr,FALSE -TUR,en,FALSE -TUV,en,FALSE -TZA,en,FALSE -UGA,en,FALSE -UKR,en,FALSE -URY,es,FALSE -USA,en,FALSE -UZB,en,FALSE -VAT,fr,TRUE -VCT,en,FALSE -VEN,es,FALSE -VGB,en,TRUE -VIR,en,FALSE -VNM,en,FALSE -VUT,en,FALSE -WLF,fr,TRUE -WSM,en,FALSE -YEM,en,FALSE -ZAF,en,FALSE -ZMB,en,FALSE -ZWE,en,FALSE diff --git a/tools/fraReport/fra_countries.csv b/tools/fraReport/fra_countries.csv deleted file mode 100644 index 7fc3d284fa..0000000000 --- a/tools/fraReport/fra_countries.csv +++ /dev/null @@ -1,237 +0,0 @@ -country_iso,list_name_en,full_name_en,language -"ABW","Aruba","Aruba","en" -"AFG","Afghanistan","The Islamic Republic of Afghanistan","en" -"AGO","Angola","the Republic of Angola","en" -"AIA","Anguilla","Anguilla","en" -"ALB","Albania","the Republic of Albania","en" -"AND","Andorra","the Principality of Andorra","en" -"ARE","United Arab Emirates","the United Arab Emirates","en" -"ARG","Argentina","the Argentine Republic","en" -"ARM","Armenia","the Republic of Armenia","en" -"ASM","American Samoa","American Samoa","en" -"ATG","Antigua and Barbuda","Antigua and Barbuda","en" -"AUS","Australia","Australia","en" -"AUT","Austria","the Republic of Austria","en" -"AZE","Azerbaijan","the Republic of Azerbaijan","en" -"BDI","Burundi","the Republic of Burundi","en" -"BEL","Belgium","the Kingdom of Belgium","en" -"BEN","Benin","the Republic of Benin","en" -"BES","Bonaire, Sint Eustatius and Saba","Bonaire, Sint Eustatius and Saba","en" -"BFA","Burkina Faso","Burkina Faso","en" -"BGD","Bangladesh","the People's Republic of Bangladesh","en" -"BGR","Bulgaria","the Republic of Bulgaria","en" -"BHR","Bahrain","the Kingdom of Bahrain","en" -"BHS","Bahamas","the Commonwealth of the Bahamas","en" -"BIH","Bosnia and Herzegovina","Bosnia and Herzegovina","en" -"BLM","Saint Barthélemy","Saint Barthélemy","en" -"BLR","Belarus","the Republic of Belarus","en" -"BLZ","Belize","Belize","en" -"BMU","Bermuda","Bermuda","en" -"BOL","Bolivia (Plurinational State of)","the Plurinational State of Bolivia","en" -"BRA","Brazil","the Federative Republic of Brazil","en" -"BRB","Barbados","Barbados","en" -"BRN","Brunei Darussalam","Brunei Darussalam","en" -"BTN","Bhutan","the Kingdom of Bhutan","en" -"BWA","Botswana","the Republic of Botswana","en" -"CAF","Central African Republic","the Central African Republic","en" -"CAN","Canada","Canada","en" -"CHE","Switzerland","the Swiss Confederation","en" -"CHL","Chile","the Republic of Chile","en" -"CHN","China","the People's Republic of China","en" -"CIV","Côte d'Ivoire","the Republic of Côte d'Ivoire","en" -"CMR","Cameroon","the Republic of Cameroon","en" -"COD","Democratic Republic of the Congo","the Democratic Republic of the Congo","en" -"COG","Congo","the Republic of the Congo","en" -"COK","Cook Islands","the Cook Islands","en" -"COL","Colombia","the Republic of Colombia","en" -"COM","Comoros","the Union of the Comoros","en" -"CPV","Cabo Verde","Republic of Cabo Verde","en" -"CRI","Costa Rica","the Republic of Costa Rica","en" -"CUB","Cuba","the Republic of Cuba","en" -"CUW","Curaçao","Curaçao","en" -"CYM","Cayman Islands","Cayman Islands","en" -"CYP","Cyprus","the Republic of Cyprus","en" -"CZE","Czechia","the Czech Republic","en" -"DEU","Germany","the Federal Republic of Germany","en" -"DJI","Djibouti","the Republic of Djibouti","en" -"DMA","Dominica","the Commonwealth of Dominica","en" -"DNK","Denmark","the Kingdom of Denmark","en" -"DOM","Dominican Republic","the Dominican Republic","en" -"DZA","Algeria","the People's Democratic Republic of Algeria","en" -"ECU","Ecuador","the Republic of Ecuador","en" -"EGY","Egypt","the Arab Republic of Egypt","en" -"ERI","Eritrea","the State of Eritrea","en" -"ESH","Western Sahara","Western Sahara","en" -"ESP","Spain","the Kingdom of Spain","en" -"EST","Estonia","the Republic of Estonia","en" -"ETH","Ethiopia","the Federal Democratic Republic of Ethiopia","en" -"FIN","Finland","the Republic of Finland","en" -"FJI","Fiji","the Republic of Fiji","en" -"FLK","Falkland Islands (Malvinas)","the Falkland Islands (Malvinas)","en" -"FRA","France","the French Republic","en" -"FRO","Faroe Islands (Associate Member)","Faroe Islands","en" -"FSM","Micronesia (Federated States of)","the Federated States of Micronesia","en" -"GAB","Gabon","the Gabonese Republic","en" -"GBR","United Kingdom","the United Kingdom of Great Britain and Northern Ireland","en" -"GEO","Georgia","Georgia","en" -"GGY","Guernsey","Bailiwick of Guernsey","en" -"GHA","Ghana","the Republic of Ghana","en" -"GIB","Gibraltar","Gibraltar","en" -"GIN","Guinea","the Republic of Guinea","en" -"GLP","Guadeloupe","Guadeloupe","en" -"GMB","Gambia","the Republic of the Gambia","en" -"GNB","Guinea-Bissau","the Republic of Guinea-Bissau","en" -"GNQ","Equatorial Guinea","the Republic of Equatorial Guinea","en" -"GRC","Greece","the Hellenic Republic","en" -"GRD","Grenada","Grenada","en" -"GRL","Greenland","Greenland","en" -"GTM","Guatemala","the Republic of Guatemala","en" -"GUF","French Guyana","French Guyana","en" -"GUM","Guam","Guam","en" -"GUY","Guyana","the Republic of Guyana","en" -"HND","Honduras","the Republic of Honduras","en" -"HRV","Croatia","the Republic of Croatia","en" -"HTI","Haiti","the Republic of Haiti","en" -"HUN","Hungary","Hungary","en" -"IDN","Indonesia","the Republic of Indonesia","en" -"IMN","Isle of Man","Isle of Man","en" -"IND","India","the Republic of India","en" -"IRL","Ireland","Ireland","en" -"IRN","Iran (Islamic Republic of)","the Islamic Republic of Iran","en" -"IRQ","Iraq","the Republic of Iraq","en" -"ISL","Iceland","the Republic of Iceland","en" -"ISR","Israel","the State of Israel","en" -"ITA","Italy","the Republic of Italy","en" -"JAM","Jamaica","Jamaica","en" -"JEY","Jersey","Jersey","en" -"JOR","Jordan","the Hashemite Kingdom of Jordan","en" -"JPN","Japan","Japan","en" -"KAZ","Kazakhstan","the Republic of Kazakhstan","en" -"KEN","Kenya","the Republic of Kenya","en" -"KGZ","Kyrgyzstan","the Kyrgyz Republic","en" -"KHM","Cambodia","the Kingdom of Cambodia","en" -"KIR","Kiribati","the Republic of Kiribati","en" -"KNA","Saint Kitts and Nevis","Saint Kitts and Nevis","en" -"KOR","Republic of Korea","the Republic of Korea","en" -"KWT","Kuwait","the State of Kuwait","en" -"LAO","Lao People's Democratic Republic","the Lao People's Democratic Republic","en" -"LBN","Lebanon","the Lebanese Republic","en" -"LBR","Liberia","the Republic of Liberia","en" -"LBY","Libya","State of Libya","en" -"LCA","Saint Lucia","Saint Lucia","en" -"LIE","Liechtenstein","the Principality of Liechtenstein","en" -"LKA","Sri Lanka","the Democratic Socialist Republic of Sri Lanka","en" -"LSO","Lesotho","the Kingdom of Lesotho","en" -"LTU","Lithuania","the Republic of Lithuania","en" -"LUX","Luxembourg","the Grand Duchy of Luxembourg","en" -"LVA","Latvia","the Republic of Latvia","en" -"MAF","Saint-Martin (French Part)","Saint-Martin (French Part)","en" -"MAR","Morocco","the Kingdom of Morocco","en" -"MCO","Monaco","the Principality of Monaco","en" -"MDA","Republic of Moldova","the Republic of Moldova","en" -"MDG","Madagascar","the Republic of Madagascar","en" -"MDV","Maldives","the Republic of Maldives","en" -"MEX","Mexico","the United Mexican States","en" -"MHL","Marshall Islands","the Republic of the Marshall Islands","en" -"MKD","North Macedonia","North Macedonia","en" -"MLI","Mali","the Republic of Mali","en" -"MLT","Malta","the Republic of Malta","en" -"MMR","Myanmar","the Republic of the Union of Myanmar","en" -"MNE","Montenegro","Montenegro","en" -"MNG","Mongolia","Mongolia","en" -"MNP","Northern Mariana Islands","The Commonwealth of the Northern Mariana Islands","en" -"MOZ","Mozambique","the Republic of Mozambique","en" -"MRT","Mauritania","the Islamic Republic of Mauritania","en" -"MSR","Montserrat","Montserrat","en" -"MTQ","Martinique","Martinique","en" -"MUS","Mauritius","the Republic of Mauritius","en" -"MWI","Malawi","the Republic of Malawi","en" -"MYS","Malaysia","Malaysia","en" -"MYT","Mayotte","Mayotte","en" -"NAM","Namibia","the Republic of Namibia","en" -"NCL","New Caledonia","New Caledonia","en" -"NER","Niger","the Republic of the Niger","en" -"NFK","Norfolk Island","Territory of Norfolk Island","en" -"NGA","Nigeria","the Federal Republic of Nigeria","en" -"NIC","Nicaragua","the Republic of Nicaragua","en" -"NIU","Niue","Niue","en" -"NLD","Netherlands","the Kingdom of the Netherlands","en" -"NOR","Norway","the Kingdom of Norway","en" -"NPL","Nepal","the Federal Democratic Republic of Nepal","en" -"NRU","Nauru","the Republic of Nauru","en" -"NZL","New Zealand","New Zealand","en" -"OMN","Oman","the Sultanate of Oman","en" -"PAK","Pakistan","the Islamic Republic of Pakistan","en" -"PAN","Panama","the Republic of Panama","en" -"PCN","Pitcairn Islands","Pitcairn Islands","en" -"PER","Peru","the Republic of Peru","en" -"PHL","Philippines","the Republic of the Philippines","en" -"PLW","Palau","the Republic of Palau","en" -"PNG","Papua New Guinea","Independent State of Papua New Guinea","en" -"POL","Poland","the Republic of Poland","en" -"PRI","Puerto Rico","the Commonwealth of Puerto Rico","en" -"PRK","Democratic People's Republic of Korea","the Democratic People's Republic of Korea","en" -"PRT","Portugal","the Portuguese Republic","en" -"PRY","Paraguay","the Republic of Paraguay","en" -"PSE","Palestine","Palestine","en" -"PYF","French Polynesia","French Polynesia","en" -"QAT","Qatar","the State of Qatar","en" -"REU","Réunion","Réunion","en" -"ROU","Romania","Romania","en" -"RUS","Russian Federation","the Russian Federation","en" -"RWA","Rwanda","the Republic of Rwanda","en" -"SAU","Saudi Arabia","the Kingdom of Saudi Arabia","en" -"SDN","Sudan","the Republic of the Sudan","en" -"SEN","Senegal","the Republic of Senegal","en" -"SGP","Singapore","the Republic of Singapore","en" -"SHN","Saint Helena, Ascension and Tristan da Cunha","Saint Helena, Ascension and Tristan da Cunha","en" -"SJM","Svalbard and Jan Mayen Islands","Svalbard and Jan Mayen Islands","en" -"SLB","Solomon Islands","Solomon Islands","en" -"SLE","Sierra Leone","the Republic of Sierra Leone","en" -"SLV","El Salvador","the Republic of El Salvador","en" -"SMR","San Marino","the Republic of San Marino","en" -"SOM","Somalia","the Federal Republic of Somalia","en" -"SPM","Saint Pierre and Miquelon","Saint Pierre and Miquelon","en" -"SRB","Serbia","the Republic of Serbia","en" -"SSD","South Sudan","the Republic of South Sudan","en" -"STP","Sao Tome and Principe","the Democratic Republic of Sao Tome and Principe","en" -"SUR","Suriname","the Republic of Suriname","en" -"SVK","Slovakia","the Slovak Republic","en" -"SVN","Slovenia","the Republic of Slovenia","en" -"SWE","Sweden","the Kingdom of Sweden","en" -"SWZ","Eswatini","the Kingdom of Eswatini","en" -"SXM","Sint Maarten (Dutch part)","Sint Maarten (Dutch part)","en" -"SYC","Seychelles","the Republic of Seychelles","en" -"SYR","Syrian Arab Republic","the Syrian Arab Republic","en" -"TCA","Turks and Caicos Islands","Turks and Caicos Islands","en" -"TCD","Chad","the Republic of Chad","en" -"TGO","Togo","the Togolese Republic","en" -"THA","Thailand","the Kingdom of Thailand","en" -"TJK","Tajikistan","the Republic of Tajikistan","en" -"TKL","Tokelau (Associate Member)","Tokelau","en" -"TKM","Turkmenistan","Turkmenistan","en" -"TLS","Timor-Leste","the Democratic Republic of Timor-Leste","en" -"TON","Tonga","the Kingdom of Tonga","en" -"TTO","Trinidad and Tobago","the Republic of Trinidad and Tobago","en" -"TUN","Tunisia","the Republic of Tunisia","en" -"TUR","Turkey","the Republic of Turkey","en" -"TUV","Tuvalu","Tuvalu","en" -"TZA","United Republic of Tanzania","the United Republic of Tanzania","en" -"UGA","Uganda","the Republic of Uganda","en" -"UKR","Ukraine","Ukraine","en" -"URY","Uruguay","the Eastern Republic of Uruguay","en" -"USA","United States of America","the United States of America","en" -"UZB","Uzbekistan","the Republic of Uzbekistan","en" -"VAT","Holy See","Holy see","en" -"VCT","Saint Vincent and the Grenadines","Saint Vincent and the Grenadines","en" -"VEN","Venezuela (Bolivarian Republic of)","the Bolivarian Republic of Venezuela","en" -"VGB","British Virgin Islands","the British Virgin Islands","en" -"VIR","United States Virgin Islands","the United States Virgin Islands","en" -"VNM","Viet Nam","the Socialist Republic of Viet Nam","en" -"VUT","Vanuatu","the Republic of Vanuatu","en" -"WLF","Wallis and Futuna Islands","Wallis and Futuna Islands","en" -"WSM","Samoa","the Independent State of Samoa","en" -"YEM","Yemen","the Republic of Yemen","en" -"ZAF","South Africa","the Republic of South Africa","en" -"ZMB","Zambia","the Republic of Zambia","en" -"ZWE","Zimbabwe","the Republic of Zimbabwe","en" diff --git a/tools/generatePasswordHash.ts b/tools/generatePasswordHash.ts deleted file mode 100644 index f079f05291..0000000000 --- a/tools/generatePasswordHash.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { passwordHash } from '../src/server/api/auth/utils/passwordUtils' - -if (process.argv[2]) passwordHash(process.argv[2]).then(console.log) -else console.log('usage: ts-node generatePasswordHash.ts \nEx: ts-node generatePasswordHash.ts 123') -export {} diff --git a/tools/initialCountryConfigFileAssembler.js b/tools/initialCountryConfigFileAssembler.js deleted file mode 100644 index 55e0b8f29c..0000000000 --- a/tools/initialCountryConfigFileAssembler.js +++ /dev/null @@ -1,30 +0,0 @@ -const R = require('ramda') -const faoStat = require('./faoStat') -const domainMapping = require('../server/biomassStock/countriesDomainMapping') -const fs = require('fs') - -if (process.argv.length < 4) { - console.log(`Usage: ${process.argv[0]} `) - process.exit() -} - -const faoStatCsvFile = process.argv[2] -console.log('reading file', faoStatCsvFile) -const outputFile = process.argv[3] - -const domains = R.reduce( - (result, row) => R.assocPath([row.countryIso, 'domain'], row.domain, result), - {}, - domainMapping -) - -const handleFaoStatValues = faoStatValues => { - const merged = R.mergeDeepLeft(faoStatValues, domains) - fs.writeFileSync(outputFile, JSON.stringify(merged), 'utf8') - console.log('Wrote merged faostat and domain mappings to', outputFile) -} - -faoStat.getFaostatValues(faoStatCsvFile) - .then(handleFaoStatValues) - .catch(err => console.log('Error: ', err)) - diff --git a/tools/panEuropeanQualitativeQuestionnaire.js b/tools/panEuropeanQualitativeQuestionnaire.js deleted file mode 100644 index ed665f6318..0000000000 --- a/tools/panEuropeanQualitativeQuestionnaire.js +++ /dev/null @@ -1,52 +0,0 @@ -const Promise = require('bluebird') -const R = require('ramda') -const countryConfig = require('../server/controller/country/countryConfig') - -const fs = Promise.promisifyAll(require('fs')) -const csv = Promise.promisifyAll(require('csv')) - -const exampleUsage = - 'node faostatUpdater.js exampleData/panEuropeanQualitativeQuestionnaire.csv /tmp/countryConfigWithPanEuropeanQualitativeQuestionnaire.json' - -if (process.argv.length < 4) { - console.log(`Usage: ${process.argv[0]} `) - console.log(`example:\n${exampleUsage}`) - process.exit() -} - -const climaticDomainCsvFile = process.argv[2] -console.log('reading file', climaticDomainCsvFile) -const outputFile = process.argv[3] - -const update = async (panEuropeanQualitativeQuestionnaireCsvFile, outputFile) => { - try { - const rawPanEuropeanQualitativeQuestionnaireData = await fs.readFileAsync( - panEuropeanQualitativeQuestionnaireCsvFile, - { encoding: 'utf-8' } - ) - const parsedPanEuropeanQualitativeQuestionnaireData = await csv.parseAsync( - rawPanEuropeanQualitativeQuestionnaireData - ) - const panEuropeanQualitativeQuestionnaireData = R.slice(1, undefined, parsedPanEuropeanQualitativeQuestionnaireData) - const countryPanEuropeanQualitativeQuestionnaireData = R.reduce( - (result, row) => { - const panEuropean = { - qualitativeQuestionnaireUrl: row[3], - } - return R.assoc(row[0], { panEuropean }, result) - }, - {}, - panEuropeanQualitativeQuestionnaireData - ) - - const merged = R.mergeDeepRight(countryConfig, countryPanEuropeanQualitativeQuestionnaireData) - await fs.writeFileAsync(outputFile, JSON.stringify(merged, null, ' '), 'utf8') - - console.log('Wrote merged values into: ', outputFile) - console.log('You should manually copy them over the countryConfig values') - } catch (e) { - console.log(e) - } -} - -update(climaticDomainCsvFile, outputFile) diff --git a/tools/previousFraValuesFrom2015Updater.js b/tools/previousFraValuesFrom2015Updater.js deleted file mode 100644 index 3eb141dabb..0000000000 --- a/tools/previousFraValuesFrom2015Updater.js +++ /dev/null @@ -1,39 +0,0 @@ -const R = require('ramda') -const promise = require('bluebird') -const countryConfig = require('../server/controller/country/countryConfig') -const fs = promise.promisifyAll(require('fs')) -const csv = promise.promisifyAll(require('csv')) - -const exampleUsage = - 'node previousFraValuesFrom2015Updater.js exampleData/fra-2015-forest-areas.csv /tmp/countryConfigUpdatedWithFra2015ForestAreas.json' - -if (process.argv.length < 4) { - console.log(`Usage: ${process.argv[0]} `) - console.log(`example:\n${exampleUsage}`) - process.exit() -} - -const previousFraFile = process.argv[2] -console.log('reading file', previousFraFile) -const outputFile = process.argv[3] - -const update = async (previousFraFile, outputFile) => { - try { - const rawData = await fs.readFileAsync(previousFraFile, { encoding: 'utf-8' }) - const parsedData = await csv.parseAsync(rawData) - const years = parsedData[1].slice(1) - const previousFraValuePairs = R.map( - (row) => [row[0], { fra2015ForestAreas: R.fromPairs(R.zip(years, row.slice(1))) }], - parsedData.slice(2) - ) - const previousFraValues = R.fromPairs(previousFraValuePairs) - const merged = R.mergeDeepLeft(previousFraValues, countryConfig) - fs.writeFileSync(outputFile, JSON.stringify(merged, null, ' '), 'utf8') - console.log('Wrote merged values into: ', outputFile) - console.log('You should manually copy them over the countryConfig values') - } catch (e) { - console.log(e) - } -} - -update(previousFraFile, outputFile)