Revision 53375
Added by Claudio Atzori over 5 years ago
modules/dnet-openaireplus-mapping-utils/branches/solr7/src/test/java/eu/dnetlib/pace/distance/DetectorTest.java | ||
---|---|---|
1 |
package eu.dnetlib.pace.distance; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import com.google.common.collect.Lists; |
|
6 |
import eu.dnetlib.pace.AbstractProtoPaceTest; |
|
7 |
import eu.dnetlib.pace.config.Config; |
|
8 |
import eu.dnetlib.pace.distance.eval.ScoreResult; |
|
9 |
import eu.dnetlib.pace.model.MapDocument; |
|
10 |
import org.junit.Test; |
|
11 |
|
|
12 |
import static org.junit.Assert.assertTrue; |
|
13 |
|
|
14 |
public class DetectorTest extends AbstractProtoPaceTest { |
|
15 |
|
|
16 |
@Test |
|
17 |
public void testDistanceResultSimple() { |
|
18 |
final Config config = getResultSimpleConf(); |
|
19 |
|
|
20 |
final MapDocument resA = result(config, "A", "Recent results from CDF"); |
|
21 |
final MapDocument resB = result(config, "B", "Recent results from CDF"); |
|
22 |
|
|
23 |
final ScoreResult sr = new PaceDocumentDistance().between(resA, resB, config); |
|
24 |
final double d = sr.getScore(); |
|
25 |
System.out.println(String.format(" d ---> %s", d)); |
|
26 |
|
|
27 |
assertTrue(d == 1.0); |
|
28 |
} |
|
29 |
|
|
30 |
@Test |
|
31 |
public void testDistanceResultSimpleMissingDates() { |
|
32 |
final Config config = getResultSimpleConf(); |
|
33 |
|
|
34 |
final MapDocument resA = result(config, "A", "Recent results from BES"); |
|
35 |
final MapDocument resB = result(config, "A", "Recent results from CES"); |
|
36 |
|
|
37 |
final ScoreResult sr = new PaceDocumentDistance().between(resA, resB, config); |
|
38 |
final double d = sr.getScore(); |
|
39 |
System.out.println(String.format(" d ---> %s", d)); |
|
40 |
|
|
41 |
assertTrue(d > 0.97); |
|
42 |
} |
|
43 |
|
|
44 |
@Test |
|
45 |
public void testDistanceResultInvalidDate() { |
|
46 |
final Config config = getResultConf(); |
|
47 |
|
|
48 |
final MapDocument resA = result(config, "A", "title title title 6BESR", "2013-01-05"); |
|
49 |
final MapDocument resB = result(config, "B", "title title title 6BESR", "qwerty"); |
|
50 |
|
|
51 |
final ScoreResult sr = new PaceDocumentDistance().between(resA, resB, config); |
|
52 |
final double d = sr.getScore(); |
|
53 |
System.out.println(String.format(" d ---> %s", d)); |
|
54 |
|
|
55 |
assertTrue(d == 1.0); |
|
56 |
} |
|
57 |
|
|
58 |
@Test |
|
59 |
public void testDistanceResultMissingOneDate() { |
|
60 |
final Config config = getResultConf(); |
|
61 |
|
|
62 |
final MapDocument resA = result(config, "A", "title title title 6BESR", null); |
|
63 |
final MapDocument resB = result(config, "B", "title title title 6CLER", "2012-02"); |
|
64 |
|
|
65 |
final ScoreResult sr = new PaceDocumentDistance().between(resA, resB, config); |
|
66 |
double d = sr.getScore(); |
|
67 |
System.out.println(String.format(" d ---> %s", d)); |
|
68 |
|
|
69 |
assertTrue((d > 0.9) && (d < 1.0)); |
|
70 |
} |
|
71 |
|
|
72 |
@Test |
|
73 |
public void testDistanceResult() { |
|
74 |
final Config config = getResultConf(); |
|
75 |
|
|
76 |
final MapDocument resA = result(config, "A", "title title title BES", ""); |
|
77 |
final MapDocument resB = result(config, "B", "title title title CLEO"); |
|
78 |
|
|
79 |
final ScoreResult sr = new PaceDocumentDistance().between(resA, resB, config); |
|
80 |
double d = sr.getScore(); |
|
81 |
System.out.println(String.format(" d ---> %s", d)); |
|
82 |
|
|
83 |
assertTrue((d > 0.9) && (d < 1.0)); |
|
84 |
} |
|
85 |
|
|
86 |
@Test |
|
87 |
public void testDistanceResultMissingTwoDate() { |
|
88 |
final Config config = getResultConf(); |
|
89 |
|
|
90 |
final MapDocument resA = result(config, "A", "title title title 6BESR"); |
|
91 |
final MapDocument resB = result(config, "B", "title title title 6CLER"); |
|
92 |
|
|
93 |
final ScoreResult sr = new PaceDocumentDistance().between(resA, resB, config); |
|
94 |
double d = sr.getScore(); |
|
95 |
System.out.println(String.format(" d ---> %s", d)); |
|
96 |
|
|
97 |
assertTrue((d > 0.9) && (d < 1.0)); |
|
98 |
} |
|
99 |
|
|
100 |
@Test |
|
101 |
public void testDistanceOrganizationIgnoreMissing() { |
|
102 |
|
|
103 |
final Config config = getOrganizationSimpleConf(); |
|
104 |
|
|
105 |
final MapDocument orgA = organization(config, "A", "CONSIGLIO NAZIONALE DELLE RICERCHE"); |
|
106 |
final MapDocument orgB = organization(config, "B", "CONSIGLIO NAZIONALE DELLE RICERCHE", "CNR"); |
|
107 |
|
|
108 |
final ScoreResult sr = new PaceDocumentDistance().between(orgA, orgB, config); |
|
109 |
final double d = sr.getScore(); |
|
110 |
System.out.println(String.format(" d ---> %s", d)); |
|
111 |
|
|
112 |
assertTrue(d == 1.0); |
|
113 |
} |
|
114 |
|
|
115 |
@Test |
|
116 |
public void testDistanceResultCase1() { |
|
117 |
|
|
118 |
final Config config = getResultConf(); |
|
119 |
|
|
120 |
final MapDocument resA = result(config, "A", "Search the Standard Model Higgs boson", "2003"); |
|
121 |
final MapDocument resB = result(config, "B", "Search for the Standard Model Higgs Boson", "2003"); |
|
122 |
|
|
123 |
final ScoreResult sr = new PaceDocumentDistance().between(resA, resB, config); |
|
124 |
double d = sr.getScore(); |
|
125 |
System.out.println(String.format(" d ---> %s", d)); |
|
126 |
|
|
127 |
assertTrue((d > 0.9) && (d < 1.0)); |
|
128 |
} |
|
129 |
|
|
130 |
@Test |
|
131 |
public void testDistanceResultCaseDoiMatch1() { |
|
132 |
final Config config = getResultConf(); |
|
133 |
|
|
134 |
final MapDocument resA = result(config, "A", "Search the Standard Model Higgs boson", "2003", "10.1594/PANGAEA.726855"); |
|
135 |
final MapDocument resB = result(config, "B", "Search the Standard Model Higgs Boson", "2003", "10.1594/PANGAEA.726855"); |
|
136 |
|
|
137 |
final ScoreResult sr = new PaceDocumentDistance().between(resA, resB, config); |
|
138 |
double d = sr.getScore(); |
|
139 |
System.out.println(String.format(" d ---> %s", d)); |
|
140 |
|
|
141 |
assertTrue("exact DOIs will produce an exact match", d == 1.0); |
|
142 |
} |
|
143 |
|
|
144 |
@Test |
|
145 |
public void testDistanceResultCaseDoiMatch2() { |
|
146 |
final Config config = getResultConf(); |
|
147 |
|
|
148 |
final MapDocument resA = result(config, "A", "Conference proceedings on X. Appendix", "2003", "10.1594/PANGAEA.726855"); |
|
149 |
final MapDocument resB = result(config, "B", "Search the Standard Model Higgs Boson", "2005", "10.1594/PANGAEA.726855"); |
|
150 |
|
|
151 |
final ScoreResult sr = new PaceDocumentDistance().between(resA, resB, config); |
|
152 |
double d = sr.getScore(); |
|
153 |
System.out.println(String.format(" d ---> %s", d)); |
|
154 |
|
|
155 |
assertTrue("exact DOIs will produce an exact match, regardless of different titles or publication years", d == 1.0); |
|
156 |
} |
|
157 |
|
|
158 |
@Test |
|
159 |
public void testDistanceResultCaseDoiMatch3() { |
|
160 |
final Config config = getResultConf(); |
|
161 |
|
|
162 |
final MapDocument resA = result(config, "A", "Conference proceedings on X. Appendix", "2003", "10.1016/j.jmb.2010.12.024"); |
|
163 |
final MapDocument resB = result(config, "B", "Conference proceedings on X. Appendix", "2003"); |
|
164 |
|
|
165 |
final ScoreResult sr = new PaceDocumentDistance().between(resA, resB, config); |
|
166 |
double d = sr.getScore(); |
|
167 |
System.out.println(String.format(" d ---> %s", d)); |
|
168 |
|
|
169 |
assertTrue("a missing DOI will casue the comparsion to continue with the following conditions", d == 1.0); |
|
170 |
} |
|
171 |
|
|
172 |
@Test |
|
173 |
public void testDistanceResultCaseDoiMatch4() { |
|
174 |
final Config config = getResultConf(); |
|
175 |
|
|
176 |
final MapDocument resA = result(config, "A", "Conference proceedings on X. Appendix", "2003", "10.1016/j.jmb.2010.12.024"); |
|
177 |
final MapDocument resB = result(config, "B", "Conference proceedings on X. Appendix", "2005"); |
|
178 |
|
|
179 |
final ScoreResult sr = new PaceDocumentDistance().between(resA, resB, config); |
|
180 |
double d = sr.getScore(); |
|
181 |
System.out.println(String.format(" d ---> %s", d)); |
|
182 |
|
|
183 |
assertTrue("a missing DOI, comparsion continues with the following conditions, different publication years will drop the score to 0", d == 0.0); |
|
184 |
} |
|
185 |
|
|
186 |
@Test |
|
187 |
public void testDistanceResultCaseDoiMatch5() { |
|
188 |
|
|
189 |
final Config config = getResultConf(); |
|
190 |
|
|
191 |
final MapDocument resA = result(config, "A", "Search for the Standard Model Higgs Boson", "2003", "10.1016/j.jmb.2010.12.020"); |
|
192 |
final MapDocument resB = result(config, "B", "Search the Standard Model Higgs Boson", "2003"); |
|
193 |
|
|
194 |
final ScoreResult sr = new PaceDocumentDistance().between(resA, resB, config); |
|
195 |
double d = sr.getScore(); |
|
196 |
System.out.println(String.format(" d ---> %s", d)); |
|
197 |
|
|
198 |
assertTrue("a missing DOI, comparsion continues with the following conditions", (d > 0.9) && (d < 1.0)); |
|
199 |
} |
|
200 |
|
|
201 |
@Test |
|
202 |
public void testDistanceResultCaseDoiMatch6() { |
|
203 |
final Config config = getResultConf(); |
|
204 |
|
|
205 |
final MapDocument resA = result(config, "A", "Conference proceedings on X. Appendix", "2003", "10.1016/j.jmb.2010.12.024"); |
|
206 |
final MapDocument resB = result(config, "B", "Conference proceedings on X. Appendix", "2003", "anotherDifferentDOI"); |
|
207 |
|
|
208 |
final ScoreResult sr = new PaceDocumentDistance().between(resA, resB, config); |
|
209 |
double d = sr.getScore(); |
|
210 |
System.out.println(String.format(" d ---> %s", d)); |
|
211 |
|
|
212 |
assertTrue("different DOIs will NOT drop the score to 0, then evaluate other fields", d == 1.0); |
|
213 |
} |
|
214 |
|
|
215 |
@Test |
|
216 |
public void testDistanceResultCaseDoiMatch7() { |
|
217 |
final Config config = getResultConf(); |
|
218 |
|
|
219 |
final MapDocument resA = result(config, "A", "Adrenal Insufficiency asd asd", "1951", Lists.newArrayList("PMC2037944", "axdsds")); |
|
220 |
final MapDocument resB = result(config, "B", "Adrenal Insufficiency", "1951", "PMC2037944"); |
|
221 |
|
|
222 |
final ScoreResult sr = new PaceDocumentDistance().between(resA, resB, config); |
|
223 |
double d = sr.getScore(); |
|
224 |
System.out.println(String.format(" d ---> %s", d)); |
|
225 |
|
|
226 |
assertTrue("different DOIs will drop the score to 0, regardless of the other fields", d > 0.9 & d < 1); |
|
227 |
} |
|
228 |
|
|
229 |
// http://dx.doi.org/10.1594/PANGAEA.726855 doi:10.1594/PANGAEA.726855 |
|
230 |
|
|
231 |
@Test |
|
232 |
public void testDistanceResultCaseAuthor1() { |
|
233 |
|
|
234 |
final Config config = getResultAuthorsConf(); |
|
235 |
|
|
236 |
final List<String> authorsA = Lists.newArrayList("a", "b", "c", "d"); |
|
237 |
final List<String> authorsB = Lists.newArrayList("a", "b", "c"); |
|
238 |
final List<String> pid = Lists.newArrayList(); |
|
239 |
|
|
240 |
final MapDocument resA = result(config, "A", "Search the Standard Model Higgs Boson", "2003", pid, authorsA); |
|
241 |
final MapDocument resB = result(config, "B", "Search the Standard Model Higgs Boson", "2003", pid, authorsB); |
|
242 |
|
|
243 |
final ScoreResult sr = new PaceDocumentDistance().between(resA, resB, config); |
|
244 |
final double d = sr.getScore(); |
|
245 |
System.out.println(String.format(" d ---> %s", d)); |
|
246 |
|
|
247 |
assertTrue(d == 0.0); |
|
248 |
} |
|
249 |
|
|
250 |
@Test |
|
251 |
public void testDistanceResultCaseAuthor2() { |
|
252 |
|
|
253 |
final Config config = getResultAuthorsConf(); |
|
254 |
|
|
255 |
final List<String> authorsA = Lists.newArrayList("a", "b", "c"); |
|
256 |
final List<String> authorsB = Lists.newArrayList("a", "b", "c"); |
|
257 |
final List<String> pid = Lists.newArrayList(); |
|
258 |
|
|
259 |
final MapDocument resA = result(config, "A", "Search the Standard Model Higgs Boson", "2003", pid, authorsA); |
|
260 |
final MapDocument resB = result(config, "B", "Search the Standard Model Higgs Boson", "2003", pid, authorsB); |
|
261 |
|
|
262 |
final ScoreResult sr = new PaceDocumentDistance().between(resA, resB, config); |
|
263 |
final double d = sr.getScore(); |
|
264 |
System.out.println(String.format(" d ---> %s", d)); |
|
265 |
|
|
266 |
assertTrue(d == 1.0); |
|
267 |
} |
|
268 |
|
|
269 |
@Test |
|
270 |
public void testDistanceResultCaseAuthor3() { |
|
271 |
|
|
272 |
final Config config = getResultAuthorsConf(); |
|
273 |
|
|
274 |
final List<String> authorsA = Lists.newArrayList("Bardi, A.", "Manghi, P.", "Artini, M."); |
|
275 |
final List<String> authorsB = Lists.newArrayList("Bardi Alessia", "Manghi Paolo", "Artini Michele"); |
|
276 |
final List<String> pid = Lists.newArrayList(); |
|
277 |
|
|
278 |
final MapDocument resA = result(config, "A", "Search the Standard Model Higgs Boson", "2003", pid, authorsA); |
|
279 |
final MapDocument resB = result(config, "B", "Search the Standard Model Higgs Boson", "2003", pid, authorsB); |
|
280 |
|
|
281 |
final ScoreResult sr = new PaceDocumentDistance().between(resA, resB, config); |
|
282 |
double d = sr.getScore(); |
|
283 |
System.out.println(String.format(" d ---> %s", d)); |
|
284 |
|
|
285 |
assertTrue((d > 0.9) && (d < 1.0)); |
|
286 |
} |
|
287 |
|
|
288 |
@Test |
|
289 |
public void testDistanceResultCaseAuthor4() { |
|
290 |
|
|
291 |
final Config config = getResultAuthorsConf(); |
|
292 |
|
|
293 |
final List<String> authorsA = Lists.newArrayList("Bardi, Alessia", "Manghi, Paolo", "Artini, Michele", "a"); |
|
294 |
final List<String> authorsB = Lists.newArrayList("Bardi Alessia", "Manghi Paolo", "Artini Michele"); |
|
295 |
final List<String> pid = Lists.newArrayList(); |
|
296 |
|
|
297 |
final MapDocument resA = result(config, "A", "Search the Standard Model Higgs Boson", "2003", pid, authorsA); |
|
298 |
final MapDocument resB = result(config, "B", "Search the Standard Model Higgs Boson", "2003", pid, authorsB); |
|
299 |
|
|
300 |
final ScoreResult sr = new PaceDocumentDistance().between(resA, resB, config); |
|
301 |
final double d = sr.getScore(); |
|
302 |
System.out.println(String.format(" d ---> %s", d)); |
|
303 |
|
|
304 |
// assertTrue(d.getScore() == 0.0); |
|
305 |
} |
|
306 |
|
|
307 |
@Test |
|
308 |
public void testDistanceResultFullConf() { |
|
309 |
|
|
310 |
final Config config = getResultFullConf(); |
|
311 |
|
|
312 |
final List<String> authorsA = Lists.newArrayList("Nagarajan Pranesh", "Guy Vautier", "Punyanganie de Silva"); |
|
313 |
final List<String> authorsB = Lists.newArrayList("Pranesh Nagarajan", "Vautier Guy", "de Silva Punyanganie"); |
|
314 |
|
|
315 |
final MapDocument resA = |
|
316 |
result(config, "A", "Presentations of perforated colonic pathology in patients with polymyalgia rheumatica: two case reports", "2010", |
|
317 |
"10.1186/1752-1947-4-299", authorsA); |
|
318 |
|
|
319 |
final MapDocument resB = |
|
320 |
result(config, "B", "Presentations of perforated colonic pathology in patients with polymyalgia rheumatica: two case reports", "2010", |
|
321 |
"10.1186/1752-1947-4-299", authorsB); |
|
322 |
|
|
323 |
final ScoreResult sr = new PaceDocumentDistance().between(resA, resB, config); |
|
324 |
final double d = sr.getScore(); |
|
325 |
System.out.println(String.format(" d ---> %s", d)); |
|
326 |
|
|
327 |
// assertTrue(d.getScore() == 0.0); |
|
328 |
} |
|
329 |
|
|
330 |
} |
modules/dnet-openaireplus-mapping-utils/branches/solr7/src/test/java/eu/dnetlib/pace/clustering/ClusteringCombinerTest.java | ||
---|---|---|
1 |
package eu.dnetlib.pace.clustering; |
|
2 |
|
|
3 |
import org.junit.Before; |
|
4 |
import org.junit.Test; |
|
5 |
|
|
6 |
import eu.dnetlib.pace.AbstractProtoPaceTest; |
|
7 |
import eu.dnetlib.pace.config.Config; |
|
8 |
import eu.dnetlib.pace.config.Type; |
|
9 |
import eu.dnetlib.pace.model.FieldListImpl; |
|
10 |
import eu.dnetlib.pace.model.FieldValueImpl; |
|
11 |
import eu.dnetlib.pace.model.MapDocument; |
|
12 |
|
|
13 |
public class ClusteringCombinerTest extends AbstractProtoPaceTest { |
|
14 |
|
|
15 |
private Config config; |
|
16 |
|
|
17 |
@Before |
|
18 |
public void setUp() { |
|
19 |
config = getResultFullConf(); |
|
20 |
} |
|
21 |
|
|
22 |
@Test |
|
23 |
public void testCombine() { |
|
24 |
String title = "Dipping in Cygnus X-2 in a multi-wavelength campaign due to absorption of extended ADC emission"; |
|
25 |
MapDocument result = result(config, "A", title, "2013"); |
|
26 |
|
|
27 |
FieldListImpl fl = new FieldListImpl(); |
|
28 |
fl.add(new FieldValueImpl(Type.String, "desc", "lorem ipsum cabalie qwerty")); |
|
29 |
|
|
30 |
result.getFieldMap().put("desc", fl); |
|
31 |
System.out.println(title); |
|
32 |
System.out.println(ClusteringCombiner.combine(result, config)); |
|
33 |
} |
|
34 |
|
|
35 |
} |
modules/dnet-openaireplus-mapping-utils/branches/solr7/src/test/java/eu/dnetlib/pace/clustering/BlacklistAwareClusteringCombinerTest.java | ||
---|---|---|
1 |
package eu.dnetlib.pace.clustering; |
|
2 |
|
|
3 |
import org.junit.Before; |
|
4 |
import org.junit.Test; |
|
5 |
|
|
6 |
import eu.dnetlib.pace.AbstractProtoPaceTest; |
|
7 |
import eu.dnetlib.pace.config.Config; |
|
8 |
import eu.dnetlib.pace.config.Type; |
|
9 |
import eu.dnetlib.pace.model.FieldListImpl; |
|
10 |
import eu.dnetlib.pace.model.FieldValueImpl; |
|
11 |
import eu.dnetlib.pace.model.MapDocument; |
|
12 |
|
|
13 |
public class BlacklistAwareClusteringCombinerTest extends AbstractProtoPaceTest { |
|
14 |
|
|
15 |
private Config config; |
|
16 |
|
|
17 |
@Before |
|
18 |
public void setUp() { |
|
19 |
config = getResultFullConf(); |
|
20 |
} |
|
21 |
|
|
22 |
@Test |
|
23 |
public void testCombine() { |
|
24 |
final MapDocument result = |
|
25 |
result(config, "A", "Dipping in Cygnus X-2 in a multi-wavelength campaign due to absorption of extended ADC emission", "2013"); |
|
26 |
final FieldListImpl fl = new FieldListImpl(); |
|
27 |
fl.add(new FieldValueImpl(Type.String, "desc", "hello world description pipeline")); |
|
28 |
|
|
29 |
result.getFieldMap().put("desc", fl); |
|
30 |
|
|
31 |
fl.clear(); |
|
32 |
fl.add(new FieldValueImpl(Type.String, "title", "lorem ipsum cabalie qwerty")); |
|
33 |
final FieldListImpl field = (FieldListImpl) result.getFieldMap().get("title"); |
|
34 |
field.add(fl); |
|
35 |
|
|
36 |
System.out.println(BlacklistAwareClusteringCombiner.filterAndCombine(result, config, config.blacklists())); |
|
37 |
} |
|
38 |
} |
modules/dnet-openaireplus-mapping-utils/branches/solr7/src/test/java/eu/dnetlib/pace/AbstractProtoPaceTest.java | ||
---|---|---|
1 |
package eu.dnetlib.pace; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.io.StringWriter; |
|
5 |
import java.util.ArrayList; |
|
6 |
import java.util.LinkedList; |
|
7 |
import java.util.List; |
|
8 |
import java.util.stream.Collectors; |
|
9 |
import java.util.stream.IntStream; |
|
10 |
|
|
11 |
import com.google.common.collect.Lists; |
|
12 |
import com.google.gson.Gson; |
|
13 |
import eu.dnetlib.data.mapreduce.util.OafTest; |
|
14 |
import eu.dnetlib.data.proto.FieldTypeProtos.Author; |
|
15 |
import eu.dnetlib.data.proto.FieldTypeProtos.Qualifier; |
|
16 |
import eu.dnetlib.data.proto.FieldTypeProtos.StructuredProperty; |
|
17 |
import eu.dnetlib.data.proto.FieldTypeProtos.StructuredProperty.Builder; |
|
18 |
import eu.dnetlib.data.proto.OafProtos.Oaf; |
|
19 |
import eu.dnetlib.data.proto.OafProtos.OafEntity; |
|
20 |
import eu.dnetlib.data.proto.OrganizationProtos.Organization; |
|
21 |
import eu.dnetlib.data.proto.ResultProtos.Result; |
|
22 |
import eu.dnetlib.pace.config.Config; |
|
23 |
import eu.dnetlib.pace.config.DedupConfig; |
|
24 |
import eu.dnetlib.pace.config.Type; |
|
25 |
import eu.dnetlib.pace.model.Field; |
|
26 |
import eu.dnetlib.pace.model.FieldValueImpl; |
|
27 |
import eu.dnetlib.pace.model.MapDocument; |
|
28 |
import eu.dnetlib.pace.model.ProtoDocumentBuilder; |
|
29 |
import eu.dnetlib.pace.model.gt.GTAuthor; |
|
30 |
|
|
31 |
import org.apache.commons.io.IOUtils; |
|
32 |
import org.apache.commons.lang.RandomStringUtils; |
|
33 |
import org.apache.commons.lang.StringUtils; |
|
34 |
|
|
35 |
public abstract class AbstractProtoPaceTest extends OafTest { |
|
36 |
|
|
37 |
protected DedupConfig getResultFullConf() { |
|
38 |
return DedupConfig.load(readFromClasspath("/eu/dnetlib/pace/result.full.pace.conf")); |
|
39 |
} |
|
40 |
|
|
41 |
protected DedupConfig getResultSimpleConf() { |
|
42 |
return DedupConfig.load(readFromClasspath("/eu/dnetlib/pace/result.simple.pace.conf")); |
|
43 |
} |
|
44 |
|
|
45 |
protected DedupConfig getResultConf() { |
|
46 |
return DedupConfig.load(readFromClasspath("/eu/dnetlib/pace/result.pace.conf")); |
|
47 |
} |
|
48 |
|
|
49 |
protected DedupConfig getOrganizationSimpleConf() { |
|
50 |
return DedupConfig.load(readFromClasspath("/eu/dnetlib/pace/organization.pace.conf")); |
|
51 |
} |
|
52 |
|
|
53 |
protected DedupConfig getResultAuthorsConf() { |
|
54 |
return DedupConfig.load(readFromClasspath("/eu/dnetlib/pace/result.authors.pace.conf")); |
|
55 |
} |
|
56 |
|
|
57 |
protected DedupConfig getResultProdConf() { |
|
58 |
return DedupConfig.load(readFromClasspath("/eu/dnetlib/pace/result.prod.pace.conf")); |
|
59 |
} |
|
60 |
|
|
61 |
protected MapDocument author(final Config conf, final String id, final Oaf oaf) { |
|
62 |
return ProtoDocumentBuilder.newInstance(id, oaf.getEntity(), conf.model()); |
|
63 |
} |
|
64 |
|
|
65 |
protected GTAuthor getGTAuthor(final String path) { |
|
66 |
|
|
67 |
final Gson gson = new Gson(); |
|
68 |
|
|
69 |
final String json = readFromClasspath(path); |
|
70 |
|
|
71 |
final GTAuthor gta = gson.fromJson(json, GTAuthor.class); |
|
72 |
|
|
73 |
return gta; |
|
74 |
} |
|
75 |
|
|
76 |
private String readFromClasspath(final String filename) { |
|
77 |
final StringWriter sw = new StringWriter(); |
|
78 |
try { |
|
79 |
IOUtils.copy(getClass().getResourceAsStream(filename), sw); |
|
80 |
return sw.toString(); |
|
81 |
} catch (final IOException e) { |
|
82 |
throw new RuntimeException("cannot load resource from classpath: " + filename); |
|
83 |
} |
|
84 |
} |
|
85 |
|
|
86 |
protected MapDocument result(final Config config, final String id, final String title) { |
|
87 |
return result(config, id, title, null, new ArrayList<>(), null); |
|
88 |
} |
|
89 |
|
|
90 |
protected MapDocument result(final Config config, final String id, final String title, final String date) { |
|
91 |
return result(config, id, title, date, new ArrayList<>(), null); |
|
92 |
} |
|
93 |
|
|
94 |
protected MapDocument result(final Config config, final String id, final String title, final String date, final List<String> pid) { |
|
95 |
return result(config, id, title, date, pid, null); |
|
96 |
} |
|
97 |
|
|
98 |
protected MapDocument result(final Config config, final String id, final String title, final String date, final String pid) { |
|
99 |
return result(config, id, title, date, pid, null); |
|
100 |
} |
|
101 |
|
|
102 |
protected MapDocument result(final Config config, final String id, final String title, final String date, final String pid, final List<String> authors) { |
|
103 |
return result(config, id, title, date, Lists.newArrayList(pid), authors); |
|
104 |
} |
|
105 |
|
|
106 |
protected MapDocument result(final Config config, final String id, final String title, final String date, final List<String> pid, final List<String> authors) { |
|
107 |
final Result.Metadata.Builder metadata = Result.Metadata.newBuilder(); |
|
108 |
if (!StringUtils.isBlank(title)) { |
|
109 |
metadata.addTitle(getStruct(title, getQualifier("main title", "dnet:titles"))); |
|
110 |
metadata.addTitle(getStruct(RandomStringUtils.randomAlphabetic(10), getQualifier("alternative title", "dnet:titles"))); |
|
111 |
} |
|
112 |
if (!StringUtils.isBlank(date)) { |
|
113 |
metadata.setDateofacceptance(sf(date)); |
|
114 |
} |
|
115 |
|
|
116 |
final OafEntity.Builder entity = oafEntity(id, eu.dnetlib.data.proto.TypeProtos.Type.result); |
|
117 |
final Result.Builder result = Result.newBuilder().setMetadata(metadata); |
|
118 |
|
|
119 |
if (authors != null) { |
|
120 |
result.getMetadataBuilder().addAllAuthor( |
|
121 |
IntStream.range(0, authors.size()) |
|
122 |
.mapToObj(i -> author(authors.get(i), i)) |
|
123 |
.collect(Collectors.toCollection(LinkedList::new))); |
|
124 |
} |
|
125 |
|
|
126 |
entity.setResult(result); |
|
127 |
|
|
128 |
if (pid != null) { |
|
129 |
for(String p : pid) { |
|
130 |
if (!StringUtils.isBlank(p)) { |
|
131 |
entity.addPid(sp(p, "doi")); |
|
132 |
//entity.addPid(sp(RandomStringUtils.randomAlphabetic(10), "oai")); |
|
133 |
} |
|
134 |
} |
|
135 |
} |
|
136 |
|
|
137 |
final OafEntity build = entity.build(); |
|
138 |
return ProtoDocumentBuilder.newInstance(id, build, config.model()); |
|
139 |
} |
|
140 |
|
|
141 |
private Author author(final String s, int rank) { |
|
142 |
final eu.dnetlib.pace.model.Person p = new eu.dnetlib.pace.model.Person(s, false); |
|
143 |
final Author.Builder author = Author.newBuilder(); |
|
144 |
if (p.isAccurate()) { |
|
145 |
author.setName(p.getNormalisedFirstName()); |
|
146 |
author.setSurname(p.getNormalisedSurname()); |
|
147 |
} |
|
148 |
author.setFullname(p.getNormalisedFullname()); |
|
149 |
author.setRank(rank); |
|
150 |
|
|
151 |
return author.build(); |
|
152 |
} |
|
153 |
|
|
154 |
private OafEntity.Builder oafEntity(final String id, final eu.dnetlib.data.proto.TypeProtos.Type type) { |
|
155 |
final OafEntity.Builder entity = OafEntity.newBuilder().setId(id).setType(type); |
|
156 |
return entity; |
|
157 |
} |
|
158 |
|
|
159 |
protected MapDocument organization(final Config config, final String id, final String legalName) { |
|
160 |
return organization(config, id, legalName, null); |
|
161 |
} |
|
162 |
|
|
163 |
protected MapDocument organization(final Config config, final String id, final String legalName, final String legalShortName) { |
|
164 |
final Organization.Metadata.Builder metadata = Organization.Metadata.newBuilder(); |
|
165 |
if (legalName != null) { |
|
166 |
metadata.setLegalname(sf(legalName)); |
|
167 |
} |
|
168 |
if (legalShortName != null) { |
|
169 |
metadata.setLegalshortname(sf(legalShortName)); |
|
170 |
} |
|
171 |
|
|
172 |
final OafEntity.Builder entity = oafEntity(id, eu.dnetlib.data.proto.TypeProtos.Type.result); |
|
173 |
entity.setOrganization(Organization.newBuilder().setMetadata(metadata)); |
|
174 |
|
|
175 |
return ProtoDocumentBuilder.newInstance(id, entity.build(), config.model()); |
|
176 |
} |
|
177 |
|
|
178 |
private StructuredProperty sp(final String pid, final String type) { |
|
179 |
final Builder pidSp = |
|
180 |
StructuredProperty.newBuilder().setValue(pid) |
|
181 |
.setQualifier(Qualifier.newBuilder().setClassid(type).setClassname(type).setSchemeid("dnet:pid_types").setSchemename("dnet:pid_types")); |
|
182 |
return pidSp.build(); |
|
183 |
} |
|
184 |
|
|
185 |
protected Field title(final String s) { |
|
186 |
return new FieldValueImpl(Type.String, "title", s); |
|
187 |
} |
|
188 |
|
|
189 |
protected static StructuredProperty.Builder getStruct(final String value, final Qualifier.Builder qualifier) { |
|
190 |
return StructuredProperty.newBuilder().setValue(value).setQualifier(qualifier); |
|
191 |
} |
|
192 |
|
|
193 |
/* |
|
194 |
* protected static StringField.Builder sf(final String s) { return StringField.newBuilder().setValue(s); } |
|
195 |
* |
|
196 |
* protected static Qualifier.Builder getQualifier(final String classname, final String schemename) { return |
|
197 |
* Qualifier.newBuilder().setClassid(classname).setClassname(classname).setSchemeid(schemename).setSchemename(schemename); } |
|
198 |
*/ |
|
199 |
|
|
200 |
} |
modules/dnet-openaireplus-mapping-utils/branches/solr7/src/test/java/eu/dnetlib/pace/model/ProtoDocumentBuilderTest.java | ||
---|---|---|
1 |
package eu.dnetlib.pace.model; |
|
2 |
|
|
3 |
import com.google.common.collect.Iterables; |
|
4 |
import com.google.common.collect.Sets; |
|
5 |
import com.google.common.collect.Sets.SetView; |
|
6 |
import eu.dnetlib.pace.AbstractProtoPaceTest; |
|
7 |
import eu.dnetlib.pace.config.Config; |
|
8 |
import org.junit.Test; |
|
9 |
|
|
10 |
import static org.junit.Assert.assertFalse; |
|
11 |
import static org.junit.Assert.assertTrue; |
|
12 |
|
|
13 |
public class ProtoDocumentBuilderTest extends AbstractProtoPaceTest { |
|
14 |
|
|
15 |
@Test |
|
16 |
public void test_serialise1() { |
|
17 |
|
|
18 |
final String id = "12345"; |
|
19 |
|
|
20 |
final Config config = getResultFullConf(); |
|
21 |
|
|
22 |
final MapDocument document = ProtoDocumentBuilder.newInstance(id, getResult(id), config.model()); |
|
23 |
|
|
24 |
assertFalse(document.fieldNames().isEmpty()); |
|
25 |
assertFalse(Iterables.isEmpty(document.fields())); |
|
26 |
|
|
27 |
System.out.println("original:\n" + document); |
|
28 |
|
|
29 |
final String stringDoc = MapDocumentSerializer.toString(document); |
|
30 |
|
|
31 |
System.out.println("srialization:\n" + stringDoc); |
|
32 |
|
|
33 |
final MapDocument decoded = MapDocumentSerializer.decode(stringDoc.getBytes()); |
|
34 |
|
|
35 |
final SetView<String> diff = Sets.difference(document.fieldNames(), decoded.fieldNames()); |
|
36 |
|
|
37 |
assertTrue(diff.isEmpty()); |
|
38 |
|
|
39 |
System.out.println("decoded:\n" + decoded); |
|
40 |
} |
|
41 |
|
|
42 |
} |
modules/dnet-openaireplus-mapping-utils/branches/solr7/src/test/java/eu/dnetlib/pace/model/gt/AuthorTest.java | ||
---|---|---|
1 |
package eu.dnetlib.pace.model.gt; |
|
2 |
|
|
3 |
import static org.junit.Assert.assertTrue; |
|
4 |
|
|
5 |
import java.util.Set; |
|
6 |
|
|
7 |
import org.junit.Test; |
|
8 |
|
|
9 |
import com.google.common.collect.Sets; |
|
10 |
|
|
11 |
import eu.dnetlib.pace.model.gt.Author; |
|
12 |
import eu.dnetlib.pace.model.gt.Authors; |
|
13 |
|
|
14 |
public class AuthorTest { |
|
15 |
|
|
16 |
@Test |
|
17 |
public void test() { |
|
18 |
final Set<Author> s1 = getAuthors(3); |
|
19 |
final Set<Author> s2 = getAuthors(3); |
|
20 |
|
|
21 |
final Set<Author> i = Sets.intersection(s1, s2); |
|
22 |
|
|
23 |
System.out.println(i); |
|
24 |
|
|
25 |
assertTrue(i.size() == 3); |
|
26 |
|
|
27 |
} |
|
28 |
|
|
29 |
@Test |
|
30 |
public void test1() { |
|
31 |
final Authors a1 = new Authors(a("1", "Wang, M.")); |
|
32 |
final Authors a2 = new Authors(a("1", "Wang, M.")); |
|
33 |
|
|
34 |
final Set<Author> i = Sets.intersection(a1, a2); |
|
35 |
|
|
36 |
assertTrue(i.size() == 1); |
|
37 |
|
|
38 |
} |
|
39 |
|
|
40 |
private Set<Author> getAuthors(final int n) { |
|
41 |
final Set<Author> s = Sets.newHashSet(); |
|
42 |
|
|
43 |
for (int i = 0; i < n; i++) { |
|
44 |
s.add(a(i + "", "name" + i)); |
|
45 |
} |
|
46 |
return s; |
|
47 |
} |
|
48 |
|
|
49 |
private Author a(final String id, final String fullname) { |
|
50 |
final Author a = new Author(); |
|
51 |
a.setId(id); |
|
52 |
a.setFullname(fullname); |
|
53 |
return a; |
|
54 |
} |
|
55 |
|
|
56 |
} |
modules/dnet-openaireplus-mapping-utils/branches/solr7/src/main/java/eu/dnetlib/data/transform/xml/AbstractDNetXsltFunctions.java | ||
---|---|---|
962 | 962 |
code2name.put("0034","Project deliverable"); |
963 | 963 |
code2name.put("0035","Project proposal"); |
964 | 964 |
code2name.put("0036","Project milestone"); |
965 |
code2name.put("0037","Clinical Trial"); |
|
965 | 966 |
code2name.put("crissystem","CRIS System"); |
966 | 967 |
code2name.put("datarepository::unknown","Data Repository"); |
967 | 968 |
code2name.put("aggregator::datarepository","Data Repository Aggregator"); |
... | ... | |
1018 | 1019 |
|
1019 | 1020 |
protected static String getDefaultResulttype(final Element cobjcategory) { |
1020 | 1021 |
switch (cobjcategory.getText()) { |
1021 |
case "0029": |
|
1022 |
return "software"; |
|
1023 |
case "0021": |
|
1024 |
case "0024": |
|
1025 |
case "0025": |
|
1026 |
case "0030": |
|
1027 |
return "dataset"; |
|
1028 |
case "0000": |
|
1029 |
case "0010": |
|
1030 |
case "0018": |
|
1031 |
case "0020": |
|
1032 |
case "0022": |
|
1033 |
case "0023": |
|
1034 |
case "0026": |
|
1035 |
case "0027": |
|
1036 |
case "0028": |
|
1037 |
case "0037": |
|
1038 |
return "other"; |
|
1039 |
case "0001": |
|
1040 |
case "0002": |
|
1041 |
case "0004": |
|
1042 |
case "0005": |
|
1043 |
case "0006": |
|
1044 |
case "0007": |
|
1045 |
case "0008": |
|
1046 |
case "0009": |
|
1047 |
case "0011": |
|
1048 |
case "0012": |
|
1049 |
case "0013": |
|
1050 |
case "0014": |
|
1051 |
case "0015": |
|
1052 |
case "0016": |
|
1053 |
case "0017": |
|
1054 |
case "0019": |
|
1055 |
case "0031": |
|
1056 |
case "0032": |
|
1057 |
return "publication"; |
|
1058 |
default: |
|
1059 |
return "publication"; |
|
1022 |
case "0029":
|
|
1023 |
return "software";
|
|
1024 |
case "0021":
|
|
1025 |
case "0024":
|
|
1026 |
case "0025":
|
|
1027 |
case "0030":
|
|
1028 |
return "dataset";
|
|
1029 |
case "0000":
|
|
1030 |
case "0010":
|
|
1031 |
case "0018":
|
|
1032 |
case "0020":
|
|
1033 |
case "0022":
|
|
1034 |
case "0023":
|
|
1035 |
case "0026":
|
|
1036 |
case "0027":
|
|
1037 |
case "0028":
|
|
1038 |
case "0037":
|
|
1039 |
return "other";
|
|
1040 |
case "0001":
|
|
1041 |
case "0002":
|
|
1042 |
case "0004":
|
|
1043 |
case "0005":
|
|
1044 |
case "0006":
|
|
1045 |
case "0007":
|
|
1046 |
case "0008":
|
|
1047 |
case "0009":
|
|
1048 |
case "0011":
|
|
1049 |
case "0012":
|
|
1050 |
case "0013":
|
|
1051 |
case "0014":
|
|
1052 |
case "0015":
|
|
1053 |
case "0016":
|
|
1054 |
case "0017":
|
|
1055 |
case "0019":
|
|
1056 |
case "0031":
|
|
1057 |
case "0032":
|
|
1058 |
return "publication";
|
|
1059 |
default:
|
|
1060 |
return "publication";
|
|
1060 | 1061 |
} |
1061 | 1062 |
} |
1062 | 1063 |
|
... | ... | |
1064 | 1065 |
|
1065 | 1066 |
switch(rType) { |
1066 | 1067 |
|
1067 |
case datasourceOrganization: |
|
1068 |
return rel.setDatasourceOrganization(DatasourceOrganization.newBuilder().setProvision((Provision.Builder) subRel)); |
|
1069 |
case projectOrganization: |
|
1070 |
return rel.setProjectOrganization(ProjectOrganization.newBuilder().setParticipation((Participation.Builder) subRel)); |
|
1071 |
case resultOrganization: |
|
1072 |
return rel.setResultOrganization(ResultOrganization.newBuilder().setAffiliation((Affiliation.Builder) subRel)); |
|
1073 |
case resultProject: |
|
1074 |
return rel.setResultProject(ResultProject.newBuilder().setOutcome((Outcome.Builder) subRel)); |
|
1075 |
case resultResult: |
|
1076 |
final ResultResult.Builder rr = ResultResult.newBuilder(); |
|
1077 |
switch (subRelType) { |
|
1068 |
case datasourceOrganization:
|
|
1069 |
return rel.setDatasourceOrganization(DatasourceOrganization.newBuilder().setProvision((Provision.Builder) subRel));
|
|
1070 |
case projectOrganization:
|
|
1071 |
return rel.setProjectOrganization(ProjectOrganization.newBuilder().setParticipation((Participation.Builder) subRel));
|
|
1072 |
case resultOrganization:
|
|
1073 |
return rel.setResultOrganization(ResultOrganization.newBuilder().setAffiliation((Affiliation.Builder) subRel));
|
|
1074 |
case resultProject:
|
|
1075 |
return rel.setResultProject(ResultProject.newBuilder().setOutcome((Outcome.Builder) subRel));
|
|
1076 |
case resultResult:
|
|
1077 |
final ResultResult.Builder rr = ResultResult.newBuilder();
|
|
1078 |
switch (subRelType) {
|
|
1078 | 1079 |
|
1079 |
case similarity: |
|
1080 |
return rel.setResultResult(rr.setSimilarity((Similarity.Builder) subRel)); |
|
1081 |
case publicationDataset: |
|
1082 |
return rel.setResultResult(rr.setPublicationDataset((PublicationDataset.Builder) subRel)); |
|
1083 |
case dedup: |
|
1084 |
return rel.setResultResult(rr.setDedup((Dedup.Builder) subRel)); |
|
1085 |
case dedupSimilarity: |
|
1086 |
return rel.setResultResult(rr.setDedupSimilarity((DedupSimilarity.Builder) subRel)); |
|
1087 |
case supplement: |
|
1088 |
return rel.setResultResult(rr.setSupplement((Supplement.Builder) subRel)); |
|
1089 |
case part: |
|
1090 |
return rel.setResultResult(rr.setPart((Part.Builder) subRel)); |
|
1091 |
default: |
|
1092 |
throw new IllegalArgumentException("invalid subRelType for result_result relations: " + subRelType.toString()); |
|
1093 |
} |
|
1094 |
case organizationOrganization: |
|
1095 |
final OrganizationOrganization.Builder oo = OrganizationOrganization.newBuilder(); |
|
1096 |
switch (subRelType) { |
|
1097 |
case dedup: |
|
1098 |
return rel.setOrganizationOrganization(oo.setDedup((Dedup.Builder) subRel)); |
|
1099 |
case dedupSimilarity: |
|
1100 |
return rel.setOrganizationOrganization(oo.setDedupSimilarity((DedupSimilarity.Builder) subRel)); |
|
1101 |
default: |
|
1102 |
throw new IllegalArgumentException("invalid subRelType for organization_organization relations: " + subRelType.toString()); |
|
1103 |
} |
|
1080 |
case similarity:
|
|
1081 |
return rel.setResultResult(rr.setSimilarity((Similarity.Builder) subRel));
|
|
1082 |
case publicationDataset:
|
|
1083 |
return rel.setResultResult(rr.setPublicationDataset((PublicationDataset.Builder) subRel));
|
|
1084 |
case dedup:
|
|
1085 |
return rel.setResultResult(rr.setDedup((Dedup.Builder) subRel));
|
|
1086 |
case dedupSimilarity:
|
|
1087 |
return rel.setResultResult(rr.setDedupSimilarity((DedupSimilarity.Builder) subRel));
|
|
1088 |
case supplement:
|
|
1089 |
return rel.setResultResult(rr.setSupplement((Supplement.Builder) subRel));
|
|
1090 |
case part:
|
|
1091 |
return rel.setResultResult(rr.setPart((Part.Builder) subRel));
|
|
1092 |
default:
|
|
1093 |
throw new IllegalArgumentException("invalid subRelType for result_result relations: " + subRelType.toString());
|
|
1094 |
}
|
|
1095 |
case organizationOrganization:
|
|
1096 |
final OrganizationOrganization.Builder oo = OrganizationOrganization.newBuilder();
|
|
1097 |
switch (subRelType) {
|
|
1098 |
case dedup:
|
|
1099 |
return rel.setOrganizationOrganization(oo.setDedup((Dedup.Builder) subRel));
|
|
1100 |
case dedupSimilarity:
|
|
1101 |
return rel.setOrganizationOrganization(oo.setDedupSimilarity((DedupSimilarity.Builder) subRel));
|
|
1102 |
default:
|
|
1103 |
throw new IllegalArgumentException("invalid subRelType for organization_organization relations: " + subRelType.toString());
|
|
1104 |
}
|
|
1104 | 1105 |
} |
1105 | 1106 |
throw new IllegalArgumentException("invalid relation type " + rType.toString()); |
1106 | 1107 |
} |
... | ... | |
1109 | 1110 |
|
1110 | 1111 |
switch (subRelType) { |
1111 | 1112 |
|
1112 |
case provision: |
|
1113 |
return Provision.newBuilder().setRelMetadata(metadata); |
|
1114 |
case outcome: |
|
1115 |
return Outcome.newBuilder().setRelMetadata(metadata); |
|
1116 |
case similarity: |
|
1117 |
return Similarity.newBuilder().setRelMetadata(metadata); |
|
1118 |
case publicationDataset: |
|
1119 |
return PublicationDataset.newBuilder().setRelMetadata(metadata); |
|
1120 |
case affiliation: |
|
1121 |
return Affiliation.newBuilder().setRelMetadata(metadata); |
|
1122 |
case dedup: |
|
1123 |
return Dedup.newBuilder().setRelMetadata(metadata); |
|
1124 |
case dedupSimilarity: |
|
1125 |
return DedupSimilarity.newBuilder().setRelMetadata(metadata); |
|
1126 |
case supplement: |
|
1127 |
return Supplement.newBuilder().setRelMetadata(metadata); |
|
1128 |
case part: |
|
1129 |
return Part.newBuilder().setRelMetadata(metadata); |
|
1113 |
case provision:
|
|
1114 |
return Provision.newBuilder().setRelMetadata(metadata);
|
|
1115 |
case outcome:
|
|
1116 |
return Outcome.newBuilder().setRelMetadata(metadata);
|
|
1117 |
case similarity:
|
|
1118 |
return Similarity.newBuilder().setRelMetadata(metadata);
|
|
1119 |
case publicationDataset:
|
|
1120 |
return PublicationDataset.newBuilder().setRelMetadata(metadata);
|
|
1121 |
case affiliation:
|
|
1122 |
return Affiliation.newBuilder().setRelMetadata(metadata);
|
|
1123 |
case dedup:
|
|
1124 |
return Dedup.newBuilder().setRelMetadata(metadata);
|
|
1125 |
case dedupSimilarity:
|
|
1126 |
return DedupSimilarity.newBuilder().setRelMetadata(metadata);
|
|
1127 |
case supplement:
|
|
1128 |
return Supplement.newBuilder().setRelMetadata(metadata);
|
|
1129 |
case part:
|
|
1130 |
return Part.newBuilder().setRelMetadata(metadata);
|
|
1130 | 1131 |
} |
1131 | 1132 |
throw new IllegalArgumentException("invalid relation type " + subRelType.toString()); |
1132 | 1133 |
} |
... | ... | |
1134 | 1135 |
protected static String getVocabularyName(final RelType relType) { |
1135 | 1136 |
switch (relType) { |
1136 | 1137 |
|
1137 |
case datasourceOrganization: |
|
1138 |
return "dnet:datasource_organization_relations"; |
|
1139 |
case projectOrganization: |
|
1140 |
return "dnet:project_organization_relations"; |
|
1141 |
case resultOrganization: |
|
1142 |
return "dnet:result_organization_relations"; |
|
1143 |
case resultProject: |
|
1144 |
return "dnet:result_project_relations"; |
|
1145 |
case resultResult: |
|
1146 |
return "dnet:result_result_relations"; |
|
1147 |
case organizationOrganization: |
|
1148 |
return "dnet:organization_organization_relations"; |
|
1138 |
case datasourceOrganization:
|
|
1139 |
return "dnet:datasource_organization_relations";
|
|
1140 |
case projectOrganization:
|
|
1141 |
return "dnet:project_organization_relations";
|
|
1142 |
case resultOrganization:
|
|
1143 |
return "dnet:result_organization_relations";
|
|
1144 |
case resultProject:
|
|
1145 |
return "dnet:result_project_relations";
|
|
1146 |
case resultResult:
|
|
1147 |
return "dnet:result_result_relations";
|
|
1148 |
case organizationOrganization:
|
|
1149 |
return "dnet:organization_organization_relations";
|
|
1149 | 1150 |
} |
1150 | 1151 |
throw new IllegalArgumentException("invalid relation type " + relType.toString()); |
1151 | 1152 |
} |
... | ... | |
1189 | 1190 |
} |
1190 | 1191 |
|
1191 | 1192 |
protected static OafRel.Builder getRel(final String sourceId, |
1192 |
final String targetId, |
|
1193 |
final RelType relType, |
|
1194 |
final SubRelType subRelType, |
|
1195 |
final String relClass, |
|
1196 |
final List<KeyValue> collectedFrom, |
|
1197 |
final boolean isChild) { |
|
1193 |
final String targetId,
|
|
1194 |
final RelType relType,
|
|
1195 |
final SubRelType subRelType,
|
|
1196 |
final String relClass,
|
|
1197 |
final List<KeyValue> collectedFrom,
|
|
1198 |
final boolean isChild) {
|
|
1198 | 1199 |
final OafRel.Builder oafRel = OafRel.newBuilder().setSource(sourceId) |
1199 | 1200 |
.setTarget(targetId) |
1200 | 1201 |
.setRelType(relType) |
... | ... | |
1209 | 1210 |
} |
1210 | 1211 |
|
1211 | 1212 |
protected static OafEntity.Builder getEntity(final Type type, |
1212 |
final String id, |
|
1213 |
final List<KeyValue> collectedFrom, |
|
1214 |
final Collection<String> originalIds, |
|
1215 |
final String dateOfCollection, |
|
1216 |
final String dateOfTransformation, |
|
1217 |
final List<StructuredProperty> pids) { |
|
1213 |
final String id,
|
|
1214 |
final List<KeyValue> collectedFrom,
|
|
1215 |
final Collection<String> originalIds,
|
|
1216 |
final String dateOfCollection,
|
|
1217 |
final String dateOfTransformation,
|
|
1218 |
final List<StructuredProperty> pids) {
|
|
1218 | 1219 |
final OafEntity.Builder builder = OafEntity.newBuilder().setType(type).setId(id); |
1219 | 1220 |
if (collectedFrom != null) builder.addAllCollectedfrom(collectedFrom); |
1220 | 1221 |
builder.setDateoftransformation(StringUtils.isBlank(dateOfTransformation) ? "" : dateOfTransformation); |
... | ... | |
1228 | 1229 |
|
1229 | 1230 |
if ((pids != null) && !pids.isEmpty()) { |
1230 | 1231 |
builder.addAllPid( |
1231 |
pids.stream().filter(Objects::nonNull)
|
|
1232 |
.collect(Collectors.toList()));
|
|
1232 |
pids.stream().filter(Objects::nonNull)
|
|
1233 |
.collect(Collectors.toList()));
|
|
1233 | 1234 |
} |
1234 | 1235 |
|
1235 | 1236 |
return builder; |
... | ... | |
1388 | 1389 |
} |
1389 | 1390 |
|
1390 | 1391 |
protected static void addStructuredProps(final Builder builder, |
1391 |
final FieldDescriptor fd, |
|
1392 |
final ElementList values, |
|
1393 |
final String defaultClass, |
|
1394 |
final String defaultScheme) { |
|
1392 |
final FieldDescriptor fd,
|
|
1393 |
final ElementList values,
|
|
1394 |
final String defaultClass,
|
|
1395 |
final String defaultScheme) {
|
|
1395 | 1396 |
if (values != null) { |
1396 | 1397 |
for (final Element s : values) { |
1397 | 1398 |
final String classId = s.getAttributeValue("classid") != null ? s.getAttributeValue("classid") : defaultClass; |
... | ... | |
1466 | 1467 |
} else { |
1467 | 1468 |
Object fieldValue = value; |
1468 | 1469 |
switch (descriptor.getType()) { |
1469 |
case BOOL: |
|
1470 |
fieldValue = Boolean.valueOf(value.toString()); |
|
1471 |
break; |
|
1472 |
case BYTES: |
|
1473 |
fieldValue = value.toString().getBytes(Charset.forName("UTF-8")); |
|
1474 |
break; |
|
1475 |
case DOUBLE: |
|
1476 |
fieldValue = Double.valueOf(value.toString()); |
|
1477 |
break; |
|
1478 |
case FLOAT: |
|
1479 |
fieldValue = Float.valueOf(value.toString()); |
|
1480 |
break; |
|
1481 |
case INT32: |
|
1482 |
case INT64: |
|
1483 |
case SINT32: |
|
1484 |
case SINT64: |
|
1485 |
fieldValue = Integer.valueOf(value.toString()); |
|
1486 |
break; |
|
1487 |
case MESSAGE: |
|
1488 |
final Builder q = builder.newBuilderForField(descriptor); |
|
1470 |
case BOOL:
|
|
1471 |
fieldValue = Boolean.valueOf(value.toString());
|
|
1472 |
break;
|
|
1473 |
case BYTES:
|
|
1474 |
fieldValue = value.toString().getBytes(Charset.forName("UTF-8"));
|
|
1475 |
break;
|
|
1476 |
case DOUBLE:
|
|
1477 |
fieldValue = Double.valueOf(value.toString());
|
|
1478 |
break;
|
|
1479 |
case FLOAT:
|
|
1480 |
fieldValue = Float.valueOf(value.toString());
|
|
1481 |
break;
|
|
1482 |
case INT32:
|
|
1483 |
case INT64:
|
|
1484 |
case SINT32:
|
|
1485 |
case SINT64:
|
|
1486 |
fieldValue = Integer.valueOf(value.toString());
|
|
1487 |
break;
|
|
1488 |
case MESSAGE:
|
|
1489 |
final Builder q = builder.newBuilderForField(descriptor);
|
|
1489 | 1490 |
|
1490 |
if (value instanceof Builder) { |
|
1491 |
value = ((Builder) value).build(); |
|
1492 |
final byte[] b = ((Message) value).toByteArray(); |
|
1493 |
try { |
|
1494 |
q.mergeFrom(b); |
|
1495 |
} catch (final InvalidProtocolBufferException e) { |
|
1496 |
throw new IllegalArgumentException("Unable to merge value: " + value + " with builder: " + q.getDescriptorForType().getName()); |
|
1491 |
if (value instanceof Builder) { |
|
1492 |
value = ((Builder) value).build(); |
|
1493 |
final byte[] b = ((Message) value).toByteArray(); |
|
1494 |
try { |
|
1495 |
q.mergeFrom(b); |
|
1496 |
} catch (final InvalidProtocolBufferException e) { |
|
1497 |
throw new IllegalArgumentException("Unable to merge value: " + value + " with builder: " + q.getDescriptorForType().getName()); |
|
1498 |
} |
|
1499 |
} else if (Qualifier.getDescriptor().getName().equals(q.getDescriptorForType().getName())) { |
|
1500 |
if (value instanceof Qualifier) { |
|
1501 |
q.mergeFrom((Qualifier) value); |
|
1502 |
} else { |
|
1503 |
parseMessage(q, Qualifier.getDescriptor(), value.toString(), "@@@"); |
|
1504 |
} |
|
1505 |
} else if (StructuredProperty.getDescriptor().getName().equals(q.getDescriptorForType().getName())) { |
|
1506 |
if (value instanceof StructuredProperty) { |
|
1507 |
q.mergeFrom((StructuredProperty) value); |
|
1508 |
} else { |
|
1509 |
parseMessage(q, StructuredProperty.getDescriptor(), value.toString(), "###"); |
|
1510 |
} |
|
1511 |
} else if (KeyValue.getDescriptor().getName().equals(q.getDescriptorForType().getName())) { |
|
1512 |
if (value instanceof KeyValue) { |
|
1513 |
q.mergeFrom((KeyValue) value); |
|
1514 |
} else { |
|
1515 |
parseMessage(q, KeyValue.getDescriptor(), value.toString(), "&&&"); |
|
1516 |
} |
|
1517 |
} else if (StringField.getDescriptor().getName().equals(q.getDescriptorForType().getName())) { |
|
1518 |
if (value instanceof StringField) { |
|
1519 |
q.mergeFrom((StringField) value); |
|
1520 |
} else { |
|
1521 |
q.setField(StringField.getDescriptor().findFieldByName("value"), value); |
|
1522 |
} |
|
1523 |
} else if (BoolField.getDescriptor().getName().equals(q.getDescriptorForType().getName())) { |
|
1524 |
if (value instanceof BoolField) { |
|
1525 |
q.mergeFrom((BoolField) value); |
|
1526 |
} else if (value instanceof String) { |
|
1527 |
q.setField(BoolField.getDescriptor().findFieldByName("value"), Boolean.valueOf((String) value)); |
|
1528 |
} else { |
|
1529 |
q.setField(BoolField.getDescriptor().findFieldByName("value"), value); |
|
1530 |
} |
|
1531 |
} else if (IntField.getDescriptor().getName().equals(q.getDescriptorForType().getName())) { |
|
1532 |
if (value instanceof IntField) { |
|
1533 |
q.mergeFrom((IntField) value); |
|
1534 |
} else if (value instanceof String) { |
|
1535 |
q.setField(IntField.getDescriptor().findFieldByName("value"), NumberUtils.toInt((String) value)); |
|
1536 |
} else { |
|
1537 |
q.setField(IntField.getDescriptor().findFieldByName("value"), value); |
|
1538 |
} |
|
1497 | 1539 |
} |
1498 |
} else if (Qualifier.getDescriptor().getName().equals(q.getDescriptorForType().getName())) { |
|
1499 |
if (value instanceof Qualifier) { |
|
1500 |
q.mergeFrom((Qualifier) value); |
|
1501 |
} else { |
|
1502 |
parseMessage(q, Qualifier.getDescriptor(), value.toString(), "@@@"); |
|
1503 |
} |
|
1504 |
} else if (StructuredProperty.getDescriptor().getName().equals(q.getDescriptorForType().getName())) { |
|
1505 |
if (value instanceof StructuredProperty) { |
|
1506 |
q.mergeFrom((StructuredProperty) value); |
|
1507 |
} else { |
|
1508 |
parseMessage(q, StructuredProperty.getDescriptor(), value.toString(), "###"); |
|
1509 |
} |
|
1510 |
} else if (KeyValue.getDescriptor().getName().equals(q.getDescriptorForType().getName())) { |
|
1511 |
if (value instanceof KeyValue) { |
|
1512 |
q.mergeFrom((KeyValue) value); |
|
1513 |
} else { |
|
1514 |
parseMessage(q, KeyValue.getDescriptor(), value.toString(), "&&&"); |
|
1515 |
} |
|
1516 |
} else if (StringField.getDescriptor().getName().equals(q.getDescriptorForType().getName())) { |
|
1517 |
if (value instanceof StringField) { |
|
1518 |
q.mergeFrom((StringField) value); |
|
1519 |
} else { |
|
1520 |
q.setField(StringField.getDescriptor().findFieldByName("value"), value); |
|
1521 |
} |
|
1522 |
} else if (BoolField.getDescriptor().getName().equals(q.getDescriptorForType().getName())) { |
|
1523 |
if (value instanceof BoolField) { |
|
1524 |
q.mergeFrom((BoolField) value); |
|
1525 |
} else if (value instanceof String) { |
|
1526 |
q.setField(BoolField.getDescriptor().findFieldByName("value"), Boolean.valueOf((String) value)); |
|
1527 |
} else { |
|
1528 |
q.setField(BoolField.getDescriptor().findFieldByName("value"), value); |
|
1529 |
} |
|
1530 |
} else if (IntField.getDescriptor().getName().equals(q.getDescriptorForType().getName())) { |
|
1531 |
if (value instanceof IntField) { |
|
1532 |
q.mergeFrom((IntField) value); |
|
1533 |
} else if (value instanceof String) { |
|
1534 |
q.setField(IntField.getDescriptor().findFieldByName("value"), NumberUtils.toInt((String) value)); |
|
1535 |
} else { |
|
1536 |
q.setField(IntField.getDescriptor().findFieldByName("value"), value); |
|
1537 |
} |
|
1538 |
} |
|
1539 | 1540 |
|
1540 |
fieldValue = q.buildPartial(); |
|
1541 |
break; |
|
1542 |
default: |
|
1543 |
break; |
|
1541 |
fieldValue = q.buildPartial();
|
|
1542 |
break;
|
|
1543 |
default:
|
|
1544 |
break;
|
|
1544 | 1545 |
} |
1545 | 1546 |
|
1546 | 1547 |
doAddField(builder, descriptor, fieldValue); |
... | ... | |
1594 | 1595 |
} |
1595 | 1596 |
|
1596 | 1597 |
protected static StructuredProperty getStructuredProperty(final String value, |
1597 |
final String classid, |
|
1598 |
final String classname, |
|
1599 |
final String schemeid, |
|
1600 |
final String schemename) { |
|
1598 |
final String classid,
|
|
1599 |
final String classname,
|
|
1600 |
final String schemeid,
|
|
1601 |
final String schemename) {
|
|
1601 | 1602 |
if ((value == null) || value.isEmpty()) return null; |
1602 | 1603 |
return StructuredProperty.newBuilder().setValue(value).setQualifier(getQualifier(classid, classname, schemeid, schemename)).build(); |
1603 | 1604 |
} |
modules/dnet-openaireplus-mapping-utils/branches/solr7/src/main/java/eu/dnetlib/data/transform/xml/DbmfToHbaseXsltFunctions.java | ||
---|---|---|
35 | 35 |
public class DbmfToHbaseXsltFunctions extends CommonDNetXsltFunctions { |
36 | 36 |
|
37 | 37 |
public static String oafEntity(final String type, |
38 |
final String id, |
|
39 |
final String collectedFromId, |
|
40 |
final String collectedFromName, |
|
41 |
final NodeList identities, |
|
42 |
final String dateOfCollection, |
|
43 |
final String dateOfTransformation, |
|
44 |
final NodeList nodeList) { |
|
38 |
final String id,
|
|
39 |
final String collectedFromId,
|
|
40 |
final String collectedFromName,
|
|
41 |
final NodeList identities,
|
|
42 |
final String dateOfCollection,
|
|
43 |
final String dateOfTransformation,
|
|
44 |
final NodeList nodeList) {
|
|
45 | 45 |
|
46 | 46 |
final String entityId = OafRowKeyDecoder.decode(id).getKey(); |
47 | 47 |
List<String> ids = Lists.newArrayList(); |
48 | 48 |
for(int i = 0; i < identities.getLength(); i++){ |
49 | 49 |
Node n = identities.item(i); |
50 | 50 |
String s = n.getTextContent(); |
51 |
ids.add(s); |
|
51 |
if (StringUtils.isNotBlank(s)) { |
|
52 |
ids.add(s); |
|
53 |
} |
|
52 | 54 |
} |
53 | 55 |
switch (Type.valueOf(type)) { |
54 |
case datasource: |
|
55 |
return serializeOafEntity(nodeList, Type.datasource, entityId, getKV(collectedFromId, collectedFromName), ids, dateOfCollection, |
|
56 |
dateOfTransformation, Datasource.newBuilder()); |
|
57 |
case organization: |
|
58 |
return serializeOafEntity(nodeList, Type.organization, entityId, getKV(collectedFromId, collectedFromName), ids, dateOfCollection, |
|
59 |
dateOfTransformation, Organization.newBuilder()); |
|
60 |
case project: |
|
61 |
return serializeOafEntity(nodeList, Type.project, entityId, getKV(collectedFromId, collectedFromName), ids, dateOfCollection, |
|
62 |
dateOfTransformation, Project.newBuilder()); |
|
63 |
case result: |
|
64 |
return serializeOafEntity(nodeList, Type.result, entityId, getKV(collectedFromId, collectedFromName), ids, dateOfCollection, |
|
65 |
dateOfTransformation ,Result.newBuilder()); |
|
66 |
default: |
|
67 |
throw new IllegalArgumentException("Invalid entity type: " + type); |
|
56 |
case datasource:
|
|
57 |
return serializeOafEntity(nodeList, Type.datasource, entityId, getKV(collectedFromId, collectedFromName), ids, dateOfCollection,
|
|
58 |
dateOfTransformation, Datasource.newBuilder());
|
|
59 |
case organization:
|
|
60 |
return serializeOafEntity(nodeList, Type.organization, entityId, getKV(collectedFromId, collectedFromName), ids, dateOfCollection,
|
|
61 |
dateOfTransformation, Organization.newBuilder());
|
|
62 |
case project:
|
|
63 |
return serializeOafEntity(nodeList, Type.project, entityId, getKV(collectedFromId, collectedFromName), ids, dateOfCollection,
|
|
64 |
dateOfTransformation, Project.newBuilder());
|
|
65 |
case result:
|
|
66 |
return serializeOafEntity(nodeList, Type.result, entityId, getKV(collectedFromId, collectedFromName), ids, dateOfCollection,
|
|
67 |
dateOfTransformation ,Result.newBuilder());
|
|
68 |
default:
|
|
69 |
throw new IllegalArgumentException("Invalid entity type: " + type);
|
|
68 | 70 |
} |
69 | 71 |
} |
70 | 72 |
|
71 | 73 |
public static String oafRel(final String relationType, |
72 |
final String source, |
|
73 |
final String target, |
|
74 |
final NodeList nodeList, |
|
75 |
final String relClass, |
|
76 |
final String relScheme) { |
|
74 |
final String source,
|
|
75 |
final String target,
|
|
76 |
final NodeList nodeList,
|
|
77 |
final String relClass,
|
|
78 |
final String relScheme) {
|
|
77 | 79 |
return oafRel(relationType, source, target, nodeList, relClass, relScheme, null, null); |
78 | 80 |
} |
79 | 81 |
|
80 | 82 |
public static String oafRel(final String relationType, |
81 |
final String source, |
|
82 |
final String target, |
|
83 |
final NodeList nodeList, |
|
84 |
final String relClass, |
|
85 |
final String relScheme, |
|
86 |
final String collectedFromId, |
|
87 |
final String collectedFromName) { |
|
83 |
final String source,
|
|
84 |
final String target,
|
|
85 |
final NodeList nodeList,
|
|
86 |
final String relClass,
|
|
87 |
final String relScheme,
|
|
88 |
final String collectedFromId,
|
|
89 |
final String collectedFromName) {
|
|
88 | 90 |
|
89 | 91 |
final String eSource = OafRowKeyDecoder.decode(source).getKey(); |
90 | 92 |
final String eTarget = OafRowKeyDecoder.decode(target).getKey(); |
91 | 93 |
final RelType relType = RelType.valueOf(relationType); |
92 | 94 |
|
93 | 95 |
switch (relType) { |
94 |
case datasourceOrganization: |
|
95 |
Provision.Builder provision = Provision.newBuilder().setRelMetadata( |
|
96 |
RelMetadata.newBuilder().setSemantics(getSimpleQualifier(Provision.RelName.valueOf(relClass).toString(), relScheme))); |
|
97 |
DatasourceOrganization.Builder dorg = DatasourceOrganization.newBuilder().setProvision(provision); |
|
96 |
case datasourceOrganization:
|
|
97 |
Provision.Builder provision = Provision.newBuilder().setRelMetadata(
|
|
98 |
RelMetadata.newBuilder().setSemantics(getSimpleQualifier(Provision.RelName.valueOf(relClass).toString(), relScheme)));
|
|
99 |
DatasourceOrganization.Builder dorg = DatasourceOrganization.newBuilder().setProvision(provision);
|
|
98 | 100 |
|
99 |
return serializeOafRel(nodeList, eSource, eTarget, relType, SubRelType.provision, relClass, collectedFromId, collectedFromName, false, dorg, provision); |
|
100 |
case projectOrganization: |
|
101 |
Participation.Builder participant = Participation.newBuilder().setRelMetadata( |
|
102 |
RelMetadata.newBuilder().setSemantics(getSimpleQualifier(Participation.RelName.valueOf(relClass).toString(), relScheme))); |
|
103 |
ProjectOrganization.Builder projectOrganization = ProjectOrganization.newBuilder().setParticipation(participant); |
|
101 |
return serializeOafRel(nodeList, eSource, eTarget, relType, SubRelType.provision, relClass, collectedFromId, collectedFromName, false, dorg, provision);
|
|
102 |
case projectOrganization:
|
|
103 |
Participation.Builder participant = Participation.newBuilder().setRelMetadata(
|
|
104 |
RelMetadata.newBuilder().setSemantics(getSimpleQualifier(Participation.RelName.valueOf(relClass).toString(), relScheme)));
|
|
105 |
ProjectOrganization.Builder projectOrganization = ProjectOrganization.newBuilder().setParticipation(participant);
|
|
104 | 106 |
|
105 |
return serializeOafRel(nodeList, eSource, eTarget, relType, SubRelType.participation, relClass, collectedFromId, collectedFromName, false, projectOrganization, participant); |
|
106 |
case resultProject: |
|
107 |
Outcome.Builder outcome = Outcome.newBuilder().setRelMetadata( |
|
108 |
RelMetadata.newBuilder().setSemantics(getSimpleQualifier(Outcome.RelName.valueOf(relClass).toString(), relScheme))); |
|
109 |
ResultProject.Builder resultProject = ResultProject.newBuilder().setOutcome(outcome); |
|
107 |
return serializeOafRel(nodeList, eSource, eTarget, relType, SubRelType.participation, relClass, collectedFromId, collectedFromName, false, projectOrganization, participant);
|
|
108 |
case resultProject:
|
|
109 |
Outcome.Builder outcome = Outcome.newBuilder().setRelMetadata(
|
|
110 |
RelMetadata.newBuilder().setSemantics(getSimpleQualifier(Outcome.RelName.valueOf(relClass).toString(), relScheme)));
|
|
111 |
ResultProject.Builder resultProject = ResultProject.newBuilder().setOutcome(outcome);
|
|
110 | 112 |
|
111 |
return serializeOafRel(nodeList, eSource, eTarget, relType, SubRelType.outcome, relClass, collectedFromId, collectedFromName, false, resultProject, outcome); |
|
112 |
case resultOrganization: |
|
113 |
Affiliation.Builder affiliation = Affiliation.newBuilder().setRelMetadata( |
|
114 |
RelMetadata.newBuilder().setSemantics(getSimpleQualifier(Affiliation.RelName.valueOf(relClass).toString(), relScheme))); |
|
115 |
ResultOrganization.Builder resultOrganization = ResultOrganization.newBuilder().setAffiliation(affiliation); |
|
113 |
return serializeOafRel(nodeList, eSource, eTarget, relType, SubRelType.outcome, relClass, collectedFromId, collectedFromName, false, resultProject, outcome);
|
|
114 |
case resultOrganization:
|
|
115 |
Affiliation.Builder affiliation = Affiliation.newBuilder().setRelMetadata(
|
|
116 |
RelMetadata.newBuilder().setSemantics(getSimpleQualifier(Affiliation.RelName.valueOf(relClass).toString(), relScheme)));
|
|
117 |
ResultOrganization.Builder resultOrganization = ResultOrganization.newBuilder().setAffiliation(affiliation);
|
|
116 | 118 |
|
117 |
return serializeOafRel(nodeList, eSource, eTarget, relType, SubRelType.affiliation, relClass, collectedFromId, collectedFromName, false, resultOrganization, affiliation); |
|
118 |
default: |
|
119 |
throw new IllegalArgumentException("unhandled relType: " + relationType); |
|
119 |
return serializeOafRel(nodeList, eSource, eTarget, relType, SubRelType.affiliation, relClass, collectedFromId, collectedFromName, false, resultOrganization, affiliation);
|
|
120 |
default:
|
|
121 |
throw new IllegalArgumentException("unhandled relType: " + relationType);
|
|
120 | 122 |
} |
121 | 123 |
} |
122 | 124 |
|
123 | 125 |
// //////////////////////////////////////////////////////// |
124 | 126 |
|
125 | 127 |
protected static String serializeOafEntity(final NodeList nodelist, |
126 |
final Type type, |
|
127 |
final String id, |
|
128 |
final KeyValue collectedFrom, |
|
129 |
final List<String> identities, |
|
130 |
final String dateOfCollection, |
|
131 |
final String dateOfTransformation, |
|
132 |
final Builder entity) { |
|
128 |
final Type type,
|
|
129 |
final String id,
|
|
130 |
final KeyValue collectedFrom,
|
|
131 |
final List<String> identities,
|
|
132 |
final String dateOfCollection,
|
|
133 |
final String dateOfTransformation,
|
|
134 |
final Builder entity) {
|
|
133 | 135 |
try { |
134 | 136 |
final FieldDescriptor md = entity.getDescriptorForType().findFieldByName("metadata"); |
135 | 137 |
|
... | ... | |
159 | 161 |
} |
160 | 162 |
|
161 | 163 |
protected static String serializeOafRel(final NodeList nodeList, |
162 |
final String sourceId, |
|
163 |
final String targetId, |
|
164 |
final RelType relType, |
|
165 |
final SubRelType subRelType, |
|
166 |
final String relClass, |
|
167 |
final String collectedFromId, |
|
168 |
final String collectedFromName, |
|
169 |
final boolean isChild, |
|
170 |
final Builder rel, |
|
171 |
final Builder subRel) { |
|
164 |
final String sourceId,
|
|
165 |
final String targetId,
|
|
166 |
final RelType relType,
|
|
167 |
final SubRelType subRelType,
|
|
168 |
final String relClass,
|
|
169 |
final String collectedFromId,
|
|
170 |
final String collectedFromName,
|
|
171 |
final boolean isChild,
|
|
172 |
final Builder rel,
|
|
173 |
final Builder subRel) {
|
|
172 | 174 |
try { |
173 | 175 |
|
174 | 176 |
final DataInfo.Builder dataInfo = DataInfo.newBuilder(); |
... | ... | |
200 | 202 |
} |
201 | 203 |
|
202 | 204 |
private static void parseNodelist(final NodeList nodeList, final Builder... builders) { |
203 |
|
|
205 |
|
|
204 | 206 |
for (int i = 0; i < nodeList.getLength(); i++) { |
205 | 207 |
|
206 | 208 |
final Node fieldNode = nodeList.item(i); |
Also available in: Unified diff
updated mappings *2hbase from master branch