2011-07-07 21:23:51 +00:00
|
|
|
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
|
|
|
|
|
2011-07-11 16:09:09 +00:00
|
|
|
<%-- Landing page for managing web pages associated with an individual. From here, we do one of three things:
|
2011-07-08 21:30:47 +00:00
|
|
|
|
2011-07-11 16:09:09 +00:00
|
|
|
1. If arriving here by clicking add link on profile, go directly to add form.
|
|
|
|
2. If arriving here by edit link on the profile page, stay here for web page management (can add, edit, or delete).
|
|
|
|
3. If arriving here after an add/edit form submission, stay here for additional web page management.
|
2011-07-08 21:30:47 +00:00
|
|
|
|
|
|
|
--%>
|
|
|
|
|
|
|
|
<%@ page import="java.util.List" %>
|
|
|
|
<%@ page import="java.util.ArrayList" %>
|
|
|
|
<%@ page import="java.util.Arrays" %>
|
2011-07-11 21:13:05 +00:00
|
|
|
<%@ page import="java.util.Map" %>
|
2011-07-08 21:30:47 +00:00
|
|
|
|
2011-07-07 21:23:51 +00:00
|
|
|
<%@ page import="com.hp.hpl.jena.rdf.model.Literal" %>
|
|
|
|
<%@ page import="com.hp.hpl.jena.vocabulary.XSD" %>
|
2011-07-11 21:13:05 +00:00
|
|
|
<%@ page import="com.hp.hpl.jena.query.ResultSet" %>
|
|
|
|
<%@ page import="com.hp.hpl.jena.rdf.model.RDFNode" %>
|
|
|
|
<%@ page import="com.hp.hpl.jena.query.QuerySolution" %>
|
|
|
|
<%@ page import="com.hp.hpl.jena.query.Dataset" %>
|
2011-07-07 21:23:51 +00:00
|
|
|
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual" %>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.VClass" %>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfiguration" %>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest" %>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory" %>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataProperty" %>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao" %>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary"%>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%>
|
2011-07-08 21:30:47 +00:00
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.JavaScript" %>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Css" %>
|
2011-07-11 21:13:05 +00:00
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils" %>
|
2011-07-07 21:23:51 +00:00
|
|
|
|
2011-07-11 21:13:05 +00:00
|
|
|
<%@ page import="org.apache.commons.lang.StringUtils" %>
|
2011-07-07 21:23:51 +00:00
|
|
|
<%@ page import="org.apache.commons.logging.Log" %>
|
|
|
|
<%@ page import="org.apache.commons.logging.LogFactory" %>
|
|
|
|
|
|
|
|
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
|
|
|
|
<%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %>
|
2011-07-11 21:13:05 +00:00
|
|
|
|
2011-07-07 21:23:51 +00:00
|
|
|
<%!
|
2011-07-11 16:09:09 +00:00
|
|
|
public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.forms.manageWebpagesForIndividual.jsp");
|
2011-07-07 21:23:51 +00:00
|
|
|
%>
|
2011-07-11 16:09:09 +00:00
|
|
|
|
2011-07-07 21:23:51 +00:00
|
|
|
<%
|
|
|
|
|
2011-07-11 16:09:09 +00:00
|
|
|
String objectUri = (String) request.getAttribute("objectUri");
|
|
|
|
String view = request.getParameter("view");
|
2011-07-07 21:23:51 +00:00
|
|
|
|
2011-07-11 16:09:09 +00:00
|
|
|
if ( "form".equals(view) || // the url specifies form view
|
|
|
|
( view == null && objectUri == null ) ) { // add form always starts with form
|
|
|
|
|
|
|
|
%> <jsp:forward page="addEditWebpageForm.jsp" /> <%
|
|
|
|
|
2011-07-11 21:13:05 +00:00
|
|
|
} // else stay here to manage webpages
|
2011-07-07 21:23:51 +00:00
|
|
|
|
2011-07-11 16:09:09 +00:00
|
|
|
VitroRequest vreq = new VitroRequest(request);
|
|
|
|
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
|
|
|
vreq.setAttribute("defaultNamespace", wdf.getDefaultNamespace());
|
2011-07-08 21:30:47 +00:00
|
|
|
|
2011-07-11 16:09:09 +00:00
|
|
|
String subjectName = ((Individual)request.getAttribute("subject")).getName();
|
2011-07-11 21:13:05 +00:00
|
|
|
String subjectUri = (String) request.getAttribute("subjectUri");
|
|
|
|
|
|
|
|
List<Map<String, String>> webpages = getWebpages(subjectUri, vreq);
|
|
|
|
vreq.setAttribute("webpages", webpages);
|
|
|
|
|
|
|
|
String ulClass = "";
|
|
|
|
List<String> ulClasses = new ArrayList<String>();
|
|
|
|
if (webpages.size() > 1) {
|
|
|
|
// This class triggers application of dd styles. Don't wait for js to add
|
|
|
|
// the ui-sortable class, because then the page flashes as the styles are updated.
|
|
|
|
ulClasses.add("dd");
|
|
|
|
}
|
|
|
|
if (ulClasses.size() > 0) {
|
|
|
|
ulClass="class=\"" + StringUtils.join(ulClasses, " ") + "\"";
|
|
|
|
}
|
|
|
|
|
|
|
|
List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(),
|
|
|
|
JavaScript.CUSTOM_FORM_UTILS.path(),
|
|
|
|
//"/js/browserUtils.js",
|
|
|
|
"/edit/forms/js/manageWebpagesForIndividual.js"
|
|
|
|
));
|
|
|
|
request.setAttribute("customJs", customJs);
|
|
|
|
|
|
|
|
List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(),
|
|
|
|
Css.CUSTOM_FORM.path(),
|
|
|
|
"/edit/forms/css/manageWebpagesForIndividual.css"
|
|
|
|
));
|
|
|
|
request.setAttribute("customCss", customCss);
|
2011-07-07 21:23:51 +00:00
|
|
|
%>
|
|
|
|
|
2011-07-11 21:28:25 +00:00
|
|
|
<c:url var="deleteWebpageUrl" value="/edit/primitiveDelete" />
|
2011-07-11 21:40:51 +00:00
|
|
|
|
|
|
|
<c:set var="subjectUri" value="<%= subjectUri %>" />
|
|
|
|
<c:url var="returnToIndividualUrl" value="/individual?uri=${subjectUri}" />
|
2011-07-11 21:13:05 +00:00
|
|
|
|
2011-07-07 21:23:51 +00:00
|
|
|
<jsp:include page="${preForm}"/>
|
|
|
|
|
2011-07-11 16:09:09 +00:00
|
|
|
<h2><em><%= subjectName %></em></h2>
|
|
|
|
|
|
|
|
<h3>Manage Web Pages</h3>
|
|
|
|
|
2011-07-11 21:13:05 +00:00
|
|
|
<script type="text/javascript">
|
|
|
|
var webpageData = [];
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<ul id="manageWebpages" <%= ulClass %>>
|
|
|
|
|
|
|
|
<c:if test="${ empty webpages }">
|
|
|
|
<p>This individual currently has no web pages specified. Add a new web page by clicking on the button below.</p>
|
|
|
|
</c:if>
|
|
|
|
|
|
|
|
<c:forEach var="webpage" items="${webpages}">
|
|
|
|
<li class="webpage">
|
|
|
|
<c:set var="anchor">${ empty webpage.anchor ? webpage.url : webpage.anchor }</c:set>
|
|
|
|
<span class="webpageName">
|
|
|
|
<a href="${webpage.url}">${anchor}</a>
|
|
|
|
</span>
|
|
|
|
<span class="editingLinks">
|
|
|
|
<a href="" class="edit">Edit</a> |
|
2011-07-11 21:28:25 +00:00
|
|
|
<a href="${deleteWebpageUrl}" class="remove">Delete</a>
|
2011-07-11 21:13:05 +00:00
|
|
|
</span>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
webpageData.push({
|
|
|
|
"webpageUri": "${webpage.link}"
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</c:forEach>
|
|
|
|
</ul>
|
|
|
|
|
2011-07-11 21:40:51 +00:00
|
|
|
<a href="${showAddFormUrl}" id="showAddForm" class="button">Add Web Page</a>
|
|
|
|
<a href="${returnToIndividualUrl}" id="returnToIndividual">Return to Individual</a>
|
2011-07-07 21:23:51 +00:00
|
|
|
|
|
|
|
<jsp:include page="${postForm}"/>
|
2011-07-11 21:13:05 +00:00
|
|
|
|
|
|
|
<%!
|
|
|
|
|
|
|
|
private static String WEBPAGE_QUERY = ""
|
|
|
|
+ "PREFIX core: <http://vivoweb.org/ontology/core#> \n"
|
|
|
|
+ "SELECT DISTINCT ?link ?url ?anchor ?rank WHERE { \n"
|
|
|
|
+ " ?subject core:webpage ?link . \n"
|
|
|
|
+ " OPTIONAL { ?link core:linkURI ?url } \n"
|
|
|
|
+ " OPTIONAL { ?link core:linkAnchorText ?anchor } \n"
|
|
|
|
+ " OPTIONAL { ?link core:rank ?rank } \n"
|
|
|
|
+ "} ORDER BY ?rank";
|
|
|
|
|
|
|
|
|
|
|
|
private List<Map<String, String>> getWebpages(String subjectUri, VitroRequest vreq) {
|
|
|
|
|
|
|
|
String queryStr = QueryUtils.subUriForQueryVar(WEBPAGE_QUERY, "subject", subjectUri);
|
|
|
|
log.debug("Query string is: " + queryStr);
|
|
|
|
List<Map<String, String>> webpages = new ArrayList<Map<String, String>>();
|
|
|
|
try {
|
|
|
|
ResultSet results = QueryUtils.getQueryResults(queryStr, vreq);
|
|
|
|
while (results.hasNext()) {
|
|
|
|
QuerySolution soln = results.nextSolution();
|
|
|
|
RDFNode node = soln.get("link");
|
|
|
|
if (node.isURIResource()) {
|
|
|
|
webpages.add(QueryUtils.querySolutionToStringValueMap(soln));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.error(e, e);
|
|
|
|
}
|
|
|
|
|
|
|
|
return webpages;
|
|
|
|
}
|
|
|
|
|
|
|
|
%>
|