DEFINE input:inference 'ariadneplus_rules'

CONSTRUCT {
	<${subjectURL}> crm:P1_is_identified_by ?IDRes .
	?IDRes a crm:E42_Identifier .
	?IDRes rdfs:label ?ID_label .

	<${subjectURL}> crm:P102_has_title ?title .
	<${subjectURL}> crm:P3_has_note ?description .
	<${subjectURL}> a ?type .
    <${subjectURL}> rdfs:label ?label .

     <${subjectURL}> crm:P129_is_about ?about .
     ?about a ?aboutType .
     ?about rdfs:label ?aboutLabel .

    <${subjectURL}> crm:P2_has_type ?e55TypeLabel .

    <${subjectURL}> crmpe:PP8i_is_dataset_hosted_by ?host .
    <${subjectURL}> crmpe:PP32i_is_curated_by ?curator .

	<${subjectURL}> crm:P106i_forms_part_of ?container .
	<${subjectURL}> crm:P106_is_composed_of ?d3 .

	<${subjectURL}> crmpe:PP39_is_metadata_for ?anotherdataset .
	<${subjectURL}> crmpe:PP39i_has_metadata  ?metadata .

	<${subjectURL}> crmpe:PP17i_is_snapshot_of  ?snapshotted .
	<${subjectURL}> crmpe:PP17_has_snapshot ?snapshot .

	<${subjectURL}> <encoding> ?encoding_label .
	<${subjectURL}> <used_software> ?sw .
	<${subjectURL}> <creator> ?creator .
	<${subjectURL}> <creationtime> ?creationtime .
	<${subjectURL}> <updatetime> ?updatetime .
	<${subjectURL}> <custodytime> ?custodytime .
	<${subjectURL}> <custodialhistorynote> ?custodialhistoryNote .
	<${subjectURL}> <curationtime> ?curationtime .
	<${subjectURL}> crm:P72_has_language ?languageLabel .
}
WHERE {
 <${subjectURL}> a crmpe:PE18_Dataset .
 <${subjectURL}> a ?type .
   {
   <${subjectURL}> crm:P1_is_identified_by ?IDRes .
   ?IDRes a crm:E42_Identifier .
   ?IDRes rdfs:label ?ID_label .
   }
   UNION
{
 <${subjectURL}> crm:P1_is_identified_by ?titleRes .
 ?titleRes a crm:E41_Appellation .
 ?titleRes rdfs:label ?title .
}
UNION{
 <${subjectURL}> crm:P3_has_note ?description .
}
UNION{
 <${subjectURL}> rdfs:label ?label .
}
 UNION{
  <${subjectURL}> crm:P129_is_about ?about .
  ?about a ?aboutType .
  ?about rdfs:label ?aboutLabel .
 }
 UNION {
   <${subjectURL}> crm:P2_has_type ?e55Type .
   ?e55Type rdfs:label ?e55TypeLabel .
 }
 UNION{ <${subjectURL}> crmpe:PP8i_is_dataset_hosted_by ?host . }
 UNION{ ?host crmpe:PP8_hosts_dataset <${subjectURL}> . }
 UNION{ <${subjectURL}> crmpe:PP32i_is_curated_by ?curator .}
 UNION{ ?curator crmpe:PP32_curates <${subjectURL}> .}
 UNION{ <${subjectURL}> crmpe:PP32i_is_curated_by ?curator .}
 UNION{ ?curator crmpe:PP32_curates <${subjectURL}> .}
 UNION{ <${subjectURL}> crmpe:PP31_uses_curation_plan ?curationplan .}
 UNION{ <${subjectURL}> crm:P106i_forms_part_of ?container .}
 UNION{ ?container crm:P106_is_composed_of <${subjectURL}> .}
 UNION{ <${subjectURL}> crm:P106_is_composed_of ?d3 .}
 UNION{ ?d3 crm:P106i_forms_part_of <${subjectURL}> .}
 UNION{ <${subjectURL}> crmpe:PP39_is_metadata_for ?anotherdataset .}
 UNION{ ?anotherdataset crmpe:PP39i_has_metadata <${subjectURL}> .}
 UNION{ <${subjectURL}> crmpe:PP39i_has_metadata  ?metadata .}
 UNION{ ?metadata crmpe:PP39_is_metadata_for <${subjectURL}> .}
 UNION{ <${subjectURL}> crmpe:PP17_has_snapshot ?snapshot .}
 UNION{ ?snapshot crmpe:PP17i_is_snapshot_of <${subjectURL}>  .}
 UNION{ <${subjectURL}> crmpe:PP17i_is_snapshot_of  ?snapshotted .}
 UNION{ ?snapshotted crmpe:PP17_has_snapshot <${subjectURL}>  .}
 UNION{
    <${subjectURL}> crm:P94i_was_created_by ?Creation_event .
    ?Creation_event crm:P33_used_specific_technique ?technique .
    ?technique crm:P2_has_type ?techniquetype .
    ?techniquetype rdfs:label ?encoding_label .
 }
UNION{
	<${subjectURL}> crm:P94i_was_created_by ?Creation_event .
	?Creation_event crm:P2_has_type <http://ariadneplus.d4science.org/handle/AriadnePlus/REG/Concept/eventtype/creation> .
    ?Creation_event crmdig:L23_used_software_or_firmware ?sw .
}
UNION{
	<${subjectURL}> crm:P94i_was_created_by ?Creation_event .
	?Creation_event crm:P2_has_type <http://ariadneplus.d4science.org/handle/AriadnePlus/REG/Concept/eventtype/creation> .
    ?Creation_event crm:P14_carried_out_by ?creator .
  }
UNION{
    <${subjectURL}> crm:P94i_was_created_by ?event1 .
    ?event1 crm:P2_has_type <http://ariadneplus.d4science.org/handle/AriadnePlus/REG/Concept/eventtype/creation> .
    ?event1 crm:P4_has_time-span ?timespan .
    ?timespan crm:P81_ongoing_throughout ?creationtime .
   }
UNION{
   <${subjectURL}> crm:P94i_was_created_by ?updateEvent .
   ?updateEvent crm:P2_has_type <http://ariadneplus.d4science.org/handle/AriadnePlus/REG/Concept/eventtype/update> .
   ?updateEvent crm:P4_has_time-span ?timespanUpdate .
   ?timespanUpdate crm:P82_at_some_time_within ?updatetime .
}
UNION{
   <${subjectURL}> crm:P94i_was_created_by ?custodialhistory .
   ?custodialhistory crm:P2_has_type <http://ariadneplus.d4science.org/handle/AriadnePlus/REG/Concept/eventtype/custodialhistory> .
   ?custodialhistory crm:P3_has_note ?custodialhistoryNote .
}
UNION{
   <${subjectURL}> crm:P94i_was_created_by ?custodialhistory .
   ?custodialhistory crm:P2_has_type <http://ariadneplus.d4science.org/handle/AriadnePlus/REG/Concept/eventtype/custodialhistory> .
   ?custodialhistory crm:P4_has_time-span ?timespanCustody .
   ?timespanCustody crm:P82_at_some_time_within ?custodytime .
}
UNION {
	<${subjectURL}> ?hasCurationActivity ?curationActivity .
	?curationActivity a crm:E87_Curation_Activity .
	?curationActivity crm:P4_has_time-span ?curationActivitytimespan .
	?curationActivitytimespan crm:P82_at_some_time_within ?curationtime .
}
UNION {
	<${subjectURL}> crm:P72_has_language ?language .
	?language rdfs:label ?languageLabel .
}
}