Commit a91d12cfe8442109774bebb3f6f8568fa3b7f26a

Authored by Tiago Guimarães
1 parent e65c68fed9

Fixed Duplicates Curation Task

removed Queue button form curate collection and curate community
Added translations
dspace-api/src/main/java/pt/uminho/sdum/dspace/curationtasks/CheckDuplicates.java
1 1 package pt.uminho.sdum.dspace.curationtasks;
2 2  
3 3 import org.dspace.content.*;
  4 +import org.dspace.content.Collection;
4 5 import org.dspace.curate.AbstractCurationTask;
5 6 import org.dspace.curate.Curator;
6 7 import org.dspace.curate.Distributive;
7 8  
8 9 import java.io.IOException;
9 10 import java.sql.SQLException;
10   -import java.util.ArrayList;
11   -import java.util.HashSet;
12   -import java.util.List;
13   -import java.util.Set;
  11 +import java.util.*;
14 12  
15 13 /**
16 14 * Naive approach, memory heavy
... ... @@ -33,8 +31,24 @@ public class CheckDuplicates extends AbstractCurationTask {
33 31 e.printStackTrace();
34 32 }
35 33 return 0;
  34 + } else if (dso instanceof Community) {
  35 + try {
  36 + List<Item> col = collectAllItemsFromComunnity((Community) dso);
  37 + setResult(checkDuplicates(col));
  38 + } catch (SQLException e) {
  39 + e.printStackTrace();
  40 + }
  41 + return 0;
  42 + } else if (dso instanceof Collection) {
  43 + try {
  44 + List<Item> col = collectAllItemsFromCollection((Collection) dso);
  45 + setResult(checkDuplicates(col));
  46 + } catch (SQLException e) {
  47 + e.printStackTrace();
  48 + }
  49 + return 0;
36 50 } else {
37   - setResult("A tarefa deve ser aplicada ao site inteiro");
  51 + setResult("A tarefa deve ser aplicada ao site, comunidade ou coleção");
38 52 return 2;
39 53 }
40 54 }
... ... @@ -43,7 +57,7 @@ public class CheckDuplicates extends AbstractCurationTask {
43 57 StringBuilder sb = new StringBuilder("<br>");
44 58 Set<Integer> processed = new HashSet<>();
45 59 for (int i = 0; i < col.size(); ++i) {
46   - if(!processed.contains(i)) {
  60 + if (!processed.contains(i)) {
47 61 Item itemI = col.get(i);
48 62 for (int j = i + 1; j < col.size(); ++j) {
49 63 if (!processed.contains(j)) {
... ... @@ -92,18 +106,37 @@ public class CheckDuplicates extends AbstractCurationTask {
92 106 dateI.trim().equals(dateJ.trim());
93 107 }
94 108  
95   - private List<Item> collectAllItems() {
  109 +
  110 + private List<Item> collectAllItemsFromCollection(Collection col) {
96 111 List<Item> res = new ArrayList<>();
97 112 try {
98   - for (Community com : Community.findAllTop(Curator.curationContext()))
99   - for (Collection col : com.getAllCollections()) {
100   - ItemIterator it = col.getAllItems();
101   - if (it != null)
102   - while (it.hasNext())
103   - res.add(it.next());
104   - }
  113 + ItemIterator it = col.getAllItems();
  114 + if (it != null)
  115 + while (it.hasNext())
  116 + res.add(it.next());
  117 + } catch (SQLException e) {
  118 + e.printStackTrace();
  119 + }
  120 + return res;
  121 + }
105 122  
  123 + private List<Item> collectAllItemsFromComunnity(Community com) {
  124 + List<Item> res = new ArrayList<>();
  125 + try {
  126 + for (Collection col : com.getAllCollections())
  127 + res.addAll(collectAllItemsFromCollection(col));
  128 +
  129 + } catch (SQLException e) {
  130 + e.printStackTrace();
  131 + }
  132 + return res;
  133 + }
106 134  
  135 + private List<Item> collectAllItems() {
  136 + List<Item> res = new ArrayList<>();
  137 + try {
  138 + for (Community com : Community.findAllTop(Curator.curationContext()))
  139 + res.addAll(collectAllItemsFromComunnity(com));
107 140 } catch (SQLException e) {
108 141 e.printStackTrace();
109 142 }
... ...
dspace-jspui/src/main/resources/Messages_pt_PT.properties
... ... @@ -496,3 +496,8 @@ metadata.dc.identifier.tid = TID
496 496 metadata.dc.relation.publisherversion = Vers&atilde;o do Editor
497 497 metadata.thesis.degree.name = Designa&ccedil;&atilde;o
498 498 metadata.dc.date.issued_thesis = Data de Defesa
  499 +
  500 +#traduções curation
  501 +jsp.tools.edit-community.form.button.curate = Curadoria
  502 +jsp.tools.edit-collection.form.label27 = Curadoria da Coleção:
  503 +jsp.tools.edit-community.form.label9 = Curadoria da Comunidade:
499 504 \ No newline at end of file
... ...
dspace/modules/jspui/src/main/webapp/tools/curate-collection.jsp
... ... @@ -0,0 +1,95 @@
  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 + - Form requesting a Handle or internal item ID for item editing
  12 + -
  13 + - Attributes:
  14 + - curate_group_options - options string of gropu selection.
  15 + - "" unless ui.taskgroups is set
  16 + - curate_task_options - options string of task selection.
  17 + - collection - the collection
  18 + - task_result - result of the curation task
  19 + --%>
  20 +
  21 +<%@ page contentType="text/html;charset=UTF-8" %>
  22 +
  23 +<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"
  24 + prefix="fmt" %>
  25 +
  26 +<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
  27 +
  28 +<%@ page import="javax.servlet.jsp.jstl.fmt.LocaleSupport" %>
  29 +<%@ page import="org.dspace.app.webui.servlet.admin.EditCommunitiesServlet" %>
  30 +<%@ page import="org.dspace.app.webui.util.CurateTaskResult" %>
  31 +<%@ page import="org.dspace.content.Collection" %>
  32 +<%@ page import="org.dspace.core.ConfigurationManager" %>
  33 +<%!
  34 + private static final String TASK_QUEUE_NAME = ConfigurationManager.getProperty("curate", "ui.queuename");
  35 +%>
  36 +<%
  37 + Collection collection = (Collection) request.getAttribute("collection");
  38 + int collectionID = (collection != null ? collection.getID() : -1);
  39 + int communityID = (collection.getParentObject() != null ? collection.getParentObject().getID() : -1);
  40 + String title = (collection != null ? collection.getMetadata("name") : "Unknown Collection");
  41 + String groupOptions = (String)request.getAttribute("curate_group_options");
  42 + String taskOptions = (String)request.getAttribute("curate_task_options");
  43 +%>
  44 +
  45 +<dspace:layout style="submission" titlekey="jsp.tools.curate.collection.title"
  46 + navbar="admin"
  47 + locbar="link"
  48 + parenttitlekey="jsp.administer"
  49 + parentlink="/dspace-admin">
  50 +
  51 +<%@ include file="/tools/curate-message.jsp" %>
  52 +
  53 + <h1><fmt:message key="jsp.tools.curate.collection.heading">
  54 + <fmt:param value="<%= title %>"/>
  55 + </fmt:message>
  56 + </h1>
  57 + <div class="row container">
  58 + <form action="<%=request.getContextPath()%>/tools/curate" method="post">
  59 +
  60 +<%
  61 + if (groupOptions != null && !"".equals(groupOptions))
  62 + {
  63 +%>
  64 + <label for="select_curate_group"><fmt:message key="jsp.tools.curate.select-group.tag"/></label>:
  65 + <select class="form-control" name="select_curate_group" id="select_curate_group" onchange="this.form.submit();">
  66 + <%= groupOptions %>
  67 + </select>
  68 +<%
  69 + }
  70 +%>
  71 + <div class="input-group">
  72 + <label for="curate_task" class="input-group-addon"><fmt:message key="jsp.tools.curate.select-task.tag"/>:</label>
  73 + <select class="form-control" name="curate_task" id="curate_task">
  74 + <%= taskOptions %>
  75 + </select>
  76 + <input type="hidden" name="collection_id" value="<%= collectionID %>"/>
  77 + </div>
  78 + <br/>
  79 + <div class="col-md-4 row pull-right">
  80 + <!--Commented because queue is forbidden <input class="btn btn-warning col-md-6" type="submit" name="submit_collection_queue" value="<fmt:message key="jsp.tools.curate.queue.button"/>" /> -->
  81 + <input class="btn btn-primary col-md-6" type="submit" name="submit_collection_curate" value="<fmt:message key="jsp.tools.curate.perform.button"/>" />
  82 + </div>
  83 + </form>
  84 + </div>
  85 + <br/>
  86 + <div class="row container">
  87 + <form method="post" action="<%=request.getContextPath()%>/tools/edit-communities">
  88 + <input type="hidden" name="collection_id" value="<%= collectionID %>"/>
  89 + <input type="hidden" name="community_id" value="<%= communityID %>" />
  90 + <input type="hidden" name="action" value="<%=EditCommunitiesServlet.START_EDIT_COLLECTION %>" />
  91 + <input class="btn btn-default" type="submit" value="<fmt:message key="jsp.tools.curate.return.collection.button"/>" />
  92 + </form>
  93 + </div>
  94 +
  95 +</dspace:layout>
... ...
dspace/modules/jspui/src/main/webapp/tools/curate-community.jsp
... ... @@ -0,0 +1,95 @@
  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 + - Form requesting a Handle or internal item ID for item editing
  12 + -
  13 + - Attributes:
  14 + - curate_group_options - options string of gropu selection.
  15 + - "" unless ui.taskgroups is set
  16 + - curate_task_options - options string of task selection.
  17 + - community - the community
  18 + - task_result - result of the curation task
  19 + --%>
  20 +
  21 +<%@ page contentType="text/html;charset=UTF-8" %>
  22 +
  23 +<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"
  24 + prefix="fmt" %>
  25 +
  26 +<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
  27 +
  28 +<%@ page import="javax.servlet.jsp.jstl.fmt.LocaleSupport" %>
  29 +<%@ page import="org.dspace.app.webui.servlet.admin.EditCommunitiesServlet" %>
  30 +<%@ page import="org.dspace.app.webui.util.CurateTaskResult" %>
  31 +<%@ page import="org.dspace.content.Community" %>
  32 +<%@ page import="org.dspace.core.ConfigurationManager" %>
  33 +<%!
  34 + private static final String TASK_QUEUE_NAME = ConfigurationManager.getProperty("curate", "ui.queuename");
  35 +%>
  36 +<%
  37 + Community community = (Community) request.getAttribute("community");
  38 + int communityID = (community != null ? community.getID() : -1);
  39 + String title = (community != null ? community.getMetadata("name") : "Unknown Community");
  40 + String groupOptions = (String)request.getAttribute("curate_group_options");
  41 + String taskOptions = (String)request.getAttribute("curate_task_options");
  42 +%>
  43 +
  44 +<dspace:layout style="submission" titlekey="jsp.tools.curate.community.title"
  45 + navbar="admin"
  46 + locbar="link"
  47 + parenttitlekey="jsp.administer"
  48 + parentlink="/dspace-admin">
  49 +
  50 +<%@ include file="/tools/curate-message.jsp" %>
  51 +
  52 + <h1><fmt:message key="jsp.tools.curate.community.heading">
  53 + <fmt:param value="<%= title %>"/>
  54 + </fmt:message>
  55 + </h1>
  56 + <div class="row container">
  57 + <form action="<%=request.getContextPath()%>/tools/curate" method="post">
  58 +
  59 +<%
  60 + if (groupOptions != null && !"".equals(groupOptions))
  61 + {
  62 +%>
  63 +
  64 + <label for="select_curate_group"><fmt:message key="jsp.tools.curate.select-group.tag"/></label>:
  65 + <select class="form-control" name="select_curate_group" id="select_curate_group" onchange="this.form.submit();">
  66 + <%= groupOptions %>
  67 + </select>
  68 +<%
  69 + }
  70 +%>
  71 +
  72 + <div class="input-group">
  73 + <label for="curate_task" class="input-group-addon"><fmt:message key="jsp.tools.curate.select-task.tag"/>:</label>
  74 + <select class="form-control" name="curate_task" id="curate_task">
  75 + <%= taskOptions %>
  76 + </select>
  77 + </div>
  78 + <input type="hidden" name="community_id" value="<%= communityID %>"/>
  79 + <br/>
  80 + <div class="col-md-4 row pull-right">
  81 + <!--Commented because queue is forbidden <input class="btn btn-warning col-md-6" type="submit" name="submit_community_queue" value="<fmt:message key="jsp.tools.curate.queue.button"/>" />-->
  82 + <input class="btn btn-primary col-md-6" type="submit" name="submit_community_curate" value="<fmt:message key="jsp.tools.curate.perform.button"/>" />
  83 + </div>
  84 + </form>
  85 + </div>
  86 + <br/>
  87 + <div class="row container">
  88 + <form method="post" action="<%=request.getContextPath()%>/tools/edit-communities">
  89 + <input type="hidden" name="community_id" value="<%= communityID %>" />
  90 + <input type="hidden" name="action" value="<%=EditCommunitiesServlet.START_EDIT_COMMUNITY %>" />
  91 + <input class="btn btn-default" type="submit" value="<fmt:message key="jsp.tools.curate.return.community.button"/>" />
  92 + </form>
  93 + </div>
  94 +
  95 +</dspace:layout>
... ...