Revision 43443
Added by Claudio Atzori almost 8 years ago
ProtoMapping.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.data.mapreduce.hbase.broker.mapping; |
2 | 2 |
|
3 | 3 |
import java.util.List; |
4 |
import java.util.Set; |
|
4 | 5 |
|
5 | 6 |
import com.google.common.base.Function; |
6 | 7 |
import com.google.common.collect.Iterables; |
7 | 8 |
import com.google.common.collect.Lists; |
9 |
import com.google.common.collect.Sets; |
|
8 | 10 |
import eu.dnetlib.data.broker.model.openaire.ExternalReference; |
9 | 11 |
import eu.dnetlib.data.broker.model.openaire.Instance; |
10 | 12 |
import eu.dnetlib.data.broker.model.openaire.Pid; |
... | ... | |
19 | 21 |
*/ |
20 | 22 |
public abstract class ProtoMapping { |
21 | 23 |
|
22 |
protected static List<Instance> mapInstances(final List<Result.Instance> in) {
|
|
23 |
return Lists.newArrayList(Iterables.transform(in, new Function<Result.Instance, Instance>() {
|
|
24 |
protected static Set<Instance> mapInstances(final List<Result.Instance> in) {
|
|
25 |
return Sets.newHashSet(Iterables.transform(in, new Function<Result.Instance, Instance>() {
|
|
24 | 26 |
@Override |
25 | 27 |
public Instance apply(final Result.Instance i) { |
26 | 28 |
return new Instance() |
... | ... | |
32 | 34 |
})); |
33 | 35 |
} |
34 | 36 |
|
35 |
protected static List<Pid> mapPids(final List<StructuredProperty> sp) {
|
|
36 |
return Lists.newArrayList(Iterables.transform(sp, new Function<StructuredProperty, Pid>() {
|
|
37 |
@Override
|
|
38 |
public Pid apply(final StructuredProperty sp) {
|
|
39 |
return new Pid().setType(sp.getQualifier().getClassid()).setValue(sp.getValue());
|
|
40 |
}
|
|
41 |
}));
|
|
37 |
protected static Set<Pid> mapPids(final List<StructuredProperty> sp) {
|
|
38 |
return Sets.newHashSet(Iterables.transform(sp, new Function<StructuredProperty, Pid>() {
|
|
39 |
@Override |
|
40 |
public Pid apply(final StructuredProperty sp) { |
|
41 |
return new Pid().setType(sp.getQualifier().getClassid()).setValue(sp.getValue()); |
|
42 |
} |
|
43 |
})); |
|
42 | 44 |
} |
43 | 45 |
|
44 |
protected static List<ExternalReference> mapExternalRefs(final List<Result.ExternalReference> ext) {
|
|
45 |
return Lists.newArrayList(Iterables.transform(ext, new Function<Result.ExternalReference, ExternalReference>() {
|
|
46 |
protected static Set<ExternalReference> mapExternalRefs(final List<Result.ExternalReference> ext) {
|
|
47 |
return Sets.newHashSet(Iterables.transform(ext, new Function<Result.ExternalReference, ExternalReference>() {
|
|
46 | 48 |
@Override |
47 | 49 |
public ExternalReference apply(final Result.ExternalReference e) { |
48 | 50 |
return new ExternalReference() |
Also available in: Unified diff
[broker] created factories for specific event type