Revision 47404
Added by Antonis Lempesis almost 7 years ago
ISLookUpImpl.java | ||
---|---|---|
10 | 10 |
import eu.dnetlib.api.enabling.ISLookUpService; |
11 | 11 |
import eu.dnetlib.api.enabling.ISLookUpServiceException; |
12 | 12 |
import eu.dnetlib.domain.DriverResource; |
13 |
import eu.dnetlib.domain.EPR; |
|
14 | 13 |
import eu.dnetlib.domain.SearchCriteria; |
15 | 14 |
import gr.uoa.di.driver.enabling.ISLookUp; |
16 | 15 |
import gr.uoa.di.driver.enabling.ISLookUpException; |
17 |
import gr.uoa.di.driver.enabling.resultset.ResultSet; |
|
18 | 16 |
import gr.uoa.di.driver.enabling.resultset.ResultSetFactory; |
19 | 17 |
import gr.uoa.di.driver.util.ServiceLocator; |
20 | 18 |
import gr.uoa.di.driver.xml.ResourceToXmlConverter; |
... | ... | |
24 | 22 |
|
25 | 23 |
private ServiceLocator<ISLookUpService> lookupLocator = null; |
26 | 24 |
private ResourceToXmlConverter<D> converter = null; |
27 |
private ResultSetFactory rsFactory = null; |
|
28 | 25 |
|
29 | 26 |
public D getById(String profileId) throws ISLookUpException { |
30 | 27 |
try { |
... | ... | |
55 | 52 |
String xQuery = converter.toXQueryString(criteria); |
56 | 53 |
logger.debug("xQuery: " + xQuery); |
57 | 54 |
|
58 |
EPR epr = lookupLocator.getService().searchProfile(xQuery); |
|
59 |
ResultSet<String> xmls = rsFactory.createResultSet(epr);
|
|
55 |
|
|
56 |
List<String> xmls = lookupLocator.getService().quickSearchProfile(xQuery);
|
|
60 | 57 |
List<D> res = new ArrayList<D>(); |
61 | 58 |
|
62 | 59 |
logger.debug("Getting results from result set. Result set size: " |
... | ... | |
65 | 62 |
logger.debug("starting parsing"); |
66 | 63 |
|
67 | 64 |
if (xmls.size() > 0) { |
68 |
for (String xml : xmls.get(1, xmls.size()))
|
|
65 |
for (String xml : xmls) |
|
69 | 66 |
res.add(this.parseXmlProfile(xml)); |
70 | 67 |
} |
71 |
|
|
72 | 68 |
logger.debug("parsed"); |
73 | 69 |
|
74 | 70 |
return res; |
... | ... | |
90 | 86 |
} |
91 | 87 |
|
92 | 88 |
public List<String> fetch(String XQuery) throws ISLookUpException { |
93 |
ResultSet<String> rs; |
|
89 |
|
|
94 | 90 |
try { |
95 |
rs = rsFactory.createResultSet(lookupLocator.getService().searchProfile( |
|
96 |
XQuery)); |
|
97 |
|
|
98 |
if (rs.size() > 0) |
|
99 |
return rs.get(1, rs.size()); |
|
100 |
else |
|
101 |
return new ArrayList<String>(); |
|
91 |
return lookupLocator.getService().quickSearchProfile(XQuery); |
|
102 | 92 |
} catch (ISLookUpServiceException e) { |
103 | 93 |
throw new ISLookUpException(e); |
104 | 94 |
} |
... | ... | |
134 | 124 |
throw new ISLookUpException("More than one results in query"); |
135 | 125 |
} |
136 | 126 |
|
137 |
@Override |
|
138 |
public EPR search(SearchCriteria criteria) throws ISLookUpException { |
|
139 |
try { |
|
140 |
return lookupLocator.getService().searchProfile( |
|
141 |
converter.toXQueryString(criteria)); |
|
142 |
} catch (ISLookUpServiceException e) { |
|
143 |
throw new ISLookUpException(e); |
|
144 |
} |
|
145 |
} |
|
146 |
|
|
147 |
@Override |
|
148 |
public EPR search(String XQuery) throws ISLookUpException { |
|
149 |
try { |
|
150 |
return lookupLocator.getService().searchProfile(XQuery); |
|
151 |
} catch (ISLookUpServiceException e) { |
|
152 |
throw new ISLookUpException(e); |
|
153 |
} |
|
154 |
} |
|
155 |
|
|
156 | 127 |
public void setLookupLocator(ServiceLocator<ISLookUpService> lookupLocator) { |
157 | 128 |
this.lookupLocator = lookupLocator; |
158 | 129 |
} |
... | ... | |
160 | 131 |
public void setConverter(ResourceToXmlConverter<D> converter) { |
161 | 132 |
this.converter = converter; |
162 | 133 |
} |
163 |
|
|
164 |
public void setRsFactory(ResultSetFactory rsFactory) { |
|
165 |
this.rsFactory = rsFactory; |
|
166 |
} |
|
167 | 134 |
} |
Also available in: Unified diff
moved to dnet45