NIHVIVO-1923 Moving construction of activityTypeQuery into a separate method, since it's lengthy
This commit is contained in:
parent
cc722d5ad0
commit
605b0c974e
1 changed files with 65 additions and 32 deletions
|
@ -25,10 +25,15 @@
|
|||
<%@ page import="java.util.List" %>
|
||||
<%@ page import="java.util.ArrayList" %>
|
||||
<%@ page import="java.util.Arrays" %>
|
||||
<%@ page import="java.util.Set" %>
|
||||
<%@ page import="java.util.HashSet" %>
|
||||
|
||||
<%@ page import="com.hp.hpl.jena.rdf.model.Model" %>
|
||||
<%@ page import="com.hp.hpl.jena.vocabulary.XSD" %>
|
||||
|
||||
<%@ page import="org.json.JSONObject" %>
|
||||
<%@ page import="org.json.JSONException" %>
|
||||
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration" %>
|
||||
|
@ -218,40 +223,19 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.
|
|||
SELECT ?existingRoleLabel WHERE { ?role <${label}> ?existingRoleLabel . }
|
||||
</v:jsonset>
|
||||
|
||||
<%
|
||||
String objectClassUri = vreq.getParameter("roleActivityType_objectClassUri");
|
||||
if (StringUtils.isNotBlank(objectClassUri)) { %>
|
||||
<c:set var="objectClassUri" value="<%= objectClassUri %>" />
|
||||
<%--
|
||||
<v:jsonset var="activityTypeQuery">
|
||||
PREFIX core: <${vivoCore}>
|
||||
PREFIX rdfs: <${rdfs}>
|
||||
SELECT ?existingActivityType WHERE {
|
||||
?role core:roleIn ?existingActivity .
|
||||
?existingActivity a ?existingActivityType .
|
||||
?existingActivityType rdfs:subClassOf <${objectClassUri}> .
|
||||
}
|
||||
</v:jsonset>
|
||||
--%>
|
||||
<%
|
||||
/*
|
||||
} else {
|
||||
// Need to get the hardcoded literals and filter for them
|
||||
String optionsType = vreq.getParameter("roleActivityType_optionsType");
|
||||
if ("HARCODED_LITERALS".equals(optionsType)) {
|
||||
String typeLiteralOptions = vreq.getParameter("roleActivityType_literalOptions");
|
||||
if (StringUtils.isNotBlank(typeLiteralOptions)) {
|
||||
List<String> types = new ArrayList<String>();
|
||||
}
|
||||
*/
|
||||
} else {
|
||||
request.setAttribute("typeQuery", getActivityTypeQuery(vreq));
|
||||
%>
|
||||
<v:jsonset var="activityTypeQuery">
|
||||
PREFIX core: <${vivoCore}>
|
||||
SELECT ?existingActivityType WHERE {
|
||||
?role core:roleIn ?existingActivity .
|
||||
?existingActivity a ?existingActivityType .
|
||||
}
|
||||
</v:jsonset>
|
||||
<% } %>
|
||||
<v:jsonset var="activityTypeQuery">${typeQuery}</v:jsonset>
|
||||
|
||||
<v:jsonset var="existingIntervalNodeQuery" >
|
||||
SELECT ?existingIntervalNode WHERE {
|
||||
|
@ -551,3 +535,52 @@ if (StringUtils.isNotBlank(objectClassUri)) { %>
|
|||
<% } %>
|
||||
|
||||
<jsp:include page="${postForm}"/>
|
||||
|
||||
<%!
|
||||
// The activity type query results must be limited to the values in the activity type select element.
|
||||
// Sometimes the query returns a superclass such as owl:Thing instead.
|
||||
private String getActivityTypeQuery(VitroRequest vreq) {
|
||||
|
||||
String activityTypeQuery = null;
|
||||
String vivoCore = "http://vivoweb.org/ontology/core#";
|
||||
String defaultActivityTypeQuery =
|
||||
"PREFIX core: <" + vivoCore + ">\n" +
|
||||
"SELECT ?existingActivityType WHERE { \n" +
|
||||
"?role core:roleIn ?existingActivity . \n" +
|
||||
"?existingActivity a ?existingActivityType . \n" +
|
||||
"}";
|
||||
|
||||
// Select options are subclasses of a specified class
|
||||
String objectClassUri = vreq.getParameter("roleActivityType_objectClassUri");
|
||||
if (StringUtils.isNotBlank(objectClassUri)) {
|
||||
log.debug("objectClassUri = " + objectClassUri);
|
||||
activityTypeQuery =
|
||||
"PREFIX core: <" + vivoCore + ">\n" +
|
||||
"PREFIX rdfs: <" + VitroVocabulary.RDFS + ">\n" +
|
||||
"SELECT ?existingActivityType WHERE {\n" +
|
||||
"?role core:roleIn ?existingActivity . \n" +
|
||||
"?existingActivity a ?existingActivityType . \n" +
|
||||
"?existingActivityType rdfs:subClassOf <" + objectClassUri + "> . \n" +
|
||||
"}";
|
||||
} else {
|
||||
String optionsType = vreq.getParameter("roleActivityType_optionsType");
|
||||
// Select options are hardcoded
|
||||
if ("HARDCODED_LITERALS".equals(optionsType)) {
|
||||
String typeLiteralOptions = vreq.getParameter("roleActivityType_literalOptions");
|
||||
if (StringUtils.isNotBlank(typeLiteralOptions)) {
|
||||
try {
|
||||
JSONObject json = new JSONObject(typeLiteralOptions);
|
||||
Set<String> selectOptions = new HashSet<String>();
|
||||
} catch (JSONException e) {
|
||||
activityTypeQuery = defaultActivityTypeQuery;
|
||||
}
|
||||
}
|
||||
activityTypeQuery = defaultActivityTypeQuery; // temporary
|
||||
} else {
|
||||
activityTypeQuery = defaultActivityTypeQuery;
|
||||
}
|
||||
}
|
||||
log.debug("Activity type query: " + activityTypeQuery);
|
||||
return activityTypeQuery;
|
||||
}
|
||||
%>
|
Loading…
Add table
Reference in a new issue