diff --git a/productMods/templates/freemarker/visualization/personlevel/coAuthorPersonLevel.ftl b/productMods/templates/freemarker/visualization/personlevel/coAuthorPersonLevel.ftl index 47d38d29..c684c32f 100644 --- a/productMods/templates/freemarker/visualization/personlevel/coAuthorPersonLevel.ftl +++ b/productMods/templates/freemarker/visualization/personlevel/coAuthorPersonLevel.ftl @@ -95,6 +95,7 @@ $(document).ready(function(){ <#-- Moniker--> +
4Back to Profile diff --git a/productMods/templates/freemarker/visualization/personlevel/coPIPersonLevel.ftl b/productMods/templates/freemarker/visualization/personlevel/coPIPersonLevel.ftl index df93b6d3..3caffdbc 100644 --- a/productMods/templates/freemarker/visualization/personlevel/coPIPersonLevel.ftl +++ b/productMods/templates/freemarker/visualization/personlevel/coPIPersonLevel.ftl @@ -92,7 +92,7 @@ $(document).ready(function(){ <#-- Moniker--> - +
4Back to Profile diff --git a/src/edu/cornell/mannlib/vitro/webapp/controller/visualization/DummyVisClientController.java b/src/edu/cornell/mannlib/vitro/webapp/controller/visualization/DummyVisClientController.java deleted file mode 100644 index ed1943e0..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/controller/visualization/DummyVisClientController.java +++ /dev/null @@ -1,104 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.controller.visualization; - -/* -Copyright (c) 2010, Cornell University -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of Cornell University nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -import java.io.IOException; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import edu.cornell.mannlib.vedit.controller.BaseEditController; -import edu.cornell.mannlib.vitro.webapp.beans.Portal; -import edu.cornell.mannlib.vitro.webapp.controller.Controllers; -import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; - -/** - * Services a sparql query. This will return a simple error message and a 501 if - * there is no jena Model. - * - * @author bdc34 - * - */ -public class DummyVisClientController extends BaseEditController { - - private static final long serialVersionUID = 1L; - - private static final Log log = LogFactory.getLog(DummyVisClientController.class.getName()); - - @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException - { - this.doGet(request,response); - } - - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException - { - if (!checkLoginStatus(request, response)) - return; - - super.doGet(request, response); - - VitroRequest vreq = new VitroRequest(request); - prepareVisualizationQueryResponse(request, response, vreq); - - return; - } - - private void prepareVisualizationQueryResponse(HttpServletRequest request, - HttpServletResponse response, VitroRequest vreq) { - - Portal portal = vreq.getPortal(); - - RequestDispatcher requestDispatcher = request.getRequestDispatcher(Controllers.BASIC_JSP); - request.setAttribute("bodyJsp", "/templates/visualization/dummy_vis_client.jsp"); - request.setAttribute("portalBean", portal); - request.setAttribute("title", "Dummy Visualization Client"); - request.setAttribute("scripts", "/templates/visualization/visualization_scripts.jsp"); - - try { - requestDispatcher.forward(request, response); - } catch (Exception e) { - log.error("EntityEditController could not forward to view."); - log.error(e.getMessage()); - log.error(e.getStackTrace()); - } - - } - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/controller/visualization/VisualizationController.java b/src/edu/cornell/mannlib/vitro/webapp/controller/visualization/VisualizationController.java deleted file mode 100644 index 70d8a233..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/controller/visualization/VisualizationController.java +++ /dev/null @@ -1,224 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.controller.visualization; - -import java.io.IOException; -import java.util.Map; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletException; -import javax.servlet.ServletOutputStream; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.beans.factory.BeanFactory; -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -import com.hp.hpl.jena.query.DataSource; -import com.hp.hpl.jena.query.DatasetFactory; -import com.hp.hpl.jena.query.Syntax; -import com.hp.hpl.jena.rdf.model.Model; -import com.hp.hpl.jena.rdf.model.ModelMaker; - -import edu.cornell.mannlib.vedit.controller.BaseEditController; -import edu.cornell.mannlib.vitro.webapp.beans.Portal; -import edu.cornell.mannlib.vitro.webapp.controller.Controllers; -import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; -import edu.cornell.mannlib.vitro.webapp.visualization.constants.VisConstants; -import edu.cornell.mannlib.vitro.webapp.visualization.visutils.VisualizationRequestHandler; - -/** - * Services a visualization request. This will return a simple error message and a 501 if - * there is no jena Model. - * - * @author cdtank - */ -@SuppressWarnings("serial") -public class VisualizationController extends BaseEditController { - - private Map visualizationIDsToClass; - - public static final String URL_ENCODING_SCHEME = "UTF-8"; - - private static final Log log = LogFactory.getLog(VisualizationController.class.getName()); - - protected static final Syntax SYNTAX = Syntax.syntaxARQ; - - /* This method is overridden to inject vis dependencies i.e. the vis algorithms that are - * being implemented into the vis controller. Modified Dependency Injection pattern is - * used here. XML file containing the location of all the vis is saved in accessible folder. - * @see javax.servlet.GenericServlet#init() - */ - @Override - public void init() throws ServletException { - super.init(); - try { - - String resourcePath = - getServletContext() - .getRealPath(VisualizationFrameworkConstants - .RELATIVE_LOCATION_OF_VISUALIZATIONS_BEAN); - - ApplicationContext context = new ClassPathXmlApplicationContext( - "file:" + resourcePath); - - BeanFactory factory = context; - - VisualizationInjector visualizationInjector = - (VisualizationInjector) factory.getBean("visualizationInjector"); - - visualizationIDsToClass = visualizationInjector.getVisualizationIDToClass(); - - } catch (Exception e) { - log.error(e); - } - } - - - @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - this.doGet(request, response); - } - - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - super.doGet(request, response); - - VitroRequest vitroRequest = new VitroRequest(request); - - /* - * Based on the query parameters passed via URI get the appropriate visualization - * request handler. - * */ - VisualizationRequestHandler visRequestHandler = - getVisualizationRequestHandler(request, response, vitroRequest); - - /* - * Pass the query to the selected visualization request handler & render the visualization. - * Since the visualization content is directly added to the response object we are side- - * effecting this method. - * */ - renderVisualization(request, response, vitroRequest, visRequestHandler); - - return; - } - - - private void renderVisualization(HttpServletRequest request, - HttpServletResponse response, - VitroRequest vitroRequest, - VisualizationRequestHandler visRequestHandler) - throws ServletException, IOException { - - DataSource dataSource = setupJENADataSource(request, - response, - vitroRequest); - if (dataSource != null && visRequestHandler != null) { - - visRequestHandler.generateVisualization(vitroRequest, - request, - response, - log, - dataSource); - - } else { - - String errorMessage = "Data Model Empty &/or Inappropriate " - + "query parameters were submitted. "; - - handleMalformedParameters(errorMessage, - request, - response); - - log.error(errorMessage); - } - } - - private VisualizationRequestHandler getVisualizationRequestHandler( - HttpServletRequest request, - HttpServletResponse response, - VitroRequest vitroRequest) - throws ServletException, IOException { - - String visType = vitroRequest.getParameter(VisualizationFrameworkConstants - .VIS_TYPE_KEY); - VisualizationRequestHandler visRequestHandler = null; - try { - visRequestHandler = visualizationIDsToClass.get(visType); - } catch (NullPointerException nullKeyException) { - - /* - * This is side-effecting because the error content is directly - * added to the request object. From where it is redirected to - * the error page. - * */ - handleMalformedParameters("Inappropriate query parameters were submitted. ", - request, - response); - } - return visRequestHandler; - } - - private DataSource setupJENADataSource(HttpServletRequest request, - HttpServletResponse response, VitroRequest vreq) { - - Model model = vreq.getJenaOntModel(); // getModel() - if (model == null) { - doNoModelInContext(request, response); - return null; - } - - log.debug("rdfResultFormat was: " + VisConstants.RDF_RESULT_FORMAT_PARAM); - - DataSource dataSource = DatasetFactory.create(); - ModelMaker maker = (ModelMaker) getServletContext().getAttribute("vitroJenaModelMaker"); - - dataSource.setDefaultModel(model); - - return dataSource; - } - - private void doNoModelInContext(HttpServletRequest request, HttpServletResponse res) { - try { - res.setStatus(HttpServletResponse.SC_NOT_IMPLEMENTED); - ServletOutputStream sos = res.getOutputStream(); - sos.println("this service is not supporeted by the current " - + "webapp configuration. A jena model is required in the " - + "servlet context."); - - } catch (IOException e) { - log.error("Could not write to ServletOutputStream"); - } - } - - private void handleMalformedParameters(String errorMessage, HttpServletRequest request, - HttpServletResponse response) - throws ServletException, IOException { - - VitroRequest vreq = new VitroRequest(request); - Portal portal = vreq.getPortal(); - - request.setAttribute("error", errorMessage); - - RequestDispatcher requestDispatcher = request.getRequestDispatcher(Controllers.BASIC_JSP); - request.setAttribute("bodyJsp", "/templates/visualization/visualization_error.jsp"); - request.setAttribute("portalBean", portal); - request.setAttribute("title", "Visualization Query Error"); - - try { - requestDispatcher.forward(request, response); - } catch (Exception e) { - log.error("EntityEditController could not forward to view."); - log.error(e.getMessage()); - log.error(e.getStackTrace()); - } - } - -} - diff --git a/src/edu/cornell/mannlib/vitro/webapp/controller/visualization/VisualizationFrameworkConstants.java b/src/edu/cornell/mannlib/vitro/webapp/controller/visualization/VisualizationFrameworkConstants.java deleted file mode 100644 index 22418b1d..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/controller/visualization/VisualizationFrameworkConstants.java +++ /dev/null @@ -1,91 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.controller.visualization; - -public class VisualizationFrameworkConstants { - - /* - * Contains the location of bean containing info on all the visualizations - * available in that instance. Currently it is stored under - * "productMods/WEB-INF..." - */ - public static final String RELATIVE_LOCATION_OF_VISUALIZATIONS_BEAN = - "/WEB-INF/visualization/visualizations-beans-injection.xml"; - - /* - * Freemarker Version - * */ - public static final String RELATIVE_LOCATION_OF_FM_VISUALIZATIONS_BEAN = - "/WEB-INF/visualization/visualizations-beans-injection-fm.xml"; - - public static final String ERROR_TEMPLATE = "/visualization/visualizationError.ftl"; - - /* - * Vis URL prefix that is seen by all the users - */ - public static final String VISUALIZATION_URL_PREFIX = "/visualization"; - public static final String FREEMARKERIZED_VISUALIZATION_URL_PREFIX = "/visualizationfm"; - public static final String AJAX_VISUALIZATION_SERVICE_URL_PREFIX = "/visualizationAjax"; - public static final String DATA_VISUALIZATION_SERVICE_URL_PREFIX = "/visualizationData"; - - public static final String INDIVIDUAL_URL_PREFIX = "/individual"; - - /* - * These represent possible query keys in a URI for visualization purposes. - * Examples, - * 1. http://vivo.indiana.edu/visualization?uri=http://vivoweb.org/ontology/core/Person10979&vis=person_level&render_mode=standalone - * 2. http://vivo.indiana.edu/visualization?uri=http://vivoweb.org/ontology/core/Person72&vis=person_pub_count&render_mode=dynamic&container=vis_container - * */ - public static final String VIS_TYPE_KEY = "vis"; - public static final String VIS_CONTAINER_KEY = "container"; - public static final String INDIVIDUAL_URI_KEY = "uri"; - public static final String VIS_MODE_KEY = "vis_mode"; - public static final String RENDER_MODE_KEY = "render_mode"; - - /* - * These values represent possible render modes. - * */ - public static final String STANDALONE_RENDER_MODE = "standalone"; - public static final String DYNAMIC_RENDER_MODE = "dynamic"; - public static final String DATA_RENDER_MODE = "data"; - public static final String PDF_RENDER_MODE = "pdf"; - - /* - * These values represent possible sub-vis modes. - * */ - public static final String IMAGE_VIS_MODE = "image"; - public static final String SPARKLINE_VIS_MODE = "sparkline"; - public static final String COAUTHORSLIST_VIS_MODE = "coauthors"; - public static final String SHORT_SPARKLINE_VIS_MODE = "short"; - public static final String FULL_SPARKLINE_VIS_MODE = "full"; - public static final String COPI_VIS_MODE = "copi"; - - /* - * These values represent possible utilities vis modes. - * */ - public static final String PROFILE_INFO_UTILS_VIS_MODE = "PROFILE_INFO"; - public static final String PROFILE_UTILS_VIS_MODE = "PROFILE_URL"; - public static final String COAUTHOR_UTILS_VIS_MODE = "COAUTHORSHIP_URL"; - public static final String PERSON_LEVEL_UTILS_VIS_MODE = "PERSON_LEVEL_URL"; - public static final String COPI_UTILS_VIS_MODE = "COPI_URL"; - public static final String IMAGE_UTILS_VIS_MODE = "IMAGE_URL"; - public static final String UNIVERSITY_COMPARISON_VIS_MODE = "UNIVERSITY"; - public static final String SCHOOL_COMPARISON_VIS_MODE = "SCHOOL"; - public static final String DEPARTMENT_COMPARISON_VIS_MODE = "DEPARTMENT"; - - - /* - * These values represent possible visualizations provided as values to the "vis" url key. - * */ - public static final String PERSON_PUBLICATION_COUNT_VIS = "person_pub_count"; - public static final String PERSON_GRANT_COUNT_VIS = "person_grant_count"; - public static final String PDF_REPORT_VIS = "pdf_report"; - public static final String COLLEGE_PUBLICATION_COUNT_VIS = "college_pub_count"; - public static final String COAUTHORSHIP_VIS = "coauthorship"; - public static final String PERSON_LEVEL_VIS = "person_level"; - public static final String UTILITIES_VIS = "utilities"; - public static final String ENTITY_COMPARISON_VIS = "entity_comparison"; - public static final String CO_PI_VIS = "coprincipalinvestigator"; - - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/controller/visualization/VisualizationInjector.java b/src/edu/cornell/mannlib/vitro/webapp/controller/visualization/VisualizationInjector.java deleted file mode 100644 index b9ecc8bd..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/controller/visualization/VisualizationInjector.java +++ /dev/null @@ -1,19 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ -package edu.cornell.mannlib.vitro.webapp.controller.visualization; - -import java.util.Map; - -import edu.cornell.mannlib.vitro.webapp.visualization.visutils.VisualizationRequestHandler; - -public class VisualizationInjector { - private Map visualizationIDToClass; - - public Map getVisualizationIDToClass() { - return visualizationIDToClass; - } - - public void setVisualizations(Map visualizationIDToClass) { - this.visualizationIDToClass = visualizationIDToClass; - } - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/entitygrantcount/EntityGrantCountQueryRunner.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/entitygrantcount/EntityGrantCountQueryRunner.java deleted file mode 100644 index 2f6d9169..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/entitygrantcount/EntityGrantCountQueryRunner.java +++ /dev/null @@ -1,7 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.visualization.entitygrantcount; - -public class EntityGrantCountQueryRunner { - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/personpubcount/PersonPublicationCountRequestHandler.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/personpubcount/PersonPublicationCountRequestHandler.java index f89f5e71..d89024b5 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/personpubcount/PersonPublicationCountRequestHandler.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/personpubcount/PersonPublicationCountRequestHandler.java @@ -33,7 +33,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.In import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SparklineData; import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.UtilityFunctions; import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.VisualizationRequestHandler; -import edu.cornell.mannlib.vitro.webapp.visualization.visutils.PDFDocument; +import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.PDFDocument; import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.QueryRunner; /** diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/utilities/UtilitiesRequestHandler.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/utilities/UtilitiesRequestHandler.java deleted file mode 100644 index 5f169db2..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/utilities/UtilitiesRequestHandler.java +++ /dev/null @@ -1,305 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.visualization.utilities; - -import java.io.IOException; -import java.io.PrintWriter; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.logging.Log; - -import com.google.gson.Gson; -import com.hp.hpl.jena.query.DataSource; -import com.hp.hpl.jena.query.QuerySolution; -import com.hp.hpl.jena.query.ResultSet; -import com.hp.hpl.jena.rdf.model.RDFNode; - -import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; -import edu.cornell.mannlib.vitro.webapp.controller.visualization.VisualizationController; -import edu.cornell.mannlib.vitro.webapp.controller.visualization.VisualizationFrameworkConstants; -import edu.cornell.mannlib.vitro.webapp.filestorage.FileServingHelper; -import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryFieldLabels; -import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException; -import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.GenericQueryMap; -import edu.cornell.mannlib.vitro.webapp.visualization.visutils.AllPropertiesQueryRunner; -import edu.cornell.mannlib.vitro.webapp.visualization.visutils.GenericQueryRunner; -import edu.cornell.mannlib.vitro.webapp.visualization.visutils.QueryRunner; -import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UtilityFunctions; -import edu.cornell.mannlib.vitro.webapp.visualization.visutils.VisualizationRequestHandler; - -/** - * This request handler is used when you need helpful information to add more context - * to the visualization. It does not have any code for generating the visualization, - * just fires sparql queries to get info for specific cases like, - * 1. thumbnail/image location for a particular individual - * 2. profile information for a particular individual like label, moniker etc - * 3. person level vis url for a particular individual - * etc. - * @author cdtank - */ -public class UtilitiesRequestHandler implements VisualizationRequestHandler { - - public void generateVisualization(VitroRequest vitroRequest, - HttpServletRequest request, - HttpServletResponse response, - Log log, - DataSource dataSource) { - - String individualURI = vitroRequest.getParameter( - VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY); - - String visMode = vitroRequest.getParameter( - VisualizationFrameworkConstants.VIS_MODE_KEY); - - String preparedURL = ""; - - try { - - /* - * If the info being requested is about a profile which includes the name, moniker - * & image url. - * */ - if (VisualizationFrameworkConstants.PROFILE_INFO_UTILS_VIS_MODE - .equalsIgnoreCase(visMode)) { - - - String filterRule = "?predicate = j.2:mainImage " - + "|| ?predicate = vitro:moniker " - + "|| ?predicate = rdfs:label"; - - QueryRunner profileQueryHandler = - new AllPropertiesQueryRunner(individualURI, - filterRule, - dataSource, - log); - - try { - - GenericQueryMap profilePropertiesToValues = - profileQueryHandler.getQueryResult(); - - profilePropertiesToValues.addEntry("imageContextPath", - request.getContextPath()); - - Gson profileInformation = new Gson(); - - prepareUtilitiesResponse( - profileInformation.toJson(profilePropertiesToValues), - response); - - return; - - - } catch (MalformedQueryParametersException e) { - try { - UtilityFunctions.handleMalformedParameters( - e.getMessage(), - "Visualization Query Error - Utilities Profile Info", - vitroRequest, - request, - response, - log); - } catch (ServletException e1) { - log.error(e1.getStackTrace()); - } catch (IOException e1) { - log.error(e1.getStackTrace()); - } - return; - } - } else if (VisualizationFrameworkConstants.IMAGE_UTILS_VIS_MODE - .equalsIgnoreCase(visMode)) { - /* - * If the url being requested is about a standalone image, which is used when we - * want to render an image & other info for a co-author OR ego for that matter. - * */ - - Map fieldLabelToOutputFieldLabel = new HashMap(); - fieldLabelToOutputFieldLabel.put("downloadLocation", - QueryFieldLabels.THUMBNAIL_LOCATION_URL); - fieldLabelToOutputFieldLabel.put("fileName", QueryFieldLabels.THUMBNAIL_FILENAME); - - String whereClause = "<" + individualURI - + "> j.2:thumbnailImage ?thumbnailImage . " - + "?thumbnailImage j.2:downloadLocation " - + "?downloadLocation ; j.2:filename ?fileName ."; - - - - QueryRunner imageQueryHandler = - new GenericQueryRunner(individualURI, - fieldLabelToOutputFieldLabel, - whereClause, - dataSource, - log); - - try { - - String thumbnailAccessURL = - getThumbnailInformation( - imageQueryHandler.getQueryResult(), - fieldLabelToOutputFieldLabel); - - prepareUtilitiesResponse(thumbnailAccessURL, response); - return; - - - } catch (MalformedQueryParametersException e) { - try { - UtilityFunctions.handleMalformedParameters( - e.getMessage(), - "Visualization Query Error - Utilities Image Info", - vitroRequest, - request, - response, - log); - } catch (ServletException e1) { - log.error(e1.getStackTrace()); - } catch (IOException e1) { - log.error(e1.getStackTrace()); - } - return; - } - } else if (VisualizationFrameworkConstants.COAUTHOR_UTILS_VIS_MODE - .equalsIgnoreCase(visMode)) { - - /* - * By default we will be generating profile url else some specific url like - * coAuthorShip vis url for that individual. - * */ - preparedURL += request.getContextPath() - + VisualizationFrameworkConstants.VISUALIZATION_URL_PREFIX - + "?" - + VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY - + "=" + URLEncoder.encode(individualURI, - VisualizationController.URL_ENCODING_SCHEME).toString() - + "&" - + VisualizationFrameworkConstants.VIS_TYPE_KEY - + "=" + URLEncoder.encode("coauthorship", - VisualizationController.URL_ENCODING_SCHEME).toString() - + "&" - + VisualizationFrameworkConstants.RENDER_MODE_KEY - + "=" + URLEncoder.encode(VisualizationFrameworkConstants - .STANDALONE_RENDER_MODE, - VisualizationController.URL_ENCODING_SCHEME) - .toString(); - - - prepareUtilitiesResponse(preparedURL, response); - return; - } else if (VisualizationFrameworkConstants.PERSON_LEVEL_UTILS_VIS_MODE - .equalsIgnoreCase(visMode)) { - /* - * By default we will be generating profile url else some specific url like - * coAuthorShip vis url for that individual. - * */ - preparedURL += request.getContextPath() - + VisualizationFrameworkConstants.VISUALIZATION_URL_PREFIX - + "?" - + VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY - + "=" + URLEncoder.encode(individualURI, - VisualizationController.URL_ENCODING_SCHEME).toString() - + "&" - + VisualizationFrameworkConstants.VIS_TYPE_KEY - + "=" + URLEncoder.encode("person_level", - VisualizationController.URL_ENCODING_SCHEME).toString() - + "&" - + VisualizationFrameworkConstants.RENDER_MODE_KEY - + "=" + URLEncoder.encode(VisualizationFrameworkConstants - .STANDALONE_RENDER_MODE, - VisualizationController.URL_ENCODING_SCHEME).toString() - + "&" - + VisualizationFrameworkConstants.VIS_MODE_KEY - + "=" + URLEncoder.encode("coauthorship", - VisualizationController.URL_ENCODING_SCHEME).toString(); - - prepareUtilitiesResponse(preparedURL, response); - return; - } else if (VisualizationFrameworkConstants.COPI_UTILS_VIS_MODE - .equalsIgnoreCase(visMode)) { - - preparedURL += request.getContextPath() - + VisualizationFrameworkConstants.VISUALIZATION_URL_PREFIX - + "?" - + VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY - + "=" + URLEncoder.encode(individualURI, - VisualizationController.URL_ENCODING_SCHEME).toString() - + "&" - + VisualizationFrameworkConstants.VIS_TYPE_KEY - + "=" + URLEncoder.encode("person_level", - VisualizationController.URL_ENCODING_SCHEME).toString() - + "&" - + VisualizationFrameworkConstants.RENDER_MODE_KEY - + "=" + URLEncoder.encode(VisualizationFrameworkConstants - .STANDALONE_RENDER_MODE, - VisualizationController.URL_ENCODING_SCHEME).toString() - + "&" - + VisualizationFrameworkConstants.VIS_MODE_KEY - + "=" + URLEncoder.encode("copi", - VisualizationController.URL_ENCODING_SCHEME).toString(); - - prepareUtilitiesResponse(preparedURL, response); - return; - } else { - - preparedURL += request.getContextPath() - + VisualizationFrameworkConstants.INDIVIDUAL_URL_PREFIX - + "?" - + VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY - + "=" + URLEncoder.encode(individualURI, - VisualizationController.URL_ENCODING_SCHEME).toString(); - - prepareUtilitiesResponse(preparedURL, response); - return; - } - } catch (UnsupportedEncodingException e) { - log.error(e.getLocalizedMessage()); - } - - } - - private String getThumbnailInformation(ResultSet resultSet, - Map fieldLabelToOutputFieldLabel) { - - String finalThumbNailLocation = ""; - - while (resultSet.hasNext()) { - QuerySolution solution = resultSet.nextSolution(); - - - RDFNode downloadLocationNode = solution.get( - fieldLabelToOutputFieldLabel - .get("downloadLocation")); - RDFNode fileNameNode = solution.get(fieldLabelToOutputFieldLabel.get("fileName")); - - if (downloadLocationNode != null && fileNameNode != null) { - finalThumbNailLocation = - FileServingHelper - .getBytestreamAliasUrl(downloadLocationNode.toString(), - fileNameNode.toString()); - } - } - return finalThumbNailLocation; - } - - private void prepareUtilitiesResponse(String preparedURL, - HttpServletResponse response) { - - response.setContentType("text/plain"); - - try { - PrintWriter responseWriter = response.getWriter(); - responseWriter.append(preparedURL); - responseWriter.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } -} - diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/BiboDocument.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/BiboDocument.java deleted file mode 100644 index 759e76a5..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/BiboDocument.java +++ /dev/null @@ -1,183 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.visualization.valueobjects; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants; - -/** - * @author cdtank - * - */ -public class BiboDocument extends Individual { - - private String documentMoniker; - private String documentBlurb; - private String documentDescription; - private String publicationYear; - private String publicationYearMonth; - private String publicationDate; - private String parsedPublicationYear = VOConstants.DEFAULT_PUBLICATION_YEAR; - - public BiboDocument(String documentURL) { - super(documentURL); - } - - public String getDocumentURL() { - return this.getIndividualURI(); - } - - public String getDocumentMoniker() { - return documentMoniker; - } - - public void setDocumentMoniker(String documentMoniker) { - this.documentMoniker = documentMoniker; - } - - public String getDocumentLabel() { - return this.getIndividualLabel(); - } - - public void setDocumentLabel(String documentLabel) { - this.setIndividualLabel(documentLabel); - } - - public String getDocumentBlurb() { - return documentBlurb; - } - - public void setDocumentBlurb(String documentBlurb) { - this.documentBlurb = documentBlurb; - -// if (documentBlurb != null) { -// this.setParsedPublicationYear(parsePublicationYear(documentBlurb)); -// } - } - - private String parsePublicationYear(String documentBlurb) { - - /* - * This pattern will match all group of numbers which have only 4 digits - * delimited by the word boundary. - * */ - String pattern = "(?= VOConstants.MINIMUM_PUBLICATION_YEAR) { - publishedYear = candidateYearInteger.toString(); - } - - } - - return publishedYear; - } - - public String getDocumentDescription() { - return documentDescription; - } - public void setDocumentDescription(String documentDescription) { - this.documentDescription = documentDescription; - } - - /** - * This method will be called when there is no usable core:year value found - * for the bibo:Document. It will first check & parse core:yearMonth failing - * which it will try core:date - * @return - */ - public String getParsedPublicationYear() { - - /* - * We are assuming that core:yearMonth has "YYYY-MM" format. This is based - * off of http://www.w3.org/TR/xmlschema-2/#gYearMonth , which is what - * core:yearMonth points to internally. - * */ - if (publicationYearMonth != null - && publicationYearMonth.length() >= VOConstants.NUM_CHARS_IN_YEAR_FORMAT - && isValidPublicationYear(publicationYearMonth.substring( - 0, - VOConstants.NUM_CHARS_IN_YEAR_FORMAT))) { - - return publicationYearMonth.substring(0, VOConstants.NUM_CHARS_IN_YEAR_FORMAT); - - } - - if (publicationDate != null - && publicationDate.length() >= VOConstants.NUM_CHARS_IN_YEAR_FORMAT - && isValidPublicationYear(publicationDate - .substring(0, - VOConstants.NUM_CHARS_IN_YEAR_FORMAT))) { - - return publicationDate.substring(0, VOConstants.NUM_CHARS_IN_YEAR_FORMAT); - } - - /* - * If all else fails return default unknown year identifier - * */ - return VOConstants.DEFAULT_PUBLICATION_YEAR; - } - - /* - * This publicationYear value is directly from the data supported by the ontology. - * If this is empty only then use the parsedPublicationYear. - * */ - public String getPublicationYear() { - if (publicationYear != null && isValidPublicationYear(publicationYear)) { - return publicationYear; - } else { - return null; - } - - } - - public void setPublicationYear(String publicationYear) { - this.publicationYear = publicationYear; - } - - public String getPublicationYearMonth() { - return publicationYearMonth; - } - - public void setPublicationYearMonth(String publicationYearMonth) { - this.publicationYearMonth = publicationYearMonth; - } - - public String getPublicationDate() { - return publicationDate; - } - - public void setPublicationDate(String publicationDate) { - this.publicationDate = publicationDate; - } - - private boolean isValidPublicationYear(String testPublicationYear) { - - if (testPublicationYear.length() != 0 - && testPublicationYear.trim().length() == VOConstants.NUM_CHARS_IN_YEAR_FORMAT - && testPublicationYear.matches("\\d+") - && Integer.parseInt(testPublicationYear) >= VOConstants.MINIMUM_PUBLICATION_YEAR) { - return true; - } - - return false; - } - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/Child.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/Child.java deleted file mode 100644 index b7870aca..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/Child.java +++ /dev/null @@ -1,42 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ -package edu.cornell.mannlib.vitro.webapp.visualization.valueobjects; - -import java.util.Set; -import java.util.HashSet; -/** - * @author bkoniden - * Deepak Konidena - * - */ -public class Child extends Individual { - - Set documents = new HashSet(); - - public Child(String individualURI) { - super(individualURI); - } - - public Set getDocuments() { - return documents; - } - - public Child(String individualURI, String individualLabel) { - super(individualURI, individualLabel); - } - - @Override - public boolean equals(Object other){ - boolean result = false; - if (other instanceof Child){ - Child person = (Child) other; - result = (this.getIndividualLabel().equals(person.getIndividualLabel()) - && this.getIndividualURI().equals(person.getIndividualURI())); - } - return result; - } - - @Override - public int hashCode(){ - return(41*(getIndividualLabel().hashCode() + 41*(getIndividualURI().hashCode()))); - } -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/CoAuthorshipData.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/CoAuthorshipData.java deleted file mode 100644 index 4bc11dc5..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/CoAuthorshipData.java +++ /dev/null @@ -1,229 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.visualization.valueobjects; - -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; - -public class CoAuthorshipData { - - private Set nodes; - private Set edges; - private Node egoNode; - private Set> NODE_SCHEMA; - private Set> EDGE_SCHEMA; - - public CoAuthorshipData(Node egoNode, Set nodes, Set edges) { - this.egoNode = egoNode; - this.nodes = nodes; - this.edges = edges; - } - - public Set getNodes() { - return nodes; - } - - public Set getEdges() { - return edges; - } - - public Node getEgoNode() { - return egoNode; - } - - /* - * Node Schema for graphML - * */ - public Set> getNodeSchema() { - - if (NODE_SCHEMA == null) { - NODE_SCHEMA = initializeNodeSchema(); - } - - return NODE_SCHEMA; - } - - /* - * Edge Schema for graphML - * */ - public Set> getEdgeSchema() { - - if (EDGE_SCHEMA == null) { - EDGE_SCHEMA = initializeEdgeSchema(); - } - - return EDGE_SCHEMA; - } - - private Set> initializeEdgeSchema() { - - Set> edgeSchema = new HashSet>(); - - Map schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "collaborator1"); - schemaAttributes.put("for", "edge"); - schemaAttributes.put("attr.name", "collaborator1"); - schemaAttributes.put("attr.type", "string"); - - edgeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "collaborator2"); - schemaAttributes.put("for", "edge"); - schemaAttributes.put("attr.name", "collaborator2"); - schemaAttributes.put("attr.type", "string"); - - edgeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "number_of_coauthored_works"); - schemaAttributes.put("for", "edge"); - schemaAttributes.put("attr.name", "number_of_coauthored_works"); - schemaAttributes.put("attr.type", "int"); - - edgeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "earliest_collaboration"); - schemaAttributes.put("for", "edge"); - schemaAttributes.put("attr.name", "earliest_collaboration"); - schemaAttributes.put("attr.type", "int"); - - edgeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "num_earliest_collaboration"); - schemaAttributes.put("for", "edge"); - schemaAttributes.put("attr.name", "num_earliest_collaboration"); - schemaAttributes.put("attr.type", "int"); - - edgeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "latest_collaboration"); - schemaAttributes.put("for", "edge"); - schemaAttributes.put("attr.name", "latest_collaboration"); - schemaAttributes.put("attr.type", "int"); - - edgeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "num_latest_collaboration"); - schemaAttributes.put("for", "edge"); - schemaAttributes.put("attr.name", "num_latest_collaboration"); - schemaAttributes.put("attr.type", "int"); - - edgeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "num_unknown_collaboration"); - schemaAttributes.put("for", "edge"); - schemaAttributes.put("attr.name", "num_unknown_collaboration"); - schemaAttributes.put("attr.type", "int"); - - edgeSchema.add(schemaAttributes); - - return edgeSchema; - } - - - private Set> initializeNodeSchema() { - - Set> nodeSchema = new HashSet>(); - - Map schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "url"); - schemaAttributes.put("for", "node"); - schemaAttributes.put("attr.name", "url"); - schemaAttributes.put("attr.type", "string"); - - nodeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "label"); - schemaAttributes.put("for", "node"); - schemaAttributes.put("attr.name", "label"); - schemaAttributes.put("attr.type", "string"); - - nodeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "profile_url"); - schemaAttributes.put("for", "node"); - schemaAttributes.put("attr.name", "profile_url"); - schemaAttributes.put("attr.type", "string"); - - nodeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "number_of_authored_works"); - schemaAttributes.put("for", "node"); - schemaAttributes.put("attr.name", "number_of_authored_works"); - schemaAttributes.put("attr.type", "int"); - - nodeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "earliest_publication"); - schemaAttributes.put("for", "node"); - schemaAttributes.put("attr.name", "earliest_publication"); - schemaAttributes.put("attr.type", "int"); - - nodeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "num_earliest_publication"); - schemaAttributes.put("for", "node"); - schemaAttributes.put("attr.name", "num_earliest_publication"); - schemaAttributes.put("attr.type", "int"); - - nodeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "latest_publication"); - schemaAttributes.put("for", "node"); - schemaAttributes.put("attr.name", "latest_publication"); - schemaAttributes.put("attr.type", "int"); - - nodeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "num_latest_publication"); - schemaAttributes.put("for", "node"); - schemaAttributes.put("attr.name", "num_latest_publication"); - schemaAttributes.put("attr.type", "int"); - - nodeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "num_unknown_publication"); - schemaAttributes.put("for", "node"); - schemaAttributes.put("attr.name", "num_unknown_publication"); - schemaAttributes.put("attr.type", "int"); - - nodeSchema.add(schemaAttributes); - - - return nodeSchema; - } - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/CoPIData.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/CoPIData.java deleted file mode 100644 index 05b69942..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/CoPIData.java +++ /dev/null @@ -1,251 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.visualization.valueobjects; - -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; - -public class CoPIData { - - private Set nodes; - private Set edges; - private CoPINode egoNode; - private Set> NODE_SCHEMA; - private Set> EDGE_SCHEMA; - - public CoPIData(CoPINode egoNode, Set nodes, Set edges) { - this.egoNode = egoNode; - this.nodes = nodes; - this.edges = edges; - } - - public Set getNodes() { - return nodes; - } - - public Set getEdges() { - return edges; - } - - public CoPINode getEgoNode() { - return egoNode; - } - - /* - * Node Schema for graphML - * */ - public Set> getNodeSchema() { - - if (NODE_SCHEMA == null) { - NODE_SCHEMA = initializeNodeSchema(); - } - - return NODE_SCHEMA; - } - - /* - * Edge Schema for graphML - * */ - public Set> getEdgeSchema() { - - if (EDGE_SCHEMA == null) { - EDGE_SCHEMA = initializeEdgeSchema(); - } - - return EDGE_SCHEMA; - } - - public void print(){ - - System.out.println("\n-----------------------------"); - - System.out.println("Ego node is "+ this.getEgoNode().getNodeName()); - - System.out.println("\nNodes are: "); - - for(CoPINode node : this.getNodes()){ - System.out.println(node.getNodeName()); - } - - System.out.println("\nEdges are: "); - - for(CoPIEdge edge : this.getEdges()){ - System.out.println(edge.getSourceNode() + "-->" + edge.getTargetNode()); - } - - System.out.println("\n-----------------------------"); - - } - - private Set> initializeEdgeSchema() { - - Set> edgeSchema = new HashSet>(); - - Map schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "collaborator1"); - schemaAttributes.put("for", "edge"); - schemaAttributes.put("attr.name", "collaborator1"); - schemaAttributes.put("attr.type", "string"); - - edgeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "collaborator2"); - schemaAttributes.put("for", "edge"); - schemaAttributes.put("attr.name", "collaborator2"); - schemaAttributes.put("attr.type", "string"); - - edgeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "number_of_coinvestigated_grants"); - schemaAttributes.put("for", "edge"); - schemaAttributes.put("attr.name", "number_of_coinvestigated_grants"); - schemaAttributes.put("attr.type", "int"); - - edgeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "earliest_collaboration"); - schemaAttributes.put("for", "edge"); - schemaAttributes.put("attr.name", "earliest_collaboration"); - schemaAttributes.put("attr.type", "int"); - - edgeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "num_earliest_collaboration"); - schemaAttributes.put("for", "edge"); - schemaAttributes.put("attr.name", "num_earliest_collaboration"); - schemaAttributes.put("attr.type", "int"); - - edgeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "latest_collaboration"); - schemaAttributes.put("for", "edge"); - schemaAttributes.put("attr.name", "latest_collaboration"); - schemaAttributes.put("attr.type", "int"); - - edgeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "num_latest_collaboration"); - schemaAttributes.put("for", "edge"); - schemaAttributes.put("attr.name", "num_latest_collaboration"); - schemaAttributes.put("attr.type", "int"); - - edgeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "num_unknown_collaboration"); - schemaAttributes.put("for", "edge"); - schemaAttributes.put("attr.name", "num_unknown_collaboration"); - schemaAttributes.put("attr.type", "int"); - - edgeSchema.add(schemaAttributes); - - return edgeSchema; - } - - - private Set> initializeNodeSchema() { - - Set> nodeSchema = new HashSet>(); - - Map schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "url"); - schemaAttributes.put("for", "node"); - schemaAttributes.put("attr.name", "url"); - schemaAttributes.put("attr.type", "string"); - - nodeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "label"); - schemaAttributes.put("for", "node"); - schemaAttributes.put("attr.name", "label"); - schemaAttributes.put("attr.type", "string"); - - nodeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "profile_url"); - schemaAttributes.put("for", "node"); - schemaAttributes.put("attr.name", "profile_url"); - schemaAttributes.put("attr.type", "string"); - - nodeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "number_of_investigated_grants"); - schemaAttributes.put("for", "node"); - schemaAttributes.put("attr.name", "number_of_investigated_grants"); - schemaAttributes.put("attr.type", "int"); - - nodeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "earliest_grant"); - schemaAttributes.put("for", "node"); - schemaAttributes.put("attr.name", "earliest_grant"); - schemaAttributes.put("attr.type", "int"); - - nodeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "num_earliest_grant"); - schemaAttributes.put("for", "node"); - schemaAttributes.put("attr.name", "num_earliest_grant"); - schemaAttributes.put("attr.type", "int"); - - nodeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "latest_grant"); - schemaAttributes.put("for", "node"); - schemaAttributes.put("attr.name", "latest_grant"); - schemaAttributes.put("attr.type", "int"); - - nodeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "num_latest_grant"); - schemaAttributes.put("for", "node"); - schemaAttributes.put("attr.name", "num_latest_grant"); - schemaAttributes.put("attr.type", "int"); - - nodeSchema.add(schemaAttributes); - - schemaAttributes = new LinkedHashMap(); - - schemaAttributes.put("id", "num_unknown_grant"); - schemaAttributes.put("for", "node"); - schemaAttributes.put("attr.name", "num_unknown_grant"); - schemaAttributes.put("attr.type", "int"); - - nodeSchema.add(schemaAttributes); - - - return nodeSchema; - } - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/CoPIEdge.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/CoPIEdge.java deleted file mode 100644 index 1e419b52..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/CoPIEdge.java +++ /dev/null @@ -1,144 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ -package edu.cornell.mannlib.vitro.webapp.visualization.valueobjects; - -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants; -import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UniqueIDGenerator; -import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UtilityFunctions; - -/** - * This stores edge information for Co-PI vis. - * @author bkoniden - * Deepak Konidena - */ -public class CoPIEdge { - - private int edgeID; - private Map yearToGrantCount; - private Set collaboratorGrants = new HashSet(); - private CoPINode sourceNode; - private CoPINode targetNode; - - public CoPIEdge(CoPINode sourceNode, CoPINode targetNode, Grant seedCoPIedGrant, UniqueIDGenerator uniqueIDGenerator){ - edgeID = uniqueIDGenerator.getNextNumericID(); - this.sourceNode = sourceNode; - this.targetNode = targetNode; - this.collaboratorGrants.add(seedCoPIedGrant); - } - - public int getEdgeID() { - return edgeID; - } - public Set getCollaboratorGrants() { - return collaboratorGrants; - } - public CoPINode getSourceNode() { - return sourceNode; - } - public CoPINode getTargetNode() { - return targetNode; - } - - public int getNumberOfCoInvestigatedGrants(){ - return collaboratorGrants.size(); - } - - public void addCollaboratorGrant(Grant grant){ - this.collaboratorGrants.add(grant); - } - - /* - * getEarliest, Latest & Unknown Grant YearCount should only be used after - * the parsing of the entire sparql is done. Else it will give results based on - * incomplete dataset. - * */ - @SuppressWarnings("serial") - public Map getEarliestCollaborationYearCount() { - if (yearToGrantCount == null) { - yearToGrantCount = UtilityFunctions.getYearToGrantCount(collaboratorGrants); - } - - /* - * We do not want to consider the default grant year when we are checking - * for the min or max grant year. - * */ - Set yearsToBeConsidered = new HashSet(yearToGrantCount.keySet()); - yearsToBeConsidered.remove(VOConstants.DEFAULT_PUBLICATION_YEAR); - - /* - * There can be a case when the only publication the author has no attached year to it - * so essentially an "Unknown". In that case Collections.max or min will throw an - * NoSuchElementException. - * - * If there is no maximum year available then we should imply so by returning a "null". - * */ - if (yearsToBeConsidered.size() > 0) { - final String earliestYear = Collections.min(yearsToBeConsidered); - final Integer earliestYearGrantCount = yearToGrantCount.get(earliestYear); - - return new HashMap() { { - put(earliestYear, earliestYearGrantCount); - } }; - } else { - return null; - } - } - - - @SuppressWarnings("serial") - public Map getLatestCollaborationYearCount() { - if (yearToGrantCount == null) { - yearToGrantCount = UtilityFunctions.getYearToGrantCount(collaboratorGrants); - } - - /* - * We do not want to consider the default grant year when we are checking - * for the min or max grant year. - * */ - Set yearsToBeConsidered = new HashSet(yearToGrantCount.keySet()); - yearsToBeConsidered.remove(VOConstants.DEFAULT_PUBLICATION_YEAR); - - /* - * There can be a case when the only grant the PI has no attached year to it - * so essentially an "Unknown". In that case Collections.max or min will throw an - * NoSuchElementException. - * - * If there is no maximum year available then we should imply so by returning a "null". - * */ - if (yearsToBeConsidered.size() > 0) { - final String latestYear = Collections.max(yearsToBeConsidered); - final Integer latestYearGrantCount = yearToGrantCount.get(latestYear); - - return new HashMap() { { - put(latestYear, latestYearGrantCount); - } }; - } else { - return null; - } - - } - - public Integer getUnknownCollaborationYearCount() { - if (yearToGrantCount == null) { - yearToGrantCount = UtilityFunctions.getYearToGrantCount(collaboratorGrants); - } - - Integer unknownYearGrantCount = yearToGrantCount - .get(VOConstants.DEFAULT_PUBLICATION_YEAR); - - /* - * If there is no unknown year available then we should imply so by returning a "null". - * */ - if (unknownYearGrantCount != null) { - return unknownYearGrantCount; - } else { - return null; - } - } - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/CoPINode.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/CoPINode.java deleted file mode 100644 index 50c5ce42..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/CoPINode.java +++ /dev/null @@ -1,154 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ -package edu.cornell.mannlib.vitro.webapp.visualization.valueobjects; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.HashSet; - -import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants; -import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UniqueIDGenerator; -import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UtilityFunctions; - -/** - * CoPINode is the node in a CoPI vis. - * @author bkoniden - * Deepak Konidena - */ -public class CoPINode extends Individual { - - private int nodeID; - private Map yearToGrantCount; - - private Set pIGrants = new HashSet(); - - public CoPINode(String nodeURI, UniqueIDGenerator uniqueIDGenerator){ - super(nodeURI); - nodeID = uniqueIDGenerator.getNextNumericID(); - } - - public int getNodeID(){ - return nodeID; - } - - public String getNodeURI(){ - return this.getIndividualURI(); - } - - public String getNodeName(){ - return this.getIndividualLabel(); - } - - public void setNodeName(String nodeName) { - this.setIndividualLabel(nodeName); - } - - public Set getInvestigatedGrants(){ - return pIGrants; - } - - public int getNumberOfInvestigatedGrants(){ - return pIGrants.size(); - } - - public void addGrant(Grant grant){ - this.pIGrants.add(grant); - } - - public Map getYearToGrantCount(){ - if(yearToGrantCount == null){ - yearToGrantCount = UtilityFunctions.getYearToGrantCount(pIGrants); - } - return yearToGrantCount; - } - - /* - * getEarliest, Latest & Unknown Grant YearCount should only be used after - * the parsing of the entire sparql is done. Else it will give results based on - * incomplete dataset. - * */ - @SuppressWarnings("serial") - public Map getEarliestGrantYearCount() { - if (yearToGrantCount == null) { - yearToGrantCount = UtilityFunctions.getYearToGrantCount(pIGrants); - } - - /* - * We do not want to consider the default grant year when we are checking - * for the min or max grant year. - * */ - Set yearsToBeConsidered = new HashSet(yearToGrantCount.keySet()); - yearsToBeConsidered.remove(VOConstants.DEFAULT_PUBLICATION_YEAR); - - /* - * There can be a case when the only publication the author has no attached year to it - * so essentially an "Unknown". In that case Collections.max or min will throw an - * NoSuchElementException. - * - * If there is no maximum year available then we should imply so by returning a "null". - * */ - if (yearsToBeConsidered.size() > 0) { - final String earliestYear = Collections.min(yearsToBeConsidered); - final Integer earliestYearGrantCount = yearToGrantCount.get(earliestYear); - - return new HashMap() { { - put(earliestYear, earliestYearGrantCount); - } }; - } else { - return null; - } - } - - - @SuppressWarnings("serial") - public Map getLatestGrantYearCount() { - if (yearToGrantCount == null) { - yearToGrantCount = UtilityFunctions.getYearToGrantCount(pIGrants); - } - - /* - * We do not want to consider the default grant year when we are checking - * for the min or max grant year. - * */ - Set yearsToBeConsidered = new HashSet(yearToGrantCount.keySet()); - yearsToBeConsidered.remove(VOConstants.DEFAULT_PUBLICATION_YEAR); - - /* - * There can be a case when the only grant the PI has no attached year to it - * so essentially an "Unknown". In that case Collections.max or min will throw an - * NoSuchElementException. - * - * If there is no maximum year available then we should imply so by returning a "null". - * */ - if (yearsToBeConsidered.size() > 0) { - final String latestYear = Collections.max(yearsToBeConsidered); - final Integer latestYearGrantCount = yearToGrantCount.get(latestYear); - - return new HashMap() { { - put(latestYear, latestYearGrantCount); - } }; - } else { - return null; - } - - } - - public Integer getUnknownGrantYearCount() { - if (yearToGrantCount == null) { - yearToGrantCount = UtilityFunctions.getYearToGrantCount(pIGrants); - } - - Integer unknownYearGrantCount = yearToGrantCount - .get(VOConstants.DEFAULT_PUBLICATION_YEAR); - - /* - * If there is no unknown year available then we should imply so by returning a "null". - * */ - if (unknownYearGrantCount != null) { - return unknownYearGrantCount; - } else { - return null; - } - } -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/Department.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/Department.java deleted file mode 100644 index 542905d3..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/Department.java +++ /dev/null @@ -1,54 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ -package edu.cornell.mannlib.vitro.webapp.visualization.valueobjects; - -import java.util.Set; - -/** - * @author bkoniden - * Deepak Konidena - * - */ -public class Department extends Individual{ - - Set publication; - Set person; - - public Department(String departmentURI, String departmentLabel){ - super(departmentURI, departmentLabel); - } - - public void setDepartmentLabel(String departmentURI){ - this.setIndividualLabel(departmentURI); - } - - public String getDepartmentURI(){ - return this.getIndividualURI(); - } - - public Set getPublication() { - return publication; - } - - public String getDepartmentLabel(){ - return this.getIndividualLabel(); - } - - public Set getPerson() { - return person; - } - - public void addPublication(BiboDocument biboDocument) { - this.publication.add(biboDocument); - } - - public void addPersons(Person person) { - this.person.add(person); - - } - - public void addPerson(Person person) { - this.person.add(person); - - } - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/Edge.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/Edge.java deleted file mode 100644 index f576aa5b..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/Edge.java +++ /dev/null @@ -1,153 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.visualization.valueobjects; - -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants; -import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UniqueIDGenerator; -import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UtilityFunctions; - -/** - * - * This is stores edge information mainly for co-author vis. - * - * @author cdtank - * - */ -public class Edge { - - private int edgeID; - private Map yearToPublicationCount; - private Set collaboratorDocuments = new HashSet(); - private Node sourceNode; - private Node targetNode; - - public Edge(Node sourceNode, Node targetNode, BiboDocument seedCoAuthoredDocument, - UniqueIDGenerator uniqueIDGenerator) { - edgeID = uniqueIDGenerator.getNextNumericID(); - this.sourceNode = sourceNode; - this.targetNode = targetNode; - this.collaboratorDocuments.add(seedCoAuthoredDocument); - } - - public int getEdgeID() { - return edgeID; - } - - public Node getSourceNode() { - return sourceNode; - } - - public Node getTargetNode() { - return targetNode; - } - - public Set getCollaboratorDocuments() { - return collaboratorDocuments; - } - - public int getNumOfCoAuthoredWorks() { - return collaboratorDocuments.size(); - } - - public void addCollaboratorDocument(BiboDocument authorDocument) { - this.collaboratorDocuments.add(authorDocument); - } - - /* - * getEarliest, Latest & Unknown Publication YearCount should only be used after - * the parsing of the entire sparql is done. Else it will give results based on - * incomplete dataset. - * */ - @SuppressWarnings("serial") - public Map getEarliestCollaborationYearCount() { - if (yearToPublicationCount == null) { - yearToPublicationCount = UtilityFunctions - .getYearToPublicationCount(collaboratorDocuments); - } - - /* - * We do not want to consider the default publication year when we are checking - * for the min or max publication year. - * */ - Set yearsToBeConsidered = new HashSet(yearToPublicationCount.keySet()); - yearsToBeConsidered.remove(VOConstants.DEFAULT_PUBLICATION_YEAR); - - /* - * There can be a case when the only publication the author has no attached year to it - * so essentially an "Unknown". In that case Collections.max or min will throw an - * NoSuchElementException. - * - * If there is no maximum year available then we should imply so by returning a "null". - * */ - if (yearsToBeConsidered.size() > 0) { - final String earliestYear = Collections.min(yearsToBeConsidered); - final Integer earliestYearPubCount = yearToPublicationCount.get(earliestYear); - - return new HashMap() { { - put(earliestYear, earliestYearPubCount); - } }; - } else { - return null; - } - } - - @SuppressWarnings("serial") - public Map getLatestCollaborationYearCount() { - if (yearToPublicationCount == null) { - yearToPublicationCount = UtilityFunctions - .getYearToPublicationCount(collaboratorDocuments); - } - - /* - * We do not want to consider the default publication year when we are checking - * for the min or max publication year. - * */ - Set yearsToBeConsidered = new HashSet(yearToPublicationCount.keySet()); - yearsToBeConsidered.remove(VOConstants.DEFAULT_PUBLICATION_YEAR); - - /* - * There can be a case when the only publication the author has no attached year to it - * so essentially an "Unknown". In that case Collections.max or min will throw an - * NoSuchElementException. - * - * If there is no maximum year available then we should imply so by returning a "null". - * */ - if (yearsToBeConsidered.size() > 0) { - final String latestYear = Collections.max(yearsToBeConsidered); - final Integer latestYearPubCount = yearToPublicationCount.get(latestYear); - - return new HashMap() { { - put(latestYear, latestYearPubCount); - } }; - } else { - return null; - } - } - - public Integer getUnknownCollaborationYearCount() { - if (yearToPublicationCount == null) { - yearToPublicationCount = UtilityFunctions - .getYearToPublicationCount(collaboratorDocuments); - } - - Integer unknownYearPubCount = yearToPublicationCount - .get(VOConstants.DEFAULT_PUBLICATION_YEAR); - - /* - * If there is no unknown year available then we should imply so by returning a "null". - * */ - if (unknownYearPubCount != null) { - return unknownYearPubCount; - } else { - return null; - } - } - - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/Entity.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/Entity.java deleted file mode 100644 index ca1228ec..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/Entity.java +++ /dev/null @@ -1,51 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ -package edu.cornell.mannlib.vitro.webapp.visualization.valueobjects; - -import java.util.HashSet; -import java.util.Set; -import java.util.LinkedHashSet; - -/** - * @author bkoniden - * Deepak Konidena - * - */ -public class Entity extends Individual{ - - Set publications = new HashSet(); - Set children = new LinkedHashSet(); - - public Entity(String departmentURI, String departmentLabel){ - super(departmentURI, departmentLabel); - } - - public void setDepartmentLabel(String departmentURI){ - this.setIndividualLabel(departmentURI); - } - - public String getEntityURI(){ - return this.getIndividualURI(); - } - - public Set getPublications() { - return publications; - } - - public String getEntityLabel(){ - return this.getIndividualLabel(); - } - - public Set getSubEntities() { - return children; - } - - public void addPublications(BiboDocument biboDocument) { - this.publications.add(biboDocument); - } - - public void addSubEntity(SubEntity subEntity) { - this.children.add(subEntity); - - } - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/GenericQueryMap.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/GenericQueryMap.java deleted file mode 100644 index 2c01d34d..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/GenericQueryMap.java +++ /dev/null @@ -1,41 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.visualization.valueobjects; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Set; - -/** - * Right now this is just acting as a hashmap but in future we would want to provide - * more detailed info other than just what properties had what values. E.g. we - * could parse properties (& its values) to look for what namespaces are used. - * - * @author cdtank - */ -@SuppressWarnings("serial") -public class GenericQueryMap extends HashMap> { - - public GenericQueryMap() { - super(); - } - - public void addEntry(String property, String value) { - - Set values; - - if (this.containsKey(property)) { - - values = this.get(property); - values.add(value); - - } else { - - values = new HashSet(); - values.add(value); - this.put(property, values); - - } - } - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/Grant.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/Grant.java deleted file mode 100644 index 0d27f2cc..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/Grant.java +++ /dev/null @@ -1,134 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ -package edu.cornell.mannlib.vitro.webapp.visualization.valueobjects; - -import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants; - -/** - * @author bkoniden - * Deepak Konidena - * - */ - -public class Grant extends Individual { - - private String grantStartYear; - private String grantStartYearMonth; - private String grantStartDate; - private String grantEndYear; - private String grantEndYearMonth; - private String grantEndDate; - - public Grant(String grantURL, String grantLabel){ - super(grantURL, grantLabel); - } - - public Grant(String grantURL){ - super(grantURL); - } - - public String getGrantURL() { - return this.getIndividualURI(); - } - - public String getGrantLabel(){ - return this.getIndividualLabel(); - } - /** - * This method will be called when there is no usable core:year value found - * for the bibo:Document. It will first check & parse core:yearMonth failing - * which it will try core:date - * @return - */ - public String getParsedGrantStartYear() { - - /* - * We are assuming that core:yearMonth has "YYYY-MM-DD" format. This is based - * off of http://www.w3.org/TR/xmlschema-2/#gYearMonth , which is what - * core:yearMonth points to internally. - * */ - if (grantStartYearMonth != null - && grantStartYearMonth.length() >= VOConstants.NUM_CHARS_IN_YEAR_FORMAT - && isValidPublicationYear(grantStartYearMonth.substring( - 0, - VOConstants.NUM_CHARS_IN_YEAR_FORMAT))) { - - return grantStartYearMonth.substring(0, VOConstants.NUM_CHARS_IN_YEAR_FORMAT); - - } - - if (grantStartDate != null - && grantStartDate.length() >= VOConstants.NUM_CHARS_IN_YEAR_FORMAT - && isValidPublicationYear(grantStartDate - .substring(0, - VOConstants.NUM_CHARS_IN_YEAR_FORMAT))) { - - return grantStartDate.substring(0, VOConstants.NUM_CHARS_IN_YEAR_FORMAT); - } - - /* - * If all else fails return default unknown year identifier - * */ - return VOConstants.DEFAULT_GRANT_YEAR; - } - - public String getGrantStartYear() { - return grantStartYear; - } - - public void setGrantStartYear(String grantStartYear) { - this.grantStartYear = grantStartYear; - } - - public String getGrantStartYearMonth() { - return grantStartYearMonth; - } - - public void setGrantStartYearMonth(String grantStartYearMonth) { - this.grantStartYearMonth = grantStartYearMonth; - } - - public String getGrantStartDate() { - return grantStartDate; - } - - public void setGrantStartDate(String grantStartDate) { - this.grantStartDate = grantStartDate; - } - - public String getGrantEndYear() { - return grantEndYear; - } - - public void setGrantEndYear(String grantEndYear) { - this.grantEndYear = grantEndYear; - } - - public String getGrantEndYearMonth() { - return grantEndYearMonth; - } - - public void setGrantEndYearMonth(String grantEndYearMonth) { - this.grantEndYearMonth = grantEndYearMonth; - } - - public String getGrantEndDate() { - return grantEndDate; - } - - public void setGrantEndDate(String grantEndDate) { - this.grantEndDate = grantEndDate; - } - - private boolean isValidPublicationYear(String testGrantYear) { - - if (testGrantYear.length() != 0 - && testGrantYear.trim().length() == VOConstants.NUM_CHARS_IN_YEAR_FORMAT - && testGrantYear.matches("\\d+") - && Integer.parseInt(testGrantYear) >= VOConstants.MINIMUM_PUBLICATION_YEAR) { - return true; - } - - return false; - } - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/Individual.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/Individual.java deleted file mode 100644 index 89c6ddd5..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/Individual.java +++ /dev/null @@ -1,32 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.visualization.valueobjects; - -public class Individual { - - private String individualLabel; - private String individualURI; - - public Individual(String individualURI, String individualLabel) { - this.individualURI = individualURI; - this.individualLabel = individualLabel; - } - - public Individual(String individualURI) { - this(individualURI, ""); - } - - public String getIndividualLabel() { - return individualLabel; - } - - public void setIndividualLabel(String individualLabel) { - this.individualLabel = individualLabel; - } - - public String getIndividualURI() { - return individualURI; - } - - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/JsonObject.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/JsonObject.java deleted file mode 100644 index 62fa2a69..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/JsonObject.java +++ /dev/null @@ -1,76 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ -package edu.cornell.mannlib.vitro.webapp.visualization.valueobjects; - -import java.util.ArrayList; -import java.util.List; - -/** - * JsonObject is used for creating data in JSON format, - * by just using the fields that are required to be included. - * @author bkoniden - * Deepak Konidena - */ -public class JsonObject { - - private String label; - private List> data = new ArrayList>(); - private String entityURI; - private String visMode; - private List organizationType = new ArrayList(); - private List stopWords = new ArrayList(); - - public List getStopWords() { - return stopWords; - } - - public void setStopWords(List stopWords) { - this.stopWords = stopWords; - } - - public List getOrganizationType() { - return organizationType; - } - - public void setOrganizationType(List organizationType) { - this.organizationType = organizationType; - } - - public String getEntityURI() { - return entityURI; - } - - public void setEntityURI(String entityURI) { - this.entityURI = entityURI; - } - - public String getVisMode() { - return visMode; - } - - public void setVisMode(String visMode) { - this.visMode = visMode; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public List> getYearToPublicationCount() { - return data; - } - - - - public JsonObject(String label){ - this.label = label; - } - - public void setYearToPublicationCount(List> yearToPublicationCount){ - this.data = yearToPublicationCount; - } - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/Node.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/Node.java deleted file mode 100644 index 242d9e81..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/Node.java +++ /dev/null @@ -1,156 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.visualization.valueobjects; - -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants; -import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UniqueIDGenerator; -import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UtilityFunctions; - -/** - * - * This stores node information mainly for co-author vis. - * - * @author cdtank - */ -public class Node extends Individual { - - private int nodeID; - private Map yearToPublicationCount; - - private Set authorDocuments = new HashSet(); - - public Node(String nodeURI, - UniqueIDGenerator uniqueIDGenerator) { - super(nodeURI); - nodeID = uniqueIDGenerator.getNextNumericID(); - } - - public int getNodeID() { - return nodeID; - } - - public String getNodeURI() { - return this.getIndividualURI(); - } - - public String getNodeName() { - return this.getIndividualLabel(); - } - - public void setNodeName(String nodeName) { - this.setIndividualLabel(nodeName); - } - - public Set getAuthorDocuments() { - return authorDocuments; - } - - public int getNumOfAuthoredWorks() { - return authorDocuments.size(); - } - - public void addAuthorDocument(BiboDocument authorDocument) { - this.authorDocuments.add(authorDocument); - } - - public Map getYearToPublicationCount() { - if (yearToPublicationCount == null) { - yearToPublicationCount = UtilityFunctions.getYearToPublicationCount(authorDocuments); - } - return yearToPublicationCount; - } - - /* - * getEarliest, Latest & Unknown Publication YearCount should only be used after - * the parsing of the entire sparql is done. Else it will give results based on - * incomplete dataset. - * */ - @SuppressWarnings("serial") - public Map getEarliestPublicationYearCount() { - if (yearToPublicationCount == null) { - yearToPublicationCount = UtilityFunctions.getYearToPublicationCount(authorDocuments); - } - - /* - * We do not want to consider the default publication year when we are checking - * for the min or max publication year. - * */ - Set yearsToBeConsidered = new HashSet(yearToPublicationCount.keySet()); - yearsToBeConsidered.remove(VOConstants.DEFAULT_PUBLICATION_YEAR); - - /* - * There can be a case when the only publication the author has no attached year to it - * so essentially an "Unknown". In that case Collections.max or min will throw an - * NoSuchElementException. - * - * If there is no maximum year available then we should imply so by returning a "null". - * */ - if (yearsToBeConsidered.size() > 0) { - final String earliestYear = Collections.min(yearsToBeConsidered); - final Integer earliestYearPubCount = yearToPublicationCount.get(earliestYear); - - return new HashMap() { { - put(earliestYear, earliestYearPubCount); - } }; - } else { - return null; - } - } - - @SuppressWarnings("serial") - public Map getLatestPublicationYearCount() { - if (yearToPublicationCount == null) { - yearToPublicationCount = UtilityFunctions.getYearToPublicationCount(authorDocuments); - } - - /* - * We do not want to consider the default publication year when we are checking - * for the min or max publication year. - * */ - Set yearsToBeConsidered = new HashSet(yearToPublicationCount.keySet()); - yearsToBeConsidered.remove(VOConstants.DEFAULT_PUBLICATION_YEAR); - - /* - * There can be a case when the only publication the author has no attached year to it - * so essentially an "Unknown". In that case Collections.max or min will throw an - * NoSuchElementException. - * - * If there is no maximum year available then we should imply so by returning a "null". - * */ - if (yearsToBeConsidered.size() > 0) { - final String latestYear = Collections.max(yearsToBeConsidered); - final Integer latestYearPubCount = yearToPublicationCount.get(latestYear); - - return new HashMap() { { - put(latestYear, latestYearPubCount); - } }; - } else { - return null; - } - - } - - public Integer getUnknownPublicationYearCount() { - if (yearToPublicationCount == null) { - yearToPublicationCount = UtilityFunctions.getYearToPublicationCount(authorDocuments); - } - - Integer unknownYearPubCount = yearToPublicationCount - .get(VOConstants.DEFAULT_PUBLICATION_YEAR); - - /* - * If there is no unknown year available then we should imply so by returning a "null". - * */ - if (unknownYearPubCount != null) { - return unknownYearPubCount; - } else { - return null; - } - } -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/Person.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/Person.java deleted file mode 100644 index f5944d37..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/Person.java +++ /dev/null @@ -1,27 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ -package edu.cornell.mannlib.vitro.webapp.visualization.valueobjects; - -import java.util.Set; -import java.util.HashSet; - -/** - * @author bkoniden - * Deepak Konidena - */ -public class Person extends Individual { - - Set documents = new HashSet(); - - public Person(String individualURI) { - super(individualURI); - } - - public Set getDocuments() { - return documents; - } - - public Person(String individualURI, String individualLabel) { - super(individualURI, individualLabel); - } - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/SparklineData.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/SparklineData.java deleted file mode 100644 index d5b6baad..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/SparklineData.java +++ /dev/null @@ -1,140 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.visualization.valueobjects; - -public class SparklineData { - - /* - * For now sparklineNumPublicationsText & sparklinePublicationRangeText is left - * as empty but later on we would want to leverage the granularity that this - * provides. - * */ - private String sparklineNumPublicationsText = ""; - private String sparklinePublicationRangeText = ""; - - private Integer earliestRenderedPublicationYear; - private Integer latestRenderedPublicationYear; - - private Integer earliestRenderedGrantYear; - private Integer latestRenderedGrantYear; - - private String table = ""; - - private String downloadDataLink = ""; - private String fullTimelineNetworkLink = ""; - - private String downloadCoPIDataLink = ""; - private String fullTimelineCoPINetworkLink = ""; - - private String sparklineContent; - private String sparklineContext; - - public String getSparklineNumPublicationsText() { - return sparklineNumPublicationsText; - } - - public void setSparklineNumPublicationsText(String sparklineNumPublicationsText) { - this.sparklineNumPublicationsText = sparklineNumPublicationsText; - } - - public String getSparklinePublicationRangeText() { - return sparklinePublicationRangeText; - } - - public void setSparklinePublicationRangeText( - String sparklinePublicationRangeText) { - this.sparklinePublicationRangeText = sparklinePublicationRangeText; - } - - public Integer getEarliestRenderedPublicationYear() { - return earliestRenderedPublicationYear; - } - - public void setEarliestRenderedPublicationYear( - Integer earliestRenderedPublicationYear) { - this.earliestRenderedPublicationYear = earliestRenderedPublicationYear; - } - - public Integer getLatestRenderedPublicationYear() { - return latestRenderedPublicationYear; - } - - public void setLatestRenderedPublicationYear( - Integer latestRenderedPublicationYear) { - this.latestRenderedPublicationYear = latestRenderedPublicationYear; - } - - public String getTable() { - return table; - } - - public void setTable(String table) { - this.table = table; - } - - public String getDownloadDataLink() { - return downloadDataLink; - } - - public void setDownloadDataLink(String downloadDataLink) { - this.downloadDataLink = downloadDataLink; - } - - public String getFullTimelineNetworkLink() { - return fullTimelineNetworkLink; - } - - public void setFullTimelineNetworkLink(String fullTimelineNetworkLink) { - this.fullTimelineNetworkLink = fullTimelineNetworkLink; - } - - public String getSparklineContent() { - return sparklineContent; - } - - public void setSparklineContent(String shortSparklineContent) { - this.sparklineContent = shortSparklineContent; - } - - public String getSparklineContext() { - return sparklineContext; - } - - public void setSparklineContext(String shortSparklineContext) { - this.sparklineContext = shortSparklineContext; - } - - public String getDownloadCoPIDataLink() { - return downloadCoPIDataLink; - } - - public void setDownloadCoPIDataLink(String downloadCoPIDataLink) { - this.downloadCoPIDataLink = downloadCoPIDataLink; - } - - public String getFullTimelineCoPINetworkLink() { - return fullTimelineCoPINetworkLink; - } - - public void setFullTimelineCoPINetworkLink(String fullTimelineCoPINetworkLink) { - this.fullTimelineCoPINetworkLink = fullTimelineCoPINetworkLink; - } - - public Integer getEarliestRenderedGrantYear() { - return earliestRenderedGrantYear; - } - - public void setEarliestRenderedGrantYear(Integer earliestRenderedGrantYear) { - this.earliestRenderedGrantYear = earliestRenderedGrantYear; - } - - public Integer getLatestRenderedGrantYear() { - return latestRenderedGrantYear; - } - - public void setLatestRenderedGrantYear(Integer latestRenderedGrantYear) { - this.latestRenderedGrantYear = latestRenderedGrantYear; - } - - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/SubEntity.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/SubEntity.java deleted file mode 100644 index 348260b3..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/valueobjects/SubEntity.java +++ /dev/null @@ -1,59 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ -package edu.cornell.mannlib.vitro.webapp.visualization.valueobjects; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.HashSet; - -/** - * @author bkoniden - * Deepak Konidena - */ -public class SubEntity extends Individual { - - Set publications = new HashSet(); - Map> personToPositionAndStartYear = new HashMap>(); - - public SubEntity(String individualURI) { - super(individualURI); - } - - - public Map> getPersonToPositionAndStartYear() { - return personToPositionAndStartYear; - } - - public void setPersonToPositionAndStartYear( - Map> personToPositionAndStartYear) { - this.personToPositionAndStartYear = personToPositionAndStartYear; - } - - public Set getDocuments() { - return publications; - } - - public SubEntity(String individualURI, String individualLabel) { - super(individualURI, individualLabel); - } - - @Override - public boolean equals(Object other){ - boolean result = false; - if (other instanceof SubEntity){ - SubEntity person = (SubEntity) other; - result = (this.getIndividualLabel().equals(person.getIndividualLabel()) - && this.getIndividualURI().equals(person.getIndividualURI())); - } - return result; - } - - @Override - public int hashCode(){ - return(41*(getIndividualLabel().hashCode() + 41*(getIndividualURI().hashCode()))); - } - - public void addPublications(BiboDocument biboDocument) { - this.publications.add(biboDocument); - } -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/visutils/AllPropertiesQueryRunner.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/visutils/AllPropertiesQueryRunner.java deleted file mode 100644 index fdf53fd1..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/visutils/AllPropertiesQueryRunner.java +++ /dev/null @@ -1,148 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.visualization.visutils; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; - -import com.hp.hpl.jena.iri.IRI; -import com.hp.hpl.jena.iri.IRIFactory; -import com.hp.hpl.jena.iri.Violation; -import com.hp.hpl.jena.query.DataSource; -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.ResultSet; -import com.hp.hpl.jena.query.Syntax; -import com.hp.hpl.jena.rdf.model.RDFNode; - -import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants; -import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryFieldLabels; -import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException; -import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.GenericQueryMap; - - - -/** - * This query runner is used to execute a sparql query that will fetch all the - * properties available for the provided individual URI. - * - * @author cdtank - */ -public class AllPropertiesQueryRunner implements QueryRunner { - - protected static final Syntax SYNTAX = Syntax.syntaxARQ; - - private String filterRule, individualURI; - private DataSource dataSource; - - private Log log; - - public AllPropertiesQueryRunner(String individualURI, - String filterRule, - DataSource dataSource, - Log log) { - - this.individualURI = individualURI; - this.filterRule = filterRule; - this.dataSource = dataSource; - this.log = log; - - } - - private GenericQueryMap createJavaValueObjects(ResultSet resultSet) { - - GenericQueryMap queryResult = new GenericQueryMap(); - - while (resultSet.hasNext()) { - QuerySolution solution = resultSet.nextSolution(); - - - RDFNode predicateNode = solution.get(QueryFieldLabels.PREDICATE); - RDFNode objectNode = solution.get(QueryFieldLabels.OBJECT); - - if (predicateNode != null && objectNode != null) { - queryResult.addEntry(predicateNode.toString(), - objectNode.toString()); - } - - } - - return queryResult; - } - - private ResultSet executeQuery(String queryText, - DataSource dataSource) { - - QueryExecution queryExecution = null; -// try { - Query query = QueryFactory.create(queryText, SYNTAX); - -// QuerySolutionMap qs = new QuerySolutionMap(); -// qs.add("authPerson", queryParam); // bind resource to s - - queryExecution = QueryExecutionFactory.create(query, dataSource); - - // if (query.isSelectType()) { - return queryExecution.execSelect(); -// } -// } finally { -// if (queryExecution != null) { -// queryExecution.close(); -// } -// -// } -// return null; - } - - private String generateGenericSparqlQuery(String queryURI, String filterRule) { -// Resource uri1 = ResourceFactory.createResource(queryURI); - String filterClause; - - if (StringUtils.isNotBlank(filterRule)) { - filterClause = "FILTER ( " + filterRule + " ) . "; - } else { - filterClause = ""; - } - - String sparqlQuery = QueryConstants.getSparqlPrefixQuery() - + "SELECT " - + " (str(?predicate) as ?" + QueryFieldLabels.PREDICATE + ") " - + " (str(?object) as ?" + QueryFieldLabels.OBJECT + ") " - + "WHERE { " - + "<" + queryURI + "> ?predicate ?object. " - + filterClause - + "}"; - - return sparqlQuery; - } - - public GenericQueryMap getQueryResult() - throws MalformedQueryParametersException { - if (StringUtils.isNotBlank(this.individualURI)) { - /* - * To test for the validity of the URI submitted. - * */ - IRIFactory iRIFactory = IRIFactory.jenaImplementation(); - IRI iri = iRIFactory.create(this.individualURI); - if (iri.hasViolation(false)) { - String errorMsg = ((Violation) iri.violations(false).next()).getShortMessage(); - log.error("Generic Query " + errorMsg); - throw new MalformedQueryParametersException( - "URI provided for an individual is malformed."); - } - - } else { - throw new MalformedQueryParametersException("URI parameter is either null or empty."); - } - - ResultSet resultSet = executeQuery(generateGenericSparqlQuery( - this.individualURI, - this.filterRule), - this.dataSource); - - return createJavaValueObjects(resultSet); - } -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/visutils/GenericQueryRunner.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/visutils/GenericQueryRunner.java deleted file mode 100644 index 1e854a6a..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/visutils/GenericQueryRunner.java +++ /dev/null @@ -1,131 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.visualization.visutils; - -import java.util.Map; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; - -import com.hp.hpl.jena.iri.IRI; -import com.hp.hpl.jena.iri.IRIFactory; -import com.hp.hpl.jena.iri.Violation; -import com.hp.hpl.jena.query.DataSource; -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.ResultSet; -import com.hp.hpl.jena.query.Syntax; - -import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants; -import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException; - - - -/** - * This query runner is used to run a generic sparql query based on the "select", - * "where" & "filter" rules provided to it. - * - * @author cdtank - */ -public class GenericQueryRunner implements QueryRunner { - - protected static final Syntax SYNTAX = Syntax.syntaxARQ; - - private String whereClause, individualURLParam; - private DataSource dataSource; - - private Log log; - - private Map fieldLabelToOutputFieldLabel; - - public GenericQueryRunner(String individualURLParam, - Map fieldLabelToOutputFieldLabel, - String whereClause, - DataSource dataSource, - Log log) { - - this.individualURLParam = individualURLParam; - this.fieldLabelToOutputFieldLabel = fieldLabelToOutputFieldLabel; - this.whereClause = whereClause; - this.dataSource = dataSource; - this.log = log; - - } - - private ResultSet executeQuery(String queryText, - DataSource dataSource) { - - QueryExecution queryExecution = null; -// try { - Query query = QueryFactory.create(queryText, SYNTAX); - -// QuerySolutionMap qs = new QuerySolutionMap(); -// qs.add("authPerson", queryParam); // bind resource to s - - queryExecution = QueryExecutionFactory.create(query, dataSource); - - - //remocve this if loop after knowing what is describe & construct sparql stuff. -// if (query.isSelectType()) { - return queryExecution.execSelect(); -// } -// } finally { -// if (queryExecution != null) { -// queryExecution.close(); -// } -// -// } -// return null; - } - - private String generateGenericSparqlQuery() { -// Resource uri1 = ResourceFactory.createResource(queryURI); - - StringBuilder sparqlQuery = new StringBuilder(); - sparqlQuery.append(QueryConstants.getSparqlPrefixQuery()); - - sparqlQuery.append("SELECT\n"); - - for (Map.Entry currentfieldLabelToOutputFieldLabel - : this.fieldLabelToOutputFieldLabel.entrySet()) { - - sparqlQuery.append("\t(str(?" + currentfieldLabelToOutputFieldLabel.getKey() + ") as ?" - + currentfieldLabelToOutputFieldLabel.getValue() + ")\n"); - - } - - sparqlQuery.append("WHERE {\n"); - - sparqlQuery.append(this.whereClause); - - sparqlQuery.append("}\n"); - - return sparqlQuery.toString(); - } - - public ResultSet getQueryResult() - throws MalformedQueryParametersException { - if (StringUtils.isNotBlank(this.individualURLParam)) { - /* - * To test for the validity of the URI submitted. - * */ - IRIFactory iRIFactory = IRIFactory.jenaImplementation(); - IRI iri = iRIFactory.create(this.individualURLParam); - if (iri.hasViolation(false)) { - String errorMsg = ((Violation) iri.violations(false).next()).getShortMessage(); - log.error("Generic Query " + errorMsg); - throw new MalformedQueryParametersException( - "URI provided for an individual is malformed."); - } - } else { - throw new MalformedQueryParametersException("URI parameter is either null or empty."); - } - - ResultSet resultSet = executeQuery(generateGenericSparqlQuery(), - this.dataSource); - - return resultSet; - } -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/visutils/PDFDocument.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/visutils/PDFDocument.java deleted file mode 100644 index d6a737cf..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/visutils/PDFDocument.java +++ /dev/null @@ -1,297 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.visualization.visutils; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Stroke; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Map; -import java.util.Map.Entry; - -import com.itextpdf.text.BadElementException; -import com.itextpdf.text.BaseColor; -import com.itextpdf.text.Chunk; -import com.itextpdf.text.Document; -import com.itextpdf.text.DocumentException; -import com.itextpdf.text.Element; -import com.itextpdf.text.Font; -import com.itextpdf.text.FontFactory; -import com.itextpdf.text.Image; -import com.itextpdf.text.Paragraph; -import com.itextpdf.text.Phrase; -import com.itextpdf.text.pdf.ColumnText; -import com.itextpdf.text.pdf.PdfContentByte; -import com.itextpdf.text.pdf.PdfGState; -import com.itextpdf.text.pdf.PdfPCell; -import com.itextpdf.text.pdf.PdfPTable; -import com.itextpdf.text.pdf.PdfWriter; - -public class PDFDocument { - - - static Stroke stroke = new BasicStroke(5.f, BasicStroke.CAP_ROUND, - BasicStroke.JOIN_ROUND); - - final static Color bg = Color.green; - - final static Color fg = Color.black; - - public PDFDocument(String authorName, - Map yearToPublicationCount, - Document document, - PdfWriter pdfWriter) { - -// setPreferredSize(new Dimension(600,400)); - - try { - - document.addTitle("PDF Pipeline iText Prototype"); - document.addAuthor(authorName); - document.addSubject("This example tests text, color, image, transparency & table functionality."); - document.addKeywords("text, color, image, transparency, table"); - document.addCreator("Standalone PDF Renderer using iText"); - - Paragraph header = new Paragraph(); - - Font pageHeaderStyle = FontFactory.getFont(FontFactory.TIMES_ROMAN, 15, Font.BOLDITALIC | Font.UNDERLINE); - Font featureHeaderStyle = FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, new BaseColor(Color.red)); - - header.add(new Chunk("PDF Pipeline Prototype v2 using iText\n", - pageHeaderStyle)); - - header.setSpacingAfter(15f); - - - document.add(header); - - - Paragraph content = new Paragraph(); - - content.add(new Chunk("Publication Count - Author Name - " + authorName, - featureHeaderStyle)); - - content.setSpacingAfter(15f); - - document.add(content); - // step4 - - PdfPTable publicationCount = createTable(yearToPublicationCount); - - document.add(publicationCount); - - content = new Paragraph(); - - content.add(new Chunk("Transparency of Shapes", - featureHeaderStyle)); - - content.setSpacingAfter(15f); - - document.add(content); - - createTransparencyShapes(document, pdfWriter); - - - createImage(document, pdfWriter, featureHeaderStyle); - - } catch (DocumentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - - - private void createImage(Document document, PdfWriter writer, - Font featureHeaderStyle) throws BadElementException, - MalformedURLException, IOException, DocumentException { - Image imageSprite = Image.getInstance(new URL("http://lh3.ggpht.com/_4msVPAgKJv8/SCRYD-pPVKI/AAAAAAAAAYU/zUN963EPoZc/s1024/102_0609.JPG")); - imageSprite.setAbsolutePosition(400, 500); - imageSprite.scaleAbsolute(171.0f, 250.0f); - float imageSpriteY = document.getPageSize().getHeight() * 0.60f; - float imageSpriteX = document.getPageSize().getWidth() * 0.65f; - imageSprite.setAlignment(Image.UNDERLYING); - - document.add(imageSprite); - - PdfContentByte cb = writer.getDirectContent(); - ColumnText ct = new ColumnText(cb); - Chunk imageHeader = new Chunk("Images", - featureHeaderStyle); - ct.addText(imageHeader); - ct.setAlignment(Element.ALIGN_LEFT); - ct.setSimpleColumn(imageSpriteX, imageSpriteY - imageSprite.getScaledHeight(), - imageSpriteX + imageSprite.getScaledWidth(), imageSpriteY + imageSprite.getScaledHeight() + 20); - ct.go(); - - ct = new ColumnText(cb); - Chunk imageFooter = new Chunk("Footer to be set for a figure. Similar to 'image cpation'.", - FontFactory.getFont(FontFactory.TIMES_ROMAN, 8)); - ct.addText(imageFooter); - ct.setAlignment(Element.ALIGN_CENTER); - ct.setSimpleColumn(imageSpriteX, imageSpriteY - 150, imageSpriteX + imageSprite.getScaledWidth(), imageSpriteY); - ct.go(); - } - - private void createTransparencyShapes(Document document, - PdfWriter writer) throws Exception { - PdfContentByte cb = writer.getDirectContent(); - - pictureBackdrop(document.leftMargin(), 350, cb); - cb.saveState(); - PdfGState gs1 = new PdfGState(); - gs1.setFillOpacity(0.5f); - cb.setGState(gs1); - pictureCircles(document.leftMargin(), 350, cb); - cb.restoreState(); - - cb.resetRGBColorFill(); - } - - /** - * Prints a square and fills half of it with a gray rectangle. - * @param x - * @param y - * @param cb - * @throws Exception - */ - public void pictureBackdrop(float x, float y, PdfContentByte cb) throws Exception { - cb.setColorStroke(new BaseColor(Color.black)); - cb.setColorFill(new BaseColor(Color.gray)); - cb.rectangle(x, y, 100, 200); - cb.fill(); - cb.setLineWidth(2); - cb.rectangle(x, y, 200, 200); - cb.stroke(); - } - - /** - * Prints 3 circles in different colors that intersect with eachother. - * @param x - * @param y - * @param cb - * @throws Exception - */ - public void pictureCircles(float x, float y, PdfContentByte cb) throws Exception { - - cb.saveState(); - PdfGState gs1 = new PdfGState(); - gs1.setFillOpacity(1.0f); - cb.setGState(gs1); - cb.setColorFill(new BaseColor(Color.red)); - cb.circle(x + 70, y + 70, 50); - cb.fill(); - cb.restoreState(); - - cb.setColorFill(new BaseColor(Color.yellow)); - cb.circle(x + 100, y + 130, 50); - cb.fill(); - cb.setColorFill(new BaseColor(Color.blue)); - cb.circle(x + 130, y + 70, 50); - cb.fill(); - } - - private PdfPTable createTable(Map yearToPublicationCount) { - - Font normalContentStyle = FontFactory.getFont(FontFactory.TIMES_ROMAN, 11); - Font summaryContentStyle = FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, Font.BOLDITALIC); - BaseColor summaryBackgroundColor = new BaseColor(0xEE, 0xEE, 0xEE); - BaseColor headerBackgroundColor = new BaseColor(0xC3, 0xD9, 0xFF); - BaseColor bodyBackgroundColor = new BaseColor(Color.white); - - PdfPTable table = new PdfPTable(2); - table.setWidthPercentage(36.0f); - - table.setHorizontalAlignment(Element.ALIGN_LEFT); - table.getDefaultCell().setBorderWidth(0.0f); - table.setHeaderRows(2); - - PdfPCell cell; - cell = new PdfPCell(new Phrase("Publications per year", normalContentStyle)); - setTableCaptionStyle(summaryBackgroundColor, cell); - table.addCell(cell); - - cell = new PdfPCell(new Phrase("Year", normalContentStyle)); - setTableHeaderStyle(headerBackgroundColor, cell); - table.addCell(cell); - - cell.setPhrase(new Phrase("Publications", normalContentStyle)); - table.addCell(cell); - - - - setTableBodyStyle(bodyBackgroundColor, cell); - int totalPublications = 0; - - for (Entry currentEntry : yearToPublicationCount.entrySet()) { - - cell.setPhrase(new Phrase(currentEntry.getKey(), normalContentStyle)); - table.addCell(cell); - - cell.setPhrase(new Phrase(currentEntry.getValue().toString(), normalContentStyle)); - table.addCell(cell); - - totalPublications += currentEntry.getValue(); - } - - setTableFooterStyle(summaryBackgroundColor, cell); - cell.setPhrase(new Phrase("Total", summaryContentStyle)); - table.addCell(cell); - - cell.setPhrase(new Phrase(String.valueOf(totalPublications), summaryContentStyle)); - table.addCell(cell); - - return table; - } - - private void setTableFooterStyle(BaseColor footerBackgroundColor, - PdfPCell cell) { - cell.setBorderWidth(0.0f); - cell.setBackgroundColor(footerBackgroundColor); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); - cell.setPaddingTop(5f); - cell.setPaddingRight(10f); - cell.setPaddingBottom(5f); - cell.setPaddingLeft(10f); - } - - private void setTableBodyStyle(BaseColor bodyBackgroundColor, - PdfPCell cell) { - cell.setBorderWidth(0.0f); - cell.setBackgroundColor(bodyBackgroundColor); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); - cell.setPaddingTop(5f); - cell.setPaddingRight(10f); - cell.setPaddingBottom(5f); - cell.setPaddingLeft(10f); - } - - private void setTableHeaderStyle(BaseColor headerBackgroundColor, - PdfPCell cell) { - cell.setBorderWidth(0.0f); - cell.setBackgroundColor(headerBackgroundColor); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); - cell.setPaddingTop(5f); - cell.setPaddingRight(10f); - cell.setPaddingBottom(5f); - cell.setPaddingLeft(10f); - } - - private void setTableCaptionStyle(BaseColor summaryBackgroundColor, - PdfPCell cell) { - cell.setBorderWidth(0.0f); - cell.setBackgroundColor(summaryBackgroundColor); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); - cell.setPaddingTop(5.0f); - cell.setPaddingRight(10.0f); - cell.setPaddingBottom(5.0f); - cell.setPaddingLeft(10.0f); - cell.setColspan(2); - } - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/visutils/QueryRunner.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/visutils/QueryRunner.java deleted file mode 100644 index 58a572ae..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/visutils/QueryRunner.java +++ /dev/null @@ -1,11 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.visualization.visutils; - -import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException; - -public interface QueryRunner { - - QueryResult getQueryResult() throws MalformedQueryParametersException; - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/visutils/UniqueIDGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/visutils/UniqueIDGenerator.java deleted file mode 100644 index ddfa0b27..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/visutils/UniqueIDGenerator.java +++ /dev/null @@ -1,16 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.visualization.visutils; - -public class UniqueIDGenerator { - - private int nextNumericID = 1; - - public int getNextNumericID() { - int nextNumericID = this.nextNumericID; - this.nextNumericID++; - - return nextNumericID; - } - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/visutils/UtilityFunctions.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/visutils/UtilityFunctions.java deleted file mode 100644 index fc406c06..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/visutils/UtilityFunctions.java +++ /dev/null @@ -1,243 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.visualization.visutils; - -import java.io.IOException; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; - -import edu.cornell.mannlib.vitro.webapp.beans.Portal; -import edu.cornell.mannlib.vitro.webapp.controller.Controllers; -import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; -import edu.cornell.mannlib.vitro.webapp.visualization.constants.VisConstants; -import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.BiboDocument; -import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.CoAuthorshipData; -import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.CoPIData; -import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Grant; -import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.CoPINode; -import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Node; - - -public class UtilityFunctions { - - public static Map getYearToPublicationCount( - Set authorDocuments) { - - /* - * Create a map from the year to number of publications. Use the BiboDocument's - * parsedPublicationYear to populate the data. - * */ - Map yearToPublicationCount = new TreeMap(); - - for (BiboDocument curr : authorDocuments) { - - /* - * Increment the count because there is an entry already available for - * that particular year. - * - * I am pushing the logic to check for validity of year in "getPublicationYear" itself - * because, - * 1. We will be using getPub... multiple times & this will save us duplication of code - * 2. If we change the logic of validity of a pub year we would not have to make - * changes all throughout the codebase. - * 3. We are asking for a publication year & we should get a proper one or NOT at all. - * */ - String publicationYear; - if (curr.getPublicationYear() != null) { - publicationYear = curr.getPublicationYear(); - } else { - publicationYear = curr.getParsedPublicationYear(); - } - - if (yearToPublicationCount.containsKey(publicationYear)) { - yearToPublicationCount.put(publicationYear, - yearToPublicationCount - .get(publicationYear) + 1); - - } else { - yearToPublicationCount.put(publicationYear, 1); - } - - } - - return yearToPublicationCount; - } - - /** - * This method is used to return a mapping between publication year & all the co-authors - * that published with ego in that year. - * @param authorNodesAndEdges - * @return - */ - public static Map> getPublicationYearToCoAuthors( - CoAuthorshipData authorNodesAndEdges) { - - Map> yearToCoAuthors = new TreeMap>(); - - Node egoNode = authorNodesAndEdges.getEgoNode(); - - for (Node currNode : authorNodesAndEdges.getNodes()) { - - /* - * We have already printed the Ego Node info. - * */ - if (currNode != egoNode) { - - for (String year : currNode.getYearToPublicationCount().keySet()) { - - Set coAuthorNodes; - - if (yearToCoAuthors.containsKey(year)) { - - coAuthorNodes = yearToCoAuthors.get(year); - coAuthorNodes.add(currNode); - - } else { - - coAuthorNodes = new HashSet(); - coAuthorNodes.add(currNode); - yearToCoAuthors.put(year, coAuthorNodes); - } - - } - - } - } - return yearToCoAuthors; - } - - /** - * Currently the approach for slugifying filenames is naive. In future if there is need, - * we can write more sophisticated method. - * @param textToBeSlugified - * @return - */ - public static String slugify(String textToBeSlugified) { - String textBlockSeparator = "-"; - return StringUtils.removeEnd(StringUtils.substring(textToBeSlugified.toLowerCase().trim() - .replaceAll("[^a-zA-Z0-9-]+", textBlockSeparator), - 0, - VisConstants.MAX_NAME_TEXT_LENGTH), - textBlockSeparator); - } - - - public static void handleMalformedParameters(String errorMessage, - String errorPageTitle, - VitroRequest vitroRequest, - HttpServletRequest request, - HttpServletResponse response, - Log log) - throws ServletException, IOException { - - Portal portal = vitroRequest.getPortal(); - - request.setAttribute("error", errorMessage); - - RequestDispatcher requestDispatcher = request.getRequestDispatcher(Controllers.BASIC_JSP); - request.setAttribute("bodyJsp", "/templates/visualization/visualization_error.jsp"); - request.setAttribute("portalBean", portal); - request.setAttribute("title", errorPageTitle); - - try { - requestDispatcher.forward(request, response); - } catch (Exception e) { - log.error("EntityEditController could not forward to view."); - log.error(e.getMessage()); - log.error(e.getStackTrace()); - } - } - - public static Map> getGrantYearToCoPI( - CoPIData pINodesAndEdges) { - - - Map> yearToCoPIs = new TreeMap>(); - - CoPINode egoNode = pINodesAndEdges.getEgoNode(); - - for (CoPINode currNode : pINodesAndEdges.getNodes()) { - - /* - * We have already printed the Ego Node info. - * */ - if (currNode != egoNode) { - - for (String year : currNode.getYearToGrantCount().keySet()) { - - Set coPINodes; - - if (yearToCoPIs.containsKey(year)) { - - coPINodes = yearToCoPIs.get(year); - coPINodes.add(currNode); - - } else { - - coPINodes = new HashSet(); - coPINodes.add(currNode); - yearToCoPIs.put(year, coPINodes); - } - - } - - } - } - return yearToCoPIs; - - } - - public static Map getYearToGrantCount(Set pIGrants) { - - /* - * Create a map from the year to number of grants. Use the Grant's - * parsedGrantStartYear to populate the data. - * */ - Map yearToGrantCount = new TreeMap(); - - for (Grant curr : pIGrants) { - - /* - * Increment the count because there is an entry already available for - * that particular year. - * - * I am pushing the logic to check for validity of year in "getGrantYear" itself - * because, - * 1. We will be using getGra... multiple times & this will save us duplication of code - * 2. If we change the logic of validity of a grant year we would not have to make - * changes all throughout the codebase. - * 3. We are asking for a grant year & we should get a proper one or NOT at all. - * */ - String grantYear; - if (curr.getGrantStartYear() != null) { - grantYear = curr.getGrantStartYear(); - } else { - grantYear = curr.getParsedGrantStartYear(); - } - - if (yearToGrantCount.containsKey(grantYear)) { - yearToGrantCount.put(grantYear, - yearToGrantCount - .get(grantYear) + 1); - - } else { - yearToGrantCount.put(grantYear, 1); - } - - } - - return yearToGrantCount; - - } - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/visutils/VisualizationRequestHandler.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/visutils/VisualizationRequestHandler.java deleted file mode 100644 index ecfa6bbd..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/visutils/VisualizationRequestHandler.java +++ /dev/null @@ -1,31 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ -package edu.cornell.mannlib.vitro.webapp.visualization.visutils; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.logging.Log; - -import com.hp.hpl.jena.query.DataSource; - -import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; - -/** - * This interface is being implemented by all the visualization request handlers like - * PersonLevelRequestHandler, PersonPublicationCountRequestHandler, UtilitiesRequestHandler - * etc. All the future visualizations must implement this because the ability of - * a visualization to be served to the users is dependent on it. We have implemented - * dependency injection mechanism & one of the conditions that is used to enable a visualization - * handler is its implementation of VisualizationRequestHandler. - * - * @author cdtank - */ -public interface VisualizationRequestHandler { - - void generateVisualization(VitroRequest vitroRequest, - HttpServletRequest request, - HttpServletResponse response, - Log log, - DataSource dataSource); - -}