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

prefixes:
  data: "https://dataportal.material-digital.de/dataset/2347d95a-4588-44da-9e94-26330bcbf7c5/resource/4a3e6125-0416-490b-995f-e59ef6cb677b/download/urn_uuid_c61741ef-830c-4681-a7f3-5862176ab544-urn_uuid_30e156ef-0e5b-4bf7-9812-c7531cc72d8d.json"
  method: "https://dataportal.material-digital.de/dataset/2347d95a-4588-44da-9e94-26330bcbf7c5/resource/bc100a33-a7da-46ce-9a1f-590e9393ef40/download/aspectmodel.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/2347d95a-4588-44da-9e94-26330bcbf7c5/resource/4a3e6125-0416-490b-995f-e59ef6cb677b/download/urn_uuid_c61741ef-830c-4681-a7f3-5862176ab544-urn_uuid_30e156ef-0e5b-4bf7-9812-c7531cc72d8d.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)]