Revision 52957
Added by Sandro La Bruzzo over 5 years ago
ScholixToActions.java | ||
---|---|---|
25 | 25 |
import static eu.dnetlib.data.proto.ResultProtos.Result.*; |
26 | 26 |
import static eu.dnetlib.data.proto.ResultResultProtos.ResultResult; |
27 | 27 |
import static eu.dnetlib.data.proto.TypeProtos.Type; |
28 |
import static eu.dnetlib.data.mapreduce.hbase.dataimport.DumpToActionsUtility.*; |
|
28 | 29 |
|
29 | 30 |
public class ScholixToActions { |
30 | 31 |
|
... | ... | |
319 | 320 |
return result; |
320 | 321 |
} |
321 | 322 |
|
322 |
public static Qualifier getQualifier(final String classValue, final String schemeValue) { |
|
323 | 323 |
|
324 |
return Qualifier.newBuilder() |
|
325 |
.setSchemeid(schemeValue) |
|
326 |
.setSchemename(schemeValue) |
|
327 |
.setClassname(classValue) |
|
328 |
.setClassid(classValue) |
|
329 |
.build(); |
|
330 |
} |
|
331 | 324 |
|
332 |
private static StructuredProperty getPid(final JsonObject localIdentifier, final Map<String, ScholExplorerConfiguration> conf) { |
|
333 |
final String pidType = getStringValue(localIdentifier, "type"); |
|
334 |
final ScholExplorerConfiguration configuration = conf.get(pidType); |
|
335 |
if (configuration.getCleandPidType() == null) { |
|
336 |
return null; |
|
337 |
} |
|
338 |
final String pid = getStringValue(localIdentifier, "id"); |
|
339 |
return StructuredProperty.newBuilder() |
|
340 |
.setValue(pid) |
|
341 |
.setQualifier(getQualifier(configuration.getCleandPidType(), "dnet:pid_types")) |
|
342 |
.build(); |
|
343 |
} |
|
344 | 325 |
|
345 |
public static String getStringValue(final JsonObject root, final String key) { |
|
346 |
if (root.has(key) && !root.get(key).isJsonNull()) |
|
347 |
return root.get(key).getAsString(); |
|
348 |
return null; |
|
349 |
} |
|
350 | 326 |
|
351 |
public static List<String> getArrayValues(final JsonObject root, final String key) { |
|
352 |
if (root.has(key) && root.get(key).isJsonArray()) { |
|
353 |
final JsonArray asJsonArray = root.get(key).getAsJsonArray(); |
|
354 |
final List<String> result = new ArrayList<>(); |
|
355 | 327 |
|
356 | 328 |
|
357 |
asJsonArray.forEach(it -> { |
|
358 |
if (StringUtils.isNotBlank(it.getAsString())) { |
|
359 |
result.add(it.getAsString()); |
|
360 |
} |
|
361 |
}); |
|
362 |
return result; |
|
363 |
} |
|
364 |
return new ArrayList<>(); |
|
365 |
} |
|
366 |
|
|
367 | 329 |
} |
Also available in: Unified diff
refactored Action