Merge branch 'develop' of https://github.com/vivo-project/Vitro into develop

This commit is contained in:
j2blake 2013-11-07 15:27:42 -05:00
commit 6d9a70df6f
123 changed files with 2860 additions and 3209 deletions

View file

@ -67,7 +67,7 @@
<h4>Vitro inside Tomcat</h4> <h4>Vitro inside Tomcat</h4>
<p> <p>
When you run the build script to compile and deploy Vitro When you run the build script to compile and deploy Vitro
(see <a href="#deploy">installation step VI</a>, below), (see <a href="#deploy">installation step V</a>, below),
the files will be deployed to a the files will be deployed to a
directory inside Tomcat. This is the actual executing code for Vitro, directory inside Tomcat. This is the actual executing code for Vitro,
but you wont need to look at it or change it. If you need to change but you wont need to look at it or change it. If you need to change
@ -86,7 +86,7 @@
build.properties file (see <a href="#build_properties">installation step IV</a>, build.properties file (see <a href="#build_properties">installation step IV</a>,
below). You must create this directory before starting Vitro, below). You must create this directory before starting Vitro,
you must create the <code>runtime.properties</code> file in this directory you must create the <code>runtime.properties</code> file in this directory
(see <a href="#runtime_properties">Step V</a>, below), and you (see <a href="#runtime_properties">Step VI</a>, below), and you
must ensure that Tomcat has permission to read and write to this must ensure that Tomcat has permission to read and write to this
directory when it runs. directory when it runs.
</p> </p>
@ -186,10 +186,10 @@
<a href="#build_properties">Specify build properties</a> <a href="#build_properties">Specify build properties</a>
</li> </li>
<li> <li>
<a href="#runtime_properties">Specify runtime properties</a> <a href="#deploy">Compile and deploy</a>
</li> </li>
<li> <li>
<a href="#deploy">Compile and deploy</a> <a href="#runtime_properties">Specify runtime properties</a>
</li> </li>
<li> <li>
<a href="#tomcat_settings">Configure Tomcat</a> <a href="#tomcat_settings">Configure Tomcat</a>
@ -226,20 +226,19 @@
</p> </p>
<ul> <ul>
<li> <li>
Java (SE) 1.6 or higher, <a href="http://java.sun.com">http://java.sun.com</a> Java (SE) 1.7.x <a href="http://java.sun.com">http://java.sun.com</a>
(Not OpenJDK) <ul>
<li>VIVO has not been tested with OpenJDK</li>
</ul>
</li> </li>
<li> <li>
Apache Tomcat 6.x or higher, <a href="http://tomcat.apache.org">http://tomcat.apache.org</a> Apache Tomcat 6.x or 7.x <a href="http://tomcat.apache.org">http://tomcat.apache.org</a>
</li> </li>
<li> <li>
Apache Ant 1.8 or higher, <a href="http://ant.apache.org">http://ant.apache.org</a> Apache Ant 1.8 or higher, <a href="http://ant.apache.org">http://ant.apache.org</a>
</li> </li>
<li> <li>
MySQL 5.1 or higher*, <a href="http://www.mysql.com">http://www.mysql.com</a> MySQL 5.1 or higher, <a href="http://www.mysql.com">http://www.mysql.com</a>
</li>
<li>
Apache Subversion 1.6.x or higher*, <a href="http://subversion.apache.org/">http://subversion.apache.org/</a>
</li> </li>
</ul> </ul>
<p> <p>
@ -320,8 +319,8 @@
<p> <p>
These properties are used in compilation and deployment. These properties are used in compilation and deployment.
They will be incorporated into Vitro when it is compiled in They will be incorporated into Vitro when it is compiled in
<a href="#deploy">Step VI</a>. If you want to change these properties at <a href="#deploy">Step V</a>. If you want to change these properties at
a later date, you will need to stop Tomcat, repeat <a href="#deploy">Step VI</a>, a later date, you will need to stop Tomcat, repeat <a href="#deploy">Step V</a>,
and restart Tomcat. and restart Tomcat.
</p> </p>
<p> <p>
@ -394,22 +393,64 @@
</tbody> </tbody>
</table> </table>
<h3 id="runtime_properties">V. Specify runtime properties </h3> <h3 id="deploy">V. Compile and deploy</h3>
<p> <p>
In <a href="#build_properties">Step IV</a>, you defined the location of the Vitro home directory, In <a href="#build_properties">Step IV</a>, you defined the location of the VIVO home directory,
by specifying <code>vitro.home</code> in the <code>build.properties</code> file. by specifying <code>vitro.home</code> in the <code>build.properties</code> file.
Create that directory now. Create that directory now.
</p> </p>
<p> <p>
In the <code>webapp/config</code> subdirectory of the Vitro distribution, you will find a file called At the command line, change to the <code>webapp</code> directory inside the Vitro distribution
<code>example.runtime.properties</code>. Copy this to the Vitro home directory you have created, directory. Then type:
renaming the copy to <code>runtime.properties</code>. </p>
Edit the file to suit your installation, as described in the following table. <pre> ant all<br> </pre>
<p>
to build Vitro and deploy to Tomcat's webapps directory.
</p>
<p>
The build script may run for as much as five minutes,
and creates more than 100 lines of output.
The process comprises several steps:
<ul>
<li>collecting the source files from the distribution directory,</li>
<li>compiling the Java source code,</li>
<li>compiling and running unit tests,</li>
<li>preparing the Solr search engine,</li>
<li>deploying Vitro and Solr to Tomcat.</li>
</ul>
</p>
<p>
The output of the build may include a variety of warning messages.
The Java compiler may warn of code that is outdated.
Unit tests may produce warning messages,
and some tests may be ignored if they do not produce consistent results.
</p>
<table align="center"><tr><td>
BUILD SUCCESSFUL<br>Total time: 1 minute 49 seconds
</td></tr></table>
<p>
If the output ends with a success message, the build was successful.
Proceed to the next step.
</p>
<table align="center"><tr><td>
BUILD FAILED<br>Total time: 35 seconds
</td></tr></table>
<p>
If the output ends with a failure message, the build has failed.
Find the cause of the failure, fix the problem, and run the script again.
</p>
<h3 id="runtime_properties">VI. Specify runtime properties </h3>
<p>
The build process in <a href="deploy">Step V</a> created a file called <code>example.runtime.properties</code>
in your Vitro home directory (<code>vitro.home</code> in the <code>build.properties</code> file).
Rename this file to <code>runtime.properties</code>, and
edit the file to suit your installation, as described in the following table.
</p> </p>
<p> <p>
These properties are loaded when Vitro starts up. If you want to change these These properties are loaded when Vitro starts up. If you want to change these
properties at a later date, you will need to restart Tomcat for them to take properties at a later date, you will need to restart Tomcat for them to take
effect. You will not need to repeat <a href="#deploy">Step VI</a>. effect. You will not need to repeat <a href="#deploy">Step V</a>.
</p> </p>
<p> <p>
<em>Windows:</em> <em>Windows:</em>
@ -800,47 +841,6 @@
</tbody> </tbody>
</table> </table>
<h3 id="deploy">VI. Compile and deploy</h3>
<p>
At the command line, change to the <code>webapp</code> directory inside the Vitro distribution
directory. Then type:
</p>
<pre> ant all<br> </pre>
<p>
to build Vitro and deploy to Tomcat's webapps directory.
</p>
<p>
The build script may run for as much as five minutes,
and creates more than 100 lines of output.
The process comprises several steps:
<ul>
<li>collecting the source files from the distribution directory,</li>
<li>compiling the Java source code,</li>
<li>compiling and running unit tests,</li>
<li>preparing the Solr search engine,</li>
<li>deploying Vitro and Solr to Tomcat.</li>
</ul>
</p>
<p>
The output of the build may include a variety of warning messages.
The Java compiler may warn of code that is outdated.
Unit tests may produce warning messages,
and some tests may be ignored if they do not produce consistent results.
</p>
<table align="center"><tr><td>
BUILD SUCCESSFUL<br>Total time: 1 minute 49 seconds
</td></tr></table>
<p>
If the output ends with a success message, the build was successful.
Proceed to the next step.
</p>
<table align="center"><tr><td>
BUILD FAILED<br>Total time: 35 seconds
</td></tr></table>
<p>
If the output ends with a failure message, the build has failed.
Find the cause of the failure, fix the problem, and run the script again.
</p>
<h3 id="tomcat_settings">VII. Configure Tomcat</h3> <h3 id="tomcat_settings">VII. Configure Tomcat</h3>
<h4>Set JVM parameters</h4> <h4>Set JVM parameters</h4>
@ -921,8 +921,8 @@
problem is detected, the normal Vitro pages will redirect problem is detected, the normal Vitro pages will redirect
to a startup status page describing the problem. You to a startup status page describing the problem. You
can stop tomcat, attempt to fix the problem and can stop tomcat, attempt to fix the problem and
proceeded from <a href="#deploy">Step VI</a>. The proceed from <a href="#deploy">Step V</a>. If the problem is not serious, the
startup status page may offer a continue link which startup status page may offer a <code>continue</code> link which
will allow you to use VIVO in spite of the problems. will allow you to use VIVO in spite of the problems.
</p> </p>
<p> <p>

View file

@ -4,13 +4,13 @@
DELETE FROM `orng_apps`; DELETE FROM `orng_apps`;
INSERT INTO `orng_apps` (`appid`, `name`, `url`, `PersonFilterID`, `enabled`, `channels`) VALUES INSERT INTO `orng_apps` (`appid`, `name`, `url`, `PersonFilterID`, `enabled`, `channels`) VALUES
(100, 'Google Search', 'http://dev-profiles.ucsf.edu/orng/GoogleSearch.xml', NULL, 1, NULL), (100, 'Google Search', 'http://stage-profiles.ucsf.edu/apps/ucsfsearch.xml', NULL, 1, NULL),
(101, 'Featured Presentations', 'http://dev-profiles.ucsf.edu/orng/SlideShare.xml', NULL, 1, NULL), (101, 'Featured Presentations', 'http://stage-profiles.ucsf.edu/apps/SlideShare.xml', NULL, 1, NULL),
(102, 'Faculty Mentor', 'http://dev-profiles.ucsf.edu/orng/Mentor.xml', NULL, 0, NULL), (102, 'Faculty Mentor', 'http://stage-profiles.ucsf.edu/apps/Mentor.xml', NULL, 0, NULL),
(103, 'Websites', 'http://dev-profiles.ucsf.edu/orng/Links.xml', NULL, 1, NULL), (103, 'Websites', 'http://stage-profiles.ucsf.edu/apps/Links.xml', NULL, 1, NULL),
(104, 'Profile List', 'http://dev-profiles.ucsf.edu/orng/ProfileListTool.xml', NULL, 1, 'JSONPersonIds'), (104, 'Profile List', 'http://stage-profiles.ucsf.edu/apps/ProfileListTool.xml', NULL, 1, 'JSONPersonIds'),
(106, 'RDF Test Gadget', 'http://dev-profiles.ucsf.edu/orng/RDFTest.xml', NULL, 1, NULL), (106, 'RDF Test Gadget', 'http://stage-profiles.ucsf.edu/apps/RDFTest.xml', NULL, 1, NULL),
(112, 'Twitter', 'http://dev-profiles.ucsf.edu/ORNG/Twitter.xml', NULL, 1, NULL); (112, 'Twitter', 'http://stage-profiles.ucsf.edu/apps/Twitter.xml', NULL, 1, NULL);
DELETE FROM `orng_app_views`; DELETE FROM `orng_app_views`;

View file

@ -102,6 +102,24 @@
<target name="deployProperties" depends="buildProperties"> <target name="deployProperties" depends="buildProperties">
<fail unless="vitro.home" message="${build.properties.file} must contain a value for vitro.home" /> <fail unless="vitro.home" message="${build.properties.file} must contain a value for vitro.home" />
<fail unless="tomcat.home" message="${build.properties.file} must contain a value for tomcat.home" /> <fail unless="tomcat.home" message="${build.properties.file} must contain a value for tomcat.home" />
<fail>
<condition>
<not>
<available file="${tomcat.home}" />
</not>
</condition>
Tomcat home directory '${tomcat.home}' does not exist.
Check the value of 'tomcat.home' in your build.properties file.
</fail>
<fail>
<condition>
<not>
<available file="${tomcat.home}/webapps" />
</not>
</condition>
'${tomcat.home}' does not refer to a valid Tomcat instance: it has no 'webapps' sub-directory.
Check the value of 'tomcat.home' in your build.properties file."
</fail>
<property name="solr.home.dir" location="${vitro.home}/solr" /> <property name="solr.home.dir" location="${vitro.home}/solr" />

View file

@ -126,10 +126,6 @@ submit_add_new_account = Añadir nueva cuenta
account_created = Su {0} cuenta ha sido creada. account_created = Su {0} cuenta ha sido creada.
account_created_subject = Su {0} cuenta ha sido creada. account_created_subject = Su {0} cuenta ha sido creada.
account_created_email_html = @@file files/accountCreatedEmail.html
account_created_email_text = @@file files/accountCreatedEmail.txt
account_created_external_email_html = @@file files/accountCreatedExternalOnlyEmail.html
account_created_external_email_text = @@file files/accountCreatedExternalOnlyEmail.txt
confirm_delete_account_singular = ¿Está seguro de que desea eliminar esta cuenta? confirm_delete_account_singular = ¿Está seguro de que desea eliminar esta cuenta?
confirm_delete_account_plural = ¿Está seguro de que desea eliminar estas cuentas? confirm_delete_account_plural = ¿Está seguro de que desea eliminar estas cuentas?
@ -148,21 +144,11 @@ select_associated_profile = Seleccione el perfil asociado
create_associated_profile = Cree el perfil asociado create_associated_profile = Cree el perfil asociado
email_changed_subject = Su {0} cuenta de correo electrónico ha cambiado. email_changed_subject = Su {0} cuenta de correo electrónico ha cambiado.
email_changed_html = @@file files/accountEmailChanged.html
email_changed_text = @@file files/accountEmailChanged.txt
create_your_password = Crea tu Contraseña create_your_password = Crea tu Contraseña
password_created_subject = Su {0} contraseña ha sido creado con éxito. password_created_subject = Su {0} contraseña ha sido creado con éxito.
password_created_email_html = @@file files/passwordCreatedEmail.html
password_created_email_text = @@file files/passwordCreatedEmail.txt
password_reset_pending_subject = {0} restablecer solicitud de contraseña password_reset_pending_subject = {0} restablecer solicitud de contraseña
password_reset_pending_email_html = @@file files/passwordResetPending.html
password_reset_pending_email_text = @@file files/passwordResetPending.txt
password_reset_complete_subject = Su {0} ha cambiado la contraseña. password_reset_complete_subject = Su {0} ha cambiado la contraseña.
password_reset_complete_email_html = @@file files/passwordResetComplete.html
password_reset_complete_email_text = @@file files/passwordResetComplete.txt
reset_your_password = Renovar su contraseña reset_your_password = Renovar su contraseña
first_time_login = Log Por primera vez en first_time_login = Log Por primera vez en
@ -181,8 +167,6 @@ password_saved_please_login = Su contraseña ha sido guardada. Por favor, ingres
please_provide_contact_information = Por favor proporcione su información de contacto para terminar de crear la cuenta. please_provide_contact_information = Por favor proporcione su información de contacto para terminar de crear la cuenta.
first_time_login_note = Nota: Un correo electrónico será enviado a la dirección indicada anteriormente notificar que una cuenta ha sido creada. first_time_login_note = Nota: Un correo electrónico será enviado a la dirección indicada anteriormente notificar que una cuenta ha sido creada.
first_time_external_email_html = @@file files/accountFirstTimeExternal.html
first_time_external_email_text = @@file files/accountFirstTimeExternal.txt
myAccount_heading = Mi cuenta myAccount_heading = Mi cuenta
myAccount_confirm_changes = Los cambios se han guardado. myAccount_confirm_changes = Los cambios se han guardado.
@ -873,3 +857,5 @@ processing_icon = tratamiento
selection_in_process = Su selección se está procesando.view_labels_capitalized = Ver etiquetas selection_in_process = Su selección se está procesando.view_labels_capitalized = Ver etiquetas
view_labels_capitalized = Ver etiquetas view_labels_capitalized = Ver etiquetas
view_labels_for = Ver Etiquetas de view_labels_for = Ver Etiquetas de
select_an_existing_document = Seleccione un documento existente

View file

@ -0,0 +1,68 @@
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<#-- Confirmation that an account has been created. -->
<#assign subject = "Su cuenta ${siteName} ha sido creado." />
<#assign html>
<html>
<head>
<title>${subject}</title>
</head>
<body>
<p>
${userAccount.firstName} ${userAccount.lastName}
</p>
<p>
<strong>Enhorabuena!</strong>
</p>
<p>
Hemos creado la nueva cuenta en ${siteName}, asociada con ${userAccount.emailAddress}.
</p>
<p>
Si no has solicitado esta nueva cuenta puede ignorar este mensaje.
Esta solicitud caducará si no se hubiere pronunciado sobre durante 30 días.
</p>
<p>
Haga clic en el enlace de abajo para crear la contraseña de su cuenta usando nuestro servidor seguro.
</p>
<p>
<a href="${passwordLink}" title="password">${passwordLink}</a>
</p>
<p>
Si el enlace no funciona, puedes copiar y pegar el enlace directamente en la barra de direcciones de su navegador.
</p>
<p>
¡Gracias!
</p>
</body>
</html>
</#assign>
<#assign text>
${userAccount.firstName} ${userAccount.lastName}
Enhorabuena!
Hemos creado la nueva cuenta en ${siteName},
asociada con ${userAccount.emailAddress}.
Si no has solicitado esta nueva cuenta puede ignorar este mensaje.
Esta solicitud caducará si no se hubiere pronunciado sobre durante 30 días.
Pega el siguiente enlace en la barra de direcciones de su navegador para
crear su contraseña para su nueva cuenta usando nuestro servidor seguro.
${passwordLink}
¡Gracias!
</#assign>
<@email subject=subject html=html text=text />

View file

@ -0,0 +1,43 @@
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<#-- Confirmation that an account has been created. -->
<#assign subject = "Su cuenta ${siteName} ha sido creada." />
<#assign html>
<html>
<head>
<title>${subject}</title>
</head>
<body>
<p>
${userAccount.firstName} ${userAccount.lastName}
</p>
<p>
<strong>¡Enhorabuena!</strong>
</p>
<p>
Hemos creado la nueva cuenta VIVO asociado con ${userAccount.emailAddress}.
</p>
<p>
¡Gracias!
</p>
</body>
</html>
</#assign>
<#assign text>
${userAccount.firstName} ${userAccount.lastName}
¡Enhorabuena!
Hemos creado la nueva cuenta VIVO asociado con
${userAccount.emailAddress}.
¡Gracias!
</#assign>
<@email subject=subject html=html text=text />

View file

@ -0,0 +1,38 @@
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<#-- Confirmation that the user has changed his email account. -->
<#assign subject = "Su cuenta de correo electrónico ${siteName} ha cambiado." />
<#assign html>
<html>
<head>
<title>${subject}</title>
</head>
<body>
<p>
Hola, ${userAccount.firstName} ${userAccount.lastName}
</p>
<p>
Ha cambiado recientemente la dirección de correo electrónico asociada a
${userAccount.firstName} ${userAccount.lastName}
</p>
<p>
Gracias.
</p>
</body>
</html>
</#assign>
<#assign text>
Hola, ${userAccount.firstName} ${userAccount.lastName}
Ha cambiado recientemente la dirección de correo electrónico asociada a
${userAccount.firstName} ${userAccount.lastName}
Gracias.
</#assign>
<@email subject=subject html=html text=text />

View file

@ -0,0 +1,43 @@
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<#-- Confirmation that an account has been created for an externally-authenticated user. -->
<#assign subject = "Su cuenta ${siteName} ha sido creada." />
<#assign html>
<html>
<head>
<title>${subject}</title>
</head>
<body>
<p>
${userAccount.firstName} ${userAccount.lastName}
</p>
<p>
<strong>¡Enhorabuena!</strong>
</p>
<p>
Hemos creado la nueva cuenta VIVO asociado con ${userAccount.emailAddress}.
</p>
<p>
¡Gracias!
</p>
</body>
</html>
</#assign>
<#assign text>
${userAccount.firstName} ${userAccount.lastName}
¡Enhorabuena!
Hemos creado la nueva cuenta VIVO asociado con
${userAccount.emailAddress}.
¡Gracias!
</#assign>
<@email subject=subject html=html text=text />

View file

@ -0,0 +1,43 @@
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<#-- Confirmation that an password has been created. -->
<#assign subject = "El ${siteName} contraseña ha sido creado con éxito." />
<#assign html>
<html>
<head>
<title>${subject}</title>
</head>
<body>
<p>
${userAccount.firstName} ${userAccount.lastName}
</p>
<p>
<strong>Contraseña creado con éxito.</strong>
</p>
<p>
Su nueva contraseña asociada con ${userAccount.emailAddress} se ha creado.
</p>
<p>
Gracias.
</p>
</body>
</html>
</#assign>
<#assign text>
${userAccount.firstName} ${userAccount.lastName}
Contraseña creado con éxito.
Su nueva contraseña asociada con ${userAccount.emailAddress}
se ha creado.
Gracias.
</#assign>
<@email subject=subject html=html text=text />

View file

@ -0,0 +1,44 @@
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<#-- Confirmation that a password has been reset. -->
<#assign subject = "El ${siteName} contraseña cambiada." />
<#assign html>
<html>
<head>
<title>${subject}</title>
</head>
<body>
<p>
${userAccount.firstName} ${userAccount.lastName}
</p>
<p>
<strong>Contraseña cambiada con éxito.</strong>
</p>
<p>
Su nueva contraseña asociada con ${userAccount.emailAddress} ha sido cambiado.
</p>
<p>
Gracias.
</p>
</body>
</html>
</#assign>
<#assign text>
${userAccount.firstName} ${userAccount.lastName}
Contraseña cambiada con éxito.
Su nueva contraseña asociada con ${userAccount.emailAddress}
ha sido cambiado.
Gracias.
</#assign>
<@email subject=subject html=html text=text />

View file

@ -0,0 +1,62 @@
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<#-- Confirmation email for user account password reset -->
<#assign subject = "${siteName} restablecer solicitud de contraseña" />
<#assign html>
<html>
<head>
<title>${subject}</title>
</head>
<body>
<p>
Estimado ${userAccount.firstName} ${userAccount.lastName}:
</p>
<p>
Hemos recibido una solicitud para restablecer la contraseña de su cuenta ${siteName}
(${userAccount.emailAddress}).
</p>
<p>
Por favor, siga las siguientes instrucciones para proceder con su restablecimiento de contraseña.
</p>
<p>
Si no has solicitado esta nueva cuenta puede ignorar este mensaje.
Esta solicitud caducará si no se hubiere pronunciado en un plazo de 30 días.
</p>
<p>
Haga clic en el enlace de abajo o pegarlo en la barra de direcciones de su navegador para
restablecer su contraseña usando nuestro servidor seguro.
</p>
<p>${passwordLink}</p>
<p>¡Gracias!</p>
</body>
</html>
</#assign>
<#assign text>
Estimado ${userAccount.firstName} ${userAccount.lastName}:
Hemos recibido una solicitud para restablecer la contraseña de su cuenta ${siteName}
(${userAccount.emailAddress}).
Por favor, siga las siguientes instrucciones para proceder con su restablecimiento de contraseña.
Si no has solicitado esta nueva cuenta puede ignorar este mensaje.
Esta solicitud caducará si no se hubiere pronunciado en un plazo de 30 días.
Pega el siguiente enlace en la barra de direcciones de su navegador para
restablecer su contraseña usando nuestro servidor seguro.
${passwordLink}
¡Gracias!
</#assign>
<@email subject=subject html=html text=text />

View file

@ -241,6 +241,9 @@ public class FormUtils {
option.setValue(vclass.getURI()); option.setValue(vclass.getURI());
option.setBody(vclass.getPickListName()); option.setBody(vclass.getPickListName());
vclassOptionList.add(option); vclassOptionList.add(option);
if(selectedVClassURI != null && selectedVClassURI.equals(vclass.getURI())) {
option.setSelected(true);
}
} }
return vclassOptionList; return vclassOptionList;
} }

View file

@ -11,7 +11,6 @@ import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec; import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.RDFNode; import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.Statement; import com.hp.hpl.jena.rdf.model.Statement;
@ -20,7 +19,6 @@ import com.hp.hpl.jena.rdf.model.StmtIterator;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.ActiveIdentifierBundleFactories; import edu.cornell.mannlib.vitro.webapp.auth.identifier.ActiveIdentifierBundleFactories;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle; import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.RequestIdentifiers; import edu.cornell.mannlib.vitro.webapp.auth.identifier.RequestIdentifiers;
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyIface; import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyIface;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
@ -136,7 +134,8 @@ public class PolicyHelper {
.asResource().getURI()); .asResource().getURI());
} else { } else {
action = new AddDataPropertyStatement(modelToBeModified, action = new AddDataPropertyStatement(modelToBeModified,
subject.getURI(), predicate.getURI()); subject.getURI(), predicate.getURI(), objectNode
.asLiteral().getString());
} }
return isAuthorizedForActions(req, action); return isAuthorizedForActions(req, action);
} }
@ -169,7 +168,8 @@ public class PolicyHelper {
.asResource().getURI()); .asResource().getURI());
} else { } else {
action = new DropDataPropertyStatement(modelToBeModified, action = new DropDataPropertyStatement(modelToBeModified,
subject.getURI(), predicate.getURI()); subject.getURI(), predicate.getURI(), objectNode
.asLiteral().getString());
} }
return isAuthorizedForActions(req, action); return isAuthorizedForActions(req, action);
} }

View file

@ -16,15 +16,17 @@ public abstract class AbstractDataPropertyStatementAction extends
private final String subjectUri; private final String subjectUri;
private final String predicateUri; private final String predicateUri;
private final Property predicate; private final Property predicate;
private final String dataValue;
public AbstractDataPropertyStatementAction(OntModel ontModel, public AbstractDataPropertyStatementAction(OntModel ontModel,
String subjectUri, String predicateUri) { String subjectUri, String predicateUri, String dataValue) {
super(ontModel); super(ontModel);
this.subjectUri = subjectUri; this.subjectUri = subjectUri;
this.predicateUri = predicateUri; this.predicateUri = predicateUri;
Property dataProperty = new Property(); Property dataProperty = new Property();
dataProperty.setURI(predicateUri); dataProperty.setURI(predicateUri);
this.predicate = dataProperty; this.predicate = dataProperty;
this.dataValue = dataValue;
} }
public AbstractDataPropertyStatementAction(OntModel ontModel, public AbstractDataPropertyStatementAction(OntModel ontModel,
@ -36,12 +38,14 @@ public abstract class AbstractDataPropertyStatementAction extends
Property dataProperty = new Property(); Property dataProperty = new Property();
dataProperty.setURI(predicateUri); dataProperty.setURI(predicateUri);
this.predicate = dataProperty; this.predicate = dataProperty;
this.dataValue = dps.getData();
} }
public String getSubjectUri() { public String getSubjectUri() {
return subjectUri; return subjectUri;
} }
@Override
public Property getPredicate() { public Property getPredicate() {
return predicate; return predicate;
} }

View file

@ -13,8 +13,8 @@ public class AddDataPropertyStatement extends
AbstractDataPropertyStatementAction { AbstractDataPropertyStatementAction {
public AddDataPropertyStatement(OntModel ontModel, String subjectUri, public AddDataPropertyStatement(OntModel ontModel, String subjectUri,
String predicateUri) { String predicateUri, String dataValue) {
super(ontModel, subjectUri, predicateUri); super(ontModel, subjectUri, predicateUri, dataValue);
} }
public AddDataPropertyStatement(OntModel ontModel, DataPropertyStatement dps) { public AddDataPropertyStatement(OntModel ontModel, DataPropertyStatement dps) {

View file

@ -14,8 +14,8 @@ public class DropDataPropertyStatement extends
AbstractDataPropertyStatementAction { AbstractDataPropertyStatementAction {
public DropDataPropertyStatement(OntModel ontModel, String subjectUri, public DropDataPropertyStatement(OntModel ontModel, String subjectUri,
String predicateUri) { String predicateUri, String dataValue) {
super(ontModel, subjectUri, predicateUri); super(ontModel, subjectUri, predicateUri, dataValue);
} }
public DropDataPropertyStatement(OntModel ontModel, public DropDataPropertyStatement(OntModel ontModel,

View file

@ -12,8 +12,8 @@ import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
public class EditDataPropertyStatement extends public class EditDataPropertyStatement extends
AbstractDataPropertyStatementAction { AbstractDataPropertyStatementAction {
public EditDataPropertyStatement(OntModel ontModel, String subjectUri, public EditDataPropertyStatement(OntModel ontModel, String subjectUri,
String predicateUri) { String predicateUri, String dataValue) {
super(ontModel, subjectUri, predicateUri); super(ontModel, subjectUri, predicateUri, dataValue);
} }
public EditDataPropertyStatement(OntModel ontModel, public EditDataPropertyStatement(OntModel ontModel,

View file

@ -34,6 +34,13 @@ public interface Individual extends ResourceBean, Comparable<Individual> {
List<ObjectProperty> getObjectPropertyList(); List<ObjectProperty> getObjectPropertyList();
void setPropertyList(List<ObjectProperty> propertyList); void setPropertyList(List<ObjectProperty> propertyList);
/**
* Returns a list of ObjectProperty objects for which statements exist about
* the individual. Note that this method now returns multiple copies of
* a given predicate, with the rangeVClassURI changed to indicate the distinct
* types of the related objects. This supports finding the approriate list
* views for the "faux" qualified properties.
*/
List<ObjectProperty> getPopulatedObjectPropertyList(); List<ObjectProperty> getPopulatedObjectPropertyList();
void setPopulatedObjectPropertyList(List<ObjectProperty> propertyList); void setPopulatedObjectPropertyList(List<ObjectProperty> propertyList);

View file

@ -22,7 +22,7 @@ import com.hp.hpl.jena.datatypes.xsd.XSDDatatype;
* a class representing an object property * a class representing an object property
* *
*/ */
public class ObjectProperty extends Property implements Comparable<ObjectProperty>, ResourceBean public class ObjectProperty extends Property implements Comparable<ObjectProperty>, ResourceBean, Cloneable
{ {
private static final Log log = LogFactory.getLog(ObjectProperty.class.getName()); private static final Log log = LogFactory.getLog(ObjectProperty.class.getName());
@ -610,6 +610,55 @@ public class ObjectProperty extends Property implements Comparable<ObjectPropert
"selectFromExisting" + getSelectFromExisting() + "\n\t" + "selectFromExisting" + getSelectFromExisting() + "\n\t" +
"offerCreateNewOption" + getOfferCreateNewOption() + "\n\t" + "offerCreateNewOption" + getOfferCreateNewOption() + "\n\t" +
"** object property statements: " + list + "\n"; "** object property statements: " + list + "\n";
}
@Override
public ObjectProperty clone()
{
ObjectProperty clone = new ObjectProperty();
clone.setAddLinkSuppressed(this.isAddLinkSuppressed());
clone.setCollateBySubclass(this.getCollateBySubclass());
clone.setCustomEntryForm(this.getCustomEntryForm());
clone.setDeleteLinkSuppressed(this.isDeleteLinkSuppressed());
clone.setDescription(this.getDescription());
clone.setDomainDisplayLimit(this.getDomainDisplayLimitInteger());
clone.setDomainDisplayTier(this.getDomainDisplayTier());
clone.setDomainEntitySortDirection(this.getDomainEntitySortDirection());
clone.setDomainEntityURI(this.getDomainEntityURI());
clone.setDomainPublic(this.getDomainPublic());
clone.setDomainVClass(this.getDomainVClass());
clone.setDomainVClassURI(this.getDomainVClassURI());
clone.setEditLinkSuppressed(this.isEditLinkSuppressed());
clone.setExample(this.getExample());
clone.setFunctional(this.getFunctional());
clone.setGroupURI(this.getGroupURI());
clone.setHiddenFromDisplayBelowRoleLevel(this.getHiddenFromDisplayBelowRoleLevel());
clone.setInverseFunctional(this.getInverseFunctional());
clone.setLabel(this.getLabel());
clone.setLocalName(this.getLocalName());
clone.setLocalNameInverse(this.getLocalNameInverse());
clone.setLocalNameWithPrefix(this.getLocalNameWithPrefix());
clone.setNamespace(this.getNamespace());
clone.setNamespaceInverse(this.getNamespaceInverse());
clone.setObjectIndividualSortPropertyURI(this.getObjectIndividualSortPropertyURI());
clone.setOfferCreateNewOption(this.getOfferCreateNewOption());
clone.setParentURI(this.getParentURI());
clone.setPickListName(this.getPickListName());
clone.setProhibitedFromUpdateBelowRoleLevel(this.getProhibitedFromUpdateBelowRoleLevel());
clone.setPublicDescription(this.getPublicDescription());
clone.setRangeDisplayLimit(this.getRangeDisplayLimit());
clone.setRangeDisplayTier(this.getRangeDisplayTier());
clone.setRangeEntitySortDirection(this.getRangeEntitySortDirection());
clone.setRangeEntityURI(this.getRangeEntityURI());
clone.setRangePublic(this.getRangePublic());
clone.setRangeVClass(this.getRangeVClass());
clone.setRangeVClassURI(this.getRangeVClassURI());
clone.setSelectFromExisting(this.getSelectFromExisting());
clone.setStubObjectRelation(this.getStubObjectRelation());
clone.setSymmetric(this.getSymmetric());
clone.setTransitive(this.getTransitive());
clone.setURI(this.getURI());
clone.setURIInverse(this.getURIInverse());
return clone;
} }
} }

View file

@ -267,7 +267,8 @@ public class ConfigurationPropertiesSetup implements ServletContextListener {
@Override @Override
public void contextDestroyed(ServletContextEvent sce) { public void contextDestroyed(ServletContextEvent sce) {
ConfigurationProperties.removeBean(sce.getServletContext()); // No need to remove the bean. It's only a map of strings, and if we
// restart the app, it will be replaced.
} }
/** /**

View file

@ -102,7 +102,6 @@ public class ImageUploadController extends FreemarkerHttpServlet {
private static final String URL_HERE = UrlBuilder.getUrl("/uploadImages"); private static final String URL_HERE = UrlBuilder.getUrl("/uploadImages");
private static final String TEXT_BUNDLE = "imageUpload";
private static final String TEXT_STRING_UPLOAD_TITLE = "upload_page_title"; private static final String TEXT_STRING_UPLOAD_TITLE = "upload_page_title";
private static final String TEXT_STRING_UPLOAD_TITLE_WITH_NAME = "upload_page_title_with_name"; private static final String TEXT_STRING_UPLOAD_TITLE_WITH_NAME = "upload_page_title_with_name";
private static final String TEXT_STRING_REPLACE_TITLE = "replace_page_title"; private static final String TEXT_STRING_REPLACE_TITLE = "replace_page_title";
@ -572,10 +571,10 @@ public class ImageUploadController extends FreemarkerHttpServlet {
if (entity != null) { if (entity != null) {
String name = entity.getName(); String name = entity.getName();
if (name != null) { if (name != null) {
return I18n.text(req, TEXT_BUNDLE, nameTitleKey, name); return I18n.text(req, nameTitleKey, name);
} }
} }
return I18n.text(req, TEXT_BUNDLE, noNameTitleKey); return I18n.text(req, noNameTitleKey);
} }
/** /**

View file

@ -13,10 +13,7 @@ import javax.servlet.ServletContext;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.response.QueryResponse;
import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClass;
@ -25,9 +22,8 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ExceptionResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ExceptionResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.individuallist.IndividualListResults;
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao; import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
import edu.cornell.mannlib.vitro.webapp.search.solr.SolrSetup;
import edu.cornell.mannlib.vitro.webapp.utils.solr.SolrQueryUtils; import edu.cornell.mannlib.vitro.webapp.utils.solr.SolrQueryUtils;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individuallist.ListedIndividual; import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individuallist.ListedIndividual;
@ -94,16 +90,15 @@ public class IndividualListController extends FreemarkerHttpServlet {
String alpha = getAlphaParameter(vreq); String alpha = getAlphaParameter(vreq);
int page = getPageParameter(vreq); int page = getPageParameter(vreq);
Map<String,Object> map = getResultsForVClass( IndividualListResults vcResults = getResultsForVClass(
vclass.getURI(), vclass.getURI(),
page, page,
alpha, alpha,
vreq.getWebappDaoFactory().getIndividualDao(), vreq.getWebappDaoFactory().getIndividualDao(),
getServletContext()); getServletContext());
body.putAll(map); body.putAll(vcResults.asFreemarkerMap());
@SuppressWarnings("unchecked") List<Individual> inds = vcResults.getEntities();
List<Individual> inds = (List<Individual>)map.get("entities");
List<ListedIndividual> indsTm = new ArrayList<ListedIndividual>(); List<ListedIndividual> indsTm = new ArrayList<ListedIndividual>();
if (inds != null) { if (inds != null) {
for ( Individual ind : inds ) { for ( Individual ind : inds ) {
@ -154,13 +149,12 @@ public class IndividualListController extends FreemarkerHttpServlet {
return SolrQueryUtils.getPageParameter(request); return SolrQueryUtils.getPageParameter(request);
} }
public static Map<String,Object> getResultsForVClass(String vclassURI, int page, String alpha, IndividualDao indDao, ServletContext context) public static IndividualListResults getResultsForVClass(String vclassURI, int page, String alpha, IndividualDao indDao, ServletContext context)
throws SearchException{ throws SearchException{
Map<String,Object> rvMap = new HashMap<String,Object>();
try{ try{
List<String> classUris = Collections.singletonList(vclassURI); List<String> classUris = Collections.singletonList(vclassURI);
IndividualListQueryResults results = SolrQueryUtils.buildAndExecuteVClassQuery(classUris, alpha, page, INDIVIDUALS_PER_PAGE, context, indDao); IndividualListQueryResults results = SolrQueryUtils.buildAndExecuteVClassQuery(classUris, alpha, page, INDIVIDUALS_PER_PAGE, context, indDao);
rvMap = getResultsForVClassQuery(results, page, INDIVIDUALS_PER_PAGE, alpha); return getResultsForVClassQuery(results, page, INDIVIDUALS_PER_PAGE, alpha);
} catch (SolrServerException e) { } catch (SolrServerException e) {
String msg = "An error occurred retrieving results for vclass query"; String msg = "An error occurred retrieving results for vclass query";
log.error(msg, e); log.error(msg, e);
@ -168,31 +162,29 @@ public class IndividualListController extends FreemarkerHttpServlet {
throw new SearchException(msg); throw new SearchException(msg);
} catch(Throwable th) { } catch(Throwable th) {
log.error("An error occurred retrieving results for vclass query", th); log.error("An error occurred retrieving results for vclass query", th);
return IndividualListResults.EMPTY;
} }
return rvMap;
} }
public static Map<String,Object> getResultsForVClassIntersections(List<String> vclassURIs, int page, int pageSize, String alpha, IndividualDao indDao, ServletContext context) { public static IndividualListResults getResultsForVClassIntersections(List<String> vclassURIs, int page, int pageSize, String alpha, IndividualDao indDao, ServletContext context) {
Map<String,Object> rvMap = new HashMap<String,Object>();
try{ try{
IndividualListQueryResults results = SolrQueryUtils.buildAndExecuteVClassQuery(vclassURIs, alpha, page, pageSize, context, indDao); IndividualListQueryResults results = SolrQueryUtils.buildAndExecuteVClassQuery(vclassURIs, alpha, page, pageSize, context, indDao);
rvMap = getResultsForVClassQuery(results, page, pageSize, alpha); return getResultsForVClassQuery(results, page, pageSize, alpha);
} catch(Throwable th) { } catch(Throwable th) {
log.error("Error retrieving individuals corresponding to intersection multiple classes." + vclassURIs.toString(), th); log.error("Error retrieving individuals corresponding to intersection multiple classes." + vclassURIs.toString(), th);
return IndividualListResults.EMPTY;
} }
return rvMap;
} }
public static Map<String,Object> getRandomResultsForVClass(String vclassURI, int page, int pageSize, IndividualDao indDao, ServletContext context) { public static IndividualListResults getRandomResultsForVClass(String vclassURI, int page, int pageSize, IndividualDao indDao, ServletContext context) {
Map<String,Object> rvMap = new HashMap<String,Object>();
try{ try{
List<String> classUris = Collections.singletonList(vclassURI); List<String> classUris = Collections.singletonList(vclassURI);
IndividualListQueryResults results = SolrQueryUtils.buildAndExecuteRandomVClassQuery(classUris, page, pageSize, context, indDao); IndividualListQueryResults results = SolrQueryUtils.buildAndExecuteRandomVClassQuery(classUris, page, pageSize, context, indDao);
rvMap = getResultsForVClassQuery(results, page, pageSize, ""); return getResultsForVClassQuery(results, page, pageSize, "");
} catch(Throwable th) { } catch(Throwable th) {
log.error("An error occurred retrieving random results for vclass query", th); log.error("An error occurred retrieving random results for vclass query", th);
return IndividualListResults.EMPTY;
} }
return rvMap;
} }
//TODO: Get rid of this method and utilize SolrQueryUtils - currently appears to be referenced //TODO: Get rid of this method and utilize SolrQueryUtils - currently appears to be referenced
@ -201,24 +193,13 @@ public class IndividualListController extends FreemarkerHttpServlet {
return SolrQueryUtils.getIndividualCount(vclassUris, indDao, context); return SolrQueryUtils.getIndividualCount(vclassUris, indDao, context);
} }
private static Map<String,Object> getResultsForVClassQuery(IndividualListQueryResults results, int page, int pageSize, String alpha) { private static IndividualListResults getResultsForVClassQuery(IndividualListQueryResults results, int page, int pageSize, String alpha) {
Map<String,Object> rvMap = new HashMap<String,Object>();
long hitCount = results.getHitCount(); long hitCount = results.getHitCount();
if ( hitCount > pageSize ){ if ( hitCount > pageSize ){
rvMap.put("showPages", Boolean.TRUE); return new IndividualListResults(hitCount, results.getIndividuals(), alpha, true, makePagesList(hitCount, pageSize, page));
List<PageRecord> pageRecords = makePagesList(hitCount, pageSize, page);
rvMap.put("pages", pageRecords);
}else{ }else{
rvMap.put("showPages", Boolean.FALSE); return new IndividualListResults(hitCount, results.getIndividuals(), alpha, false, Collections.<PageRecord>emptyList());
rvMap.put("pages", Collections.emptyList());
} }
rvMap.put("alpha",alpha);
rvMap.put("totalCount", hitCount);
rvMap.put("entities", results.getIndividuals());
return rvMap;
} }

View file

@ -64,7 +64,9 @@ public class ListDatatypePropertiesController extends FreemarkerHttpServlet {
List<DataProperty> props = new ArrayList<DataProperty>(); List<DataProperty> props = new ArrayList<DataProperty>();
if (vreq.getParameter("propsForClass") != null) { if (vreq.getParameter("propsForClass") != null) {
noResultsMsgStr = "There are no data properties that apply to this class."; noResultsMsgStr = "There are no data properties that apply to this class.";
Collection <DataProperty> dataProps = dao.getDataPropertiesForVClass(vreq.getParameter("vclassUri")); Collection <DataProperty> dataProps = vreq.getLanguageNeutralWebappDaoFactory()
.getDataPropertyDao().getDataPropertiesForVClass(
vreq.getParameter("vclassUri"));
Iterator<DataProperty> dataPropIt = dataProps.iterator(); Iterator<DataProperty> dataPropIt = dataProps.iterator();
HashSet<String> propURIs = new HashSet<String>(); HashSet<String> propURIs = new HashSet<String>();
while (dataPropIt.hasNext()) { while (dataPropIt.hasNext()) {

View file

@ -59,7 +59,7 @@ public class ListPropertyWebappsController extends FreemarkerHttpServlet {
String ontologyUri = vreq.getParameter("ontologyUri"); String ontologyUri = vreq.getParameter("ontologyUri");
ObjectPropertyDao dao = vreq.getUnfilteredWebappDaoFactory().getObjectPropertyDao(); ObjectPropertyDao dao = vreq.getUnfilteredWebappDaoFactory().getObjectPropertyDao();
PropertyInstanceDao piDao = vreq.getUnfilteredWebappDaoFactory().getPropertyInstanceDao(); PropertyInstanceDao piDao = vreq.getLanguageNeutralWebappDaoFactory().getPropertyInstanceDao();
VClassDao vcDao = vreq.getUnfilteredWebappDaoFactory().getVClassDao(); VClassDao vcDao = vreq.getUnfilteredWebappDaoFactory().getVClassDao();
PropertyGroupDao pgDao = vreq.getUnfilteredWebappDaoFactory().getPropertyGroupDao(); PropertyGroupDao pgDao = vreq.getUnfilteredWebappDaoFactory().getPropertyGroupDao();

View file

@ -51,7 +51,7 @@ public class ListVClassWebappsController extends FreemarkerHttpServlet {
List<VClass> classes = null; List<VClass> classes = null;
if (vreq.getParameter("showPropertyRestrictions") != null) { if (vreq.getParameter("showPropertyRestrictions") != null) {
PropertyDao pdao = vreq.getUnfilteredWebappDaoFactory().getObjectPropertyDao(); PropertyDao pdao = vreq.getLanguageNeutralWebappDaoFactory().getObjectPropertyDao();
classes = pdao.getClassesWithRestrictionOnProperty(vreq.getParameter("propertyURI")); classes = pdao.getClassesWithRestrictionOnProperty(vreq.getParameter("propertyURI"));
} else { } else {
VClassDao vcdao = vreq.getUnfilteredWebappDaoFactory().getVClassDao(); VClassDao vcdao = vreq.getUnfilteredWebappDaoFactory().getVClassDao();

View file

@ -2,6 +2,7 @@
package edu.cornell.mannlib.vitro.webapp.controller.individual; package edu.cornell.mannlib.vitro.webapp.controller.individual;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -343,7 +344,9 @@ public class IndividualRdfAssembler {
} }
private Literal createDateLiteral(OntModel o) { private Literal createDateLiteral(OntModel o) {
return o.createTypedLiteral(new Date(), XSDDatatype.XSDdate); String date = new SimpleDateFormat("YYYY-MM-dd'T'HH:mm:ss")
.format(new Date());
return o.createTypedLiteral(date, XSDDatatype.XSDdateTime);
} }
} }

View file

@ -4,11 +4,6 @@ package edu.cornell.mannlib.vitro.webapp.controller.individual;
import java.util.List; import java.util.List;
import javax.servlet.ServletContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.SelfEditingConfiguration; import edu.cornell.mannlib.vitro.webapp.beans.SelfEditingConfiguration;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
@ -22,18 +17,13 @@ import edu.cornell.mannlib.vitro.webapp.filestorage.model.FileInfo;
*/ */
public class IndividualRequestAnalysisContextImpl implements public class IndividualRequestAnalysisContextImpl implements
IndividualRequestAnalysisContext { IndividualRequestAnalysisContext {
private static final Log log = LogFactory
.getLog(IndividualRequestAnalysisContextImpl.class);
private final VitroRequest vreq; private final VitroRequest vreq;
private final ServletContext ctx;
private final WebappDaoFactory wadf; private final WebappDaoFactory wadf;
private final IndividualDao iDao; private final IndividualDao iDao;
public IndividualRequestAnalysisContextImpl(VitroRequest vreq) { public IndividualRequestAnalysisContextImpl(VitroRequest vreq) {
this.vreq = vreq; this.vreq = vreq;
this.ctx = vreq.getSession().getServletContext();
this.wadf = vreq.getWebappDaoFactory(); this.wadf = vreq.getWebappDaoFactory();
this.iDao = wadf.getIndividualDao(); this.iDao = wadf.getIndividualDao();
} }

View file

@ -0,0 +1,48 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.controller.individuallist;
import java.util.Collection;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
/**
* Wrap an Individual in a JSON object for display by the script.
*
* This will be overridden in VIVO so we can have more info in the display.
*/
public class IndividualJsonWrapper {
static JSONObject packageIndividualAsJson(VitroRequest vreq, Individual ind)
throws JSONException {
// need an unfiltered dao to get firstnames and lastnames
WebappDaoFactory fullWdf = vreq.getUnfilteredWebappDaoFactory();
JSONObject jo = new JSONObject();
jo.put("URI", ind.getURI());
jo.put("label", ind.getRdfsLabel());
jo.put("name", ind.getName());
jo.put("thumbUrl", ind.getThumbUrl());
jo.put("imageUrl", ind.getImageUrl());
jo.put("profileUrl", UrlBuilder.getIndividualProfileUrl(ind, vreq));
jo.put("mostSpecificTypes", getMostSpecificTypes(ind, fullWdf));
return jo;
}
public static Collection<String> getMostSpecificTypes(
Individual individual, WebappDaoFactory wdf) {
ObjectPropertyStatementDao opsDao = wdf.getObjectPropertyStatementDao();
Map<String, String> mostSpecificTypes = opsDao
.getMostSpecificTypesInClassgroupsForIndividual(individual
.getURI());
return mostSpecificTypes.values();
}
}

View file

@ -0,0 +1,87 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.controller.individuallist;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController.PageRecord;
/**
* These are the paged results of a query for Individuals.
*
* The criteria for the search are the index of the desired page, the number of
* results displayed on each page, and an optional initial letter to search
* against.
*
* By the time this is built, the results have already been partially processed.
* A list of PageRecord object is included, with values that the GUI can use to
* create Alphabetical links. Maybe this processing should have been done later.
* Maybe it should have been left to the GUI.
*/
public class IndividualListResults {
private static final Log log = LogFactory
.getLog(IndividualListResults.class);
public static final IndividualListResults EMPTY = new IndividualListResults();
private final long totalCount;
private final List<Individual> entities;
private final String alpha;
private final boolean showPages;
private final List<PageRecord> pages;
public IndividualListResults(long totalCount, List<Individual> entities,
String alpha, boolean showPages, List<PageRecord> pages) {
this.totalCount = totalCount;
this.entities = entities;
this.alpha = alpha;
this.showPages = showPages;
this.pages = pages;
}
private IndividualListResults() {
this(0L, Collections.<Individual> emptyList(), "", false, Collections
.<PageRecord> emptyList());
}
public long getTotalCount() {
return totalCount;
}
public String getAlpha() {
return alpha;
}
public List<Individual> getEntities() {
return entities;
}
public List<PageRecord> getPages() {
return pages;
}
public boolean isShowPages() {
return showPages;
}
/**
* Some controllers put this data directly into the Freemarker body map.
* Others wrap it in JSON.
*/
public Map<String, Object> asFreemarkerMap() {
Map<String, Object> m = new HashMap<>();
m.put("showPages", showPages);
m.put("pages", pages);
m.put("alpha", alpha);
m.put("totalCount", totalCount);
m.put("entities", entities);
return m;
}
}

View file

@ -0,0 +1,148 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.controller.individuallist;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController.PageRecord;
/**
* Utility methods for procesing the paged results of a query for a list of Individuals.
*
* Right now, there is only a method to wrap the results in Json.
*/
public class IndividualListResultsUtils {
private static final Log log = LogFactory
.getLog(IndividualListResultsUtils.class);
/**
* Process results related to VClass or vclasses. Handles both single and
* multiple vclasses being sent.
*/
public static JSONObject wrapIndividualListResultsInJson(IndividualListResults results, VitroRequest vreq,
boolean multipleVclasses) {
JSONObject rObj = new JSONObject();
if (log.isDebugEnabled()) {
dumpParametersFromRequest(vreq);
}
try {
List<VClass> vclasses = buildListOfRequestedVClasses(vreq);
VClass vclass = null;
// if single vclass expected, then include vclass.
// This relates to what the expected behavior is, not size of list
if (!multipleVclasses) {
vclass = vclasses.get(0);
// currently used for ClassGroupPage
} else {
// For now, utilize very last VClass (assume that that is the one to be employed)
// TODO: Find more general way of dealing with this: put multiple ones in?
vclass = vclasses.get(vclasses.size() - 1);
// rObj.put("vclasses", new JSONObject().put("URIs",vitroClassIdStr).put("name",vclass.getName()));
}
rObj.put("vclass", packageVClassAsJson(vclass));
rObj.put("totalCount", results.getTotalCount());
rObj.put("alpha", results.getAlpha());
rObj.put("individuals", packageIndividualsAsJson(vreq, results.getEntities()));
rObj.put("pages", packagePageRecordsAsJson(results.getPages()));
rObj.put("letters", packageLettersAsJson());
} catch (Exception ex) {
log.error("Error occurred in processing JSON object", ex);
}
return rObj;
}
private static List<VClass> buildListOfRequestedVClasses(VitroRequest vreq)
throws Exception {
String[] vitroClassIdStr = vreq.getParameterValues("vclassId");
if (ArrayUtils.isEmpty(vitroClassIdStr)) {
log.error("parameter vclassId URI parameter expected ");
throw new Exception("parameter vclassId URI parameter expected ");
}
List<VClass> list = new ArrayList<>();
for (String vclassId : vitroClassIdStr) {
VClass vclass = vreq.getWebappDaoFactory().getVClassDao()
.getVClassByURI(vclassId);
if (vclass == null) {
log.error("Couldn't retrieve vclass ");
throw new Exception("Class " + vclassId + " not found");
}
list.add(vclass);
}
return list;
}
private static JSONObject packageVClassAsJson(VClass vclass)
throws JSONException {
JSONObject jvclass = new JSONObject();
jvclass.put("URI", vclass.getURI());
jvclass.put("name", vclass.getName());
return jvclass;
}
private static JSONArray packageLettersAsJson() throws JSONException,
UnsupportedEncodingException {
List<String> letters = Controllers.getLetters();
JSONArray jletters = new JSONArray();
for (String s : letters) {
JSONObject jo = new JSONObject();
jo.put("text", s);
jo.put("param", "alpha=" + URLEncoder.encode(s, "UTF-8"));
jletters.put(jo);
}
return jletters;
}
private static JSONArray packagePageRecordsAsJson(List<PageRecord> pages)
throws JSONException {
JSONArray wpages = new JSONArray();
for (PageRecord pr : pages) {
JSONObject p = new JSONObject();
p.put("text", pr.text);
p.put("param", pr.param);
p.put("index", pr.index);
wpages.put(p);
}
return wpages;
}
private static JSONArray packageIndividualsAsJson(VitroRequest vreq,
List<Individual> inds) throws JSONException {
log.debug("Number of individuals returned from request: " + inds.size());
JSONArray jInds = new JSONArray();
for (Individual ind : inds) {
jInds.put(IndividualJsonWrapper.packageIndividualAsJson(vreq, ind));
}
return jInds;
}
private static void dumpParametersFromRequest(VitroRequest vreq) {
Map<String, String[]> pMap = vreq.getParameterMap();
for (String name : pMap.keySet()) {
for (String value : pMap.get(name)) {
log.debug("value for " + name + ": '" + value + "'");
}
}
}
}

View file

@ -3,11 +3,8 @@
package edu.cornell.mannlib.vitro.webapp.controller.json; package edu.cornell.mannlib.vitro.webapp.controller.json;
import java.io.IOException; import java.io.IOException;
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -18,18 +15,15 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty; import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet; import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController.PageRecord; import edu.cornell.mannlib.vitro.webapp.controller.individuallist.IndividualListResultsUtils;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder; import edu.cornell.mannlib.vitro.webapp.controller.individuallist.IndividualListResults;
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao; import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.utils.log.LogUtils; import edu.cornell.mannlib.vitro.webapp.utils.log.LogUtils;
@ -94,29 +88,28 @@ public class JsonServlet extends VitroHttpServlet {
List<String> vclassURIs = Collections.singletonList(vclassURI); List<String> vclassURIs = Collections.singletonList(vclassURI);
VitroRequest vreq = new VitroRequest(req); VitroRequest vreq = new VitroRequest(req);
Map<String, Object> map = getSolrVClassIntersectionResults(vclassURIs, vreq, context); IndividualListResults vcResults = getSolrVClassIntersectionResults(vclassURIs, vreq, context);
//last parameter indicates single vclass instead of multiple vclasses //last parameter indicates single vclass instead of multiple vclasses
return processVclassResultsJSON(map, vreq, false); return IndividualListResultsUtils.wrapIndividualListResultsInJson(vcResults, vreq, false);
} }
public static JSONObject getSolrIndividualsByVClasses(List<String> vclassURIs, HttpServletRequest req, ServletContext context) throws Exception { public static JSONObject getSolrIndividualsByVClasses(List<String> vclassURIs, HttpServletRequest req, ServletContext context) throws Exception {
VitroRequest vreq = new VitroRequest(req); VitroRequest vreq = new VitroRequest(req);
log.debug("Retrieve solr results for vclasses" + vclassURIs.toString()); log.debug("Retrieve solr results for vclasses" + vclassURIs.toString());
Map<String, Object> map = getSolrVClassIntersectionResults(vclassURIs, vreq, context); IndividualListResults vcResults = getSolrVClassIntersectionResults(vclassURIs, vreq, context);
log.debug("Results returned from Solr for " + vclassURIs.toString() + " are of size " + map.size()); log.debug("Results returned from Solr for " + vclassURIs.toString() + " are of size " + vcResults.getTotalCount());
return processVclassResultsJSON(map, vreq, true); return IndividualListResultsUtils.wrapIndividualListResultsInJson(vcResults, vreq, true);
} }
//Including version for Solr query for Vclass Intersections //Including version for Solr query for Vclass Intersections
private static Map<String,Object> getSolrVClassIntersectionResults(List<String> vclassURIs, VitroRequest vreq, ServletContext context){ private static IndividualListResults getSolrVClassIntersectionResults(List<String> vclassURIs, VitroRequest vreq, ServletContext context){
log.debug("Retrieving Solr intersection results for " + vclassURIs.toString()); log.debug("Retrieving Solr intersection results for " + vclassURIs.toString());
String alpha = IndividualListController.getAlphaParameter(vreq); String alpha = IndividualListController.getAlphaParameter(vreq);
int page = IndividualListController.getPageParameter(vreq); int page = IndividualListController.getPageParameter(vreq);
log.debug("Alpha and page parameters are " + alpha + " and " + page); log.debug("Alpha and page parameters are " + alpha + " and " + page);
Map<String,Object> map = null;
try { try {
map = IndividualListController.getResultsForVClassIntersections( return IndividualListController.getResultsForVClassIntersections(
vclassURIs, vclassURIs,
page, INDIVIDUALS_PER_PAGE, page, INDIVIDUALS_PER_PAGE,
alpha, alpha,
@ -124,21 +117,8 @@ public class JsonServlet extends VitroHttpServlet {
context); context);
} catch(Exception ex) { } catch(Exception ex) {
log.error("Error in retrieval of search results for VClass " + vclassURIs.toString(), ex); log.error("Error in retrieval of search results for VClass " + vclassURIs.toString(), ex);
return IndividualListResults.EMPTY;
} }
return map;
}
// Map given to process method includes the actual individuals returned from the search
// public static JSONObject processVClassResults(Map<String, Object> map, VitroRequest vreq, ServletContext context, boolean multipleVclasses) throws Exception{
// JSONObject rObj = processVclassResultsJSON(map, vreq, multipleVclasses);
// return rObj;
// }
public static Collection<String> getMostSpecificTypes(Individual individual, WebappDaoFactory wdf) {
ObjectPropertyStatementDao opsDao = wdf.getObjectPropertyStatementDao();
Map<String, String> mostSpecificTypes = opsDao.getMostSpecificTypesInClassgroupsForIndividual(individual.getURI());
return mostSpecificTypes.values();
} }
public static String getDataPropertyValue(Individual ind, DataProperty dp, WebappDaoFactory wdf){ public static String getDataPropertyValue(Individual ind, DataProperty dp, WebappDaoFactory wdf){
@ -152,21 +132,20 @@ public class JsonServlet extends VitroHttpServlet {
public static JSONObject getRandomSolrIndividualsByVClass(String vclassURI, HttpServletRequest req, ServletContext context) throws Exception { public static JSONObject getRandomSolrIndividualsByVClass(String vclassURI, HttpServletRequest req, ServletContext context) throws Exception {
VitroRequest vreq = new VitroRequest(req); VitroRequest vreq = new VitroRequest(req);
Map<String, Object> map = getRandomSolrVClassResults(vclassURI, vreq, context); IndividualListResults vcResults = getRandomSolrVClassResults(vclassURI, vreq, context);
//last parameter indicates single vclass instead of multiple vclasses //last parameter indicates single vclass instead of multiple vclasses
return processVclassResultsJSON(map, vreq, false); return IndividualListResultsUtils.wrapIndividualListResultsInJson(vcResults, vreq, false);
} }
//Including version for Random Solr query for Vclass Intersections //Including version for Random Solr query for Vclass Intersections
private static Map<String,Object> getRandomSolrVClassResults(String vclassURI, VitroRequest vreq, ServletContext context){ private static IndividualListResults getRandomSolrVClassResults(String vclassURI, VitroRequest vreq, ServletContext context){
log.debug("Retrieving random Solr intersection results for " + vclassURI); log.debug("Retrieving random Solr intersection results for " + vclassURI);
int page = IndividualListController.getPageParameter(vreq); int page = IndividualListController.getPageParameter(vreq);
int pageSize = Integer.parseInt(vreq.getParameter("pageSize")); int pageSize = Integer.parseInt(vreq.getParameter("pageSize"));
log.debug("page and pageSize parameters = " + page + " and " + pageSize); log.debug("page and pageSize parameters = " + page + " and " + pageSize);
Map<String,Object> map = null;
try { try {
map = IndividualListController.getRandomResultsForVClass( return IndividualListController.getRandomResultsForVClass(
vclassURI, vclassURI,
page, page,
pageSize, pageSize,
@ -174,126 +153,8 @@ public class JsonServlet extends VitroHttpServlet {
context); context);
} catch(Exception ex) { } catch(Exception ex) {
log.error("Error in retrieval of search results for VClass " + vclassURI, ex); log.error("Error in retrieval of search results for VClass " + vclassURI, ex);
} return IndividualListResults.EMPTY;
return map;
}
/**
* Process results related to VClass or vclasses. Handles both single and multiple vclasses being sent.
*/
public static JSONObject processVclassResultsJSON(Map<String, Object> map, VitroRequest vreq, boolean multipleVclasses) {
JSONObject rObj = new JSONObject();
VClass vclass=null;
try {
// Properties from ontologies used by VIVO - should not be in vitro
DataProperty fNameDp = (new DataProperty());
fNameDp.setURI("http://xmlns.com/foaf/0.1/firstName");
DataProperty lNameDp = (new DataProperty());
lNameDp.setURI("http://xmlns.com/foaf/0.1/lastName");
DataProperty preferredTitleDp = (new DataProperty());
preferredTitleDp.setURI("http://vivoweb.org/ontology/core#preferredTitle");
if( log.isDebugEnabled() ){
@SuppressWarnings("unchecked")
Enumeration<String> e = vreq.getParameterNames();
while(e.hasMoreElements()){
String name = e.nextElement();
log.debug("parameter: " + name);
for( String value : vreq.getParameterValues(name) ){
log.debug("value for " + name + ": '" + value + "'");
}
} }
} }
//need an unfiltered dao to get firstnames and lastnames
WebappDaoFactory fullWdf = vreq.getUnfilteredWebappDaoFactory();
String[] vitroClassIdStr = vreq.getParameterValues("vclassId");
if ( vitroClassIdStr != null && vitroClassIdStr.length > 0){
for(String vclassId: vitroClassIdStr) {
vclass = vreq.getWebappDaoFactory().getVClassDao().getVClassByURI(vclassId);
if (vclass == null) {
log.error("Couldn't retrieve vclass ");
throw new Exception ("Class " + vclassId + " not found");
}
}
}else{
log.error("parameter vclassId URI parameter expected ");
throw new Exception("parameter vclassId URI parameter expected ");
}
List<String> vclassIds = Arrays.asList(vitroClassIdStr);
//if single vclass expected, then include vclass. This relates to what the expected behavior is, not size of list
if(!multipleVclasses) {
//currently used for ClassGroupPage
rObj.put("vclass",
new JSONObject().put("URI",vclass.getURI())
.put("name",vclass.getName()));
} else {
//For now, utilize very last VClass (assume that that is the one to be employed)
//TODO: Find more general way of dealing with this
//put multiple ones in?
if(vclassIds.size() > 0) {
int numberVClasses = vclassIds.size();
vclass = vreq.getWebappDaoFactory().getVClassDao().getVClassByURI(vclassIds.get(numberVClasses - 1));
rObj.put("vclass", new JSONObject().put("URI",vclass.getURI())
.put("name",vclass.getName()));
}
// rObj.put("vclasses", new JSONObject().put("URIs",vitroClassIdStr)
// .put("name",vclass.getName()));
}
if (vclass != null) {
rObj.put("totalCount", map.get("totalCount"));
rObj.put("alpha", map.get("alpha"));
List<Individual> inds = (List<Individual>)map.get("entities");
log.debug("Number of individuals returned from request: " + inds.size());
JSONArray jInds = new JSONArray();
for(Individual ind : inds ){
JSONObject jo = new JSONObject();
jo.put("URI", ind.getURI());
jo.put("label",ind.getRdfsLabel());
jo.put("name",ind.getName());
jo.put("thumbUrl", ind.getThumbUrl());
jo.put("imageUrl", ind.getImageUrl());
jo.put("profileUrl", UrlBuilder.getIndividualProfileUrl(ind, vreq));
jo.put("mostSpecificTypes", JsonServlet.getMostSpecificTypes(ind,fullWdf));
jo.put("preferredTitle", JsonServlet.getDataPropertyValue(ind, preferredTitleDp, fullWdf));
jInds.put(jo);
}
rObj.put("individuals", jInds);
JSONArray wpages = new JSONArray();
//Made sure that PageRecord here is SolrIndividualListController not IndividualListController
List<PageRecord> pages = (List<PageRecord>)map.get("pages");
for( PageRecord pr: pages ){
JSONObject p = new JSONObject();
p.put("text", pr.text);
p.put("param", pr.param);
p.put("index", pr.index);
wpages.put( p );
}
rObj.put("pages",wpages);
JSONArray jletters = new JSONArray();
List<String> letters = Controllers.getLetters();
for( String s : letters){
JSONObject jo = new JSONObject();
jo.put("text", s);
jo.put("param", "alpha=" + URLEncoder.encode(s, "UTF-8"));
jletters.put( jo );
}
rObj.put("letters", jletters);
}
} catch(Exception ex) {
log.error("Error occurred in processing JSON object", ex);
}
return rObj;
}
} }

View file

@ -17,6 +17,18 @@ public interface ObjectPropertyDao extends PropertyDao {
public ObjectProperty getObjectPropertyByURIs(String objectPropertyURI, String domainURI, String rangeURI); public ObjectProperty getObjectPropertyByURIs(String objectPropertyURI, String domainURI, String rangeURI);
/**
* Use this method to supply a base ObjectProperty whose fields will be updated
* as necessary to correspond to the configuration for the specified Domain
* and Range.
* @param objectPropertyURI
* @param domainURI
* @param rangeURI
* @param base
* @return ObjectProperty
*/
public ObjectProperty getObjectPropertyByURIs(String objectPropertyURI, String domainURI, String rangeURI, ObjectProperty base);
public List <ObjectProperty> getObjectPropertiesForObjectPropertyStatements(List /*of ObjectPropertyStatement */ objectPropertyStatements); public List <ObjectProperty> getObjectPropertiesForObjectPropertyStatements(List /*of ObjectPropertyStatement */ objectPropertyStatements);
public List<String> getSuperPropertyURIs(String objectPropertyURI, boolean direct); public List<String> getSuperPropertyURIs(String objectPropertyURI, boolean direct);
@ -54,8 +66,22 @@ public interface ObjectPropertyDao extends PropertyDao {
List <ObjectProperty> getRootObjectProperties(); List <ObjectProperty> getRootObjectProperties();
/**
* Returns a list of ObjectProperty objects for which statements exist about
* the individual. Note that this method now returns multiple copies of
* a given predicate, with the rangeVClassURI changed to indicate the distinct
* types of the related objects. This supports finding the approriate list
* views for the "faux" qualified properties.
*/
public List<ObjectProperty> getObjectPropertyList(Individual subject); public List<ObjectProperty> getObjectPropertyList(Individual subject);
/**
* Returns a list of ObjectProperty objects for which statements exist about
* the individual. Note that this method now returns multiple copies of
* a given predicate, with the rangeVClassURI changed to indicate the distinct
* types of the related objects. This supports finding the approriate list
* views for the "faux" qualified properties.
*/
public List<ObjectProperty> getObjectPropertyList(String subjectUri); public List<ObjectProperty> getObjectPropertyList(String subjectUri);
public String getCustomListViewConfigFileName(ObjectProperty objectProperty); public String getCustomListViewConfigFileName(ObjectProperty objectProperty);

View file

@ -5,14 +5,20 @@ package edu.cornell.mannlib.vitro.webapp.dao;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import org.openjena.atlas.lib.Pair;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
public class WebappDaoFactoryConfig { public class WebappDaoFactoryConfig {
private List<String> preferredLanguages; private List<String> preferredLanguages;
private String defaultNamespace; private String defaultNamespace;
private Set<String> nonUserNamespaces; private Set<String> nonUserNamespaces;
private boolean isUnderlyingStoreReasoned = false; private boolean isUnderlyingStoreReasoned = false;
public Map<Pair<String,Pair<ObjectProperty, String>>, String> customListViewConfigFileMap;
public WebappDaoFactoryConfig() { public WebappDaoFactoryConfig() {
preferredLanguages = Arrays.asList("en-US", "en", "EN"); preferredLanguages = Arrays.asList("en-US", "en", "EN");
@ -53,4 +59,13 @@ public class WebappDaoFactoryConfig {
return this.isUnderlyingStoreReasoned; return this.isUnderlyingStoreReasoned;
} }
public Map<Pair<String,Pair<ObjectProperty, String>>, String> getCustomListViewConfigFileMap() {
return this.getCustomListViewConfigFileMap();
}
public void setCustomListViewConfigFileMap(
Map<Pair<String,Pair<ObjectProperty, String>>, String> map) {
this.customListViewConfigFileMap = map;
}
} }

View file

@ -54,6 +54,11 @@ class ObjectPropertyDaoFiltering extends BaseFiltering implements ObjectProperty
return (newOprop == null) ? null : new ObjectPropertyFiltering(newOprop, filters); return (newOprop == null) ? null : new ObjectPropertyFiltering(newOprop, filters);
} }
public ObjectProperty getObjectPropertyByURIs(String objectPropertyURI, String domainURI, String rangeURI, ObjectProperty base) {
ObjectProperty newOprop=innerObjectPropertyDao.getObjectPropertyByURIs(objectPropertyURI, domainURI, rangeURI, base);
return (newOprop == null) ? null : new ObjectPropertyFiltering(newOprop, filters);
}
public List<ObjectPropertyStatement> getStatementsUsingObjectProperty(ObjectProperty op) { public List<ObjectPropertyStatement> getStatementsUsingObjectProperty(ObjectProperty op) {
return ObjectPropertyStatementDaoFiltering.filterAndWrapList(innerObjectPropertyDao.getStatementsUsingObjectProperty(op),filters); return ObjectPropertyStatementDaoFiltering.filterAndWrapList(innerObjectPropertyDao.getStatementsUsingObjectProperty(op),filters);
} }

View file

@ -45,15 +45,14 @@ import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty; import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement; import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstance; import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstance;
import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao; import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
import edu.cornell.mannlib.vitro.webapp.dao.InsertException; import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent; import edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent;
import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.PelletListener; import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.PelletListener;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
public class DataPropertyDaoJena extends PropertyDaoJena implements public class DataPropertyDaoJena extends PropertyDaoJena implements
DataPropertyDao { DataPropertyDao {
@ -71,9 +70,10 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
} }
} }
public DataPropertyDaoJena(DatasetWrapperFactory dwf, public DataPropertyDaoJena(RDFService rdfService,
DatasetWrapperFactory dwf,
WebappDaoFactoryJena wadf) { WebappDaoFactoryJena wadf) {
super(dwf, wadf); super(rdfService, dwf, wadf);
} }
public void deleteDataProperty(DataProperty dtp) { public void deleteDataProperty(DataProperty dtp) {
@ -672,7 +672,7 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
PREFIXES + "\n" + PREFIXES + "\n" +
"SELECT DISTINCT ?property WHERE { \n" + "SELECT DISTINCT ?property WHERE { \n" +
" ?subject ?property ?object . \n" + " ?subject ?property ?object . \n" +
" ?property a owl:DatatypeProperty . \n" + //" ?property a owl:DatatypeProperty . \n" +
" FILTER ( \n" + " FILTER ( \n" +
" isLiteral(?object) && \n" + " isLiteral(?object) && \n" +
" ( !regex(str(?property), \"^" + VitroVocabulary.PUBLIC + "\" )) && \n" + " ( !regex(str(?property), \"^" + VitroVocabulary.PUBLIC + "\" )) && \n" +
@ -708,7 +708,7 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
} }
log.debug("Data property query string:\n" + query); log.debug("Data property query string:\n" + query);
ResultSet results = getPropertyQueryResults(query); ResultSet results = getPropertyQueryResults(queryString);
List<DataProperty> properties = new ArrayList<DataProperty>(); List<DataProperty> properties = new ArrayList<DataProperty>();
while (results.hasNext()) { while (results.hasNext()) {
QuerySolution sol = results.next(); QuerySolution sol = results.next();

View file

@ -13,11 +13,13 @@ import java.util.Map;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.openjena.atlas.lib.Pair;
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; import com.hp.hpl.jena.datatypes.xsd.XSDDatatype;
import com.hp.hpl.jena.ontology.ConversionException; import com.hp.hpl.jena.ontology.ConversionException;
import com.hp.hpl.jena.ontology.DatatypeProperty; import com.hp.hpl.jena.ontology.DatatypeProperty;
import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.ontology.OntProperty; import com.hp.hpl.jena.ontology.OntProperty;
import com.hp.hpl.jena.ontology.OntResource; import com.hp.hpl.jena.ontology.OntResource;
import com.hp.hpl.jena.ontology.ProfileException; import com.hp.hpl.jena.ontology.ProfileException;
@ -28,7 +30,6 @@ import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.QuerySolution; import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Property; import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.RDFNode; import com.hp.hpl.jena.rdf.model.RDFNode;
@ -37,30 +38,31 @@ import com.hp.hpl.jena.rdf.model.ResourceFactory;
import com.hp.hpl.jena.rdf.model.Statement; import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.rdf.model.StmtIterator; import com.hp.hpl.jena.rdf.model.StmtIterator;
import com.hp.hpl.jena.shared.Lock; import com.hp.hpl.jena.shared.Lock;
import com.hp.hpl.jena.sparql.expr.NodeValue;
import com.hp.hpl.jena.util.iterator.ClosableIterator; import com.hp.hpl.jena.util.iterator.ClosableIterator;
import com.hp.hpl.jena.vocabulary.OWL; import com.hp.hpl.jena.vocabulary.OWL;
import com.hp.hpl.jena.vocabulary.RDF; import com.hp.hpl.jena.vocabulary.RDF;
import com.hp.hpl.jena.vocabulary.RDFS; import com.hp.hpl.jena.vocabulary.RDFS;
import com.hp.hpl.jena.sdb.util.Pair;
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean; import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean;
import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty; import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement; import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
import edu.cornell.mannlib.vitro.webapp.dao.InsertException; import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao; import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent; import edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectPropertyDao { public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectPropertyDao {
private static final Log log = LogFactory.getLog(ObjectPropertyDaoJena.class.getName()); private static final Log log = LogFactory.getLog(ObjectPropertyDaoJena.class.getName());
public ObjectPropertyDaoJena(DatasetWrapperFactory dwf, public ObjectPropertyDaoJena(RDFService rdfService,
DatasetWrapperFactory dwf,
Map<Pair<String,Pair<ObjectProperty, String>>, String>
customListViewConfigFileMap,
WebappDaoFactoryJena wadf) { WebappDaoFactoryJena wadf) {
super(dwf, wadf); super(rdfService, dwf, wadf);
this.customListViewConfigFileMap = customListViewConfigFileMap;
} }
@Override @Override
@ -69,7 +71,6 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
} }
public void deleteObjectProperty(String propertyURI) { public void deleteObjectProperty(String propertyURI) {
OntProperty p = getOntModel().getOntProperty(propertyURI);
ObjectProperty op = new ObjectProperty(); ObjectProperty op = new ObjectProperty();
op.setURI(propertyURI); op.setURI(propertyURI);
deleteObjectProperty(op); deleteObjectProperty(op);
@ -269,22 +270,43 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
} }
public ObjectProperty getObjectPropertyByURI(String propertyURI) { public ObjectProperty getObjectPropertyByURI(String propertyURI) {
if( propertyURI == null ) return null; if( propertyURI == null ) return null;
getOntModel().enterCriticalSection(Lock.READ); OntModel ontModel = getOntModel();
OntModel localModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
ontModel.enterCriticalSection(Lock.READ);
try { try {
OntProperty op = getOntModel().getObjectProperty(propertyURI); Resource prop = ontModel.getResource(propertyURI);
localModel.add(ontModel.listStatements(prop, null, (RDFNode) null));
StmtIterator invit = ontModel.listStatements(prop, OWL.inverseOf, (RDFNode) null);
while (invit.hasNext()) {
Statement invSit = invit.nextStatement();
if (invSit.getObject().isURIResource()) {
Resource invProp = (Resource) invSit.getObject();
localModel.add(ontModel.listStatements(invProp, null, (RDFNode) null));
}
}
OntProperty op = localModel.getObjectProperty(propertyURI);
return propertyFromOntProperty(op); return propertyFromOntProperty(op);
} finally { } finally {
getOntModel().leaveCriticalSection(); ontModel.leaveCriticalSection();
} }
} }
public ObjectProperty getObjectPropertyByURIs(String propertyURI, String domainURI, String rangeURI) { public ObjectProperty getObjectPropertyByURIs(String propertyURI,
String domainURI, String rangeURI) {
return getObjectPropertyByURIs(propertyURI, domainURI, rangeURI, null);
}
public ObjectProperty getObjectPropertyByURIs(String propertyURI,
String domainURI, String rangeURI, ObjectProperty base) {
if(log.isDebugEnabled()) { if(log.isDebugEnabled()) {
log.debug("Getting " + propertyURI + " with domain " + domainURI + " and range " + rangeURI); log.debug("Getting " + propertyURI + " with domain " + domainURI + " and range " + rangeURI);
} }
ObjectProperty op = getObjectPropertyByURI(propertyURI); long start = System.currentTimeMillis();
ObjectProperty op = (base != null) ? base : getObjectPropertyByURI(propertyURI);
if (op == null || rangeURI == null) { if (op == null || rangeURI == null) {
return op; return op;
} }
@ -293,11 +315,11 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
String propQuery = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + String propQuery = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
"PREFIX config: <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#> \n" + "PREFIX config: <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#> \n" +
"PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> \n" + "PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> \n" +
"SELECT ?range ?label ?group ?customForm ?displayRank ?displayLevel " + "SELECT ?range ?rangeRoot ?label ?group ?customForm ?displayRank ?displayLevel " +
" ?updateLevel ?editLinkSuppressed ?addLinkSuppressed ?deleteLinkSuppressed \n" + " ?updateLevel ?editLinkSuppressed ?addLinkSuppressed ?deleteLinkSuppressed \n" +
" ?collateBySubclass ?displayLimit ?individualSortProperty \n" + " ?collateBySubclass ?displayLimit ?individualSortProperty \n" +
" ?entitySortDirection ?selectFromExisting ?offerCreateNew \n" + " ?entitySortDirection ?selectFromExisting ?offerCreateNew \n" +
" ?publicDescription \n" + " ?publicDescription ?stubDeletion \n" +
" WHERE { \n" + " WHERE { \n" +
" ?context config:configContextFor <" + propertyURI + "> . \n"; " ?context config:configContextFor <" + propertyURI + "> . \n";
if (domainURI != null) { if (domainURI != null) {
@ -308,7 +330,8 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
if (rangeURI != null) { if (rangeURI != null) {
propQuery += " ?context config:qualifiedBy <" + rangeURI + "> . \n"; propQuery += " ?context config:qualifiedBy <" + rangeURI + "> . \n";
}; };
propQuery += " ?context config:hasConfiguration ?configuration . \n" + propQuery += " OPTIONAL { ?context config:qualifiedByRoot ?rangeRoot } \n" +
" ?context config:hasConfiguration ?configuration . \n" +
" ?configuration a config:ObjectPropertyDisplayConfig . \n" + " ?configuration a config:ObjectPropertyDisplayConfig . \n" +
" OPTIONAL { ?configuration config:propertyGroup ?group } \n" + " OPTIONAL { ?configuration config:propertyGroup ?group } \n" +
" OPTIONAL { ?configuration config:displayName ?label } \n" + " OPTIONAL { ?configuration config:displayName ?label } \n" +
@ -326,6 +349,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
" OPTIONAL { ?configuration <" + PROPERTY_SELECTFROMEXISTINGANNOT.getURI() + "> ?selectFromExisting } \n" + " OPTIONAL { ?configuration <" + PROPERTY_SELECTFROMEXISTINGANNOT.getURI() + "> ?selectFromExisting } \n" +
" OPTIONAL { ?configuration <" + PROPERTY_OFFERCREATENEWOPTIONANNOT.getURI() + "> ?offerCreateNew } \n" + " OPTIONAL { ?configuration <" + PROPERTY_OFFERCREATENEWOPTIONANNOT.getURI() + "> ?offerCreateNew } \n" +
" OPTIONAL { ?configuration <" + PUBLIC_DESCRIPTION_ANNOT.getURI() + "> ?publicDescription } \n" + " OPTIONAL { ?configuration <" + PUBLIC_DESCRIPTION_ANNOT.getURI() + "> ?publicDescription } \n" +
" OPTIONAL { ?configuration <" + PROPERTY_STUBOBJECTPROPERTYANNOT.getURI() + "> ?stubDeletion } \n" +
"}"; "}";
Query q = QueryFactory.create(propQuery); Query q = QueryFactory.create(propQuery);
@ -334,6 +358,15 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
ResultSet rs = qe.execSelect(); ResultSet rs = qe.execSelect();
if (rs.hasNext()) { if (rs.hasNext()) {
QuerySolution qsoln = rs.nextSolution(); QuerySolution qsoln = rs.nextSolution();
// This is a bit of hack, used for things where the type of the
// immediately-related object ("root," for lack of a better term)
// is important to record but not the type directly associated with
// a configuration
Resource rangeRootRes = qsoln.getResource("rangeRoot");
if (rangeRootRes != null) {
// reusing this obsolete field for now
op.setRangeEntityURI(rangeRootRes.getURI());
}
Resource groupRes = qsoln.getResource("group"); Resource groupRes = qsoln.getResource("group");
if (groupRes != null) { if (groupRes != null) {
op.setGroupURI(groupRes.getURI()); op.setGroupURI(groupRes.getURI());
@ -400,6 +433,10 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
if (offerCreateNewLit != null) { if (offerCreateNewLit != null) {
op.setOfferCreateNewOption(offerCreateNewLit.getBoolean()); op.setOfferCreateNewOption(offerCreateNewLit.getBoolean());
} }
Literal stubDeletionLit = qsoln.getLiteral("stubDeletion");
if (stubDeletionLit != null) {
op.setStubObjectRelation(stubDeletionLit.getBoolean());
}
Literal publicDescriptionLit = qsoln.getLiteral("publicDescription"); Literal publicDescriptionLit = qsoln.getLiteral("publicDescription");
if (publicDescriptionLit != null) { if (publicDescriptionLit != null) {
op.setPublicDescription(publicDescriptionLit.getLexicalForm()); op.setPublicDescription(publicDescriptionLit.getLexicalForm());
@ -922,20 +959,26 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
protected static final String OBJECT_PROPERTY_QUERY_STRING = protected static final String OBJECT_PROPERTY_QUERY_STRING =
PREFIXES + "\n" + PREFIXES + "\n" +
"SELECT DISTINCT ?property WHERE { \n" + "SELECT DISTINCT ?property ?objType WHERE { \n" +
" ?subject ?property ?object . \n" + " ?subject ?property ?object . \n" +
" ?object a ?objType . \n" +
// " ?property a owl:ObjectProperty . \n" + // " ?property a owl:ObjectProperty . \n" +
" FILTER ( \n" + " FILTER ( \n" +
" isURI(?object) && \n" + " isURI(?object) && \n" +
PROPERTY_FILTERS + "\n" + PROPERTY_FILTERS + "\n" +
" ) \n" + " ) \n" +
"}"; "} ORDER BY ?property ?objType";
@Override @Override
public List<ObjectProperty> getObjectPropertyList(Individual subject) { public List<ObjectProperty> getObjectPropertyList(Individual subject) {
return getObjectPropertyList(subject.getURI()); return getObjectPropertyList(subject.getURI());
} }
// Returns a list of ObjectProperty objects for which statements exist about
// the individual. Note that this method now returns additional copies of
// a given predicate, with the rangeVClassURI changed to indicate the distinct
// types of the related objects. This supports finding the approriate list
// views for the "faux" qualified properties.
@Override @Override
public List<ObjectProperty> getObjectPropertyList(String subjectUri) { public List<ObjectProperty> getObjectPropertyList(String subjectUri) {
@ -954,15 +997,35 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
} }
log.debug("Object property query:\n" + query); log.debug("Object property query:\n" + query);
ResultSet results = getPropertyQueryResults(query); ObjectProperty propRegister = new ObjectProperty();
propRegister.setURI("");
ResultSet results = getPropertyQueryResults(queryString);
List<ObjectProperty> properties = new ArrayList<ObjectProperty>(); List<ObjectProperty> properties = new ArrayList<ObjectProperty>();
while (results.hasNext()) { while (results.hasNext()) {
QuerySolution soln = results.next(); QuerySolution soln = results.next();
Resource resource = soln.getResource("property"); Resource resource = soln.getResource("property");
String uri = resource.getURI(); String uri = resource.getURI();
log.debug("Found populated object property " + uri); Resource objType = soln.getResource("objType");
ObjectProperty property = getObjectPropertyByURI(uri); String objTypeUri = objType.getURI();
log.debug("Found populated object property " + uri +
" with object type " + objType);
ObjectProperty property = null;
if (uri.equals(propRegister.getURI())) {
property = propRegister.clone();
} else {
ObjectProperty newProperty = getObjectPropertyByURI(uri);
if (newProperty != null) {
propRegister = newProperty;
// add canonical instance of the property first in the list
// before the range-changed versions
properties.add(newProperty);
// isolate the canonical prop from what's about to happen next
property = newProperty.clone();
}
}
if (property != null) { if (property != null) {
property.setRangeVClassURI(objTypeUri);
properties.add(property); properties.add(property);
} }
} }
@ -998,12 +1061,15 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
// Map key is inner pair of object property and range class URI, // Map key is inner pair of object property and range class URI,
// with first member of outer pair being a domain class URI. // with first member of outer pair being a domain class URI.
// If domain or range is unspecified, OWL.Thing.getURI() is used in the key. // If domain or range is unspecified, OWL.Thing.getURI() is used in the key.
Map<Pair<String,Pair<ObjectProperty, String>>, String> customListViewConfigFileMap = null; Map<Pair<String,Pair<ObjectProperty, String>>, String> customListViewConfigFileMap;
@Override @Override
public String getCustomListViewConfigFileName(ObjectProperty op) { public String getCustomListViewConfigFileName(ObjectProperty op) {
if (customListViewConfigFileMap == null) { if (customListViewConfigFileMap == null) {
customListViewConfigFileMap = new HashMap<Pair<String,Pair<ObjectProperty, String>>, String>(); customListViewConfigFileMap = new HashMap<Pair<String,Pair<ObjectProperty, String>>, String>();
}
if (customListViewConfigFileMap.isEmpty()) {
long start = System.currentTimeMillis();
OntModel displayModel = getOntModelSelector().getDisplayModel(); OntModel displayModel = getOntModelSelector().getDisplayModel();
//Get all property to list view config file mappings in the system //Get all property to list view config file mappings in the system
QueryExecution qexec = QueryExecutionFactory.create(listViewConfigFileQuery, displayModel); QueryExecution qexec = QueryExecutionFactory.create(listViewConfigFileQuery, displayModel);
@ -1037,9 +1103,18 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
prop, rangeUri)), filename); prop, rangeUri)), filename);
} }
} }
// If there are no custom list views, put a bogus entry in the map
// to avoid further recomputation
if (customListViewConfigFileMap.isEmpty()) {
ObjectProperty bottom = new ObjectProperty();
bottom.setURI(OWL.NS + "bottomObjectProperty");
customListViewConfigFileMap.put(
new Pair<String,Pair<ObjectProperty,String>>(
null, new Pair<ObjectProperty, String>(
bottom, null)), "nothing");
}
qexec.close(); qexec.close();
} }
String customListViewConfigFileName = customListViewConfigFileMap.get(new Pair<String, Pair<ObjectProperty, String>>(op.getDomainVClassURI(), new Pair<ObjectProperty,String>(op, op.getRangeVClassURI()))); String customListViewConfigFileName = customListViewConfigFileMap.get(new Pair<String, Pair<ObjectProperty, String>>(op.getDomainVClassURI(), new Pair<ObjectProperty,String>(op, op.getRangeVClassURI())));
if (customListViewConfigFileName == null) { if (customListViewConfigFileName == null) {
log.debug("no list view found for " + op.getURI() + " qualified by range " + op.getRangeVClassURI() + " and domain " + op.getDomainVClassURI()); log.debug("no list view found for " + op.getURI() + " qualified by range " + op.getRangeVClassURI() + " and domain " + op.getDomainVClassURI());

View file

@ -11,7 +11,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -25,6 +24,7 @@ import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.QuerySolution; import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.QuerySolutionMap; import com.hp.hpl.jena.query.QuerySolutionMap;
import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.ResultSetFactory;
import com.hp.hpl.jena.query.Syntax; import com.hp.hpl.jena.query.Syntax;
import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.ModelFactory;
@ -35,6 +35,7 @@ import com.hp.hpl.jena.rdf.model.ResourceFactory;
import com.hp.hpl.jena.rdf.model.Statement; import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.rdf.model.StmtIterator; import com.hp.hpl.jena.rdf.model.StmtIterator;
import com.hp.hpl.jena.shared.Lock; import com.hp.hpl.jena.shared.Lock;
import com.hp.hpl.jena.sparql.resultset.ResultSetMem;
import com.hp.hpl.jena.util.iterator.ClosableIterator; import com.hp.hpl.jena.util.iterator.ClosableIterator;
import com.hp.hpl.jena.vocabulary.OWL; import com.hp.hpl.jena.vocabulary.OWL;
@ -46,6 +47,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.IndividualUpdateEvent; import edu.cornell.mannlib.vitro.webapp.dao.jena.event.IndividualUpdateEvent;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService; import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements ObjectPropertyStatementDao { public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements ObjectPropertyStatementDao {
@ -92,7 +94,8 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
else { else {
Map<String, ObjectProperty> uriToObjectProperty = new HashMap<String,ObjectProperty>(); Map<String, ObjectProperty> uriToObjectProperty = new HashMap<String,ObjectProperty>();
ObjectPropertyDaoJena opDaoJena = new ObjectPropertyDaoJena(dwf, getWebappDaoFactory()); ObjectPropertyDaoJena opDaoJena = (ObjectPropertyDaoJena) getWebappDaoFactory().getObjectPropertyDao();
//new ObjectPropertyDaoJena(rdfService, dwf, getWebappDaoFactory());
OntModel ontModel = getOntModelSelector().getABoxModel(); OntModel ontModel = getOntModelSelector().getABoxModel();
ontModel.enterCriticalSection(Lock.READ); ontModel.enterCriticalSection(Lock.READ);
@ -278,8 +281,13 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
Set<String> constructQueryStrings, Set<String> constructQueryStrings,
String sortDirection) { String sortDirection) {
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
long start = System.currentTimeMillis();
try {
Model constructedModel = constructModelForSelectQueries( Model constructedModel = constructModelForSelectQueries(
subjectUri, propertyUri, constructQueryStrings); subjectUri, propertyUri, rangeUri, constructQueryStrings);
if(log.isDebugEnabled()) { if(log.isDebugEnabled()) {
log.debug("Constructed model has " + constructedModel.size() + " statements."); log.debug("Constructed model has " + constructedModel.size() + " statements.");
@ -289,13 +297,59 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
queryString = queryString.replaceAll(" ASC\\(", " DESC("); queryString = queryString.replaceAll(" ASC\\(", " DESC(");
} }
ResultSet results = (constructedModel == null) ? selectFromRDFService(
queryString, subjectUri, propertyUri, domainUri, rangeUri) : selectFromConstructedModel(
queryString, subjectUri, propertyUri, domainUri, rangeUri, constructedModel);
while (results.hasNext()) {
QuerySolution soln = results.nextSolution();
RDFNode node = soln.get(objectKey);
if (node.isURIResource()) {
list.add(QueryUtils.querySolutionToStringValueMap(soln));
}
}
if(log.isDebugEnabled()) {
long duration = System.currentTimeMillis() - start;
log.debug(duration + " to do list view for " +
propertyUri + " / " + domainUri + " / " + rangeUri);
}
} catch (Exception e) {
log.error("Error getting object property values for subject " + subjectUri + " and property " + propertyUri, e);
return Collections.emptyList();
}
return list;
}
private ResultSet selectFromRDFService(String queryString, String subjectUri,
String propertyUri, String domainUri, String rangeUri) {
String[] part = queryString.split("[Ww][Hh][Ee][Rr][Ee]");
part[1] = part[1].replace("?subject", "<" + subjectUri + ">");
part[1] = part[1].replace("?property", "<" + propertyUri + ">");
if (domainUri != null && !domainUri.startsWith(VitroVocabulary.PSEUDO_BNODE_NS)) {
part[1] = part[1].replace("?subjectType", "<" + domainUri + ">");
}
if (rangeUri != null && !rangeUri.startsWith(VitroVocabulary.PSEUDO_BNODE_NS)) {
part[1] = part[1].replace("?objectType", "<" + rangeUri + ">");
}
queryString = part[0] + "WHERE" + part[1];
try {
return ResultSetFactory.fromJSON(
rdfService.sparqlSelectQuery(queryString, RDFService.ResultFormat.JSON));
} catch (RDFServiceException e) {
throw new RuntimeException(e);
}
}
private ResultSet selectFromConstructedModel(String queryString,
String subjectUri, String propertyUri, String domainUri, String rangeUri,
Model constructedModel) {
Query query = null; Query query = null;
try { try {
query = QueryFactory.create(queryString, Syntax.syntaxARQ); query = QueryFactory.create(queryString, Syntax.syntaxARQ);
} catch(Throwable th){ } catch(Throwable th){
log.error("Could not create SPARQL query for query string. " + th.getMessage()); log.error("Could not create SPARQL query for query string. " + th.getMessage());
log.error(queryString); log.error(queryString);
return Collections.emptyList(); throw new RuntimeException(th);
} }
QuerySolutionMap initialBindings = new QuerySolutionMap(); QuerySolutionMap initialBindings = new QuerySolutionMap();
@ -308,51 +362,30 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
initialBindings.add("objectType", ResourceFactory.createResource(rangeUri)); initialBindings.add("objectType", ResourceFactory.createResource(rangeUri));
} }
if(log.isDebugEnabled()) {
log.debug("Query string for object property " + propertyUri + ": " + queryString); log.debug("Query string for object property " + propertyUri + ": " + queryString);
}
// Run the SPARQL query to get the properties // Run the SPARQL query to get the properties
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
DatasetWrapper w = dwf.getDatasetWrapper();
Dataset dataset = w.getDataset();
dataset.getLock().enterCriticalSection(Lock.READ);
QueryExecution qexec = null; QueryExecution qexec = null;
try { try {
qexec = QueryExecutionFactory.create(
qexec = (constructedModel == null)
? QueryExecutionFactory.create(
query, dataset, initialBindings)
: QueryExecutionFactory.create(
query, constructedModel, initialBindings); query, constructedModel, initialBindings);
return new ResultSetMem(qexec.execSelect());
ResultSet results = qexec.execSelect();
while (results.hasNext()) {
QuerySolution soln = results.nextSolution();
RDFNode node = soln.get(objectKey);
if (node.isURIResource()) {
list.add(QueryUtils.querySolutionToStringValueMap(soln));
}
}
return list;
} catch (Exception e) {
log.error("Error getting object property values for subject " + subjectUri + " and property " + propertyUri);
return Collections.emptyList();
} finally { } finally {
dataset.getLock().leaveCriticalSection();
w.close();
if (qexec != null) { if (qexec != null) {
qexec.close(); qexec.close();
} }
} }
} }
private Model constructModelForSelectQueries(String subjectUri, private Model constructModelForSelectQueries(String subjectUri,
String propertyUri, String propertyUri,
String rangeUri,
Set<String> constructQueries) { Set<String> constructQueries) {
if (constructQueries == null) { if (constructQueries.size() == 0 || constructQueries == null) {
return null; return null;
} }
@ -362,24 +395,18 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
queryString = queryString.replace("?subject", "<" + subjectUri + ">"); queryString = queryString.replace("?subject", "<" + subjectUri + ">");
queryString = queryString.replace("?property", "<" + propertyUri + ">"); queryString = queryString.replace("?property", "<" + propertyUri + ">");
if (rangeUri != null) {
queryString = queryString.replace("?objectType", "<" + rangeUri + ">");
}
if (log.isDebugEnabled()) {
log.debug("CONSTRUCT query string for object property " + log.debug("CONSTRUCT query string for object property " +
propertyUri + ": " + queryString); propertyUri + ": " + queryString);
}
// we no longer need this query object, but we might want to do this
// query parse step to improve debugging, depending on the error returned
// through the RDF API
// try {
// QueryFactory.create(queryString, Syntax.syntaxARQ);
// } catch(Throwable th){
// log.error("Could not create CONSTRUCT SPARQL query for query " +
// "string. " + th.getMessage());
// log.error(queryString);
// return constructedModel;
// }
try { try {
//If RDFService is null, will do what code used to do before, otherwise employ rdfservice //If RDFService is null, will do what code used to do before,
//otherwise employ rdfservice
if(rdfService == null) { if(rdfService == null) {
log.debug("RDF Service null, Using CONSTRUCT query string for object property " + log.debug("RDF Service null, Using CONSTRUCT query string for object property " +
propertyUri + ": " + queryString); propertyUri + ": " + queryString);
@ -402,7 +429,8 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
query, dataset); query, dataset);
qe.execConstruct(constructedModel); qe.execConstruct(constructedModel);
} catch (Exception e) { } catch (Exception e) {
log.error("Error getting constructed model for subject " + subjectUri + " and property " + propertyUri); log.error("Error getting constructed model for subject "
+ subjectUri + " and property " + propertyUri);
} finally { } finally {
if (qe != null) { if (qe != null) {
qe.close(); qe.close();
@ -412,28 +440,31 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
} }
} else { } else {
String parseFormat = "N3"; String parseFormat = "N3";
RDFService.ModelSerializationFormat resultFormat = RDFService.ModelSerializationFormat.N3; RDFService.ModelSerializationFormat resultFormat = RDFService
.ModelSerializationFormat.N3;
/* If the test ObjectPropertyStatementDaoJenaTest.testN3WithSameAs() fails /* If the test ObjectPropertyStatementDaoJenaTest.testN3WithSameAs()
* this code can be removed: */ * fails this code can be removed: */
if( OWL.sameAs.getURI().equals( propertyUri )){ if( OWL.sameAs.getURI().equals( propertyUri )){
// VIVO-111: owl:sameAs can be represented as = in n3 but Jena's parser does not recognize it. // VIVO-111: owl:sameAs can be represented as = in n3 but
// Switch to rdf/xml only for sameAs since it seems like n3 would be faster the rest of the time. // Jena's parser does not recognize it.
// Switch to rdf/xml only for sameAs since it seems like n3
// would be faster the rest of the time.
parseFormat = "RDF/XML"; parseFormat = "RDF/XML";
resultFormat = RDFService.ModelSerializationFormat.RDFXML; resultFormat = RDFService.ModelSerializationFormat.RDFXML;
} }
/* end of removal */ /* end of removal */
InputStream is = rdfService.sparqlConstructQuery(queryString, resultFormat); InputStream is = rdfService.sparqlConstructQuery(
queryString, resultFormat);
constructedModel.read( is, null, parseFormat); constructedModel.read( is, null, parseFormat);
} }
} catch (Exception e) { } catch (Exception e) {
log.error("Error getting constructed model for subject " + subjectUri + " and property " + propertyUri, e); log.error("Error getting constructed model for subject "
+ subjectUri + " and property " + propertyUri, e);
} }
} }
return constructedModel; return constructedModel;
} }
protected static final String MOST_SPECIFIC_TYPE_QUERY = "" protected static final String MOST_SPECIFIC_TYPE_QUERY = ""

View file

@ -21,13 +21,13 @@ import com.hp.hpl.jena.ontology.OntClass;
import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntProperty; import com.hp.hpl.jena.ontology.OntProperty;
import com.hp.hpl.jena.ontology.Restriction; import com.hp.hpl.jena.ontology.Restriction;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.query.Query; import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution; import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory; import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory; import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.QuerySolution; import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.ResultSetFactory;
import com.hp.hpl.jena.query.Syntax; import com.hp.hpl.jena.query.Syntax;
import com.hp.hpl.jena.rdf.model.RDFNode; import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.rdf.model.Resource;
@ -36,7 +36,6 @@ import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.rdf.model.StmtIterator; import com.hp.hpl.jena.rdf.model.StmtIterator;
import com.hp.hpl.jena.sdb.util.Pair; import com.hp.hpl.jena.sdb.util.Pair;
import com.hp.hpl.jena.shared.Lock; import com.hp.hpl.jena.shared.Lock;
import com.hp.hpl.jena.sparql.resultset.ResultSetMem;
import com.hp.hpl.jena.vocabulary.OWL; import com.hp.hpl.jena.vocabulary.OWL;
import com.hp.hpl.jena.vocabulary.RDFS; import com.hp.hpl.jena.vocabulary.RDFS;
@ -45,10 +44,13 @@ import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.Property; import edu.cornell.mannlib.vitro.webapp.beans.Property;
import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstance; import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstance;
import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
import edu.cornell.mannlib.vitro.webapp.dao.PropertyDao; import edu.cornell.mannlib.vitro.webapp.dao.PropertyDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent; import edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
public class PropertyDaoJena extends JenaBaseDao implements PropertyDao { public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
@ -74,11 +76,14 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
log.debug("Query prefixes: " + PREFIXES); log.debug("Query prefixes: " + PREFIXES);
} }
protected RDFService rdfService;
protected DatasetWrapperFactory dwf; protected DatasetWrapperFactory dwf;
public PropertyDaoJena(DatasetWrapperFactory dwf, public PropertyDaoJena(RDFService rdfService,
DatasetWrapperFactory dwf,
WebappDaoFactoryJena wadf) { WebappDaoFactoryJena wadf) {
super(wadf); super(wadf);
this.rdfService = rdfService;
this.dwf = dwf; this.dwf = dwf;
} }
@ -87,6 +92,10 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
return getOntModelSelector().getTBoxModel(); return getOntModelSelector().getTBoxModel();
} }
protected RDFService getRDFService() {
return this.rdfService;
}
public void addSuperproperty(ObjectProperty property, ObjectProperty superproperty) { public void addSuperproperty(ObjectProperty property, ObjectProperty superproperty) {
addSuperproperty(property.getURI(),superproperty.getURI()); addSuperproperty(property.getURI(),superproperty.getURI());
} }
@ -414,8 +423,8 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
return classSet; return classSet;
} }
protected ResultSet getPropertyQueryResults(Query query) { protected ResultSet getPropertyQueryResults(String queryString) {
log.debug("SPARQL query:\n" + query.toString()); log.debug("SPARQL query:\n" + queryString);
// RY Removing prebinding due to Jena bug: when isLiteral(?object) or // RY Removing prebinding due to Jena bug: when isLiteral(?object) or
// isURI(?object) is added to the query as a filter, the query fails with prebinding // isURI(?object) is added to the query as a filter, the query fails with prebinding
@ -424,23 +433,32 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
//subjectBinding.add("subject", ResourceFactory.createResource(subjectUri)); //subjectBinding.add("subject", ResourceFactory.createResource(subjectUri));
// Run the SPARQL query to get the properties // Run the SPARQL query to get the properties
DatasetWrapper w = dwf.getDatasetWrapper();
Dataset dataset = w.getDataset();
dataset.getLock().enterCriticalSection(Lock.READ);
ResultSet rs = null;
try { try {
QueryExecution qexec = QueryExecutionFactory.create( return ResultSetFactory.fromJSON(
query, dataset); //, subjectBinding); getRDFService().sparqlSelectQuery(
try { queryString, RDFService.ResultFormat.JSON));
rs = new ResultSetMem(qexec.execSelect()); } catch (RDFServiceException e) {
} finally { throw new RuntimeException(e);
qexec.close();
} }
} finally {
dataset.getLock().leaveCriticalSection(); // DatasetWrapper w = dwf.getDatasetWrapper();
w.close(); // Dataset dataset = w.getDataset();
} // dataset.getLock().enterCriticalSection(Lock.READ);
return rs; // ResultSet rs = null;
// try {
// QueryExecution qexec = QueryExecutionFactory.create(
// query, dataset); //, subjectBinding);
// try {
// rs = new ResultSetMem(qexec.execSelect());
// } finally {
// qexec.close();
// }
// } finally {
// dataset.getLock().leaveCriticalSection();
// w.close();
// }
// return rs;
} }
/** /**
@ -577,19 +595,34 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
private void updatePropertyRangeMap(Map<String, Resource[]> map, private void updatePropertyRangeMap(Map<String, Resource[]> map,
String propURI, String propURI,
Resource[] ranges) { Resource[] ranges,
boolean replaceIfMoreSpecific) {
Resource[] existingRanges = map.get(propURI); Resource[] existingRanges = map.get(propURI);
if (existingRanges == null) { if (existingRanges == null) {
map.put(propURI, ranges); map.put(propURI, ranges);
} else if (existingRanges[0] == null && existingRanges[1] != null) { } else if (existingRanges[0] == null && existingRanges[1] != null) {
existingRanges[0] = ranges[0]; existingRanges[0] = ranges[0];
map.put(propURI, existingRanges); map.put(propURI, existingRanges);
} else if (existingRanges[0] != null && existingRanges[1] == null) { } else if (existingRanges[0] != null) {
if (existingRanges[1] == null) {
existingRanges[1] = ranges[1]; existingRanges[1] = ranges[1];
}
if (ranges[0] != null && moreSpecificThan(ranges[0], existingRanges[0])) {
existingRanges[0] = ranges[0];
}
map.put(propURI, existingRanges); map.put(propURI, existingRanges);
} }
} }
private boolean moreSpecificThan(Resource r1, Resource r2) {
if(r1.getURI() == null) {
return false;
} else if (r2.getURI() == null) {
return true;
}
return getWebappDaoFactory().getVClassDao().isSubClassOf(r1.getURI(), r2.getURI());
}
private List<OntClass> listSuperClasses(OntClass ontClass) { private List<OntClass> listSuperClasses(OntClass ontClass) {
return relatedClasses(ontClass, RDFS.subClassOf); return relatedClasses(ontClass, RDFS.subClassOf);
} }
@ -693,10 +726,11 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
Resource[] ranges = new Resource[2]; Resource[] ranges = new Resource[2];
if (rest.isAllValuesFromRestriction()) { if (rest.isAllValuesFromRestriction()) {
ranges[0] = (rest.asAllValuesFromRestriction()).getAllValuesFrom(); ranges[0] = (rest.asAllValuesFromRestriction()).getAllValuesFrom();
updatePropertyRangeMap(applicableProperties, onProperty.getURI(), ranges, true);
} else if (rest.isSomeValuesFromRestriction()) { } else if (rest.isSomeValuesFromRestriction()) {
ranges[1] = (rest.asSomeValuesFromRestriction()).getSomeValuesFrom(); ranges[1] = (rest.asSomeValuesFromRestriction()).getSomeValuesFrom();
updatePropertyRangeMap(applicableProperties, onProperty.getURI(), ranges, false);
} }
updatePropertyRangeMap(applicableProperties, onProperty.getURI(), ranges);
} }
} }
@ -718,7 +752,7 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
Resource[] ranges = new Resource[2]; Resource[] ranges = new Resource[2];
ranges[0] = rangeRes; ranges[0] = rangeRes;
updatePropertyRangeMap( updatePropertyRangeMap(
applicableProperties, prop.getURI(), ranges); applicableProperties, prop.getURI(), ranges, false);
} }
} }
@ -744,8 +778,7 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
? foundRanges[1] ? foundRanges[1]
: op.getRange(); : op.getRange();
Resource domainRes = op.getDomain(); Resource domainRes = op.getDomain();
propInsts.add(getPropInst( propInsts.add(getPropInst(op, domainRes, rangeRes));
op, domainRes, rangeRes, applicableProperties));
List<Pair<String,String>> additionalFauxSubpropertyDomainAndRangeURIs = List<Pair<String,String>> additionalFauxSubpropertyDomainAndRangeURIs =
getAdditionalFauxSubpropertyDomainAndRangeURIsForPropertyURI( getAdditionalFauxSubpropertyDomainAndRangeURIsForPropertyURI(
propertyURI); propertyURI);
@ -770,8 +803,8 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
propInsts.add(getPropInst( propInsts.add(getPropInst(
op, op,
ResourceFactory.createResource(domainAndRangeURIs.getLeft()), ResourceFactory.createResource(domainAndRangeURIs.getLeft()),
ResourceFactory.createResource(domainAndRangeURIs.getRight()), ResourceFactory.createResource(domainAndRangeURIs.getRight())
applicableProperties)); ));
} }
} }
} }
@ -781,12 +814,31 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
ontModel.leaveCriticalSection(); ontModel.leaveCriticalSection();
} }
// add any faux properties with applicable domain where the predicate URI
// is not already on the list
List<ObjectProperty> stragglers = getAdditionalFauxSubpropertiesForVClasses(
vclasses, propInsts);
for (ObjectProperty op : stragglers) {
propInsts.add(makePropInst(op));
}
return propInsts; return propInsts;
} }
private PropertyInstance getPropInst(OntProperty op, Resource domainRes, Resource rangeRes, private PropertyInstance makePropInst(ObjectProperty op) {
Map<String, Resource[]> applicableProperties) { PropertyInstance pi = new PropertyInstance();
pi.setDomainClassURI(op.getDomainVClassURI());
pi.setRangeClassURI(op.getRangeVClassURI());
pi.setSubjectSide(true);
pi.setPropertyURI(op.getURI());
pi.setPropertyName(op.getLabel());
pi.setDomainPublic(op.getDomainPublic());
return pi;
}
private PropertyInstance getPropInst(OntProperty op, Resource domainRes,
Resource rangeRes) {
if (log.isDebugEnabled() && domainRes != null && rangeRes != null) { if (log.isDebugEnabled() && domainRes != null && rangeRes != null) {
log.debug("getPropInst() op: " + op.getURI() + " domain: " + log.debug("getPropInst() op: " + op.getURI() + " domain: " +
domainRes.getURI() + " range: " + rangeRes.getURI()); domainRes.getURI() + " range: " + rangeRes.getURI());
@ -795,9 +847,9 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
String domainURIStr = (domainRes != null && !domainRes.isAnon()) ? String domainURIStr = (domainRes != null && !domainRes.isAnon()) ?
domainURIStr = domainRes.getURI() domainURIStr = domainRes.getURI()
: null; : null;
if (rangeRes == null) { // if (rangeRes == null) {
pi.setRangeClassURI(OWL.Thing.getURI()); // TODO see above // pi.setRangeClassURI(OWL.Thing.getURI()); // TODO see above
} else { if(rangeRes != null) {
String rangeClassURI; String rangeClassURI;
if (rangeRes.isAnon()) { if (rangeRes.isAnon()) {
rangeClassURI = PSEUDO_BNODE_NS + rangeRes.getId() rangeClassURI = PSEUDO_BNODE_NS + rangeRes.getId()
@ -834,6 +886,58 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
return pi; return pi;
} }
private List<ObjectProperty> getAdditionalFauxSubpropertiesForVClasses(
List<VClass> vclasses, List<PropertyInstance> propInsts) {
List<ObjectProperty> opList = new ArrayList<ObjectProperty>();
if (vclasses.size() == 0) {
return opList;
}
ObjectPropertyDao opDao = getWebappDaoFactory().getObjectPropertyDao();
String propQuery = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
"PREFIX config: <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#> \n" +
"PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> \n" +
"SELECT ?property ?domain ?range WHERE { \n" +
" ?context config:configContextFor ?property . \n" +
" ?context config:qualifiedByDomain ?domain . \n" +
" ?context config:qualifiedBy ?range . \n";
for(PropertyInstance propInst : propInsts) {
propQuery += " FILTER (?property != <" + propInst.getPropertyURI() + "> ) \n";
}
Iterator<VClass> classIt = vclasses.iterator();
if(classIt.hasNext()) {
propQuery += " FILTER ( \n";
propQuery += " (?domain = <" + OWL.Thing.getURI() + "> )\n";
while (classIt.hasNext()) {
VClass vclass = classIt.next();
if(vclass.isAnonymous()) {
continue;
}
propQuery += " || (?domain = <" + vclass.getURI() + "> ) \n";
}
propQuery += ") \n";
}
propQuery += "} \n";
log.debug(propQuery);
Query q = QueryFactory.create(propQuery);
QueryExecution qe = QueryExecutionFactory.create(
q, getOntModelSelector().getDisplayModel());
try {
ResultSet rs = qe.execSelect();
while (rs.hasNext()) {
QuerySolution qsoln = rs.nextSolution();
String propertyURI = qsoln.getResource("property").getURI();
String domainURI = qsoln.getResource("domain").getURI();
String rangeURI = qsoln.getResource("range").getURI();
opList.add(opDao.getObjectPropertyByURIs(
propertyURI, domainURI, rangeURI, null));
}
} finally {
qe.close();
}
return opList;
}
private List<Pair<String,String>> getAdditionalFauxSubpropertyDomainAndRangeURIsForPropertyURI(String propertyURI) { private List<Pair<String,String>> getAdditionalFauxSubpropertyDomainAndRangeURIsForPropertyURI(String propertyURI) {
List<Pair<String,String>> domainAndRangeURIs = new ArrayList<Pair<String,String>>(); List<Pair<String,String>> domainAndRangeURIs = new ArrayList<Pair<String,String>>();
String propQuery = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + String propQuery = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
@ -866,19 +970,5 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
return domainAndRangeURIs; return domainAndRangeURIs;
} }
private String getURIStr(Resource res) {
String URIStr;
if (res == null) {
URIStr = OWL.Thing.getURI(); // TODO: rdf:Resource if using RDF model; or option to turn off entirely
} else {
if (res.isAnon()) {
URIStr = PSEUDO_BNODE_NS+res.getId().toString();
} else {
URIStr = res.getURI();
}
}
return URIStr;
}
} }

View file

@ -29,11 +29,14 @@ import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao; import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao;
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.IndividualDeletionEvent; import edu.cornell.mannlib.vitro.webapp.dao.jena.event.IndividualDeletionEvent;
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.IndividualUpdateEvent; import edu.cornell.mannlib.vitro.webapp.dao.jena.event.IndividualUpdateEvent;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
public class PropertyInstanceDaoJena extends PropertyDaoJena implements public class PropertyInstanceDaoJena extends PropertyDaoJena implements
PropertyInstanceDao { PropertyInstanceDao {
public PropertyInstanceDaoJena(DatasetWrapperFactory dwf, WebappDaoFactoryJena wadf) { public PropertyInstanceDaoJena(RDFService rdfService,
super(dwf, wadf); DatasetWrapperFactory dwf,
WebappDaoFactoryJena wadf) {
super(rdfService, dwf, wadf);
} }
public void deleteObjectPropertyStatement(String subjectURI, String propertyURI, String objectURI) { public void deleteObjectPropertyStatement(String subjectURI, String propertyURI, String objectURI) {
@ -59,7 +62,6 @@ public class PropertyInstanceDaoJena extends PropertyDaoJena implements
baseModel.notifyEvent(new IndividualUpdateEvent(userUri,true,subjectURI)); baseModel.notifyEvent(new IndividualUpdateEvent(userUri,true,subjectURI));
try { try {
ontModel.remove(subjRes,pred,objRes); ontModel.remove(subjRes,pred,objRes);
updatePropertyDateTimeValue(subjRes,MODTIME,Calendar.getInstance().getTime(),ontModel);
} finally { } finally {
baseModel.notifyEvent(new IndividualUpdateEvent(userUri,false,subjectURI)); baseModel.notifyEvent(new IndividualUpdateEvent(userUri,false,subjectURI));
} }
@ -75,7 +77,6 @@ public class PropertyInstanceDaoJena extends PropertyDaoJena implements
baseModel.notifyEvent(new IndividualUpdateEvent(userUri,true,objectURI)); baseModel.notifyEvent(new IndividualUpdateEvent(userUri,true,objectURI));
try { try {
ontModel.remove(objRes,invPred,subjRes); ontModel.remove(objRes,invPred,subjRes);
updatePropertyDateTimeValue(objRes,MODTIME,Calendar.getInstance().getTime(),ontModel);
} finally { } finally {
baseModel.notifyEvent(new IndividualUpdateEvent(userUri,false,subjectURI)); baseModel.notifyEvent(new IndividualUpdateEvent(userUri,false,subjectURI));
} }
@ -212,7 +213,6 @@ public class PropertyInstanceDaoJena extends PropertyDaoJena implements
getOntModel().getBaseModel().notifyEvent(new IndividualUpdateEvent(getWebappDaoFactory().getUserURI(),true,prop.getSubjectEntURI())); getOntModel().getBaseModel().notifyEvent(new IndividualUpdateEvent(getWebappDaoFactory().getUserURI(),true,prop.getSubjectEntURI()));
try { try {
ontModel.add(subjRes,pred,objRes); ontModel.add(subjRes,pred,objRes);
updatePropertyDateTimeValue(subjRes,MODTIME,Calendar.getInstance().getTime(),getOntModel());
} finally { } finally {
getOntModel().getBaseModel().notifyEvent(new IndividualUpdateEvent(getWebappDaoFactory().getUserURI(),false,prop.getSubjectEntURI())); getOntModel().getBaseModel().notifyEvent(new IndividualUpdateEvent(getWebappDaoFactory().getUserURI(),false,prop.getSubjectEntURI()));
} }
@ -221,7 +221,6 @@ public class PropertyInstanceDaoJena extends PropertyDaoJena implements
getOntModel().getBaseModel().notifyEvent(new IndividualUpdateEvent(getWebappDaoFactory().getUserURI(),true,prop.getObjectEntURI())); getOntModel().getBaseModel().notifyEvent(new IndividualUpdateEvent(getWebappDaoFactory().getUserURI(),true,prop.getObjectEntURI()));
try { try {
ontModel.add(objRes,invPred,subjRes); ontModel.add(objRes,invPred,subjRes);
updatePropertyDateTimeValue(objRes,MODTIME,Calendar.getInstance().getTime(),getOntModel());
} finally { } finally {
getOntModel().getBaseModel().notifyEvent(new IndividualUpdateEvent(getWebappDaoFactory().getUserURI(),false,prop.getSubjectEntURI())); getOntModel().getBaseModel().notifyEvent(new IndividualUpdateEvent(getWebappDaoFactory().getUserURI(),false,prop.getSubjectEntURI()));
} }

View file

@ -9,18 +9,16 @@ import java.util.Map;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QuerySolution; import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.ResultSetFactory;
import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.RDFNode; import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.shared.Lock;
import com.hp.hpl.jena.sparql.resultset.ResultSetMem;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
/** /**
* Utilities for executing queries and working with query results. * Utilities for executing queries and working with query results.
@ -115,31 +113,21 @@ public class QueryUtils {
} }
public static ResultSet getQueryResults(String queryStr, VitroRequest vreq) { public static ResultSet getQueryResults(String queryStr, VitroRequest vreq) {
return getQueryResults(queryStr, vreq.getDataset()); return getQueryResults(queryStr, vreq.getRDFService());
} }
public static ResultSet getLanguageNeutralQueryResults(String queryStr, VitroRequest vreq) { public static ResultSet getLanguageNeutralQueryResults(String queryStr, VitroRequest vreq) {
return getQueryResults(queryStr, vreq.getUnfilteredDataset()); return getQueryResults(queryStr, vreq.getUnfilteredRDFService());
} }
/** Already have the dataset, so process the query and return the results. */ /** Already have the dataset, so process the query and return the results. */
private static ResultSet getQueryResults(String queryStr, Dataset dataset) { private static ResultSet getQueryResults(String queryStr, RDFService rdfService) {
dataset.getLock().enterCriticalSection(Lock.READ);
QueryExecution qexec = null;
ResultSet results = null;
try { try {
qexec = QueryExecutionFactory.create(queryStr, dataset); return ResultSetFactory.fromJSON(
results = new ResultSetMem(qexec.execSelect()); rdfService.sparqlSelectQuery(queryStr, RDFService.ResultFormat.JSON));
} catch (Exception e) { } catch (RDFServiceException e) {
log.error(e, e); throw new RuntimeException(e);
} finally {
dataset.getLock().leaveCriticalSection();
if (qexec != null) {
qexec.close();
} }
} }
return results;
}
} }

View file

@ -50,6 +50,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig;
import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.PelletListener; import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.PelletListener;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService; import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel;
import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase; import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase;
import edu.cornell.mannlib.vitro.webapp.utils.jena.URIUtils; import edu.cornell.mannlib.vitro.webapp.utils.jena.URIUtils;
@ -109,6 +110,8 @@ public class WebappDaoFactoryJena implements WebappDaoFactory {
Dataset dataset = makeInMemoryDataset(assertions, inferences); Dataset dataset = makeInMemoryDataset(assertions, inferences);
this.dwf = new StaticDatasetFactory(dataset); this.dwf = new StaticDatasetFactory(dataset);
this.rdfService = new RDFServiceModel(ontModelSelector.getFullModel());
} }
public WebappDaoFactoryJena(OntModelSelector ontModelSelector, public WebappDaoFactoryJena(OntModelSelector ontModelSelector,
@ -327,7 +330,7 @@ public class WebappDaoFactoryJena implements WebappDaoFactory {
DataPropertyDao dataPropertyDao = null; DataPropertyDao dataPropertyDao = null;
public DataPropertyDao getDataPropertyDao() { public DataPropertyDao getDataPropertyDao() {
if( dataPropertyDao == null ) if( dataPropertyDao == null )
dataPropertyDao = new DataPropertyDaoJena(dwf, this); dataPropertyDao = new DataPropertyDaoJena(rdfService, dwf, this);
return dataPropertyDao; return dataPropertyDao;
} }
@ -358,14 +361,15 @@ public class WebappDaoFactoryJena implements WebappDaoFactory {
private ObjectPropertyDao objectPropertyDao = null; private ObjectPropertyDao objectPropertyDao = null;
public ObjectPropertyDao getObjectPropertyDao() { public ObjectPropertyDao getObjectPropertyDao() {
if( objectPropertyDao == null ) if( objectPropertyDao == null )
objectPropertyDao = new ObjectPropertyDaoJena(dwf, this); objectPropertyDao = new ObjectPropertyDaoJena(
rdfService, dwf, config.customListViewConfigFileMap, this);
return objectPropertyDao; return objectPropertyDao;
} }
private PropertyInstanceDao propertyInstanceDao = null; private PropertyInstanceDao propertyInstanceDao = null;
public PropertyInstanceDao getPropertyInstanceDao() { public PropertyInstanceDao getPropertyInstanceDao() {
if( propertyInstanceDao == null ) if( propertyInstanceDao == null )
propertyInstanceDao = new PropertyInstanceDaoJena(dwf, this); propertyInstanceDao = new PropertyInstanceDaoJena(rdfService, dwf, this);
return propertyInstanceDao; return propertyInstanceDao;
} }

View file

@ -105,10 +105,7 @@ public class EditConfigurationUtils {
public static ObjectProperty getObjectProperty(VitroRequest vreq) { public static ObjectProperty getObjectProperty(VitroRequest vreq) {
//gets the predicate uri from the request return getObjectPropertyForPredicate(vreq, getPredicateUri(vreq));
String predicateUri = getPredicateUri(vreq);
String rangeUri = getRangeUri(vreq);
return getObjectPropertyForPredicate(vreq, predicateUri, rangeUri);
} }
public static DataProperty getDataProperty(VitroRequest vreq) { public static DataProperty getDataProperty(VitroRequest vreq) {
@ -116,17 +113,18 @@ public class EditConfigurationUtils {
return getDataPropertyForPredicate(vreq, predicateUri); return getDataPropertyForPredicate(vreq, predicateUri);
} }
public static ObjectProperty getObjectPropertyForPredicate(VitroRequest vreq, String predicateUri) { public static ObjectProperty getObjectPropertyForPredicate(VitroRequest vreq,
return getObjectPropertyForPredicate(vreq, predicateUri, null); String predicateUri) {
String domainUri = getDomainUri(vreq);
String rangeUri = getRangeUri(vreq);
return getObjectPropertyForPredicate(vreq, predicateUri, domainUri, rangeUri);
} }
public static ObjectProperty getObjectPropertyForPredicate(VitroRequest vreq, String predicateUri, String rangeUri) { public static ObjectProperty getObjectPropertyForPredicate(VitroRequest vreq,
String predicateUri, String domainUri, String rangeUri) {
WebappDaoFactory wdf = vreq.getWebappDaoFactory(); WebappDaoFactory wdf = vreq.getWebappDaoFactory();
ObjectProperty objectProp = wdf.getObjectPropertyDao().getObjectPropertyByURI(predicateUri); ObjectProperty objectProp = wdf.getObjectPropertyDao().getObjectPropertyByURIs(
if (rangeUri != null) { predicateUri, domainUri, rangeUri);
objectProp.setRangeVClassURI(rangeUri);
// TODO implement this in the DAO?
}
return objectProp; return objectProp;
} }

View file

@ -19,6 +19,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.utils.fields.FieldUtils;
public class IndividualsViaObjectPropetyOptions implements FieldOptions { public class IndividualsViaObjectPropetyOptions implements FieldOptions {
@ -100,7 +101,7 @@ public class IndividualsViaObjectPropetyOptions implements FieldOptions {
List<ObjectPropertyStatement> stmts = subject.getObjectPropertyStatements(); List<ObjectPropertyStatement> stmts = subject.getObjectPropertyStatements();
individuals = removeIndividualsAlreadyInRange( individuals = FieldUtils.removeIndividualsAlreadyInRange(
individuals, stmts, predicateUri, objectUri); individuals, stmts, predicateUri, objectUri);
// Collections.sort(individuals,new compareIndividualsByName());a // Collections.sort(individuals,new compareIndividualsByName());a
@ -162,28 +163,7 @@ public class IndividualsViaObjectPropetyOptions implements FieldOptions {
return filteredVClassesURIs; return filteredVClassesURIs;
} }
// copied from OptionsForPropertyTag.java in the thought that class may be deprecated
private static List<Individual> removeIndividualsAlreadyInRange(List<Individual> individuals,
List<ObjectPropertyStatement> stmts, String predicateUri, String objectUriBeingEdited){
HashSet<String> range = new HashSet<String>();
for(ObjectPropertyStatement ops : stmts){
if( ops.getPropertyURI().equals(predicateUri))
range.add( ops.getObjectURI() );
}
int removeCount=0;
ListIterator<Individual> it = individuals.listIterator();
while(it.hasNext()){
Individual ind = it.next();
if( range.contains( ind.getURI()) && !(ind.getURI().equals(objectUriBeingEdited)) ) {
it.remove();
++removeCount;
}
}
return individuals;
}
public Comparator<String[]> getCustomComparator() { public Comparator<String[]> getCustomComparator() {
return null; return null;

View file

@ -0,0 +1,154 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import javax.servlet.ServletContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
import edu.cornell.mannlib.vitro.webapp.search.solr.SolrSetup;
import edu.cornell.mannlib.vitro.webapp.utils.fields.FieldUtils;
/*
* This runs a solr query to get individuals of a certain class instead of relying on the dao classes.
* Also it gets individuals that belong to the most specific type(s) specified.
*/
public class IndividualsViaSolrQueryOptions extends IndividualsViaVClassOptions implements FieldOptions {
private Log log = LogFactory.getLog(IndividualsViaSolrQueryOptions.class);
private ServletContext servletContext;
private String subjectUri;
private String predicateUri;
private String objectUri;
public IndividualsViaSolrQueryOptions(ServletContext context, String inputSubjectUri, String inputPredicateUri, String inputObjectUri, String ... vclassURIs) throws Exception {
super(vclassURIs);
this.servletContext = context;
this.subjectUri = inputSubjectUri;
this.predicateUri = inputPredicateUri;
this.objectUri = inputObjectUri;
}
@Override
protected Map<String,Individual> getIndividualsForClass(String vclassURI, WebappDaoFactory wDaoFact ){
Map<String, Individual> individualMap = new HashMap<String, Individual>();
try {
SolrServer solrServer = SolrSetup.getSolrServer(servletContext);
//solr query for type count.
SolrQuery query = new SolrQuery();
if( VitroVocabulary.OWL_THING.equals( vclassURI )){
query.setQuery( "*:*" );
}else{
query.setQuery( VitroSearchTermNames.MOST_SPECIFIC_TYPE_URIS + ":" + vclassURI);
}
query.setStart(0)
.setRows(1000);
query.setFields(VitroSearchTermNames.URI); // fields to retrieve
QueryResponse rsp = solrServer.query(query);
SolrDocumentList docs = rsp.getResults();
long found = docs.getNumFound();
if(found > 0) {
for (SolrDocument doc : docs) {
try {
String uri = doc.get(VitroSearchTermNames.URI).toString();
Individual individual = wDaoFact.getIndividualDao().getIndividualByURI(uri);
if (individual == null) {
log.debug("No individual for search document with uri = " + uri);
} else {
individualMap.put(individual.getURI(), individual);
log.debug("Adding individual " + uri + " to individual list");
}
}
catch(Exception ex) {
log.error("An error occurred retrieving the individual solr query resutls", ex);
}
}
}
} catch(Exception ex) {
log.error("Error occurred in executing solr query ", ex);
}
return individualMap;
}
@Override
public Map<String, String> getOptions(
EditConfigurationVTwo editConfig,
String fieldName,
WebappDaoFactory wDaoFact) throws Exception {
Map<String, Individual> individualMap = new HashMap<String, Individual>();
for( String vclassURI : vclassURIs){
individualMap.putAll( getIndividualsForClass( vclassURI, wDaoFact) );
}
//sort the individuals
List<Individual> individuals = new ArrayList<Individual>();
individuals.addAll(individualMap.values());
//Here we will remove individuals already in the range
Individual subject = wDaoFact.getIndividualDao().getIndividualByURI(subjectUri);
List<ObjectPropertyStatement> stmts = subject.getObjectPropertyStatements();
individuals = FieldUtils.removeIndividualsAlreadyInRange(
individuals, stmts, predicateUri, objectUri);
//Also remove subjectUri if it
individuals = removeSubjectUri(individuals, subjectUri);
//sort the list
Collections.sort(individuals);
//set up the options map
Map<String, String> optionsMap = new HashMap<String,String>();
if (defaultOptionLabel != null) {
optionsMap.put(LEFT_BLANK, defaultOptionLabel);
}
if (individuals.size() == 0) {
//return empty map, unlike individualsViaVclass
return optionsMap ;
} else {
for (Individual ind : individuals) {
if (ind.getURI() != null) {
optionsMap.put(ind.getURI(), ind.getName().trim());
}
}
}
return optionsMap;
}
//TODO: Check if this can be done simply by reference
private List<Individual> removeSubjectUri(List<Individual> individuals,
String subjectUri) {
ListIterator<Individual> it = individuals.listIterator();
while(it.hasNext()){
Individual ind = it.next();
if( ind.getURI().equals(subjectUri)) {
it.remove();
}
}
return individuals;
}
}

View file

@ -18,8 +18,8 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTw
public class IndividualsViaVClassOptions implements FieldOptions { public class IndividualsViaVClassOptions implements FieldOptions {
public static final String LEFT_BLANK = ""; public static final String LEFT_BLANK = "";
private List<String> vclassURIs; protected List<String> vclassURIs;
private String defaultOptionLabel; protected String defaultOptionLabel;
public IndividualsViaVClassOptions(String ... vclassURIs) throws Exception { public IndividualsViaVClassOptions(String ... vclassURIs) throws Exception {
super(); super();

View file

@ -126,6 +126,7 @@ public class DateTimeValueFormGenerator extends BaseEditConfigurationGenerator
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) { public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
HashMap<String, Object> formSpecificData = new HashMap<String, Object>(); HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
formSpecificData.put("editMode", getEditMode(vreq).name().toLowerCase()); formSpecificData.put("editMode", getEditMode(vreq).name().toLowerCase());
formSpecificData.put("domainUri", getDomainUri(vreq));
editConfiguration.setFormSpecificData(formSpecificData); editConfiguration.setFormSpecificData(formSpecificData);
} }
@ -140,4 +141,10 @@ public class DateTimeValueFormGenerator extends BaseEditConfigurationGenerator
} }
return editMode; return editMode;
} }
private String getDomainUri(VitroRequest vreq) {
String domainUri = vreq.getParameter("domainUri");
return domainUri;
}
} }

View file

@ -145,15 +145,15 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
SolrServer solrServer = SolrSetup.getSolrServer(session.getServletContext()); SolrServer solrServer = SolrSetup.getSolrServer(session.getServletContext());
List<String> types = new ArrayList<String>(); List<String> types = new ArrayList<String>();
//empty list means the range is not set to anything, force Thing
if(types.size() == 0 ){
types.add(VitroVocabulary.OWL_THING);
} else {
for (VClass vclass : rangeTypes) { for (VClass vclass : rangeTypes) {
if (vclass.getURI() != null) { if (vclass.getURI() != null) {
types.add(vclass.getURI()); types.add(vclass.getURI());
} }
} }
//empty list means the range is not set to anything, force Thing
if(types.size() == 0 ){
types.add(VitroVocabulary.OWL_THING);
} }
long count = 0; long count = 0;

View file

@ -1,6 +1,10 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */ /* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators; package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants.SOME_LITERAL;
import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants.SOME_PREDICATE;
import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants.SOME_URI;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -24,14 +28,12 @@ import com.hp.hpl.jena.vocabulary.RDFS;
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper; import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddDataPropertyStatement; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddDataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddObjectPropertyStatement; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.Property; import edu.cornell.mannlib.vitro.webapp.beans.Property;
import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils; import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils; 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.EditConfigurationVTwo;
@ -271,11 +273,10 @@ public class ManageLabelsForIndividualGenerator extends BaseEditConfigurationGen
Individual individual = EditConfigurationUtils.getIndividual(vreq, config.getSubjectUri()); Individual individual = EditConfigurationUtils.getIndividual(vreq, config.getSubjectUri());
AddDataPropertyStatement adps = new AddDataPropertyStatement( AddDataPropertyStatement adps = new AddDataPropertyStatement(
vreq.getJenaOntModel(), individual.getURI(), vreq.getJenaOntModel(), individual.getURI(),
RequestActionConstants.SOME_URI); SOME_URI, SOME_LITERAL);
AddObjectPropertyStatement aops = new AddObjectPropertyStatement( AddObjectPropertyStatement aops = new AddObjectPropertyStatement(
vreq.getJenaOntModel(), individual.getURI(), vreq.getJenaOntModel(), individual.getURI(),
RequestActionConstants.SOME_PREDICATE, SOME_PREDICATE, SOME_URI);
RequestActionConstants.SOME_URI);
return PolicyHelper.isAuthorizedForActions(vreq, new Actions(adps).or(aops)); return PolicyHelper.isAuthorizedForActions(vreq, new Actions(adps).or(aops));
} }

View file

@ -164,7 +164,9 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
//edit key is set here, NOT in the generator class //edit key is set here, NOT in the generator class
EditConfigurationVTwo editConfig = null; EditConfigurationVTwo editConfig = null;
EditConfigurationVTwo existingConfig = EditConfigurationVTwo.getConfigFromSession(session, vreq); EditConfigurationVTwo existingConfig = EditConfigurationVTwo.getConfigFromSession(session, vreq);
if(existingConfig != null) { //if delete form from the editing page, then edit configuration already exists and the
//delete generator wouldn't be used, we need to make sure that it is used if it's a delete option
if(existingConfig != null && !isDeleteForm(vreq)) {
editConfig = existingConfig; editConfig = existingConfig;
} else { } else {
editConfig = editConfig =

View file

@ -55,6 +55,15 @@ public class PostEditCleanupController extends FreemarkerHttpServlet{
return new RedirectResponseValues( UrlBuilder.getHomeUrl() ); return new RedirectResponseValues( UrlBuilder.getHomeUrl() );
} }
//In some cases, a generator/form may have a regular URL to return to but the same generator
//may be used from different pages, so a parameter allowing the form to return to a specific page
//would be useful
String returnURLParameter = vreq.getParameter("returnURL");
if(returnURLParameter != null) {
return new DirectRedirectResponseValues( returnURLParameter );
}
// If there is a urlToReturnTo that takes precedence // If there is a urlToReturnTo that takes precedence
if( editConfig.getUrlToReturnTo() != null && ! editConfig.getUrlToReturnTo().trim().isEmpty()){ if( editConfig.getUrlToReturnTo() != null && ! editConfig.getUrlToReturnTo().trim().isEmpty()){
//this does not get value substitution or the predicate anchor //this does not get value substitution or the predicate anchor

View file

@ -10,6 +10,8 @@ import java.text.Collator;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import javax.servlet.Filter; import javax.servlet.Filter;
@ -24,6 +26,7 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.openjena.atlas.lib.Pair;
import com.hp.hpl.jena.graph.BulkUpdateHandler; import com.hp.hpl.jena.graph.BulkUpdateHandler;
import com.hp.hpl.jena.graph.Graph; import com.hp.hpl.jena.graph.Graph;
@ -35,6 +38,7 @@ import com.hp.hpl.jena.rdf.model.ModelFactory;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.RequestIdentifiers; import edu.cornell.mannlib.vitro.webapp.auth.identifier.RequestIdentifiers;
import edu.cornell.mannlib.vitro.webapp.auth.policy.ServletPolicyList; import edu.cornell.mannlib.vitro.webapp.auth.policy.ServletPolicyList;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet; import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
@ -311,6 +315,8 @@ public class RequestModelsPrep implements Filter {
config.setDefaultNamespace(defaultNamespace); config.setDefaultNamespace(defaultNamespace);
config.setPreferredLanguages(langs); config.setPreferredLanguages(langs);
config.setUnderlyingStoreReasoned(isStoreReasoned(req)); config.setUnderlyingStoreReasoned(isStoreReasoned(req));
config.setCustomListViewConfigFileMap(getCustomListViewConfigFileMap(
req.getSession().getServletContext()));
return config; return config;
} }
@ -366,6 +372,18 @@ public class RequestModelsPrep implements Filter {
return ("true".equals(isStoreReasoned)); return ("true".equals(isStoreReasoned));
} }
private Map<Pair<String,Pair<ObjectProperty, String>>, String>
getCustomListViewConfigFileMap(ServletContext ctx) {
Map<Pair<String,Pair<ObjectProperty, String>>, String> map =
(Map<Pair<String,Pair<ObjectProperty, String>>, String>)
ctx.getAttribute("customListViewConfigFileMap");
if (map == null) {
map = new ConcurrentHashMap<Pair<String,Pair<ObjectProperty, String>>, String>();
ctx.setAttribute("customListViewConfigFileMap", map);
}
return map;
}
@Override @Override
public void destroy() { public void destroy() {
// Nothing to destroy // Nothing to destroy

View file

@ -31,6 +31,8 @@ import com.hp.hpl.jena.vocabulary.RDF;
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceDataset; import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceDataset;
import edu.cornell.mannlib.vitro.webapp.ontology.update.AtomicOntologyChange.AtomicChangeType; import edu.cornell.mannlib.vitro.webapp.ontology.update.AtomicOntologyChange.AtomicChangeType;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService; import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
/** /**
* Performs knowledge base updates to the abox to align with a new ontology version * Performs knowledge base updates to the abox to align with a new ontology version
@ -594,6 +596,7 @@ public class ABoxUpdater {
return; return;
} }
long start = System.currentTimeMillis();
Iterator<String> graphIt = dataset.listNames(); Iterator<String> graphIt = dataset.listNames();
while(graphIt.hasNext()) { while(graphIt.hasNext()) {
String graph = graphIt.next(); String graph = graphIt.next();
@ -604,11 +607,23 @@ public class ABoxUpdater {
Model renamePropAddModel = ModelFactory.createDefaultModel(); Model renamePropAddModel = ModelFactory.createDefaultModel();
Model renamePropRetractModel = ModelFactory.createDefaultModel(); Model renamePropRetractModel = ModelFactory.createDefaultModel();
log.debug("renaming " + oldProperty.getURI() + " in graph " + graph);
aboxModel.enterCriticalSection(Lock.WRITE); aboxModel.enterCriticalSection(Lock.WRITE);
try { try {
start = System.currentTimeMillis();
// String queryStr = "CONSTRUCT { ?s <" + oldProperty.getURI() + "> ?o } WHERE { GRAPH<" + graph + "> { ?s <" + oldProperty.getURI() + "> ?o } } ";
// try {
// renamePropRetractModel = RDFServiceUtils.parseModel(rdfService.sparqlConstructQuery(queryStr, RDFService.ModelSerializationFormat.NTRIPLE), RDFService.ModelSerializationFormat.NTRIPLE);
// } catch (RDFServiceException e) {
// log.error(e,e);
// }
// log.info(System.currentTimeMillis() - start + " to run sparql construct for " + renamePropRetractModel.size() + " statements" );
start = System.currentTimeMillis();
renamePropRetractModel.add( aboxModel.listStatements( renamePropRetractModel.add( aboxModel.listStatements(
(Resource) null, oldProperty, (RDFNode) null)); (Resource) null, oldProperty, (RDFNode) null));
log.debug(System.currentTimeMillis() - start + " to list " + renamePropRetractModel.size() + " old statements");
start = System.currentTimeMillis();
StmtIterator stmItr = renamePropRetractModel.listStatements(); StmtIterator stmItr = renamePropRetractModel.listStatements();
while(stmItr.hasNext()) { while(stmItr.hasNext()) {
Statement tempStatement = stmItr.nextStatement(); Statement tempStatement = stmItr.nextStatement();
@ -616,8 +631,13 @@ public class ABoxUpdater {
newProperty, newProperty,
tempStatement.getObject() ); tempStatement.getObject() );
} }
log.debug(System.currentTimeMillis() - start + " to make new statements");
start = System.currentTimeMillis();
aboxModel.remove(renamePropRetractModel); aboxModel.remove(renamePropRetractModel);
log.debug(System.currentTimeMillis() - start + " to retract old statements");
start = System.currentTimeMillis();
aboxModel.add(renamePropAddModel); aboxModel.add(renamePropAddModel);
log.debug(System.currentTimeMillis() - start + " to add new statements");
} finally { } finally {
aboxModel.leaveCriticalSection(); aboxModel.leaveCriticalSection();
} }

View file

@ -83,7 +83,7 @@ public class KnowledgeBaseUpdater {
logger.closeLogs(); logger.closeLogs();
long elapsedSecs = (System.currentTimeMillis() - startTime)/1000; long elapsedSecs = (System.currentTimeMillis() - startTime)/1000;
log.info("Finished knowledge base migration in " + elapsedSecs + " second" + (elapsedSecs != 1 ? "s" : "")); log.info("Finished checking knowledge base in " + elapsedSecs + " second" + (elapsedSecs != 1 ? "s" : ""));
return record.hasRecordedChanges(); return record.hasRecordedChanges();
} }
@ -95,20 +95,20 @@ public class KnowledgeBaseUpdater {
AtomicOntologyChangeLists changes = new AtomicOntologyChangeLists(rawChanges,settings.getNewTBoxModel(),settings.getOldTBoxModel()); AtomicOntologyChangeLists changes = new AtomicOntologyChangeLists(rawChanges,settings.getNewTBoxModel(),settings.getOldTBoxModel());
// update ABox data any time // update ABox data any time
log.info("performing SPARQL CONSTRUCT additions"); log.debug("performing SPARQL CONSTRUCT additions");
performSparqlConstructs(settings.getSparqlConstructAdditionsDir(), settings.getRDFService(), ADD); performSparqlConstructs(settings.getSparqlConstructAdditionsDir(), settings.getRDFService(), ADD);
log.info("performing SPARQL CONSTRUCT retractions"); log.debug("performing SPARQL CONSTRUCT retractions");
performSparqlConstructs(settings.getSparqlConstructDeletionsDir(), settings.getRDFService(), RETRACT); performSparqlConstructs(settings.getSparqlConstructDeletionsDir(), settings.getRDFService(), RETRACT);
log.info("\tupdating the abox"); log.info("\tchecking the abox");
updateABox(changes); updateABox(changes);
log.info("performing post-processing SPARQL CONSTRUCT additions"); log.debug("performing post-processing SPARQL CONSTRUCT additions");
performSparqlConstructs(settings.getSparqlConstructAdditionsDir() + "/post/", performSparqlConstructs(settings.getSparqlConstructAdditionsDir() + "/post/",
settings.getRDFService(), ADD); settings.getRDFService(), ADD);
log.info("performing post-processing SPARQL CONSTRUCT retractions"); log.debug("performing post-processing SPARQL CONSTRUCT retractions");
performSparqlConstructs(settings.getSparqlConstructDeletionsDir() + "/post/", performSparqlConstructs(settings.getSparqlConstructDeletionsDir() + "/post/",
settings.getRDFService(), RETRACT); settings.getRDFService(), RETRACT);
@ -145,7 +145,7 @@ public class KnowledgeBaseUpdater {
boolean add) throws IOException { boolean add) throws IOException {
Dataset dataset = new RDFServiceDataset(rdfService); Dataset dataset = new RDFServiceDataset(rdfService);
File sparqlConstructDirectory = new File(sparqlConstructDir); File sparqlConstructDirectory = new File(sparqlConstructDir);
log.info("Using SPARQL CONSTRUCT directory " + sparqlConstructDirectory); log.debug("Using SPARQL CONSTRUCT directory " + sparqlConstructDirectory);
if (!sparqlConstructDirectory.isDirectory()) { if (!sparqlConstructDirectory.isDirectory()) {
String logMsg = this.getClass().getName() + String logMsg = this.getClass().getName() +
"performSparqlConstructs() expected to find a directory " + "performSparqlConstructs() expected to find a directory " +
@ -178,7 +178,7 @@ public class KnowledgeBaseUpdater {
} }
Model anonModel = ModelFactory.createDefaultModel(); Model anonModel = ModelFactory.createDefaultModel();
try { try {
log.info("\t\tprocessing SPARQL construct query from file " + sparqlFile.getName()); log.debug("\t\tprocessing SPARQL construct query from file " + sparqlFile.getName());
anonModel = RDFServiceUtils.parseModel( anonModel = RDFServiceUtils.parseModel(
rdfService.sparqlConstructQuery(fileContents.toString(), rdfService.sparqlConstructQuery(fileContents.toString(),

View file

@ -23,6 +23,7 @@ import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService.ModelSerialization
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService.ResultFormat; import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService.ResultFormat;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException; import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory; import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory;
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.logging.LoggingRDFServiceFactory;
public class RDFServiceUtils { public class RDFServiceUtils {
@ -34,7 +35,18 @@ public class RDFServiceUtils {
public static RDFServiceFactory getRDFServiceFactory(ServletContext context) { public static RDFServiceFactory getRDFServiceFactory(ServletContext context) {
Object o = context.getAttribute(RDFSERVICEFACTORY_ATTR); Object o = context.getAttribute(RDFSERVICEFACTORY_ATTR);
return (o instanceof RDFServiceFactory) ? (RDFServiceFactory) o : null; if (o instanceof RDFServiceFactory) {
RDFServiceFactory factory = (RDFServiceFactory) o;
/*
* Every factory is wrapped in a logger, so we can dynamically
* enable or disable logging.
*/
return new LoggingRDFServiceFactory(context, factory);
} else {
log.error("Expecting an RDFServiceFactory on the context, but found " + o);
return null;
}
} }
public static void setRDFServiceFactory(ServletContext context, public static void setRDFServiceFactory(ServletContext context,

View file

@ -0,0 +1,125 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.rdfservice.impl.logging;
import java.io.InputStream;
import java.util.List;
import javax.servlet.ServletContext;
import edu.cornell.mannlib.vitro.webapp.rdfservice.ChangeListener;
import edu.cornell.mannlib.vitro.webapp.rdfservice.ChangeSet;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
/**
* This RDFService wrapper adds instrumentation to the time-consuming methods of
* the inner RDFService.
*
* For the other methods, it just delegates to the inner RDFService.
*/
public class LoggingRDFService implements RDFService {
private final ServletContext ctx;
private final RDFService innerService;
LoggingRDFService(ServletContext ctx, RDFService innerService) {
this.ctx = ctx;
this.innerService = innerService;
}
// ----------------------------------------------------------------------
// Timed methods
// ----------------------------------------------------------------------
@Override
public boolean changeSetUpdate(ChangeSet changeSet)
throws RDFServiceException {
try (RDFServiceLogger l = new RDFServiceLogger(ctx, changeSet)) {
return innerService.changeSetUpdate(changeSet);
}
}
@Override
public InputStream sparqlConstructQuery(String query,
ModelSerializationFormat resultFormat) throws RDFServiceException {
try (RDFServiceLogger l = new RDFServiceLogger(ctx, resultFormat, query)) {
return innerService.sparqlConstructQuery(query, resultFormat);
}
}
@Override
public InputStream sparqlDescribeQuery(String query,
ModelSerializationFormat resultFormat) throws RDFServiceException {
try (RDFServiceLogger l = new RDFServiceLogger(ctx, resultFormat, query)) {
return innerService.sparqlDescribeQuery(query, resultFormat);
}
}
@Override
public InputStream sparqlSelectQuery(String query, ResultFormat resultFormat)
throws RDFServiceException {
try (RDFServiceLogger l = new RDFServiceLogger(ctx, resultFormat, query)) {
return innerService.sparqlSelectQuery(query, resultFormat);
}
}
@Override
public boolean sparqlAskQuery(String query) throws RDFServiceException {
try (RDFServiceLogger l = new RDFServiceLogger(ctx, query)) {
return innerService.sparqlAskQuery(query);
}
}
// ----------------------------------------------------------------------
// Untimed methods
// ----------------------------------------------------------------------
@Override
public void newIndividual(String individualURI, String individualTypeURI)
throws RDFServiceException {
innerService.newIndividual(individualURI, individualTypeURI);
}
@Override
public void newIndividual(String individualURI, String individualTypeURI,
String graphURI) throws RDFServiceException {
innerService.newIndividual(individualURI, individualTypeURI, graphURI);
}
@Override
public List<String> getGraphURIs() throws RDFServiceException {
return innerService.getGraphURIs();
}
@Override
public void getGraphMetadata() throws RDFServiceException {
innerService.getGraphMetadata();
}
@Override
public String getDefaultWriteGraphURI() throws RDFServiceException {
return innerService.getDefaultWriteGraphURI();
}
@Override
public void registerListener(ChangeListener changeListener)
throws RDFServiceException {
innerService.registerListener(changeListener);
}
@Override
public void unregisterListener(ChangeListener changeListener)
throws RDFServiceException {
innerService.unregisterListener(changeListener);
}
@Override
public ChangeSet manufactureChangeSet() {
return innerService.manufactureChangeSet();
}
@Override
public void close() {
innerService.close();
}
}

View file

@ -0,0 +1,48 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.rdfservice.impl.logging;
import javax.servlet.ServletContext;
import edu.cornell.mannlib.vitro.webapp.rdfservice.ChangeListener;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory;
/**
* If the RDFServiceFactory is wrapped in this, then all RDFServices will be
* wrapped in a LoggingRDFService.
*/
public class LoggingRDFServiceFactory implements RDFServiceFactory {
private final ServletContext ctx;
private final RDFServiceFactory factory;
public LoggingRDFServiceFactory(ServletContext ctx,
RDFServiceFactory factory) {
this.ctx = ctx;
this.factory = factory;
}
@Override
public RDFService getRDFService() {
return new LoggingRDFService(ctx, factory.getRDFService());
}
@Override
public RDFService getShortTermRDFService() {
return new LoggingRDFService(ctx, factory.getShortTermRDFService());
}
@Override
public void registerListener(ChangeListener changeListener)
throws RDFServiceException {
factory.registerListener(changeListener);
}
@Override
public void unregisterListener(ChangeListener changeListener)
throws RDFServiceException {
factory.unregisterListener(changeListener);
}
}

View file

@ -0,0 +1,188 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.rdfservice.impl.logging;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.ListIterator;
import java.util.regex.Pattern;
import javax.servlet.ServletContext;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
/**
* Writes the log message for the LoggingRDFService.
*
* If not enabled, or if the logging level is insufficient, this does nothing.
*
* If enabled, it checks for restrictions. If there is a restriction pattern
* (regular expression), the a log message will only be printed if one of the
* fully-qualified class names in the stack trace matches that pattern.
*
* If everything passes muster, the constructor will record the time that the
* instance was created.
*
* When close() is called, if a start time was recorded, then a log record is
* produced. This contains the elapsed time, the name of the method, and any
* arguments passed to the constructor. It may also include a stack trace, if
* requested.
*
* The stack trace is abbreviated. It will reach into this class, and will not
* extend past the first reference to the ApplicationFilterChain. It also omits
* any Jena classes. Perhaps it should be abbreviated further?
*/
public class RDFServiceLogger implements AutoCloseable {
private static final Log log = LogFactory.getLog(RDFServiceLogger.class);
private static final String PROPERTY_ENABLED = "developer.loggingRDFService.enable";
private static final String PROPERTY_STACK_TRACE = "developer.loggingRDFService.stackTrace";
private static final String PROPERTY_RESTRICTION = "developer.loggingRDFService.restriction";
private final ServletContext ctx;
private final Object[] args;
private boolean isEnabled;
private boolean traceRequested;
private Pattern restriction;
private String methodName;
private List<StackTraceElement> trace = Collections.emptyList();
private long startTime;
public RDFServiceLogger(ServletContext ctx, Object... args) {
this.ctx = ctx;
this.args = args;
getProperties();
if (isEnabled && log.isInfoEnabled()) {
loadStackTrace();
if (passesRestrictions()) {
this.startTime = System.currentTimeMillis();
}
}
}
private void getProperties() {
ConfigurationProperties props = ConfigurationProperties.getBean(ctx);
isEnabled = Boolean.valueOf(props.getProperty(PROPERTY_ENABLED));
traceRequested = Boolean.valueOf(props
.getProperty(PROPERTY_STACK_TRACE));
String restrictionString = props.getProperty(PROPERTY_RESTRICTION);
if (StringUtils.isNotBlank(restrictionString)) {
try {
restriction = Pattern.compile(restrictionString);
} catch (Exception e) {
log.error("Failed to compile the pattern for "
+ PROPERTY_RESTRICTION + " = " + restriction + " " + e);
isEnabled = false;
}
}
}
private void loadStackTrace() {
StackTraceElement[] stack = Thread.currentThread().getStackTrace();
List<StackTraceElement> list = new ArrayList<StackTraceElement>(
Arrays.asList(stack));
trimStackTraceAtBeginning(list);
trimStackTraceAtEnd(list);
removeJenaClassesFromStackTrace(list);
if (list.isEmpty()) {
this.methodName = "UNKNOWN";
} else {
this.methodName = list.get(0).getMethodName();
}
this.trace = list;
log.debug("Stack array: " + Arrays.toString(stack));
log.debug("Stack trace: " + this.trace);
}
private void trimStackTraceAtBeginning(List<StackTraceElement> list) {
ListIterator<StackTraceElement> iter = list.listIterator();
while (iter.hasNext()) {
StackTraceElement ste = iter.next();
if (ste.getClassName().equals(LoggingRDFService.class.getName())) {
break;
} else {
iter.remove();
}
}
}
private void trimStackTraceAtEnd(List<StackTraceElement> list) {
ListIterator<StackTraceElement> iter = list.listIterator();
boolean trimming = false;
while (iter.hasNext()) {
StackTraceElement ste = iter.next();
if (trimming) {
iter.remove();
} else if (ste.getClassName().contains("ApplicationFilterChain")) {
trimming = true;
}
}
}
private void removeJenaClassesFromStackTrace(List<StackTraceElement> list) {
ListIterator<StackTraceElement> iter = list.listIterator();
while (iter.hasNext()) {
StackTraceElement ste = iter.next();
if (ste.getClassName().startsWith("com.hp.hpl.jena.")) {
iter.remove();
}
}
}
private boolean passesRestrictions() {
if (restriction == null) {
return true;
}
for (StackTraceElement ste : trace) {
if (restriction.matcher(ste.getClassName()).find()) {
return true;
}
}
return false;
}
@Override
public void close() {
if (startTime != 0L) {
long endTime = System.currentTimeMillis();
float elapsedSeconds = (endTime - startTime) / 1000.0F;
String cleanArgs = Arrays.deepToString(args).replaceAll(
"[\\n\\r\\t]+", " ");
String formattedTrace = formatStackTrace();
log.info(String.format("%8.3f %s %s %s", elapsedSeconds,
methodName, cleanArgs, formattedTrace));
}
}
private String formatStackTrace() {
StringBuilder sb = new StringBuilder();
if (traceRequested) {
for (StackTraceElement ste : trace) {
sb.append(String.format("\n line %d4, %s",
ste.getLineNumber(), ste.getClassName()));
}
sb.append("\n ...");
}
return sb.toString();
}
}

View file

@ -1,811 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.search.indexing;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.QuerySolutionMap;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.Syntax;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.ResourceFactory;
import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.shared.Lock;
import edu.cornell.mannlib.vitro.webapp.search.beans.StatementToURIsToUpdate;
public class AdditionalURIsForContextNodes implements StatementToURIsToUpdate {
private OntModel model;
private Set<String> alreadyChecked;
private long accumulatedTime = 0;
private static final List<String> multiValuedQueriesForAgent = new ArrayList<String>();
private static final String multiValuedQueryForInformationResource;
private static final List<String> multiValuedQueriesForRole = new ArrayList<String>();
private static final List<String>queryList;
private Log log = LogFactory.getLog(AdditionalURIsForContextNodes.class);
public AdditionalURIsForContextNodes( OntModel jenaOntModel){
this.model = jenaOntModel;
}
@Override
public List<String> findAdditionalURIsToIndex(Statement stmt) {
if( stmt != null ){
long start = System.currentTimeMillis();
List<String>urisToIndex = new ArrayList<String>();
if(stmt.getSubject() != null && stmt.getSubject().isURIResource() ){
String subjUri = stmt.getSubject().getURI();
if( subjUri != null && ! alreadyChecked.contains( subjUri )){
urisToIndex.addAll( findAdditionalURIsToIndex(subjUri));
alreadyChecked.add(subjUri);
}
}
if( stmt.getObject() != null && stmt.getObject().isURIResource() ){
String objUri = stmt.getSubject().getURI();
if( objUri != null && ! alreadyChecked.contains(objUri)){
urisToIndex.addAll( findAdditionalURIsToIndex(objUri));
alreadyChecked.add(objUri);
}
}
accumulatedTime += (System.currentTimeMillis() - start ) ;
return urisToIndex;
}else{
return Collections.emptyList();
}
}
@Override
public void startIndexing() {
alreadyChecked = new HashSet<String>();
accumulatedTime = 0L;
}
@Override
public void endIndxing() {
log.debug( "Accumulated time for this run of the index: " + accumulatedTime + " msec");
alreadyChecked = null;
}
protected List<String> findAdditionalURIsToIndex(String uri) {
List<String> uriList = new ArrayList<String>();
for(String query : queryList){
//log.info("Executing query: "+ query);
QuerySolutionMap initialBinding = new QuerySolutionMap();
Resource uriResource = ResourceFactory.createResource(uri);
initialBinding.add("uri", uriResource);
Query sparqlQuery = QueryFactory.create( query, Syntax.syntaxARQ);
model.getLock().enterCriticalSection(Lock.READ);
try{
QueryExecution qExec = QueryExecutionFactory.create(sparqlQuery, model, initialBinding);
try{
ResultSet results = qExec.execSelect();
while(results.hasNext()){
QuerySolution soln = results.nextSolution();
Iterator<String> iter = soln.varNames() ;
while( iter.hasNext()){
String name = iter.next();
RDFNode node = soln.get( name );
if( node != null ){
uriList.add("" + node.toString());
}else{
log.debug(name + " is null");
}
}
}
}catch(Throwable t){
log.error(t,t);
} finally{
qExec.close();
}
}finally{
model.getLock().leaveCriticalSection();
}
}
if( log.isDebugEnabled() )
log.debug( "additional uris for " + uri + " are " + uriList);
return uriList;
}
private static final String prefix = "prefix owl: <http://www.w3.org/2002/07/owl#> \n"
+ " prefix vitroDisplay: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#> \n"
+ " prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
+ " prefix core: <http://vivoweb.org/ontology/core#> \n"
+ " prefix foaf: <http://xmlns.com/foaf/0.1/> \n"
+ " prefix obo: <http://purl.obolibrary.org/obo/> \n"
+ " prefix vcard: <http://www.w3.org/2006/vcard/ns#> \n"
+ " prefix event: <http://purl.org/NET/c4dm/event.owl#> \n"
+ " prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
+ " prefix localNav: <http://vitro.mannlib.cornell.edu/ns/localnav#> \n"
+ " prefix bibo: <http://purl.org/ontology/bibo/> \n";
static{
// If a person changes then update
// organizations for positions
multiValuedQueriesForAgent.add(prefix +
"SELECT DISTINCT \n" +
" (str(?i) as ?positionInOrganization) \n" +
" WHERE {\n"
+ "?uri rdf:type foaf:Agent ; core:relatedBy ?c . \n"
+ " ?c rdf:type core:Position . \n"
+ " OPTIONAL { ?c core:relates ?i . ?i rdf:type foaf:Organization } . \n"
+ " }");
// If a person changes then update
// advisee, linkedAuthor and informationResource
multiValuedQueriesForAgent.add(prefix +
"SELECT (str(?d) as ?advisee) \n" +
" (str(?f) as ?linkedAuthor) (str(?h) as ?linkedInformationResource) WHERE { {\n"
+ "?uri rdf:type foaf:Agent . \n"
+ "?uri core:relatedBy ?c . \n"
+ "?c rdf:type core:AdvisingRelationship . \n"
+ "?c core:relates ?d . \n"
+ "?d rdf:type core:AdviseeRole . \n"
+ "?d obo:RO_0000052 ?e . \n"
+ "?e rdf:type foaf:Person . \n"
+ "} \n"
+ "UNION { \n"
+ " ?uri rdf:type foaf:Agent . \n"
+ " ?uri core:relatedBy ?c . \n"
+ " ?c rdf:type core:Authorship . \n"
+ " OPTIONAL {?c core:relates ?f . \n"
+ " ?f rdf:type foaf:Person . } \n"
+ " OPTIONAL { ?c core:relates ?h . \n"
+ " ?h rdf:type obo:IAO_0000030 . } \n"
+ " } } ");
// If a person changes then update
// award giver
multiValuedQueriesForAgent.add(prefix +
"SELECT (str(?d) as ?awardConferredBy) \n" +
"WHERE {\n"
+ "?uri rdf:type foaf:Agent ; ?b ?c . \n"
+ " ?c rdf:type core:AwardReceipt . \n"
+ " OPTIONAL { ?c core:assignedBy ?d . } . \n"
+ " }");
// If a person changes then update
// organization for role
multiValuedQueriesForAgent.add(prefix +
"SELECT (str(?Organization) as ?organization) \n" +
"WHERE {\n"
+ "?uri rdf:type foaf:Agent ; ?b ?c . \n"
+ " ?c rdf:type obo:BFO_0000023 ; obo:BFO_0000054 ?Organization .\n"
+ " }");
// If a person changes then update
// organization in educational training
multiValuedQueriesForAgent.add(prefix +
"SELECT \n" +
"(str(?e) as ?trainingAtOrganization) WHERE {\n"
+ " ?uri rdf:type foaf:Agent ; ?b ?c . \n"
+ " ?c rdf:type core:EducationalProcess . \n"
+ " OPTIONAL { ?c obo:RO_0000057 ?e . \n"
+ " ?e rdf:type foaf:Organization . } . "
+"}");
// If an organization changes then update
// people in head of relations
multiValuedQueriesForAgent.add(
" # for organization, get leader \n" +
prefix +
"SELECT \n" +
"(str(?e) as ?LeaderPerson ) WHERE {\n"
+ " ?uri rdf:type foaf:Agent . \n"
+ " ?uri core:contributingRole ?c . \n"
+ " ?c rdf:type core:LeaderRole . \n"
+ " OPTIONAL { ?c obo:RO_0000052 ?e . \n"
+ " ?e rdf:type foaf:Person . } . "
+"}");
}
//multivalued query for core:InformationResource
static {
multiValuedQueryForInformationResource = prefix +
"SELECT (str(?b) as ?linkedAuthor) (str(?d) as ?linkedInformationResource) \n"
+ "(str(?f) as ?editor) \n" +
"(str(?i) as ?features) WHERE {\n"
+ " ?uri rdf:type obo:IAO_0000030 . \n"
+ " OPTIONAL { ?uri core:relatedBy ?a . \n"
+ " ?a rdf:type core:Authorship . \n"
+ " ?a core:relates ?b . ?b rdf:type foaf:Person .\n"
+ " ?a core:relates ?d . ?d rdf:type obo:IAO_0000030 .\n"
+ "} . "
+ " OPTIONAL { ?uri core:relatedBy ?e . \n"
+ " ?e rdf:type core:Editorship . \n"
+ " ?e core:relates ?f . ?f rdf:type foaf:Person .\n"
+ "} . "
+ " OPTIONAL { ?uri core:features ?i . } . \n"
+"}" ;
}
protected static List<String> queriesForAuthorship(){
List<String> queries = new ArrayList<String>();
//get additional URIs of information resources from author side
queries.add(
prefix
+ "SELECT (str(?a) as ?infoResource) WHERE {\n"
+ " ?uri rdf:type foaf:Person . \n"
+ " ?uri core:relatedBy ?aship .\n"
+ " ?aship rdf:type core:Authorship .\n"
+ "OPTIONAL { ?aship core:relates ?a . ?a rdf:type obo:IAO_0000030 } .\n"
+"}" );
//get additional URIs of authors from information resource side
queries.add(
prefix
+ "SELECT (str(?a) as ?author ) WHERE {\n"
+ " ?uri rdf:type obo:IAO_0000030 . \n"
+ " ?uri core:relatedBy ?aship . ?aship rdf:type core:Authorship . \n"
+ "OPTIONAL { ?aship core:relates ?a . ?a rdf:type foaf:Person } .\n"
+"}" );
return queries;
}
protected static List<String> queriesForURLLink(){
List<String> queries = new ArrayList<String>();
//get additional URIs when URLLink is changed
queries.add(
prefix
+ "SELECT (str(?x) as ?individual) WHERE {\n"
+ " ?i rdf:type vcard:Individual . \n"
+ " ?i vcard:hasURL ?uri . \n"
+ " ?i obo:ARG_2000029 ?x . \n"
+"}" );
return queries;
}
protected static List<String> queriesForEducationalTraining(){
List<String> queries = new ArrayList<String>();
//if person changes, no additional URIs need to be
//changed because the person is not displayed on the
//degree individual or on the degree granting organization
//if the degree changes, the person needs to be updated
//since the degree name is shown on the person page.
queries.add(
prefix
+ " SELECT (str(?person) as ?personUri) WHERE {\n"
+ " ?uri rdf:type core:AcademicDegree . \n"
+ " ?uri core:relatedBy ?awardedDegree .\n"
+ " ?awardedDegree rdf:type core:AwardedDegree .\n"
+ " ?awardedDegree core:relates ?person .\n"
+ " ?person rdf:type foaf:Person .\n"
+"}" );
//if the organization changes the person needs to be updated
//since the organization name is shown on the person page.
queries.add(
prefix
+ " SELECT (str(?person) as ?personUri) WHERE {\n"
+ " ?uri rdf:type foaf:Organization . \n"
+ " ?uri obo:RO_0000056 ?edTrainingNode .\n"
+ " ?edTrainingNode rdf:type core:EducationalProcess . \n"
+ " ?edTrainingNode obo:RO_0000057 ?person . \n"
+ " ?person rdf:type foaf:Person ."
+"}" );
return queries;
}
protected static List<String> queriesForPosition(){
List<String> queries = new ArrayList<String>();
//If an organization changes, update people
queries.add(
prefix
+ " SELECT (str(?person) as ?personUri) WHERE {\n"
+ " ?uri rdf:type foaf:Organization . \n"
+ " ?uri core:relatedBy ?positionNode .\n"
+ " ?positionNode rdf:type core:Position .\n"
+ " ?positionNode core:relates ?person . \n"
+ " ?person rdf:type foaf:Person .\n"
+"}" );
//if people change, update organizations
queries.add(
prefix
+ " SELECT (str(?org) as ?orgUri) WHERE {\n"
+ " ?uri rdf:type foaf:Person . \n"
+ " ?uri core:relatedBy ?positionNode .\n"
+ " ?positionNode rdf:type core:Position .\n"
+ " ?positionNode core:relates ?org . \n"
+ " ?org rdf:type foaf:Organization .\n"
+"}" );
return queries;
}
static{
// core:AttendeeRole
// If the person changes, update the attendee role in organization
// core:AttendeeRole applies to events, not organizations; updating accordingly - tlw72
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?event) \n " +
"WHERE {\n"
+ "?uri rdf:type foaf:Person . \n"
+ "?uri obo:RO_0000053 ?c . \n"
+ "?c rdf:type core:AttendeeRole . \n"
+ "?c obo:BFO_0000054 ?d . \n"
+ "?d rdf:type event:Event .\n"
+ " }");
// If the organization changes, update the attendee role of person
// core:AttendeeRole applies to events, not organizations; updating accordingly - tlw72
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?person) \n" +
"WHERE {\n"
+ "?uri rdf:type event:Event . \n"
+ "?uri obo:BFO_0000055 ?c . \n"
+ "?c rdf:type core:AttendeeRole . \n"
+ "?c obo:RO_0000052 ?d . \n"
+ "?d rdf:type foaf:Person .\n"
+ " }");
// core:ClinicalRole -- core:clinicalRoleOf
// If the person changes, update the clinical role in project
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?project) \n" +
"WHERE {\n"
+ "?uri rdf:type foaf:Person . \n"
+ "?uri obo:RO_0000053 ?c . \n"
+ "?c rdf:type core:ClinicalRole . \n"
+ "?c obo:BFO_0000054 ?d .\n"
+ "?d rdf:type core:Project .\n"
+ " }");
// If the person changes, update the clinical role in service
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?service) \n" +
"WHERE {\n"
+ "?uri rdf:type foaf:Person . \n"
+ "?uri obo:RO_0000053 ?c . \n"
+ "?c rdf:type core:ClinicalRole . \n"
+ "?c core:roleContributesTo ?d .\n"
+ "?d rdf:type obo:ERO_0000005 .\n"
+ " }");
// If the project changes, update the clinical role of person
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?person) \n" +
"WHERE {\n"
+ "?uri rdf:type core:Project . \n"
+ "?uri obo:BFO_0000055 ?c . \n"
+ "?c rdf:type core:ClinicalRole . \n"
+ "?c obo:RO_0000052 ?d .\n "
+ "?d rdf:type foaf:Person .\n "
+ " }");
// If the service changes, update the clinical role of person
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?person) \n" +
"WHERE {\n"
+ "?uri rdf:type obo:ERO_0000005 . \n"
+ "?uri core:contributingRole ?c . \n"
+ "?c rdf:type core:ClinicalRole . \n"
+ "?c obo:RO_0000052 ?d .\n "
+ "?d rdf:type foaf:Person .\n "
+ " }");
// If the person changes, update the leader role in organization
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?organization) \n" +
"WHERE {\n"
+ "?uri rdf:type foaf:Person . \n"
+ "?uri obo:RO_0000053 ?c . \n"
+ "?c rdf:type core:LeaderRole . \n"
+ "?c core:roleContributesTo ?d .\n"
+ "?d rdf:type foaf:Organization .\n "
+ " }");
// If the organization changes, update the leader role of person
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?person) \n" +
"WHERE {\n"
+ "?uri rdf:type foaf:Organization . \n"
+ "?uri core:contributingRole ?c . \n"
+ "?c rdf:type core:LeaderRole . \n"
+ "?c obo:RO_0000052 ?d .\n "
+ "?d rdf:type foaf:Person .\n "
+ " }");
// core:MemberRole -- core:memberRoleOf
// If the person changes, update the member role in organization
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?organization) \n" +
"WHERE \n{"
+ "?uri rdf:type foaf:Person . \n"
+ "?uri obo:RO_0000053 ?c . \n"
+ "?c rdf:type core:MemberRole . \n"
+ "?c core:roleContributesTo ?d .\n"
+ "?d rdf:type foaf:Organization .\n "
+ " }");
// If the organization changes, update the member role of person
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?person) \n" +
"WHERE {"
+ "?uri rdf:type foaf:Organization . \n"
+ "?uri core:contributingRole ?c . \n"
+ "?c rdf:type core:MemberRole . \n"
+ "?c obo:RO_0000052 ?d .\n "
+ "?d rdf:type foaf:Person .\n "
+ " }");
// core:OrganizerRole -- core:organizerRoleOf
// If the person changes, update the organizer role in organization
// organizerRole appplies to events not organizations; updating accordingly - tlw72
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?event) \n" +
"WHERE {"
+ "?uri rdf:type foaf:Person . \n"
+ "?uri obo:RO_0000053 ?c . \n"
+ "?c rdf:type core:OrganizerRole .\n"
+ "?c obo:BFO_0000054 ?d .\n"
+ "?d rdf:type event:Event .\n "
+ " }");
// If the organization changes, update the organizer role of person
// organizerRole appplies to events not organizations; updating accordingly - tlw72
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?person) \n" +
"WHERE {\n"
+ "?uri rdf:type event:Event . \n"
+ "?uri obo:BFO_0000055 ?c . \n"
+ "?c rdf:type core:OrganizerRole . \n"
+ "?c obo:RO_0000052 ?d .\n "
+ "?d rdf:type foaf:Person .\n "
+ " }");
// core:OutreachProviderRole -- core:outreachProviderRoleOf
// If the person changes, update the outreach provider role in organization
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?organization) \n" +
"WHERE {\n"
+ "?uri rdf:type foaf:Person . \n"
+ "?uri obo:RO_0000053 ?c . \n"
+ "?c rdf:type core:OutreachProviderRole .\n"
+ "?c core:roleContributesTo ?d .\n"
+ "?d rdf:type foaf:Organization .\n "
+ " }");
// If the organization changes, update the outreach provider role of person
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?person) \n" +
"WHERE {\n"
+ "?uri rdf:type foaf:Organization . \n"
+ "?uri core:contributingRole ?c . \n"
+ "?c rdf:type core:OutreachProviderRole . \n"
+ "?c obo:RO_0000052 ?d .\n "
+ "?d rdf:type foaf:Person .\n "
+ " }");
// core:PresenterRole -- core:presenterRoleOf
// If the person changes, update the presentation
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?presentation) \n" +
"WHERE {\n"
+ "?uri rdf:type foaf:Person . \n"
+ "?uri obo:RO_0000053 ?c . \n"
+ " ?c rdf:type core:PresenterRole . \n"
+ " ?c obo:BFO_0000054 ?d .\n"
+ " ?d rdf:type core:Presentation . \n"
+ " }");
// If the presentation changes, update the person
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?person) \n" +
"WHERE {\n"
+ "?uri rdf:type core:Presentation . \n"
+ "?uri obo:BFO_0000055 ?c . \n"
+ " ?c rdf:type core:PresenterRole . \n "
+ "?c obo:RO_0000052 ?d .\n "
+ "?d rdf:type foaf:Person .\n "
+ " }");
// core:ResearcherRole -- core:researcherRoleOf
// If the person changes, update the grant
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?grant) \n" +
"WHERE {\n"
+ "?uri rdf:type foaf:Person . \n"
+ "?uri obo:RO_0000053 ?c . \n"
+ " ?c rdf:type core:ResearcherRole . \n "
+ " ?c core:relatedBy ?d .\n"
+ " ?d rdf:type core:Grant . \n"
+ " }");
// If the grant changes, update the researcher
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?person) \n" +
"WHERE {\n"
+ "?uri rdf:type core:Grant . \n"
+ "?uri core:relates ?c . \n"
+ " ?c rdf:type core:ResearcherRole . \n "
+ " ?c obo:RO_0000052 ?d .\n"
+ "?d rdf:type foaf:Person .\n "
+ " }");
// If the grant changes, update the principal investigator
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?person) \n" +
"WHERE {\n"
+ "?uri rdf:type core:Grant . \n"
+ " ?uri core:relates ?c . \n"
+ " ?c rdf:type core:PrincipalInvestigatorRole . \n "
+ " ?c obo:RO_0000052 ?d .\n"
+ "?d rdf:type foaf:Person .\n "
+ " }");
// If the grant changes, update the co-principal investigator
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?person) \n" +
"WHERE {\n"
+ "?uri rdf:type core:Grant . \n"
+ " ?uri core:relates ?c . \n"
+ " ?c rdf:type core:CoPrincipalInvestigatorRole . \n "
+ " ?c obo:RO_0000052 ?d .\n"
+ "?d rdf:type foaf:Person .\n "
+ " }");
// If the grant changes, update the investigator
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?person) \n" +
"WHERE {\n"
+ "?uri rdf:type core:Grant . \n"
+ " ?uri core:relates ?c . \n"
+ " ?c rdf:type core:InvestigatorRole . \n "
+ " ?c obo:RO_0000052 ?d .\n"
+ "?d rdf:type foaf:Person .\n "
+ " }");
// If the person changes, update the project
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?project) \n" +
"WHERE {\n"
+ "?uri rdf:type foaf:Person . \n"
+ "?uri obo:RO_0000053 ?c . \n"
+ " ?c rdf:type core:ResearcherRole . \n "
+ " ?c obo:BFO_0000054 ?d .\n"
+ " ?d rdf:type core:Project . \n"
+ " }");
// If the project changes, update the researcher
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?person) \n" +
"WHERE {\n"
+ "?uri rdf:type core:Project . \n"
+ " ?uri obo:BFO_0000055 ?c .\n"
+ " ?c rdf:type core:ResearcherRole . \n "
+ " ?c obo:RO_0000052 ?d .\n"
+ "?d rdf:type foaf:Person .\n "
+ " }");
// core:EditorRole -- core:editorRoleOf, core:forInformationResource (person, informationresource)
// If the person changes, update the editor role of the info resource
// changing foaf:Organization to info content entity. Org no longer applies here - tlw72
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?informationResource) \n" +
"WHERE {\n"
+ "?uri rdf:type foaf:Person . \n"
+ "?uri obo:RO_0000053 ?c . \n"
+ " ?c rdf:type core:EditorRole . \n "
+ " ?c core:roleContributesTo ?d .\n"
+ "?d rdf:type obo:IAO_0000030 .\n "
+ " }");
// If the info respource changes, update the editor role of person
// changing foaf:Organization to info content entity. Org no longer applies here - tlw72
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?person) \n" +
"WHERE {\n"
+ "?uri rdf:type obo:IAO_0000030 . \n"
+ "?uri core:contributingRole ?c . \n"
+ " ?c rdf:type core:EditorRole . \n "
+ " ?c obo:RO_0000052 ?d .\n"
+ "?d rdf:type foaf:Person .\n "
+ " }");
// Next two queries are covered by the previous two. Commenting them out - tlw72
// If the person changes, update the information resource associated with editor role
/* multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?informationResource) \n" +
"WHERE {\n"
+ "?uri rdf:type foaf:Person ; ?b ?c . \n"
+ " ?c rdf:type core:EditorRole ; core:forInformationResource ?d .\n"
+ " }");
// If the organization changes, update the information resource associated with editor role
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?informationResource) \n" +
"WHERE {\n"
+ "?uri rdf:type foaf:Organization ; ?b ?c . \n"
+ " ?c rdf:type core:EditorRole ; core:forInformationResource ?d .\n"
+ " }");
*/
// core:ServiceProviderRole -- core:serviceProviderRoleOf
// If the person changes, update the service provider role in organization
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?organization) \n" +
"WHERE {\n"
+ "?uri rdf:type foaf:Person . \n"
+ "?uri obo:RO_0000053 ?c . \n"
+ " ?c rdf:type obo:ERO_0000012 . \n"
+ " ?c core:roleContributesTo ?d .\n"
+ " ?d rdf:type foaf:Organization .\n "
+ " }");
// If the organization changes, update the service provider role of person
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?person) \n" +
"WHERE {\n"
+ "?uri rdf:type foaf:Organization . \n"
+ "?uri core:contributingRole ?c . \n"
+ " ?c rdf:type obo:ERO_0000012 . \n "
+ " ?c obo:RO_0000052 ?d .\n"
+ "?d rdf:type foaf:Person .\n "
+ " }");
// core:TeacherRole -- core:teacherRoleOf
// If the person changes, update the teacher role in organization
// updated to make this an Event (e.g., a course) not an organization - tlw72
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?event) \n" +
"WHERE {\n"
+ "?uri rdf:type foaf:Person . \n"
+ "?uri obo:RO_0000053 ?c . \n"
+ " ?c rdf:type core:TeacherRole . \n"
+ " ?c obo:BFO_0000054 ?d .\n"
+ " ?d rdf:type event:Event .\n "
+ " }");
// If the organization changes, update the teacher role of person
// updated to make this an Event (e.g., a course) not an organization - tlw72
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?person) \n" +
"WHERE {\n"
+ "?uri rdf:type event:Event . \n"
+ "?uri obo:BFO_0000055 ?c . \n"
+ " ?c rdf:type core:TeacherRole . \n "
+ " ?c obo:RO_0000052 ?d .\n"
+ "?d rdf:type foaf:Person .\n "
+ " }");
// core:ReviewerRole -- core:forInformationResource, core:reviewerRoleOf
// core:PeerReviewerRole -- core:forInformationResource, core:reviewerRoleOf
// If the person changes, update the reviewer role in organization
// There is no relationship between a reviewerRole and an organization; commenting
// the next two queries out - tlw72
/* multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?organization) \n" +
"WHERE {\n"
+ "?uri rdf:type foaf:Person ; ?b ?c . \n"
+ " ?c rdf:type core:ReviewerRole ; core:roleIn ?d .\n"
+ " }");
// If the organization changes, update the reviewer role of person
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?person) \n" +
"WHERE {\n"
+ "?uri rdf:type foaf:Organization ; ?b ?c . \n"
+ " ?c rdf:type core:ReviewerRole ; core:reviewerRoleOf ?d .\n"
+ " }");
*/
// If the person changes, update the information resource associated with reviewer role
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?informationResource) \n " +
"WHERE {\n"
+ "?uri rdf:type foaf:Person . \n"
+ "?uri obo:RO_0000053 ?c . \n"
+ " ?c rdf:type core:ReviewerRole . \n"
+ " ?c core:roleContributesTo ?d .\n"
+ " ?d rdf:type obo:IAO_0000030 .\n "
+ " }");
// If the organization changes, update the information resource associated with reviewer role
multiValuedQueriesForRole.add(prefix +
"SELECT (str(?d) as ?informationResource) \n" +
"WHERE {\n"
+ "?uri rdf:type obo:IAO_0000030 . \n"
+ "?uri core:contributingRole ?c . \n"
+ " ?c rdf:type core:ReviewerRole. \n "
+ " ?c obo:RO_0000052 ?d .\n"
+ "?d rdf:type foaf:Person .\n "
+ " }");
}
static{
List<String> tmpList = new ArrayList<String>();
tmpList.add(multiValuedQueryForInformationResource);
tmpList.addAll(multiValuedQueriesForAgent);
tmpList.addAll(multiValuedQueriesForRole);
tmpList.addAll( queriesForAuthorship());
tmpList.addAll(queriesForURLLink());
tmpList.addAll(queriesForEducationalTraining());
tmpList.addAll(queriesForPosition());
queryList = Collections.unmodifiableList(tmpList);
}
}

View file

@ -0,0 +1,30 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.search.indexing;
import java.util.ArrayList;
import java.util.List;
import com.hp.hpl.jena.ontology.OntModel;
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.search.beans.StatementToURIsToUpdate;
/**
* Make a list of StatementToURIsToUpdate objects for use by the
* IndexBuidler.
*/
public class AdditionalUriFinders {
public static List<StatementToURIsToUpdate> getList(OntModel jenaOntModel,
IndividualDao indDao) {
// TODO How many of these are only relevant to VIVO?
List<StatementToURIsToUpdate> uriFinders = new ArrayList<>();
uriFinders.add(new AdditionalURIsForDataProperties());
uriFinders.add(new AdditionalURIsForObjectProperties(jenaOntModel));
uriFinders.add(new AdditionalURIsForTypeStatements());
uriFinders.add(new URIsForClassGroupChange(indDao));
return uriFinders;
}
}

View file

@ -281,10 +281,23 @@ public class IndexBuilder extends VitroBackgroundThread {
//keep uris unique by using a HashSet //keep uris unique by using a HashSet
Collection<String> urisToUpdate = new HashSet<String>(); Collection<String> urisToUpdate = new HashSet<String>();
for( Statement stmt : getAndClearChangedStmts() ){ Statement[] changedStatements = getAndClearChangedStmts();
int howManyChanges = changedStatements.length;
if (howManyChanges > 100) {
log.info("Finding URIs that are affected by " + howManyChanges
+ " changed statements.");
}
for (int i = 0; i < howManyChanges; i++) {
Statement stmt = changedStatements[i];
for (StatementToURIsToUpdate stu : stmtToURIsToIndexFunctions) { for (StatementToURIsToUpdate stu : stmtToURIsToIndexFunctions) {
urisToUpdate.addAll(stu.findAdditionalURIsToIndex(stmt)); urisToUpdate.addAll(stu.findAdditionalURIsToIndex(stmt));
} }
if ((i > 0) && (i % 1000 == 0)) {
log.info("Processed " + i + " changed statements; found "
+ urisToUpdate.size() + " affected URIs.");
}
} }
//inform StatementToURIsToUpdate that they are done //inform StatementToURIsToUpdate that they are done

View file

@ -12,8 +12,10 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.search.IndexingException; import edu.cornell.mannlib.vitro.webapp.search.IndexingException;
import edu.cornell.mannlib.vitro.webapp.search.beans.IndexerIface; import edu.cornell.mannlib.vitro.webapp.search.beans.IndexerIface;
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.IndividualToSolrDocument; import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.IndividualToSolrDocument;
import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread;
class IndexWorkerThread extends Thread{ class IndexWorkerThread extends VitroBackgroundThread{
private static final Log log = LogFactory.getLog(IndexWorkerThread.class);
protected final int threadNum; protected final int threadNum;
protected IndividualToSolrDocument individualToSolrDoc; protected IndividualToSolrDocument individualToSolrDoc;
@ -21,7 +23,6 @@ class IndexWorkerThread extends Thread{
protected final Iterator<Individual> individualsToIndex; protected final Iterator<Individual> individualsToIndex;
protected boolean stopRequested = false; protected boolean stopRequested = false;
private Log log = LogFactory.getLog(IndexWorkerThread.class);
private static AtomicLong countCompleted= new AtomicLong(); private static AtomicLong countCompleted= new AtomicLong();
private static AtomicLong countToIndex= new AtomicLong(); private static AtomicLong countToIndex= new AtomicLong();
private static long starttime = 0; private static long starttime = 0;
@ -38,6 +39,7 @@ class IndexWorkerThread extends Thread{
} }
public void run(){ public void run(){
setWorkLevel(WorkLevel.WORKING, "indexing " + individualsToIndex + " individuals");
while( ! stopRequested ){ while( ! stopRequested ){
@ -48,6 +50,8 @@ class IndexWorkerThread extends Thread{
// done so shut this thread down. // done so shut this thread down.
stopRequested = true; stopRequested = true;
} }
setWorkLevel(WorkLevel.IDLE);
log.debug("Worker number " + threadNum + " exiting."); log.debug("Worker number " + threadNum + " exiting.");
} }
@ -82,8 +86,8 @@ class IndexWorkerThread extends Thread{
} }
} }
}catch(Throwable th){ }catch(Throwable th){
//on tomcat shutdown odd exceptions get thrown and log can be null //on tomcat shutdown odd exceptions get thrown
if( log != null && ! stopRequested ) if( ! stopRequested )
log.error("Exception during index building",th); log.error("Exception during index building",th);
} }
} }

View file

@ -2,8 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.search.solr; package edu.cornell.mannlib.vitro.webapp.search.solr;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -18,7 +16,6 @@ import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.vocabulary.OWL; import com.hp.hpl.jena.vocabulary.OWL;
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess; import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
@ -29,13 +26,9 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory; import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory;
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils; import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
import edu.cornell.mannlib.vitro.webapp.search.beans.StatementToURIsToUpdate; import edu.cornell.mannlib.vitro.webapp.search.beans.StatementToURIsToUpdate;
import edu.cornell.mannlib.vitro.webapp.search.indexing.AdditionalURIsForContextNodes; import edu.cornell.mannlib.vitro.webapp.search.indexing.AdditionalUriFinders;
import edu.cornell.mannlib.vitro.webapp.search.indexing.AdditionalURIsForDataProperties;
import edu.cornell.mannlib.vitro.webapp.search.indexing.AdditionalURIsForObjectProperties;
import edu.cornell.mannlib.vitro.webapp.search.indexing.AdditionalURIsForTypeStatements;
import edu.cornell.mannlib.vitro.webapp.search.indexing.IndexBuilder; import edu.cornell.mannlib.vitro.webapp.search.indexing.IndexBuilder;
import edu.cornell.mannlib.vitro.webapp.search.indexing.SearchReindexingListener; import edu.cornell.mannlib.vitro.webapp.search.indexing.SearchReindexingListener;
import edu.cornell.mannlib.vitro.webapp.search.indexing.URIsForClassGroupChange;
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.DocumentModifier; import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.DocumentModifier;
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.ExcludeBasedOnNamespace; import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.ExcludeBasedOnNamespace;
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.ExcludeBasedOnType; import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.ExcludeBasedOnType;
@ -140,7 +133,7 @@ public class SolrSetup implements javax.servlet.ServletContextListener{
wadf = new WebappDaoFactoryFiltering(wadf, vf); wadf = new WebappDaoFactoryFiltering(wadf, vf);
// make objects that will find additional URIs for context nodes etc // make objects that will find additional URIs for context nodes etc
List<StatementToURIsToUpdate> uriFinders = makeURIFinders(jenaOntModel,wadf.getIndividualDao()); List<StatementToURIsToUpdate> uriFinders = AdditionalUriFinders.getList(jenaOntModel,wadf.getIndividualDao());
// Make the IndexBuilder // Make the IndexBuilder
IndexBuilder builder = new IndexBuilder( solrIndexer, wadf, uriFinders ); IndexBuilder builder = new IndexBuilder( solrIndexer, wadf, uriFinders );
@ -159,22 +152,6 @@ public class SolrSetup implements javax.servlet.ServletContextListener{
} }
/**
* Make a list of StatementToURIsToUpdate objects for use by the
* IndexBuidler.
* @param indDao
*/
public List<StatementToURIsToUpdate> makeURIFinders( OntModel jenaOntModel, IndividualDao indDao ){
List<StatementToURIsToUpdate> uriFinders = new ArrayList<StatementToURIsToUpdate>();
uriFinders.add( new AdditionalURIsForDataProperties() );
uriFinders.add( new AdditionalURIsForObjectProperties(jenaOntModel) );
uriFinders.add( new AdditionalURIsForContextNodes(jenaOntModel) );
uriFinders.add( new AdditionalURIsForTypeStatements() );
uriFinders.add( new URIsForClassGroupChange( indDao ));
return uriFinders;
}
@Override @Override
public void contextDestroyed(ServletContextEvent sce) { public void contextDestroyed(ServletContextEvent sce) {
IndexBuilder builder = (IndexBuilder)sce.getServletContext().getAttribute(IndexBuilder.class.getName()); IndexBuilder builder = (IndexBuilder)sce.getServletContext().getAttribute(IndexBuilder.class.getName());

View file

@ -1,300 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.SolrInputField;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.QuerySolutionMap;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.Syntax;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.ResourceFactory;
import com.hp.hpl.jena.shared.Lock;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
public class CalculateParameters implements DocumentModifier {
private boolean shutdown = false;
private Dataset dataset;
// public static int totalInd=1;
private static final String prefix = "prefix owl: <http://www.w3.org/2002/07/owl#> "
+ " prefix vitroDisplay: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#> "
+ " prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
+ " prefix core: <http://vivoweb.org/ontology/core#> "
+ " prefix foaf: <http://xmlns.com/foaf/0.1/> "
+ " prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> "
+ " prefix localNav: <http://vitro.mannlib.cornell.edu/ns/localnav#> "
+ " prefix bibo: <http://purl.org/ontology/bibo/> ";
private static final String betaQuery = prefix + " SELECT count(distinct ?inLinks) " +
" WHERE { " +
" ?uri rdf:type owl:Thing . " +
" ?inLinks ?prop ?uri . " +
" } ";
private static final String totalCountQuery = prefix + " SELECT count(distinct ?ind) " +
" WHERE { " +
" ?ind rdf:type owl:Thing . " +
" } ";
private static Log log = LogFactory.getLog(CalculateParameters.class);
public CalculateParameters(Dataset dataset){
this.dataset =dataset;
// new Thread(new TotalInd(this.dataset,totalCountQuery)).start();
}
public CalculateParameters(){
super();
}
public float calculateBeta(String uri){
float beta=0;
int Conn=0;
Query query;
QuerySolutionMap initialBinding = new QuerySolutionMap();
QuerySolution soln = null;
Resource uriResource = ResourceFactory.createResource(uri);
initialBinding.add("uri", uriResource);
dataset.getLock().enterCriticalSection(Lock.READ);
QueryExecution qexec=null;
try{
query = QueryFactory.create(betaQuery,Syntax.syntaxARQ);
qexec = QueryExecutionFactory.create(query,dataset,initialBinding);
ResultSet results = qexec.execSelect();
List<String> resultVars = results.getResultVars();
if(resultVars!=null && resultVars.size()!=0){
soln = results.next();
Conn = Integer.parseInt(soln.getLiteral(resultVars.get(0)).getLexicalForm());
}
}catch(Throwable t){
if( ! shutdown )
log.error(t,t);
}finally{
if( qexec != null )
qexec.close();
dataset.getLock().leaveCriticalSection();
}
beta = (float)Conn;
//beta *= 100;
beta += 1;
// sigmoid function to keep beta between 0 to 1;
beta = (float) (1 / ( 1 + Math.pow(Math.E,(-beta))));
if(beta > 1)
log.info("Beta higher than 1 : " + beta);
else if(beta <= 0)
log.info("Beta lower < = 0 : " + beta);
return beta;
}
public String[] getAdjacentNodes(String uri){
List<String> queryList = new ArrayList<String>();
Set<String> adjacentNodes = new HashSet<String>();
Set<String> coauthorNames = new HashSet<String>();
String[] info = new String[]{"",""};
StringBuffer adjacentNodesConcat = new StringBuffer();
StringBuffer coauthorBuff = new StringBuffer();
adjacentNodesConcat.append("");
coauthorBuff.append("");
queryList.add(prefix +
" SELECT ?adjobj (str(?adjobjLabel) as ?coauthor) " +
" WHERE { " +
" ?uri rdf:type <http://xmlns.com/foaf/0.1/Person> . " +
" ?uri ?prop ?obj . " +
" ?obj rdf:type <http://vivoweb.org/ontology/core#Relationship> . " +
" ?obj ?prop2 ?obj2 . " +
" ?obj2 rdf:type <http://vivoweb.org/ontology/core#InformationResource> . " +
" ?obj2 ?prop3 ?obj3 . " +
" ?obj3 rdf:type <http://vivoweb.org/ontology/core#Relationship> . " +
" ?obj3 ?prop4 ?adjobj . " +
" ?adjobj rdfs:label ?adjobjLabel . " +
" ?adjobj rdf:type <http://xmlns.com/foaf/0.1/Person> . " +
" FILTER (?prop !=rdf:type) . " +
" FILTER (?prop2!=rdf:type) . " +
" FILTER (?prop3!=rdf:type) . " +
" FILTER (?prop4!=rdf:type) . " +
" FILTER (?adjobj != ?uri) . " +
"}");
queryList.add(prefix +
" SELECT ?adjobj " +
" WHERE{ " +
" ?uri rdf:type foaf:Agent . " +
" ?uri ?prop ?obj . " +
" ?obj ?prop2 ?adjobj . " +
" FILTER (?prop !=rdf:type) . " +
" FILTER isURI(?obj) . " +
" FILTER (?prop2!=rdf:type) . " +
" FILTER (?adjobj != ?uri) . " +
" FILTER isURI(?adjobj) . " +
" { ?adjobj rdf:type <http://xmlns.com/foaf/0.1/Organization> . } " +
" UNION " +
" { ?adjobj rdf:type <http://xmlns.com/foaf/0.1/Person> . } " +
" UNION " +
" { ?adjobj rdf:type <http://vivoweb.org/ontology/core#InformationResource> . } " +
" UNION " +
" { ?adjobj rdf:type <http://vivoweb.org/ontology/core#Location> . } ." +
"}");
Query query;
QuerySolution soln;
QuerySolutionMap initialBinding = new QuerySolutionMap();
Resource uriResource = ResourceFactory.createResource(uri);
initialBinding.add("uri", uriResource);
Iterator<String> queryItr = queryList.iterator();
dataset.getLock().enterCriticalSection(Lock.READ);
Resource adjacentIndividual = null;
RDFNode coauthor = null;
try{
while(queryItr.hasNext()){
/*if(!isPerson){
queryItr.next(); // we don't want first query to execute if the ind is not a person.
}*/
query = QueryFactory.create(queryItr.next(),Syntax.syntaxARQ);
QueryExecution qexec = QueryExecutionFactory.create(query,dataset,initialBinding);
try{
ResultSet results = qexec.execSelect();
while(results.hasNext()){
soln = results.nextSolution();
adjacentIndividual = (Resource)soln.get("adjobj");
if(adjacentIndividual!=null){
adjacentNodes.add(adjacentIndividual.getURI());
}
coauthor = soln.get("coauthor");
if(coauthor!=null){
coauthorNames.add(" co-authors " + coauthor.toString() + " co-authors ");
}
}
}catch(Exception e){
if( ! shutdown )
log.error("Error found in getAdjacentNodes method of SearchQueryHandler");
}finally{
qexec.close();
}
}
queryList = null;
Iterator<String> itr = adjacentNodes.iterator();
while(itr.hasNext()){
adjacentNodesConcat.append(itr.next() + " ");
}
info[0] = adjacentNodesConcat.toString();
itr = coauthorNames.iterator();
while(itr.hasNext()){
coauthorBuff.append(itr.next());
}
info[1] = coauthorBuff.toString();
}
catch(Throwable t){
if( ! shutdown )
log.error(t,t);
}finally{
dataset.getLock().leaveCriticalSection();
adjacentNodes = null;
adjacentNodesConcat = null;
coauthorBuff = null;
}
return info;
}
@Override
public void modifyDocument(Individual individual, SolrInputDocument doc, StringBuffer addUri) {
// TODO Auto-generated method stub
// calculate beta value.
log.debug("Parameter calculation starts..");
float beta = calculateBeta(individual.getURI());
doc.addField(VitroSearchTermNames.BETA, beta);
doc.setDocumentBoost(beta + doc.getDocumentBoost() );
log.debug("Parameter calculation is done");
}
public void shutdown(){
shutdown=true;
}
}
class TotalInd implements Runnable{
private Dataset dataset;
private String totalCountQuery;
private static Log log = LogFactory.getLog(TotalInd.class);
public TotalInd(Dataset dataset,String totalCountQuery){
this.dataset = dataset;
this.totalCountQuery = totalCountQuery;
}
public void run(){
int totalInd=0;
Query query;
QuerySolution soln = null;
dataset.getLock().enterCriticalSection(Lock.READ);
QueryExecution qexec = null;
try{
query = QueryFactory.create(totalCountQuery,Syntax.syntaxARQ);
qexec = QueryExecutionFactory.create(query,dataset);
ResultSet results = qexec.execSelect();
List<String> resultVars = results.getResultVars();
if(resultVars!=null && resultVars.size()!=0){
soln = results.next();
totalInd = Integer.parseInt(soln.getLiteral(resultVars.get(0)).getLexicalForm());
}
//CalculateParameters.totalInd = totalInd;
//log.info("Total number of individuals in the system are : " + CalculateParameters.totalInd);
}catch(Throwable t){
log.error(t,t);
}finally{
if( qexec != null )
qexec.close();
dataset.getLock().leaveCriticalSection();
}
}
}

View file

@ -439,9 +439,13 @@ public class FakeApplicationOntologyService {
* "display model". The query finds a preferred title for the individual. * "display model". The query finds a preferred title for the individual.
*/ */
private static class FakeVivoPeopleDataGetter extends SparqlQueryDataGetter { private static class FakeVivoPeopleDataGetter extends SparqlQueryDataGetter {
private static final String QUERY_STRING = "SELECT ?uri ?pt WHERE {\n" private static String QUERY_STRING = ""
+ " ?uri <http://vivoweb.org/ontology/core#preferredTitle> ?pt\n" + "PREFIX obo: <http://purl.obolibrary.org/obo/> \n"
+ "} LIMIT 1"; + "PREFIX vcard: <http://www.w3.org/2006/vcard/ns#> \n"
+ "SELECT ?pt \n" + "WHERE { \n"
+ " ?uri obo:ARG_2000028 ?vIndividual . \n"
+ " ?vIndividual vcard:hasTitle ?vTitle . \n"
+ " ?vTitle vcard:title ?pt . \n" + "} LIMIT 1";
private static final String FAKE_VIVO_PEOPLE_DATA_GETTER_URI = "http://FakeVivoPeopleDataGetter"; private static final String FAKE_VIVO_PEOPLE_DATA_GETTER_URI = "http://FakeVivoPeopleDataGetter";
@ -475,10 +479,10 @@ public class FakeApplicationOntologyService {
@Override @Override
public Map<String, Object> getData(Map<String, Object> pageData) { public Map<String, Object> getData(Map<String, Object> pageData) {
Map<String, String[]> parms = new HashMap<String, String[]>(); Map<String, Object> parms = new HashMap<>();
parms.put("uri", new String[] { individualUri }); parms.put("uri", individualUri);
return doQuery(parms, getModel(ctx, vreq, null)); return super.getData(parms);
} }
} }

View file

@ -79,7 +79,8 @@ public class FileGraphSetup implements ServletContextListener {
cleanupDB(dataset, pathsToURIs(paths, ABOX), ABOX); cleanupDB(dataset, pathsToURIs(paths, ABOX), ABOX);
OntModel aboxBaseModel = baseOms.getABoxModel(); OntModel aboxBaseModel = baseOms.getABoxModel();
aboxChanged = readGraphs(paths, maker, ABOX, aboxBaseModel); // Just update the ABox filegraphs in the DB; don't attach them to a base model.
aboxChanged = readGraphs(paths, maker, ABOX, /* aboxBaseModel */ null);
// TBox files // TBox files
paths = getFilegraphPaths(ctx, RDF, TBOX, FILEGRAPH); paths = getFilegraphPaths(ctx, RDF, TBOX, FILEGRAPH);
@ -108,7 +109,7 @@ public class FileGraphSetup implements ServletContextListener {
if ( (aboxChanged || tboxChanged) && !isUpdateRequired(sce.getServletContext())) { if ( (aboxChanged || tboxChanged) && !isUpdateRequired(sce.getServletContext())) {
log.info("a full recompute of the Abox will be performed because" + log.info("a full recompute of the Abox will be performed because" +
" the filegraph abox(s) and/or tbox(s) have changed or are being read for the first time." ); " the filegraph abox(s) and/or tbox(s) have changed or are being read for the first time." );
SimpleReasonerSetup.setRecomputeRequired(sce.getServletContext()); SimpleReasonerSetup.setRecomputeRequired(sce.getServletContext(), SimpleReasonerSetup.RecomputeMode.BACKGROUND);
} }
} }
@ -140,6 +141,14 @@ public class FileGraphSetup implements ServletContextListener {
return paths; return paths;
} }
/*
* Reads graphs without using submodels to separate filegraph content from the
* base model.
*/
public boolean readGraphs(Set<Path> pathSet, RDFServiceModelMaker dataset, String type, OntModel baseModel) {
return readGraphs(pathSet, dataset, type, baseModel, true);
}
/* /*
* Reads the graphs stored as files in sub-directories of * Reads the graphs stored as files in sub-directories of
* 1. updates the SDB store to reflect the current contents of the graph. * 1. updates the SDB store to reflect the current contents of the graph.
@ -148,7 +157,7 @@ public class FileGraphSetup implements ServletContextListener {
* Note: no connection needs to be maintained between the in-memory copy of the * Note: no connection needs to be maintained between the in-memory copy of the
* graph and the DB copy. * graph and the DB copy.
*/ */
public boolean readGraphs(Set<Path> pathSet, RDFServiceModelMaker dataset, String type, OntModel baseModel) { public boolean readGraphs(Set<Path> pathSet, RDFServiceModelMaker dataset, String type, OntModel baseModel, boolean useSubmodels) {
int count = 0; int count = 0;
@ -172,9 +181,14 @@ public class FileGraphSetup implements ServletContextListener {
log.warn("Ignoring " + type + " file graph " + p + " because the file extension is unrecognized."); log.warn("Ignoring " + type + " file graph " + p + " because the file extension is unrecognized.");
} }
if ( !model.isEmpty() ) { if ( !model.isEmpty() && baseModel != null ) {
if (useSubmodels) {
baseModel.addSubModel(model); baseModel.addSubModel(model);
} else {
baseModel.add(model);
}
log.info("Attached file graph as " + type + " submodel " + p.getFileName()); log.info("Attached file graph as " + type + " submodel " + p.getFileName());
} }
modelChanged = modelChanged | updateGraphInDB(dataset, model, type, p); modelChanged = modelChanged | updateGraphInDB(dataset, model, type, p);

View file

@ -87,14 +87,23 @@ public class RDFFilesLoader {
OntModel model) { OntModel model) {
OntModel everytimeModel = ModelFactory OntModel everytimeModel = ModelFactory
.createOntologyModel(OntModelSpec.OWL_MEM); .createOntologyModel(OntModelSpec.OWL_MEM);
Set<Path> paths = getPaths(locateHomeDirectory(ctx), RDF, modelPath, String home = locateHomeDirectory(ctx);
EVERY_TIME); Set<Path> paths = getPaths(home, RDF, modelPath, EVERY_TIME);
for (Path p : paths) { for (Path p : paths) {
log.info("Loading " + relativePath(p, home));
readOntologyFileIntoModel(p, everytimeModel); readOntologyFileIntoModel(p, everytimeModel);
} }
model.addSubModel(everytimeModel); model.addSubModel(everytimeModel);
} }
private static Path relativePath(Path p, String home) {
try {
return Paths.get(home).relativize(p);
} catch (Exception e) {
return p;
}
}
/** /**
* Create a model from all the RDF files in the specified directory. * Create a model from all the RDF files in the specified directory.
*/ */
@ -148,7 +157,7 @@ public class RDFFilesLoader {
private static void readOntologyFileIntoModel(Path p, Model model) { private static void readOntologyFileIntoModel(Path p, Model model) {
String format = getRdfFormat(p); String format = getRdfFormat(p);
log.info("Loading "+ p); log.debug("Loading "+ p);
try (InputStream stream = new FileInputStream(p.toFile())) { try (InputStream stream = new FileInputStream(p.toFile())) {
model.read(stream, null, format); model.read(stream, null, format);
log.debug("...successful"); log.debug("...successful");

View file

@ -12,7 +12,6 @@ import java.util.List;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener; import javax.servlet.ServletContextListener;
import javax.sql.DataSource;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -21,7 +20,6 @@ import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.vocabulary.OWL; import com.hp.hpl.jena.vocabulary.OWL;
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess; import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector; import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
@ -35,6 +33,7 @@ import edu.cornell.mannlib.vitro.webapp.reasoner.ReasonerPlugin;
import edu.cornell.mannlib.vitro.webapp.reasoner.SimpleReasoner; import edu.cornell.mannlib.vitro.webapp.reasoner.SimpleReasoner;
import edu.cornell.mannlib.vitro.webapp.reasoner.SimpleReasonerTBoxListener; import edu.cornell.mannlib.vitro.webapp.reasoner.SimpleReasonerTBoxListener;
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus; import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread;
public class SimpleReasonerSetup implements ServletContextListener { public class SimpleReasonerSetup implements ServletContextListener {
@ -117,7 +116,16 @@ public class SimpleReasonerSetup implements ServletContextListener {
assertionsOms.getTBoxModel().register(simpleReasonerTBoxListener); assertionsOms.getTBoxModel().register(simpleReasonerTBoxListener);
inferencesOms.getTBoxModel().register(simpleReasonerTBoxListener); inferencesOms.getTBoxModel().register(simpleReasonerTBoxListener);
log.info("Simple reasoner connected for the ABox"); RecomputeMode mode = getRecomputeRequired(ctx);
if (RecomputeMode.FOREGROUND.equals(mode)) {
log.info("ABox inference recompute required.");
simpleReasoner.recompute();
} else if (RecomputeMode.BACKGROUND.equals(mode)) {
log.info("starting ABox inference recompute in a separate thread.");
new VitroBackgroundThread(
new ABoxRecomputer(
simpleReasoner),"ABoxRecomputer").start();
}
} catch (Throwable t) { } catch (Throwable t) {
t.printStackTrace(); t.printStackTrace();
@ -179,15 +187,19 @@ public class SimpleReasonerSetup implements ServletContextListener {
} }
} }
public enum RecomputeMode {
FOREGROUND, BACKGROUND
}
private static final String RECOMPUTE_REQUIRED_ATTR = private static final String RECOMPUTE_REQUIRED_ATTR =
SimpleReasonerSetup.class.getName() + ".recomputeRequired"; SimpleReasonerSetup.class.getName() + ".recomputeRequired";
public static void setRecomputeRequired(ServletContext ctx) { public static void setRecomputeRequired(ServletContext ctx, RecomputeMode mode) {
ctx.setAttribute(RECOMPUTE_REQUIRED_ATTR, true); ctx.setAttribute(RECOMPUTE_REQUIRED_ATTR, mode);
} }
public static boolean isRecomputeRequired(ServletContext ctx) { public static RecomputeMode getRecomputeRequired(ServletContext ctx) {
return (ctx.getAttribute(RECOMPUTE_REQUIRED_ATTR) != null); return (RecomputeMode) ctx.getAttribute(RECOMPUTE_REQUIRED_ATTR);
} }
private static final String MSTCOMPUTE_REQUIRED_ATTR = private static final String MSTCOMPUTE_REQUIRED_ATTR =
@ -249,6 +261,18 @@ public class SimpleReasonerSetup implements ServletContextListener {
log.debug("Classnames of reasoner plugins = " + list); log.debug("Classnames of reasoner plugins = " + list);
return list; return list;
}
private class ABoxRecomputer implements Runnable {
private SimpleReasoner simpleReasoner;
public ABoxRecomputer(SimpleReasoner simpleReasoner) {
this.simpleReasoner = simpleReasoner;
}
public void run() {
simpleReasoner.recompute();
}
} }
} }

View file

@ -12,6 +12,7 @@ import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -24,6 +25,10 @@ import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec; import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.RDFNode; import com.hp.hpl.jena.rdf.model.RDFNode;
@ -42,8 +47,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.ontology.update.KnowledgeBaseUpdater; import edu.cornell.mannlib.vitro.webapp.ontology.update.KnowledgeBaseUpdater;
import edu.cornell.mannlib.vitro.webapp.ontology.update.UpdateSettings; import edu.cornell.mannlib.vitro.webapp.ontology.update.UpdateSettings;
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils; import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
import edu.cornell.mannlib.vitro.webapp.reasoner.ABoxRecomputer;
import edu.cornell.mannlib.vitro.webapp.reasoner.SimpleReasoner;
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus; import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
/** /**
@ -158,41 +161,25 @@ public class UpdateKnowledgeBase implements ServletContextListener {
} }
} }
SimpleReasoner simpleReasoner = (SimpleReasoner) sce.getServletContext() removeBadRestrictions(settings.getAssertionOntModelSelector().getTBoxModel());
.getAttribute(SimpleReasoner.class.getName());
if (simpleReasoner != null) { log.info("Simple reasoner connected for the ABox");
if ( (requiredUpdate && migrationChangesMade) if(JenaDataSourceSetupBase.isFirstStartup()
|| JenaDataSourceSetupBase.isFirstStartup()) { || (migrationChangesMade && requiredUpdate)) {
log.info("ABox inference recompute required."); SimpleReasonerSetup.setRecomputeRequired(
simpleReasoner.recompute(); ctx, SimpleReasonerSetup.RecomputeMode.FOREGROUND);
} else if (SimpleReasonerSetup.isRecomputeRequired(sce.getServletContext()) || migrationChangesMade) { } else if (migrationChangesMade) {
log.info("starting ABox inference recompute in a separate thread."); SimpleReasonerSetup.setRecomputeRequired(
new Thread( ctx, SimpleReasonerSetup.RecomputeMode.BACKGROUND);
new ABoxRecomputer(
simpleReasoner),"ABoxRecomputer").start();
}
} }
} catch (Throwable t){ } catch (Throwable t){
ss.fatal(this, "Exception updating knowledge base for ontology changes: ", t); ss.fatal(this, "Exception updating knowledge base for ontology changes: ", t);
} }
} }
private class ABoxRecomputer implements Runnable {
private SimpleReasoner simpleReasoner;
public ABoxRecomputer(SimpleReasoner simpleReasoner) {
this.simpleReasoner = simpleReasoner;
}
public void run() {
simpleReasoner.recompute();
}
}
/** /**
@ -549,6 +536,51 @@ public class UpdateKnowledgeBase implements ServletContextListener {
} }
} }
/**
* Remove restrictions with missing owl:onProperty or obsolete core class
* This should be worked into the main migration later.
*/
private void removeBadRestrictions(Model tboxModel) {
List<String> queryStrs = Arrays.asList("PREFIX owl: <http://www.w3.org/2002/07/owl#> \n " +
"CONSTRUCT { \n" +
" ?rest ?p ?o . \n" +
" ?oo ?pp ?rest \n" +
"} WHERE { \n" +
" ?rest a owl:Restriction . \n" +
" FILTER NOT EXISTS { ?rest owl:onProperty ?x } \n" +
" ?rest ?p ?o . \n" +
" ?oo ?pp ?rest \n" +
"} \n" ,
"PREFIX owl: <http://www.w3.org/2002/07/owl#> \n " +
"CONSTRUCT { \n" +
" ?rest ?p ?o . \n" +
" ?oo ?pp ?rest \n" +
"} WHERE { \n" +
" ?rest a owl:Restriction . \n" +
" { ?rest owl:someValuesFrom ?c } UNION { ?rest owl:allValuesFrom ?c } \n" +
" FILTER (regex(str(?c), \"vivoweb.org\")) \n" +
" FILTER NOT EXISTS { ?c ?cp ?co } \n" +
" ?rest ?p ?o . \n" +
" ?oo ?pp ?rest \n" +
"} \n" );
for (String queryStr : queryStrs) {
Query query = QueryFactory.create(queryStr);
QueryExecution qe = QueryExecutionFactory.create(query, tboxModel);
try {
Model bad = qe.execConstruct();
tboxModel.remove(bad);
if (bad.size() > 0) {
log.info("Deleted " + bad.size() +
" triples of syntactically invalid restrictions");
}
} finally {
if (qe != null) {
qe.close();
}
}
}
}
@Override @Override
public void contextDestroyed(ServletContextEvent arg0) { public void contextDestroyed(ServletContextEvent arg0) {
// nothing to do // nothing to do

View file

@ -83,7 +83,7 @@ public class ApplicationConfigurationOntologyUtils {
String rangeURI = qsoln.getResource("range").getURI(); String rangeURI = qsoln.getResource("range").getURI();
if (appropriateDomain(domainRes, subject, tboxModel)) { if (appropriateDomain(domainRes, subject, tboxModel)) {
ObjectProperty faux = opDao.getObjectPropertyByURIs( ObjectProperty faux = opDao.getObjectPropertyByURIs(
opURI, domainURI, rangeURI); opURI, domainURI, rangeURI, (prop != null) ? prop.clone() : null);
if (faux != null) { if (faux != null) {
additionalProps.add(faux); additionalProps.add(faux);
} else { } else {

View file

@ -3,10 +3,7 @@ package edu.cornell.mannlib.vitro.webapp.utils.dataGetter;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.net.URLEncoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -17,7 +14,6 @@ import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import com.hp.hpl.jena.query.Query; import com.hp.hpl.jena.query.Query;
@ -35,20 +31,13 @@ import com.hp.hpl.jena.rdf.model.ResourceFactory;
import com.hp.hpl.jena.shared.Lock; import com.hp.hpl.jena.shared.Lock;
import com.hp.hpl.jena.vocabulary.OWL; import com.hp.hpl.jena.vocabulary.OWL;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup; import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController.PageRecord;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
import edu.cornell.mannlib.vitro.webapp.controller.json.JsonServlet;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupsForRequest; import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupsForRequest;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache; import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache;
@ -324,123 +313,6 @@ public class DataGetterUtils {
return classGroupUri; return classGroupUri;
} }
/**
* Process results related to VClass or vclasses. Handles both single and multiple vclasses being sent.
*/
public static JSONObject processVclassResultsJSON(Map<String, Object> map, VitroRequest vreq, boolean multipleVclasses) {
JSONObject rObj = new JSONObject();
VClass vclass=null;
try {
// Properties from ontologies used by VIVO - should not be in vitro
DataProperty fNameDp = (new DataProperty());
fNameDp.setURI("http://xmlns.com/foaf/0.1/firstName");
DataProperty lNameDp = (new DataProperty());
lNameDp.setURI("http://xmlns.com/foaf/0.1/lastName");
DataProperty preferredTitleDp = (new DataProperty());
preferredTitleDp.setURI("http://vivoweb.org/ontology/core#preferredTitle");
if( log.isDebugEnabled() ){
@SuppressWarnings("unchecked")
Enumeration<String> e = vreq.getParameterNames();
while(e.hasMoreElements()){
String name = e.nextElement();
log.debug("parameter: " + name);
for( String value : vreq.getParameterValues(name) ){
log.debug("value for " + name + ": '" + value + "'");
}
}
}
//need an unfiltered dao to get firstnames and lastnames
WebappDaoFactory fullWdf = vreq.getUnfilteredWebappDaoFactory();
String[] vitroClassIdStr = vreq.getParameterValues("vclassId");
if ( vitroClassIdStr != null && vitroClassIdStr.length > 0){
for(String vclassId: vitroClassIdStr) {
vclass = vreq.getWebappDaoFactory().getVClassDao().getVClassByURI(vclassId);
if (vclass == null) {
log.error("Couldn't retrieve vclass ");
throw new Exception ("Class " + vclassId + " not found");
}
}
}else{
log.error("parameter vclassId URI parameter expected ");
throw new Exception("parameter vclassId URI parameter expected ");
}
List<String> vclassIds = Arrays.asList(vitroClassIdStr);
//if single vclass expected, then include vclass. This relates to what the expected behavior is, not size of list
if(!multipleVclasses) {
//currently used for ClassGroupPage
rObj.put("vclass",
new JSONObject().put("URI",vclass.getURI())
.put("name",vclass.getName()));
} else {
//For now, utilize very last VClass (assume that that is the one to be employed)
//TODO: Find more general way of dealing with this
//put multiple ones in?
if(vclassIds.size() > 0) {
int numberVClasses = vclassIds.size();
vclass = vreq.getWebappDaoFactory().getVClassDao().getVClassByURI(vclassIds.get(numberVClasses - 1));
rObj.put("vclass", new JSONObject().put("URI",vclass.getURI())
.put("name",vclass.getName()));
}
// rObj.put("vclasses", new JSONObject().put("URIs",vitroClassIdStr)
// .put("name",vclass.getName()));
}
if (vclass != null) {
rObj.put("totalCount", map.get("totalCount"));
rObj.put("alpha", map.get("alpha"));
List<Individual> inds = (List<Individual>)map.get("entities");
log.debug("Number of individuals returned from request: " + inds.size());
JSONArray jInds = new JSONArray();
for(Individual ind : inds ){
JSONObject jo = new JSONObject();
jo.put("URI", ind.getURI());
jo.put("label",ind.getRdfsLabel());
jo.put("name",ind.getName());
jo.put("thumbUrl", ind.getThumbUrl());
jo.put("imageUrl", ind.getImageUrl());
jo.put("profileUrl", UrlBuilder.getIndividualProfileUrl(ind, vreq));
jo.put("mostSpecificTypes", JsonServlet.getMostSpecificTypes(ind,fullWdf));
jo.put("preferredTitle", JsonServlet.getDataPropertyValue(ind, preferredTitleDp, fullWdf));
jInds.put(jo);
}
rObj.put("individuals", jInds);
JSONArray wpages = new JSONArray();
//Made sure that PageRecord here is SolrIndividualListController not IndividualListController
List<PageRecord> pages = (List<PageRecord>)map.get("pages");
for( PageRecord pr: pages ){
JSONObject p = new JSONObject();
p.put("text", pr.text);
p.put("param", pr.param);
p.put("index", pr.index);
wpages.put( p );
}
rObj.put("pages",wpages);
JSONArray jletters = new JSONArray();
List<String> letters = Controllers.getLetters();
for( String s : letters){
JSONObject jo = new JSONObject();
jo.put("text", s);
jo.put("param", "alpha=" + URLEncoder.encode(s, "UTF-8"));
jletters.put( jo );
}
rObj.put("letters", jletters);
}
} catch(Exception ex) {
log.error("Error occurred in processing JSON object", ex);
}
return rObj;
}
private static final String forClassGroupURI = "<" + DisplayVocabulary.FOR_CLASSGROUP + ">"; private static final String forClassGroupURI = "<" + DisplayVocabulary.FOR_CLASSGROUP + ">";
private static final String classGroupForDataGetterQuery = private static final String classGroupForDataGetterQuery =

View file

@ -353,11 +353,12 @@ public class IndividualsForClassesDataGetter extends DataGetterBase implements D
public String getDataServiceUrl() { public String getDataServiceUrl() {
return UrlBuilder.getUrl("/dataservice?getRenderedSolrIndividualsByVClass=1&vclassId="); return UrlBuilder.getUrl("/dataservice?getRenderedSolrIndividualsByVClass=1&vclassId=");
} }
/** /**
* For processig of JSONObject * For processig of JSONObject
*/ */
public JSONObject convertToJSON(Map<String, Object> map, VitroRequest vreq) { public JSONObject convertToJSON(Map<String, Object> dataMap, VitroRequest vreq) {
JSONObject rObj = DataGetterUtils.processVclassResultsJSON(map, vreq, true); JSONObject rObj = null;
return rObj; return rObj;
} }

View file

@ -3,9 +3,7 @@ package edu.cornell.mannlib.vitro.webapp.utils.dataGetter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -23,7 +21,6 @@ import com.hp.hpl.jena.query.QuerySolutionMap;
import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.ResourceFactory; import com.hp.hpl.jena.rdf.model.ResourceFactory;
import com.hp.hpl.jena.shared.Lock; import com.hp.hpl.jena.shared.Lock;
@ -33,8 +30,9 @@ import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup; import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController.SearchException; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController.SearchException;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
import edu.cornell.mannlib.vitro.webapp.controller.individuallist.IndividualListResults;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
import edu.cornell.mannlib.vitro.webapp.utils.solr.SolrQueryUtils; import edu.cornell.mannlib.vitro.webapp.utils.solr.SolrQueryUtils;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individuallist.ListedIndividual; import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individuallist.ListedIndividual;
@ -174,16 +172,15 @@ public class SolrIndividualsDataGetter extends DataGetterBase implements DataGet
try { try {
String alpha = SolrQueryUtils.getAlphaParameter(vreq); String alpha = SolrQueryUtils.getAlphaParameter(vreq);
int page = SolrQueryUtils.getPageParameter(vreq); int page = SolrQueryUtils.getPageParameter(vreq);
Map<String,Object> map = IndividualListController.getResultsForVClass( IndividualListResults vcResults = IndividualListController.getResultsForVClass(
vclass.getURI(), vclass.getURI(),
page, page,
alpha, alpha,
vreq.getWebappDaoFactory().getIndividualDao(), vreq.getWebappDaoFactory().getIndividualDao(),
vreq.getSession().getServletContext()); vreq.getSession().getServletContext());
body.putAll(map); body.putAll(vcResults.asFreemarkerMap());
@SuppressWarnings("unchecked") List<Individual> inds = vcResults.getEntities();
List<Individual> inds = (List<Individual>)map.get("entities");
List<ListedIndividual> indsTm = new ArrayList<ListedIndividual>(); List<ListedIndividual> indsTm = new ArrayList<ListedIndividual>();
if (inds != null) { if (inds != null) {
for ( Individual ind : inds ) { for ( Individual ind : inds ) {

View file

@ -29,8 +29,18 @@ import com.hp.hpl.jena.shared.Lock;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
public class SparqlQueryDataGetter extends DataGetterBase implements DataGetter{ public class SparqlQueryDataGetter extends DataGetterBase implements DataGetter{
private final static Log log = LogFactory.getLog(SparqlQueryDataGetter.class);
private static final String queryPropertyURI = "<" + DisplayVocabulary.QUERY + ">";
private static final String saveToVarPropertyURI= "<" + DisplayVocabulary.SAVE_TO_VAR+ ">";
private static final String queryModelPropertyURI= "<" + DisplayVocabulary.QUERY_MODEL+ ">";
public static final String defaultVarNameForResults = "results";
private static final String defaultTemplate = "menupage--defaultSparql.ftl";
String dataGetterURI; String dataGetterURI;
String queryText; String queryText;
String saveToVar; String saveToVar;
@ -38,11 +48,6 @@ public class SparqlQueryDataGetter extends DataGetterBase implements DataGetter{
VitroRequest vreq; VitroRequest vreq;
ServletContext context; ServletContext context;
final static Log log = LogFactory.getLog(SparqlQueryDataGetter.class);
//default template
private final static String defaultTemplate = "menupage--defaultSparql.ftl";
/** /**
* Constructor with display model and data getter URI that will be called by reflection. * Constructor with display model and data getter URI that will be called by reflection.
*/ */
@ -50,20 +55,10 @@ public class SparqlQueryDataGetter extends DataGetterBase implements DataGetter{
this.configure(vreq, displayModel,dataGetterURI); this.configure(vreq, displayModel,dataGetterURI);
} }
@Override
public Map<String, Object> getData(Map<String, Object> pageData) {
// Merge the pageData with the request parameters. PageData overrides
Map<String, String[]> merged = new HashMap<String, String[]>();
merged.putAll(vreq.getParameterMap());
for (String key: pageData.keySet()) {
merged.put(key, new String[] {String.valueOf(pageData.get(key))});
}
return doQuery( merged, getModel(context, vreq, modelURI));
}
/** /**
* Configure this instance based on the URI and display model. * Configure this instance based on the URI and display model.
*/ */
@SuppressWarnings("hiding")
protected void configure(VitroRequest vreq, Model displayModel, String dataGetterURI) { protected void configure(VitroRequest vreq, Model displayModel, String dataGetterURI) {
if( vreq == null ) if( vreq == null )
throw new IllegalArgumentException("VitroRequest may not be null."); throw new IllegalArgumentException("VitroRequest may not be null.");
@ -79,7 +74,6 @@ public class SparqlQueryDataGetter extends DataGetterBase implements DataGetter{
QuerySolutionMap initBindings = new QuerySolutionMap(); QuerySolutionMap initBindings = new QuerySolutionMap();
initBindings.add("dataGetterURI", ResourceFactory.createResource(this.dataGetterURI)); initBindings.add("dataGetterURI", ResourceFactory.createResource(this.dataGetterURI));
int count = 0;
Query dataGetterConfigurationQuery = QueryFactory.create(dataGetterQuery) ; Query dataGetterConfigurationQuery = QueryFactory.create(dataGetterQuery) ;
displayModel.enterCriticalSection(Lock.READ); displayModel.enterCriticalSection(Lock.READ);
try{ try{
@ -88,7 +82,6 @@ public class SparqlQueryDataGetter extends DataGetterBase implements DataGetter{
ResultSet res = qexec.execSelect(); ResultSet res = qexec.execSelect();
try{ try{
while( res.hasNext() ){ while( res.hasNext() ){
count++;
QuerySolution soln = res.next(); QuerySolution soln = res.next();
//query is NOT OPTIONAL //query is NOT OPTIONAL
@ -121,52 +114,124 @@ public class SparqlQueryDataGetter extends DataGetterBase implements DataGetter{
} }
/** /**
* Do the query and return a result. This is in its own method * Query to get the definition of the SparqlDataGetter for a given URI.
* to make testing easy.
*/ */
protected Map<String, Object> doQuery(Map<String, String[]>parameterMap, Model queryModel){ private static final String dataGetterQuery =
"PREFIX display: <" + DisplayVocabulary.DISPLAY_NS +"> \n" +
"SELECT ?query ?saveToVar ?queryModel WHERE { \n" +
" ?dataGetterURI "+queryPropertyURI+" ?query . \n" +
" OPTIONAL{ ?dataGetterURI "+saveToVarPropertyURI+" ?saveToVar } \n " +
" OPTIONAL{ ?dataGetterURI "+queryModelPropertyURI+" ?queryModel } \n" +
"}";
if( this.queryText == null ){
log.error("no SPARQL query defined for page " + this.dataGetterURI); @Override
public Map<String, Object> getData(Map<String, Object> pageData) {
Map<String, String> merged = mergeParameters(vreq.getParameterMap(), pageData);
String boundQueryText = bindParameters(queryText, merged);
if (modelURI != null) {
return doQueryOnModel(boundQueryText, getModel(context, vreq, modelURI));
} else {
return doQueryOnRDFService(boundQueryText);
}
}
/** Merge the pageData with the request parameters. PageData overrides. */
private Map<String, String> mergeParameters(
Map<String, String[]> parameterMap, Map<String, Object> pageData) {
Map<String, String> merged = new HashMap<>();
for (String key: parameterMap.keySet()) {
merged.put(key, parameterMap.get(key)[0]);
}
for (String key: pageData.keySet()) {
merged.put(key, String.valueOf(pageData.get(key)));
}
if (log.isDebugEnabled()) {
log.debug("Merging request parameters " + parameterMap
+ " with page data " + pageData + " results in " + merged);
}
return merged;
}
/**
* InitialBindings don't always work, and besides, RDFService doesn't accept
* them. So do a text-based substitution.
*
* This assumes that every parameter is a URI. What if we want to substitute
* a string value?
*/
private String bindParameters(String text, Map<String, String> merged) {
String bound = text;
for (String key : merged.keySet()) {
bound = bound.replace('?' + key, '<' + merged.get(key) + '>');
}
if (log.isDebugEnabled()) {
log.debug("parameters: " + merged);
log.debug("query before binding parameters:" + text);
log.debug("query after binding parameters: " + bound);
}
return bound;
}
/**
* Do the query and return a result. This is in its own method, with
* protected access, to make testing easy.
*/
protected Map<String, Object> doQueryOnRDFService(String q) {
log.debug("Going to RDFService with " + q);
ResultSet results = QueryUtils.getQueryResults(q, vreq);
return assembleMap(parseResults(results));
}
/**
* Do the query and return a result. This is in its own method, with
* protected access, to make testing easy.
*/
protected Map<String, Object> doQueryOnModel(String q, Model queryModel){
log.debug("Going to model " + modelURI + " with " + q);
if (q == null) {
return Collections.emptyMap(); return Collections.emptyMap();
} }
//this may throw a SPARQL syntax error Query query = makeQuery(q);
Query query = QueryFactory.create( this.queryText ); if (query == null) {
return Collections.emptyMap();
//build query bindings
QuerySolutionMap initialBindings = createBindings( parameterMap);
//execute query
List<Map<String,String>> results = executeQuery( query, queryModel, initialBindings);
//put results in page data, what key to use for results?
Map<String, Object> rmap = new HashMap<String,Object>();
//also store the variable name within which results will be returned
rmap.put("variableName", this.saveToVar);
rmap.put(this.saveToVar, results);
//This will be overridden at page level in display model if template specified there
rmap.put("bodyTemplate", defaultTemplate);
return rmap;
} }
private List<Map<String, String>> executeQuery(Query query, Model model, return assembleMap(executeQuery( query, queryModel));
QuerySolutionMap initialBindings) { }
List<Map<String,String>> rows = new ArrayList<Map<String,String>>(); private Query makeQuery(String q) {
try {
return QueryFactory.create(q);
} catch (Exception e) {
log.error("Failed to build a query from ''", e);
return null;
}
}
private List<Map<String, String>> executeQuery(Query query, Model model) {
model.enterCriticalSection(Lock.READ); model.enterCriticalSection(Lock.READ);
try{ try{
QueryExecution qexec= QueryExecutionFactory.create(query, model,initialBindings ); QueryExecution qexec= QueryExecutionFactory.create(query, model );
ResultSet results = qexec.execSelect(); ResultSet results = qexec.execSelect();
try{ try{
return parseResults(results);
}finally{ qexec.close(); }
}finally{ model.leaveCriticalSection(); }
}
/**
* Converts a ResultSet into a List of Maps.
*/
private List<Map<String, String>> parseResults(ResultSet results) {
List<Map<String,String>> rows = new ArrayList<Map<String,String>>();
while (results.hasNext()) { while (results.hasNext()) {
QuerySolution soln = results.nextSolution(); QuerySolution soln = results.nextSolution();
rows.add( toRow( soln ) ); rows.add( toRow( soln ) );
} }
}finally{ qexec.close(); }
}finally{ model.leaveCriticalSection(); }
return rows; return rows;
} }
@ -186,8 +251,8 @@ public class SparqlQueryDataGetter extends DataGetterBase implements DataGetter{
private String toCell(RDFNode rdfNode) { private String toCell(RDFNode rdfNode) {
if( rdfNode == null){ if( rdfNode == null){
return ""; return "";
}else if( rdfNode.canAs( Literal.class )){ }else if( rdfNode.isLiteral() ){
return ((Literal)rdfNode.as(Literal.class)).getLexicalForm(); return rdfNode.asLiteral().getLexicalForm();
}else if( rdfNode.isResource() ){ }else if( rdfNode.isResource() ){
Resource resource = (Resource)rdfNode; Resource resource = (Resource)rdfNode;
if( ! resource.isAnon() ){ if( ! resource.isAnon() ){
@ -200,40 +265,17 @@ public class SparqlQueryDataGetter extends DataGetterBase implements DataGetter{
} }
} }
private Map<String, Object> assembleMap(List<Map<String, String>> results) {
Map<String, Object> rmap = new HashMap<String,Object>();
//put results in page data
rmap.put(this.saveToVar, results);
//also store the variable name within which results will be returned
rmap.put("variableName", this.saveToVar);
//This will be overridden at page level in display model if template specified there
rmap.put("bodyTemplate", defaultTemplate);
private QuerySolutionMap createBindings(Map<String, String[]>parameterMap) { return rmap;
QuerySolutionMap initBindings = new QuerySolutionMap();
//could have bindings from HTTP parameters
for( String var : parameterMap.keySet() ) {
String[] values = parameterMap.get(var);
if( values != null && values.length == 1 ){
//what do do when we don't want a Resource?
initBindings.add(var, ResourceFactory.createResource(values[0]) );
}else if( values.length > 1){
log.error("more than 1 http parameter for " + var);
}
}
return initBindings;
} }
private static final String queryPropertyURI = "<" + DisplayVocabulary.QUERY + ">";
private static final String saveToVarPropertyURI= "<" + DisplayVocabulary.SAVE_TO_VAR+ ">";
private static final String queryModelPropertyURI= "<" + DisplayVocabulary.QUERY_MODEL+ ">";
public static final String defaultVarNameForResults = "results";
/**
* Query to get the definition of the SparqlDataGetter for a given URI.
*/
private static final String dataGetterQuery =
"PREFIX display: <" + DisplayVocabulary.DISPLAY_NS +"> \n" +
"SELECT ?query ?saveToVar ?queryModel WHERE { \n" +
" ?dataGetterURI "+queryPropertyURI+" ?query . \n" +
" OPTIONAL{ ?dataGetterURI "+saveToVarPropertyURI+" ?saveToVar } \n " +
" OPTIONAL{ ?dataGetterURI "+queryModelPropertyURI+" ?queryModel } \n" +
"}";
} }

View file

@ -0,0 +1,44 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.utils.fields;
import java.util.HashSet;
import java.util.List;
import java.util.ListIterator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
public class FieldUtils {
private static final Log log = LogFactory.getLog(FieldUtils.class);
// copied from OptionsForPropertyTag.java in the thought that class may be deprecated
public static List<Individual> removeIndividualsAlreadyInRange(List<Individual> individuals,
List<ObjectPropertyStatement> stmts, String predicateUri, String objectUriBeingEdited){
HashSet<String> range = new HashSet<String>();
for(ObjectPropertyStatement ops : stmts){
if( ops.getPropertyURI().equals(predicateUri))
range.add( ops.getObjectURI() );
}
int removeCount=0;
ListIterator<Individual> it = individuals.listIterator();
while(it.hasNext()){
Individual ind = it.next();
if( range.contains( ind.getURI()) && !(ind.getURI().equals(objectUriBeingEdited)) ) {
it.remove();
++removeCount;
}
}
return individuals;
}
}

View file

@ -4,8 +4,6 @@ package edu.cornell.mannlib.vitro.webapp.utils.solr;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -20,9 +18,7 @@ import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.client.solrj.response.QueryResponse;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListQueryResults; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListQueryResults;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController.SearchException;
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao; import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames; import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
import edu.cornell.mannlib.vitro.webapp.search.solr.SolrSetup; import edu.cornell.mannlib.vitro.webapp.search.solr.SolrSetup;

View file

@ -367,6 +367,14 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
return editConfig.getObject(); return editConfig.getObject();
} }
public String getDomainUri() {
return EditConfigurationUtils.getDomainUri(vreq);
}
public String getRangeUri() {
return EditConfigurationUtils.getRangeUri(vreq);
}
//data literal //data literal
//Thus would depend on the literals on the form //Thus would depend on the literals on the form
@ -666,7 +674,13 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
//this url is for canceling //this url is for canceling
public String getCancelUrl() { public String getCancelUrl() {
String editKey = editConfig.getEditKey(); String editKey = editConfig.getEditKey();
return EditConfigurationUtils.getCancelUrlBase(vreq) + "?editKey=" + editKey + "&cancel=true"; String cancelURL = EditConfigurationUtils.getCancelUrlBase(vreq) + "?editKey=" + editKey + "&cancel=true";
//Check for special return url parameter
String returnURLParameter = vreq.getParameter("returnURL");
if(returnURLParameter != null && !returnURLParameter.isEmpty() ) {
cancelURL += "&returnURL=" + returnURLParameter;
}
return cancelURL;
} }
//Get confirm deletion url //Get confirm deletion url

View file

@ -2,6 +2,10 @@
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual; package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants.SOME_LITERAL;
import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants.SOME_PREDICATE;
import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants.SOME_URI;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -16,7 +20,6 @@ import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission; import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper; import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddDataPropertyStatement; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddDataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddObjectPropertyStatement; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement; import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
@ -116,11 +119,10 @@ public abstract class BaseIndividualTemplateModel extends BaseTemplateModel {
public boolean isEditable() { public boolean isEditable() {
AddDataPropertyStatement adps = new AddDataPropertyStatement( AddDataPropertyStatement adps = new AddDataPropertyStatement(
vreq.getJenaOntModel(), individual.getURI(), vreq.getJenaOntModel(), individual.getURI(),
RequestActionConstants.SOME_URI); SOME_URI, SOME_LITERAL);
AddObjectPropertyStatement aops = new AddObjectPropertyStatement( AddObjectPropertyStatement aops = new AddObjectPropertyStatement(
vreq.getJenaOntModel(), individual.getURI(), vreq.getJenaOntModel(), individual.getURI(),
RequestActionConstants.SOME_PREDICATE, SOME_PREDICATE, SOME_URI);
RequestActionConstants.SOME_URI);
return PolicyHelper.isAuthorizedForActions(vreq, new Actions(adps).or(aops)); return PolicyHelper.isAuthorizedForActions(vreq, new Actions(adps).or(aops));
} }

View file

@ -2,6 +2,8 @@
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual; package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants.SOME_LITERAL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -118,7 +120,7 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
// Determine whether a new statement can be added // Determine whether a new statement can be added
RequestedAction action = new AddDataPropertyStatement( RequestedAction action = new AddDataPropertyStatement(
vreq.getJenaOntModel(), subjectUri, propertyUri); vreq.getJenaOntModel(), subjectUri, propertyUri, SOME_LITERAL);
if ( ! PolicyHelper.isAuthorizedForActions(vreq, action) ) { if ( ! PolicyHelper.isAuthorizedForActions(vreq, action) ) {
return; return;
} }

View file

@ -6,8 +6,10 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -74,12 +76,22 @@ public class GroupedPropertyList extends BaseTemplateModel {
List<ObjectProperty> populatedObjectPropertyList = subject List<ObjectProperty> populatedObjectPropertyList = subject
.getPopulatedObjectPropertyList(); .getPopulatedObjectPropertyList();
Map<String, List<String>> populatedObjTypes = makePopulatedObjTypeMap(
populatedObjectPropertyList);
// save applicable ranges before deduping to filter later
populatedObjectPropertyList = dedupe(populatedObjectPropertyList);
Collection<ObjectProperty> additions = ApplicationConfigurationOntologyUtils Collection<ObjectProperty> additions = ApplicationConfigurationOntologyUtils
.getAdditionalFauxSubpropertiesForList( .getAdditionalFauxSubpropertiesForList(
populatedObjectPropertyList, subject, vreq); populatedObjectPropertyList, subject, vreq);
additions = filterAdditions(additions, populatedObjTypes);
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
for (ObjectProperty t : additions) { for (ObjectProperty t : additions) {
log.debug(t.getDomainPublic() + " " + t.getGroupURI() + " domain " + t.getDomainVClassURI()); log.debug(t.getDomainPublic() + " " + t.getGroupURI() + " domain " +
t.getDomainVClassURI());
} }
log.debug("Added " + additions.size() + log.debug("Added " + additions.size() +
" properties due to application configuration ontology"); " properties due to application configuration ontology");
@ -93,7 +105,7 @@ public class GroupedPropertyList extends BaseTemplateModel {
// unpopulated, so the properties are displayed to allow statements to be added to these properties. // unpopulated, so the properties are displayed to allow statements to be added to these properties.
// RY In future, we should limit this to properties that the user has permission to add properties to. // RY In future, we should limit this to properties that the user has permission to add properties to.
if (editing) { if (editing) {
mergeAllPossibleObjectProperties(populatedObjectPropertyList, propertyList); propertyList = mergeAllPossibleObjectProperties(populatedObjectPropertyList, propertyList);
} }
// Now do much the same with data properties: get the list of populated data properties, then add in placeholders for missing ones // Now do much the same with data properties: get the list of populated data properties, then add in placeholders for missing ones
@ -110,7 +122,12 @@ public class GroupedPropertyList extends BaseTemplateModel {
mergeAllPossibleDataProperties(propertyList); mergeAllPossibleDataProperties(propertyList);
} }
propertyList = correctLanguageForProperties(propertyList); // Not currently necessary since the language-specific version is now added
// during the merge
// if (editing) {
// propertyList = correctLanguageForProperties(propertyList);
// }
sort(propertyList); sort(propertyList);
// Put the list into groups // Put the list into groups
@ -131,6 +148,34 @@ public class GroupedPropertyList extends BaseTemplateModel {
} }
private Map<String, List<String>> makePopulatedObjTypeMap(List<ObjectProperty> props) {
Map<String, List<String>> map = new HashMap<String, List<String>>();
for (ObjectProperty prop : props) {
if(prop.getRangeVClassURI() != null) {
List<String> typeList = map.get(prop.getURI());
if(typeList == null) {
typeList = new ArrayList<String>();
map.put(prop.getURI(), typeList);
}
typeList.add(prop.getRangeVClassURI());
}
}
return map;
}
private List<ObjectProperty> filterAdditions(Collection<ObjectProperty> additions,
Map<String, List<String>> populatedObjTypes) {
List<ObjectProperty> filteredAdditions = new ArrayList<ObjectProperty>();
for (ObjectProperty prop : additions) {
List<String> allowedTypes = populatedObjTypes.get(prop.getURI());
if(allowedTypes != null && (allowedTypes.contains(prop.getRangeVClassURI())
|| allowedTypes.contains(prop.getRangeEntityURI()) ) ) {
filteredAdditions.add(prop);
}
}
return filteredAdditions;
}
// Use the language-filtering WebappDaoFactory to get the right version of // Use the language-filtering WebappDaoFactory to get the right version of
// each property. When editing, the methods that add to the property list // each property. When editing, the methods that add to the property list
// are blissfully (and intentionally) language-unaware. // are blissfully (and intentionally) language-unaware.
@ -188,6 +233,19 @@ public class GroupedPropertyList extends BaseTemplateModel {
} }
} }
//assumes sorted list
protected List<ObjectProperty> dedupe(List<ObjectProperty> propList) {
List<ObjectProperty> dedupedList = new ArrayList<ObjectProperty>();
String uriRegister = "";
for (ObjectProperty prop : propList) {
if(!uriRegister.equals(prop.getURI())) {
uriRegister = prop.getURI();
dedupedList.add(prop);
}
}
return dedupedList;
}
protected void sort(List<Property> propertyList) { protected void sort(List<Property> propertyList) {
try { try {
Collections.sort(propertyList, new PropertyRanker(vreq)); Collections.sort(propertyList, new PropertyRanker(vreq));
@ -197,7 +255,7 @@ public class GroupedPropertyList extends BaseTemplateModel {
} }
} }
private void mergeAllPossibleObjectProperties( private List<Property> mergeAllPossibleObjectProperties(
List<ObjectProperty> populatedObjectPropertyList, List<ObjectProperty> populatedObjectPropertyList,
List<Property> propertyList) { List<Property> propertyList) {
@ -215,10 +273,27 @@ public class GroupedPropertyList extends BaseTemplateModel {
if (allPropInstColl != null) { if (allPropInstColl != null) {
for (PropertyInstance pi : allPropInstColl) { for (PropertyInstance pi : allPropInstColl) {
if (pi != null) { if (pi != null) {
if (!alreadyOnObjectPropertyList( // use the language-aware wdf because redundancy check
populatedObjectPropertyList, pi)) { // for display will depend on public label match
addObjectPropertyToPropertyList(pi.getPropertyURI(), pi.getDomainClassURI(), pi.getRangeClassURI(), ObjectProperty piOp = wdf.getObjectPropertyDao().getObjectPropertyByURIs(
propertyList); pi.getPropertyURI(), pi.getDomainClassURI(), pi.getRangeClassURI());
if (piOp == null) {
continue;
}
boolean addToList = true;
int opIndex = 0;
for(ObjectProperty op : populatedObjectPropertyList) {
if(redundant(op, piOp)) {
addToList = false;
if (moreRestrictiveRange(piOp, op, wadf)) {
propertyList = replaceOpWithPiOpInList(piOp, op, opIndex, propertyList);
}
break;
}
opIndex++;
}
if(addToList) {
propertyList.add(piOp);
} }
} else { } else {
log.error("a property instance in the Collection created by PropertyInstanceDao.getAllPossiblePropInstForIndividual() is unexpectedly null"); log.error("a property instance in the Collection created by PropertyInstanceDao.getAllPossiblePropInstForIndividual() is unexpectedly null");
@ -236,31 +311,74 @@ public class GroupedPropertyList extends BaseTemplateModel {
addObjectPropertyToPropertyList(propertyUri, null, null, propertyList); addObjectPropertyToPropertyList(propertyUri, null, null, propertyList);
} }
} }
return propertyList;
} }
private boolean alreadyOnObjectPropertyList(List<ObjectProperty> opList, private boolean moreRestrictiveRange(ObjectProperty piOp, ObjectProperty op,
PropertyInstance pi) { WebappDaoFactory wadf) {
if (pi.getPropertyURI() == null) { if(piOp.getRangeVClassURI() == null) {
return false;
} else if (op.getRangeVClassURI() == null) {
return (piOp.getRangeVClassURI() != null);
} else {
return (wadf.getVClassDao().isSubClassOf(
piOp.getRangeVClassURI(), op.getRangeVClassURI()));
}
}
private List<Property> replaceOpWithPiOpInList(ObjectProperty piOp,
ObjectProperty op, int opIndex, List<Property> propertyList) {
List<Property> returnList = new ArrayList<Property>();
int index = 0;
for(Property p : propertyList) {
if(index == opIndex /* p.equals(op) */) {
returnList.add(piOp);
} else {
returnList.add(p);
}
index++;
}
return returnList;
}
private boolean redundant(ObjectProperty op, ObjectProperty op2) {
if (op2.getURI() == null) {
return false; return false;
} }
for (ObjectProperty op : opList) { boolean uriMatches = (op.getURI() != null
if (op.getURI() != null && op.getURI().equals(pi.getPropertyURI())) { && op.getURI().equals(op2.getURI()));
if(op.getDomainVClassURI() == null) { boolean domainMatches = false;
if(pi.getDomainClassURI() == null) { boolean rangeMatches = false;
boolean labelMatches = false;
if(op.getDomainPublic() == null) {
if(op2.getDomainPublic() == null) {
labelMatches = true;
}
} else if (op.getDomainPublic().equals(op2.getDomainPublic())) {
labelMatches = true;
}
if(uriMatches && labelMatches) {
return true; return true;
} }
} else if (op.getDomainVClassURI().equals(pi.getDomainClassURI())) { if(op.getDomainVClassURI() == null) {
return true; if(op2.getDomainVClassURI() == null) {
domainMatches = true;
}
} else if (op.getDomainVClassURI().equals(op2.getDomainVClassURI())) {
domainMatches = true;
} }
if(op.getRangeVClassURI() == null) { if(op.getRangeVClassURI() == null) {
if (pi.getDomainClassURI() == null) { if (op2.getRangeVClassURI() == null) {
rangeMatches = true;
}
} else if (op.getRangeVClassURI().equals(op2.getRangeVClassURI())) {
rangeMatches = true;
}
if (uriMatches && domainMatches && rangeMatches) {
return true; return true;
} }
} else if (op.getRangeVClassURI().equals(pi.getRangeClassURI())) {
return true;
}
}
}
return false; return false;
} }
@ -325,10 +443,12 @@ public class GroupedPropertyList extends BaseTemplateModel {
// Get the property groups // Get the property groups
PropertyGroupDao pgDao = wdf.getPropertyGroupDao(); PropertyGroupDao pgDao = wdf.getPropertyGroupDao();
long start = System.currentTimeMillis();
List<PropertyGroup> groupList = pgDao.getPublicGroups(false); // may be returned empty but not null List<PropertyGroup> groupList = pgDao.getPublicGroups(false); // may be returned empty but not null
// To test no property groups defined, use: // To test no property groups defined, use:
// List<PropertyGroup> groupList = new ArrayList<PropertyGroup>(); // List<PropertyGroup> groupList = new ArrayList<PropertyGroup>();
start = System.currentTimeMillis();
int groupCount = groupList.size(); int groupCount = groupList.size();
/* /*
@ -377,6 +497,7 @@ public class GroupedPropertyList extends BaseTemplateModel {
log.error("Exception on trying to prune unpopulated groups from group list: " log.error("Exception on trying to prune unpopulated groups from group list: "
+ ex.getMessage()); + ex.getMessage());
} }
log.debug(System.currentTimeMillis() - start + " to remove unpopulated groups");
// If the group for unassigned properties is populated, add it to the // If the group for unassigned properties is populated, add it to the
// group list. // group list.

View file

@ -47,11 +47,11 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
ops.setProperty(predicate); ops.setProperty(predicate);
// Do delete url first, since it is used in building edit url // Do delete url first, since it is used in building edit url
this.deleteUrl = makeDeleteUrl(); this.deleteUrl = makeDeleteUrl(ops);
this.editUrl = makeEditUrl(ops); this.editUrl = makeEditUrl(ops);
} }
private String makeDeleteUrl() { private String makeDeleteUrl(ObjectPropertyStatement ops) {
// Is the delete link suppressed for this property? // Is the delete link suppressed for this property?
if (property.isDeleteLinkSuppressed()) { if (property.isDeleteLinkSuppressed()) {
return ""; return "";
@ -87,6 +87,13 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
} }
} }
if (ops.getProperty()!= null && ops.getProperty().getDomainVClassURI() != null) {
params.put("domainUri", ops.getProperty().getDomainVClassURI());
}
if (ops.getProperty()!= null && ops.getProperty().getRangeVClassURI() != null) {
params.put("rangeUri", ops.getProperty().getRangeVClassURI());
}
params.put("templateName", templateName); params.put("templateName", templateName);
params.putAll(UrlBuilder.getModelParams(vreq)); params.putAll(UrlBuilder.getModelParams(vreq));

View file

@ -8,6 +8,9 @@ import java.util.List;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.display.DisplayObjectProperty;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty; import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty; import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
@ -37,6 +40,10 @@ public class PropertyGroupTemplateModel extends BaseTemplateModel {
for (Property p : propertyList) { for (Property p : propertyList) {
if (p instanceof ObjectProperty) { if (p instanceof ObjectProperty) {
ObjectProperty op = (ObjectProperty) p; ObjectProperty op = (ObjectProperty) p;
RequestedAction dop = new DisplayObjectProperty(op);
if (!PolicyHelper.isAuthorizedForActions(vreq, dop)) {
continue;
}
ObjectPropertyTemplateModel tm = ObjectPropertyTemplateModel.getObjectPropertyTemplateModel( ObjectPropertyTemplateModel tm = ObjectPropertyTemplateModel.getObjectPropertyTemplateModel(
op, subject, vreq, editing, populatedObjectPropertyList); op, subject, vreq, editing, populatedObjectPropertyList);
if (!tm.isEmpty() || (editing && !tm.getAddUrl().isEmpty())) { if (!tm.isEmpty() || (editing && !tm.getAddUrl().isEmpty())) {

View file

@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.auth.policy;
import static edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.Authorization.AUTHORIZED; import static edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.Authorization.AUTHORIZED;
import static edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.Authorization.INCONCLUSIVE; import static edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.Authorization.INCONCLUSIVE;
import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants.SOME_LITERAL;
import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull; import static junit.framework.Assert.assertNull;
@ -31,6 +32,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.RebuildTextIn
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.RemoveUser; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.RemoveUser;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.ServerStatus; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.ServerStatus;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.UpdateTextIndex; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.UpdateTextIndex;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.CreateOwlClass; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.CreateOwlClass;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.DefineDataProperty; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.DefineDataProperty;
@ -125,19 +127,19 @@ public class SelfEditingPolicyTest extends AbstractTestClass {
// now with dataprop statements // now with dataprop statements
whatToAuth = new AddDataPropertyStatement(ontModel, SELFEDITOR_URI, whatToAuth = new AddDataPropertyStatement(ontModel, SELFEDITOR_URI,
"http://mannlib.cornell.edu/bad#prp234"); "http://mannlib.cornell.edu/bad#prp234", SOME_LITERAL);
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth)); assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
whatToAuth = new AddDataPropertyStatement(ontModel, SELFEDITOR_URI, whatToAuth = new AddDataPropertyStatement(ontModel, SELFEDITOR_URI,
"http://mannlib.cornell.edu/bad#prp999"); "http://mannlib.cornell.edu/bad#prp999", SOME_LITERAL);
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth)); assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
whatToAuth = new AddDataPropertyStatement(ontModel, SELFEDITOR_URI, whatToAuth = new AddDataPropertyStatement(ontModel, SELFEDITOR_URI,
SAFE_PREDICATE.getURI()); SAFE_PREDICATE.getURI(), SOME_LITERAL);
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth)); assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
whatToAuth = new AddDataPropertyStatement(ontModel, SELFEDITOR_URI, whatToAuth = new AddDataPropertyStatement(ontModel, SELFEDITOR_URI,
UNSAFE_PREDICATE.getURI()); UNSAFE_PREDICATE.getURI(), SOME_LITERAL);
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth)); assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
} }
@ -219,16 +221,16 @@ public class SelfEditingPolicyTest extends AbstractTestClass {
// //
@Test @Test
public void testVisitIdentifierBundleEditDataPropStmt() { public void testVisitIdentifierBundleEditDataPropStmt() {
whatToAuth = new EditDataPropertyStatement(ontModel, SELFEDITOR_URI,SAFE_PREDICATE.getURI()); whatToAuth = new EditDataPropertyStatement(ontModel, SELFEDITOR_URI,SAFE_PREDICATE.getURI(), SOME_LITERAL);
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth)); assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
whatToAuth = new EditDataPropertyStatement(ontModel, SELFEDITOR_URI, UNSAFE_PREDICATE.getURI()); whatToAuth = new EditDataPropertyStatement(ontModel, SELFEDITOR_URI, UNSAFE_PREDICATE.getURI(), SOME_LITERAL);
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth)); assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
whatToAuth = new EditDataPropertyStatement(ontModel, UNSAFE_RESOURCE, SAFE_PREDICATE.getURI()); whatToAuth = new EditDataPropertyStatement(ontModel, UNSAFE_RESOURCE, SAFE_PREDICATE.getURI(), SOME_LITERAL);
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth)); assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
whatToAuth = new EditDataPropertyStatement(ontModel, SAFE_RESOURCE, SAFE_PREDICATE.getURI()); whatToAuth = new EditDataPropertyStatement(ontModel, SAFE_RESOURCE, SAFE_PREDICATE.getURI(), SOME_LITERAL);
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth)); assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
} }
@ -288,7 +290,7 @@ public class SelfEditingPolicyTest extends AbstractTestClass {
public void twoSEIsFindDataPropertySubject() { public void twoSEIsFindDataPropertySubject() {
setUpTwoSEIs(); setUpTwoSEIs();
whatToAuth = new EditDataPropertyStatement(ontModel, SELFEDITOR_URI, SAFE_PREDICATE.getURI()); whatToAuth = new EditDataPropertyStatement(ontModel, SELFEDITOR_URI, SAFE_PREDICATE.getURI(), SOME_LITERAL);
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth)); assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
} }
@ -296,7 +298,7 @@ public class SelfEditingPolicyTest extends AbstractTestClass {
public void twoSEIsDontFindInDataProperty() { public void twoSEIsDontFindInDataProperty() {
setUpTwoSEIs(); setUpTwoSEIs();
whatToAuth = new EditDataPropertyStatement(ontModel, SAFE_RESOURCE, SAFE_PREDICATE.getURI()); whatToAuth = new EditDataPropertyStatement(ontModel, SAFE_RESOURCE, SAFE_PREDICATE.getURI(), SOME_LITERAL);
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth)); assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
} }

View file

@ -2,6 +2,8 @@
package edu.cornell.mannlib.vitro.webapp.auth.policy; package edu.cornell.mannlib.vitro.webapp.auth.policy;
import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants.SOME_LITERAL;
import java.io.InputStream; import java.io.InputStream;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -306,7 +308,7 @@ public class SelfEditingPolicy_2_Test extends AbstractTestClass {
private void assertEditDataPropStmt(String individualURI, private void assertEditDataPropStmt(String individualURI,
String datapropURI, String data, Authorization expectedAuthorization) { String datapropURI, String data, Authorization expectedAuthorization) {
EditDataPropertyStatement whatToAuth = new EditDataPropertyStatement( EditDataPropertyStatement whatToAuth = new EditDataPropertyStatement(
ontModel, individualURI, datapropURI); ontModel, individualURI, datapropURI, SOME_LITERAL);
PolicyDecision dec = policy.isAuthorized(ids, whatToAuth); PolicyDecision dec = policy.isAuthorized(ids, whatToAuth);
log.debug(dec); log.debug(dec);
Assert.assertNotNull(dec); Assert.assertNotNull(dec);

View file

@ -1,670 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.search.indexing;
import static org.junit.Assert.assertTrue;
import java.io.StringReader;
import java.util.List;
import org.junit.Test;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import edu.cornell.mannlib.vitro.webapp.search.indexing.AdditionalURIsForContextNodes;
public class AdditionalURIsForContextNodesTest {
@Test
public void testPositionChanges(){
String n3 =
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5423> <http://vivoweb.org/ontology/core#relatedBy> <http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5431> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5423> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#AcademicDepartment> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5423> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Department> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5423> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5423> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5423> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Organization> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5423> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#AcademicDepartment> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5431> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#DependentResource> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5431> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#DependentResource> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5431> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Position> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5431> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5431> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#FacultyPosition> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5431> <http://vivoweb.org/ontology/core#relates> <http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5423> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5431> <http://vivoweb.org/ontology/core#relates> <http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n932> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n932> <http://vivoweb.org/ontology/core#relatedBy> <http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5431> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n932> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#FacultyMember> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n932> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n932> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n932> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n932> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#FacultyMember> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5398> <http://vivoweb.org/ontology/core#start> <http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5425> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5398> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#DateTimeInterval> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5398> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5398> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#DateTimeInterval> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5425> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5425> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#DateTimeValue> . \n" +
"<http://vivoweb.org/ontology/core#AcademicDepartment> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> . \n" +
"<http://vivoweb.org/ontology/core#Position> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> . \n" +
"<http://vivoweb.org/ontology/core#FacultyMember> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> . \n" +
"<http://xmlns.com/foaf/0.1/Organization> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> . \n" +
"<http://xmlns.com/foaf/0.1/Person> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> . \n" +
"<http://xmlns.com/foaf/0.1/Agent> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> . \n" +
"<http://vivoweb.org/ontology/core#DateTimeInterval> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> . \n" +
"<http://vivoweb.org/ontology/core#Department> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> . \n" ;
//make a test model with an person, an authorship context node and a book
OntModel model = ModelFactory.createOntologyModel();
model.read( new StringReader(n3), null, "N3");
//make an AdditionalURIsForContextNodesTest object with that model
AdditionalURIsForContextNodes uriFinder = new AdditionalURIsForContextNodes( model );
//if the person changes then the org needs to be updated
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n932");
assertTrue("did not find org for context node", uris.contains("http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5423" ));
//if the org changes then the person needs to be updated
uris = uriFinder.findAdditionalURIsToIndex( "http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5423");
assertTrue("did not find person for context node", uris.contains("http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n932" ));
}
@Test
public void testPersonOnOrgChange() {
String n3 ="@prefix dc: <http://purl.org/dc/elements/1.1/> . \n" +
"@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . \n" +
"@prefix swrl: <http://www.w3.org/2003/11/swrl#> . \n" +
"@prefix vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> . \n" +
"@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . \n" +
"@prefix swrlb: <http://www.w3.org/2003/11/swrlb#> . \n" +
"@prefix owl: <http://www.w3.org/2002/07/owl#> . \n" +
"@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . \n" +
"@prefix core: <http://vivoweb.org/ontology/core#> . \n" +
"@prefix vivo: <http://vivo.library.cornell.edu/ns/0.1#> . \n" +
"@prefix obo: <http://purl.obolibrary.org/obo/> . \n" +
" " +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n2577> \n" +
" a owl:Thing , core:Role , core:LeaderRole ; \n" +
" rdfs:label \"head\"^^xsd:string ; \n" +
" vitro:mostSpecificType \n" +
" core:LeaderRole ; \n" +
" core:dateTimeInterval \n" +
" <http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n2594> ; \n" +
" obo:RO_0000052 <http://vivo.scripps.edu/individual/n14979> ; \n" +
" core:roleContributesTo <http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n2592> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n2592> \n" +
" a <http://xmlns.com/foaf/0.1/Organization> , owl:Thing , <http://xmlns.com/foaf/0.1/Agent> , core:ClinicalOrganization ; \n" +
" rdfs:label \"Organization XYZ\"^^xsd:string ; \n" +
" vitro:mostSpecificType \n" +
" core:ClinicalOrganization ; \n" +
" core:contributingRole <http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n2577> . \n" +
" <http://vivo.scripps.edu/individual/n14979> a <http://xmlns.com/foaf/0.1/Person> , owl:Thing , <http://xmlns.com/foaf/0.1/Agent> . \n";
//make a test model with an person, an authorship context node and a book
OntModel model = ModelFactory.createOntologyModel();
model.read( new StringReader(n3), null, "N3");
//make an AdditionalURIsForContextNodesTest object with that model
AdditionalURIsForContextNodes uriFinder = new AdditionalURIsForContextNodes( model );
//get additional uris for org
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n2592");
assertTrue("did not find person for context node", uris.contains("http://vivo.scripps.edu/individual/n14979" ));
}
@Test
public void testLeaderRoleChanges(){
String n3=
"<http://vivo.scripps.edu/individual/n2027> <http://www.w3.org/2000/01/rdf-schema#label> \"1, Test\" . \n " +
// "<http://vivo.scripps.edu/individual/n2027> <http://xmlns.com/foaf/0.1/lastName> \"1\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
// "<http://vivo.scripps.edu/individual/n2027> <http://xmlns.com/foaf/0.1/firstName> \"Test\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
"<http://vivo.scripps.edu/individual/n2027> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://xmlns.com/foaf/0.1/Person> . \n " +
"<http://vivo.scripps.edu/individual/n2027> <http://purl.obolibrary.org/obo/RO_0000053> <http://vivo.scripps.edu/individual/n7067> . \n " +
"<http://vivo.scripps.edu/individual/n2027> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n " +
"<http://vivo.scripps.edu/individual/n2027> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . \n " +
"<http://vivo.scripps.edu/individual/n2027> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n " +
"<http://vivo.scripps.edu/individual/n7067> <http://www.w3.org/2000/01/rdf-schema#label> \"Leader Role\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
"<http://vivo.scripps.edu/individual/n7067> <http://purl.obolibrary.org/obo/RO_0000052> <http://vivo.scripps.edu/individual/n2027> . \n " +
"<http://vivo.scripps.edu/individual/n7067> <http://vivoweb.org/ontology/core#dateTimeInterval> <http://vivo.scripps.edu/individual/n7083> . \n " +
"<http://vivo.scripps.edu/individual/n7067> <http://vivoweb.org/ontology/core#roleContributesTo> <http://vivo.scripps.edu/individual/n7080> . \n " +
"<http://vivo.scripps.edu/individual/n7067> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#LeaderRole> . \n " +
"<http://vivo.scripps.edu/individual/n7067> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#LeaderRole> . \n " +
"<http://vivo.scripps.edu/individual/n7067> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n " +
"<http://vivo.scripps.edu/individual/n7080> <http://www.w3.org/2000/01/rdf-schema#label> \"University1\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
"<http://vivo.scripps.edu/individual/n7080> <http://vivoweb.org/ontology/core#contributingRole> <http://vivo.scripps.edu/individual/n7067> . \n " +
"<http://vivo.scripps.edu/individual/n7080> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#University> .\n " +
"<http://vivo.scripps.edu/individual/n7080> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#University> . \n " +
"<http://vivo.scripps.edu/individual/n7080> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n " +
"<http://vivo.scripps.edu/individual/n7080> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n " +
"<http://vivo.scripps.edu/individual/n7080> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Organization> . \n " ;
//make a test model with an person, a leader role node and a university
OntModel model = ModelFactory.createOntologyModel();
model.read( new StringReader(n3), null, "N3");
//make an AdditionalURIsForContextNodesTest object with that model
AdditionalURIsForContextNodes uriFinder = new AdditionalURIsForContextNodes( model );
//if the person changes then the university needs to be updated
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n2027");
assertTrue("did not find org for context node", uris.contains("http://vivo.scripps.edu/individual/n7080" ));
//if the university changes then the person needs to be updated
uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n7080");
assertTrue("did not find person for context node", uris.contains("http://vivo.scripps.edu/individual/n2027" ));
}
@Test
public void testMemberRoleChanges(){
String n3 =
"<http://vivo.scripps.edu/individual/n4519> <http://purl.obolibrary.org/obo/RO_0000053> <http://vivo.scripps.edu/individual/n6040> . \n " +
"<http://vivo.scripps.edu/individual/n4519> <http://www.w3.org/2000/01/rdf-schema#label> \"2, Test\" . \n " +
// "<http://vivo.scripps.edu/individual/n4519> <http://xmlns.com/foaf/0.1/lastName> \"2\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
// "<http://vivo.scripps.edu/individual/n4519> <http://xmlns.com/foaf/0.1/firstName> \"Test\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
"<http://vivo.scripps.edu/individual/n4519> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://xmlns.com/foaf/0.1/Person> . \n " +
"<http://vivo.scripps.edu/individual/n4519> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n " +
"<http://vivo.scripps.edu/individual/n4519> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . \n " +
"<http://vivo.scripps.edu/individual/n4519> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n " +
"<http://vivo.scripps.edu/individual/n6040> <http://www.w3.org/2000/01/rdf-schema#label> \"Member Role\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
"<http://vivo.scripps.edu/individual/n6040> <http://vivoweb.org/ontology/core#dateTimeInterval> <http://vivo.scripps.edu/individual/n6031> . \n " +
"<http://vivo.scripps.edu/individual/n6040> <http://vivoweb.org/ontology/core#roleContributesTo> <http://vivo.scripps.edu/individual/n6004> . \n " +
"<http://vivo.scripps.edu/individual/n6040> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#MemberRole> . \n " +
"<http://vivo.scripps.edu/individual/n6040> <http://purl.obolibrary.org/obo/RO_0000052> <http://vivo.scripps.edu/individual/n4519> . \n " +
"<http://vivo.scripps.edu/individual/n6040> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#MemberRole> . \n " +
"<http://vivo.scripps.edu/individual/n6040> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Role> . \n " +
"<http://vivo.scripps.edu/individual/n6040> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n " +
"<http://vivo.scripps.edu/individual/n6004> <http://www.w3.org/2000/01/rdf-schema#label> \"University2\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
"<http://vivo.scripps.edu/individual/n6004> <http://vivoweb.org/ontology/core#contributingRole> <http://vivo.scripps.edu/individual/n6040> . \n " +
"<http://vivo.scripps.edu/individual/n6004> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#University> . \n " +
"<http://vivo.scripps.edu/individual/n6004> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#University> . \n " +
"<http://vivo.scripps.edu/individual/n6004> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n " +
"<http://vivo.scripps.edu/individual/n6004> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n " +
"<http://vivo.scripps.edu/individual/n6004> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Organization> . \n " ;
//make a test model with an person, a member role node and a university
OntModel model = ModelFactory.createOntologyModel();
model.read( new StringReader(n3), null, "N3");
//make an AdditionalURIsForContextNodesTest object with that model
AdditionalURIsForContextNodes uriFinder = new AdditionalURIsForContextNodes( model );
//if the person changes then the university needs to be updated
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n4519");
assertTrue("did not find org for context node", uris.contains("http://vivo.scripps.edu/individual/n6004" ));
//if the university changes then the person needs to be updated
uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n6004");
assertTrue("did not find person for context node", uris.contains("http://vivo.scripps.edu/individual/n4519" ));
}
@Test
public void testClinicalRoleChangesForProject(){
String n3 =
"<http://vivo.scripps.edu/individual/n4858> <http://www.w3.org/2000/01/rdf-schema#label> \"3, Test\" . \n" +
// "<http://vivo.scripps.edu/individual/n4858> <http://xmlns.com/foaf/0.1/lastName> \"3\"^^<http://www.w3.org/2001/XMLSchema#string> .\n" +
// "<http://vivo.scripps.edu/individual/n4858> <http://xmlns.com/foaf/0.1/firstName> \"Test\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n4858> <http://purl.obolibrary.org/obo/RO_0000053> <http://vivo.scripps.edu/individual/n5185> . \n" +
"<http://vivo.scripps.edu/individual/n4858> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n4858> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n" +
"<http://vivo.scripps.edu/individual/n4858> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n4858> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n5185> <http://purl.obolibrary.org/obo/RO_0000052> <http://vivo.scripps.edu/individual/n4858> . \n" +
"<http://vivo.scripps.edu/individual/n5185> <http://www.w3.org/2000/01/rdf-schema#label> \"Clinical Role\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n5185> <http://vivoweb.org/ontology/core#dateTimeInterval> <http://vivo.scripps.edu/individual/n5180> . \n" +
"<http://vivo.scripps.edu/individual/n5185> <http://purl.obolibrary.org/obo/BFO_0000054> <http://vivo.scripps.edu/individual/n5177> . \n" +
"<http://vivo.scripps.edu/individual/n5185> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#ClinicalRole> . \n" +
"<http://vivo.scripps.edu/individual/n5185> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Role> . \n" +
"<http://vivo.scripps.edu/individual/n5185> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n5185> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#ClinicalRole> . \n" +
"<http://vivo.scripps.edu/individual/n5177> <http://www.w3.org/2000/01/rdf-schema#label> \"Project1\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n5177> <http://purl.obolibrary.org/obo/BFO_0000055> <http://vivo.scripps.edu/individual/n5185> . \n" +
"<http://vivo.scripps.edu/individual/n5177> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#Project> . \n" +
"<http://vivo.scripps.edu/individual/n5177> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Project> . \n" +
"<http://vivo.scripps.edu/individual/n5177> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n5177> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Process> . \n" ;
//make a test model with an person, a clinical role node and a project
OntModel model = ModelFactory.createOntologyModel();
model.read( new StringReader(n3), null, "N3");
//make an AdditionalURIsForContextNodesTest object with that model
AdditionalURIsForContextNodes uriFinder = new AdditionalURIsForContextNodes( model );
//if the person changes then the project needs to be updated
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n4858");
assertTrue("did not find project for clinical role", uris.contains("http://vivo.scripps.edu/individual/n5177" ));
//if the project changes then the person needs to be updated
uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n5177");
assertTrue("did not find person for clinical role", uris.contains("http://vivo.scripps.edu/individual/n4858" ));
}
@Test
public void testClinicalRoleChangesForService(){
String n3 =
"<http://vivo.scripps.edu/individual/n5651> <http://www.w3.org/2000/01/rdf-schema#label> \"4, Test\" . \n" +
// "<http://vivo.scripps.edu/individual/n5651> <http://xmlns.com/foaf/0.1/lastName> \"4\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
// "<http://vivo.scripps.edu/individual/n5651> <http://xmlns.com/foaf/0.1/firstName> \"Test\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n5651> <http://purl.obolibrary.org/obo/RO_0000053> <http://vivo.scripps.edu/individual/n4428> . \n" +
"<http://vivo.scripps.edu/individual/n5651> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n5651> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n" +
"<http://vivo.scripps.edu/individual/n5651> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n5651> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n4428> <http://purl.obolibrary.org/obo/RO_0000052> <http://vivo.scripps.edu/individual/n5651> . \n" +
"<http://vivo.scripps.edu/individual/n4428> <http://www.w3.org/2000/01/rdf-schema#label> \"Clinical Role 2\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n4428> <http://vivoweb.org/ontology/core#dateTimeInterval> <http://vivo.scripps.edu/individual/n4444> . \n" +
"<http://vivo.scripps.edu/individual/n4428> <http://vivoweb.org/ontology/core#roleContributesTo> <http://vivo.scripps.edu/individual/n4442> . \n" +
"<http://vivo.scripps.edu/individual/n4428> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#ClinicalRole> . \n" +
"<http://vivo.scripps.edu/individual/n4428> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Role> . \n" +
"<http://vivo.scripps.edu/individual/n4428> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n4428> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#ClinicalRole> . \n" +
"<http://vivo.scripps.edu/individual/n4442> <http://www.w3.org/2000/01/rdf-schema#label> \"Service1\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n4442> <http://vivoweb.org/ontology/core#contributingRole> <http://vivo.scripps.edu/individual/n4428> . \n" +
"<http://vivo.scripps.edu/individual/n4442> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://purl.obolibrary.org/obo/ERO_0000005> . \n" +
"<http://vivo.scripps.edu/individual/n4442> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n4442> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.obolibrary.org/obo/ERO_0000005> . \n" ;
//make a test model with an person, a clinical role node and a service
OntModel model = ModelFactory.createOntologyModel();
model.read( new StringReader(n3), null, "N3");
//make an AdditionalURIsForContextNodesTest object with that model
AdditionalURIsForContextNodes uriFinder = new AdditionalURIsForContextNodes( model );
//if the person changes then the service needs to be updated
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n5651");
assertTrue("did not find service for clinical role", uris.contains("http://vivo.scripps.edu/individual/n4442" ));
//if the service changes then the person needs to be updated
uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n4442");
assertTrue("did not find person for clinical role", uris.contains("http://vivo.scripps.edu/individual/n5651" ));
}
@Test
public void testPresenterRoleChangesForPresentation(){
String n3 =
"<http://vivo.scripps.edu/individual/n5596> <http://purl.obolibrary.org/obo/RO_0000053> <http://vivo.scripps.edu/individual/n1294> . \n" +
"<http://vivo.scripps.edu/individual/n5596> <http://www.w3.org/2000/01/rdf-schema#label> \"5, Test\" . \n" +
// "<http://vivo.scripps.edu/individual/n5596> <http://xmlns.com/foaf/0.1/lastName> \"5\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
// "<http://vivo.scripps.edu/individual/n5596> <http://xmlns.com/foaf/0.1/firstName> \"Test\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n5596> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n5596> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n" +
"<http://vivo.scripps.edu/individual/n5596> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n5596> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n1294> <http://purl.obolibrary.org/obo/RO_0000052> <http://vivo.scripps.edu/individual/n5596> . \n" +
"<http://vivo.scripps.edu/individual/n1294> <http://www.w3.org/2000/01/rdf-schema#label> \"Presenter Role\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n1294> <http://vivoweb.org/ontology/core#dateTimeInterval> <http://vivo.scripps.edu/individual/n1304> . \n" +
"<http://vivo.scripps.edu/individual/n1294> <http://purl.obolibrary.org/obo/BFO_0000054> <http://vivo.scripps.edu/individual/n1305> . \n" +
"<http://vivo.scripps.edu/individual/n1294> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#PresenterRole> . \n" +
"<http://vivo.scripps.edu/individual/n1294> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Role> . \n" +
"<http://vivo.scripps.edu/individual/n1294> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#PresenterRole> . \n" +
"<http://vivo.scripps.edu/individual/n1294> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n1305> <http://www.w3.org/2000/01/rdf-schema#label> \"Presentation 1\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n1305> <http://purl.obolibrary.org/obo/BFO_0000055> <http://vivo.scripps.edu/individual/n1294> . \n" +
"<http://vivo.scripps.edu/individual/n1305> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#Presentation> . \n" +
"<http://vivo.scripps.edu/individual/n1305> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Presentation> . \n" +
"<http://vivo.scripps.edu/individual/n1305> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.org/NET/c4dm/event.owl#Event> . \n" +
"<http://vivo.scripps.edu/individual/n1305> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" ;
//make a test model with an person, a presenter role node and a presentation
OntModel model = ModelFactory.createOntologyModel();
model.read( new StringReader(n3), null, "N3");
//make an AdditionalURIsForContextNodesTest object with that model
AdditionalURIsForContextNodes uriFinder = new AdditionalURIsForContextNodes( model );
//if the person changes then the presentation needs to be updated
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n5596");
assertTrue("did not find service for clinical role", uris.contains("http://vivo.scripps.edu/individual/n1305" ));
//if the presentation changes then the person needs to be updated
uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n1305");
assertTrue("did not find person for clinical role", uris.contains("http://vivo.scripps.edu/individual/n5596" ));
}
@Test
public void testPresenterRoleChangesForInvitedTalk(){
String n3 =
"<http://vivo.scripps.edu/individual/n4112> <http://purl.obolibrary.org/obo/RO_0000053> <http://vivo.scripps.edu/individual/n4144> . \n " +
"<http://vivo.scripps.edu/individual/n4112> <http://www.w3.org/2000/01/rdf-schema#label> \"6, Test\" . \n " +
// "<http://vivo.scripps.edu/individual/n4112> <http://xmlns.com/foaf/0.1/lastName> \"6\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
// "<http://vivo.scripps.edu/individual/n4112> <http://xmlns.com/foaf/0.1/firstName> \"Test\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
"<http://vivo.scripps.edu/individual/n4112> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://xmlns.com/foaf/0.1/Person> . \n " +
"<http://vivo.scripps.edu/individual/n4112> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n " +
"<http://vivo.scripps.edu/individual/n4112> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . \n " +
"<http://vivo.scripps.edu/individual/n4112> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n " +
"<http://vivo.scripps.edu/individual/n4144> <http://purl.obolibrary.org/obo/RO_0000052> <http://vivo.scripps.edu/individual/n4112> . \n " +
"<http://vivo.scripps.edu/individual/n4144> <http://www.w3.org/2000/01/rdf-schema#label> \"Presenter Role 2\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
"<http://vivo.scripps.edu/individual/n4144> <http://vivoweb.org/ontology/core#dateTimeInterval> <http://vivo.scripps.edu/individual/n4136> . \n " +
"<http://vivo.scripps.edu/individual/n4144> <http://purl.obolibrary.org/obo/BFO_0000054> <http://vivo.scripps.edu/individual/n4107> . \n " +
"<http://vivo.scripps.edu/individual/n4144> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#PresenterRole> . \n " +
"<http://vivo.scripps.edu/individual/n4144> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Role> . \n " +
"<http://vivo.scripps.edu/individual/n4144> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#PresenterRole> . \n " +
"<http://vivo.scripps.edu/individual/n4144> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n " +
"<http://vivo.scripps.edu/individual/n4107> <http://www.w3.org/2000/01/rdf-schema#label> \"Invited Talk 1\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
"<http://vivo.scripps.edu/individual/n4107> <http://purl.obolibrary.org/obo/BFO_0000055> <http://vivo.scripps.edu/individual/n4144> . \n " +
"<http://vivo.scripps.edu/individual/n4107> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#InvitedTalk> . \n " +
"<http://vivo.scripps.edu/individual/n4107> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Presentation> . \n " +
"<http://vivo.scripps.edu/individual/n4107> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.org/NET/c4dm/event.owl#Event> . \n " +
"<http://vivo.scripps.edu/individual/n4107> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n " +
"<http://vivo.scripps.edu/individual/n4107> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#InvitedTalk> . \n " ;
//make a test model with an person, a presenter role node and an invited talk
OntModel model = ModelFactory.createOntologyModel();
model.read( new StringReader(n3), null, "N3");
//make an AdditionalURIsForContextNodesTest object with that model
AdditionalURIsForContextNodes uriFinder = new AdditionalURIsForContextNodes( model );
//if the person changes then the invited talk needs to be updated
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n4112");
assertTrue("did not find invited talk for person", uris.contains("http://vivo.scripps.edu/individual/n4107" ));
//if the invited talk changes then the person needs to be updated
uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n4107");
assertTrue("did not find person for invited talk", uris.contains("http://vivo.scripps.edu/individual/n4112" ));
}
@Test
public void testResearcherRoleForGrant(){
String n3 =
"<http://vivo.scripps.edu/individual/n4957> <http://www.w3.org/2000/01/rdf-schema#label> \"7, Test\" . \n" +
// "<http://vivo.scripps.edu/individual/n4957> <http://xmlns.com/foaf/0.1/lastName> \"7\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
// "<http://vivo.scripps.edu/individual/n4957> <http://xmlns.com/foaf/0.1/firstName> \"Test\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n4957> <http://purl.obolibrary.org/obo/RO_0000053> <http://vivo.scripps.edu/individual/n4288> . \n" +
"<http://vivo.scripps.edu/individual/n4957> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n4957> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n" +
"<http://vivo.scripps.edu/individual/n4957> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n4957> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n4288> <http://www.w3.org/2000/01/rdf-schema#label> \"Researcher Role\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n4288> <http://vivoweb.org/ontology/core#dateTimeInterval> <http://vivo.scripps.edu/individual/n4251> . \n" +
"<http://vivo.scripps.edu/individual/n4288> <http://vivoweb.org/ontology/core#relatedBy> <http://vivo.scripps.edu/individual/n4252> . \n" +
"<http://vivo.scripps.edu/individual/n4288> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#ResearcherRole> . \n" +
"<http://vivo.scripps.edu/individual/n4288> <http://purl.obolibrary.org/obo/RO_0000052> <http://vivo.scripps.edu/individual/n4957> . \n" +
"<http://vivo.scripps.edu/individual/n4288> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Role> . \n" +
"<http://vivo.scripps.edu/individual/n4288> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#ResearcherRole> . \n" +
"<http://vivo.scripps.edu/individual/n4288> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n4252> <http://www.w3.org/2000/01/rdf-schema#label> \"Grant1\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n4252> <http://vivoweb.org/ontology/core#relates> <http://vivo.scripps.edu/individual/n4288> . \n" +
"<http://vivo.scripps.edu/individual/n4252> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#Grant> . \n" +
"<http://vivo.scripps.edu/individual/n4252> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Agreement> . \n" +
"<http://vivo.scripps.edu/individual/n4252> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n4252> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Grant> . \n" ;
//make a test model with an person, a researcher role node and a grant
OntModel model = ModelFactory.createOntologyModel();
model.read( new StringReader(n3), null, "N3");
//make an AdditionalURIsForContextNodesTest object with that model
AdditionalURIsForContextNodes uriFinder = new AdditionalURIsForContextNodes( model );
//if the person changes then the grant needs to be updated
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n4957");
assertTrue("did not find service for clinical role", uris.contains("http://vivo.scripps.edu/individual/n4252" ));
//if the grant changes then the person needs to be updated
uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n4252");
assertTrue("did not find person for clinical role", uris.contains("http://vivo.scripps.edu/individual/n4957" ));
}
@Test
public void testResearcherRoleForProject(){
String n3 =
"<http://vivo.scripps.edu/individual/n2029> <http://www.w3.org/2000/01/rdf-schema#label> \"8, Test\" . \n " +
// "<http://vivo.scripps.edu/individual/n2029> <http://xmlns.com/foaf/0.1/lastName> \"8\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
// "<http://vivo.scripps.edu/individual/n2029> <http://xmlns.com/foaf/0.1/firstName> \"Test\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
"<http://vivo.scripps.edu/individual/n2029> <http://purl.obolibrary.org/obo/RO_0000053> <http://vivo.scripps.edu/individual/n556> . \n " +
"<http://vivo.scripps.edu/individual/n2029> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://xmlns.com/foaf/0.1/Person> . \n " +
"<http://vivo.scripps.edu/individual/n2029> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n " +
"<http://vivo.scripps.edu/individual/n2029> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . \n " +
"<http://vivo.scripps.edu/individual/n2029> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n " +
"<http://vivo.scripps.edu/individual/n556> <http://www.w3.org/2000/01/rdf-schema#label> \"Researcher Role 2\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
"<http://vivo.scripps.edu/individual/n556> <http://vivoweb.org/ontology/core#dateTimeInterval> <http://vivo.scripps.edu/individual/n568> . \n " +
"<http://vivo.scripps.edu/individual/n556> <http://purl.obolibrary.org/obo/BFO_0000054> <http://vivo.scripps.edu/individual/n564> . \n " +
"<http://vivo.scripps.edu/individual/n556> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#ResearcherRole> . \n " +
"<http://vivo.scripps.edu/individual/n556> <http://purl.obolibrary.org/obo/RO_0000052> <http://vivo.scripps.edu/individual/n2029> . \n " +
"<http://vivo.scripps.edu/individual/n556> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Role> . \n " +
"<http://vivo.scripps.edu/individual/n556> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#ResearcherRole> . \n " +
"<http://vivo.scripps.edu/individual/n556> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n " +
"<http://vivo.scripps.edu/individual/n564> <http://www.w3.org/2000/01/rdf-schema#label> \"Project2\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
"<http://vivo.scripps.edu/individual/n564> <http://purl.obolibrary.org/obo/BFO_0000055> <http://vivo.scripps.edu/individual/n556> . \n " +
"<http://vivo.scripps.edu/individual/n564> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#Project> . \n " +
"<http://vivo.scripps.edu/individual/n564> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Project> . \n " +
"<http://vivo.scripps.edu/individual/n564> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n " +
"<http://vivo.scripps.edu/individual/n564> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Process> . \n " ;
//make a test model with an person, a researcher role node and a project
OntModel model = ModelFactory.createOntologyModel();
model.read( new StringReader(n3), null, "N3");
//make an AdditionalURIsForContextNodesTest object with that model
AdditionalURIsForContextNodes uriFinder = new AdditionalURIsForContextNodes( model );
//if the person changes then the project needs to be updated
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n2029");
assertTrue("did not find service for clinical role", uris.contains("http://vivo.scripps.edu/individual/n564" ));
//if the project changes then the person needs to be updated
uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n564");
assertTrue("did not find person for clinical role", uris.contains("http://vivo.scripps.edu/individual/n2029" ));
}
@Test
public void testPrincipalInvestigatorRoleChanges(){
String n3 =
"<http://vivo.scripps.edu/individual/n2368> <http://purl.obolibrary.org/obo/RO_0000053> <http://vivo.scripps.edu/individual/n1740> . \n" +
"<http://vivo.scripps.edu/individual/n2368> <http://www.w3.org/2000/01/rdf-schema#label> \"8, Test\" . \n" +
// "<http://vivo.scripps.edu/individual/n2368> <http://xmlns.com/foaf/0.1/lastName> \"8\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
// "<http://vivo.scripps.edu/individual/n2368> <http://xmlns.com/foaf/0.1/firstName> \"Test\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n2368> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n2368> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n" +
"<http://vivo.scripps.edu/individual/n2368> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n2368> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n1740> <http://purl.obolibrary.org/obo/RO_0000052> <http://vivo.scripps.edu/individual/n2368> . \n" +
"<http://vivo.scripps.edu/individual/n1740> <http://vivoweb.org/ontology/core#dateTimeInterval> <http://vivo.scripps.edu/individual/n1756> . \n" +
"<http://vivo.scripps.edu/individual/n1740> <http://vivoweb.org/ontology/core#relatedBy> <http://vivo.scripps.edu/individual/n1742> . \n" +
"<http://vivo.scripps.edu/individual/n1740> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#PrincipalInvestigatorRole> . \n" +
"<http://vivo.scripps.edu/individual/n1740> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Role> . \n" +
"<http://vivo.scripps.edu/individual/n1740> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#PrincipalInvestigatorRole> . \n" +
"<http://vivo.scripps.edu/individual/n1740> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#ResearcherRole> . \n" +
"<http://vivo.scripps.edu/individual/n1740> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n1740> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#InvestigatorRole> . \n" +
"<http://vivo.scripps.edu/individual/n1742> <http://www.w3.org/2000/01/rdf-schema#label> \"Grant 2\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n1742> <http://vivoweb.org/ontology/core#relates> <http://vivo.scripps.edu/individual/n1740> . \n" +
"<http://vivo.scripps.edu/individual/n1742> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#Grant> . \n" +
"<http://vivo.scripps.edu/individual/n1742> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Agreement> . \n" +
"<http://vivo.scripps.edu/individual/n1742> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n1742> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Grant> . \n" ;
//make a test model with an person, a principal investigator role node and a grant
OntModel model = ModelFactory.createOntologyModel();
model.read( new StringReader(n3), null, "N3");
//make an AdditionalURIsForContextNodesTest object with that model
AdditionalURIsForContextNodes uriFinder = new AdditionalURIsForContextNodes( model );
//if the person changes then the grant needs to be updated
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n2368");
assertTrue("did not find grant for pi", uris.contains("http://vivo.scripps.edu/individual/n1742" ));
//if the grant changes then the person needs to be updated
uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n1742");
assertTrue("did not find pi for grant", uris.contains("http://vivo.scripps.edu/individual/n2368" ));
}
@Test
public void testCoPrincipalInvestigatorRoleChanges(){
String n3 =
"<http://vivo.scripps.edu/individual/n1373> <http://www.w3.org/2000/01/rdf-schema#label> \"9, Test\" . \n" +
// "<http://vivo.scripps.edu/individual/n1373> <http://xmlns.com/foaf/0.1/lastName> \"9\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
// "<http://vivo.scripps.edu/individual/n1373> <http://xmlns.com/foaf/0.1/firstName> \"Test\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n1373> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n1373> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n" +
"<http://vivo.scripps.edu/individual/n1373> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n1373> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n1373> <http://purl.obolibrary.org/obo/RO_0000053> <http://vivo.scripps.edu/individual/n4928> . \n" +
"<http://vivo.scripps.edu/individual/n4928> <http://purl.obolibrary.org/obo/RO_0000052> <http://vivo.scripps.edu/individual/n1373> . \n" +
"<http://vivo.scripps.edu/individual/n4928> <http://vivoweb.org/ontology/core#dateTimeInterval> <http://vivo.scripps.edu/individual/n4895> . \n" +
"<http://vivo.scripps.edu/individual/n4928> <http://vivoweb.org/ontology/core#relatedBy> <http://vivo.scripps.edu/individual/n4931> . \n" +
"<http://vivo.scripps.edu/individual/n4928> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#CoPrincipalInvestigatorRole> . \n" +
"<http://vivo.scripps.edu/individual/n4928> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#CoPrincipalInvestigatorRole> . \n" +
"<http://vivo.scripps.edu/individual/n4928> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Role> . \n" +
"<http://vivo.scripps.edu/individual/n4928> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#ResearcherRole> . \n" +
"<http://vivo.scripps.edu/individual/n4928> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n4928> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#InvestigatorRole> . \n" +
"<http://vivo.scripps.edu/individual/n4931> <http://www.w3.org/2000/01/rdf-schema#label> \"Grant 3\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n4931> <http://vivoweb.org/ontology/core#relates> <http://vivo.scripps.edu/individual/n4928> . \n" +
"<http://vivo.scripps.edu/individual/n4931> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#Grant> . \n" +
"<http://vivo.scripps.edu/individual/n4931> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Agreement> . \n" +
"<http://vivo.scripps.edu/individual/n4931> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n4931> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Grant> . \n" ;
//make a test model with an person, a co-principal investigator role node and a grant
OntModel model = ModelFactory.createOntologyModel();
model.read( new StringReader(n3), null, "N3");
//make an AdditionalURIsForContextNodesTest object with that model
AdditionalURIsForContextNodes uriFinder = new AdditionalURIsForContextNodes( model );
//if the copi changes then the grant needs to be updated
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n1373");
assertTrue("did not find grant for co-pi", uris.contains("http://vivo.scripps.edu/individual/n4931" ));
//if the grant changes then the copi needs to be updated
uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n4931");
assertTrue("did not find co-pi for grant", uris.contains("http://vivo.scripps.edu/individual/n1373" ));
}
@Test
public void testInvestigatorRoleChanges(){
String n3 =
"<http://vivo.scripps.edu/individual/n5282> <http://www.w3.org/2000/01/rdf-schema#label> \"10, Test\" . \n" +
// "<http://vivo.scripps.edu/individual/n5282> <http://xmlns.com/foaf/0.1/lastName> \"10\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
// "<http://vivo.scripps.edu/individual/n5282> <http://xmlns.com/foaf/0.1/firstName> \"Test\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n5282> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n5282> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n" +
"<http://vivo.scripps.edu/individual/n5282> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n5282> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n5282> <http://purl.obolibrary.org/obo/RO_0000053> <http://vivo.scripps.edu/individual/n157> . \n" +
"<http://vivo.scripps.edu/individual/n157> <http://vivoweb.org/ontology/core#dateTimeInterval> <http://vivo.scripps.edu/individual/n127> . \n" +
"<http://vivo.scripps.edu/individual/n157> <http://vivoweb.org/ontology/core#relatedBy> <http://vivo.scripps.edu/individual/n160> . \n" +
"<http://vivo.scripps.edu/individual/n157> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#InvestigatorRole> . \n" +
"<http://vivo.scripps.edu/individual/n157> <http://purl.obolibrary.org/obo/RO_0000052> <http://vivo.scripps.edu/individual/n5282> . \n" +
"<http://vivo.scripps.edu/individual/n157> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Role> . \n" +
"<http://vivo.scripps.edu/individual/n157> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#ResearcherRole> . \n" +
"<http://vivo.scripps.edu/individual/n157> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n157> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#InvestigatorRole> . \n" +
"<http://vivo.scripps.edu/individual/n160> <http://www.w3.org/2000/01/rdf-schema#label> \"Grant 4\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n160> <http://vivoweb.org/ontology/core#relates> <http://vivo.scripps.edu/individual/n157> . \n" +
"<http://vivo.scripps.edu/individual/n160> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#Grant> . \n" +
"<http://vivo.scripps.edu/individual/n160> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Agreement> . \n" +
"<http://vivo.scripps.edu/individual/n160> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n160> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Grant> . \n" ;
//make a test model with an person, a investigator role node and a grant
OntModel model = ModelFactory.createOntologyModel();
model.read( new StringReader(n3), null, "N3");
//make an AdditionalURIsForContextNodesTest object with that model
AdditionalURIsForContextNodes uriFinder = new AdditionalURIsForContextNodes( model );
//if the investigator changes then the grant needs to be updated
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n5282");
assertTrue("did not find grant for investigator", uris.contains("http://vivo.scripps.edu/individual/n160" ));
//if the grant changes then the investigator needs to be updated
uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n160");
assertTrue("did not find investigator for grant", uris.contains("http://vivo.scripps.edu/individual/n5282" ));
}
}

View file

@ -5,13 +5,14 @@ package edu.cornell.mannlib.vitro.webapp.search.indexing;
import junit.framework.Assert; import junit.framework.Assert;
import org.apache.log4j.Level; import org.apache.log4j.Level;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import edu.cornell.mannlib.vitro.testing.AbstractTestClass; import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
public class IndexBuilderThreadTest extends AbstractTestClass { public class IndexBuilderThreadTest extends AbstractTestClass {
@Ignore
@Test @Test
public void testStoppingTheThread(){ public void testStoppingTheThread(){
setLoggerLevel(IndexBuilder.class, Level.OFF); setLoggerLevel(IndexBuilder.class, Level.OFF);

View file

@ -67,9 +67,9 @@ public class SparqlQueryDataGetterTest extends AbstractTestClass{
String bobURI = "http://example.com/p/bob"; String bobURI = "http://example.com/p/bob";
dataModel.add(ResourceFactory.createResource(bobURI), RDF.type, ResourceFactory.createResource("http://xmlns.com/foaf/0.1/Person")); dataModel.add(ResourceFactory.createResource(bobURI), RDF.type, ResourceFactory.createResource("http://xmlns.com/foaf/0.1/Person"));
Map<String, String[]> params = Collections.emptyMap(); Map<String, String> params = Collections.emptyMap();
Map<String,Object> mapOut = sdg.doQuery(params, dataModel); Map<String,Object> mapOut = sdg.doQueryOnModel(sdg.queryText, dataModel);
Assert.assertNotNull(mapOut); Assert.assertNotNull(mapOut);
Assert.assertTrue("should contain key people" , mapOut.containsKey("people")); Assert.assertTrue("should contain key people" , mapOut.containsKey("people"));

View file

@ -67,7 +67,14 @@ public class ObjectPropertyDaoStub implements ObjectPropertyDao {
} }
@Override @Override
public ObjectProperty getObjectPropertyByURIs(String objectPropertyURI, String domainURI, String rangeURI) { public ObjectProperty getObjectPropertyByURIs(String objectPropertyURI,
String domainURI, String rangeURI) {
return getObjectPropertyByURI(objectPropertyURI);
}
@Override
public ObjectProperty getObjectPropertyByURIs(String objectPropertyURI,
String domainURI, String rangeURI, ObjectProperty base) {
return getObjectPropertyByURI(objectPropertyURI); return getObjectPropertyByURI(objectPropertyURI);
} }

View file

@ -10,20 +10,7 @@
<body class="${bodyClasses!}"> <body class="${bodyClasses!}">
<#include "identity.ftl"> <#include "identity.ftl">
<#include "search.ftl">
<section id="search" role="region">
<fieldset>
<legend>${i18n().search_form}</legend>
<form id="search-form" action="${urls.search}" name="search" role="search" accept-charset="UTF-8" method="POST">
<div id="search-field">
<input type="text" name="querytext" class="search-vitro" value="${querytext!}" autocapitalize="off" />
<input type="submit" value="${i18n().search_button}" class="search">
</div>
</form>
</fieldset>
</section>
<#include "menu.ftl"> <#include "menu.ftl">
${body} ${body}

View file

@ -0,0 +1,14 @@
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<section id="search" role="region">
<fieldset>
<legend>${i18n().search_form}</legend>
<form id="search-form" action="${urls.search}" name="search" role="search" accept-charset="UTF-8" method="POST">
<div id="search-field">
<input type="text" name="querytext" class="search-vitro" value="${querytext!}" autocapitalize="off" />
<input type="submit" value="${i18n().search_button}" class="search">
</div>
</form>
</fieldset>
</section>

View file

@ -134,10 +134,6 @@ submit_add_new_account = Add new account
account_created = Your {0} account has been created. account_created = Your {0} account has been created.
account_created_subject = Your {0} account has been created. account_created_subject = Your {0} account has been created.
account_created_email_html = @@file files/accountCreatedEmail.html
account_created_email_text = @@file files/accountCreatedEmail.txt
account_created_external_email_html = @@file files/accountCreatedExternalOnlyEmail.html
account_created_external_email_text = @@file files/accountCreatedExternalOnlyEmail.txt
confirm_delete_account_singular = Are you sure you want to delete this account? confirm_delete_account_singular = Are you sure you want to delete this account?
confirm_delete_account_plural = Are you sure you want to delete these accounts? confirm_delete_account_plural = Are you sure you want to delete these accounts?
@ -156,21 +152,11 @@ select_associated_profile = Select the associated profile
create_associated_profile = Create the associated profile create_associated_profile = Create the associated profile
email_changed_subject = Your {0} email account has been changed. email_changed_subject = Your {0} email account has been changed.
email_changed_html = @@file files/accountEmailChanged.html
email_changed_text = @@file files/accountEmailChanged.txt
create_your_password = Create your Password create_your_password = Create your Password
password_created_subject = Your {0} password has successfully been created. password_created_subject = Your {0} password has successfully been created.
password_created_email_html = @@file files/passwordCreatedEmail.html
password_created_email_text = @@file files/passwordCreatedEmail.txt
password_reset_pending_subject = {0} reset password request password_reset_pending_subject = {0} reset password request
password_reset_pending_email_html = @@file files/passwordResetPending.html
password_reset_pending_email_text = @@file files/passwordResetPending.txt
password_reset_complete_subject = Your {0} password changed. password_reset_complete_subject = Your {0} password changed.
password_reset_complete_email_html = @@file files/passwordResetComplete.html
password_reset_complete_email_text = @@file files/passwordResetComplete.txt
reset_your_password = Reset your Password reset_your_password = Reset your Password
first_time_login = First time log in first_time_login = First time log in
@ -193,8 +179,6 @@ password_saved_please_login = Your password has been saved. Please log in.
please_provide_contact_information = Please provide your contact information to finish creating your account. please_provide_contact_information = Please provide your contact information to finish creating your account.
first_time_login_note = Note: An email will be sent to the address entered above notifying \ first_time_login_note = Note: An email will be sent to the address entered above notifying \
that an account has been created. that an account has been created.
first_time_external_email_html = @@file files/accountFirstTimeExternal.html
first_time_external_email_text = @@file files/accountFirstTimeExternal.txt
myAccount_heading = My account myAccount_heading = My account
myAccount_confirm_changes = Your changes have been saved. myAccount_confirm_changes = Your changes have been saved.
@ -885,3 +869,5 @@ processing_icon = processing
selection_in_process = Your selection is being processed. selection_in_process = Your selection is being processed.
view_labels_capitalized = View Labels view_labels_capitalized = View Labels
view_labels_for = View Labels for view_labels_for = View Labels for
select_an_existing_document = Select an existing document

View file

@ -1,39 +0,0 @@
<html>
<head>
<title>{1}</title>
</head>
<body>
<p>
{2} {3}
</p>
<p>
<strong>Congratulations!</strong>
</p>
<p>
We have created your new account on {0}, associated with {4}.
</p>
<p>
If you did not request this new account you can safely ignore this email.
This request will expire if not acted upon for 30 days.
</p>
<p>
Click the link below to create your password for your new account using our secure server.
</p>
<p>
<a href="{5}" title="password">{5}</a>
</p>
<p>
If the link above doesn't work, you can copy and paste the link directly into your browser's address bar.
</p>
<p>
Thanks!
</p>
</body>
</html>

View file

@ -1,17 +0,0 @@
{2} {3}
Congratulations!
We have created your new account on {0},
associated with {4}.
If you did not request this new account you can safely ignore this email.
This request will expire if not acted upon for 30 days.
Paste the link below into your browser's address bar to create your password
for your new account using our secure server.
{5}
Thanks!

View file

@ -1,22 +0,0 @@
<html>
<head>
<title>${1}</title>
</head>
<body>
<p>
${2} ${3}
</p>
<p>
<strong>Congratulations!</strong>
</p>
<p>
We have created your new VIVO account associated with ${4}.
</p>
<p>
Thanks!
</p>
</body>
</html>

View file

@ -1,9 +0,0 @@
${2} ${3}
Congratulations!
We have created your new VIVO account associated with
${4}.
Thanks!

View file

@ -1,19 +0,0 @@
<html>
<head>
<title>{1}</title>
</head>
<body>
<p>
Hi, {2} ${3}
</p>
<p>
You recently changed the email address associated with
${2} ${3}
</p>
<p>
Thank you.
</p>
</body>
</html>

View file

@ -1,6 +0,0 @@
Hi, {2} {3}
You recently changed the email address associated with
{2} {3}
Thank you.

View file

@ -1,22 +0,0 @@
<html>
<head>
<title>{1}</title>
</head>
<body>
<p>
{2} {3}
</p>
<p>
<strong>Congratulations!</strong>
</p>
<p>
We have created your new {0} account associated with {4}.
</p>
<p>
Thanks!
</p>
</body>
</html>

View file

@ -1,8 +0,0 @@
{2} {3}
Congratulations!
We have created your new {0} account associated with
{4}
Thanks!

View file

@ -1,22 +0,0 @@
<html>
<head>
<title>{1}</title>
</head>
<body>
<p>
{2} {3}
</p>
<p>
<strong>Password successfully created.</strong>
</p>
<p>
Your new password associated with {4} has been created.
</p>
<p>
Thank you.
</p>
</body>
</html>

View file

@ -1,8 +0,0 @@
{2} {3}
Password successfully created.
Your new password associated with {4}
has been created.
Thank you.

Some files were not shown because too many files have changed in this diff Show more