Revision 50070
Added by Jochen Schirrwagen over 6 years ago
modules/dnet-collector-plugins/trunk/src/test/java/eu/dnetlib/data/collector/plugins/rest/RestIteratorTest.java | ||
---|---|---|
3 | 3 |
*/ |
4 | 4 |
package eu.dnetlib.data.collector.plugins.rest; |
5 | 5 |
|
6 |
import java.io.FileWriter; |
|
7 |
|
|
6 |
import org.junit.Ignore; |
|
8 | 7 |
import org.junit.Test; |
9 | 8 |
|
10 | 9 |
/** |
... | ... | |
21 | 20 |
private String resultFormatParam = "format"; |
22 | 21 |
private String resultFormatValue = "json"; |
23 | 22 |
private String resultSizeParam = "size"; |
24 |
private int resultSizeValue = 100; |
|
25 | 23 |
private String query = "q=%28sources%3ASocArXiv+AND+type%3Apreprint%29"; |
26 | 24 |
|
27 | 25 |
|
26 |
@Ignore |
|
28 | 27 |
@Test |
29 | 28 |
public void test(){ |
30 |
final RestIterator iterator = new RestIterator(baseUrl, resumptionType, resumptionParam, resumptionXpath, resultTotalXpath, resultFormatParam, resultFormatValue, resultSizeParam, resultSizeValue, query);
|
|
29 |
final RestIterator iterator = new RestIterator(baseUrl, resumptionType, resumptionParam, resumptionXpath, resultTotalXpath, resultFormatParam, resultFormatValue, resultSizeParam, query); |
|
31 | 30 |
int i =20; |
32 | 31 |
while (iterator.hasNext() && i > 0) { |
33 | 32 |
String result = iterator.next(); |
34 |
// try { |
|
35 |
// FileWriter writer = new FileWriter("/tmp/" + i + ".xml"); |
|
36 |
// writer.write(result); |
|
37 |
// writer.close(); |
|
38 |
// }catch(Exception e) { |
|
39 |
// e.printStackTrace(); |
|
40 |
// } |
|
41 | 33 |
|
42 | 34 |
i--; |
43 | 35 |
} |
modules/dnet-collector-plugins/trunk/src/main/java/eu/dnetlib/data/collector/plugins/rest/RestIteratorFactory.java | ||
---|---|---|
20 | 20 |
final String resultFormatParam, |
21 | 21 |
final String resultFormatValue, |
22 | 22 |
final String resultSizeParam, |
23 |
final int resultSizeValue, |
|
24 | 23 |
final String query |
25 | 24 |
){ |
26 |
return new RestIterator(baseUrl, resumptionType, resumptionParam, resumptionXpath, resultTotalXpath, resultFormatParam, resultFormatValue, resultSizeParam, resultSizeValue, query);
|
|
25 |
return new RestIterator(baseUrl, resumptionType, resumptionParam, resumptionXpath, resultTotalXpath, resultFormatParam, resultFormatValue, resultSizeParam, query); |
|
27 | 26 |
} |
28 | 27 |
} |
modules/dnet-collector-plugins/trunk/src/main/java/eu/dnetlib/data/collector/plugins/rest/RestIterator.java | ||
---|---|---|
60 | 60 |
final String resultFormatParam, |
61 | 61 |
final String resultFormatValue, |
62 | 62 |
final String resultSizeParam, |
63 |
final int resultSizeValue, |
|
64 | 63 |
final String queryParams |
65 | 64 |
) { |
66 | 65 |
this.baseUrl = baseUrl; |
67 | 66 |
this.resumptionType = resumptionType; |
68 | 67 |
this.resumptionParam = resumptionParam; |
69 | 68 |
this.resultFormatValue = resultFormatValue; |
70 |
this.resultSizeValue = resultSizeValue; |
|
71 | 69 |
this.queryParams = queryParams; |
72 | 70 |
|
73 | 71 |
queryFormat = (resultFormatParam!="")? "&" + resultFormatParam + "=" + resultFormatValue : ""; |
modules/dnet-collector-plugins/trunk/src/main/resources/eu/dnetlib/data/collector/plugins/applicationContext-dnet-modular-collector-plugins.xml | ||
---|---|---|
63 | 63 |
</property> |
64 | 64 |
</bean> |
65 | 65 |
</property> |
66 |
</bean> |
|
66 | 67 |
|
67 |
|
|
68 |
<bean id="restCollectorPlugin" class="eu.dnetlib.data.collector.plugins.rest.RestCollectorPlugin"> |
|
69 |
<property name="protocolDescriptor"> |
|
70 |
<bean class="eu.dnetlib.data.collector.rmi.ProtocolDescriptor" p:name="rest_json2xml"> |
|
71 |
<property name="params"> |
|
72 |
<list> |
|
73 |
<bean class="eu.dnetlib.data.collector.rmi.ProtocolParameter" |
|
74 |
p:name="resumptionType" /> |
|
75 |
<bean class="eu.dnetlib.data.collector.rmi.ProtocolParameter" |
|
76 |
p:name="resumptionParam" /> |
|
77 |
<bean class="eu.dnetlib.data.collector.rmi.ProtocolParameter" |
|
78 |
p:name="resumptionXpath" /> |
|
79 |
<bean class="eu.dnetlib.data.collector.rmi.ProtocolParameter" |
|
80 |
p:name="resultTotalXpath" /> |
|
81 |
<bean class="eu.dnetlib.data.collector.rmi.ProtocolParameter" |
|
82 |
p:name="resultFormatParam" /> |
|
83 |
<bean class="eu.dnetlib.data.collector.rmi.ProtocolParameter" |
|
84 |
p:name="resultFormatValue" /> |
|
85 |
<bean class="eu.dnetlib.data.collector.rmi.ProtocolParameter" |
|
86 |
p:name="resultSizeParam" /> |
|
87 |
<bean class="eu.dnetlib.data.collector.rmi.ProtocolParameter" |
|
88 |
p:name="queryParams" /> |
|
89 |
</list> |
|
90 |
</property> |
|
91 |
</bean> |
|
92 |
</property> |
|
68 | 93 |
</bean> |
69 | 94 |
|
70 |
|
|
71 | 95 |
</beans> |
Also available in: Unified diff
declaring bean for RestCollectorPlugin