organization property changes including new custom form et al (VIVO-518)

This commit is contained in:
tworrall 2013-11-13 13:33:47 -05:00
parent 812e07baea
commit 65b13dc91d
8 changed files with 374 additions and 7 deletions

View file

@ -873,4 +873,6 @@ edit_publication_date = Editar fecha de publicación
name_prefix = Prefijo de nombre name_prefix = Prefijo de nombre
name_suffix = Sufijo de nombre name_suffix = Sufijo de nombre
administering_organization_for = administración de la organización para administering_organization_for = administración de la organización para
missing_credential = falta credencial missing_credential = falta credencial
grant_administered_by = conceder administrado por
missing_grant = falta de subvención

View file

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<!-- See guidelines in vitro/doc/list_view_configuration_guidelines.txt -->
<list-view-config>
<query-select>
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
PREFIX core: &lt;http://vivoweb.org/ontology/core#&gt;
PREFIX rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt;
PREFIX obo: &lt;http://purl.obolibrary.org/obo/&gt;
SELECT DISTINCT ?administratorRole
?grant
?grantLabel
WHERE {
?subject ?property ?administratorRole .
?administratorRole a core:AdministratorRole .
OPTIONAL { ?administratorRole core:relatedBy ?grant .
?grant core:relates ?administratorRole .
?grant rdfs:label ?grantLabel .
}
} ORDER BY ?grantLabel
</query-select>
<query-construct>
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
PREFIX core: &lt;http://vivoweb.org/ontology/core#&gt;
PREFIX rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt;
PREFIX obo: &lt;http://purl.obolibrary.org/obo/&gt;
CONSTRUCT {
?subject ?property ?administratorRole .
?administratorRole a core:AdministratorRole .
?administratorRole core:relatedBy ?grant .
?grant core:relates ?administratorRole .
?grant rdfs:label ?grantLabel .
} WHERE {
{
?subject ?property ?administratorRole .
?administratorRole a core:AdministratorRole .
} UNION {
?subject ?property ?administratorRole .
?administratorRole a core:AdministratorRole .
?administratorRole core:relatedBy ?grant .
?grant a core:Grant .
?grant core:relates ?administratorRole .
?grant rdfs:label ?grantLabel .
}
}
</query-construct>
<template>propStatement-organizationAdministersGrant.ftl</template>
</list-view-config>

View file

@ -0,0 +1,26 @@
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<#--
This template must be self-contained and not rely on other variables set for the individual page, because it
is also used to generate the property statement during a deletion.
-->
<#import "lib-sequence.ftl" as s>
<#import "lib-datetime.ftl" as dt>
<@showAdministeredGrant statement />
<#-- Use a macro to keep variable assignments local; otherwise the values carry over to the
next statement -->
<#macro showAdministeredGrant statement>
<#local linkedIndividual>
<#if statement.grant??>
<a href="${profileUrl(statement.uri("grant"))}" title="${i18n().grant_name}">${statement.grantLabel!""}</a>
<#else>
<a href="${profileUrl(statement.uri("administratorRole"))}" title="${i18n().grant_administered_by}">${i18n().missing_grant}</a>
</#if>
</#local>
${linkedIndividual!}
</#macro>

View file

@ -0,0 +1,136 @@
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<#-- this is in request.subject.name -->
<#-- leaving this edit/add mode code in for reference in case we decide we need it -->
<#import "lib-vivo-form.ftl" as lvf>
<#--Retrieve certain edit configuration information-->
<#if editConfiguration.objectUri?has_content>
<#assign editMode = "edit">
<#else>
<#assign editMode = "add">
</#if>
<#--The blank sentinel indicates what value should be put in a URI when no autocomplete result has been selected.
If the blank value is non-null or non-empty, n3 editing for an existing object will remove the original relationship
if nothing is selected for that object-->
<#assign blankSentinel = "" />
<#if editConfigurationConstants?has_content && editConfigurationConstants?keys?seq_contains("BLANK_SENTINEL")>
<#assign blankSentinel = editConfigurationConstants["BLANK_SENTINEL"] />
</#if>
<#--This flag is for clearing the label field on submission for an existing object being selected from autocomplete.
Set this flag on the input acUriReceiver where you would like this behavior to occur. -->
<#assign flagClearLabelForExisting = "flagClearLabelForExisting" />
<#assign htmlForElements = editConfiguration.pageData.htmlForElements />
<#--Retrieve variables needed-->
<#assign existingGrantValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "existingGrant") />
<#assign grantLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "grantLabel") />
<#assign grantLabelDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "grantLabelDisplay") />
<#--If edit submission exists, then retrieve validation errors if they exist-->
<#if editSubmission?has_content && editSubmission.submissionExists = true && editSubmission.validationErrors?has_content>
<#assign submissionErrors = editSubmission.validationErrors/>
</#if>
<#if editMode == "edit">
<#assign titleVerb="${i18n().edit_capitalized}">
<#assign submitButtonText="${i18n().save_changes}">
<#assign disabledVal="disabled">
<#else>
<#assign titleVerb="${i18n().create_capitalized}">
<#assign submitButtonText="${i18n().create_entry}">
<#assign disabledVal=""/>
</#if>
<#assign requiredHint = "<span class='requiredHint'> *</span>" />
<h2>${titleVerb}&nbsp;${i18n().grant_administered_by} ${editConfiguration.subjectName}</h2>
<#--Display error messages if any-->
<#if submissionErrors?has_content>
<#if grantLabelDisplayValue?has_content >
<#assign grantLabelValue = grantLabelDisplayValue />
</#if>
<section id="error-alert" role="alert">
<img src="${urls.images}/iconAlert.png" width="24" height="24" alt="${i18n().error_alert_icon}" />
<p>
<#--Checking if any required fields are empty-->
<#if lvf.submissionErrorExists(editSubmission, "grantLabel")>
${i18n().enter_or_select_grant}
</#if>
</p>
</section>
</#if>
<@lvf.unsupportedBrowser urls.base />
<section id="organizationAdministers" role="region">
<form id="organizationAdministersGrant" class="customForm noIE67" action="${submitUrl}" role="add/edit AdministeringOrganization">
<p>
<label for="relatedIndLabel">${i18n().grant_name} ${requiredHint}</label>
<input class="acSelector" size="50" type="text" id="grant" acGroupName="grant" name="grantLabel" value="${grantLabelValue}">
<input class="display" type="hidden" id="grantDisplay" acGroupName="grant" name="grantLabelDisplay" value="${grantLabelDisplayValue}">
</p>
<div class="acSelection" acGroupName="grant" id="grantAcSelection">
<p class="inline">
<label>${i18n().selected_grant}:</label>
<span class="acSelectionInfo"></span>
<a href="" class="verifyMatch" title="${i18n().verify_match_capitalized}">(${i18n().verify_match_capitalized}</a> ${i18n().or}
<a href="#" class="changeSelection" id="changeSelection">${i18n().change_selection})</a>
</p>
<input class="acUriReceiver" type="hidden" id="grantUri" name="existingGrant" value="${existingGrantValue}" ${flagClearLabelForExisting}="true" />
</div>
<#assign htmlForElements = editConfiguration.pageData.htmlForElements />
<input type="hidden" id="editKey" name="editKey" value="${editKey}"/>
<p class="submit">
<input type="submit" class="submit" value="${submitButtonText}"/><span class="or"> ${i18n().or} </span>
<a class="cancel" href="${cancelUrl}" title="${i18n().cancel_title}">${i18n().cancel_link}</a>
</p>
<p id="requiredLegend" class="requiredHint">* ${i18n().required_fields}</p>
</form>
<script type="text/javascript">
var customFormData = {
acUrl: '${urls.base}/autocomplete?tokenize=true&stem=true',
acTypes: {grant: 'http://vivoweb.org/ontology/core#Grant'},
editMode: '${editMode}',
defaultTypeName: 'grant',
baseHref: '${urls.base}/individual?uri=',
blankSentinel: '${blankSentinel}',
flagClearLabelForExisting: '${flagClearLabelForExisting}'
};
var i18nStrings = {
selectAnExisting: '${i18n().select_an_existing}',
orCreateNewOne: '${i18n().or_create_new_one}',
selectedString: '${i18n().selected}',
};
</script>
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css" />')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/extensions/String.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/jquery_plugins/jquery.bgiframe.pack.js"></script>',
'<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js"></script>')}

View file

@ -489,8 +489,8 @@ local:organizationForTrainingConfig a :ObjectPropertyDisplayConfig ;
:listViewConfigFile "listViewConfig-organizationForTraining.xml"^^xsd:string ; :listViewConfigFile "listViewConfig-organizationForTraining.xml"^^xsd:string ;
:displayName "organization for training" ; :displayName "organization for training" ;
vitro:displayRankAnnot 1; vitro:displayRankAnnot 1;
vitro:hiddenFromDisplayBelowRoleLevelAnnot role:public ; vitro:hiddenFromDisplayBelowRoleLevelAnnot role:nobody ;
vitro:prohibitedFromUpdateBelowRoleLevelAnnot role:public ; vitro:prohibitedFromUpdateBelowRoleLevelAnnot role:nobody ;
vitro:customEntryFormAnnot "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.OrganizationForTrainingGenerator"^^<http://www.w3.org/2001/XMLSchema#string> ; vitro:customEntryFormAnnot "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.OrganizationForTrainingGenerator"^^<http://www.w3.org/2001/XMLSchema#string> ;
:propertyGroup <http://vivoweb.org/ontology#vitroPropertyGroupother> . :propertyGroup <http://vivoweb.org/ontology#vitroPropertyGroupother> .
@ -601,6 +601,21 @@ local:grantAdministeredByConfig a :ObjectPropertyDisplayConfig ;
vitro:customEntryFormAnnot "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.GrantAdministeredByGenerator"^^<http://www.w3.org/2001/XMLSchema#string> ; vitro:customEntryFormAnnot "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.GrantAdministeredByGenerator"^^<http://www.w3.org/2001/XMLSchema#string> ;
:propertyGroup <http://vivoweb.org/ontology#vitroPropertyGroupoverview> . :propertyGroup <http://vivoweb.org/ontology#vitroPropertyGroupoverview> .
local:orgAdministersGrantContext a :ConfigContext ;
:hasConfiguration local:orgAdministersGrantConfig ;
:configContextFor <http://purl.obolibrary.org/obo/RO_0000053> ;
:qualifiedByDomain <http://xmlns.com/foaf/0.1/Organization> ;
:qualifiedBy vivo:AdministratorRole .
local:orgAdministersGrantConfig a :ObjectPropertyDisplayConfig ;
:listViewConfigFile "listViewConfig-organizationAdministersGrant.xml"^^xsd:string ;
:displayName "administers grant" ;
vitro:displayRankAnnot 61;
vitro:hiddenFromDisplayBelowRoleLevelAnnot role:public ;
vitro:prohibitedFromUpdateBelowRoleLevelAnnot role:public ;
vitro:customEntryFormAnnot "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.OrganizationAdministersGrantGenerator"^^<http://www.w3.org/2001/XMLSchema#string> ;
:propertyGroup <http://vivoweb.org/ontology#vitroPropertyGroupoverview> .
### vcard properties ### ### vcard properties ###
local:mailingAddressContext a :ConfigContext ; local:mailingAddressContext a :ConfigContext ;
@ -1114,7 +1129,7 @@ local:awardOrHonorGivenConfig a :ObjectPropertyDisplayConfig ;
local:orgAwardsGrantContext a :ConfigContext ; local:orgAwardsGrantContext a :ConfigContext ;
:hasConfiguration local:orgAwardsGrantConfig ; :hasConfiguration local:orgAwardsGrantConfig ;
:configContextFor <http://vivoweb.org/ontology/core#relatedBy> ; :configContextFor <http://vivoweb.org/ontology/core#assigns> ;
:qualifiedByDomain <http://xmlns.com/foaf/0.1/Organization> ; :qualifiedByDomain <http://xmlns.com/foaf/0.1/Organization> ;
:qualifiedBy <http://vivoweb.org/ontology/core#Grant> . :qualifiedBy <http://vivoweb.org/ontology/core#Grant> .

View file

@ -85,7 +85,7 @@ public class GrantAdministeredByGenerator extends VivoBaseGenerator implements
/* N3 assertions */ /* N3 assertions */
final static String n3ForNewAdminRole = final static String n3ForNewAdminRole =
"@prefix vivo: <" + vivoCore + "> . \n\n" + "@prefix vivo: <" + vivoCore + "> . \n" +
"?grant vivo:relates ?adminRole . \n" + "?grant vivo:relates ?adminRole . \n" +
"?adminRole a vivo:AdministratorRole . \n" + "?adminRole a vivo:AdministratorRole . \n" +
"?adminRole vivo:relatedBy ?grant . " ; "?adminRole vivo:relatedBy ?grant . " ;
@ -95,13 +95,17 @@ public class GrantAdministeredByGenerator extends VivoBaseGenerator implements
"?adminRole <http://purl.obolibrary.org/obo/RO_0000052> ?newOrganization . \n" + "?adminRole <http://purl.obolibrary.org/obo/RO_0000052> ?newOrganization . \n" +
"?newOrganization a <http://xmlns.com/foaf/0.1/Organization> . \n" + "?newOrganization a <http://xmlns.com/foaf/0.1/Organization> . \n" +
"?newOrganization <http://purl.obolibrary.org/obo/RO_0000053> ?adminRole . \n" + "?newOrganization <http://purl.obolibrary.org/obo/RO_0000053> ?adminRole . \n" +
"?newOrganization vivo:relatedBy ?grant . \n" +
"?grant vivo:relates ?newOrganization . \n" +
"?newOrganization <"+ label + "> ?orgLabel ."; "?newOrganization <"+ label + "> ?orgLabel .";
final static String n3ForExistingAdminOrganization = final static String n3ForExistingAdminOrganization =
"@prefix vivo: <" + vivoCore + "> . \n\n" + "@prefix vivo: <" + vivoCore + "> . \n\n" +
"?adminRole <http://purl.obolibrary.org/obo/RO_0000052> ?existingOrganization . \n" + "?adminRole <http://purl.obolibrary.org/obo/RO_0000052> ?existingOrganization . \n" +
"?existingOrganization a <http://xmlns.com/foaf/0.1/Organization> . \n" + "?existingOrganization a <http://xmlns.com/foaf/0.1/Organization> . \n" +
"?existingOrganization <http://purl.obolibrary.org/obo/RO_0000053> ?adminRole . " ; "?existingOrganization <http://purl.obolibrary.org/obo/RO_0000053> ?adminRole . " +
"?existingOrganization vivo:relatedBy ?grant . \n" +
"?grant vivo:relates ?existingOrganization . \n" ;
/* Queries for editing an existing entry */ /* Queries for editing an existing entry */

View file

@ -0,0 +1,127 @@
/* $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.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpSession;
import com.hp.hpl.jena.vocabulary.XSD;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
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.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ChildVClassesWithParent;
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.IndividualsViaVClassOptions;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
public class OrganizationAdministersGrantGenerator extends VivoBaseGenerator implements
EditConfigurationGenerator {
public OrganizationAdministersGrantGenerator() {}
@Override
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
HttpSession session) throws Exception {
EditConfigurationVTwo conf = new EditConfigurationVTwo();
initBasics(conf, vreq);
initPropertyParameters(vreq, session, conf);
initObjectPropForm(conf, vreq);
conf.setTemplate("organizationAdministersGrant.ftl");
conf.setVarNameForSubject("organization");
conf.setVarNameForPredicate("predicate");
conf.setVarNameForObject("adminRole");
conf.setN3Required( Arrays.asList( n3ForNewAdminRole) );
conf.setN3Optional( Arrays.asList( n3ForNewAdminGrant,
n3ForExistingAdminGrant ) );
conf.addNewResource("newGrant", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("adminRole", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.setUrisOnform(Arrays.asList("existingGrant"));
conf.setLiteralsOnForm(Arrays.asList("grantLabel", "grantLabelDisplay" ));
conf.addSparqlForExistingLiteral("grantLabel", grantLabelQuery);
conf.addSparqlForExistingUris("existingGrant", existingGrantQuery);
conf.addField( new FieldVTwo(). // options will be added in browser by auto complete JS
setName("existingGrant")
);
conf.addField( new FieldVTwo().
setName("grantLabel").
setRangeDatatypeUri(XSD.xstring.toString() ).
setValidators( list("datatype:" + XSD.xstring.toString()) )
);
conf.addField( new FieldVTwo().
setName("grantLabelDisplay").
setRangeDatatypeUri(XSD.xstring.toString() ).
setValidators( list("datatype:" + XSD.xstring.toString()))
);
conf.addValidator(new AntiXssValidation());
conf.addValidator(new AutocompleteRequiredInputValidator("existingGrant", "grantLabel"));
// addFormSpecificData(conf, vreq);
prepare(vreq, conf);
return conf;
}
/* N3 assertions */
final static String n3ForNewAdminRole =
"@prefix vivo: <" + vivoCore + "> . \n\n" +
"?organization <http://purl.obolibrary.org/obo/RO_0000053> ?adminRole . \n" +
"?adminRole a vivo:AdministratorRole . \n" +
"?adminRole <http://purl.obolibrary.org/obo/RO_0000052> ?organization . " ;
final static String n3ForNewAdminGrant =
"@prefix vivo: <" + vivoCore + "> . \n" +
"?adminRole vivo:relatedBy ?newGrant . \n" +
"?newGrant a vivo:Grant . \n" +
"?newGrant vivo:relates ?adminRole . \n" +
"?organization vivo:relatedBy ?newGrant . \n" +
"?newGrant vivo:relates ?organization . \n" +
"?newGrant <"+ label + "> ?grantLabel .";
final static String n3ForExistingAdminGrant =
"@prefix vivo: <" + vivoCore + "> . \n\n" +
"?adminRole vivo:relatedBy ?existingGrant . \n" +
"?existingGrant a <http://xmlns.com/foaf/0.1/Grant> . \n" +
"?existingGrant vivo:relates ?adminRole . \n" +
"?organization vivo:relatedBy ?newGrant . \n" +
"?newGrant vivo:relates ?organization . " ;
/* Queries for editing an existing entry */
final static String existingGrantQuery =
"PREFIX vivo: <http://vivoweb.org/ontology/core#> \n" +
"SELECT ?existingGrant WHERE { \n" +
" ?adminRole vivo:relatedBy ?existingGrant . \n" +
" ?existingGrant a vivo:Grant . \n" +
"}";
final static String grantLabelQuery =
"PREFIX vivo: <http://vivoweb.org/ontology/core#> \n" +
"SELECT ?existingGrantLabel WHERE { \n" +
" ?adminRole vivo:relatedBy ?existingGrant . \n" +
" ?existingGrant a vivo:Grant . \n" +
" ?existingGrant <" + label + "> ?existingGrantLabel . \n" +
"}";
}

View file

@ -879,4 +879,6 @@ edit_publication_date = Edit publication date
name_prefix = Name Prefix name_prefix = Name Prefix
name_suffix = Name Suffix name_suffix = Name Suffix
administering_organization_for = administering organization for administering_organization_for = administering organization for
missing_credential = missing credential missing_credential = missing credential
grant_administered_by = grant being administered by
missing_grant = missing grant