[DS-1144] Maven Project Consolidation : Statistics

This commit is contained in:
Mark Diggory
2012-10-03 02:55:52 -07:00
parent ef576f7012
commit 6e834495ae
46 changed files with 531 additions and 543 deletions

View File

@@ -347,6 +347,61 @@
<artifactId>jbibtex</artifactId> <artifactId>jbibtex</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
<version>${lucene.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>org.dspace.dependencies</groupId>
<artifactId>dspace-geoip</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
</dependency>
<dependency>
<groupId>org.dspace.dnsjava</groupId>
<artifactId>dnsjava</artifactId>
<version>2.0.6</version>
</dependency>
<dependency>
<groupId>org.ostermiller</groupId>
<artifactId>utils</artifactId>
<version>1.07.00</version>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>0.18.6</version>
</dependency>
<!-- Gson: Java to Json conversion -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.1</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@@ -221,7 +221,7 @@ public class ElasticSearchLogger {
"} } }"; "} } }";
client.prepareIndex(indexName, indexType, "1") client.prepareIndex(indexName, indexType, "1")
.setSource(jsonBuilder() .setSource(XContentFactory.jsonBuilder()
.startObject() .startObject()
.field("user", "kimchy") .field("user", "kimchy")
.field("postDate", new Date()) .field("postDate", new Date())

View File

@@ -1,47 +1,47 @@
/** /**
* The contents of this file are subject to the license and copyright * The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source * detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at * tree and available online at
* *
* http://www.dspace.org/license/ * http://www.dspace.org/license/
*/ */
package org.dspace.statistics.util; package org.dspace.statistics.util;
import org.dspace.core.ConfigurationManager; import org.dspace.core.ConfigurationManager;
import org.xbill.DNS.*; import org.xbill.DNS.*;
import java.io.IOException; import java.io.IOException;
/** /**
* XBill DNS resolver to retrieve hostnames for client IP addresses. * XBill DNS resolver to retrieve hostnames for client IP addresses.
* *
* @author kevinvandevelde at atmire.com * @author kevinvandevelde at atmire.com
* @author ben at atmire.com * @author ben at atmire.com
*/ */
public class DnsLookup { public class DnsLookup {
public static String reverseDns(String hostIp) throws IOException { public static String reverseDns(String hostIp) throws IOException {
Resolver res = new ExtendedResolver(); Resolver res = new ExtendedResolver();
// set the timeout, defaults to 200 milliseconds // set the timeout, defaults to 200 milliseconds
int timeout = ConfigurationManager.getIntProperty("usage-statistics", "resolver.timeout", 200); int timeout = ConfigurationManager.getIntProperty("usage-statistics", "resolver.timeout", 200);
res.setTimeout(0, timeout); res.setTimeout(0, timeout);
Name name = ReverseMap.fromAddress(hostIp); Name name = ReverseMap.fromAddress(hostIp);
int type = Type.PTR; int type = Type.PTR;
int dclass = DClass.IN; int dclass = DClass.IN;
Record rec = Record.newRecord(name, type, dclass); Record rec = Record.newRecord(name, type, dclass);
Message query = Message.newQuery(rec); Message query = Message.newQuery(rec);
Message response = res.send(query); Message response = res.send(query);
Record[] answers = response.getSectionArray(Section.ANSWER); Record[] answers = response.getSectionArray(Section.ANSWER);
if (answers.length == 0) if (answers.length == 0)
{ {
return hostIp; return hostIp;
} }
else else
{ {
return answers[0].rdataToString(); return answers[0].rdataToString();
} }
} }
} }

View File

@@ -1,427 +1,427 @@
/** /**
* The contents of this file are subject to the license and copyright * The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source * detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at * tree and available online at
* *
* http://www.dspace.org/license/ * http://www.dspace.org/license/
*/ */
package org.dspace.statistics.util; package org.dspace.statistics.util;
import org.apache.commons.cli.*; import org.apache.commons.cli.*;
import org.apache.commons.lang.time.DateFormatUtils; import org.apache.commons.lang.time.DateFormatUtils;
import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer; import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.core.Constants; import org.dspace.core.Constants;
import org.dspace.core.ConfigurationManager; import org.dspace.core.ConfigurationManager;
import org.dspace.content.DSpaceObject; import org.dspace.content.DSpaceObject;
import org.dspace.content.Bitstream; import org.dspace.content.Bitstream;
import org.dspace.content.DCValue; import org.dspace.content.DCValue;
import org.dspace.content.Item; import org.dspace.content.Item;
import org.dspace.eperson.EPerson; import org.dspace.eperson.EPerson;
import org.dspace.statistics.SolrLogger; import org.dspace.statistics.SolrLogger;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import com.maxmind.geoip.LookupService; import com.maxmind.geoip.LookupService;
import com.maxmind.geoip.Location; import com.maxmind.geoip.Location;
/** /**
* Test class to generate random statistics data. * Test class to generate random statistics data.
* Used for load testing of searches. Inputs are slow * Used for load testing of searches. Inputs are slow
* due to inefficient randomizer. * due to inefficient randomizer.
* *
* @author kevinvandevelde at atmire.com * @author kevinvandevelde at atmire.com
* @author ben at atmire.com * @author ben at atmire.com
*/ */
public class StatisticsDataGenerator { public class StatisticsDataGenerator {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
CommandLineParser parser = new PosixParser(); CommandLineParser parser = new PosixParser();
Options options = new Options(); Options options = new Options();
options.addOption("n", "nrlogs", true, options.addOption("n", "nrlogs", true,
"type: nr of logs to be generated"); "type: nr of logs to be generated");
options.addOption("s", "startDate", true, options.addOption("s", "startDate", true,
"type: the start date from which we start generating our logs"); "type: the start date from which we start generating our logs");
options.addOption("e", "endDate", true, options.addOption("e", "endDate", true,
"type: the end date from which we start generating our logs"); "type: the end date from which we start generating our logs");
options.addOption("a", "cms", true, "The starting id of our community"); options.addOption("a", "cms", true, "The starting id of our community");
options.addOption("b", "cme", true, "The end id of our community"); options.addOption("b", "cme", true, "The end id of our community");
options options
.addOption("c", "cls", true, .addOption("c", "cls", true,
"The starting id of our collection"); "The starting id of our collection");
options.addOption("d", "cle", true, "The end if of our collection"); options.addOption("d", "cle", true, "The end if of our collection");
options.addOption("f", "is", true, "The starting id of our item"); options.addOption("f", "is", true, "The starting id of our item");
options.addOption("g", "ie", true, "The end id of our item"); options.addOption("g", "ie", true, "The end id of our item");
options.addOption("h", "bs", true, "The starting id of our bitstream"); options.addOption("h", "bs", true, "The starting id of our bitstream");
options.addOption("i", "be", true, "The end id of our bitstream"); options.addOption("i", "be", true, "The end id of our bitstream");
options.addOption("j", "ps", true, "The starting id of our epersons"); options.addOption("j", "ps", true, "The starting id of our epersons");
options.addOption("k", "pe", true, "The end id of our epersons"); options.addOption("k", "pe", true, "The end id of our epersons");
CommandLine line = parser.parse(options, args); CommandLine line = parser.parse(options, args);
int nrLogs; int nrLogs;
long startDate; long startDate;
long endDate; long endDate;
long commStartId; long commStartId;
long commEndId; long commEndId;
long collStartId; long collStartId;
long collEndId; long collEndId;
long itemStartId; long itemStartId;
long itemEndId; long itemEndId;
long bitStartId; long bitStartId;
long bitEndId; long bitEndId;
long epersonStartId; long epersonStartId;
long epersonEndId; long epersonEndId;
if (line.hasOption("n")) if (line.hasOption("n"))
{ {
nrLogs = Integer.parseInt(line.getOptionValue("n")); nrLogs = Integer.parseInt(line.getOptionValue("n"));
} }
else { else {
System.out System.out
.println("We need to know how many logs we need to create"); .println("We need to know how many logs we need to create");
return; return;
} }
if (line.hasOption("s")) { if (line.hasOption("s")) {
startDate = getDateInMiliseconds(line.getOptionValue("s")); startDate = getDateInMiliseconds(line.getOptionValue("s"));
} else } else
{ {
startDate = getDateInMiliseconds("01/01/2006"); startDate = getDateInMiliseconds("01/01/2006");
} }
if (line.hasOption("e")) { if (line.hasOption("e")) {
endDate = getDateInMiliseconds(line.getOptionValue("e")); endDate = getDateInMiliseconds(line.getOptionValue("e"));
} else } else
{ {
endDate = new Date().getTime(); endDate = new Date().getTime();
} }
if (line.hasOption("a")) if (line.hasOption("a"))
{ {
commStartId = Long.parseLong(line.getOptionValue("a")); commStartId = Long.parseLong(line.getOptionValue("a"));
} }
else else
{ {
return; return;
} }
if (line.hasOption("b")) if (line.hasOption("b"))
{ {
commEndId = Long.parseLong(line.getOptionValue("b")); commEndId = Long.parseLong(line.getOptionValue("b"));
} }
else else
{ {
return; return;
} }
if (line.hasOption("c")) if (line.hasOption("c"))
{ {
collStartId = Long.parseLong(line.getOptionValue("c")); collStartId = Long.parseLong(line.getOptionValue("c"));
} }
else else
{ {
return; return;
} }
if (line.hasOption("d")) if (line.hasOption("d"))
{ {
collEndId = Long.parseLong(line.getOptionValue("d")); collEndId = Long.parseLong(line.getOptionValue("d"));
} }
else else
{ {
return; return;
} }
if (line.hasOption("f")) if (line.hasOption("f"))
{ {
itemStartId = Long.parseLong(line.getOptionValue("f")); itemStartId = Long.parseLong(line.getOptionValue("f"));
} }
else else
{ {
return; return;
} }
if (line.hasOption("g")) if (line.hasOption("g"))
{ {
itemEndId = Long.parseLong(line.getOptionValue("g")); itemEndId = Long.parseLong(line.getOptionValue("g"));
} }
else else
{ {
return; return;
} }
if (line.hasOption("h")) if (line.hasOption("h"))
{ {
bitStartId = Long.parseLong(line.getOptionValue("h")); bitStartId = Long.parseLong(line.getOptionValue("h"));
} }
else else
{ {
return; return;
} }
if (line.hasOption("i")) if (line.hasOption("i"))
{ {
bitEndId = Long.parseLong(line.getOptionValue("i")); bitEndId = Long.parseLong(line.getOptionValue("i"));
} }
else else
{ {
return; return;
} }
if (line.hasOption("j")) if (line.hasOption("j"))
{ {
epersonStartId = Long.parseLong(line.getOptionValue("j")); epersonStartId = Long.parseLong(line.getOptionValue("j"));
} }
else else
{ {
return; return;
} }
if (line.hasOption("k")) if (line.hasOption("k"))
{ {
epersonEndId = Long.parseLong(line.getOptionValue("k")); epersonEndId = Long.parseLong(line.getOptionValue("k"));
} }
else else
{ {
return; return;
} }
// Get the max id range // Get the max id range
long maxIdTotal = Math.max(commEndId, collEndId); long maxIdTotal = Math.max(commEndId, collEndId);
maxIdTotal = Math.max(maxIdTotal, itemEndId); maxIdTotal = Math.max(maxIdTotal, itemEndId);
maxIdTotal = Math.max(maxIdTotal, bitEndId); maxIdTotal = Math.max(maxIdTotal, bitEndId);
// We got 3/4 chance the person visting the dso is not logged in // We got 3/4 chance the person visting the dso is not logged in
epersonEndId *= 4; epersonEndId *= 4;
// We got all our parameters now get the rest // We got all our parameters now get the rest
Context context = new Context(); Context context = new Context();
// Find our solr server // Find our solr server
CommonsHttpSolrServer solr = new CommonsHttpSolrServer( CommonsHttpSolrServer solr = new CommonsHttpSolrServer(
ConfigurationManager.getProperty("solr-statistics", "server")); ConfigurationManager.getProperty("solr-statistics", "server"));
solr.deleteByQuery("*:*"); solr.deleteByQuery("*:*");
solr.commit(); solr.commit();
Map<String, String> metadataStorageInfo = SolrLogger.getMetadataStorageInfo(); Map<String, String> metadataStorageInfo = SolrLogger.getMetadataStorageInfo();
String prevIp = null; String prevIp = null;
String dbfile = ConfigurationManager.getProperty("usage-statistics", "dbfile"); String dbfile = ConfigurationManager.getProperty("usage-statistics", "dbfile");
LookupService cl = new LookupService(dbfile, LookupService cl = new LookupService(dbfile,
LookupService.GEOIP_STANDARD); LookupService.GEOIP_STANDARD);
int countryErrors = 0; int countryErrors = 0;
for (int i = 0; i < nrLogs; i++) { for (int i = 0; i < nrLogs; i++) {
String ip = ""; String ip = "";
Date time; Date time;
String continent; String continent;
String countryCode; String countryCode;
float longitude; float longitude;
float latitude; float latitude;
String city; String city;
// 1. Generate an ip for our user // 1. Generate an ip for our user
StringBuilder ipBuilder = new StringBuilder(); StringBuilder ipBuilder = new StringBuilder();
for (int j = 0; j < 4; j++) { for (int j = 0; j < 4; j++) {
ipBuilder.append(getRandomNumberInRange(0, 254)); ipBuilder.append(getRandomNumberInRange(0, 254));
if (j != 3) if (j != 3)
{ {
ipBuilder.append("."); ipBuilder.append(".");
} }
} }
ip = ipBuilder.toString(); ip = ipBuilder.toString();
// 2 Depending on our ip get all the location info // 2 Depending on our ip get all the location info
Location location; Location location;
try { try {
location = cl.getLocation(ip); location = cl.getLocation(ip);
} catch (Exception e) { } catch (Exception e) {
location = null; location = null;
} }
if (location == null) { if (location == null) {
// If we haven't got a prev ip this is pretty useless so move on // If we haven't got a prev ip this is pretty useless so move on
// to the next one // to the next one
if (prevIp == null) if (prevIp == null)
{ {
continue; continue;
} }
ip = prevIp; ip = prevIp;
location = cl.getLocation(ip); location = cl.getLocation(ip);
} }
city = location.city; city = location.city;
countryCode = location.countryCode; countryCode = location.countryCode;
longitude = location.longitude; longitude = location.longitude;
latitude = location.latitude; latitude = location.latitude;
try { try {
continent = LocationUtils.getContinentCode(countryCode); continent = LocationUtils.getContinentCode(countryCode);
} catch (Exception e) { } catch (Exception e) {
// We could get an error if our country == Europa this doesn't // We could get an error if our country == Europa this doesn't
// matter for generating statistics so ignore it // matter for generating statistics so ignore it
System.out.println("COUNTRY ERROR: " + countryCode); System.out.println("COUNTRY ERROR: " + countryCode);
countryErrors++; countryErrors++;
continue; continue;
} }
// 3. Generate a date that the object was visited // 3. Generate a date that the object was visited
time = new Date(getRandomNumberInRange(startDate, endDate)); time = new Date(getRandomNumberInRange(startDate, endDate));
// 4. Get our dspaceobject we are supposed to be working on // 4. Get our dspaceobject we are supposed to be working on
// We got mostly item views so lets say we got 1/2 chance that we // We got mostly item views so lets say we got 1/2 chance that we
// got an item view // got an item view
// What type have we got (PS: I know we haven't got 5 as a dso type // What type have we got (PS: I know we haven't got 5 as a dso type
// we can log but it is used so our item gets move traffic) // we can log but it is used so our item gets move traffic)
int type = (int) getRandomNumberInRange(0, 8); int type = (int) getRandomNumberInRange(0, 8);
if (type == Constants.BUNDLE || type >= 5) if (type == Constants.BUNDLE || type >= 5)
{ {
type = Constants.ITEM; type = Constants.ITEM;
} }
int dsoId = -1; int dsoId = -1;
// Now we need to find a valid id // Now we need to find a valid id
switch (type) { switch (type) {
case Constants.COMMUNITY: case Constants.COMMUNITY:
dsoId = (int) getRandomNumberInRange(commStartId, commEndId); dsoId = (int) getRandomNumberInRange(commStartId, commEndId);
break; break;
case Constants.COLLECTION: case Constants.COLLECTION:
dsoId = (int) getRandomNumberInRange(collStartId, collEndId); dsoId = (int) getRandomNumberInRange(collStartId, collEndId);
break; break;
case Constants.ITEM: case Constants.ITEM:
dsoId = (int) getRandomNumberInRange(itemStartId, itemEndId); dsoId = (int) getRandomNumberInRange(itemStartId, itemEndId);
break; break;
case Constants.BITSTREAM: case Constants.BITSTREAM:
dsoId = (int) getRandomNumberInRange(bitStartId, bitEndId); dsoId = (int) getRandomNumberInRange(bitStartId, bitEndId);
break; break;
} }
// Now find our dso // Now find our dso
DSpaceObject dso = DSpaceObject.find(context, type, dsoId); DSpaceObject dso = DSpaceObject.find(context, type, dsoId);
if (dso instanceof Bitstream) { if (dso instanceof Bitstream) {
Bitstream bit = (Bitstream) dso; Bitstream bit = (Bitstream) dso;
if (bit.getFormat().isInternal()) { if (bit.getFormat().isInternal()) {
dso = null; dso = null;
} }
} }
// Make sure we got a dso // Make sure we got a dso
boolean substract = false; boolean substract = false;
while (dso == null) { while (dso == null) {
// If our dsoId gets higher then our maxIdtotal we need to lower // If our dsoId gets higher then our maxIdtotal we need to lower
// to find a valid id // to find a valid id
if (dsoId == maxIdTotal) if (dsoId == maxIdTotal)
{ {
substract = true; substract = true;
} }
if (substract) if (substract)
{ {
dsoId--; dsoId--;
} }
else else
{ {
dsoId++; dsoId++;
} }
dso = DSpaceObject.find(context, type, dsoId); dso = DSpaceObject.find(context, type, dsoId);
if (dso instanceof Bitstream) { if (dso instanceof Bitstream) {
Bitstream bit = (Bitstream) dso; Bitstream bit = (Bitstream) dso;
if (bit.getFormat().isInternal()) { if (bit.getFormat().isInternal()) {
dso = null; dso = null;
} }
} }
// System.out.println("REFIND"); // System.out.println("REFIND");
} }
// Find the person who is visting us // Find the person who is visting us
int epersonId = (int) getRandomNumberInRange(epersonStartId, epersonEndId); int epersonId = (int) getRandomNumberInRange(epersonStartId, epersonEndId);
EPerson eperson = EPerson.find(context, epersonId); EPerson eperson = EPerson.find(context, epersonId);
if (eperson == null) if (eperson == null)
{ {
epersonId = -1; epersonId = -1;
} }
// System.out.println(ip); // System.out.println(ip);
// System.out.println(country + " " + // System.out.println(country + " " +
// LocationUtils.getCountryName(countryCode)); // LocationUtils.getCountryName(countryCode));
// Resolve the dns // Resolve the dns
String dns = null; String dns = null;
try { try {
dns = DnsLookup.reverseDns(ip); dns = DnsLookup.reverseDns(ip);
} catch (Exception e) { } catch (Exception e) {
} }
System.out.println(ip); System.out.println(ip);
System.out.println(dns); System.out.println(dns);
// Save it in our server // Save it in our server
SolrInputDocument doc1 = new SolrInputDocument(); SolrInputDocument doc1 = new SolrInputDocument();
doc1.addField("ip", ip); doc1.addField("ip", ip);
doc1.addField("type", dso.getType()); doc1.addField("type", dso.getType());
doc1.addField("id", dso.getID()); doc1.addField("id", dso.getID());
doc1.addField("time", DateFormatUtils.format(time, doc1.addField("time", DateFormatUtils.format(time,
SolrLogger.DATE_FORMAT_8601)); SolrLogger.DATE_FORMAT_8601));
doc1.addField("continent", continent); doc1.addField("continent", continent);
// doc1.addField("country", country); // doc1.addField("country", country);
doc1.addField("countryCode", countryCode); doc1.addField("countryCode", countryCode);
doc1.addField("city", city); doc1.addField("city", city);
doc1.addField("latitude", latitude); doc1.addField("latitude", latitude);
doc1.addField("longitude", longitude); doc1.addField("longitude", longitude);
if (epersonId > 0) if (epersonId > 0)
{ {
doc1.addField("epersonid", epersonId); doc1.addField("epersonid", epersonId);
} }
if (dns != null) if (dns != null)
{ {
doc1.addField("dns", dns.toLowerCase()); doc1.addField("dns", dns.toLowerCase());
} }
if (dso instanceof Item) { if (dso instanceof Item) {
Item item = (Item) dso; Item item = (Item) dso;
// Store the metadata // Store the metadata
for (Map.Entry<String, String> entry : metadataStorageInfo.entrySet()) for (Map.Entry<String, String> entry : metadataStorageInfo.entrySet())
{ {
String dcField = entry.getValue(); String dcField = entry.getValue();
DCValue[] vals = item.getMetadata(dcField.split("\\.")[0], DCValue[] vals = item.getMetadata(dcField.split("\\.")[0],
dcField.split("\\.")[1], dcField.split("\\.")[2], dcField.split("\\.")[1], dcField.split("\\.")[2],
Item.ANY); Item.ANY);
for (DCValue val1 : vals) { for (DCValue val1 : vals) {
String val = val1.value; String val = val1.value;
doc1.addField(entry.getKey(), val); doc1.addField(entry.getKey(), val);
doc1.addField(entry.getKey() + "_search", val.toLowerCase()); doc1.addField(entry.getKey() + "_search", val.toLowerCase());
} }
} }
} }
SolrLogger.storeParents(doc1, dso); SolrLogger.storeParents(doc1, dso);
solr.add(doc1); solr.add(doc1);
// Make sure we have a previous ip // Make sure we have a previous ip
prevIp = ip; prevIp = ip;
} }
System.out.println("Nr of countryErrors: " + countryErrors); System.out.println("Nr of countryErrors: " + countryErrors);
// Commit at the end cause it takes a while // Commit at the end cause it takes a while
solr.commit(); solr.commit();
} }
/** /**
* Method returns a random integer between the given int * Method returns a random integer between the given int
* *
* @param min * @param min
* the random number must be greater or equal to this * the random number must be greater or equal to this
* @param max * @param max
* the random number must be smaller or equal to this * the random number must be smaller or equal to this
* @return a random in * @return a random in
*/ */
private static long getRandomNumberInRange(long min, long max) { private static long getRandomNumberInRange(long min, long max) {
return min + (long) (Math.random() * ((max - min) + 1)); return min + (long) (Math.random() * ((max - min) + 1));
} }
/** /**
* Method to get the miliseconds from a datestring * Method to get the miliseconds from a datestring
* *
* @param dateString * @param dateString
* the string containing our date in a string * the string containing our date in a string
* @return the nr of miliseconds in the given datestring * @return the nr of miliseconds in the given datestring
* @throws java.text.ParseException * @throws java.text.ParseException
* should not happen * should not happen
*/ */
private static long getDateInMiliseconds(String dateString) private static long getDateInMiliseconds(String dateString)
throws java.text.ParseException { throws java.text.ParseException {
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
return formatter.parse(dateString).getTime(); return formatter.parse(dateString).getTime();
} }
} }

View File

@@ -239,7 +239,7 @@ public class StatisticsImporterElasticSearch {
//TODO Is there any way to reuse ElasticSearchLogger.post() ? //TODO Is there any way to reuse ElasticSearchLogger.post() ?
// Save it in our server // Save it in our server
XContentBuilder postBuilder = jsonBuilder().startObject() XContentBuilder postBuilder = XContentFactory.jsonBuilder().startObject()
.field("id", dso.getID()) .field("id", dso.getID())
.field("typeIndex", dso.getType()) .field("typeIndex", dso.getType())
.field("type", dso.getTypeText()) .field("type", dso.getTypeText())

View File

@@ -38,10 +38,6 @@
<groupId>org.dspace</groupId> <groupId>org.dspace</groupId>
<artifactId>dspace-services-utils</artifactId> <artifactId>dspace-services-utils</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.dspace</groupId>
<artifactId>dspace-stats</artifactId>
</dependency>
<dependency> <dependency>
<groupId>commons-validator</groupId> <groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId> <artifactId>commons-validator</artifactId>

View File

@@ -1,27 +0,0 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
/**
* Build queries to the statistical subsystem and create UI elements from the
* results. The underlying SOLR engine uses a text-based query language. The
* classes here map a structure of constraint objects into that language.
* <p>
* {@link org.dspace.statistics.content.StatisticsDataVisits} is somewhat like a
* factory for statistical queries. An instance is customized with
* DatasetGenerator instances to specify interesting facets of the data and with
* filters to specify TBS. The "factory methods" then produce arrays of values
* meeting the factory's criteria, either raw or formatted for presentation.
* <p>
* DatasetGenerator subclasses are available for constraining the results to a
* given DSpaceObject, object type, and time interval.
* <p>
* A StatisticsDataVisits object can be wrapped in a
* {@link org.dspace.statistics.content.StatisticsDisplay}
* subclass to format its content as a list or a table.
*/
package org.dspace.statistics.content;

View File

@@ -43,10 +43,6 @@
<groupId>org.dspace</groupId> <groupId>org.dspace</groupId>
<artifactId>dspace-services-utils</artifactId> <artifactId>dspace-services-utils</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.dspace</groupId>
<artifactId>dspace-stats</artifactId>
</dependency>
<dependency> <dependency>
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId> <artifactId>servlet-api</artifactId>

View File

@@ -11,7 +11,6 @@ import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.environment.ObjectModelHelper; import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request; import org.apache.cocoon.environment.Request;
import org.dspace.app.xmlui.utils.HandleUtil; import org.dspace.app.xmlui.utils.HandleUtil;
import org.dspace.app.xmlui.utils.UIException;
import org.dspace.app.xmlui.wing.Message; import org.dspace.app.xmlui.wing.Message;
import org.dspace.app.xmlui.wing.WingException; import org.dspace.app.xmlui.wing.WingException;
import org.dspace.app.xmlui.wing.element.Body; import org.dspace.app.xmlui.wing.element.Body;

View File

@@ -7,7 +7,6 @@
*/ */
package org.dspace.app.xmlui.aspect.statistics; package org.dspace.app.xmlui.aspect.statistics;
import com.google.gson.Gson;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.SolrServerException;
import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer; import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
@@ -21,20 +20,13 @@ import org.dspace.content.DSpaceObject;
import org.dspace.core.Constants; import org.dspace.core.Constants;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.statistics.Dataset; import org.dspace.statistics.Dataset;
import org.dspace.statistics.ObjectCount;
import org.dspace.statistics.content.*;
import org.dspace.storage.rdbms.DatabaseManager;
import org.dspace.storage.rdbms.TableRow;
import org.dspace.storage.rdbms.TableRowIterator;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import java.io.IOException; import java.io.IOException;
import java.sql.SQLException; import java.sql.SQLException;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.Locale;
public class StatisticsTransformer extends AbstractDSpaceTransformer { public class StatisticsTransformer extends AbstractDSpaceTransformer {

View File

@@ -10,7 +10,6 @@ package org.dspace.app.xmlui.aspect.statisticsElasticSearch;
import org.apache.cocoon.environment.ObjectModelHelper; import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request; import org.apache.cocoon.environment.Request;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.dspace.app.xmlui.aspect.statistics.StatisticsTransformer;
import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer; import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
import org.dspace.app.xmlui.utils.HandleUtil; import org.dspace.app.xmlui.utils.HandleUtil;
import org.dspace.app.xmlui.wing.Message; import org.dspace.app.xmlui.wing.Message;

View File

@@ -79,10 +79,6 @@
<groupId>org.dspace</groupId> <groupId>org.dspace</groupId>
<artifactId>dspace-services-utils</artifactId> <artifactId>dspace-services-utils</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.dspace</groupId>
<artifactId>dspace-stats</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.dspace</groupId> <groupId>org.dspace</groupId>
<artifactId>dspace-discovery-provider</artifactId> <artifactId>dspace-discovery-provider</artifactId>

18
pom.xml
View File

@@ -223,19 +223,6 @@
</modules> </modules>
</profile> </profile>
<!--
Builds DSpace Solr Stats for DSpace
-->
<profile>
<id>dspace-stats</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<modules>
<module>dspace-stats</module>
</modules>
</profile>
<!-- <!--
Builds DSpace discovery for DSpace Builds DSpace discovery for DSpace
--> -->
@@ -547,11 +534,6 @@
<artifactId>dspace-services-utils</artifactId> <artifactId>dspace-services-utils</artifactId>
<version>3.0-SNAPSHOT</version> <version>3.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>org.dspace</groupId>
<artifactId>dspace-stats</artifactId>
<version>3.0-SNAPSHOT</version>
</dependency>
<!-- DSpace Localization Packages --> <!-- DSpace Localization Packages -->
<dependency> <dependency>
<groupId>org.dspace</groupId> <groupId>org.dspace</groupId>