From a68ef819ee4cd4eed4f64cfda89962cd990877ca Mon Sep 17 00:00:00 2001 From: brianjlowe Date: Tue, 5 Nov 2013 10:01:46 -0500 Subject: [PATCH 1/6] VIVO-403 safeguards against duplicate context node creation in migration --- .../additions/AdviseeRole.sparql | 4 +++ .../additions/AdvisorRole.sparql | 4 +++ .../additions/Editorship.sparql | 4 +++ .../additions/LeaderRole.sparql | 4 +++ .../additions/MemberRole.sparql | 4 +++ .../additions/grantAdmin.sparql | 5 +++ .../additions/post/awardedDegree.sparql | 4 +++ .../additions/vcard1-0.sparql | 24 ------------- .../additions/vcard1-0a.sparql | 15 ++++++++ .../additions/vcard1-0b.sparql | 15 ++++++++ .../additions/vcard1-0c.sparql | 15 ++++++++ .../additions/vcard1-0d.sparql | 16 +++++++++ .../additions/vcard1-0e.sparql | 16 +++++++++ .../additions/vcard1-0f.sparql | 16 +++++++++ .../additions/vcard1-0g.sparql | 16 +++++++++ .../additions/vcard1-0h.sparql | 16 +++++++++ .../additions/vcard1-0i.sparql | 16 +++++++++ .../additions/vcard1-0j.sparql | 16 +++++++++ .../additions/vcard1-1.sparql | 21 ----------- .../additions/vcard1-1d.sparql | 16 +++++++++ .../additions/vcard1-1e.sparql | 16 +++++++++ .../additions/vcard1-1f.sparql | 16 +++++++++ .../additions/vcard1-1g.sparql | 16 +++++++++ .../additions/vcard1-1h.sparql | 16 +++++++++ .../additions/vcard1-1i.sparql | 16 +++++++++ .../additions/vcard1-1j.sparql | 16 +++++++++ .../additions/vcard1-2.sparql | 21 ----------- .../additions/vcard1-2d.sparql | 16 +++++++++ .../additions/vcard1-2e.sparql | 16 +++++++++ .../additions/vcard1-2f.sparql | 16 +++++++++ .../additions/vcard1-2g.sparql | 16 +++++++++ .../additions/vcard1-2h.sparql | 16 +++++++++ .../additions/vcard1-2i.sparql | 16 +++++++++ .../additions/vcard1-2j.sparql | 16 +++++++++ .../sparqlConstructs/additions/vcard2.sparql | 36 ------------------- .../sparqlConstructs/additions/vcard22.sparql | 5 ++- .../sparqlConstructs/additions/vcard2a.sparql | 17 +++++++++ .../sparqlConstructs/additions/vcard2b.sparql | 13 +++++++ .../sparqlConstructs/additions/vcard2c.sparql | 17 +++++++++ .../sparqlConstructs/additions/vcard2d.sparql | 13 +++++++ .../sparqlConstructs/additions/vcard2e.sparql | 17 +++++++++ .../sparqlConstructs/additions/vcard2f.sparql | 13 +++++++ .../sparqlConstructs/additions/vcard2g.sparql | 17 +++++++++ .../sparqlConstructs/additions/vcard2h.sparql | 13 +++++++ .../sparqlConstructs/additions/vcard2i.sparql | 17 +++++++++ .../sparqlConstructs/additions/vcard2j.sparql | 13 +++++++ .../sparqlConstructs/additions/vcard3.sparql | 5 ++- .../sparqlConstructs/additions/vcard4.sparql | 6 +++- .../sparqlConstructs/additions/vcard5.sparql | 5 ++- .../sparqlConstructs/additions/vcard6.sparql | 6 +++- .../sparqlConstructs/additions/vcard7.sparql | 6 +++- .../sparqlConstructs/additions/vcard8.sparql | 13 ++++--- .../sparqlConstructs/additions/vcard9.sparql | 5 ++- rdf/tbox/filegraph/data-properties.owl | 3 -- 54 files changed, 599 insertions(+), 117 deletions(-) delete mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0a.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0b.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0c.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0d.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0e.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0f.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0g.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0h.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0i.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0j.sparql delete mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1d.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1e.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1f.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1g.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1h.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1i.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1j.sparql delete mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2d.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2e.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2f.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2g.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2h.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2i.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2j.sparql delete mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2a.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2b.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2c.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2d.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2e.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2f.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2g.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2h.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2i.sparql create mode 100644 productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2j.sparql diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/AdviseeRole.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/AdviseeRole.sparql index 799823c3..c79d5687 100644 --- a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/AdviseeRole.sparql +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/AdviseeRole.sparql @@ -12,4 +12,8 @@ CONSTRUCT { ?advisee vivo:relatedBy ?advisingRelationship . } WHERE { ?advisee vivo:adviseeIn ?advisingRelationship . + FILTER NOT EXISTS { + ?advisee ?adviseeRoleNode . + ?adviseeRoleNode vivo:relatedBy ?advisingRelationship . + } } diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/AdvisorRole.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/AdvisorRole.sparql index 685a93e1..8a389c08 100644 --- a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/AdvisorRole.sparql +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/AdvisorRole.sparql @@ -12,4 +12,8 @@ CONSTRUCT { ?advisor vivo:relatedBy ?advisingRelationship . } WHERE { ?advisor vivo:advisorIn ?advisingRelationship . + FILTER NOT EXISTS { + ?advisor ?advisorRoleNode . + ?advisorRoleNode vivo:relatedBy ?advisingRelationship . + } } diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/Editorship.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/Editorship.sparql index 79e50249..204664f8 100644 --- a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/Editorship.sparql +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/Editorship.sparql @@ -14,5 +14,9 @@ CONSTRUCT { } UNION { ?document vivo:editor ?person FILTER NOT EXISTS { ?person vivo:editorOf ?document } + } + FILTER NOT EXISTS { + ?person vivo:relatedBy ?editorshipNode . + ?editorshipNode vivo:relates ?document . } } diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/LeaderRole.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/LeaderRole.sparql index b5236339..2a09ef27 100644 --- a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/LeaderRole.sparql +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/LeaderRole.sparql @@ -14,4 +14,8 @@ CONSTRUCT { { ?org vivo:currentlyHeadedBy ?person FILTER NOT EXISTS { ?person vivo:currentlyHeadOf ?org } } + FILTER NOT EXISTS { + ?person ?leaderRoleNode . + ?leaderRoleNode vivo:roleContributesTo ?org . + } } diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/MemberRole.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/MemberRole.sparql index fecea0cc..85a5b275 100644 --- a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/MemberRole.sparql +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/MemberRole.sparql @@ -14,4 +14,8 @@ CONSTRUCT { { ?org vivo:hasCurrentMember ?person FILTER NOT EXISTS { ?person vivo:currentMemberOf ?org } } + FILTER NOT EXISTS { + ?person ?memberRoleNode . + ?memberRoleNode vivo:roleContributesTo ?org . + } } diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/grantAdmin.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/grantAdmin.sparql index d76c98d7..72315e11 100644 --- a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/grantAdmin.sparql +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/grantAdmin.sparql @@ -16,4 +16,9 @@ CONSTRUCT { { ?grant vivo:administeredBy ?agent FILTER NOT EXISTS { ?agent vivo:administers ?grant } } + FILTER NOT EXISTS { + ?agent ?adminRoleNode . + ?adminRoleNode a vivo:AdministratorRole . + ?adminRoleNode vivo:relatedBy ?grant . + } } diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/post/awardedDegree.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/post/awardedDegree.sparql index 8d90cd6d..5beaf5a2 100644 --- a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/post/awardedDegree.sparql +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/post/awardedDegree.sparql @@ -22,4 +22,8 @@ CONSTRUCT { ?educationalProcess ?org . ?org a foaf:Organization } + FILTER NOT EXISTS { + ?educationalProcess ?awardedDegreeNode . + ?person vivo:relatedBy ?awardedDegreeNode . + } } diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0.sparql deleted file mode 100644 index a9262a27..00000000 --- a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0.sparql +++ /dev/null @@ -1,24 +0,0 @@ -PREFIX arg: -PREFIX foaf: -PREFIX v: -PREFIX vivo: - -CONSTRUCT { - ?s arg:ARG_2000028 _:vcard . - _:vcard arg:ARG_2000029 ?s . - _:vcard a v:Individual . -} WHERE { - ?s a foaf:Person - FILTER ( - EXISTS { ?s foaf:firstName ?firstName } || - EXISTS { ?s foaf:lastName ?lastName } || - EXISTS { ?s vivo:middleName ?middleName } || - EXISTS { ?s vivo:email ?email } || - EXISTS { ?s vivo:primaryEmail ?primaryEmail } || - EXISTS { ?s vivo:phoneNumber ?phoneNumber } || - EXISTS { ?s vivo:primaryPhoneNumber ?primaryPhoneNumber } || - EXISTS { ?s vivo:faxNumber ?faxNumber } || - EXISTS { ?s vivo:mailingAddress ?address } || - EXISTS { ?s vivo:webpage ?webpage } - ) -} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0a.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0a.sparql new file mode 100644 index 00000000..193cc5aa --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0a.sparql @@ -0,0 +1,15 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: + +CONSTRUCT { + ?s arg:ARG_2000028 _:vcard . + _:vcard arg:ARG_2000029 ?s . + _:vcard a v:Individual . +} WHERE { + ?s foaf:firstName ?firstName + FILTER NOT EXISTS { + ?s arg:ARG_2000028 ?vcard + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0b.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0b.sparql new file mode 100644 index 00000000..f41fd0bc --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0b.sparql @@ -0,0 +1,15 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: + +CONSTRUCT { + ?s arg:ARG_2000028 _:vcard . + _:vcard arg:ARG_2000029 ?s . + _:vcard a v:Individual . +} WHERE { + ?s foaf:lastName ?lastName + FILTER NOT EXISTS { + ?s arg:ARG_2000028 ?vcard . + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0c.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0c.sparql new file mode 100644 index 00000000..03405d95 --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0c.sparql @@ -0,0 +1,15 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: + +CONSTRUCT { + ?s arg:ARG_2000028 _:vcard . + _:vcard arg:ARG_2000029 ?s . + _:vcard a v:Individual . +} WHERE { + ?s vivo:middleName ?middleName + FILTER NOT EXISTS { + ?s arg:ARG_2000028 ?vcard + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0d.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0d.sparql new file mode 100644 index 00000000..1842a23a --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0d.sparql @@ -0,0 +1,16 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: + +CONSTRUCT { + ?s arg:ARG_2000028 _:vcard . + _:vcard arg:ARG_2000029 ?s . + _:vcard a v:Individual . +} WHERE { + ?s vivo:email ?email . + ?s a foaf:Person . + FILTER NOT EXISTS { + ?s arg:ARG_2000028 ?vcard + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0e.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0e.sparql new file mode 100644 index 00000000..f392f36e --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0e.sparql @@ -0,0 +1,16 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: + +CONSTRUCT { + ?s arg:ARG_2000028 _:vcard . + _:vcard arg:ARG_2000029 ?s . + _:vcard a v:Individual . +} WHERE { + ?s vivo:primaryEmail ?email . + ?s a foaf:Person . + FILTER NOT EXISTS { + ?s arg:ARG_2000028 ?vcard + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0f.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0f.sparql new file mode 100644 index 00000000..d01698a8 --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0f.sparql @@ -0,0 +1,16 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: + +CONSTRUCT { + ?s arg:ARG_2000028 _:vcard . + _:vcard arg:ARG_2000029 ?s . + _:vcard a v:Individual . +} WHERE { + ?s vivo:phoneNumber ?phoneNumber . + ?s a foaf:Person . + FILTER NOT EXISTS { + ?s arg:ARG_2000028 ?vcard . + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0g.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0g.sparql new file mode 100644 index 00000000..a578d3e0 --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0g.sparql @@ -0,0 +1,16 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: + +CONSTRUCT { + ?s arg:ARG_2000028 _:vcard . + _:vcard arg:ARG_2000029 ?s . + _:vcard a v:Individual . +} WHERE { + ?s vivo:primaryPhoneNumber ?primaryPhoneNumber . + ?s a foaf:Person + FILTER NOT EXISTS { + ?s arg:ARG_2000028 ?vcard . + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0h.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0h.sparql new file mode 100644 index 00000000..8abf7951 --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0h.sparql @@ -0,0 +1,16 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: + +CONSTRUCT { + ?s arg:ARG_2000028 _:vcard . + _:vcard arg:ARG_2000029 ?s . + _:vcard a v:Individual . +} WHERE { + ?s vivo:faxNumber ?faxNumber . + ?s a foaf:Person + FILTER NOT EXISTS { + ?s arg:ARG_2000028 ?vcard . + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0i.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0i.sparql new file mode 100644 index 00000000..1e966109 --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0i.sparql @@ -0,0 +1,16 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: + +CONSTRUCT { + ?s arg:ARG_2000028 _:vcard . + _:vcard arg:ARG_2000029 ?s . + _:vcard a v:Individual . +} WHERE { + ?s vivo:mailingAddress ?address . + ?s a foaf:Person + FILTER NOT EXISTS { + ?s arg:ARG_2000028 ?vcard . + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0j.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0j.sparql new file mode 100644 index 00000000..22857e64 --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-0j.sparql @@ -0,0 +1,16 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: + +CONSTRUCT { + ?s arg:ARG_2000028 _:vcard . + _:vcard arg:ARG_2000029 ?s . + _:vcard a v:Individual . +} WHERE { + ?s vivo:webpage ?webpage . + ?s a foaf:Person + FILTER NOT EXISTS { + ?s arg:ARG_2000028 ?vcard . + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1.sparql deleted file mode 100644 index a15d4d0f..00000000 --- a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1.sparql +++ /dev/null @@ -1,21 +0,0 @@ -PREFIX arg: -PREFIX foaf: -PREFIX v: -PREFIX vivo: - -CONSTRUCT { - ?s arg:ARG_2000028 _:vcard . - _:vcard arg:ARG_2000029 ?s . - _:vcard a v:Organization . -} WHERE { - ?s a foaf:Organization - FILTER ( - EXISTS { ?s vivo:email ?email } || - EXISTS { ?s vivo:primaryEmail ?primaryEmail } || - EXISTS { ?s vivo:phoneNumber ?phoneNumber } || - EXISTS { ?s vivo:primaryPhoneNumber ?primaryPhoneNumber } || - EXISTS { ?s vivo:faxNumber ?faxNumber } || - EXISTS { ?s vivo:mailingAddress ?address } || - EXISTS { ?s vivo:webpage ?webpage } - ) -} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1d.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1d.sparql new file mode 100644 index 00000000..b7a4c933 --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1d.sparql @@ -0,0 +1,16 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: + +CONSTRUCT { + ?s arg:ARG_2000028 _:vcard . + _:vcard arg:ARG_2000029 ?s . + _:vcard a v:Organization . +} WHERE { + ?s vivo:email ?email . + ?s a foaf:Organization . + FILTER NOT EXISTS { + ?s arg:ARG_2000028 ?vcard + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1e.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1e.sparql new file mode 100644 index 00000000..fad907f8 --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1e.sparql @@ -0,0 +1,16 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: + +CONSTRUCT { + ?s arg:ARG_2000028 _:vcard . + _:vcard arg:ARG_2000029 ?s . + _:vcard a v:Organization . +} WHERE { + ?s vivo:primaryEmail ?email . + ?s a foaf:Organization . + FILTER NOT EXISTS { + ?s arg:ARG_2000028 ?vcard + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1f.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1f.sparql new file mode 100644 index 00000000..5baf40f5 --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1f.sparql @@ -0,0 +1,16 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: + +CONSTRUCT { + ?s arg:ARG_2000028 _:vcard . + _:vcard arg:ARG_2000029 ?s . + _:vcard a v:Organization . +} WHERE { + ?s vivo:phoneNumber ?phoneNumber . + ?s a foaf:Organization . + FILTER NOT EXISTS { + ?s arg:ARG_2000028 ?vcard . + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1g.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1g.sparql new file mode 100644 index 00000000..90c98507 --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1g.sparql @@ -0,0 +1,16 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: + +CONSTRUCT { + ?s arg:ARG_2000028 _:vcard . + _:vcard arg:ARG_2000029 ?s . + _:vcard a v:Organization . +} WHERE { + ?s vivo:primaryPhoneNumber ?primaryPhoneNumber . + ?s a foaf:Organization + FILTER NOT EXISTS { + ?s arg:ARG_2000028 ?vcard . + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1h.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1h.sparql new file mode 100644 index 00000000..036b1c92 --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1h.sparql @@ -0,0 +1,16 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: + +CONSTRUCT { + ?s arg:ARG_2000028 _:vcard . + _:vcard arg:ARG_2000029 ?s . + _:vcard a v:Organization . +} WHERE { + ?s vivo:faxNumber ?faxNumber . + ?s a foaf:Organization + FILTER NOT EXISTS { + ?s arg:ARG_2000028 ?vcard . + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1i.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1i.sparql new file mode 100644 index 00000000..071cf222 --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1i.sparql @@ -0,0 +1,16 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: + +CONSTRUCT { + ?s arg:ARG_2000028 _:vcard . + _:vcard arg:ARG_2000029 ?s . + _:vcard a v:Organization . +} WHERE { + ?s vivo:mailingAddress ?address . + ?s a foaf:Organization + FILTER NOT EXISTS { + ?s arg:ARG_2000028 ?vcard . + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1j.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1j.sparql new file mode 100644 index 00000000..a7690455 --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-1j.sparql @@ -0,0 +1,16 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: + +CONSTRUCT { + ?s arg:ARG_2000028 _:vcard . + _:vcard arg:ARG_2000029 ?s . + _:vcard a v:Organization . +} WHERE { + ?s vivo:webpage ?webpage . + ?s a foaf:Organization + FILTER NOT EXISTS { + ?s arg:ARG_2000028 ?vcard . + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2.sparql deleted file mode 100644 index b966a2a3..00000000 --- a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2.sparql +++ /dev/null @@ -1,21 +0,0 @@ -PREFIX arg: -PREFIX foaf: -PREFIX v: -PREFIX vivo: - -CONSTRUCT { - ?s arg:ARG_2000028 _:vcard . - _:vcard arg:ARG_2000029 ?s . - _:vcard a v:Group . -} WHERE { - ?s a foaf:Group - FILTER ( - EXISTS { ?s vivo:email ?email } || - EXISTS { ?s vivo:primaryEmail ?primaryEmail } || - EXISTS { ?s vivo:phoneNumber ?phoneNumber } || - EXISTS { ?s vivo:primaryPhoneNumber ?primaryPhoneNumber } || - EXISTS { ?s vivo:faxNumber ?faxNumber } || - EXISTS { ?s vivo:mailingAddress ?address } || - EXISTS { ?s vivo:webpage ?webpage } - ) -} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2d.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2d.sparql new file mode 100644 index 00000000..37add2fa --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2d.sparql @@ -0,0 +1,16 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: + +CONSTRUCT { + ?s arg:ARG_2000028 _:vcard . + _:vcard arg:ARG_2000029 ?s . + _:vcard a v:Group . +} WHERE { + ?s vivo:email ?email . + ?s a foaf:Group . + FILTER NOT EXISTS { + ?s arg:ARG_2000028 ?vcard + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2e.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2e.sparql new file mode 100644 index 00000000..27f965b6 --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2e.sparql @@ -0,0 +1,16 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: + +CONSTRUCT { + ?s arg:ARG_2000028 _:vcard . + _:vcard arg:ARG_2000029 ?s . + _:vcard a v:Group . +} WHERE { + ?s vivo:primaryEmail ?email . + ?s a foaf:Group . + FILTER NOT EXISTS { + ?s arg:ARG_2000028 ?vcard + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2f.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2f.sparql new file mode 100644 index 00000000..3018c379 --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2f.sparql @@ -0,0 +1,16 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: + +CONSTRUCT { + ?s arg:ARG_2000028 _:vcard . + _:vcard arg:ARG_2000029 ?s . + _:vcard a v:Group . +} WHERE { + ?s vivo:phoneNumber ?phoneNumber . + ?s a foaf:Group . + FILTER NOT EXISTS { + ?s arg:ARG_2000028 ?vcard . + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2g.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2g.sparql new file mode 100644 index 00000000..7b0de744 --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2g.sparql @@ -0,0 +1,16 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: + +CONSTRUCT { + ?s arg:ARG_2000028 _:vcard . + _:vcard arg:ARG_2000029 ?s . + _:vcard a v:Group . +} WHERE { + ?s vivo:primaryPhoneNumber ?primaryPhoneNumber . + ?s a foaf:Group + FILTER NOT EXISTS { + ?s arg:ARG_2000028 ?vcard . + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2h.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2h.sparql new file mode 100644 index 00000000..2ebffbbc --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2h.sparql @@ -0,0 +1,16 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: + +CONSTRUCT { + ?s arg:ARG_2000028 _:vcard . + _:vcard arg:ARG_2000029 ?s . + _:vcard a v:Group . +} WHERE { + ?s vivo:faxNumber ?faxNumber . + ?s a foaf:Group + FILTER NOT EXISTS { + ?s arg:ARG_2000028 ?vcard . + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2i.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2i.sparql new file mode 100644 index 00000000..3e83b11e --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2i.sparql @@ -0,0 +1,16 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: + +CONSTRUCT { + ?s arg:ARG_2000028 _:vcard . + _:vcard arg:ARG_2000029 ?s . + _:vcard a v:Group . +} WHERE { + ?s vivo:mailingAddress ?address . + ?s a foaf:Group + FILTER NOT EXISTS { + ?s arg:ARG_2000028 ?vcard . + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2j.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2j.sparql new file mode 100644 index 00000000..3ec0ab9e --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard1-2j.sparql @@ -0,0 +1,16 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: + +CONSTRUCT { + ?s arg:ARG_2000028 _:vcard . + _:vcard arg:ARG_2000029 ?s . + _:vcard a v:Group . +} WHERE { + ?s vivo:webpage ?webpage . + ?s a foaf:Group + FILTER NOT EXISTS { + ?s arg:ARG_2000028 ?vcard . + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2.sparql deleted file mode 100644 index 499d0bbb..00000000 --- a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2.sparql +++ /dev/null @@ -1,36 +0,0 @@ -PREFIX arg: -PREFIX foaf: -PREFIX v: -PREFIX vivo: -PREFIX bibo: - -CONSTRUCT { - ?vcard v:hasName _:name . - _:name a v:Name . - _:name v:givenName ?firstName . - _:name vivo:middleName ?middleName . - _:name v:familyName ?lastName . - _:name v:honorificPrefix ?prefix . - _:name v:honorificSuffix ?suffix . -} WHERE { - ?s arg:ARG_2000028 ?vcard . - OPTIONAL { - ?s foaf:firstName ?firstName . - BIND("yes" as ?test) - } - OPTIONAL { - ?s foaf:lastName ?lastName . - BIND("yes" as ?test) - } - OPTIONAL { - ?s vivo:middleName ?middleName - BIND("yes" as ?test) - } - OPTIONAL { - ?s bibo:prefixName ?prefix - } - OPTIONAL { - ?s bibo:suffixName ?suffix - } - FILTER(bound(?test)) -} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard22.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard22.sparql index 9107814a..db2f6276 100644 --- a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard22.sparql +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard22.sparql @@ -9,6 +9,9 @@ CONSTRUCT { _:title a v:Title . _:title v:title ?preferredTitle . } WHERE { - ?s arg:ARG_2000028 ?vcard . ?s ?preferredTitle . + ?s arg:ARG_2000028 ?vcard . + FILTER NOT EXISTS { + ?vcard v:hasTitle ?title + } } diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2a.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2a.sparql new file mode 100644 index 00000000..ef2dc2ba --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2a.sparql @@ -0,0 +1,17 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: +PREFIX bibo: + +CONSTRUCT { + ?vcard v:hasName _:name . + _:name a v:Name . + _:name v:givenName ?firstName . +} WHERE { + ?s foaf:firstName ?firstName . + ?s arg:ARG_2000028 ?vcard . + FILTER NOT EXISTS { + ?vcard v:hasName ?name + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2b.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2b.sparql new file mode 100644 index 00000000..64634413 --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2b.sparql @@ -0,0 +1,13 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: +PREFIX bibo: + +CONSTRUCT { + ?name v:givenName ?firstName . +} WHERE { + ?s foaf:firstName ?firstName . + ?s arg:ARG_2000028 ?vcard . + ?vcard v:hasName ?name +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2c.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2c.sparql new file mode 100644 index 00000000..dbcaf50a --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2c.sparql @@ -0,0 +1,17 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: +PREFIX bibo: + +CONSTRUCT { + ?vcard v:hasName _:name . + _:name a v:Name . + _:name vivo:middleName ?middleName . +} WHERE { + ?s vivo:middleName ?middleName . + ?s arg:ARG_2000028 ?vcard . + FILTER NOT EXISTS { + ?vcard v:hasName ?name + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2d.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2d.sparql new file mode 100644 index 00000000..a065a9fe --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2d.sparql @@ -0,0 +1,13 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: +PREFIX bibo: + +CONSTRUCT { + ?name vivo:middleName ?middleName . +} WHERE { + ?s vivo:middleName ?middleName . + ?s arg:ARG_2000028 ?vcard . + ?vcard v:hasName ?name +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2e.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2e.sparql new file mode 100644 index 00000000..cfa9ea92 --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2e.sparql @@ -0,0 +1,17 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: +PREFIX bibo: + +CONSTRUCT { + ?vcard v:hasName _:name . + _:name a v:Name . + _:name v:familyName ?lastName . +} WHERE { + ?s foaf:lastName ?lastName . + ?s arg:ARG_2000028 ?vcard . + FILTER NOT EXISTS { + ?vcard v:hasName ?name + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2f.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2f.sparql new file mode 100644 index 00000000..4337be4d --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2f.sparql @@ -0,0 +1,13 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: +PREFIX bibo: + +CONSTRUCT { + ?name v:familyName ?lastName . +} WHERE { + ?s foaf:lastName ?lastName . + ?s arg:ARG_2000028 ?vcard . + ?vcard v:hasName ?name +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2g.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2g.sparql new file mode 100644 index 00000000..66231ddf --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2g.sparql @@ -0,0 +1,17 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: +PREFIX bibo: + +CONSTRUCT { + ?vcard v:hasName _:name . + _:name a v:Name . + _:name v:honorificPrefix ?prefixName . +} WHERE { + ?s bibo:prefixName ?prefixName . + ?s arg:ARG_2000028 ?vcard . + FILTER NOT EXISTS { + ?vcard v:hasName ?name + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2h.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2h.sparql new file mode 100644 index 00000000..1eb06b3b --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2h.sparql @@ -0,0 +1,13 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: +PREFIX bibo: + +CONSTRUCT { + ?name v:honorificPrefix ?prefixName . +} WHERE { + ?s bibo:prefixName ?prefixName . + ?s arg:ARG_2000028 ?vcard . + ?vcard v:hasName ?name +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2i.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2i.sparql new file mode 100644 index 00000000..5d873f15 --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2i.sparql @@ -0,0 +1,17 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: +PREFIX bibo: + +CONSTRUCT { + ?vcard v:hasName _:name . + _:name a v:Name . + _:name v:honorificSuffix ?suffixName . +} WHERE { + ?s bibo:suffixName ?suffixName . + ?s arg:ARG_2000028 ?vcard . + FILTER NOT EXISTS { + ?vcard v:hasName ?name + } +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2j.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2j.sparql new file mode 100644 index 00000000..a3abaff9 --- /dev/null +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard2j.sparql @@ -0,0 +1,13 @@ +PREFIX arg: +PREFIX foaf: +PREFIX v: +PREFIX vivo: +PREFIX bibo: + +CONSTRUCT { + ?name v:honorificSuffix ?suffixName . +} WHERE { + ?s bibo:suffixName ?suffixName . + ?s arg:ARG_2000028 ?vcard . + ?vcard v:hasName ?name +} diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard3.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard3.sparql index 91991c9e..2952d182 100644 --- a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard3.sparql +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard3.sparql @@ -8,6 +8,9 @@ CONSTRUCT { _:email a v:Email . _:email v:email ?email . } WHERE { + ?s vivo:email ?email . ?s arg:ARG_2000028 ?vcard . - ?s vivo:email ?email + FILTER NOT EXISTS { + ?vcard v:hasEmail ?emailnode + } } diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard4.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard4.sparql index b6f9409f..8699c703 100644 --- a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard4.sparql +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard4.sparql @@ -9,6 +9,10 @@ CONSTRUCT { _:primaryEmail a v:Work . _:primaryEmail v:email ?primaryEmail . } WHERE { + ?s vivo:primaryEmail ?primaryEmail . ?s arg:ARG_2000028 ?vcard . - ?s vivo:primaryEmail ?primaryEmail + FILTER NOT EXISTS { + ?vcard v:hasEmail ?email . + ?email a v:Work . + } } diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard5.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard5.sparql index 6deedc83..26017bc1 100644 --- a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard5.sparql +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard5.sparql @@ -9,6 +9,9 @@ CONSTRUCT { _:telephone a v:Voice . _:telephone v:telephone ?phoneNumber . } WHERE { + ?s vivo:phoneNumber ?phoneNumber . ?s arg:ARG_2000028 ?vcard . - ?s vivo:phoneNumber ?phoneNumber + FILTER NOT EXISTS { + ?vcard v:hasTelephone ?telephoneNode . + } } diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard6.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard6.sparql index d5c0f26e..8bc690a0 100644 --- a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard6.sparql +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard6.sparql @@ -10,6 +10,10 @@ CONSTRUCT { _:primaryTelephone a v:Work . _:primaryTelephone v:telephone ?primaryPhoneNumber . } WHERE { + ?s vivo:primaryPhoneNumber ?primaryPhoneNumber . ?s arg:ARG_2000028 ?vcard . - ?s vivo:primaryPhoneNumber ?primaryPhoneNumber + FILTER NOT EXISTS { + ?vcard v:hasTelephone ?telephoneNode . + ?vcard a v:Work . + } } diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard7.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard7.sparql index 39982679..c94a7638 100644 --- a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard7.sparql +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard7.sparql @@ -9,6 +9,10 @@ CONSTRUCT { _:fax a v:Fax. _:fax v:telephone ?faxNumber . } WHERE { + ?s vivo:faxNumber ?faxNumber . ?s arg:ARG_2000028 ?vcard . - ?s vivo:faxNumber ?faxNumber + FILTER NOT EXISTS { + ?vcard v:hasTelephone ?faxNode . + ?faxNode a v:Fax . + } } diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard8.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard8.sparql index eb88f650..1f1dddce 100644 --- a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard8.sparql +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard8.sparql @@ -12,12 +12,12 @@ CONSTRUCT { _:address v:postalCode ?addressPostalCode . _:address v:country ?addressCountry . } WHERE { - ?s arg:ARG_2000028 ?vcard . ?s vivo:mailingAddress ?address . - ?address vivo:addressCity ?addressCity . - ?address vivo:addressState ?addressState . - ?address vivo:addressCountry ?addressCountry . - ?address vivo:addressPostalCode ?addressPostalCode . + OPTIONAL { ?address vivo:addressCity ?addressCity } + OPTIONAL { ?address vivo:addressState ?addressState } + OPTIONAL { ?address vivo:addressPostalCode ?addressPostalCode } + OPTIONAL { ?address vivo:addressCountry ?addressCountry } + ?s arg:ARG_2000028 ?vcard . OPTIONAL { ?address vivo:address1 ?address1 . ?address vivo:address2 ?address2 . @@ -33,5 +33,8 @@ CONSTRUCT { OPTIONAL { ?address vivo:address1 ?address1 BIND(?address1 as ?streetAddress) + } + FILTER NOT EXISTS { + ?vcard v:hasAddress ?addressNode } } diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard9.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard9.sparql index d400de8f..62c04e1b 100644 --- a/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard9.sparql +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/additions/vcard9.sparql @@ -10,10 +10,13 @@ CONSTRUCT { _:url v:url ?linkURI . _:url rdfs:label ?linkAnchorText } WHERE { - ?s arg:ARG_2000028 ?vcard . ?s vivo:webpage ?webpage . ?webpage vivo:linkURI ?linkURI . + ?s arg:ARG_2000028 ?vcard . OPTIONAL { ?webpage vivo:linkAnchorText ?linkAnchorText } + FILTER NOT EXISTS { + ?vcard v:hasURL ?URLNode + } } diff --git a/rdf/tbox/filegraph/data-properties.owl b/rdf/tbox/filegraph/data-properties.owl index 771b3128..5799c1e7 100644 --- a/rdf/tbox/filegraph/data-properties.owl +++ b/rdf/tbox/filegraph/data-properties.owl @@ -1833,16 +1833,13 @@ use one freetextKeyword assertion for each keyword or phrase. - - - From bb4145e5657f51ceef0e2af79b6cdb6c6c9bc5ec Mon Sep 17 00:00:00 2001 From: brianjlowe Date: Tue, 5 Nov 2013 10:45:57 -0500 Subject: [PATCH 2/6] VIVO-388 fixes vivo:middleName migration bug --- .../update/sparqlConstructs/deletions/vcardDel.sparql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/productMods/WEB-INF/ontologies/update/sparqlConstructs/deletions/vcardDel.sparql b/productMods/WEB-INF/ontologies/update/sparqlConstructs/deletions/vcardDel.sparql index 439b7599..d31781cf 100644 --- a/productMods/WEB-INF/ontologies/update/sparqlConstructs/deletions/vcardDel.sparql +++ b/productMods/WEB-INF/ontologies/update/sparqlConstructs/deletions/vcardDel.sparql @@ -27,7 +27,8 @@ CONSTRUCT { ?s foaf:lastName ?lastName . } UNION { - ?s vivo:middleName ?middleName + ?s vivo:middleName ?middleName . + ?s a foaf:Person . } UNION { ?s bibo:prefixName ?prefix From 2d05f1d814c15f9eb9e84adfa9f2186fb5a5fcf1 Mon Sep 17 00:00:00 2001 From: tworrall Date: Tue, 5 Nov 2013 11:05:02 -0500 Subject: [PATCH 3/6] VIVO-476 --- productMods/counter.jsp | 888 ++++++++++++++++++++-------------------- 1 file changed, 454 insertions(+), 434 deletions(-) diff --git a/productMods/counter.jsp b/productMods/counter.jsp index 0b8de8a7..51474cd0 100644 --- a/productMods/counter.jsp +++ b/productMods/counter.jsp @@ -1,434 +1,454 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> -<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> -<%@ taglib uri="http://djpowell.net/tmp/sparql-tag/0.1/" prefix="sparql" %> -<%@ taglib uri="http://jakarta.apache.org/taglibs/string-1.1" prefix="str" %> -<%@ page import="java.net.URLDecoder" %> - -
- -

Linkage Information

-
    - - - - - PREFIX rdfs: - PREFIX rdf: - PREFIX akt: - PREFIX bibo: - PREFIX core: - SELECT (count(?author) as ?counts) WHERE { - ?author rdf:type core:Authorship . - ?author core:linkedInformationResource ?infor . - ?infor rdf:type core:InformationResource . - } - - -
  • 'Person'-'InformationResource' linkages (${inforauthorship.counts.string})
  • -
    -
    -
    - - - - - PREFIX rdfs: - PREFIX rdf: - PREFIX akt: - PREFIX foaf: - PREFIX bibo: - PREFIX core: - SELECT (count(distinct ?author) as ?counts) WHERE { - ?author core:authorInAuthorship ?obj . - ?author rdf:type foaf:Person . - ?obj core:linkedInformationResource ?infor . - ?infor rdf:type core:InformationResource . - } - - -
  • 'Person' entities which published 'InformationResource' entities (${inforauthor.counts.string})
  • -
    -
    -
    - - - - - PREFIX rdfs: - PREFIX rdf: - PREFIX akt: - PREFIX bibo: - PREFIX core: - SELECT (count(distinct ?infor) as ?counts) WHERE { - ?subj core:linkedInformationResource ?infor . - ?infor rdf:type core:InformationResource . - } - - -
  • 'InformationResource' entities (${infor.counts.string})
  • -
    -
    -
    -
- - -
    - - - - - PREFIX rdfs: - PREFIX rdf: - PREFIX akt: - PREFIX bibo: - PREFIX core: - SELECT (count(?author) as ?counts) WHERE { - ?author rdf:type core:Authorship . - ?author core:linkedInformationResource ?infor . - ?infor rdf:type core:ConferencePaper . - } - - -
  • 'Person'-'ConferencePaper' linkages (${confauthorship.counts.string})
  • -
    -
    -
    - - - - - PREFIX rdfs: - PREFIX rdf: - PREFIX akt: - PREFIX foaf: - PREFIX bibo: - PREFIX core: - SELECT (count(distinct ?author) as ?counts) WHERE { - ?author core:authorInAuthorship ?obj . - ?author rdf:type foaf:Person . - ?obj core:linkedInformationResource ?infor . - ?infor rdf:type core:ConferencePaper . - } - - -
  • 'Person' entities which published 'ConferencePaper' entities (${confauthor.counts.string})
  • -
    -
    -
    - - - - - PREFIX rdfs: - PREFIX rdf: - PREFIX akt: - PREFIX bibo: - PREFIX core: - SELECT (count(distinct ?infor) as ?counts) WHERE { - ?subj core:linkedInformationResource ?infor . - ?infor rdf:type core:ConferencePaper . - } - - -
  • 'ConferencePaper' entities (${conf.counts.string})
  • -
    -
    -
    -
- - -
    - - - - - PREFIX rdfs: - PREFIX rdf: - PREFIX akt: - PREFIX bibo: - PREFIX core: - SELECT (count(?author) as ?counts) WHERE { - ?author rdf:type core:Authorship . - ?author core:linkedInformationResource ?infor . - ?infor rdf:type bibo:AcademicArticle . - } - - -
  • 'Person'-'AcademicArticle' linkages (${acaauthorship.counts.string})
  • -
    -
    -
    - - - - - PREFIX rdfs: - PREFIX rdf: - PREFIX akt: - PREFIX foaf: - PREFIX bibo: - PREFIX core: - SELECT (count(distinct ?author) as ?counts) WHERE { - ?author core:authorInAuthorship ?obj . - ?author rdf:type foaf:Person . - ?obj core:linkedInformationResource ?infor . - ?infor rdf:type bibo:AcademicArticle . - } - - -
  • 'Person' entities which published 'AcademicArticle' entities (${acaauthor.counts.string})
  • -
    -
    -
    - - - - - PREFIX rdfs: - PREFIX rdf: - PREFIX akt: - PREFIX bibo: - PREFIX core: - SELECT (count(distinct ?infor) as ?counts) WHERE { - ?subj core:linkedInformationResource ?infor . - ?infor rdf:type bibo:AcademicArticle . - } - - -
  • 'AcademicArticle' entities (${aca.counts.string})
  • -
    -
    -
    -
- - -
    - - - - - PREFIX rdfs: - PREFIX rdf: - PREFIX akt: - PREFIX bibo: - PREFIX core: - SELECT (count(*) as ?counts) WHERE { - ?grant core:hasInvestigator ?pi . - } - - -
  • 'Person'-'Grant' linkages (${piship.counts.string})
  • -
    -
    -
    - - - - - PREFIX rdfs: - PREFIX rdf: - PREFIX akt: - PREFIX bibo: - PREFIX core: - SELECT (count(distinct ?pi) as ?counts) WHERE { - ?grant core:hasInvestigator ?pi . - ?grant rdf:type core:Grant . - } - - -
  • 'Person' entities which are (co-)investigators on 'Grant' entities (${pi.counts.string})
  • -
    -
    -
    - - - - - PREFIX rdfs: - PREFIX rdf: - PREFIX akt: - PREFIX bibo: - PREFIX core: - SELECT (count(distinct ?grant) as ?counts) WHERE { - ?grant rdf:type core:Grant . - } - - -
  • 'Grant' entities (${grant.counts.string})
  • -
    -
    -
    -
- - -
    - - - - - PREFIX rdfs: - PREFIX rdf: - PREFIX akt: - PREFIX bibo: - PREFIX core: - SELECT (count(*) as ?counts) WHERE { - ?teacher core:teaching ?obj . - } - - -
  • 'Person'-'CourseSection' linkages (${teaching.counts.string})
  • -
    -
    -
    - - - - - PREFIX rdfs: - PREFIX rdf: - PREFIX akt: - PREFIX bibo: - PREFIX core: - SELECT (count(distinct ?teacher) as ?counts) WHERE { - ?teacher core:teaching ?obj . - } - - -
  • 'Person' entities which teach 'CourseSection' entities (${teacher.counts.string})
  • -
    -
    -
    - - - - - PREFIX rdfs: - PREFIX rdf: - PREFIX akt: - PREFIX bibo: - PREFIX core: - SELECT (count(?course) as ?counts) WHERE { - ?course rdf:type core:CourseSection . - } - - -
  • 'CourseSection' entities (${course.counts.string})
  • -
    -
    -
    -
- - -
    - - - - - PREFIX rdfs: - PREFIX rdf: - PREFIX akt: - PREFIX bibo: - PREFIX core: - SELECT (count(*) as ?counts) WHERE { - ?author1 rdf:type core:Authorship . - ?author2 rdf:type core:Authorship . - ?author1 core:linkedInformationResource ?infor . - ?author2 core:linkedInformationResource ?infor . - ?infor rdf:type core:InformationResource . - FILTER (str(?author1) < str(?author2)) - } - - -
  • Total co-author linkages (${coauthor.counts.string})
  • -
    -
    -
    - - - - - - PREFIX rdfs: - PREFIX rdf: - PREFIX akt: - PREFIX bibo: - PREFIX core: - SELECT DISTINCT ?author1 ?author2 WHERE { - ?author1 rdf:type core:Authorship . - ?author2 rdf:type core:Authorship . - ?author1 core:linkedInformationResource ?infor . - ?author2 core:linkedInformationResource ?infor . - ?infor rdf:type core:InformationResource . - FILTER (str(?author1) < str(?author2)) - } - -
  • Unique co-author linkages (${fn:length(discoauthors.rows)})
  • -
    -
    -
- - -
    - - - - - PREFIX rdfs: - PREFIX rdf: - PREFIX akt: - PREFIX bibo: - PREFIX core: - SELECT (count(*) as ?counts) WHERE { - ?grant core:hasInvestigator ?pi1 . - ?grant core:hasInvestigator ?pi2 . - FILTER (str(?pi1) < str(?pi2)) - } - - -
  • Total co-investigator linkages (${copi.counts.string})
  • -
    -
    -
    - - - - - - PREFIX rdfs: - PREFIX rdf: - PREFIX akt: - PREFIX bibo: - PREFIX core: - SELECT DISTINCT ?pi1 ?pi2 WHERE { - ?grant core:hasInvestigator ?pi1 . - ?grant core:hasInvestigator ?pi2 . - FILTER (str(?pi1) < str(?pi2)) - } - -
  • Unique co-investigator linkages (${fn:length(discopis.rows)})
  • -
    -
    - -
- -
+<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> + +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> +<%@ taglib uri="http://djpowell.net/tmp/sparql-tag/0.1/" prefix="sparql" %> +<%@ taglib uri="http://jakarta.apache.org/taglibs/string-1.1" prefix="str" %> +<%@ page import="java.net.URLDecoder" %> + +
+ +

Linkage Information

+
    + + + + + PREFIX rdfs: + PREFIX rdf: + PREFIX akt: + PREFIX bibo: + PREFIX core: + PREFIX obo: + SELECT (count(?author) as ?counts) WHERE { + ?author rdf:type core:Authorship . + ?author core:relates ?infor . + ?infor rdf:type obo:IAO_0000030 . + } + + +
  • 'Person'-'InformationResource' linkages (${inforauthorship.counts.string})
  • +
    +
    +
    + + + + + PREFIX rdfs: + PREFIX rdf: + PREFIX akt: + PREFIX foaf: + PREFIX bibo: + PREFIX core: + PREFIX obo: + SELECT (count(distinct ?author) as ?counts) WHERE { + ?author core:relatedBy ?obj . + ?author rdf:type foaf:Person . + ?obj rdf:type core:Authorship . + ?obj core:relates ?infor . + ?infor rdf:type obo:IAO_0000030 . + } + + +
  • 'Person' entities which published 'InformationResource' entities (${inforauthor.counts.string})
  • +
    +
    +
    + + + + + PREFIX rdfs: + PREFIX rdf: + PREFIX akt: + PREFIX bibo: + PREFIX core: + PREFIX obo: + SELECT (count(distinct ?infor) as ?counts) WHERE { + ?subj core:relates ?infor . + ?infor rdf:type obo:IAO_0000030 . + } + + +
  • 'InformationResource' entities (${infor.counts.string})
  • +
    +
    +
    +
+ + +
    + + + + + PREFIX rdfs: + PREFIX rdf: + PREFIX akt: + PREFIX bibo: + PREFIX core: + SELECT (count(?author) as ?counts) WHERE { + ?author rdf:type core:Authorship . + ?author core:relates ?infor . + ?infor rdf:type core:ConferencePaper . + } + + +
  • 'Person'-'ConferencePaper' linkages (${confauthorship.counts.string})
  • +
    +
    +
    + + + + + PREFIX rdfs: + PREFIX rdf: + PREFIX akt: + PREFIX foaf: + PREFIX bibo: + PREFIX core: + SELECT (count(distinct ?author) as ?counts) WHERE { + ?author core:relatedBy ?obj . + ?author rdf:type foaf:Person . + ?obj rdf:type core:Authorship . + ?obj core:relates ?infor . + ?infor rdf:type core:ConferencePaper . + } + + +
  • 'Person' entities which published 'ConferencePaper' entities (${confauthor.counts.string})
  • +
    +
    +
    + + + + + PREFIX rdfs: + PREFIX rdf: + PREFIX akt: + PREFIX bibo: + PREFIX core: + SELECT (count(distinct ?infor) as ?counts) WHERE { + ?subj core:relates ?infor . + ?infor rdf:type core:ConferencePaper . + } + + +
  • 'ConferencePaper' entities (${conf.counts.string})
  • +
    +
    +
    +
+ + +
    + + + + + PREFIX rdfs: + PREFIX rdf: + PREFIX akt: + PREFIX bibo: + PREFIX core: + SELECT (count(?author) as ?counts) WHERE { + ?author rdf:type core:Authorship . + ?author core:relates ?infor . + ?infor rdf:type bibo:AcademicArticle . + } + + +
  • 'Person'-'AcademicArticle' linkages (${acaauthorship.counts.string})
  • +
    +
    +
    + + + + + PREFIX rdfs: + PREFIX rdf: + PREFIX akt: + PREFIX foaf: + PREFIX bibo: + PREFIX core: + SELECT (count(distinct ?author) as ?counts) WHERE { + ?author core:relatedBy ?obj . + ?author rdf:type foaf:Person . + ?obj rdf:type core:Authorship . + ?obj core:relates ?infor . + ?infor rdf:type bibo:AcademicArticle . + } + + +
  • 'Person' entities which published 'AcademicArticle' entities (${acaauthor.counts.string})
  • +
    +
    +
    + + + + + PREFIX rdfs: + PREFIX rdf: + PREFIX akt: + PREFIX bibo: + PREFIX core: + SELECT (count(distinct ?infor) as ?counts) WHERE { + ?subj core:relates ?infor . + ?infor rdf:type bibo:AcademicArticle . + } + + +
  • 'AcademicArticle' entities (${aca.counts.string})
  • +
    +
    +
    +
+ + +
    + + + + + PREFIX rdfs: + PREFIX rdf: + PREFIX akt: + PREFIX bibo: + PREFIX core: + SELECT (count(*) as ?counts) WHERE { + ?grant core:relates ?pi . + ?grant rdf:type core:Grant . + ?pi rdf:type core:InvestigatorRole . + } + + +
  • 'Person'-'Grant' linkages (${piship.counts.string})
  • +
    +
    +
    + + + + + PREFIX rdfs: + PREFIX rdf: + PREFIX akt: + PREFIX bibo: + PREFIX core: + SELECT (count(distinct ?pi) as ?counts) WHERE { + ?grant core:relates ?pi . + ?grant rdf:type core:Grant . + ?pi rdf:type core:InvestigatorRole . + } + + +
  • 'Person' entities which are (co-)investigators on 'Grant' entities (${pi.counts.string})
  • +
    +
    +
    + + + + + PREFIX rdfs: + PREFIX rdf: + PREFIX akt: + PREFIX bibo: + PREFIX core: + SELECT (count(distinct ?grant) as ?counts) WHERE { + ?grant rdf:type core:Grant . + } + + +
  • 'Grant' entities (${grant.counts.string})
  • +
    +
    +
    +
+ + +
    + + + + + PREFIX rdfs: + PREFIX rdf: + PREFIX akt: + PREFIX bibo: + PREFIX core: + PREFIX obo: + SELECT (count(*) as ?counts) WHERE { + ?teacher obo:RO_0000053 ?obj . + ?obj rdf:type core:teacherRole . + } + + +
  • 'Person'-'CourseSection' linkages (${teaching.counts.string})
  • +
    +
    +
    + + + + + PREFIX rdfs: + PREFIX rdf: + PREFIX akt: + PREFIX bibo: + PREFIX core: + PREFIX obo: + SELECT (count(distinct ?teacher) as ?counts) WHERE { + ?teacher core:teaching ?obj . + ?teacher obo:RO_0000053 ?obj . + ?obj rdf:type core:teacherRole . + } + + +
  • 'Person' entities which teach 'CourseSection' entities (${teacher.counts.string})
  • +
    +
    +
    + + + + + PREFIX rdfs: + PREFIX rdf: + PREFIX akt: + PREFIX bibo: + PREFIX core: + SELECT (count(?course) as ?counts) WHERE { + ?course rdf:type core:Course . + } + + +
  • 'Course' entities (${course.counts.string})
  • +
    +
    +
    +
+ + +
    + + + + + PREFIX rdfs: + PREFIX rdf: + PREFIX akt: + PREFIX bibo: + PREFIX core: + PREFIX obo: + SELECT (count(*) as ?counts) WHERE { + ?author1 rdf:type core:Authorship . + ?author2 rdf:type core:Authorship . + ?author1 core:relates ?infor . + ?author2 core:relates ?infor . + ?infor rdf:type obo:IAO_0000030 . + FILTER (str(?author1) < str(?author2)) + } + + +
  • Total co-author linkages (${coauthor.counts.string})
  • +
    +
    +
    + + + + + + PREFIX rdfs: + PREFIX rdf: + PREFIX akt: + PREFIX bibo: + PREFIX core: + PREFIX obo: + SELECT DISTINCT ?author1 ?author2 WHERE { + ?author1 rdf:type core:Authorship . + ?author2 rdf:type core:Authorship . + ?author1 core:relates ?infor . + ?author2 core:relates ?infor . + ?infor rdf:type obo:IAO_0000030 . + FILTER (str(?author1) < str(?author2)) + } + +
  • Unique co-author linkages (${fn:length(discoauthors.rows)})
  • +
    +
    +
+ + +
    + + + + + PREFIX rdfs: + PREFIX rdf: + PREFIX akt: + PREFIX bibo: + PREFIX core: + SELECT (count(*) as ?counts) WHERE { + ?grant core:relates ?pi1 . + ?pi1 rdf:type core:InvestigatorRole . + ?grant core:relates ?pi2 . + ?pi1 rdf:type core:InvestigatorRole . + FILTER (str(?pi1) < str(?pi2)) + } + + +
  • Total co-investigator linkages (${copi.counts.string})
  • +
    +
    +
    + + + + + + PREFIX rdfs: + PREFIX rdf: + PREFIX akt: + PREFIX bibo: + PREFIX core: + SELECT DISTINCT ?pi1 ?pi2 WHERE { + ?grant core:relates ?pi1 . + ?pi1 rdf:type core:InvestigatorRole . + ?grant core:relates ?pi2 . + ?pi1 rdf:type core:InvestigatorRole . + FILTER (str(?pi1) < str(?pi2)) + } + +
  • Unique co-investigator linkages (${fn:length(discopis.rows)})
  • +
    +
    + +
+ +
From d81ae170459da8e17b9c36a133e1791996ca516f Mon Sep 17 00:00:00 2001 From: brianjlowe Date: Tue, 5 Nov 2013 13:24:46 -0500 Subject: [PATCH 4/6] VIVO-493 hiding "has participant" / "participates in" --- rdf/tbox/firsttime/initialTBoxAnnotations.n3 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/rdf/tbox/firsttime/initialTBoxAnnotations.n3 b/rdf/tbox/firsttime/initialTBoxAnnotations.n3 index d1586c88..cef6df9c 100644 --- a/rdf/tbox/firsttime/initialTBoxAnnotations.n3 +++ b/rdf/tbox/firsttime/initialTBoxAnnotations.n3 @@ -2159,7 +2159,11 @@ vivo:supports "true"^^xsd:boolean . obo:RO_0000057 - rdfs:label "has participant"@en-US . + rdfs:label "has participant"@en-US ; + vitro:hiddenFromDisplayBelowRoleLevelAnnot + ; + vitro:prohibitedFromUpdateBelowRoleLevelAnnot + . vivo:patentNumber rdfs:label "patent number"@en-US ; @@ -2277,7 +2281,11 @@ obo:ARG_2000084 rdfs:label "American Board of Preventive Medicine"@en-US . obo:RO_0000056 - rdfs:label "participates in"@en-US . + rdfs:label "participates in"@en-US ; + vitro:hiddenFromDisplayBelowRoleLevelAnnot + ; + vitro:prohibitedFromUpdateBelowRoleLevelAnnot + . vcard:timeZone rdfs:label "timezone"@en-US . From 82f603a0f170c04b037fbe9d5842aed7b7e97107 Mon Sep 17 00:00:00 2001 From: tworrall Date: Tue, 5 Nov 2013 13:33:15 -0500 Subject: [PATCH 5/6] VIVO-490 thank you very much and please tip your waitress --- .../AddGrantRoleToPersonGenerator.java | 3 +- .../AddRoleToPersonTwoStageGenerator.java | 1797 +++++++++-------- 2 files changed, 902 insertions(+), 898 deletions(-) diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddGrantRoleToPersonGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddGrantRoleToPersonGenerator.java index 1a94e2d8..09b02453 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddGrantRoleToPersonGenerator.java +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddGrantRoleToPersonGenerator.java @@ -271,7 +271,8 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator urisInScope.put("roleType", Arrays.asList(new String[]{getRoleType(vreq)})); //Setting inverse role predicate - urisInScope.put("inverseRolePredicate", getInversePredicate(vreq)); + // with ISF changes this will always be the same + urisInScope.put("inverseRolePredicate", Arrays.asList(new String[]{"http://purl.obolibrary.org/obo/RO_0000052"})); editConfiguration.setUrisInScope(urisInScope); //Uris in scope include subject, predicate, and object var diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddRoleToPersonTwoStageGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddRoleToPersonTwoStageGenerator.java index 786ee6dc..c05f6c85 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddRoleToPersonTwoStageGenerator.java +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddRoleToPersonTwoStageGenerator.java @@ -1,897 +1,900 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpSession; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.vivoweb.webapp.util.ModelUtils; - -import com.hp.hpl.jena.vocabulary.RDF; -import com.hp.hpl.jena.vocabulary.RDFS; -import com.hp.hpl.jena.vocabulary.XSD; - -import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty; -import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; -import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; -import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; -import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils; -import edu.cornell.mannlib.vitro.webapp.edit.n3editing.AutocompleteRequiredInputValidator; -import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo; -import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo; -import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils; -import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo; -import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ChildVClassesOptions; -import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ConstantFieldOptions; -import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldOptions; -import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo; -import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.IndividualsViaClassGroupOptions; -import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.RoleToActivityPredicatePreprocessor; -import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation; -import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode; -import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils; -/** - * Generates the edit configuration for adding a Role to a Person. - - Stage one is selecting the type of the non-person thing - associated with the Role with the intention of reducing the - number of Individuals that the user has to select from. - Stage two is selecting the non-person Individual to associate - with the Role. - - This is intended to create a set of statements like: - - ?person core:hasResearchActivityRole ?newRole. - ?newRole rdf:type core:ResearchActivityRole ; - roleToActivityPredicate ?someActivity . - ?someActivity rdf:type core:ResearchActivity . - ?someActivity rdfs:label "activity title" . - - - - Important: This form cannot be directly used as a custom form. It has parameters that must be set. - See addClinicalRoleToPerson.jsp for an example. - - roleToActivityPredicate and activityToRolePredicate are both dependent on the type of - the activity itself. For a new statement, the predicate type is not known. - For an existing statement, the predicate is known but may change based on the type of the activity newly selected. - - - bdc34: - TODO: figure out what needs to be customized per role form, document it here in comments - TODO: rewrite class as an abstract class with simple, documented, required methods to override - - AddRoleToPersonTwoStageGenerator is abstract, each subclass will need to configure: - From the old JSP version: - - showRoleLabelField boolean - roleType URI - roleToActivityPredicate URI - activityToRolePredicate URI - roleActivityType_optionsType - roleActivityType_objectClassURI - roleActivityType_literalOptions - - For the new generator version: - template - * - */ -public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigurationGenerator implements EditConfigurationGenerator { - - private Log log = LogFactory.getLog(AddRoleToPersonTwoStageGenerator.class); - - /* ***** Methods that are REQUIRED to be implemented in subclasses ***** */ - -// abstract String getStartDatePrecision(); - -// abstract String getEndDatePrecision(); - - /** Freemarker template to use */ - abstract String getTemplate(); - - /** URI of type for the role context node */ - abstract String getRoleType(); - - /** return the java object that generates the role activity field options for - * the subclass. - * @throws Exception */ - abstract FieldOptions getRoleActivityFieldOptions(VitroRequest vreq) throws Exception; - - /** In the case of literal options, subclass generator will set the options to be returned */ - //not needed any more since the FieldOption can be returned - //abstract HashMap getRoleActivityTypeLiteralOptions(); - - /** - * Each subclass generator will return its own type of option here: - * whether literal hardcoded, based on class group, or subclasses of a specific class - * The latter two will apparently lend some kind of uri to objectClassUri ? */ - //not needed any more since the FieldOption can be returned - //abstract RoleActivityOptionTypes getRoleActivityTypeOptionsType(); - - /** The URI of a Class to use with options if required. An option type like - * CHILD_VCLASSES would reqire a role activity object class URI. */ - //not needed any more since the FieldOption can be returned - //abstract String getRoleActivityTypeObjectClassUri(VitroRequest vreq); - - /** If true an input should be shown on the form for a - * label for the role context node - * TODO: move this to the FTL and have label optional. */ - abstract boolean isShowRoleLabelField(); - - /** URI of predicate between role context node and activity - * @throws Exception */ - //Bdc34: not used anywhere? that's odd - //abstract String getActivityToRolePredicate(); - - @Override - public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) throws Exception { - EditConfigurationVTwo editConfiguration = new EditConfigurationVTwo(); - initProcessParameters(vreq, session, editConfiguration); - - editConfiguration.setVarNameForSubject("person"); - editConfiguration.setVarNameForPredicate("rolePredicate"); - editConfiguration.setVarNameForObject("role"); - - // Required N3 - editConfiguration.setN3Required(list( - N3_PREFIX + "\n" + - "?person ?rolePredicate ?role .\n" + - "?role a ?roleType .\n" + - "?role ?inverseRolePredicate ?person ." - )); - - // Optional N3 - //Note here we are placing the role to activity relationships as optional, since - //it's possible to delete this relationship from the activity - //On submission, if we kept these statements in n3required, the retractions would - //not have all variables substituted, leading to an error - //Note also we are including the relationship as a separate string in the array, to allow it to be - //independently evaluated and passed back with substitutions even if the other strings are not - //substituted correctly. - editConfiguration.setN3Optional( list( - getN3ForNewRoleActivity(), - getN3ForExistingRoleActivity(), -// getN3ForActivityType(), - getN3RoleLabelAssertion(), - getN3ForStart(), - getN3ForEnd() )); - - editConfiguration.setNewResources( newResources(vreq) ); - - //In scope - setUrisAndLiteralsInScope(editConfiguration, vreq); - - //on Form - setUrisAndLiteralsOnForm(editConfiguration, vreq); - - //Sparql queries - setSparqlQueries(editConfiguration, vreq); - - //set fields - setFields(editConfiguration, vreq, EditConfigurationUtils.getPredicateUri(vreq)); - - //Form title and submit label now moved to edit configuration template - //TODO: check if edit configuration template correct place to set those or whether - //additional methods here should be used and reference instead, e.g. edit configuration template could call - //default obj property form.populateTemplate or some such method - //Select from existing also set within template itself - editConfiguration.setTemplate(getTemplate()); - - //Add validator - editConfiguration.addValidator(new DateTimeIntervalValidationVTwo("startField","endField") ); - editConfiguration.addValidator(new AntiXssValidation()); - editConfiguration.addValidator(new AutocompleteRequiredInputValidator("existingRoleActivity", "activityLabel")); - - //Add preprocessors - addPreprocessors(editConfiguration, vreq.getWebappDaoFactory()); - //Adding additional data, specifically edit mode - addFormSpecificData(editConfiguration, vreq); - - //prepare - prepare(vreq, editConfiguration); - return editConfiguration; - } - - private void initProcessParameters(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration) { - editConfiguration.setFormUrl(EditConfigurationUtils.getFormUrlWithoutContext(vreq)); - editConfiguration.setEntityToReturnTo(EditConfigurationUtils.getSubjectUri(vreq)); - } - - /* N3 Required and Optional Generators as well as supporting methods */ - - private List getN3ForNewRoleActivity() { - List n3ForNewRoleActivity = new ArrayList(); - n3ForNewRoleActivity.add("?role " + getRoleToActivityPlaceholder() + " ?roleActivity .\n"+ - "?roleActivity " + getActivityToRolePlaceholder() + " ?role . \n" + - "?roleActivity <" + RDFS.label.getURI() + "> ?activityLabel . \n" + - "?roleActivity a ?roleActivityType ."); - return n3ForNewRoleActivity; - } - - private List getN3ForExistingRoleActivity() { - List n3ForExistingRoleActivity = new ArrayList(); - n3ForExistingRoleActivity.add("?role " + getRoleToActivityPlaceholder() + " ?existingRoleActivity .\n"+ - "?existingRoleActivity " + getActivityToRolePlaceholder() + " ?role . \n" + - "?existingRoleActivity a ?roleActivityType ."); - return n3ForExistingRoleActivity; - } - - - private String getN3RoleLabelAssertion() { - return "?role <" + RDFS.label.getURI() + "> ?roleLabel ."; - } - - private List getN3ForStart() { - List n3ForStart = new ArrayList(); - n3ForStart.add("?role <" + RoleToIntervalURI + "> ?intervalNode ." + - "?intervalNode <" + RDF.type.getURI() + "> <" + IntervalTypeURI + "> ." + - "?intervalNode <" + IntervalToStartURI + "> ?startNode ." + - "?startNode <" + RDF.type.getURI() + "> <" + DateTimeValueTypeURI + "> ." + - "?startNode <" + DateTimeValueURI + "> ?startField-value ." + - "?startNode <" + DateTimePrecisionURI + "> ?startField-precision ."); - return n3ForStart; - } - - private List getN3ForEnd() { - List n3ForEnd = new ArrayList(); - n3ForEnd.add("?role <" + RoleToIntervalURI + "> ?intervalNode . " + - "?intervalNode <" + RDF.type.getURI() + "> <" + IntervalTypeURI + "> ." + - "?intervalNode <" + IntervalToEndURI + "> ?endNode ." + - "?endNode <" + RDF.type.getURI() + "> <" + DateTimeValueTypeURI + "> ." + - "?endNode <" + DateTimeValueURI + "> ?endField-value ." + - "?endNode <" + DateTimePrecisionURI+ "> ?endField-precision ."); - return n3ForEnd; - } - - /** Get new resources */ - private Map newResources(VitroRequest vreq) { - String DEFAULT_NS_TOKEN=null; //null forces the default NS - - HashMap newResources = new HashMap(); - newResources.put("role", DEFAULT_NS_TOKEN); - newResources.put("roleActivity", DEFAULT_NS_TOKEN); - newResources.put("intervalNode", DEFAULT_NS_TOKEN); - newResources.put("startNode", DEFAULT_NS_TOKEN); - newResources.put("endNode", DEFAULT_NS_TOKEN); - return newResources; - } - - /** Set URIS and Literals In Scope and on form and supporting methods */ - private void setUrisAndLiteralsInScope(EditConfigurationVTwo editConfiguration, VitroRequest vreq) { - HashMap> urisInScope = new HashMap>(); - - //Setting inverse role predicate - urisInScope.put("inverseRolePredicate", getInversePredicate(vreq)); - urisInScope.put("roleType", list( getRoleType() ) ); - - //Uris in scope include subject, predicate, and object var - editConfiguration.setUrisInScope(urisInScope); - - //literals in scope empty initially, usually populated by code in prepare for update - //with existing values for variables - } - - private List getInversePredicate(VitroRequest vreq) { - List inversePredicateArray = new ArrayList(); - ObjectProperty op = EditConfigurationUtils.getObjectProperty(vreq); - if(op != null && op.getURIInverse() != null) { - inversePredicateArray.add(op.getURIInverse()); - } - return inversePredicateArray; - } - - private void setUrisAndLiteralsOnForm(EditConfigurationVTwo editConfiguration, VitroRequest vreq) { - List urisOnForm = new ArrayList(); - //add role activity and roleActivityType to uris on form - urisOnForm.add("existingRoleActivity"); - urisOnForm.add("roleActivityType"); - //Also adding the predicates - //TODO: Check how to override this in case of default parameter? Just write hidden input to form? - urisOnForm.add("roleToActivityPredicate"); - urisOnForm.add("activityToRolePredicate"); - editConfiguration.setUrisOnform(urisOnForm); - - //activity label and role label are literals on form - List literalsOnForm = new ArrayList(); - literalsOnForm.add("activityLabel"); - literalsOnForm.add("activityLabelDisplay"); - literalsOnForm.add("roleLabel"); - editConfiguration.setLiteralsOnForm(literalsOnForm); - } - - /** Set SPARQL Queries and supporting methods. - * @throws Exception */ - private void setSparqlQueries(EditConfigurationVTwo editConfiguration, VitroRequest vreq) throws Exception { - //Queries for activity label, role label, start Field value, end Field value - HashMap map = new HashMap(); - map.put("activityLabel", getActivityLabelQuery(vreq)); - map.put("roleLabel", getRoleLabelQuery(vreq)); - map.put("startField-value", getExistingStartDateQuery(vreq)); - map.put("endField-value", getExistingEndDateQuery(vreq)); - - editConfiguration.setSparqlForExistingLiterals(map); - - //Queries for role activity, activity type query, interval node, - // start node, end node, start field precision, endfield precision - map = new HashMap(); - map.put("existingRoleActivity", getExistingRoleActivityQuery(vreq)); - map.put("roleActivityType", getActivityTypeQuery(vreq)); - map.put("intervalNode", getIntervalNodeQuery(vreq)); - map.put("startNode", getStartNodeQuery(vreq)); - map.put("endNode", getEndNodeQuery(vreq)); - map.put("startField-precision", getStartPrecisionQuery(vreq)); - map.put("endField-precision", getEndPrecisionQuery(vreq)); - //Also need sparql queries for roleToActivityPredicate and activityToRolePredicate - map.put("roleToActivityPredicate", getRoleToActivityPredicateQuery(vreq)); - map.put("activityToRolePredicate", getActivityToRolePredicateQuery(vreq)); - - editConfiguration.setSparqlForExistingUris(map); - } - - private String getActivityToRolePredicateQuery(VitroRequest vreq) { - String query = "SELECT ?existingActivityToRolePredicate \n " + - "WHERE { \n" + - "?roleActivity ?existingActivityToRolePredicate ?role .\n"; - //Get possible predicates - List addToQuery = new ArrayList(); - List predicates = getPossibleActivityToRolePredicates(); - for(String p:predicates) { - addToQuery.add("(?existingActivityToRolePredicate=<" + p + ">)"); - } - query += "FILTER (" + StringUtils.join(addToQuery, " || ") + ")\n"; - query += "}"; - return query; - } - - private String getRoleToActivityPredicateQuery(VitroRequest vreq) { - String query = "SELECT ?existingRoleToActivityPredicate \n " + - "WHERE { \n" + - "?role ?existingRoleToActivityPredicate ?roleActivity .\n"; - //Get possible predicates - query += getFilterRoleToActivityPredicate("existingRoleToActivityPredicate"); - query += "\n}"; - return query; - } - - private String getEndPrecisionQuery(VitroRequest vreq) { - String query = "SELECT ?existingEndPrecision WHERE {\n" + - "?role <" + RoleToIntervalURI + "> ?intervalNode .\n" + - "?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + IntervalTypeURI + "> .\n" + - "?intervalNode <" + IntervalToEndURI + "> ?endNode .\n" + - "?endNode <" + VitroVocabulary.RDF_TYPE + "> <" + DateTimeValueTypeURI + "> . \n" + - "?endNode <" + DateTimePrecisionURI + "> ?existingEndPrecision . }"; - return query; - } - - private String getStartPrecisionQuery(VitroRequest vreq) { - String query = "SELECT ?existingStartPrecision WHERE {\n" + - "?role <" + RoleToIntervalURI + "> ?intervalNode .\n" + - "?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + IntervalTypeURI + "> .\n" + - "?intervalNode <" + IntervalToStartURI + "> ?startNode .\n" + - "?startNode <" + VitroVocabulary.RDF_TYPE + "> <" + DateTimeValueTypeURI + "> . \n" + - "?startNode <" + DateTimePrecisionURI + "> ?existingStartPrecision . }"; - return query; - } - - private String getEndNodeQuery(VitroRequest vreq) { - String query = "SELECT ?existingEndNode WHERE {\n"+ - "?role <" + RoleToIntervalURI + "> ?intervalNode .\n"+ - "?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + IntervalTypeURI + "> .\n"+ - "?intervalNode <" + IntervalToEndURI + "> ?existingEndNode . \n"+ - "?existingEndNode <" + VitroVocabulary.RDF_TYPE + "> <" + DateTimeValueTypeURI + "> .}\n"; - return query; - } - - private String getStartNodeQuery(VitroRequest vreq) { - String query = "SELECT ?existingStartNode WHERE {\n"+ - "?role <" + RoleToIntervalURI + "> ?intervalNode .\n"+ - "?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + IntervalTypeURI + "> .\n"+ - "?intervalNode <" + IntervalToStartURI + "> ?existingStartNode . \n"+ - "?existingStartNode <" + VitroVocabulary.RDF_TYPE + "> <" + DateTimeValueTypeURI + "> .}"; - return query; - } - - private String getIntervalNodeQuery(VitroRequest vreq) { - String query = "SELECT ?existingIntervalNode WHERE { \n" + - "?role <" + RoleToIntervalURI + "> ?existingIntervalNode . \n" + - " ?existingIntervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + IntervalTypeURI + "> . }\n"; - return query; - } - - /** - * Utility method for subclasses to make a query for type from a ConstantFieldOptions object. - * @throws Exception - */ - protected String getActivityTypeQueryForConstantOptions(VitroRequest vreq, ConstantFieldOptions fieldOptions ) - throws Exception{ - - //make list of type URIs from options, this can be called with null since - //ConstantFieldOptions doesn't use any of the arguments. - Map options = fieldOptions.getOptions(null, null, null) ; - - if (options != null && options.size() > 0) { - List typeUris = new ArrayList(); - for(String typeUri: options.keySet()) { - if(typeUri != null && !typeUri.isEmpty()) { - typeUris.add("(?existingActivityType = <" + typeUri + ">)"); - } - } - - String defaultActivityTypeQuery = getDefaultActivityTypeQuery(vreq); - String typeFilters = "FILTER (" + StringUtils.join(typeUris, "||") + ")"; - return defaultActivityTypeQuery.replaceAll("}$", "") + typeFilters + "}"; - } else { - return getDefaultActivityTypeQuery(vreq); - } - } - - /** - * Utility method for subclasses to make a query for type from a ChildVClassesOptions object. - * @throws Exception - */ - protected String getActivityTypeQueryForChildVClassOptions(VitroRequest vreq, ChildVClassesOptions opts){ - log.debug("objectClassUri = " + opts.getClassUri()); - return QueryUtils.subUriForQueryVar( - getSubclassActivityTypeQuery(vreq), - "objectClassUri", opts.getClassUri()); - } - - /** - * Utility method for subclasses to make a query for type from a IndividualsViaClassGroupOptions object. - * @throws Exception - */ - protected String getActivityTypeQueryForIndividualsViaClassGroupOptions(VitroRequest vreq, IndividualsViaClassGroupOptions opts){ - log.debug("ClassGroupUri = " + opts.getClassGroupUri()); - return QueryUtils.subUriForQueryVar( - getClassgroupActivityTypeQuery(vreq), - "classgroup", opts.getClassGroupUri()); - } - - /* - * The activity type query results must be limited to the values in the activity type select element. - * Sometimes the query returns a superclass such as owl:Thing instead. - * Make use of vitro:mostSpecificType so that, for example, an individual is both a - * core:InvitedTalk and a core:Presentation, core:InvitedTalk is selected. - * vitro:mostSpecificType alone may not suffice, since it does not guarantee that the value returned - * is in the select list. - * We could still have problems if the value from the select list is not a vitro:mostSpecificType, - * but that is unlikely. - * - */ - private String getActivityTypeQuery(VitroRequest vreq) throws Exception { - - String activityTypeQuery = null; - - FieldOptions fieldOpts = getRoleActivityFieldOptions(vreq); - try{ - if( fieldOpts == null ){ - activityTypeQuery = getDefaultActivityTypeQuery(vreq); - }if( fieldOpts instanceof ConstantFieldOptions ){ - activityTypeQuery = getActivityTypeQueryForConstantOptions(vreq, (ConstantFieldOptions)fieldOpts); // - }else if (fieldOpts instanceof ChildVClassesOptions ){ - activityTypeQuery = getActivityTypeQueryForChildVClassOptions(vreq, (ChildVClassesOptions)fieldOpts); - }else if( fieldOpts instanceof IndividualsViaClassGroupOptions){ - activityTypeQuery = getActivityTypeQueryForIndividualsViaClassGroupOptions(vreq, (IndividualsViaClassGroupOptions)fieldOpts); - } - }catch(Exception ex){ - log.debug("error while building activity type query",ex); - } - activityTypeQuery = getDefaultActivityTypeQuery(vreq); - - //The replacement of activity type query's predicate was only relevant when we actually - //know which predicate is definitely being used here - //Here we have multiple values possible for predicate so the original - //Replacement should only happen when we have an actual predicate - //String replaceRoleToActivityPredicate = getRoleToActivityPredicate(vreq); - activityTypeQuery = QueryUtils.replaceQueryVar(activityTypeQuery, "predicate", getRoleToActivityPlaceholderName()); - - log.debug("Activity type query: " + activityTypeQuery); - return activityTypeQuery; - } - - - private String getDefaultActivityTypeQuery(VitroRequest vreq) { - String query = "PREFIX core: <" + VIVO_NS + ">\n" + - "PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" + - "SELECT ?existingActivityType WHERE { \n" + - " ?role ?predicate ?existingActivity . \n" + - " ?existingActivity vitro:mostSpecificType ?existingActivityType . \n"; - query += getFilterRoleToActivityPredicate("predicate"); - query+= "}"; - return query; - } - - private String getSubclassActivityTypeQuery(VitroRequest vreq) { - String query = "PREFIX core: <" + VIVO_NS + ">\n" + - "PREFIX rdfs: <" + VitroVocabulary.RDFS + ">\n" + - "PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" + - "SELECT ?existingActivityType WHERE {\n" + - " ?role ?predicate ?existingActivity . \n" + - " ?existingActivity vitro:mostSpecificType ?existingActivityType . \n" + - " ?existingActivityType rdfs:subClassOf ?objectClassUri . \n"; - query += getFilterRoleToActivityPredicate("predicate"); - query+= "}"; - return query; - } - - private String getClassgroupActivityTypeQuery(VitroRequest vreq) { - String query = "PREFIX core: <" + VIVO_NS + ">\n" + - "PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" + - "SELECT ?existingActivityType WHERE { \n" + - " ?role ?predicate ?existingActivity . \n" + - " ?existingActivity vitro:mostSpecificType ?existingActivityType . \n" + - " ?existingActivityType vitro:inClassGroup ?classgroup . \n"; - query += getFilterRoleToActivityPredicate("predicate"); - query+= "}"; - return query; - } - - - private String getExistingRoleActivityQuery(VitroRequest vreq) { - //If role to activity predicate is the default query, then we need to replace with a union - //of both realizedIn and the other - String query = "PREFIX core: <" + VIVO_NS + ">"; - - query += "SELECT ?existingRoleActivity WHERE { \n" + - " ?role ?predicate ?existingRoleActivity . \n "; - query += getFilterRoleToActivityPredicate("predicate"); - query += "}"; - return query; - } - - private String getExistingEndDateQuery(VitroRequest vreq) { - String query = " SELECT ?existingEndDate WHERE {\n" + - "?role <" + RoleToIntervalURI + "> ?intervalNode .\n" + - "?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + IntervalTypeURI + "> .\n" + - "?intervalNode <" + IntervalToEndURI + "> ?endNode .\n" + - "?endNode <" + VitroVocabulary.RDF_TYPE + "> <" + DateTimeValueTypeURI + "> .\n" + - "?endNode <" + DateTimeValueURI + "> ?existingEndDate . }"; - return query; - } - - private String getExistingStartDateQuery(VitroRequest vreq) { - String query = "SELECT ?existingDateStart WHERE {\n" + - "?role <" + RoleToIntervalURI + "> ?intervalNode .\n" + - "?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + IntervalTypeURI + "> .\n" + - "?intervalNode <" + IntervalToStartURI+ "> ?startNode .\n" + - "?startNode <" + VitroVocabulary.RDF_TYPE + "> <" + DateTimeValueTypeURI + "> .\n" + - "?startNode <" + DateTimeValueURI + "> ?existingDateStart . }"; - - return query; - } - - private String getRoleLabelQuery(VitroRequest vreq) { - String query = "SELECT ?existingRoleLabel WHERE { \n" + - "?role <" + VitroVocabulary.LABEL + "> ?existingRoleLabel . }"; - return query; - } - - private String getActivityLabelQuery(VitroRequest vreq) { - String query = "PREFIX core: <" + VIVO_NS + ">" + - "PREFIX rdfs: <" + RDFS.getURI() + "> \n"; - - query += "SELECT ?existingTitle WHERE { \n" + - "?role ?predicate ?existingActivity . \n" + - "?existingActivity rdfs:label ?existingTitle . \n"; - query += getFilterRoleToActivityPredicate("predicate"); - query += "}"; - return query; - } - - /** - * - * Set Fields and supporting methods - * @throws Exception - */ - - private void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq, String predicateUri) throws Exception { - Map fields = new HashMap(); - //Multiple fields - getActivityLabelField(editConfiguration, vreq, fields); - getActivityLabelDisplayField(editConfiguration, vreq, fields); - getRoleActivityTypeField(editConfiguration, vreq, fields); - getExistingRoleActivityField(editConfiguration, vreq, fields); - getRoleLabelField(editConfiguration, vreq, fields); - getStartField(editConfiguration, vreq, fields); - getEndField(editConfiguration, vreq, fields); - //These fields are for the predicates that will be set later - //TODO: Do these only if not using a parameter for the predicate? - getRoleToActivityPredicateField(editConfiguration, vreq, fields); - getActivityToRolePredicateField(editConfiguration, vreq, fields); - editConfiguration.setFields(fields); - } - - //This is a literal technically? - private void getActivityToRolePredicateField( - EditConfigurationVTwo editConfiguration, VitroRequest vreq, - Map fields) { - - FieldVTwo field = new FieldVTwo(); - - String fieldName = "activityToRolePredicate"; - field.setName(fieldName); - - //get range data type uri and range language - String stringDatatypeUri = XSD.xstring.toString(); - field.setRangeDatatypeUri( stringDatatypeUri ); - - fields.put(field.getName(), field); - } - - private void getRoleToActivityPredicateField( - EditConfigurationVTwo editConfiguration, VitroRequest vreq, - Map fields) { - - FieldVTwo field = new FieldVTwo(); - - String fieldName = "roleToActivityPredicate"; - field.setName(fieldName); - - //get range data type uri and range language - String stringDatatypeUri = XSD.xstring.toString(); - field.setRangeDatatypeUri(stringDatatypeUri); - - fields.put(field.getName(), field); - } - - //Label of "right side" of role, i.e. label for role roleIn Activity - private void getActivityLabelField(EditConfigurationVTwo editConfiguration, - VitroRequest vreq, Map fields) { - - FieldVTwo field = new FieldVTwo(); - String fieldName = "activityLabel"; - field.setName(fieldName); - - //get range data type uri and range language - String stringDatatypeUri = XSD.xstring.toString(); - field.setRangeDatatypeUri(stringDatatypeUri); - - List validators = new ArrayList(); - validators.add("datatype:" + stringDatatypeUri); - field.setValidators(validators); - - fields.put(field.getName(), field); - } - - private void getActivityLabelDisplayField(EditConfigurationVTwo editConfiguration, - VitroRequest vreq, Map fields) { - FieldVTwo field = new FieldVTwo(); - - String fieldName = "activityLabelDisplay"; - field.setName(fieldName); - - //get range data type uri and range language - String stringDatatypeUri = XSD.xstring.toString(); - field.setRangeDatatypeUri(stringDatatypeUri); - - fields.put(field.getName(), field); - } - - //type of "right side" of role, i.e. type of activity from role roleIn activity - private void getRoleActivityTypeField( - EditConfigurationVTwo editConfiguration, VitroRequest vreq, - Map fields) throws Exception { - String fieldName = "roleActivityType"; - //get range data type uri and range language - - FieldVTwo field = new FieldVTwo(); - field.setName(fieldName); - - List validators = new ArrayList(); - if(isAddMode(vreq) || isRepairMode(vreq)) { - validators.add("nonempty"); - } - field.setValidators(validators); - - field.setOptions( getRoleActivityFieldOptions(vreq) ); - -// field.setOptionsType(getRoleActivityTypeOptionsType().toString()); -// field.setObjectClassUri(getRoleActivityTypeObjectClassUri(vreq)); -// -// HashMap literalOptionsMap = getRoleActivityTypeLiteralOptions(); -// List> fieldLiteralOptions = new ArrayList>(); -// Set optionUris = literalOptionsMap.keySet(); -// for(String optionUri: optionUris) { -// List uriLabelArray = new ArrayList(); -// uriLabelArray.add(optionUri); -// uriLabelArray.add(literalOptionsMap.get(optionUri)); -// fieldLiteralOptions.add(uriLabelArray); -// } -// field.setLiteralOptions(fieldLiteralOptions); - - fields.put(field.getName(), field); - - } - - - - //Assuming URI for activity for role? - private void getExistingRoleActivityField(EditConfigurationVTwo editConfiguration, - VitroRequest vreq, Map fields) { - String fieldName = "existingRoleActivity"; - - FieldVTwo field = new FieldVTwo(); - field.setName(fieldName); - - fields.put(field.getName(), field); - } - - private void getRoleLabelField(EditConfigurationVTwo editConfiguration, - VitroRequest vreq, Map fields) { - String fieldName = "roleLabel"; - - FieldVTwo field = new FieldVTwo(); - field.setName(fieldName); - - String stringDatatypeUri = XSD.xstring.toString(); - field.setRangeDatatypeUri(stringDatatypeUri); - - List validators = new ArrayList(); - validators.add("datatype:" + stringDatatypeUri); - if(isShowRoleLabelField()) { - validators.add("nonempty"); - } - field.setValidators(validators); - - fields.put(field.getName(), field); - } - - private void getStartField(EditConfigurationVTwo editConfiguration, - VitroRequest vreq, Map fields) { - FieldVTwo field = new FieldVTwo(); - - String fieldName = "startField"; - field.setName(fieldName); - - field.setEditElement( - new DateTimeWithPrecisionVTwo(field, - getStartDatePrecision(), - VitroVocabulary.Precision.NONE.uri())); - - fields.put(field.getName(), field); - } - - private void getEndField(EditConfigurationVTwo editConfiguration, - VitroRequest vreq, Map fields) { - FieldVTwo field = new FieldVTwo(); - - String fieldName = "endField"; - field.setName(fieldName); - - field.setEditElement( - new DateTimeWithPrecisionVTwo(field, - getEndDatePrecision(), - VitroVocabulary.Precision.NONE.uri())); - - fields.put(field.getName(), field); - } - - private void addPreprocessors(EditConfigurationVTwo editConfiguration, WebappDaoFactory wadf) { - //Add preprocessor that will replace the role to activity predicate and inverse - //with correct properties based on the activity type - editConfiguration.addEditSubmissionPreprocessor( - new RoleToActivityPredicatePreprocessor(editConfiguration, wadf)); - - } - - //This has a default value, but note that even that will not be used - //in the update with realized in or contributes to - //Overridden when need be in subclassed generator - //Also note that for now we're going to actually going to return a - //placeholder value by default - public String getRoleToActivityPredicate(VitroRequest vreq) { - //TODO: and ?placeholder are incompatible - return getRoleToActivityPlaceholder(); - } - //Ensure when overwritten that this includes the <> b/c otherwise the query won't work - - //Some values will have a default value - - public List getPossibleRoleToActivityPredicates() { - return ModelUtils.getPossiblePropertiesForRole(); - } - - public List getPossibleActivityToRolePredicates() { - return ModelUtils.getPossibleInversePropertiesForRole(); - } - - /* Methods that check edit mode */ - public EditMode getEditMode(VitroRequest vreq) { - List roleToGrantPredicates = getPossibleRoleToActivityPredicates(); - return EditModeUtils.getEditMode(vreq, roleToGrantPredicates); - } - - private boolean isAddMode(VitroRequest vreq) { - return EditModeUtils.isAddMode(getEditMode(vreq)); - } - - private boolean isEditMode(VitroRequest vreq) { - return EditModeUtils.isEditMode(getEditMode(vreq)); - } - - private boolean isRepairMode(VitroRequest vreq) { - return EditModeUtils.isRepairMode(getEditMode(vreq)); - } - - /* URIS for various predicates */ - private final String VIVO_NS="http://vivoweb.org/ontology/core#"; - - private final String RoleToIntervalURI = VIVO_NS + "dateTimeInterval"; - private final String IntervalTypeURI = VIVO_NS + "DateTimeInterval"; - private final String IntervalToStartURI = VIVO_NS + "start"; - private final String IntervalToEndURI = VIVO_NS + "end"; - private final String StartYearPredURI = VIVO_NS + "startYear"; - private final String EndYearPredURI = VIVO_NS + "endYear"; - private final String DateTimeValueTypeURI=VIVO_NS + "DateTimeValue"; - private final String DateTimePrecisionURI=VIVO_NS + "dateTimePrecision"; - private final String DateTimeValueURI = VIVO_NS + "dateTime"; - - //Form specific data - public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) { - HashMap formSpecificData = new HashMap(); - formSpecificData.put("editMode", getEditMode(vreq).name().toLowerCase()); - //Fields that will need select lists generated - //Store field names - List objectSelect = new ArrayList(); - objectSelect.add("roleActivityType"); - //TODO: Check if this is the proper way to do this? - formSpecificData.put("objectSelect", objectSelect); - //Also put in show role label field - formSpecificData.put("showRoleLabelField", isShowRoleLabelField()); - //Put in the fact that we require field - editConfiguration.setFormSpecificData(formSpecificData); - } - - public String getFilterRoleToActivityPredicate(String predicateVar) { - String addFilter = "FILTER ("; - List predicates = getPossibleRoleToActivityPredicates(); - List filterPortions = new ArrayList(); - for(String p: predicates) { - filterPortions.add("(?" + predicateVar + "=<" + p + ">)"); - } - addFilter += StringUtils.join(filterPortions, " || "); - addFilter += ")"; - return addFilter; - } - - private String getRoleToActivityPlaceholder() { - return "?" + getRoleToActivityPlaceholderName(); - } - - private String getRoleToActivityPlaceholderName() { - return "roleToActivityPredicate"; - } - - - private String getActivityToRolePlaceholder() { - return "?activityToRolePredicate"; - } - - //Types of options to populate drop-down for types for the "right side" of the role - public static enum RoleActivityOptionTypes { - VCLASSGROUP, - CHILD_VCLASSES, - HARDCODED_LITERALS - }; - - private final String N3_PREFIX = "@prefix core: ."; - - protected String getStartDatePrecision() { - String precision = VitroVocabulary.Precision.YEAR.uri(); - return precision; - } - - protected String getEndDatePrecision() { - String precision = VitroVocabulary.Precision.YEAR.uri(); - return precision; - } - - -} +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators; + +import java.util.ArrayList; +import java.util.Arrays; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpSession; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.vivoweb.webapp.util.ModelUtils; + +import com.hp.hpl.jena.vocabulary.RDF; +import com.hp.hpl.jena.vocabulary.RDFS; +import com.hp.hpl.jena.vocabulary.XSD; + +import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty; +import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; +import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; +import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; +import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.AutocompleteRequiredInputValidator; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ChildVClassesOptions; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ConstantFieldOptions; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldOptions; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.IndividualsViaClassGroupOptions; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.RoleToActivityPredicatePreprocessor; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation; +import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode; +import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils; +/** + * Generates the edit configuration for adding a Role to a Person. + + Stage one is selecting the type of the non-person thing + associated with the Role with the intention of reducing the + number of Individuals that the user has to select from. + Stage two is selecting the non-person Individual to associate + with the Role. + + This is intended to create a set of statements like: + + ?person core:hasResearchActivityRole ?newRole. + ?newRole rdf:type core:ResearchActivityRole ; + roleToActivityPredicate ?someActivity . + ?someActivity rdf:type core:ResearchActivity . + ?someActivity rdfs:label "activity title" . + + + + Important: This form cannot be directly used as a custom form. It has parameters that must be set. + See addClinicalRoleToPerson.jsp for an example. + + roleToActivityPredicate and activityToRolePredicate are both dependent on the type of + the activity itself. For a new statement, the predicate type is not known. + For an existing statement, the predicate is known but may change based on the type of the activity newly selected. + + + bdc34: + TODO: figure out what needs to be customized per role form, document it here in comments + TODO: rewrite class as an abstract class with simple, documented, required methods to override + + AddRoleToPersonTwoStageGenerator is abstract, each subclass will need to configure: + From the old JSP version: + + showRoleLabelField boolean + roleType URI + roleToActivityPredicate URI + activityToRolePredicate URI + roleActivityType_optionsType + roleActivityType_objectClassURI + roleActivityType_literalOptions + + For the new generator version: + template + * + */ +public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigurationGenerator implements EditConfigurationGenerator { + + private Log log = LogFactory.getLog(AddRoleToPersonTwoStageGenerator.class); + + /* ***** Methods that are REQUIRED to be implemented in subclasses ***** */ + +// abstract String getStartDatePrecision(); + +// abstract String getEndDatePrecision(); + + /** Freemarker template to use */ + abstract String getTemplate(); + + /** URI of type for the role context node */ + abstract String getRoleType(); + + /** return the java object that generates the role activity field options for + * the subclass. + * @throws Exception */ + abstract FieldOptions getRoleActivityFieldOptions(VitroRequest vreq) throws Exception; + + /** In the case of literal options, subclass generator will set the options to be returned */ + //not needed any more since the FieldOption can be returned + //abstract HashMap getRoleActivityTypeLiteralOptions(); + + /** + * Each subclass generator will return its own type of option here: + * whether literal hardcoded, based on class group, or subclasses of a specific class + * The latter two will apparently lend some kind of uri to objectClassUri ? */ + //not needed any more since the FieldOption can be returned + //abstract RoleActivityOptionTypes getRoleActivityTypeOptionsType(); + + /** The URI of a Class to use with options if required. An option type like + * CHILD_VCLASSES would reqire a role activity object class URI. */ + //not needed any more since the FieldOption can be returned + //abstract String getRoleActivityTypeObjectClassUri(VitroRequest vreq); + + /** If true an input should be shown on the form for a + * label for the role context node + * TODO: move this to the FTL and have label optional. */ + abstract boolean isShowRoleLabelField(); + + /** URI of predicate between role context node and activity + * @throws Exception */ + //Bdc34: not used anywhere? that's odd + //abstract String getActivityToRolePredicate(); + + @Override + public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) throws Exception { + EditConfigurationVTwo editConfiguration = new EditConfigurationVTwo(); + initProcessParameters(vreq, session, editConfiguration); + + editConfiguration.setVarNameForSubject("person"); + editConfiguration.setVarNameForPredicate("rolePredicate"); + editConfiguration.setVarNameForObject("role"); + + // Required N3 + editConfiguration.setN3Required(list( + N3_PREFIX + "\n" + + "?person ?rolePredicate ?role .\n" + + "?role a ?roleType .\n" + + "?role ?inverseRolePredicate ?person ." + )); + + // Optional N3 + //Note here we are placing the role to activity relationships as optional, since + //it's possible to delete this relationship from the activity + //On submission, if we kept these statements in n3required, the retractions would + //not have all variables substituted, leading to an error + //Note also we are including the relationship as a separate string in the array, to allow it to be + //independently evaluated and passed back with substitutions even if the other strings are not + //substituted correctly. + editConfiguration.setN3Optional( list( + getN3ForNewRoleActivity(), + getN3ForExistingRoleActivity(), +// getN3ForActivityType(), + getN3RoleLabelAssertion(), + getN3ForStart(), + getN3ForEnd() )); + + editConfiguration.setNewResources( newResources(vreq) ); + + //In scope + setUrisAndLiteralsInScope(editConfiguration, vreq); + + //on Form + setUrisAndLiteralsOnForm(editConfiguration, vreq); + + //Sparql queries + setSparqlQueries(editConfiguration, vreq); + + //set fields + setFields(editConfiguration, vreq, EditConfigurationUtils.getPredicateUri(vreq)); + + //Form title and submit label now moved to edit configuration template + //TODO: check if edit configuration template correct place to set those or whether + //additional methods here should be used and reference instead, e.g. edit configuration template could call + //default obj property form.populateTemplate or some such method + //Select from existing also set within template itself + editConfiguration.setTemplate(getTemplate()); + + //Add validator + editConfiguration.addValidator(new DateTimeIntervalValidationVTwo("startField","endField") ); + editConfiguration.addValidator(new AntiXssValidation()); + editConfiguration.addValidator(new AutocompleteRequiredInputValidator("existingRoleActivity", "activityLabel")); + + //Add preprocessors + addPreprocessors(editConfiguration, vreq.getWebappDaoFactory()); + //Adding additional data, specifically edit mode + addFormSpecificData(editConfiguration, vreq); + + //prepare + prepare(vreq, editConfiguration); + return editConfiguration; + } + + private void initProcessParameters(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration) { + editConfiguration.setFormUrl(EditConfigurationUtils.getFormUrlWithoutContext(vreq)); + editConfiguration.setEntityToReturnTo(EditConfigurationUtils.getSubjectUri(vreq)); + } + + /* N3 Required and Optional Generators as well as supporting methods */ + + private List getN3ForNewRoleActivity() { + List n3ForNewRoleActivity = new ArrayList(); + n3ForNewRoleActivity.add("?role " + getRoleToActivityPlaceholder() + " ?roleActivity .\n"+ + "?roleActivity " + getActivityToRolePlaceholder() + " ?role . \n" + + "?roleActivity <" + RDFS.label.getURI() + "> ?activityLabel . \n" + + "?roleActivity a ?roleActivityType ."); + return n3ForNewRoleActivity; + } + + private List getN3ForExistingRoleActivity() { + List n3ForExistingRoleActivity = new ArrayList(); + n3ForExistingRoleActivity.add("?role " + getRoleToActivityPlaceholder() + " ?existingRoleActivity .\n"+ + "?existingRoleActivity " + getActivityToRolePlaceholder() + " ?role . \n" + + "?existingRoleActivity a ?roleActivityType ."); + return n3ForExistingRoleActivity; + } + + + private String getN3RoleLabelAssertion() { + return "?role <" + RDFS.label.getURI() + "> ?roleLabel ."; + } + + private List getN3ForStart() { + List n3ForStart = new ArrayList(); + n3ForStart.add("?role <" + RoleToIntervalURI + "> ?intervalNode ." + + "?intervalNode <" + RDF.type.getURI() + "> <" + IntervalTypeURI + "> ." + + "?intervalNode <" + IntervalToStartURI + "> ?startNode ." + + "?startNode <" + RDF.type.getURI() + "> <" + DateTimeValueTypeURI + "> ." + + "?startNode <" + DateTimeValueURI + "> ?startField-value ." + + "?startNode <" + DateTimePrecisionURI + "> ?startField-precision ."); + return n3ForStart; + } + + private List getN3ForEnd() { + List n3ForEnd = new ArrayList(); + n3ForEnd.add("?role <" + RoleToIntervalURI + "> ?intervalNode . " + + "?intervalNode <" + RDF.type.getURI() + "> <" + IntervalTypeURI + "> ." + + "?intervalNode <" + IntervalToEndURI + "> ?endNode ." + + "?endNode <" + RDF.type.getURI() + "> <" + DateTimeValueTypeURI + "> ." + + "?endNode <" + DateTimeValueURI + "> ?endField-value ." + + "?endNode <" + DateTimePrecisionURI+ "> ?endField-precision ."); + return n3ForEnd; + } + + /** Get new resources */ + private Map newResources(VitroRequest vreq) { + String DEFAULT_NS_TOKEN=null; //null forces the default NS + + HashMap newResources = new HashMap(); + newResources.put("role", DEFAULT_NS_TOKEN); + newResources.put("roleActivity", DEFAULT_NS_TOKEN); + newResources.put("intervalNode", DEFAULT_NS_TOKEN); + newResources.put("startNode", DEFAULT_NS_TOKEN); + newResources.put("endNode", DEFAULT_NS_TOKEN); + return newResources; + } + + /** Set URIS and Literals In Scope and on form and supporting methods */ + private void setUrisAndLiteralsInScope(EditConfigurationVTwo editConfiguration, VitroRequest vreq) { + HashMap> urisInScope = new HashMap>(); + + //Setting inverse role predicate + //With ISF changes this will always be the same + urisInScope.put("inverseRolePredicate", Arrays.asList(new String[]{"http://purl.obolibrary.org/obo/RO_0000052"})); + urisInScope.put("roleType", list( getRoleType() ) ); + + //Uris in scope include subject, predicate, and object var + editConfiguration.setUrisInScope(urisInScope); + + //literals in scope empty initially, usually populated by code in prepare for update + //with existing values for variables + } + + private List getInversePredicate(VitroRequest vreq) { + List inversePredicateArray = new ArrayList(); + ObjectProperty op = EditConfigurationUtils.getObjectProperty(vreq); + if(op != null && op.getURIInverse() != null) { + inversePredicateArray.add(op.getURIInverse()); + } + return inversePredicateArray; + } + + private void setUrisAndLiteralsOnForm(EditConfigurationVTwo editConfiguration, VitroRequest vreq) { + List urisOnForm = new ArrayList(); + //add role activity and roleActivityType to uris on form + urisOnForm.add("existingRoleActivity"); + urisOnForm.add("roleActivityType"); + //Also adding the predicates + //TODO: Check how to override this in case of default parameter? Just write hidden input to form? + urisOnForm.add("roleToActivityPredicate"); + urisOnForm.add("activityToRolePredicate"); + editConfiguration.setUrisOnform(urisOnForm); + + //activity label and role label are literals on form + List literalsOnForm = new ArrayList(); + literalsOnForm.add("activityLabel"); + literalsOnForm.add("activityLabelDisplay"); + literalsOnForm.add("roleLabel"); + editConfiguration.setLiteralsOnForm(literalsOnForm); + } + + /** Set SPARQL Queries and supporting methods. + * @throws Exception */ + private void setSparqlQueries(EditConfigurationVTwo editConfiguration, VitroRequest vreq) throws Exception { + //Queries for activity label, role label, start Field value, end Field value + HashMap map = new HashMap(); + map.put("activityLabel", getActivityLabelQuery(vreq)); + map.put("roleLabel", getRoleLabelQuery(vreq)); + map.put("startField-value", getExistingStartDateQuery(vreq)); + map.put("endField-value", getExistingEndDateQuery(vreq)); + + editConfiguration.setSparqlForExistingLiterals(map); + + //Queries for role activity, activity type query, interval node, + // start node, end node, start field precision, endfield precision + map = new HashMap(); + map.put("existingRoleActivity", getExistingRoleActivityQuery(vreq)); + map.put("roleActivityType", getActivityTypeQuery(vreq)); + map.put("intervalNode", getIntervalNodeQuery(vreq)); + map.put("startNode", getStartNodeQuery(vreq)); + map.put("endNode", getEndNodeQuery(vreq)); + map.put("startField-precision", getStartPrecisionQuery(vreq)); + map.put("endField-precision", getEndPrecisionQuery(vreq)); + //Also need sparql queries for roleToActivityPredicate and activityToRolePredicate + map.put("roleToActivityPredicate", getRoleToActivityPredicateQuery(vreq)); + map.put("activityToRolePredicate", getActivityToRolePredicateQuery(vreq)); + + editConfiguration.setSparqlForExistingUris(map); + } + + private String getActivityToRolePredicateQuery(VitroRequest vreq) { + String query = "SELECT ?existingActivityToRolePredicate \n " + + "WHERE { \n" + + "?roleActivity ?existingActivityToRolePredicate ?role .\n"; + //Get possible predicates + List addToQuery = new ArrayList(); + List predicates = getPossibleActivityToRolePredicates(); + for(String p:predicates) { + addToQuery.add("(?existingActivityToRolePredicate=<" + p + ">)"); + } + query += "FILTER (" + StringUtils.join(addToQuery, " || ") + ")\n"; + query += "}"; + return query; + } + + private String getRoleToActivityPredicateQuery(VitroRequest vreq) { + String query = "SELECT ?existingRoleToActivityPredicate \n " + + "WHERE { \n" + + "?role ?existingRoleToActivityPredicate ?roleActivity .\n"; + //Get possible predicates + query += getFilterRoleToActivityPredicate("existingRoleToActivityPredicate"); + query += "\n}"; + return query; + } + + private String getEndPrecisionQuery(VitroRequest vreq) { + String query = "SELECT ?existingEndPrecision WHERE {\n" + + "?role <" + RoleToIntervalURI + "> ?intervalNode .\n" + + "?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + IntervalTypeURI + "> .\n" + + "?intervalNode <" + IntervalToEndURI + "> ?endNode .\n" + + "?endNode <" + VitroVocabulary.RDF_TYPE + "> <" + DateTimeValueTypeURI + "> . \n" + + "?endNode <" + DateTimePrecisionURI + "> ?existingEndPrecision . }"; + return query; + } + + private String getStartPrecisionQuery(VitroRequest vreq) { + String query = "SELECT ?existingStartPrecision WHERE {\n" + + "?role <" + RoleToIntervalURI + "> ?intervalNode .\n" + + "?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + IntervalTypeURI + "> .\n" + + "?intervalNode <" + IntervalToStartURI + "> ?startNode .\n" + + "?startNode <" + VitroVocabulary.RDF_TYPE + "> <" + DateTimeValueTypeURI + "> . \n" + + "?startNode <" + DateTimePrecisionURI + "> ?existingStartPrecision . }"; + return query; + } + + private String getEndNodeQuery(VitroRequest vreq) { + String query = "SELECT ?existingEndNode WHERE {\n"+ + "?role <" + RoleToIntervalURI + "> ?intervalNode .\n"+ + "?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + IntervalTypeURI + "> .\n"+ + "?intervalNode <" + IntervalToEndURI + "> ?existingEndNode . \n"+ + "?existingEndNode <" + VitroVocabulary.RDF_TYPE + "> <" + DateTimeValueTypeURI + "> .}\n"; + return query; + } + + private String getStartNodeQuery(VitroRequest vreq) { + String query = "SELECT ?existingStartNode WHERE {\n"+ + "?role <" + RoleToIntervalURI + "> ?intervalNode .\n"+ + "?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + IntervalTypeURI + "> .\n"+ + "?intervalNode <" + IntervalToStartURI + "> ?existingStartNode . \n"+ + "?existingStartNode <" + VitroVocabulary.RDF_TYPE + "> <" + DateTimeValueTypeURI + "> .}"; + return query; + } + + private String getIntervalNodeQuery(VitroRequest vreq) { + String query = "SELECT ?existingIntervalNode WHERE { \n" + + "?role <" + RoleToIntervalURI + "> ?existingIntervalNode . \n" + + " ?existingIntervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + IntervalTypeURI + "> . }\n"; + return query; + } + + /** + * Utility method for subclasses to make a query for type from a ConstantFieldOptions object. + * @throws Exception + */ + protected String getActivityTypeQueryForConstantOptions(VitroRequest vreq, ConstantFieldOptions fieldOptions ) + throws Exception{ + + //make list of type URIs from options, this can be called with null since + //ConstantFieldOptions doesn't use any of the arguments. + Map options = fieldOptions.getOptions(null, null, null) ; + + if (options != null && options.size() > 0) { + List typeUris = new ArrayList(); + for(String typeUri: options.keySet()) { + if(typeUri != null && !typeUri.isEmpty()) { + typeUris.add("(?existingActivityType = <" + typeUri + ">)"); + } + } + + String defaultActivityTypeQuery = getDefaultActivityTypeQuery(vreq); + String typeFilters = "FILTER (" + StringUtils.join(typeUris, "||") + ")"; + return defaultActivityTypeQuery.replaceAll("}$", "") + typeFilters + "}"; + } else { + return getDefaultActivityTypeQuery(vreq); + } + } + + /** + * Utility method for subclasses to make a query for type from a ChildVClassesOptions object. + * @throws Exception + */ + protected String getActivityTypeQueryForChildVClassOptions(VitroRequest vreq, ChildVClassesOptions opts){ + log.debug("objectClassUri = " + opts.getClassUri()); + return QueryUtils.subUriForQueryVar( + getSubclassActivityTypeQuery(vreq), + "objectClassUri", opts.getClassUri()); + } + + /** + * Utility method for subclasses to make a query for type from a IndividualsViaClassGroupOptions object. + * @throws Exception + */ + protected String getActivityTypeQueryForIndividualsViaClassGroupOptions(VitroRequest vreq, IndividualsViaClassGroupOptions opts){ + log.debug("ClassGroupUri = " + opts.getClassGroupUri()); + return QueryUtils.subUriForQueryVar( + getClassgroupActivityTypeQuery(vreq), + "classgroup", opts.getClassGroupUri()); + } + + /* + * The activity type query results must be limited to the values in the activity type select element. + * Sometimes the query returns a superclass such as owl:Thing instead. + * Make use of vitro:mostSpecificType so that, for example, an individual is both a + * core:InvitedTalk and a core:Presentation, core:InvitedTalk is selected. + * vitro:mostSpecificType alone may not suffice, since it does not guarantee that the value returned + * is in the select list. + * We could still have problems if the value from the select list is not a vitro:mostSpecificType, + * but that is unlikely. + * + */ + private String getActivityTypeQuery(VitroRequest vreq) throws Exception { + + String activityTypeQuery = null; + + FieldOptions fieldOpts = getRoleActivityFieldOptions(vreq); + try{ + if( fieldOpts == null ){ + activityTypeQuery = getDefaultActivityTypeQuery(vreq); + }if( fieldOpts instanceof ConstantFieldOptions ){ + activityTypeQuery = getActivityTypeQueryForConstantOptions(vreq, (ConstantFieldOptions)fieldOpts); // + }else if (fieldOpts instanceof ChildVClassesOptions ){ + activityTypeQuery = getActivityTypeQueryForChildVClassOptions(vreq, (ChildVClassesOptions)fieldOpts); + }else if( fieldOpts instanceof IndividualsViaClassGroupOptions){ + activityTypeQuery = getActivityTypeQueryForIndividualsViaClassGroupOptions(vreq, (IndividualsViaClassGroupOptions)fieldOpts); + } + }catch(Exception ex){ + log.debug("error while building activity type query",ex); + } + activityTypeQuery = getDefaultActivityTypeQuery(vreq); + + //The replacement of activity type query's predicate was only relevant when we actually + //know which predicate is definitely being used here + //Here we have multiple values possible for predicate so the original + //Replacement should only happen when we have an actual predicate + //String replaceRoleToActivityPredicate = getRoleToActivityPredicate(vreq); + activityTypeQuery = QueryUtils.replaceQueryVar(activityTypeQuery, "predicate", getRoleToActivityPlaceholderName()); + + log.debug("Activity type query: " + activityTypeQuery); + return activityTypeQuery; + } + + + private String getDefaultActivityTypeQuery(VitroRequest vreq) { + String query = "PREFIX core: <" + VIVO_NS + ">\n" + + "PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" + + "SELECT ?existingActivityType WHERE { \n" + + " ?role ?predicate ?existingActivity . \n" + + " ?existingActivity vitro:mostSpecificType ?existingActivityType . \n"; + query += getFilterRoleToActivityPredicate("predicate"); + query+= "}"; + return query; + } + + private String getSubclassActivityTypeQuery(VitroRequest vreq) { + String query = "PREFIX core: <" + VIVO_NS + ">\n" + + "PREFIX rdfs: <" + VitroVocabulary.RDFS + ">\n" + + "PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" + + "SELECT ?existingActivityType WHERE {\n" + + " ?role ?predicate ?existingActivity . \n" + + " ?existingActivity vitro:mostSpecificType ?existingActivityType . \n" + + " ?existingActivityType rdfs:subClassOf ?objectClassUri . \n"; + query += getFilterRoleToActivityPredicate("predicate"); + query+= "}"; + return query; + } + + private String getClassgroupActivityTypeQuery(VitroRequest vreq) { + String query = "PREFIX core: <" + VIVO_NS + ">\n" + + "PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" + + "SELECT ?existingActivityType WHERE { \n" + + " ?role ?predicate ?existingActivity . \n" + + " ?existingActivity vitro:mostSpecificType ?existingActivityType . \n" + + " ?existingActivityType vitro:inClassGroup ?classgroup . \n"; + query += getFilterRoleToActivityPredicate("predicate"); + query+= "}"; + return query; + } + + + private String getExistingRoleActivityQuery(VitroRequest vreq) { + //If role to activity predicate is the default query, then we need to replace with a union + //of both realizedIn and the other + String query = "PREFIX core: <" + VIVO_NS + ">"; + + query += "SELECT ?existingRoleActivity WHERE { \n" + + " ?role ?predicate ?existingRoleActivity . \n "; + query += getFilterRoleToActivityPredicate("predicate"); + query += "}"; + return query; + } + + private String getExistingEndDateQuery(VitroRequest vreq) { + String query = " SELECT ?existingEndDate WHERE {\n" + + "?role <" + RoleToIntervalURI + "> ?intervalNode .\n" + + "?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + IntervalTypeURI + "> .\n" + + "?intervalNode <" + IntervalToEndURI + "> ?endNode .\n" + + "?endNode <" + VitroVocabulary.RDF_TYPE + "> <" + DateTimeValueTypeURI + "> .\n" + + "?endNode <" + DateTimeValueURI + "> ?existingEndDate . }"; + return query; + } + + private String getExistingStartDateQuery(VitroRequest vreq) { + String query = "SELECT ?existingDateStart WHERE {\n" + + "?role <" + RoleToIntervalURI + "> ?intervalNode .\n" + + "?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + IntervalTypeURI + "> .\n" + + "?intervalNode <" + IntervalToStartURI+ "> ?startNode .\n" + + "?startNode <" + VitroVocabulary.RDF_TYPE + "> <" + DateTimeValueTypeURI + "> .\n" + + "?startNode <" + DateTimeValueURI + "> ?existingDateStart . }"; + + return query; + } + + private String getRoleLabelQuery(VitroRequest vreq) { + String query = "SELECT ?existingRoleLabel WHERE { \n" + + "?role <" + VitroVocabulary.LABEL + "> ?existingRoleLabel . }"; + return query; + } + + private String getActivityLabelQuery(VitroRequest vreq) { + String query = "PREFIX core: <" + VIVO_NS + ">" + + "PREFIX rdfs: <" + RDFS.getURI() + "> \n"; + + query += "SELECT ?existingTitle WHERE { \n" + + "?role ?predicate ?existingActivity . \n" + + "?existingActivity rdfs:label ?existingTitle . \n"; + query += getFilterRoleToActivityPredicate("predicate"); + query += "}"; + return query; + } + + /** + * + * Set Fields and supporting methods + * @throws Exception + */ + + private void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq, String predicateUri) throws Exception { + Map fields = new HashMap(); + //Multiple fields + getActivityLabelField(editConfiguration, vreq, fields); + getActivityLabelDisplayField(editConfiguration, vreq, fields); + getRoleActivityTypeField(editConfiguration, vreq, fields); + getExistingRoleActivityField(editConfiguration, vreq, fields); + getRoleLabelField(editConfiguration, vreq, fields); + getStartField(editConfiguration, vreq, fields); + getEndField(editConfiguration, vreq, fields); + //These fields are for the predicates that will be set later + //TODO: Do these only if not using a parameter for the predicate? + getRoleToActivityPredicateField(editConfiguration, vreq, fields); + getActivityToRolePredicateField(editConfiguration, vreq, fields); + editConfiguration.setFields(fields); + } + + //This is a literal technically? + private void getActivityToRolePredicateField( + EditConfigurationVTwo editConfiguration, VitroRequest vreq, + Map fields) { + + FieldVTwo field = new FieldVTwo(); + + String fieldName = "activityToRolePredicate"; + field.setName(fieldName); + + //get range data type uri and range language + String stringDatatypeUri = XSD.xstring.toString(); + field.setRangeDatatypeUri( stringDatatypeUri ); + + fields.put(field.getName(), field); + } + + private void getRoleToActivityPredicateField( + EditConfigurationVTwo editConfiguration, VitroRequest vreq, + Map fields) { + + FieldVTwo field = new FieldVTwo(); + + String fieldName = "roleToActivityPredicate"; + field.setName(fieldName); + + //get range data type uri and range language + String stringDatatypeUri = XSD.xstring.toString(); + field.setRangeDatatypeUri(stringDatatypeUri); + + fields.put(field.getName(), field); + } + + //Label of "right side" of role, i.e. label for role roleIn Activity + private void getActivityLabelField(EditConfigurationVTwo editConfiguration, + VitroRequest vreq, Map fields) { + + FieldVTwo field = new FieldVTwo(); + String fieldName = "activityLabel"; + field.setName(fieldName); + + //get range data type uri and range language + String stringDatatypeUri = XSD.xstring.toString(); + field.setRangeDatatypeUri(stringDatatypeUri); + + List validators = new ArrayList(); + validators.add("datatype:" + stringDatatypeUri); + field.setValidators(validators); + + fields.put(field.getName(), field); + } + + private void getActivityLabelDisplayField(EditConfigurationVTwo editConfiguration, + VitroRequest vreq, Map fields) { + FieldVTwo field = new FieldVTwo(); + + String fieldName = "activityLabelDisplay"; + field.setName(fieldName); + + //get range data type uri and range language + String stringDatatypeUri = XSD.xstring.toString(); + field.setRangeDatatypeUri(stringDatatypeUri); + + fields.put(field.getName(), field); + } + + //type of "right side" of role, i.e. type of activity from role roleIn activity + private void getRoleActivityTypeField( + EditConfigurationVTwo editConfiguration, VitroRequest vreq, + Map fields) throws Exception { + String fieldName = "roleActivityType"; + //get range data type uri and range language + + FieldVTwo field = new FieldVTwo(); + field.setName(fieldName); + + List validators = new ArrayList(); + if(isAddMode(vreq) || isRepairMode(vreq)) { + validators.add("nonempty"); + } + field.setValidators(validators); + + field.setOptions( getRoleActivityFieldOptions(vreq) ); + +// field.setOptionsType(getRoleActivityTypeOptionsType().toString()); +// field.setObjectClassUri(getRoleActivityTypeObjectClassUri(vreq)); +// +// HashMap literalOptionsMap = getRoleActivityTypeLiteralOptions(); +// List> fieldLiteralOptions = new ArrayList>(); +// Set optionUris = literalOptionsMap.keySet(); +// for(String optionUri: optionUris) { +// List uriLabelArray = new ArrayList(); +// uriLabelArray.add(optionUri); +// uriLabelArray.add(literalOptionsMap.get(optionUri)); +// fieldLiteralOptions.add(uriLabelArray); +// } +// field.setLiteralOptions(fieldLiteralOptions); + + fields.put(field.getName(), field); + + } + + + + //Assuming URI for activity for role? + private void getExistingRoleActivityField(EditConfigurationVTwo editConfiguration, + VitroRequest vreq, Map fields) { + String fieldName = "existingRoleActivity"; + + FieldVTwo field = new FieldVTwo(); + field.setName(fieldName); + + fields.put(field.getName(), field); + } + + private void getRoleLabelField(EditConfigurationVTwo editConfiguration, + VitroRequest vreq, Map fields) { + String fieldName = "roleLabel"; + + FieldVTwo field = new FieldVTwo(); + field.setName(fieldName); + + String stringDatatypeUri = XSD.xstring.toString(); + field.setRangeDatatypeUri(stringDatatypeUri); + + List validators = new ArrayList(); + validators.add("datatype:" + stringDatatypeUri); + if(isShowRoleLabelField()) { + validators.add("nonempty"); + } + field.setValidators(validators); + + fields.put(field.getName(), field); + } + + private void getStartField(EditConfigurationVTwo editConfiguration, + VitroRequest vreq, Map fields) { + FieldVTwo field = new FieldVTwo(); + + String fieldName = "startField"; + field.setName(fieldName); + + field.setEditElement( + new DateTimeWithPrecisionVTwo(field, + getStartDatePrecision(), + VitroVocabulary.Precision.NONE.uri())); + + fields.put(field.getName(), field); + } + + private void getEndField(EditConfigurationVTwo editConfiguration, + VitroRequest vreq, Map fields) { + FieldVTwo field = new FieldVTwo(); + + String fieldName = "endField"; + field.setName(fieldName); + + field.setEditElement( + new DateTimeWithPrecisionVTwo(field, + getEndDatePrecision(), + VitroVocabulary.Precision.NONE.uri())); + + fields.put(field.getName(), field); + } + + private void addPreprocessors(EditConfigurationVTwo editConfiguration, WebappDaoFactory wadf) { + //Add preprocessor that will replace the role to activity predicate and inverse + //with correct properties based on the activity type + editConfiguration.addEditSubmissionPreprocessor( + new RoleToActivityPredicatePreprocessor(editConfiguration, wadf)); + + } + + //This has a default value, but note that even that will not be used + //in the update with realized in or contributes to + //Overridden when need be in subclassed generator + //Also note that for now we're going to actually going to return a + //placeholder value by default + public String getRoleToActivityPredicate(VitroRequest vreq) { + //TODO: and ?placeholder are incompatible + return getRoleToActivityPlaceholder(); + } + //Ensure when overwritten that this includes the <> b/c otherwise the query won't work + + //Some values will have a default value + + public List getPossibleRoleToActivityPredicates() { + return ModelUtils.getPossiblePropertiesForRole(); + } + + public List getPossibleActivityToRolePredicates() { + return ModelUtils.getPossibleInversePropertiesForRole(); + } + + /* Methods that check edit mode */ + public EditMode getEditMode(VitroRequest vreq) { + List roleToGrantPredicates = getPossibleRoleToActivityPredicates(); + return EditModeUtils.getEditMode(vreq, roleToGrantPredicates); + } + + private boolean isAddMode(VitroRequest vreq) { + return EditModeUtils.isAddMode(getEditMode(vreq)); + } + + private boolean isEditMode(VitroRequest vreq) { + return EditModeUtils.isEditMode(getEditMode(vreq)); + } + + private boolean isRepairMode(VitroRequest vreq) { + return EditModeUtils.isRepairMode(getEditMode(vreq)); + } + + /* URIS for various predicates */ + private final String VIVO_NS="http://vivoweb.org/ontology/core#"; + + private final String RoleToIntervalURI = VIVO_NS + "dateTimeInterval"; + private final String IntervalTypeURI = VIVO_NS + "DateTimeInterval"; + private final String IntervalToStartURI = VIVO_NS + "start"; + private final String IntervalToEndURI = VIVO_NS + "end"; + private final String StartYearPredURI = VIVO_NS + "startYear"; + private final String EndYearPredURI = VIVO_NS + "endYear"; + private final String DateTimeValueTypeURI=VIVO_NS + "DateTimeValue"; + private final String DateTimePrecisionURI=VIVO_NS + "dateTimePrecision"; + private final String DateTimeValueURI = VIVO_NS + "dateTime"; + + //Form specific data + public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) { + HashMap formSpecificData = new HashMap(); + formSpecificData.put("editMode", getEditMode(vreq).name().toLowerCase()); + //Fields that will need select lists generated + //Store field names + List objectSelect = new ArrayList(); + objectSelect.add("roleActivityType"); + //TODO: Check if this is the proper way to do this? + formSpecificData.put("objectSelect", objectSelect); + //Also put in show role label field + formSpecificData.put("showRoleLabelField", isShowRoleLabelField()); + //Put in the fact that we require field + editConfiguration.setFormSpecificData(formSpecificData); + } + + public String getFilterRoleToActivityPredicate(String predicateVar) { + String addFilter = "FILTER ("; + List predicates = getPossibleRoleToActivityPredicates(); + List filterPortions = new ArrayList(); + for(String p: predicates) { + filterPortions.add("(?" + predicateVar + "=<" + p + ">)"); + } + addFilter += StringUtils.join(filterPortions, " || "); + addFilter += ")"; + return addFilter; + } + + private String getRoleToActivityPlaceholder() { + return "?" + getRoleToActivityPlaceholderName(); + } + + private String getRoleToActivityPlaceholderName() { + return "roleToActivityPredicate"; + } + + + private String getActivityToRolePlaceholder() { + return "?activityToRolePredicate"; + } + + //Types of options to populate drop-down for types for the "right side" of the role + public static enum RoleActivityOptionTypes { + VCLASSGROUP, + CHILD_VCLASSES, + HARDCODED_LITERALS + }; + + private final String N3_PREFIX = "@prefix core: ."; + + protected String getStartDatePrecision() { + String precision = VitroVocabulary.Precision.YEAR.uri(); + return precision; + } + + protected String getEndDatePrecision() { + String precision = VitroVocabulary.Precision.YEAR.uri(); + return precision; + } + + +} From 30c8b89436ec4f399dbf4b04c96798a8aa366574 Mon Sep 17 00:00:00 2001 From: tworrall Date: Tue, 5 Nov 2013 16:24:34 -0500 Subject: [PATCH 6/6] VIVO-492 --- rdf/display/everytime/PropertyConfig.n3 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rdf/display/everytime/PropertyConfig.n3 b/rdf/display/everytime/PropertyConfig.n3 index 47f25725..fbf5e0af 100644 --- a/rdf/display/everytime/PropertyConfig.n3 +++ b/rdf/display/everytime/PropertyConfig.n3 @@ -220,8 +220,8 @@ local:hasResearcherRoleContext a :ConfigContext ; local:hasResearcherRoleConfig a :ObjectPropertyDisplayConfig ; :listViewConfigFile "listViewConfig-researchActivities.xml"^^xsd:string ; - :displayName "research activities" ; - vitro:displayRankAnnot 15; + :displayName "other research activities" ; + vitro:displayRankAnnot 35; vitro:hiddenFromDisplayBelowRoleLevelAnnot role:public ; vitro:prohibitedFromUpdateBelowRoleLevelAnnot role:public ; vitro:customEntryFormAnnot "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.AddResearcherRoleToPersonGenerator"^^ ;