Commit 5a4279185b5cf3b25e6baca0db8d59f78bb4e06d

Authored by Tiago Guimarães
1 parent ac8af3e82b
Exists in researchcenters

files

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/resources/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
... ...
dspace-jspui/src/main/webapp/researchcenters-list.jsp
... ... @@ -36,17 +36,18 @@
36 36 <%@ page import="javax.servlet.jsp.jstl.fmt.LocaleSupport" %>
37 37 <%@ page import="java.io.IOException" %>
38 38 <%@ page import="java.sql.SQLException" %>
39   -<%@ page import="java.util.Map" %>
40   -<%@ page import="java.util.Set" %>
41   -<%@ page import="java.util.TreeSet" %>
42 39 <%@ page import="org.dspace.handle.HandleManager" %>
43 40 <%@ page import="org.dspace.core.Context" %>
44   -<%@ page import="java.util.HashSet" %>
  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" %>
45 46  
46 47 <%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
47 48  
48 49 <%
49   - Set<Community> communities = new HashSet<Community>();
  50 +
50 51 boolean admin_button = false;
51 52 ItemCounter ic = new ItemCounter(UIUtil.obtainContext(request));
52 53 %>
... ... @@ -181,13 +182,16 @@
181 182 <ul class="media-list">
182 183 <%
183 184 Context context = UIUtil.obtainContext(request);
184   - communities.add((Community) HandleManager.resolveToObject(context,"123456789/1"));
185   - communities.add((Community) HandleManager.resolveToObject(context,"123456789/15"));
186   - for (Community community : communities) {
187   - showCommunity(community, out, request, ic);
  185 +
  186 + JAXBContext jc = JAXBContext.newInstance(CentersType.class);
  187 + Unmarshaller u = jc.createUnmarshaller();
  188 + CentersType o =(CentersType) u.unmarshal( new File( "researchcenters.xml" ) );
  189 +
  190 +
  191 + for (CenterType center : o.getCenter()) {
  192 + showCommunity((Community) HandleManager.resolveToObject(context,center.getHandle()), out, request, ic);
188 193 }
189 194 %>
190 195 </ul>
191 196  
192   -%>
193 197 </dspace:layout>
... ...