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}> rdfs:label ?label .
<${subjectURL}> a ?type .
<${subjectURL}> crm:P2_has_type ?atypeLabel .

<${subjectURL}> crmpe:PP2_provided_by ?provider .
?provider crm:P1_is_identified_by ?providerTitle  .
?provider rdfs:label  ?providerLabel .
?provider crm:P3_has_note ?providerDescr .
?provider crm:P76_has_contact_point ?contactpoint .
?contactpoint crm:P2_has_type ?contactpointType .
?contactpoint rdfs:label ?contactpointLabel .
?contactpointType rdfs:label ?contactpointTypeLabel .

<${subjectURL}> crmpe:PP4_hosts_object ?object .

<${subjectURL}> crmpe:PP28_has_designated_access_point ?accesspoint .
<${subjectURL}> crmpe:PP1i_is_currently_offered_by ?offerer .
<${subjectURL}> crmpe:PP45_has_competency ?competenceLabel .

<${subjectURL}> crmpe:PP31_uses_curation_plan ?curationplan .

<${subjectURL}> crmpe:PP29_uses_access_protocol ?protocol .
?protocol rdfs:label ?protocolLabel .

<${subjectURL}> crmpe:PP32_curates ?object2 .

<${subjectURL}> crmpe:PP15_delivers_on_request ?delivered .
<${subjectURL}> crmpe:PP14_runs_on_request ?ran .

<${subjectURL}> crmpe:PP42_has_declarative_time ?declTime .

<${subjectURL}> <availability> ?availabilityLabel .
<${subjectURL}> <activitytype> ?activitytypeLabel .

 <${subjectURL}> crm:P16_used_specific_object ?Conditions_of_Use .
 ?Conditions_of_Use a crm:E30_Right .
 ?Conditions_of_Use crm:P3_has_note ?Conditions_of_Use_Note .
 ?Conditions_of_Use crm:P2_has_type ?Conditions_of_Use_Type .
 ?Conditions_of_Use_Type rdfs:label ?Conditions_of_Use_Type_label .

}
WHERE {
 <${subjectURL}> a crmpe:PE1_Service .
 <${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 .
 FILTER NOT EXISTS { ?titleRes a crm:E51_Contact_Point }
}
UNION{
 <${subjectURL}> crm:P3_has_note ?description .
}
UNION{
 <${subjectURL}> rdfs:label ?label .
}
 UNION{
 <${subjectURL}> crm:P2_has_type ?atype .
 ?atype rdfs:label ?atypeLabel .
}
UNION{
 <${subjectURL}> crm:P2_has_type ?availability .
 ?availability rdfs:label ?availabilityLabel .
 FILTER(STRSTARTS(STR(?availability), "http://ariadneplus.d4science.org/handle/AriadnePlus/REG/Concept/availabilitytype"))
}
UNION{
 <${subjectURL}> crm:P2_has_type ?activitytype .
 ?activitytype rdfs:label ?activitytypeLabel .
 FILTER(STRSTARTS(STR(?activitytype), "http://ariadneplus.d4science.org/handle/AriadnePlus/REG/Concept/activitytype"))
}
UNION {
<${subjectURL}> crmpe:PP2_provided_by ?provider .
 ?provider crm:P1_is_identified_by ?providerTitleRes .
 ?providerTitleRes rdfs:label ?providerTitle .
}
UNION {
<${subjectURL}> crmpe:PP2_provided_by ?provider .
 ?provider crm:P3_has_note ?providerDescr .
}
UNION {
<${subjectURL}> crmpe:PP2_provided_by ?provider .
 ?provider rdfs:label ?providerLabel .
}
UNION {
<${subjectURL}> crmpe:PP2_provided_by ?provider .
 ?provider crm:P76_has_contact_point ?contactpoint .
?contactpoint rdfs:label ?contactpointLabel .
}
UNION {
<${subjectURL}> crmpe:PP2_provided_by ?provider .
 ?provider crm:P76_has_contact_point ?contactpoint .
 ?contactpoint crm:P2_has_type ?contactpointType .
 ?contactpointType rdfs:label ?contactpointTypeLabel .}
UNION { <${subjectURL}> crmpe:PP28_has_designated_access_point ?accesspoint .}
UNION { ?accesspoint crmpe:PP28i_is_designated_access_point_of <${subjectURL}> .}
UNION { <${subjectURL}> crmpe:PP1i_is_currently_offered_by ?offerer .}
UNION { ?offerer  crmpe:PP1_currently_offers <${subjectURL}> .}
UNION {
 <${subjectURL}> crmpe:PP45_has_competency ?competence .
  ?competence rdfs:label ?competenceLabel .}
UNION { <${subjectURL}> crmpe:PP4_hosts_object ?object .}
UNION { ?object crmpe:PP4i_is_object_hosted_by <${subjectURL}> .}

UNION {<${subjectURL}> crmpe:PP31_uses_curation_plan ?curationplan .}
UNION { ?curationplan crmpe:PP31i_is_curation_plan_used_by <${subjectURL}> .}
UNION {
   <${subjectURL}> crmpe:PP29_uses_access_protocol ?protocol .
   ?protocol rdfs:label ?protocolLabel .}
UNION {
	?protocol crmpe:PP29i_is_access_protocol_used_by <${subjectURL}> .
	?protocol rdfs:label ?protocolLabel .}
UNION { <${subjectURL}> crmpe:PP32_curates ?object2 .}
UNION { ?object2 crmpe:PP32i_is_curated_by <${subjectURL}> .}
UNION { <${subjectURL}> crmpe:PP15_delivers_on_request ?delivered .}
UNION { ?delivered crmpe:PP15i_is_delivered_by <${subjectURL}>.}
UNION { <${subjectURL}> crmpe:PP14_runs_on_request ?ran .}
UNION { ?ran crmpe:PP14i_is_run_by <${subjectURL}>.}
 UNION {
 <${subjectURL}> crmpe:PP42_has_declarative_time ?declTime .}
UNION {
 <${subjectURL}> crm:P16_used_specific_object ?Conditions_of_Use .
 ?Conditions_of_Use a crm:E30_Right .
 ?Conditions_of_Use crm:P3_has_note ?Conditions_of_Use_Note .
}
UNION {
 <${subjectURL}> crm:P16_used_specific_object ?Conditions_of_Use .
 ?Conditions_of_Use a crm:E30_Right .
 ?Conditions_of_Use crm:P2_has_type ?Conditions_of_Use_Type .
 ?Conditions_of_Use_Type rdfs:label ?Conditions_of_Use_Type_label .
}

}

