# Construct work engagements as org:Membership with tm: vocabulary.
# Replaces migrants:work with org:Membership, using org:member and
# org:organization from the W3C Organization Ontology.

PREFIX rdfs:     <http://www.w3.org/2000/01/rdf-schema#>
PREFIX org:      <http://www.w3.org/ns/org#>
PREFIX tm:       <https://daniel.degu.cl/ontologies/theatre-migrants/>
PREFIX migrants: <http://example.org/migrants/>
PREFIX workp:    <http://example.org/migrants/work#>

CONSTRUCT {
  ?s a org:Membership .
  ?s org:member ?person .
  ?s org:organization ?organisation .
  ?s tm:workLocation ?location .
  ?s tm:secondaryOrganisation ?org2 .
  ?s tm:profession ?profession .
  ?s tm:secondaryProfession ?profession2 .
  ?s tm:tertiaryProfession ?profession3 .
  ?s tm:employmentType ?emplType .
  ?s tm:employment ?employment .
  ?s rdfs:comment ?comment .
  ?s tm:dateStartMin ?dsMin .
  ?s tm:dateStartMax ?dsMax .
  ?s tm:dateEndMin ?deMin .
  ?s tm:dateEndMax ?deMax .
  ?s tm:dateStartFuzzy ?dsFuzzy .
  ?s tm:dateEndFuzzy ?deFuzzy .
}
WHERE {
  ?s a migrants:work .
  OPTIONAL { ?s workp:ref-IDPerson ?person }
  OPTIONAL { ?s workp:ref-IDOrganisation ?organisation }
  OPTIONAL { ?s workp:ref-IDLocation ?location }
  OPTIONAL { ?s workp:ref-IDOrganisation2 ?org2 }
  OPTIONAL { ?s workp:Profession ?profession }
  OPTIONAL { ?s workp:Profession2 ?profession2 }
  OPTIONAL { ?s workp:Profession3 ?profession3 }
  OPTIONAL { ?s workp:EmploymentType ?emplType }
  OPTIONAL { ?s workp:Employment ?employment }
  OPTIONAL { ?s workp:comment ?comment }
  OPTIONAL { ?s workp:DateStart_Min ?dsMin }
  OPTIONAL { ?s workp:DateStart_Max ?dsMax }
  OPTIONAL { ?s workp:DateEnd_Min ?deMin }
  OPTIONAL { ?s workp:DateEnd_Max ?deMax }
  OPTIONAL { ?s workp:DateStart_Fuzzy ?dsFuzzy }
  OPTIONAL { ?s workp:DateEnd_Fuzzy ?deFuzzy }
}
