New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XOAI Core Library (Version 2.2.9). Fixed incorrect virtual set count. Fi... #115

Merged
merged 1 commit into from Oct 31, 2012
Jump to file or symbol
Failed to load files and symbols.
+29 −33
Diff settings

Always

Just for now

XOAI Core Library (Version 2.2.9). Fixed incorrect virtual set count.…

… Fixed incorrect date issue [DS-1311]. Fixed incorrect count at last page (XSLT).
  • Loading branch information...
lyncodev committed Oct 27, 2012
commit d6cf7b540104fdacd946115576142ed14a1dc14a
View
@@ -66,7 +66,7 @@
<dependency>
<groupId>com.lyncode</groupId>
<artifactId>xoai</artifactId>
<version>2.2.8</version>
<version>2.2.9</version>
</dependency>
<dependency>
<groupId>org.dspace</groupId>
@@ -11,6 +11,7 @@
import java.io.IOException;
import java.net.ConnectException;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
@@ -48,6 +49,7 @@
import org.dspace.xoai.solr.DSpaceSolrServer;
import org.dspace.xoai.solr.exceptions.DSpaceSolrException;
import org.dspace.xoai.solr.exceptions.DSpaceSolrIndexerException;
import org.dspace.xoai.util.DateUtils;
import org.dspace.xoai.util.ItemUtils;
import org.dspace.xoai.util.XOAICacheManager;
import org.dspace.xoai.util.XOAIDatabaseManager;
@@ -224,7 +226,10 @@ private int index(TableRowIterator iterator)
catch (MetadataBindException e)
{
log.error(e.getMessage(), e);
}
} catch (ParseException e)
{
log.error(e.getMessage(), e);
}
i++;
if (i % 100 == 0) System.out.println(i+" items imported so far...");
}
@@ -245,16 +250,16 @@ private int index(TableRowIterator iterator)
throw new DSpaceSolrIndexerException(ex.getMessage(), ex);
}
}
private SolrInputDocument index(Item item) throws SQLException, MetadataBindException
private SolrInputDocument index(Item item) throws SQLException, MetadataBindException, ParseException
{
SolrInputDocument doc = new SolrInputDocument();
doc.addField("item.id", item.getID());
boolean pub = this.isPublic(item);
doc.addField("item.public", pub);
String handle = item.getHandle();
doc.addField("item.handle", handle);
doc.addField("item.lastmodified", item.getLastModified());
doc.addField("item.lastmodified", DateUtils.toSolrDate(item.getLastModified()));
doc.addField("item.submitter", item.getSubmitter().getEmail());
doc.addField("item.deleted", item.isWithdrawn() ? "true" : "false");
for (Collection col : item.getCollections())
@@ -42,16 +42,11 @@ public boolean isShown(DSpaceItem item)
return false;
}
private String dateToString(Date date)
{
return DateUtils.formatToSolr(date);
}
@Override
public SolrFilterResult getQuery()
{
return new SolrFilterResult("item.lastmodified:["
+ ClientUtils.escapeQueryChars(this.dateToString(_date))
+ ClientUtils.escapeQueryChars(DateUtils.formatToSolr(_date))
+ " TO *]");
}
@@ -7,12 +7,12 @@
*/
package org.dspace.xoai.filter;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.solr.client.solrj.util.ClientUtils;
import org.dspace.core.Context;
import org.dspace.xoai.data.DSpaceItem;
import org.dspace.xoai.util.DateUtils;
/**
*
@@ -42,18 +42,12 @@ public boolean isShown(DSpaceItem item)
return false;
}
private String dateToString(Date date)
{
SimpleDateFormat formatDate = new SimpleDateFormat(
"yyyy-MM-dd'T'HH:mm:ss'Z'");
return formatDate.format(date);
}
@Override
public SolrFilterResult getQuery()
{
System.out.println("HEYYYY!!!!");
return new SolrFilterResult("item.lastmodified:[* TO "
+ ClientUtils.escapeQueryChars(this.dateToString(_date)) + "]");
+ ClientUtils.escapeQueryChars(DateUtils.formatToSolr(_date, false)) + "]");
}
}
@@ -11,7 +11,6 @@
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
@@ -26,12 +25,16 @@
private static Logger log = LogManager.getLogger(DateUtils.class);
public static String formatToSolr(Date date)
{
return formatToSolr(date, true);
}
public static String formatToSolr(Date date, boolean init)
{
// 2008-01-01T00:00:00Z
SimpleDateFormat format = new SimpleDateFormat(
"yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.getDefault());
format.setTimeZone(TimeZone.getTimeZone("UTC"));
String ret = format.format(date);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.'000Z'");
if (!init) sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.'999Z'");
String ret = sdf.format(date);
System.out.println(ret);
return ret;
}
@@ -107,4 +110,10 @@ public static Date parseFromSolrDate(String date)
}
return new Date();
}
public static Date toSolrDate (Date date) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
Date indexFormatExpiryDate = sdf.parse(sdf.format(date));
return indexFormatExpiryDate;
}
}
@@ -56,13 +56,6 @@ private static Element create(ObjectFactory factory, String name)
return e;
}
private static Element.Field createValue(ObjectFactory factory, String value)
{
Element.Field e = factory.createElementField();
e.setValue(value);
return e;
}
private static Element.Field createValue(ObjectFactory factory,
String name, String value)
{
@@ -1267,7 +1267,7 @@
<xsl:choose>
<xsl:when test="$cursor">
<xsl:choose>
<xsl:when test="$path/../oai:resumptionToken/text() = ''">
<xsl:when test="normalize-space($path/../oai:resumptionToken/text()) = ''">
<!-- on the last page of results we have to assume that @completeListSize is available -->
<xsl:value-of
select="$total - $count" />
ProTip! Use n and p to navigate between commits in a pull request.