Revision 53097
Added by Michele Artini over 5 years ago
modules/dnet-grid-application/trunk/src/main/java/eu/dnetlib/grid/process/utils/GridUtils.java | ||
---|---|---|
86 | 86 |
|
87 | 87 |
return orgNames.entrySet() |
88 | 88 |
.stream() |
89 |
.map(e -> toProto(e.getKey(), |
|
89 |
.map(e -> toProtos(e.getKey(),
|
|
90 | 90 |
gridId, |
91 | 91 |
e.getValue(), |
92 | 92 |
shortName, |
... | ... | |
94 | 94 |
country, |
95 | 95 |
e.getKey().equals(mainOpenaireId) ? org.getAcronyms() : new ArrayList<>(), |
96 | 96 |
orgNames, collectedFrom)) |
97 |
.flatMap(l -> l.stream()) |
|
97 | 98 |
.collect(Collectors.toList()); |
98 | 99 |
|
99 | 100 |
} |
100 | 101 |
|
101 |
private static Oaf toProto(final String openaireId,
|
|
102 |
private static List<Oaf> toProtos(final String openaireId,
|
|
102 | 103 |
final String gridId, |
103 | 104 |
final String name, |
104 | 105 |
final String shortName, |
... | ... | |
127 | 128 |
.addAllAlternativeNames(acronyms.stream().map(a -> StringField.newBuilder().setValue(a).build()).collect(Collectors.toList())) |
128 | 129 |
.setCountry(country))); |
129 | 130 |
|
130 |
orgRels.entrySet().stream() |
|
131 |
final List<Oaf> oafs = orgRels.entrySet().stream()
|
|
131 | 132 |
.filter(e -> !e.getKey().equals(openaireId)) |
132 |
.forEach(e -> entity.addCachedRel( |
|
133 |
OafRel.newBuilder() |
|
133 |
.map(e -> Oaf.newBuilder() |
|
134 |
.setKind(Kind.relation) |
|
135 |
.setLastupdatetimestamp(DateUtils.now()) |
|
136 |
.setRel(OafRel.newBuilder() |
|
134 | 137 |
.setSource(openaireId) |
135 | 138 |
.setTarget(e.getKey()) |
136 | 139 |
.setRelType(RelType.organizationOrganization) |
137 |
.setSubRelType(SubRelType.similarity)
|
|
138 |
.setRelClass("") // TODO ???
|
|
139 |
.setChild(false) |
|
140 |
// TODO ??? e.getValue()
|
|
141 |
.addCollectedfrom(collectedFrom)));
|
|
140 |
.setSubRelType(SubRelType.dedupSimilarity)
|
|
141 |
.setRelClass("isSimilarTo")
|
|
142 |
.setChild(false))
|
|
143 |
.build())
|
|
144 |
.collect(Collectors.toList());
|
|
142 | 145 |
|
143 |
return Oaf.newBuilder()
|
|
146 |
oafs.add(Oaf.newBuilder()
|
|
144 | 147 |
.setKind(Kind.entity) |
145 | 148 |
.setLastupdatetimestamp(DateUtils.now()) |
146 | 149 |
.setEntity(entity) |
... | ... | |
152 | 155 |
.setClassname("UNKNOWN") |
153 | 156 |
.setSchemeid("dnet:provenanceActions") |
154 | 157 |
.setSchemename("dnet:provenanceActions"))) |
155 |
.build(); |
|
158 |
.build()); |
|
159 |
|
|
160 |
return oafs; |
|
156 | 161 |
} |
157 | 162 |
|
158 | 163 |
private static String calculateOpenaireId(final String prefix, final String gridId, final String name) { |
modules/dnet-grid-application/trunk/src/main/java/eu/dnetlib/grid/process/GridOrganizationsApplication.java | ||
---|---|---|
9 | 9 |
import org.springframework.boot.SpringApplication; |
10 | 10 |
import org.springframework.boot.autoconfigure.SpringBootApplication; |
11 | 11 |
|
12 |
import com.googlecode.protobuf.format.JsonFormat; |
|
13 |
|
|
12 | 14 |
import eu.dnetlib.grid.process.model.GridOrganization; |
13 | 15 |
import eu.dnetlib.grid.process.utils.Datasource; |
14 | 16 |
import eu.dnetlib.grid.process.utils.GridCleaner; |
... | ... | |
42 | 44 |
.filter(o -> o.getStatus().equals("active")) |
43 | 45 |
.collect(Collectors.toMap(GridOrganization::getId, GridUtils::findShortName)); |
44 | 46 |
|
47 |
final JsonFormat jsonFormat = new JsonFormat(); |
|
48 |
|
|
45 | 49 |
GridUtils.streamOrganizations(jsonFile) |
46 | 50 |
.filter(Objects::nonNull) |
47 | 51 |
.filter(o -> o.getStatus().equals("active")) |
48 | 52 |
.map(cleaner) |
49 | 53 |
.map(org -> GridUtils.toProtos(org, parents, gridDs)) |
50 | 54 |
.flatMap(List::stream) |
51 |
.map(s -> s.getEntity().getId()) // TODO OAF -> JSON |
|
55 |
.map(jsonFormat::printToString) |
|
56 |
// .map(s -> s.getEntity().getId()) // TODO OAF -> JSON |
|
52 | 57 |
.forEach(System.out::println); |
53 | 58 |
|
54 | 59 |
} |
modules/dnet-grid-application/trunk/pom.xml | ||
---|---|---|
79 | 79 |
<groupId>com.fasterxml.jackson.core</groupId> |
80 | 80 |
<artifactId>jackson-databind</artifactId> |
81 | 81 |
</dependency> |
82 |
<dependency> |
|
83 |
<groupId>com.googlecode.protobuf-java-format</groupId> |
|
84 |
<artifactId>protobuf-java-format</artifactId> |
|
85 |
<version>1.4</version> |
|
86 |
</dependency> |
|
82 | 87 |
</dependencies> |
83 | 88 |
|
84 | 89 |
<build> |
Also available in: Unified diff