Commit 5e2a2a4dd5fd185deaeb38f74a1650a8ccf428a0

Authored by Tiago Guimarães
Exists in researchcenters

Merge branch 'researchcenters' of gitlab.fccn.pt:tguimaraes/dspace into researchcenters

dspace-jspui/src/main/java/pt/uminho/sdum/researchcenters/CenterType.java
... ... @@ -0,0 +1,100 @@
  1 +
  2 +package pt.uminho.sdum.researchcenters;
  3 +
  4 +import javax.xml.bind.annotation.XmlAccessType;
  5 +import javax.xml.bind.annotation.XmlAccessorType;
  6 +import javax.xml.bind.annotation.XmlElement;
  7 +import javax.xml.bind.annotation.XmlType;
  8 +
  9 +
  10 +/**
  11 + * <p>Java class for centerType complex type.
  12 + *
  13 + * <p>The following schema fragment specifies the expected content contained within this class.
  14 + *
  15 + * <pre>
  16 + * &lt;complexType name="centerType">
  17 + * &lt;complexContent>
  18 + * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
  19 + * &lt;sequence>
  20 + * &lt;element name="name">
  21 + * &lt;simpleType>
  22 + * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
  23 + * &lt;/restriction>
  24 + * &lt;/simpleType>
  25 + * &lt;/element>
  26 + * &lt;element name="handle">
  27 + * &lt;simpleType>
  28 + * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
  29 + * &lt;/restriction>
  30 + * &lt;/simpleType>
  31 + * &lt;/element>
  32 + * &lt;/sequence>
  33 + * &lt;/restriction>
  34 + * &lt;/complexContent>
  35 + * &lt;/complexType>
  36 + * </pre>
  37 + *
  38 + *
  39 + */
  40 +@XmlAccessorType(XmlAccessType.FIELD)
  41 +@XmlType(name = "centerType", propOrder = {
  42 + "name",
  43 + "handle"
  44 +})
  45 +public class CenterType {
  46 +
  47 + @XmlElement(required = true)
  48 + protected String name;
  49 + @XmlElement(required = true)
  50 + protected String handle;
  51 +
  52 + /**
  53 + * Gets the value of the name property.
  54 + *
  55 + * @return
  56 + * possible object is
  57 + * {@link String }
  58 + *
  59 + */
  60 + public String getName() {
  61 + return name;
  62 + }
  63 +
  64 + /**
  65 + * Sets the value of the name property.
  66 + *
  67 + * @param value
  68 + * allowed object is
  69 + * {@link String }
  70 + *
  71 + */
  72 + public void setName(String value) {
  73 + this.name = value;
  74 + }
  75 +
  76 + /**
  77 + * Gets the value of the handle property.
  78 + *
  79 + * @return
  80 + * possible object is
  81 + * {@link String }
  82 + *
  83 + */
  84 + public String getHandle() {
  85 + return handle;
  86 + }
  87 +
  88 + /**
  89 + * Sets the value of the handle property.
  90 + *
  91 + * @param value
  92 + * allowed object is
  93 + * {@link String }
  94 + *
  95 + */
  96 + public void setHandle(String value) {
  97 + this.handle = value;
  98 + }
  99 +
  100 +}
... ...
dspace-jspui/src/main/java/pt/uminho/sdum/researchcenters/CentersType.java
... ... @@ -0,0 +1,69 @@
  1 +
  2 +package pt.uminho.sdum.researchcenters;
  3 +
  4 +import javax.xml.bind.annotation.XmlAccessType;
  5 +import javax.xml.bind.annotation.XmlAccessorType;
  6 +import javax.xml.bind.annotation.XmlRootElement;
  7 +import javax.xml.bind.annotation.XmlType;
  8 +import java.util.ArrayList;
  9 +import java.util.List;
  10 +
  11 +
  12 +/**
  13 + * <p>Java class for centersType complex type.
  14 + *
  15 + * <p>The following schema fragment specifies the expected content contained within this class.
  16 + *
  17 + * <pre>
  18 + * &lt;complexType name="centersType">
  19 + * &lt;complexContent>
  20 + * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
  21 + * &lt;sequence>
  22 + * &lt;element name="center" type="{}centerType" maxOccurs="unbounded" minOccurs="0"/>
  23 + * &lt;/sequence>
  24 + * &lt;/restriction>
  25 + * &lt;/complexContent>
  26 + * &lt;/complexType>
  27 + * </pre>
  28 + *
  29 + *
  30 + */
  31 +@XmlRootElement(name = "centers")
  32 +@XmlAccessorType(XmlAccessType.FIELD)
  33 +@XmlType(name = "centersType", propOrder = {
  34 + "center"
  35 +})
  36 +public class CentersType {
  37 +
  38 + protected List<CenterType> center;
  39 +
  40 + /**
  41 + * Gets the value of the center property.
  42 + *
  43 + * <p>
  44 + * This accessor method returns a reference to the live list,
  45 + * not a snapshot. Therefore any modification you make to the
  46 + * returned list will be present inside the JAXB object.
  47 + * This is why there is not a <CODE>set</CODE> method for the center property.
  48 + *
  49 + * <p>
  50 + * For example, to add a new item, do as follows:
  51 + * <pre>
  52 + * getCenter().add(newItem);
  53 + * </pre>
  54 + *
  55 + *
  56 + * <p>
  57 + * Objects of the following type(s) are allowed in the list
  58 + * {@link CenterType }
  59 + *
  60 + *
  61 + */
  62 + public List<CenterType> getCenter() {
  63 + if (center == null) {
  64 + center = new ArrayList<CenterType>();
  65 + }
  66 + return this.center;
  67 + }
  68 +
  69 +}
... ...
dspace-jspui/src/main/java/pt/uminho/sdum/researchcenters/ObjectFactory.java
... ... @@ -0,0 +1,61 @@
  1 +
  2 +package pt.uminho.sdum.researchcenters;
  3 +
  4 +import javax.xml.bind.JAXBElement;
  5 +import javax.xml.bind.annotation.XmlElementDecl;
  6 +import javax.xml.bind.annotation.XmlRegistry;
  7 +import javax.xml.namespace.QName;
  8 +
  9 +
  10 +/**
  11 + * This object contains factory methods for each
  12 + * Java content interface and Java element interface
  13 + * generated in the pt.sdum.researchcenters package.
  14 + * <p>An ObjectFactory allows you to programatically
  15 + * construct new instances of the Java representation
  16 + * for XML content. The Java representation of XML
  17 + * content can consist of schema derived interfaces
  18 + * and classes representing the binding of schema
  19 + * type definitions, element declarations and model
  20 + * groups. Factory methods for each of these are
  21 + * provided in this class.
  22 + *
  23 + */
  24 +@XmlRegistry
  25 +public class ObjectFactory {
  26 +
  27 + private final static QName _Centers_QNAME = new QName("", "centers");
  28 +
  29 + /**
  30 + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: pt.sdum.researchcenters
  31 + *
  32 + */
  33 + public ObjectFactory() {
  34 + }
  35 +
  36 + /**
  37 + * Create an instance of {@link CentersType }
  38 + *
  39 + */
  40 + public CentersType createCentersType() {
  41 + return new CentersType();
  42 + }
  43 +
  44 + /**
  45 + * Create an instance of {@link CenterType }
  46 + *
  47 + */
  48 + public CenterType createCenterType() {
  49 + return new CenterType();
  50 + }
  51 +
  52 + /**
  53 + * Create an instance of {@link JAXBElement }{@code <}{@link CentersType }{@code >}}
  54 + *
  55 + */
  56 + @XmlElementDecl(namespace = "", name = "centers")
  57 + public JAXBElement<CentersType> createCenters(CentersType value) {
  58 + return new JAXBElement<CentersType>(_Centers_QNAME, CentersType.class, null, value);
  59 + }
  60 +
  61 +}
... ...
dspace-jspui/src/main/java/pt/uminho/sdum/researchcenters/researchcenters.xsd
... ... @@ -0,0 +1,25 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  3 + <xs:element name="centers" type="centersType"/>
  4 + <xs:complexType name="centerType">
  5 + <xs:sequence>
  6 + <xs:element name="name">
  7 + <xs:simpleType>
  8 + <xs:restriction base="xs:string">
  9 + </xs:restriction>
  10 + </xs:simpleType>
  11 + </xs:element>
  12 + <xs:element name="handle">
  13 + <xs:simpleType>
  14 + <xs:restriction base="xs:string">
  15 + </xs:restriction>
  16 + </xs:simpleType>
  17 + </xs:element>
  18 + </xs:sequence>
  19 + </xs:complexType>
  20 + <xs:complexType name="centersType">
  21 + <xs:sequence>
  22 + <xs:element type="centerType" name="center" maxOccurs="unbounded" minOccurs="0"/>
  23 + </xs:sequence>
  24 + </xs:complexType>
  25 +</xs:schema>
0 26 \ No newline at end of file
... ...
dspace-jspui/src/main/webapp/researchcenters-list.jsp
... ... @@ -0,0 +1,197 @@
  1 +<%--
  2 +
  3 + The contents of this file are subject to the license and copyright
  4 + detailed in the LICENSE and NOTICE files at the root of the source
  5 + tree and available online at
  6 +
  7 + http://www.dspace.org/license/
  8 +
  9 +--%>
  10 +
  11 +<%--
  12 + - Display hierarchical list of communities and collections
  13 + -
  14 + - Attributes to be passed in:
  15 + - communities - array of communities
  16 + - collections.map - Map where a keys is a community IDs (Integers) and
  17 + - the value is the array of collections in that community
  18 + - subcommunities.map - Map where a keys is a community IDs (Integers) and
  19 + - the value is the array of subcommunities in that community
  20 + - admin_button - Boolean, show admin 'Create Top-Level Community' button
  21 + --%>
  22 +
  23 +<%@page import="org.dspace.content.Bitstream"%>
  24 +<%@page import="org.apache.commons.lang.StringUtils"%>
  25 +<%@ page contentType="text/html;charset=UTF-8" %>
  26 +
  27 +<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
  28 +
  29 +<%@ page import="org.dspace.app.webui.servlet.admin.EditCommunitiesServlet" %>
  30 +<%@ page import="org.dspace.app.webui.util.UIUtil" %>
  31 +<%@ page import="org.dspace.browse.ItemCountException" %>
  32 +<%@ page import="org.dspace.browse.ItemCounter" %>
  33 +<%@ page import="org.dspace.content.Collection" %>
  34 +<%@ page import="org.dspace.content.Community" %>
  35 +<%@ page import="org.dspace.core.ConfigurationManager" %>
  36 +<%@ page import="javax.servlet.jsp.jstl.fmt.LocaleSupport" %>
  37 +<%@ page import="java.io.IOException" %>
  38 +<%@ page import="java.sql.SQLException" %>
  39 +<%@ page import="org.dspace.handle.HandleManager" %>
  40 +<%@ page import="org.dspace.core.Context" %>
  41 +<%@ page import="javax.xml.bind.JAXBContext" %>
  42 +<%@ page import="javax.xml.bind.Unmarshaller" %>
  43 +<%@ page import="pt.uminho.sdum.researchcenters.CentersType" %>
  44 +<%@ page import="java.io.File" %>
  45 +<%@ page import="pt.uminho.sdum.researchcenters.CenterType" %>
  46 +
  47 +<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
  48 +
  49 +<%
  50 +
  51 + boolean admin_button = false;
  52 + ItemCounter ic = new ItemCounter(UIUtil.obtainContext(request));
  53 +%>
  54 +
  55 +<%!
  56 + void showCommunity(Community c, JspWriter out, HttpServletRequest request, ItemCounter ic)
  57 + throws ItemCountException, IOException, SQLException
  58 + {
  59 + boolean showLogos = ConfigurationManager.getBooleanProperty("jspui.community-list.logos", true);
  60 + out.println( "<li class=\"media well\">" );
  61 + Bitstream logo = c.getLogo();
  62 + if (showLogos && logo != null)
  63 + {
  64 + out.println("<a class=\"pull-left col-md-1\" href=\"" + request.getContextPath() + "/handle/"
  65 + + c.getHandle() + "\"><img class=\"media-object img-responsive\" src=\"" +
  66 + request.getContextPath() + "/retrieve/" + logo.getID() + "\" alt=\"community logo\"></a>");
  67 + }
  68 +
  69 + //FR: Change - pushed up the cols and comms
  70 + Collection[] cols = c.getCollections();
  71 + Community[] comms = c.getSubcommunities();
  72 +
  73 + if (cols != null && cols.length > 0 || (comms!= null && comms.length > 0))
  74 + {
  75 +
  76 + //FR - Collapse collections
  77 + out.print("<span class=\"paneltitle\"><a class=\"collapsed label label-default\" href=\"javascript:void(0)\" data-toggle=\"collapse\" data-target=\"."+c.getHandle().replaceAll("(.*)/","comTop")+"\"> </a></span>");
  78 + }
  79 + //End Change
  80 +
  81 +
  82 + out.println( "<div class=\"media-body\"><h4 class=\"media-heading\"><a href=\"" + request.getContextPath() + "/handle/"
  83 + + c.getHandle() + "\">" + c.getMetadata("name") + "</a>");
  84 + if(ConfigurationManager.getBooleanProperty("webui.strengths.show"))
  85 + {
  86 + out.println(" <span class=\"badge\">" + ic.getCount(c) + "</span>");
  87 + }
  88 + out.println("</h4>");
  89 + if (StringUtils.isNotBlank(c.getMetadata("short_description")))
  90 + {
  91 + out.println(c.getMetadata("short_description"));
  92 + }
  93 +
  94 +
  95 + out.println("<br>");
  96 + // Get the collections in this community
  97 +
  98 + //FR: Change
  99 + //Collection[] cols = (Collection[]) collectionMap.get(c.getID());
  100 + if (cols != null && cols.length > 0)
  101 + {
  102 +
  103 + //FR - Change
  104 + out.println("<ul class=\""+c.getHandle().replaceAll("(.*)/","comTop")+" collapse media-list\">");
  105 + // out.println("<ul class=\"media-list\">");
  106 +
  107 +
  108 + for (int j = 0; j < cols.length; j++)
  109 + {
  110 + out.println("<li class=\"media well\">");
  111 +
  112 + Bitstream logoCol = cols[j].getLogo();
  113 + if (showLogos && logoCol != null)
  114 + {
  115 + out.println("<a class=\"pull-left col-md-1\" href=\"" + request.getContextPath() + "/handle/"
  116 + + cols[j].getHandle() + "\"><img class=\"media-object img-responsive\" src=\"" +
  117 + request.getContextPath() + "/retrieve/" + logoCol.getID() + "\" alt=\"collection logo\"></a>");
  118 + }
  119 + out.println("<div class=\"media-body\"><h4 class=\"media-heading\"><a href=\"" + request.getContextPath() + "/handle/" + cols[j].getHandle() + "\">" + cols[j].getMetadata("name") +"</a>");
  120 + if(ConfigurationManager.getBooleanProperty("webui.strengths.show"))
  121 + {
  122 + out.println(" [" + ic.getCount(cols[j]) + "]");
  123 + }
  124 + out.println("</h4>");
  125 + if (StringUtils.isNotBlank(cols[j].getMetadata("short_description")))
  126 + {
  127 + out.println(cols[j].getMetadata("short_description"));
  128 + }
  129 + out.println("</div>");
  130 + out.println("</li>");
  131 + }
  132 + out.println("</ul>");
  133 + }
  134 +
  135 + // Get the sub-communities in this community
  136 + //FR: Change - collapse
  137 + //Community[] comms = (Community[]) subcommunityMap.get(c.getID());
  138 + if (comms != null && comms.length > 0)
  139 + {
  140 + //FR Change
  141 + out.println("<ul class=\""+c.getHandle().replaceAll("(.*)/","comTop")+" collapse media-list\" >");
  142 + //out.println("<ul class=\"media-list\">");
  143 + for (int k = 0; k < comms.length; k++)
  144 + {
  145 + showCommunity(comms[k], out, request, ic);
  146 + }
  147 + out.println("</ul>");
  148 + }
  149 + out.println("</div>");
  150 + out.println("</li>");
  151 + }
  152 +%>
  153 +
  154 +<dspace:layout titlekey="jsp.community-list.title">
  155 +
  156 +<%
  157 + if (admin_button)
  158 + {
  159 +%>
  160 +<dspace:sidebar>
  161 + <div class="panel panel-warning">
  162 + <div class="panel-heading">
  163 + <fmt:message key="jsp.admintools"/>
  164 + <span class="pull-right">
  165 + <dspace:popup page="<%= LocaleSupport.getLocalizedMessage(pageContext, \"help.site-admin\")%>"><fmt:message key="jsp.adminhelp"/></dspace:popup>
  166 + </span>
  167 + </div>
  168 + <div class="panel-body">
  169 + <form method="post" action="<%=request.getContextPath()%>/dspace-admin/edit-communities">
  170 + <input type="hidden" name="action" value="<%=EditCommunitiesServlet.START_CREATE_COMMUNITY%>" />
  171 + <input class="btn btn-default" type="submit" name="submit" value="<fmt:message key="jsp.community-list.create.button"/>" />
  172 + </form>
  173 + </div>
  174 +</dspace:sidebar>
  175 +<%
  176 + }
  177 +%>
  178 + <h1><fmt:message key="jsp.community-list.title"/></h1>
  179 + <p><fmt:message key="jsp.community-list.text1"/></p>
  180 +
  181 +
  182 + <ul class="media-list">
  183 +<%
  184 + Context context = UIUtil.obtainContext(request);
  185 +
  186 + JAXBContext jc = JAXBContext.newInstance(CentersType.class);
  187 + Unmarshaller u = jc.createUnmarshaller();
  188 + CentersType o =(CentersType) u.unmarshal( new File( "/dspace/config/modules/researchcenters.xml" ) );
  189 +
  190 +
  191 + for (CenterType center : o.getCenter()) {
  192 + showCommunity((Community) HandleManager.resolveToObject(context,center.getHandle()), out, request, ic);
  193 + }
  194 +%>
  195 + </ul>
  196 +
  197 +</dspace:layout>
... ...
dspace/config/modules/researchcenters.xml
... ... @@ -0,0 +1,10 @@
  1 +<centers>
  2 + <center>
  3 + <name>HASLab</name>
  4 + <handle>123456789/1</handle>
  5 + </center>
  6 + <center>
  7 + <name>Centro ALGORITMI</name>
  8 + <handle>123456789/15</handle>
  9 + </center>
  10 +</centers>
0 11 \ No newline at end of file
... ...