Project

General

Profile

« Previous | Next » 

Revision 63317

Added by Michele Artini 2 months ago

fixed a problem with dates

View differences:

modules/dnet-collector-plugins/trunk/src/main/java/eu/dnetlib/data/collector/plugins/gtr2/Gtr2Helper.java
1 1
package eu.dnetlib.data.collector.plugins.gtr2;
2 2

  
3
import org.apache.commons.lang.StringUtils;
3 4
import org.apache.commons.logging.Log;
4 5
import org.apache.commons.logging.LogFactory;
5 6
import org.dom4j.Document;
......
57 58
	}
58 59

  
59 60
	public static DateTime parseDate(final String s) {
60
		// I expect dates in the format 'yyyy-MM-dd'. See class
61
		// eu.dnetlib.msro.workflows.nodes.collect.FindDateRangeForIncrementalHarvestingJobNode
62
		return DateTime.parse(s.substring(0, s.indexOf("T")), simpleDateTimeFormatter);
61
		return DateTime.parse(s.contains("T") ? s.substring(0, s.indexOf("T")) : s, simpleDateTimeFormatter);
63 62
	}
64 63

  
65 64
	public static boolean isAfter(final String d, final DateTime fromDate) {
66
		return Gtr2Helper.parseDate(d).isAfter(fromDate);
65
		return StringUtils.isNotBlank(d) && Gtr2Helper.parseDate(d).isAfter(fromDate);
67 66
	}
68 67
}
modules/dnet-collector-plugins/trunk/src/test/java/eu/dnetlib/data/collector/plugins/gtr2/Gtr2ProjectsCollectorPluginTest.java
52 52
	public void testOnePage() throws Exception {
53 53
		final Iterator<String> iterator = plugin.createIterator(baseURL, null, "12", "12");
54 54
		final int count = iterateAndCount(iterator);
55
		assertEquals(21, count);
55
		assertEquals(20, count);
56 56
	}
57 57

  
58 58
	@Test
......
61 61
		System.out.println("incremental Harvesting");
62 62
		final Iterator<String> iterator = plugin.createIterator(baseURL, "2050-12-12", "11", "13");
63 63
		final int count = iterateAndCount(iterator);
64
		assertEquals(1, count);
64
		assertEquals(0, count);
65 65
	}
66 66

  
67 67
	@Test
......
70 70
		System.out.println("incremental Harvesting");
71 71
		final Iterator<String> iterator = plugin.createIterator(baseURL, "2016-11-30", "11", "11");
72 72
		final int count = iterateAndCount(iterator);
73
		assertEquals(21, count);
73
		assertEquals(20, count);
74 74
	}
75 75

  
76 76
	@Test
modules/dnet-collector-plugins/trunk/src/test/java/eu/dnetlib/data/collector/plugins/gtr2/Gtr2PublicationsCollectorPluginTest.java
52 52
	public void testOnePage() throws Exception {
53 53
		final Iterator<String> iterator = plugin.createIterator(baseURL, null, "12", "12");
54 54
		final int count = iterateAndCount(iterator);
55
		assertEquals(21, count);
55
		assertEquals(20, count);
56 56
	}
57 57

  
58 58
	@Test
......
61 61
		System.out.println("incremental Harvesting");
62 62
		final Iterator<String> iterator = plugin.createIterator(baseURL, "2050-12-12", "11", "13");
63 63
		final int count = iterateAndCount(iterator);
64
		assertEquals(1, count);
64
		assertEquals(0, count);
65 65
	}
66 66

  
67 67
	@Test
......
70 70
		System.out.println("incremental Harvesting");
71 71
		final Iterator<String> iterator = plugin.createIterator(baseURL, "2016-11-30", "11", "11");
72 72
		final int count = iterateAndCount(iterator);
73
		assertEquals(21, count);
73
		assertEquals(20, count);
74 74
	}
75 75

  
76 76
	@Test

Also available in: Unified diff