#############################################
# MaterialData (io.catenax.material_data:1.0.0) YARRRML
# JSON -> RDF mapping (pattern version)
#############################################

prefixes:
  data: "https://dataportal.material-digital.de/dataset/91c7f4e8-5cdd-45aa-b006-de59efe6b269/resource/bcbfac28-3ad8-41a6-92ef-bbc6ce96096e/download/materialdata-sample.json"
  method: "https://dataportal.material-digital.de/dataset/91c7f4e8-5cdd-45aa-b006-de59efe6b269/resource/9b91540a-5de4-45a9-9dae-f3e9ea96ac3f/download/io.catenax.material_data_1.0.0.ttl"
  samm: "urn:samm:org.eclipse.esmf.samm:meta-model:2.1.0#"
  samm-c: "urn:samm:org.eclipse.esmf.samm:characteristic:2.1.0#"
  samm-e: "urn:samm:org.eclipse.esmf.samm:entity:2.1.0#"
  unit: "urn:samm:org.eclipse.esmf.samm:unit:2.1.0#"
  xsd: "http://www.w3.org/2001/XMLSchema#"
  cx: "urn:samm:io.catenax.material_data:1.0.0#"
  urn-uuid: "urn:uuid:"
  rdf: "http://www.w3.org/1999/02/22-rdf-syntax-ns#"

base: '#'

sources:
  root:
    access: "https://dataportal.material-digital.de/dataset/91c7f4e8-5cdd-45aa-b006-de59efe6b269/resource/bcbfac28-3ad8-41a6-92ef-bbc6ce96096e/download/materialdata-sample.json"
    iterator: '$'
    referenceFormulation: jsonpath

mappings:
  # ----------------------------
  # Root Aspect: MaterialData
  # ----------------------------
  MaterialData:
    source: [root]
    # No explicit ID in JSON -> mint deterministic subject from materialIdentifier
    s: urn-uuid:material-$(.materialInformation.materialIdentifier)
    po:
      - [rdf:type, cx:MaterialData]

      # link to sub-entities (minted IRIs)
      - [cx:materialInformation, urn-uuid:materialInformation-$(.materialInformation.materialIdentifier)~iri]
      - [cx:thermophysicalProperty, urn-uuid:thermo-$(.materialInformation.materialIdentifier)~iri]
      - [cx:mechanicalProperty, urn-uuid:mech-$(.materialInformation.materialIdentifier)~iri]
      - [cx:physicalProperty, urn-uuid:phys-$(.materialInformation.materialIdentifier)~iri]

      # emit sub-entities via child mappings
      - p: cx:materialInformation
        o:
          mapping: MaterialInformation
          condition:
            function: equal
            parameters: [[str1, "1"], [str2, "1"]]

      - p: cx:thermophysicalProperty
        o:
          mapping: ThermophysicalProperty
          condition:
            function: equal
            parameters: [[str1, "1"], [str2, "1"]]

      - p: cx:mechanicalProperty
        o:
          mapping: MechanicalProperty
          condition:
            function: equal
            parameters: [[str1, "1"], [str2, "1"]]

      - p: cx:physicalProperty
        o:
          mapping: PhysicalProperty
          condition:
            function: equal
            parameters: [[str1, "1"], [str2, "1"]]

  # ----------------------------
  # 1..1: materialInformation
  # Entity: :MaterialInformationEntity
  # ----------------------------
  MaterialInformation:
    source: [root]
    s: urn-uuid:materialInformation-$(.materialInformation.materialIdentifier)
    po:
      - [rdf:type, cx:MaterialInformationEntity]
      - [cx:materialName, $(.materialInformation.materialName)]
      - [cx:materialIdentifier, $(.materialInformation.materialIdentifier)]

  # ----------------------------
  # 1..1: thermophysicalProperty
  # Entity: :ThermophysicalPropertyEntity
  # ----------------------------
  ThermophysicalProperty:
    source: [root]
    s: urn-uuid:thermo-$(.materialInformation.materialIdentifier)
    po:
      - [rdf:type, cx:ThermophysicalPropertyEntity]
      - [cx:humidity, $(.thermophysicalProperty.humidity)]
      - [cx:glassTransitionTemperature, $(.thermophysicalProperty.glassTransitionTemperature)]
      - [cx:meltingTemperature, $(.thermophysicalProperty.meltingTemperature)]
      - [cx:waterAbsorption, $(.thermophysicalProperty.waterAbsorption)]
      - [cx:pVT, $(.thermophysicalProperty.pVT)]

      # nested entity: linearThermalExpansionCoefficient
      - [cx:linearThermalExpansionCoefficient, urn-uuid:ltec-$(.materialInformation.materialIdentifier)~iri]

      - p: cx:linearThermalExpansionCoefficient
        o:
          mapping: LinearThermalExpansionCoefficient
          condition:
            function: equal
            parameters: [[str1, "1"], [str2, "1"]]

  # ----------------------------
  # 1..1: thermophysicalProperty.linearThermalExpansionCoefficient
  # Entity: :LinearThermalExpansionCoefficientEntity
  # ----------------------------
  LinearThermalExpansionCoefficient:
    source: [root]
    s: urn-uuid:ltec-$(.materialInformation.materialIdentifier)
    po:
      - [rdf:type, cx:LinearThermalExpansionCoefficientEntity]
      - [cx:linearThermalExpansionCoefficientParallel, $(.thermophysicalProperty.linearThermalExpansionCoefficient.linearThermalExpansionCoefficientParallel)]
      - [cx:linearThermalExpansionCoefficientTransverse, $(.thermophysicalProperty.linearThermalExpansionCoefficient.linearThermalExpansionCoefficientTransverse)]

  # ----------------------------
  # 1..1: mechanicalProperty
  # Entity: :MechanicalPropertyEntity
  # ----------------------------
  MechanicalProperty:
    source: [root]
    s: urn-uuid:mech-$(.materialInformation.materialIdentifier)
    po:
      - [rdf:type, cx:MechanicalPropertyEntity]
      - [cx:flexuralStrength, $(.mechanicalProperty.flexuralStrength)]
      - [cx:impactStrength, $(.mechanicalProperty.impactStrength)]
      - [cx:youngsModulus, $(.mechanicalProperty.youngsModulus)]
      - [cx:strainAtBreak, $(.mechanicalProperty.strainAtBreak)]
      - [cx:stressAtBreak, $(.mechanicalProperty.stressAtBreak)]
      - [cx:flexuralModulus, $(.mechanicalProperty.flexuralModulus)]

  # ----------------------------
  # 1..1: physicalProperty
  # Entity: :PhysicalPropertyEntity
  # ----------------------------
  PhysicalProperty:
    source: [root]
    s: urn-uuid:phys-$(.materialInformation.materialIdentifier)
    po:
      - [rdf:type, cx:PhysicalPropertyEntity]
      - [cx:density, $(.physicalProperty.density)]
      - [cx:viscosity, $(.physicalProperty.viscosity)]