Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

295 semantics with dfr3 curves and mapping #297

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from

Conversation

longshuicy
Copy link
Member

@longshuicy longshuicy commented Jun 5, 2024

This PR:

  • Introducing new field "dataType" to MappingSet to indicate which data types those should be compatible with
  • Add checks when POST mapping set following below steps:
    1. Get listed dataType
    2. Fetch Semantics definition for given dataType and extract all the unique columns
    3. Parse Mapping rules (recursively if hashmap) to see if it is exist in the columns
    4. Gather all the DFR3 curves belong to this mapping and get all the curve parameters; Check if curve parameters exist in the columns
    5. If both mapping rule and DFR3 curve parameter check passed, allow posting to proceed; if not, through "bad request" error

Note that fragility curve parameters have special case of period and num_stories do not need to be a part of the columns; hence excluded in the SemanticsConstants.RESERVED_COLUMNS. There are special logic on pyincore to compute those two fields.


To test:

{
    "name": "Hazus flood fragilities for electric power system",
    "hazardType": "flood",
    "inventoryType": "eletric_facility",
    "dataType":["incore:epfVer2"],
    "mappings": [
        {
            "legacyEntry": {},
            "entry": {
                "Lumberton Flood Electric Power Fragility ID Code": "63641a6c297f7611014c225c"
            },
            "rules": {
                "AND": [
                    "java.lang.String utilfcltyc EQUALS 'ESSL'"
                ]
            }
        },
        {
            "legacyEntry": {},
            "entry": {
                "Lumberton Flood Electric Power Fragility ID Code": "63641a6c297f7611014c225c"
            },
            "rules": {
                "AND": [
                    "java.lang.String utilfcltyc EQUALS 'ESSM'"
                ]
            }
        },
        {
            "legacyEntry": {},
            "entry": {
                "Lumberton Flood Electric Power Fragility ID Code": "63641a6c297f7611014c225c"
            },
            "rules": {
                "AND": [
                    "java.lang.String utilfcltyc EQUALS 'ESSH'"
                ]
            }
        },
        {
            "legacyEntry": {},
            "entry": {
                "Lumberton Flood Electric Power Fragility ID Code": "63641ad0297f7611014c225d"
            },
            "rules": {
                "AND": [
                    "java.lang.String utilfcltyc EQUALS 'EDFLT'"
                ]
            }
        },
        {
            "legacyEntry": {},
            "entry": {
                "Lumberton Flood Electric Power Fragility ID Code": "63641b64297f7611014c225f"
            },
            "rules": {
                "AND": [
                    "java.lang.String utilfcltyc EQUALS 'EPPL'"
                ]
            }
        },
        {
            "legacyEntry": {},
            "entry": {
                "Lumberton Flood Electric Power Fragility ID Code": "63641b64297f7611014c225f"
            },
            "rules": {
                "AND": [
                    "java.lang.String utilfcltyc EQUALS 'EPPM'"
                ]
            }
        },
        {
            "legacyEntry": {},
            "entry": {
                "Lumberton Flood Electric Power Fragility ID Code": "63641b64297f7611014c225f"
            },
            "rules": {
                "AND": [
                    "java.lang.String utilfcltyc EQUALS 'EPPS'"
                ]
            }
        }
    ],
    "creator": "cwang138",
    "owner": "cwang138",
    "mappingEntryKeys": null,
    "spaces": [
        "cwang138",
        "incore"
    ],
    "mappingType": "fragility"
}
  1. Post above mapping should pass ✓
  2. Change dataType to ["ergo:bridgesVer3", "incore:epfVer2"] should also pass ✓
  3. Remove dataType should error out ✗
  4. Change dataType to [ergo:bridgesVer3] should fail ✗
  5. Update one of the fragility ID to 606221fe618178207f6608a1 should fail ✗

@longshuicy longshuicy linked an issue Jun 5, 2024 that may be closed by this pull request
@longshuicy

This comment was marked as resolved.

@longshuicy longshuicy marked this pull request as draft July 10, 2024 21:11
@longshuicy longshuicy changed the title 295 semantics with dfr3 curves and mapping WIP - 295 semantics with dfr3 curves and mapping Jul 10, 2024
@longshuicy longshuicy changed the title WIP - 295 semantics with dfr3 curves and mapping 295 semantics with dfr3 curves and mapping Jul 15, 2024
@longshuicy longshuicy marked this pull request as ready for review July 15, 2024 17:36
@longshuicy longshuicy requested a review from navarroc July 31, 2024 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Semantics with DFR3 curves and mapping
2 participants