Revision 48856
Added by Claudio Atzori about 7 years ago
modules/dnet-openaireplus-mapping-utils/tags/dnet-openaireplus-mapping-utils-6.0.4/src/main/java/eu/dnetlib/openaire/hadoop/utils/HBaseTableUtils.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.hadoop.utils; |
|
2 |
|
|
3 |
import java.util.Arrays; |
|
4 |
import java.util.Set; |
|
5 |
import java.util.stream.Collectors; |
|
6 |
import java.util.stream.Stream; |
|
7 |
|
|
8 |
import com.google.common.collect.Sets; |
|
9 |
import eu.dnetlib.data.proto.DatasourceOrganizationProtos.DatasourceOrganization.Provision; |
|
10 |
import eu.dnetlib.data.proto.DedupProtos.Dedup; |
|
11 |
import eu.dnetlib.data.proto.DedupSimilarityProtos.DedupSimilarity; |
|
12 |
import eu.dnetlib.data.proto.PersonPersonProtos.PersonPerson.CoAuthorship; |
|
13 |
import eu.dnetlib.data.proto.PersonResultProtos.PersonResult.Authorship; |
|
14 |
import eu.dnetlib.data.proto.ProjectOrganizationProtos.ProjectOrganization.Participation; |
|
15 |
import eu.dnetlib.data.proto.ProjectPersonProtos.ProjectPerson.ContactPerson; |
|
16 |
import eu.dnetlib.data.proto.RelTypeProtos.RelType; |
|
17 |
import eu.dnetlib.data.proto.RelTypeProtos.SubRelType; |
|
18 |
import eu.dnetlib.data.proto.ResultOrganizationProtos.ResultOrganization.Affiliation; |
|
19 |
import eu.dnetlib.data.proto.ResultProjectProtos.ResultProject.Outcome; |
|
20 |
import eu.dnetlib.data.proto.ResultResultProtos.ResultResult.*; |
|
21 |
import eu.dnetlib.data.proto.TypeProtos.Type; |
|
22 |
|
|
23 |
/** |
|
24 |
* Common static utility methods to manage the hbase tables |
|
25 |
* |
|
26 |
* @author claudio |
|
27 |
*/ |
|
28 |
public class HBaseTableUtils { |
|
29 |
|
|
30 |
private static final String SEPARATOR = "_"; |
|
31 |
|
|
32 |
public static Set<String> listAllColumns() { |
|
33 |
final Set<String> union = Sets.union(listEntities(), listRelationships()); |
|
34 |
return Sets.union(union, listDedupRelationships()); |
|
35 |
} |
|
36 |
|
|
37 |
private static Set<String> listDedupRelationships() { |
|
38 |
final Set<String> cfs = Sets.newHashSet(); |
|
39 |
cfs.add(RelType.organizationOrganization + SEPARATOR + SubRelType.dedup + SEPARATOR + Dedup.RelName.merges); |
|
40 |
cfs.add(RelType.organizationOrganization + SEPARATOR + SubRelType.dedup + SEPARATOR + Dedup.RelName.isMergedIn); |
|
41 |
cfs.add(RelType.organizationOrganization + SEPARATOR + SubRelType.dedupSimilarity + SEPARATOR + DedupSimilarity.RelName.isSimilarTo); |
|
42 |
|
|
43 |
cfs.add(RelType.personPerson + SEPARATOR + SubRelType.dedup + SEPARATOR + Dedup.RelName.merges); |
|
44 |
cfs.add(RelType.personPerson + SEPARATOR + SubRelType.dedup + SEPARATOR + Dedup.RelName.isMergedIn); |
|
45 |
cfs.add(RelType.personPerson + SEPARATOR + SubRelType.dedupSimilarity + SEPARATOR + DedupSimilarity.RelName.isSimilarTo); |
|
46 |
|
|
47 |
cfs.add(RelType.resultResult + SEPARATOR + SubRelType.dedup + SEPARATOR + Dedup.RelName.merges); |
|
48 |
cfs.add(RelType.resultResult + SEPARATOR + SubRelType.dedup + SEPARATOR + Dedup.RelName.isMergedIn); |
|
49 |
cfs.add(RelType.resultResult + SEPARATOR + SubRelType.dedupSimilarity + SEPARATOR + DedupSimilarity.RelName.isSimilarTo); |
|
50 |
|
|
51 |
return cfs; |
|
52 |
} |
|
53 |
|
|
54 |
private static Stream<String> types() { |
|
55 |
return Arrays.stream(Type.values()) |
|
56 |
.map(Enum::toString); |
|
57 |
} |
|
58 |
|
|
59 |
public static Set<String> listEntities() { |
|
60 |
return types() |
|
61 |
.collect(Collectors.toSet()); |
|
62 |
} |
|
63 |
|
|
64 |
public static Set<String> listRelationships() { |
|
65 |
final Set<String> cfs = Sets.newHashSet(); |
|
66 |
cfs.add(RelType.datasourceOrganization + SEPARATOR + SubRelType.provision + SEPARATOR + Provision.RelName.isProvidedBy); |
|
67 |
cfs.add(RelType.datasourceOrganization + SEPARATOR + SubRelType.provision + SEPARATOR + Provision.RelName.provides); |
|
68 |
|
|
69 |
cfs.add(RelType.personPerson + SEPARATOR + SubRelType.coauthorship + SEPARATOR + CoAuthorship.RelName.isCoauthorOf); |
|
70 |
|
|
71 |
cfs.add(RelType.personResult + SEPARATOR + SubRelType.authorship + SEPARATOR + Authorship.RelName.isAuthorOf); |
|
72 |
cfs.add(RelType.personResult + SEPARATOR + SubRelType.authorship + SEPARATOR + Authorship.RelName.hasAuthor); |
|
73 |
|
|
74 |
cfs.add(RelType.projectOrganization + SEPARATOR + SubRelType.participation + SEPARATOR + Participation.RelName.hasParticipant); |
|
75 |
cfs.add(RelType.projectOrganization + SEPARATOR + SubRelType.participation + SEPARATOR + Participation.RelName.isParticipant); |
|
76 |
|
|
77 |
cfs.add(RelType.projectPerson + SEPARATOR + SubRelType.contactPerson + SEPARATOR + ContactPerson.RelName.isContact); |
|
78 |
cfs.add(RelType.projectPerson + SEPARATOR + SubRelType.contactPerson + SEPARATOR + ContactPerson.RelName.hasContact); |
|
79 |
|
|
80 |
cfs.add(RelType.resultProject + SEPARATOR + SubRelType.outcome + SEPARATOR + Outcome.RelName.isProducedBy); |
|
81 |
cfs.add(RelType.resultProject + SEPARATOR + SubRelType.outcome + SEPARATOR + Outcome.RelName.produces); |
|
82 |
|
|
83 |
cfs.add(RelType.resultResult + SEPARATOR + SubRelType.similarity + SEPARATOR + Similarity.RelName.hasAmongTopNSimilarDocuments); |
|
84 |
cfs.add(RelType.resultResult + SEPARATOR + SubRelType.similarity + SEPARATOR + Similarity.RelName.isAmongTopNSimilarDocuments); |
|
85 |
|
|
86 |
cfs.add(RelType.resultResult + SEPARATOR + SubRelType.supplement + SEPARATOR + Supplement.RelName.isSupplementedBy); |
|
87 |
cfs.add(RelType.resultResult + SEPARATOR + SubRelType.supplement + SEPARATOR + Supplement.RelName.isSupplementTo); |
|
88 |
cfs.add(RelType.resultResult + SEPARATOR + SubRelType.part + SEPARATOR + Part.RelName.isPartOf); |
|
89 |
cfs.add(RelType.resultResult + SEPARATOR + SubRelType.part + SEPARATOR + Part.RelName.hasPart); |
|
90 |
|
|
91 |
cfs.add(RelType.resultResult + SEPARATOR + SubRelType.publicationDataset + SEPARATOR + PublicationDataset.RelName.isRelatedTo); |
|
92 |
|
|
93 |
cfs.add(RelType.resultOrganization + SEPARATOR + SubRelType.affiliation + SEPARATOR + Affiliation.RelName.isAuthorInstitutionOf); |
|
94 |
cfs.add(RelType.resultOrganization + SEPARATOR + SubRelType.affiliation + SEPARATOR + Affiliation.RelName.hasAuthorInstitution); |
|
95 |
|
|
96 |
cfs.add(RelType.resultResult + SEPARATOR + SubRelType.version + SEPARATOR + SoftwareSoftware.RelName.isVersionOf); |
|
97 |
cfs.add(RelType.resultResult + SEPARATOR + SubRelType.relationship + SEPARATOR + Relationship.RelName.isRelatedTo); |
|
98 |
|
|
99 |
return cfs; |
|
100 |
} |
|
101 |
|
|
102 |
} |
modules/dnet-openaireplus-mapping-utils/tags/dnet-openaireplus-mapping-utils-6.0.4/src/main/java/eu/dnetlib/openaire/exporter/model/Project.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.exporter.model; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import com.google.common.base.Splitter; |
|
7 |
import com.google.common.collect.Lists; |
|
8 |
import org.apache.commons.lang.StringUtils; |
|
9 |
|
|
10 |
/** |
|
11 |
* Created by claudio on 20/09/16. |
|
12 |
*/ |
|
13 |
public class Project { |
|
14 |
|
|
15 |
public static final String INFO_EU_REPO_GRANT_AGREEMENT = "info:eu-repo/grantAgreement/"; |
|
16 |
private String code; |
|
17 |
private String acronym; |
|
18 |
private String title; |
|
19 |
private String call_identifier; |
|
20 |
private String startdate; |
|
21 |
private String enddate; |
|
22 |
private boolean ec_sc39; |
|
23 |
private boolean oa_mandate_for_publications; |
|
24 |
private boolean ec_article29_3; |
|
25 |
private String fundingpathid; |
|
26 |
private String description; |
|
27 |
private String jurisdiction; |
|
28 |
private String legalname; |
|
29 |
private String funder; |
|
30 |
private String countryclass; |
|
31 |
private String role; |
|
32 |
private String firstname; |
|
33 |
private String secondnames; |
|
34 |
private String email; |
|
35 |
|
|
36 |
public Project() { |
|
37 |
} |
|
38 |
|
|
39 |
public String getIdnamespace() { |
|
40 |
String res = INFO_EU_REPO_GRANT_AGREEMENT + getFunder()+"/"; |
|
41 |
final String fundingProgram = asFundingProgram(getFundingpathid()); |
|
42 |
if (StringUtils.isNotBlank(fundingProgram)) { |
|
43 |
res += fundingProgram; |
|
44 |
} |
|
45 |
res += "/" + escapeCode(getCode()); |
|
46 |
if (StringUtils.isNotBlank(getJurisdiction())) { |
|
47 |
res += "/" + getJurisdiction(); |
|
48 |
} |
|
49 |
return res; |
|
50 |
} |
|
51 |
|
|
52 |
public String getListLabel() { |
|
53 |
return String.format("for:value:component:_%s_project_id", asFunder(getFunder())); |
|
54 |
} |
|
55 |
|
|
56 |
private String asFunder(final String legalshortname) { |
|
57 |
switch (legalshortname.toLowerCase()) { |
|
58 |
case "ec": |
|
59 |
return asFundingProgram(getFundingpathid()).toLowerCase(); |
|
60 |
default: |
|
61 |
return legalshortname.toLowerCase(); |
|
62 |
} |
|
63 |
} |
|
64 |
|
|
65 |
public List<String> asList() { |
|
66 |
return Lists.newArrayList( |
|
67 |
clean(getCode()), |
|
68 |
clean(getAcronym()), |
|
69 |
clean(getTitle()), |
|
70 |
clean(getCall_identifier()), |
|
71 |
clean(getStartdate()), |
|
72 |
clean(getEnddate()), |
|
73 |
String.valueOf(isEc_article29_3()), |
|
74 |
String.valueOf(isOa_mandate_for_publications()), |
|
75 |
String.valueOf(isEc_article29_3()), |
|
76 |
clean(getDescription()), |
|
77 |
clean(getLegalname()), |
|
78 |
clean(getCountryclass()), |
|
79 |
clean(getRole()), |
|
80 |
clean(getFirstname()), |
|
81 |
clean(getSecondnames()), |
|
82 |
clean(getEmail())); |
|
83 |
} |
|
84 |
|
|
85 |
private String clean(final String s) { |
|
86 |
return StringUtils.isNotBlank(s) ? "\"" + s.replaceAll("\\n|\\t|\\s+", " ").replace("\"","\"\"").trim() + "\"" : ""; |
|
87 |
} |
|
88 |
|
|
89 |
private String escapeCode(final String code) { |
|
90 |
return replaceSlash(code); |
|
91 |
} |
|
92 |
|
|
93 |
private String asFundingProgram(final String fundingpathid) { |
|
94 |
final ArrayList<String> strings = Lists.newArrayList(Splitter.on("::").split(fundingpathid)); |
|
95 |
if(strings.size() <= 1) throw new IllegalStateException("Unexpected funding id: "+fundingpathid); |
|
96 |
if(strings.size() == 2) return ""; |
|
97 |
else return replaceSlash(strings.get(2)); |
|
98 |
} |
|
99 |
|
|
100 |
private String replaceSlash(final String s) { |
|
101 |
return s.replaceAll("/", "%2F"); |
|
102 |
} |
|
103 |
|
|
104 |
public String getCode() { |
|
105 |
return code; |
|
106 |
} |
|
107 |
|
|
108 |
public Project setCode(final String code) { |
|
109 |
this.code = code; |
|
110 |
return this; |
|
111 |
} |
|
112 |
|
|
113 |
public String getAcronym() { |
|
114 |
return acronym; |
|
115 |
} |
|
116 |
|
|
117 |
public Project setAcronym(final String acronym) { |
|
118 |
this.acronym = acronym; |
|
119 |
return this; |
|
120 |
} |
|
121 |
|
|
122 |
public String getTitle() { |
|
123 |
return title; |
|
124 |
} |
|
125 |
|
|
126 |
public Project setTitle(final String title) { |
|
127 |
this.title = title; |
|
128 |
return this; |
|
129 |
} |
|
130 |
|
|
131 |
public String getCall_identifier() { |
|
132 |
return call_identifier; |
|
133 |
} |
|
134 |
|
|
135 |
public Project setCall_identifier(final String call_identifier) { |
|
136 |
this.call_identifier = call_identifier; |
|
137 |
return this; |
|
138 |
} |
|
139 |
|
|
140 |
public String getStartdate() { |
|
141 |
return startdate; |
|
142 |
} |
|
143 |
|
|
144 |
public Project setStartdate(final String startdate) { |
|
145 |
this.startdate = startdate; |
|
146 |
return this; |
|
147 |
} |
|
148 |
|
|
149 |
public String getEnddate() { |
|
150 |
return enddate; |
|
151 |
} |
|
152 |
|
|
153 |
public Project setEnddate(final String enddate) { |
|
154 |
this.enddate = enddate; |
|
155 |
return this; |
|
156 |
} |
|
157 |
|
|
158 |
public boolean isEc_sc39() { |
|
159 |
return ec_sc39; |
|
160 |
} |
|
161 |
|
|
162 |
public Project setEc_sc39(final boolean ec_sc39) { |
|
163 |
this.ec_sc39 = ec_sc39; |
|
164 |
return this; |
|
165 |
} |
|
166 |
|
|
167 |
public boolean isOa_mandate_for_publications() { |
|
168 |
return oa_mandate_for_publications; |
|
169 |
} |
|
170 |
|
|
171 |
public Project setOa_mandate_for_publications(final boolean oa_mandate_for_publications) { |
|
172 |
this.oa_mandate_for_publications = oa_mandate_for_publications; |
|
173 |
return this; |
|
174 |
} |
|
175 |
|
|
176 |
public boolean isEc_article29_3() { |
|
177 |
return ec_article29_3; |
|
178 |
} |
|
179 |
|
|
180 |
public Project setEc_article29_3(final boolean ec_article29_3) { |
|
181 |
this.ec_article29_3 = ec_article29_3; |
|
182 |
return this; |
|
183 |
} |
|
184 |
|
|
185 |
public String getFundingpathid() { |
|
186 |
return fundingpathid; |
|
187 |
} |
|
188 |
|
|
189 |
public Project setFundingpathid(final String fundingpathid) { |
|
190 |
this.fundingpathid = fundingpathid; |
|
191 |
return this; |
|
192 |
} |
|
193 |
|
|
194 |
public String getDescription() { |
|
195 |
return description; |
|
196 |
} |
|
197 |
|
|
198 |
public Project setDescription(final String description) { |
|
199 |
this.description = description; |
|
200 |
return this; |
|
201 |
} |
|
202 |
|
|
203 |
public String getJurisdiction() { |
|
204 |
return jurisdiction; |
|
205 |
} |
|
206 |
|
|
207 |
public Project setJurisdiction(final String jurisdiction) { |
|
208 |
this.jurisdiction = jurisdiction; |
|
209 |
return this; |
|
210 |
} |
|
211 |
|
|
212 |
public String getLegalname() { |
|
213 |
return legalname; |
|
214 |
} |
|
215 |
|
|
216 |
public Project setLegalname(final String legalname) { |
|
217 |
this.legalname = legalname; |
|
218 |
return this; |
|
219 |
} |
|
220 |
|
|
221 |
public String getCountryclass() { |
|
222 |
return countryclass; |
|
223 |
} |
|
224 |
|
|
225 |
public Project setCountryclass(final String countryclass) { |
|
226 |
this.countryclass = countryclass; |
|
227 |
return this; |
|
228 |
} |
|
229 |
|
|
230 |
public String getRole() { |
|
231 |
return role; |
|
232 |
} |
|
233 |
|
|
234 |
public Project setRole(final String role) { |
|
235 |
this.role = role; |
|
236 |
return this; |
|
237 |
} |
|
238 |
|
|
239 |
public String getFirstname() { |
|
240 |
return firstname; |
|
241 |
} |
|
242 |
|
|
243 |
public Project setFirstname(final String firstname) { |
|
244 |
this.firstname = firstname; |
|
245 |
return this; |
|
246 |
} |
|
247 |
|
|
248 |
public String getSecondnames() { |
|
249 |
return secondnames; |
|
250 |
} |
|
251 |
|
|
252 |
public Project setSecondnames(final String secondnames) { |
|
253 |
this.secondnames = secondnames; |
|
254 |
return this; |
|
255 |
} |
|
256 |
|
|
257 |
public String getEmail() { |
|
258 |
return email; |
|
259 |
} |
|
260 |
|
|
261 |
public Project setEmail(final String email) { |
|
262 |
this.email = email; |
|
263 |
return this; |
|
264 |
} |
|
265 |
|
|
266 |
public String getFunder() { |
|
267 |
return funder; |
|
268 |
} |
|
269 |
|
|
270 |
public Project setFunder(final String funder) { |
|
271 |
this.funder = funder; |
|
272 |
return this; |
|
273 |
} |
|
274 |
} |
modules/dnet-openaireplus-mapping-utils/tags/dnet-openaireplus-mapping-utils-6.0.4/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
3 |
<parent> |
|
4 |
<groupId>eu.dnetlib</groupId> |
|
5 |
<artifactId>dnet45-parent</artifactId> |
|
6 |
<version>1.0.0</version> |
|
7 |
<relativePath /> |
|
8 |
</parent> |
|
9 |
<modelVersion>4.0.0</modelVersion> |
|
10 |
<groupId>eu.dnetlib</groupId> |
|
11 |
<artifactId>dnet-openaireplus-mapping-utils</artifactId> |
|
12 |
<packaging>jar</packaging> |
|
13 |
<version>6.0.4</version> |
|
14 |
<scm> |
|
15 |
<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-openaireplus-mapping-utils/tags/dnet-openaireplus-mapping-utils-6.0.4</developerConnection> |
|
16 |
</scm> |
|
17 |
<dependencies> |
|
18 |
<dependency> |
|
19 |
<groupId>com.google.guava</groupId> |
|
20 |
<artifactId>guava</artifactId> |
|
21 |
<version>${google.guava.version}</version> |
|
22 |
</dependency> |
|
23 |
<dependency> |
|
24 |
<groupId>junit</groupId> |
|
25 |
<artifactId>junit</artifactId> |
|
26 |
<version>${junit.version}</version> |
|
27 |
<scope>test</scope> |
|
28 |
</dependency> |
|
29 |
<dependency> |
|
30 |
<groupId>commons-codec</groupId> |
|
31 |
<artifactId>commons-codec</artifactId> |
|
32 |
<version>${commons.codec.version}</version> |
|
33 |
</dependency> |
|
34 |
<dependency> |
|
35 |
<groupId>dom4j</groupId> |
|
36 |
<artifactId>dom4j</artifactId> |
|
37 |
<version>${dom4j.version}</version> |
|
38 |
<exclusions> |
|
39 |
<exclusion> |
|
40 |
<artifactId>xml-apis</artifactId> |
|
41 |
<groupId>xml-apis</groupId> |
|
42 |
</exclusion> |
|
43 |
</exclusions> |
|
44 |
</dependency> |
|
45 |
<dependency> |
|
46 |
<groupId>net.sf.supercsv</groupId> |
|
47 |
<artifactId>super-csv</artifactId> |
|
48 |
<version>2.4.0</version> |
|
49 |
</dependency> |
|
50 |
<dependency> |
|
51 |
<groupId>eu.dnetlib</groupId> |
|
52 |
<artifactId>dnet-openaire-data-protos</artifactId> |
|
53 |
<version>[3.7.8]</version> |
|
54 |
</dependency> |
|
55 |
<dependency> |
|
56 |
<groupId>eu.dnetlib</groupId> |
|
57 |
<artifactId>dnet-pace-core</artifactId> |
|
58 |
<version>[2.0.0,3.0.0)</version> |
|
59 |
</dependency> |
|
60 |
<dependency> |
|
61 |
<groupId>eu.dnetlib</groupId> |
|
62 |
<artifactId>cnr-misc-utils</artifactId> |
|
63 |
<version>[1.0.0,2.0.0)</version> |
|
64 |
</dependency> |
|
65 |
<dependency> |
|
66 |
<groupId>eu.dnetlib</groupId> |
|
67 |
<artifactId>dnet-hadoop-commons</artifactId> |
|
68 |
<version>[2.0.0,3.0.0)</version> |
|
69 |
</dependency> |
|
70 |
<dependency> |
|
71 |
<groupId>eu.dnetlib</groupId> |
|
72 |
<artifactId>dnet-index-solr-common</artifactId> |
|
73 |
<version>[1.0.0,2.0.0)</version> |
|
74 |
</dependency> |
|
75 |
<dependency> |
|
76 |
<groupId>com.googlecode.protobuf-java-format</groupId> |
|
77 |
<artifactId>protobuf-java-format</artifactId> |
|
78 |
<version>1.2</version> |
|
79 |
</dependency> |
|
80 |
<dependency> |
|
81 |
<groupId>eu.dnetlib</groupId> |
|
82 |
<artifactId>dnet-openaireplus-profiles</artifactId> |
|
83 |
<version>[1.0.0,2.0.0)</version> |
|
84 |
<scope>test</scope> |
|
85 |
</dependency> |
|
86 |
<dependency> |
|
87 |
<groupId>org.apache.commons</groupId> |
|
88 |
<artifactId>commons-lang3</artifactId> |
|
89 |
<version>3.5</version> |
|
90 |
</dependency> |
|
91 |
|
|
92 |
</dependencies> |
|
93 |
</project> |
modules/dnet-openaireplus-mapping-utils/tags/dnet-openaireplus-mapping-utils-6.0.4/src/test/java/eu/dnetlib/data/transform/xml/OpenTrialsXsltFunctionsTest.java | ||
---|---|---|
1 |
package eu.dnetlib.data.transform.xml; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import eu.dnetlib.data.transform.xml.OpenTrialsXsltFunctions.JsonProv; |
|
6 |
import org.junit.After; |
|
7 |
import org.junit.Before; |
|
8 |
import org.junit.Test; |
|
9 |
|
|
10 |
import static org.junit.Assert.assertEquals; |
|
11 |
|
|
12 |
|
|
13 |
/** |
|
14 |
* OpenTrialsXsltFunctions Tester. |
|
15 |
* |
|
16 |
*/ |
|
17 |
public class OpenTrialsXsltFunctionsTest { |
|
18 |
|
|
19 |
private String jsonProv = "[{\"url\" : \"http://apps.who.int/trialsearch/Trial3.aspx?trialid=NCT00378508\", \"sourceID\" : \"77eb42c5-0ec7-4e31-963a-5736b66f2d26\", \"sourceName\" : \"ictrp\"},{\"url\" : \"https://www.clinicaltrials.gov/ct2/show/NCT00378508?lup_e=02%2F04%2F2016&lup_s=01%2F01%2F2001&rank=175075&resultsxml=true\", \"sourceID\" : \"b389497c-0833-432b-a09b-930526b7b4d4\", \"sourceName\" : \"nct\"}]"; |
|
20 |
private String jsonProvWithNull = "[{\"url\" : \"\", \"sourceID\" : \"77eb42c5-0ec7-4e31-963a-5736b66f2d26\", \"sourceName\" : \"ictrp\"},{\"url\" : \"https://www.clinicaltrials.gov/ct2/show/NCT00378508?lup_e=02%2F04%2F2016&lup_s=01%2F01%2F2001&rank=175075&resultsxml=true\", \"sourceID\" : \"b389497c-0833-432b-a09b-930526b7b4d4\", \"sourceName\" : \"nct\"}]"; |
|
21 |
private String jidentifiers = "{112683,NCT00920439}"; |
|
22 |
|
|
23 |
|
|
24 |
private String jsonRecord = "[{\"source_id\" : \"nct\", \"source_url\" : \"https://clinicaltrials.gov/ct2/show/NCT02321059\", \"is_primary\" : true},{\"source_id\" : \"ictrp\", \"source_url\" : \"http://apps.who.int/trialsearch/Trial3.aspx?trialid=NCT02321059\", \"is_primary\" : false}]"; |
|
25 |
private String jsonRecordNull = "[{\"source_id\" : \"nct\", \"source_url\" : \"https://clinicaltrials.gov/ct2/show/NCT02321059\"},{\"source_id\" : \"ictrp\", \"source_url\" : \"http://apps.who.int/trialsearch/Trial3.aspx?trialid=NCT02321059\", \"is_primary\" : false}]"; |
|
26 |
private String jsonRecordVoid = "[{\"source_id\" : \"\", \"source_url\" : \"\", \"is_primary\" : \"\"}]"; |
|
27 |
private String jsonRecondPrimary = "[{\"source_id\" : \"nct\", \"source_url\" : \"https://clinicaltrials.gov/ct2/show/NCT02321059\", \"is_primary\" : false},{\"source_id\" : \"ictrp\", \"source_url\" : \"http://apps.who.int/trialsearch/Trial3.aspx?trialid=NCT02321059\", \"is_primary\" : false}]"; |
|
28 |
|
|
29 |
private String jsonPeopleVoid ="[{\"person_name\" : null, \"person_id\" : null, \"person_role\" : null}]"; |
|
30 |
private String jsonPeopleOne = "[{\"person_name\" : \"Henk Verheul, M.D., PhD\", \"person_id\" : \"116438e9-f8b1-46e5-a1f8-20f851cab73c\", \"person_role\" : \"principal_investigator\"}]"; |
|
31 |
private String jsonPeopleMore = "[{\"person_name\" : \"Henk Verheul, M.D., PhD\", \"person_id\" : \"116438e9-f8b1-46e5-a1f8-20f851cab73c\", \"person_role\" : \"principal_investigator\"},{\"person_name\" : \"Miriam Pippolippo Baglioni, PhD\", \"person_id\" : \"fake\", \"person_role\" : \"principal_investigator\"}]"; |
|
32 |
|
|
33 |
private String jsonOrganizationVoid = "[{\"organization_name\" : null, \"organization_id\" : null, \"organization_role\" : null}]"; |
|
34 |
private String jsonOrganizationOne = "[{\"organization_name\" : \"Södertälje sjukhus AB\", \"organization_id\" : \"15f0d004-b82b-408c-8605-38a57352468d\", \"organization_role\" : \"sponsor\"}]"; |
|
35 |
private String jsonOrganizationMore = "[{\"organization_name\" : \"Södertälje sjukhus AB\", \"organization_id\" : \"15f0d004-b82b-408c-8605-38a57352468d\", \"organization_role\" : \"sponsor\"},{\"organization_name\" : \"Miriam Baglioni AB\", \"organization_id\" : \"fake\", \"organization_role\" : \"primary_sponsor\"}]"; |
|
36 |
|
|
37 |
private String jsonLocationVoid = "[{\"location_name\" : null}]"; |
|
38 |
private String jsonLocationOne = "[{\"location_name\" : \"China\"}]"; |
|
39 |
private String jsonLocationMore = "[{\"location_name\" : \"China\"},{\"location_name\" : \"North Korea\"}]"; |
|
40 |
|
|
41 |
@Before |
|
42 |
public void before() throws Exception { |
|
43 |
} |
|
44 |
|
|
45 |
@After |
|
46 |
public void after() throws Exception { |
|
47 |
} |
|
48 |
|
|
49 |
/** |
|
50 |
* Method: getProvs(String jsonProvList) |
|
51 |
*/ |
|
52 |
@Test |
|
53 |
public void testGetProvs() throws Exception { |
|
54 |
List<JsonProv> list = OpenTrialsXsltFunctions.getProvs(jsonProv); |
|
55 |
assertEquals(2, list.size()); |
|
56 |
} |
|
57 |
|
|
58 |
/** |
|
59 |
* Method: getMainIdentifierURL(String jsonProvList) |
|
60 |
*/ |
|
61 |
@Test |
|
62 |
public void testGetMainIdentifierURL() throws Exception { |
|
63 |
String url = OpenTrialsXsltFunctions.getMainIdentifierURL(jsonProv); |
|
64 |
assertEquals( "http://apps.who.int/trialsearch/Trial3.aspx?trialid=NCT00378508", url ); |
|
65 |
url = OpenTrialsXsltFunctions.getMainIdentifierURL(jsonProvWithNull); |
|
66 |
assertEquals("https://www.clinicaltrials.gov/ct2/show/NCT00378508?lup_e=02%2F04%2F2016&lup_s=01%2F01%2F2001&rank=175075&resultsxml=true", url); |
|
67 |
} |
|
68 |
|
|
69 |
@Test |
|
70 |
public void testGetPrimaryRecordUrl(){ |
|
71 |
String url = OpenTrialsXsltFunctions.getPrimaryRecordUrl(jsonRecord); |
|
72 |
assertEquals("https://clinicaltrials.gov/ct2/show/NCT02321059", url); |
|
73 |
} |
|
74 |
|
|
75 |
@Test |
|
76 |
public void testGetPrimaryRecordID(){ |
|
77 |
String id = OpenTrialsXsltFunctions.getPrimaryRecordIdentifier(jsonRecord); |
|
78 |
assertEquals("nct", id); |
|
79 |
} |
|
80 |
|
|
81 |
@Test |
|
82 |
public void testGetPrimaryRecordUrlNull(){ |
|
83 |
String url = OpenTrialsXsltFunctions.getPrimaryRecordUrl(jsonRecordNull); |
|
84 |
assertEquals("https://clinicaltrials.gov/ct2/show/NCT02321059", url); |
|
85 |
} |
|
86 |
|
|
87 |
@Test |
|
88 |
public void testGetPrimaryRecordUrlVoid(){ |
|
89 |
String url = OpenTrialsXsltFunctions.getPrimaryRecordUrl(jsonRecordVoid); |
|
90 |
assertEquals("", url); |
|
91 |
} |
|
92 |
|
|
93 |
@Test |
|
94 |
public void testGetPrimaryRecordUrlNoPrimary(){ |
|
95 |
String url = OpenTrialsXsltFunctions.getPrimaryRecordUrl(jsonRecondPrimary); |
|
96 |
assertEquals("https://clinicaltrials.gov/ct2/show/NCT02321059", url); |
|
97 |
} |
|
98 |
@Test |
|
99 |
public void testGetPrimaryRecordIDNoPrimary(){ |
|
100 |
String id = OpenTrialsXsltFunctions.getPrimaryRecordIdentifier(jsonRecondPrimary); |
|
101 |
assertEquals("nct", id); |
|
102 |
} |
|
103 |
@Test |
|
104 |
public void testGetPrincipalInvestigatorsVoid(){ |
|
105 |
String url = OpenTrialsXsltFunctions.getPrincipalInvestigators(jsonPeopleVoid); |
|
106 |
assertEquals("",url); |
|
107 |
} |
|
108 |
|
|
109 |
|
|
110 |
@Test |
|
111 |
public void testGetPrincipalInvestigatorsOne(){ |
|
112 |
String url = OpenTrialsXsltFunctions.getPrincipalInvestigators(jsonPeopleOne); |
|
113 |
assertEquals("Verheul, Henk", url); |
|
114 |
} |
|
115 |
|
|
116 |
@Test |
|
117 |
public void testGetPrincipalInvestigatorsMore(){ |
|
118 |
String url = OpenTrialsXsltFunctions.getPrincipalInvestigators(jsonPeopleMore); |
|
119 |
assertEquals("Verheul, Henk@@Baglioni, Miriam Pippolippo", url); |
|
120 |
} |
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
@Test |
|
125 |
public void testgGetTrialOrganizationsVoid(){ |
|
126 |
String url = OpenTrialsXsltFunctions.getTrialOrganizations(jsonOrganizationVoid); |
|
127 |
assertEquals("",url); |
|
128 |
} |
|
129 |
|
|
130 |
|
|
131 |
@Test |
|
132 |
public void testgGetTrialOrganizationsOne(){ |
|
133 |
String url = OpenTrialsXsltFunctions.getTrialOrganizations(jsonOrganizationOne); |
|
134 |
assertEquals("Södertälje sjukhus AB@sponsor", url); |
|
135 |
} |
|
136 |
|
|
137 |
@Test |
|
138 |
public void testgGetTrialOrganizationsMore(){ |
|
139 |
String url = OpenTrialsXsltFunctions.getTrialOrganizations(jsonOrganizationMore); |
|
140 |
assertEquals("Södertälje sjukhus AB@sponsor@@Miriam Baglioni AB@sponsor", url); |
|
141 |
} |
|
142 |
|
|
143 |
@Test |
|
144 |
public void testgGetTrialLocationsVoid(){ |
|
145 |
String url = OpenTrialsXsltFunctions.getTrialLocations(jsonLocationVoid); |
|
146 |
assertEquals("",url); |
|
147 |
} |
|
148 |
|
|
149 |
|
|
150 |
@Test |
|
151 |
public void testgGetTrialLocationsOne(){ |
|
152 |
String url = OpenTrialsXsltFunctions.getTrialLocations(jsonLocationOne); |
|
153 |
assertEquals("China", url); |
|
154 |
} |
|
155 |
|
|
156 |
@Test |
|
157 |
public void testgGetTrialLocationsMore(){ |
|
158 |
String url = OpenTrialsXsltFunctions.getTrialLocations(jsonLocationMore); |
|
159 |
assertEquals("China@@North Korea", url); |
|
160 |
} |
|
161 |
|
|
162 |
@Test |
|
163 |
public void testGetNotPrimaryRecordUrlPrimary(){ |
|
164 |
String url = OpenTrialsXsltFunctions.getNotPrimaryRecordUrl(jsonRecondPrimary); |
|
165 |
assertEquals("http://apps.who.int/trialsearch/Trial3.aspx?trialid=NCT02321059", url); |
|
166 |
} |
|
167 |
|
|
168 |
@Test |
|
169 |
public void testGetNotPrimaryRecordUrlVoid(){ |
|
170 |
String url = OpenTrialsXsltFunctions.getNotPrimaryRecordUrl(jsonRecordVoid); |
|
171 |
assertEquals("", url); |
|
172 |
} |
|
173 |
|
|
174 |
@Test |
|
175 |
public void testGetNotPrimaryRecordUrl(){ |
|
176 |
String url = OpenTrialsXsltFunctions.getNotPrimaryRecordUrl(jsonRecord); |
|
177 |
assertEquals("http://apps.who.int/trialsearch/Trial3.aspx?trialid=NCT02321059", url); |
|
178 |
} |
|
179 |
|
|
180 |
|
|
181 |
} |
modules/dnet-openaireplus-mapping-utils/tags/dnet-openaireplus-mapping-utils-6.0.4/src/main/java/eu/dnetlib/pace/model/gt/GTAuthorMapper.java | ||
---|---|---|
1 |
package eu.dnetlib.pace.model.gt; |
|
2 |
|
|
3 |
import com.google.common.base.Function; |
|
4 |
import com.google.common.collect.Iterables; |
|
5 |
import eu.dnetlib.data.proto.FieldTypeProtos.DataInfo; |
|
6 |
import eu.dnetlib.data.proto.FieldTypeProtos.Qualifier; |
|
7 |
import eu.dnetlib.data.proto.FieldTypeProtos.StringField; |
|
8 |
import eu.dnetlib.data.proto.KindProtos.Kind; |
|
9 |
import eu.dnetlib.data.proto.OafProtos.Oaf; |
|
10 |
import eu.dnetlib.data.proto.OafProtos.OafEntity; |
|
11 |
import eu.dnetlib.data.proto.PersonProtos.Person; |
|
12 |
import eu.dnetlib.data.proto.PersonProtos.Person.CoAuthor; |
|
13 |
import eu.dnetlib.data.proto.PersonProtos.Person.MergedPerson; |
|
14 |
import eu.dnetlib.data.proto.PersonProtos.Person.Metadata; |
|
15 |
import eu.dnetlib.data.proto.TypeProtos.Type; |
|
16 |
import org.apache.commons.lang.StringUtils; |
|
17 |
|
|
18 |
public class GTAuthorMapper { |
|
19 |
|
|
20 |
public Oaf map(final GTAuthor gta) { |
|
21 |
|
|
22 |
final Oaf.Builder oaf = Oaf.newBuilder(); |
|
23 |
|
|
24 |
oaf.setDataInfo(getDataInfo()); |
|
25 |
oaf.setLastupdatetimestamp(System.currentTimeMillis()); |
|
26 |
oaf.setKind(Kind.entity); |
|
27 |
oaf.setEntity(getOafEntity(gta)); |
|
28 |
|
|
29 |
return oaf.build(); |
|
30 |
} |
|
31 |
|
|
32 |
private OafEntity getOafEntity(final GTAuthor gta) { |
|
33 |
final OafEntity.Builder entity = OafEntity.newBuilder(); |
|
34 |
entity.setType(Type.person); |
|
35 |
entity.setId(gta.getId()); |
|
36 |
entity.setPerson(getPerson(gta)); |
|
37 |
return entity.build(); |
|
38 |
} |
|
39 |
|
|
40 |
private Person getPerson(final GTAuthor gta) { |
|
41 |
final Person.Builder person = Person.newBuilder(); |
|
42 |
|
|
43 |
if (gta.getAuthor() != null) { |
|
44 |
final Person.Metadata.Builder m = Person.Metadata.newBuilder(); |
|
45 |
|
|
46 |
if (StringUtils.isNotBlank(gta.getAuthor().getFullname())) { |
|
47 |
m.setFullname(sf(gta.getAuthor().getFullname())); |
|
48 |
} |
|
49 |
if (StringUtils.isNotBlank(gta.getAuthor().getFirstname())) { |
|
50 |
m.setFirstname(sf(gta.getAuthor().getFirstname())); |
|
51 |
} |
|
52 |
if (StringUtils.isNotBlank(gta.getAuthor().getSecondnames())) { |
|
53 |
m.addSecondnames(sf(gta.getAuthor().getSecondnames())); |
|
54 |
} |
|
55 |
|
|
56 |
person.setMetadata(m.build()); |
|
57 |
} |
|
58 |
|
|
59 |
person.setAnchor(true); |
|
60 |
person.addAllMergedperson(Iterables.transform(gta.getMerged(), new Function<Author, MergedPerson>() { |
|
61 |
|
|
62 |
@Override |
|
63 |
public MergedPerson apply(final Author a) { |
|
64 |
final MergedPerson.Builder mp = MergedPerson.newBuilder(); |
|
65 |
mp.setId(a.getId()); |
|
66 |
mp.setMetadata(getMetadata(a)); |
|
67 |
return mp.build(); |
|
68 |
} |
|
69 |
|
|
70 |
})); |
|
71 |
|
|
72 |
person.addAllCoauthor(Iterables.transform(gta.getCoAuthors(), new Function<eu.dnetlib.pace.model.gt.CoAuthor, CoAuthor>() { |
|
73 |
|
|
74 |
@Override |
|
75 |
public CoAuthor apply(final eu.dnetlib.pace.model.gt.CoAuthor ca) { |
|
76 |
final CoAuthor.Builder coAuthor = CoAuthor.newBuilder(); |
|
77 |
coAuthor.setId(ca.getId()); |
|
78 |
if (StringUtils.isNotBlank(ca.getAnchorId())) { |
|
79 |
coAuthor.setAnchorId(ca.getAnchorId()); |
|
80 |
} |
|
81 |
coAuthor.setMetadata(getMetadata(ca)); |
|
82 |
return coAuthor.build(); |
|
83 |
} |
|
84 |
})); |
|
85 |
|
|
86 |
return person.build(); |
|
87 |
} |
|
88 |
|
|
89 |
private Metadata getMetadata(final Author a) { |
|
90 |
final Metadata.Builder m = Metadata.newBuilder(); |
|
91 |
m.setFullname(sf(a.getFullname())); |
|
92 |
if (a.isWellFormed()) { |
|
93 |
m.setFirstname(sf(a.getFirstname())); |
|
94 |
m.addSecondnames(sf(a.getSecondnames())); |
|
95 |
} |
|
96 |
return m.build(); |
|
97 |
} |
|
98 |
|
|
99 |
private DataInfo getDataInfo() { |
|
100 |
final DataInfo.Builder d = DataInfo.newBuilder(); |
|
101 |
d.setDeletedbyinference(false); |
|
102 |
d.setInferred(true); |
|
103 |
d.setTrust("0.5"); |
|
104 |
d.setInferenceprovenance("dedup-person-groundtruth"); |
|
105 |
d.setProvenanceaction(Qualifier.newBuilder().setClassid("").setClassname("").setSchemeid("").setSchemename("")); |
|
106 |
return d.build(); |
|
107 |
} |
|
108 |
|
|
109 |
private StringField sf(final String s) { |
|
110 |
final StringField.Builder sf = StringField.newBuilder(); |
|
111 |
sf.setValue(s); |
|
112 |
return sf.build(); |
|
113 |
} |
|
114 |
|
|
115 |
} |
modules/dnet-openaireplus-mapping-utils/tags/dnet-openaireplus-mapping-utils-6.0.4/src/test/java/eu/dnetlib/data/mapreduce/util/OafDecoderTest.java | ||
---|---|---|
1 |
package eu.dnetlib.data.mapreduce.util; |
|
2 |
|
|
3 |
import static org.junit.Assert.assertFalse; |
|
4 |
import static org.junit.Assert.assertNotNull; |
|
5 |
|
|
6 |
import java.util.List; |
|
7 |
|
|
8 |
import org.junit.Test; |
|
9 |
|
|
10 |
import eu.dnetlib.data.proto.KindProtos.Kind; |
|
11 |
import eu.dnetlib.miscutils.functional.xml.IndentXmlString; |
|
12 |
|
|
13 |
public class OafDecoderTest { |
|
14 |
|
|
15 |
@Test |
|
16 |
public void testAsXml() { |
|
17 |
|
|
18 |
final OafDecoder decoder = OafTest.embed(OafTest.getResult("50|id_1"), Kind.entity); |
|
19 |
|
|
20 |
assertNotNull(decoder); |
|
21 |
|
|
22 |
assertNotNull(decoder.asXml()); |
|
23 |
|
|
24 |
System.out.println(IndentXmlString.apply(decoder.asXml())); |
|
25 |
|
|
26 |
} |
|
27 |
|
|
28 |
@Test |
|
29 |
public void testGetFieldValues() { |
|
30 |
final OafDecoder decoder = OafTest.embed(OafTest.getResult("50|id_1"), Kind.entity); |
|
31 |
|
|
32 |
final String path = "result/metadata/title/value"; |
|
33 |
final List<String> titles = decoder.decodeEntity().getFieldValues(path); |
|
34 |
|
|
35 |
assertNotNull(titles); |
|
36 |
assertFalse(titles.isEmpty()); |
|
37 |
} |
|
38 |
} |
modules/dnet-openaireplus-mapping-utils/tags/dnet-openaireplus-mapping-utils-6.0.4/src/main/resources/eu/dnetlib/actionmanager/xslt/rels2actions.xslt | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
|
3 |
xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dr="http://www.driver-repository.eu/namespace/dr" |
|
4 |
xmlns:dri="http://www.driver-repository.eu/namespace/dri" xmlns:oaa="http://namespace.openaire.eu/oaa" |
|
5 |
xmlns:oaf="http://namespace.openaire.eu/oaf" xmlns:dnet="eu.dnetlib.data.transform.xml.OafToHbaseXsltFunctions" |
|
6 |
xmlns:exslt="http://exslt.org/common" |
|
7 |
xmlns:action="http://namespace.openaire.eu/action" version="1.0" |
|
8 |
extension-element-prefixes="exslt" |
|
9 |
exclude-result-prefixes="xsl dc dr dri oaa oaf dnet exslt"> |
|
10 |
|
|
11 |
<xsl:output omit-xml-declaration="yes" indent="yes" /> |
|
12 |
|
|
13 |
<xsl:param name="trust" select="string('0.9')" /> |
|
14 |
<xsl:param name="provenance" select="string('UNKNOWN')" /> |
|
15 |
|
|
16 |
<xsl:template match="/*"> |
|
17 |
|
|
18 |
<xsl:choose> |
|
19 |
<xsl:when test="count(//RELATION) = 0"> |
|
20 |
<ACTIONS /> |
|
21 |
</xsl:when> |
|
22 |
<xsl:otherwise> |
|
23 |
<ACTIONS> |
|
24 |
<xsl:for-each select="//RELATION"> |
|
25 |
<xsl:choose> |
|
26 |
<xsl:when test="./@type = 'resultProject'"> |
|
27 |
<xsl:variable name="resultId" select="./@source" /> |
|
28 |
<xsl:variable name="projectId"> |
|
29 |
<xsl:choose> |
|
30 |
<xsl:when test="starts-with(@target, '40|')"> |
|
31 |
<xsl:value-of select="./@target" /> |
|
32 |
</xsl:when> |
|
33 |
<xsl:otherwise> |
|
34 |
<xsl:value-of select="dnet:oafSplitId('project', normalize-space(@target))"/> |
|
35 |
</xsl:otherwise> |
|
36 |
</xsl:choose> |
|
37 |
</xsl:variable> |
|
38 |
|
|
39 |
<ACTION targetKey="{$resultId}" targetColumnFamily="resultProject_outcome_isProducedBy" targetColumn="{$projectId}"> |
|
40 |
<xsl:value-of select="dnet:rel($resultId, $projectId, 'resultProject', 'outcome', 'isProducedBy', $provenance, $trust)" /> |
|
41 |
</ACTION> |
|
42 |
<ACTION targetKey="{$projectId}" targetColumnFamily="resultProject_outcome_produces" targetColumn="{$resultId}"> |
|
43 |
<xsl:value-of select="dnet:rel($projectId, $resultId, 'resultProject', 'outcome', 'produces', $provenance, $trust)" /> |
|
44 |
</ACTION> |
|
45 |
</xsl:when> |
|
46 |
|
|
47 |
<!-- TODO: check this block, it caused problems: |
|
48 |
Cannot convert argument/return type in call to method 'eu.dnetlib.actionmanager.actions.infopackage.DMFInfoPackageToHbaseXsltFunctions.oafPersonResultFromInfoPackage(node-set, node-set, result-tree, reference, reference)' |
|
49 |
FATAL ERROR: 'Could not compile stylesheet' |
|
50 |
|
|
51 |
<xsl:when test="./@type = 'personResult'"> |
|
52 |
<xsl:variable name="personId" select="./@source" /> |
|
53 |
<xsl:variable name="resultId" select="./@target" /> |
|
54 |
|
|
55 |
<xsl:variable name="pos"> |
|
56 |
<xsl:choose> |
|
57 |
<xsl:when test="@position"><xsl:value-of select="@position"/></xsl:when> |
|
58 |
<xsl:otherwise>1000</xsl:otherwise> |
|
59 |
</xsl:choose> |
|
60 |
</xsl:variable> |
|
61 |
|
|
62 |
<ACTION targetKey="{$personId}" targetColumnFamily="personResult" targetColumn="{$resultId}"> |
|
63 |
<xsl:value-of select="dnet:oafPersonResultFromInfoPackage($personId, $resultId, $pos, $provenance, $trust)" /> |
|
64 |
</ACTION> |
|
65 |
<ACTION targetKey="{$resultId}" targetColumnFamily="personResult" targetColumn="{$personId}"> |
|
66 |
<xsl:value-of select="dnet:oafPersonResultFromInfoPackage($resultId, $personId, $pos, $provenance, $trust)" /> |
|
67 |
</ACTION> |
|
68 |
</xsl:when> |
|
69 |
--> |
|
70 |
</xsl:choose> |
|
71 |
</xsl:for-each> |
|
72 |
</ACTIONS> |
|
73 |
</xsl:otherwise> |
|
74 |
</xsl:choose> |
|
75 |
</xsl:template> |
|
76 |
|
|
77 |
</xsl:stylesheet> |
modules/dnet-openaireplus-mapping-utils/tags/dnet-openaireplus-mapping-utils-6.0.4/src/test/java/eu/dnetlib/openaire/exporter/model/ProjectDetailTest.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.exporter.model; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.io.StringReader; |
|
5 |
|
|
6 |
import com.google.common.collect.Lists; |
|
7 |
import org.apache.commons.io.IOUtils; |
|
8 |
import org.springframework.core.io.ClassPathResource; |
|
9 |
import org.springframework.core.io.Resource; |
|
10 |
|
|
11 |
import static org.junit.Assert.assertEquals; |
|
12 |
|
|
13 |
/** |
|
14 |
* Created by claudio on 22/09/16. |
|
15 |
*/ |
|
16 |
public class ProjectDetailTest { |
|
17 |
|
|
18 |
private Resource projectsCsv = new ClassPathResource("/eu/dnetlib/openaire/exporter/model/projectDetails.csv"); |
|
19 |
private Resource projectsJson = new ClassPathResource("/eu/dnetlib/openaire/exporter/model/projectDetails.json"); |
|
20 |
|
|
21 |
//@Test |
|
22 |
public void testSerialisationCSV() throws IOException { |
|
23 |
final String csv = IOUtils.toString(projectsCsv.getInputStream()); |
|
24 |
doTest(csv, "csv"); |
|
25 |
} |
|
26 |
|
|
27 |
//@Test |
|
28 |
public void testSerialisationCSV2() throws IOException { |
|
29 |
final ProjectDetail p = new ProjectDetail() |
|
30 |
.setAcronym("acro") |
|
31 |
.setCode("01") |
|
32 |
.setOptional1("op1") |
|
33 |
.setOptional2("op2") |
|
34 |
.setProjectId("project_01") |
|
35 |
.setJsonextrainfo("extraInfo") |
|
36 |
.setFundingPath(Lists.newArrayList("fundingpath1", "fundingpath2")); |
|
37 |
|
|
38 |
doTest(p.asCSV(), "csv"); |
|
39 |
} |
|
40 |
|
|
41 |
//@Test |
|
42 |
public void testSerialisationJSON() throws IOException { |
|
43 |
final String json = IOUtils.toString(projectsJson.getInputStream()); |
|
44 |
doTest(json, "json"); |
|
45 |
} |
|
46 |
|
|
47 |
private void doTest(final String data, final String format) throws IOException { |
|
48 |
final StringReader reader = new StringReader(data); |
|
49 |
for(String line : IOUtils.readLines(reader)) { |
|
50 |
System.out.println("line: " + line); |
|
51 |
ProjectDetail p; |
|
52 |
String s = ""; |
|
53 |
switch (format) { |
|
54 |
case "csv": |
|
55 |
p = ProjectDetail.fromCSV(line); |
|
56 |
s = p.asCSV(); |
|
57 |
break; |
|
58 |
case "json": |
|
59 |
p = ProjectDetail.fromJson(line); |
|
60 |
s = p.asJson(); |
|
61 |
break; |
|
62 |
default: throw new IllegalArgumentException("invalid format: " + format); |
|
63 |
} |
|
64 |
System.out.println("serialisation: " + s); |
|
65 |
assertEquals(s, line); |
|
66 |
} |
|
67 |
} |
|
68 |
|
|
69 |
} |
modules/dnet-openaireplus-mapping-utils/tags/dnet-openaireplus-mapping-utils-6.0.4/src/test/java/eu/dnetlib/pace/model/ProtoDocumentBuilderTest.java | ||
---|---|---|
1 |
package eu.dnetlib.pace.model; |
|
2 |
|
|
3 |
import static org.junit.Assert.assertFalse; |
|
4 |
import static org.junit.Assert.assertTrue; |
|
5 |
|
|
6 |
import org.junit.Test; |
|
7 |
|
|
8 |
import com.google.common.collect.Iterables; |
|
9 |
import com.google.common.collect.Sets; |
|
10 |
import com.google.common.collect.Sets.SetView; |
|
11 |
|
|
12 |
import eu.dnetlib.pace.AbstractProtoPaceTest; |
|
13 |
import eu.dnetlib.pace.config.Config; |
|
14 |
|
|
15 |
public class ProtoDocumentBuilderTest extends AbstractProtoPaceTest { |
|
16 |
|
|
17 |
@Test |
|
18 |
public void test_serialise1() { |
|
19 |
|
|
20 |
final String id = "12345"; |
|
21 |
|
|
22 |
final Config config = getResultFullConf(); |
|
23 |
|
|
24 |
final MapDocument document = ProtoDocumentBuilder.newInstance(id, getResult(id), config.model()); |
|
25 |
|
|
26 |
assertFalse(document.fieldNames().isEmpty()); |
|
27 |
assertFalse(Iterables.isEmpty(document.fields())); |
|
28 |
|
|
29 |
System.out.println("original:\n" + document); |
|
30 |
|
|
31 |
final String stringDoc = MapDocumentSerializer.toString(document); |
|
32 |
|
|
33 |
System.out.println("srialization:\n" + stringDoc); |
|
34 |
|
|
35 |
final MapDocument decoded = MapDocumentSerializer.decode(stringDoc.getBytes()); |
|
36 |
|
|
37 |
final SetView<String> diff = Sets.difference(document.fieldNames(), decoded.fieldNames()); |
|
38 |
|
|
39 |
assertTrue(diff.isEmpty()); |
|
40 |
|
|
41 |
System.out.println("decoded:\n" + decoded); |
|
42 |
} |
|
43 |
|
|
44 |
@Test |
|
45 |
public void test_serialise2() { |
|
46 |
|
|
47 |
final String id = "12345"; |
|
48 |
final String path = "/eu/dnetlib/pace/model/gt.author.manghi1.json"; |
|
49 |
|
|
50 |
final Config config = getPersonConf(); |
|
51 |
|
|
52 |
final MapDocument document = ProtoDocumentBuilder.newInstance(id, getPersonGT(path).getEntity(), config.model()); |
|
53 |
|
|
54 |
assertFalse(document.fieldNames().isEmpty()); |
|
55 |
assertFalse(Iterables.isEmpty(document.fields())); |
|
56 |
|
|
57 |
System.out.println("original:\n" + document); |
|
58 |
|
|
59 |
final String stringDoc = MapDocumentSerializer.toString(document); |
|
60 |
|
|
61 |
System.out.println("srialization:\n" + stringDoc); |
|
62 |
|
|
63 |
final MapDocument decoded = MapDocumentSerializer.decode(stringDoc.getBytes()); |
|
64 |
|
|
65 |
final SetView<String> diff = Sets.difference(document.fieldNames(), decoded.fieldNames()); |
|
66 |
|
|
67 |
assertTrue(diff.isEmpty()); |
|
68 |
|
|
69 |
System.out.println("decoded:\n" + decoded); |
|
70 |
} |
|
71 |
|
|
72 |
} |
modules/dnet-openaireplus-mapping-utils/tags/dnet-openaireplus-mapping-utils-6.0.4/src/main/resources/eu/dnetlib/actionmanager/xslt/dmf2insertActions.xslt | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
|
3 |
xmlns:oaf="http://namespace.openaire.eu/oaf" xmlns:dc="http://purl.org/dc/elements/1.1/" |
|
4 |
xmlns:dri="http://www.driver-repository.eu/namespace/dri" xmlns:dr="http://www.driver-repository.eu/namespace/dr" |
|
5 |
xmlns:dnet="eu.dnetlib.data.transform.xml.OafToHbaseXsltFunctions" |
|
6 |
xmlns:exslt="http://exslt.org/common" |
|
7 |
version="1.0" extension-element-prefixes="exslt" |
|
8 |
exclude-result-prefixes="xsl oaf dr dri dnet exslt"> |
|
9 |
|
|
10 |
<xsl:output omit-xml-declaration="yes" indent="yes"/> |
|
11 |
|
|
12 |
<xsl:param name="writeCoAuthors" select="false()"/> |
|
13 |
|
|
14 |
<xsl:param name="trust" select="string('0.9')"/> |
|
15 |
<xsl:param name="provenance" select="string('sysimport:crosswalk:repository')"/> |
|
16 |
|
|
17 |
<xsl:template match="/*"> |
|
18 |
<xsl:variable name="about" select="/*[local-name() = 'record']/*[local-name() = 'about']"/> |
|
19 |
<xsl:variable name="dateofcollection" select="/*[local-name() = 'record']/*[local-name() = 'header']/*[local-name()='dateOfCollection' and text()][1]"/> |
|
20 |
<xsl:variable name="dateoftransformation" select="/*[local-name() = 'record']/*[local-name() = 'header']/*[local-name()='dateOfTransformation' and text()][1]"/> |
|
21 |
<xsl:variable name="metadata" select="exslt:node-set(/*[local-name() = 'record']/*[local-name()='metadata']/*)"/> |
|
22 |
<xsl:variable name="namespaceprefix"> |
|
23 |
<xsl:choose> |
|
24 |
|
|
25 |
<!-- TODO check namespaceprefix length is 12 --> |
|
26 |
<xsl:when test="string-length(//oaf:datasourceprefix) > 0"> |
|
27 |
<xsl:value-of select="//oaf:datasourceprefix"/> |
|
28 |
</xsl:when> |
|
29 |
<xsl:otherwise> |
|
30 |
<xsl:value-of select="unknown_"/> |
|
31 |
</xsl:otherwise> |
|
32 |
</xsl:choose> |
|
33 |
</xsl:variable> |
|
34 |
|
|
35 |
<xsl:choose> |
|
36 |
<!-- <xsl:when test="count($metadata) = 0 or string-length($namespaceprefix) = 0"> --> |
|
37 |
<xsl:when test="count($metadata) = 0"> |
|
38 |
<ROWS/> |
|
39 |
</xsl:when> |
|
40 |
<xsl:otherwise> |
|
41 |
|
|
42 |
<xsl:variable name="objIdentifier" select="//dri:objIdentifier"/> |
|
43 |
<xsl:variable name="resultId" select="dnet:oafSimpleId('result', //dri:objIdentifier)"/> |
|
44 |
|
|
45 |
<xsl:if test="string-length($resultId) > 0"> |
|
46 |
|
|
47 |
<xsl:variable name="collectedfromid" select="dnet:oafSplitId('datasource', //oaf:collectedFrom/@id)"/> |
|
48 |
<xsl:variable name="collectedfromname" select="//oaf:collectedFrom/@name"/> |
|
49 |
|
|
50 |
<xsl:variable name="hostedbyid" select="dnet:oafSplitId('datasource', //oaf:hostedBy/@id)"/> |
|
51 |
<xsl:variable name="hostedbyname" select="//oaf:hostedBy/@name"/> |
|
52 |
|
|
53 |
<xsl:variable name="originalidTest" select="/*[local-name()='record']/*[local-name() = 'header']/*[local-name() = 'recordIdentifier']"/> |
|
54 |
<xsl:variable name="originalid"> |
|
55 |
<xsl:choose> |
|
56 |
<xsl:when test="contains($originalidTest, '::')"> |
|
57 |
<xsl:value-of select="substring-after($originalidTest, '::')"/> |
|
58 |
</xsl:when> |
|
59 |
<xsl:otherwise> |
|
60 |
<xsl:value-of select="$originalidTest"/> |
|
61 |
</xsl:otherwise> |
|
62 |
</xsl:choose> |
|
63 |
</xsl:variable> |
|
64 |
|
|
65 |
<xsl:variable name="result" |
|
66 |
select="dnet:oafResult($resultId, $provenance, $trust, $about, $hostedbyid, $hostedbyname, $collectedfromid, |
|
67 |
$collectedfromname, $originalid, $dateofcollection, $dateoftransformation, $metadata)"/> |
|
68 |
|
|
69 |
<ROWS> |
|
70 |
<ROW key="{$resultId}" columnFamily="result"> |
|
71 |
<QUALIFIER name="body" type="base64"> |
|
72 |
<xsl:value-of select="$result"/> |
|
73 |
</QUALIFIER> |
|
74 |
</ROW> |
|
75 |
|
|
76 |
<xsl:for-each select="//*[local-name()='projectid']"> |
|
77 |
|
|
78 |
<xsl:variable name="projectId" select="dnet:oafSplitId('project', normalize-space(.))"/> |
|
79 |
|
|
80 |
<xsl:if test="string-length($projectId) > 0"> |
|
81 |
|
|
82 |
<xsl:variable name="resultproject" |
|
83 |
select="dnet:rel($resultId, $projectId, 'resultProject', 'outcome', 'isProducedBy', |
|
84 |
$collectedfromid, $collectedfromname, $provenance, $trust, $about)"/> |
|
85 |
<xsl:variable name="projectresult" |
|
86 |
select="dnet:rel($projectId, $resultId, 'resultProject', 'outcome', 'produces', |
|
87 |
$collectedfromid, $collectedfromname, $provenance, $trust, $about)"/> |
|
88 |
|
|
89 |
<ROW key="{$resultId}" columnFamily="resultProject_outcome_isProducedBy"> |
|
90 |
<QUALIFIER name="{$projectId}" type="base64"> |
|
91 |
<xsl:value-of select="$resultproject"/> |
|
92 |
</QUALIFIER> |
|
93 |
</ROW> |
|
94 |
<ROW key="{$projectId}" columnFamily="resultProject_outcome_produces"> |
|
95 |
<QUALIFIER name="{$resultId}" type="base64"> |
|
96 |
<xsl:value-of select="$projectresult"/> |
|
97 |
</QUALIFIER> |
|
98 |
</ROW> |
|
99 |
</xsl:if> |
|
100 |
</xsl:for-each> |
|
101 |
|
|
102 |
<xsl:for-each select="//*[local-name()='relatedDataset']"> |
|
103 |
|
|
104 |
<!-- relatedDataset ids must be in the openaire format --> |
|
105 |
<xsl:variable name="datasetId" select="dnet:oafSimpleId('result', normalize-space(./@id))"/> |
|
106 |
|
|
107 |
<xsl:if test="string-length($datasetId) > 0"> |
|
108 |
|
|
109 |
<xsl:variable name="resultDataset" |
|
110 |
select="dnet:rel($resultId, $datasetId, 'resultResult', 'publicationDataset', 'isRelatedTo', |
|
111 |
$collectedfromid, $collectedfromname, $provenance, $trust, $about)"/> |
|
112 |
<xsl:variable name="datasetResult" |
|
113 |
select="dnet:rel($datasetId, $resultId, 'resultResult', 'publicationDataset', 'isRelatedTo', |
|
114 |
$collectedfromid, $collectedfromname, $provenance, $trust, $about)"/> |
|
115 |
|
|
116 |
<ROW key="{$resultId}" columnFamily="resultResult_publicationDataset_isRelatedTo"> |
|
117 |
<QUALIFIER name="{$datasetId}" type="base64"> |
|
118 |
<xsl:value-of select="$resultDataset"/> |
|
119 |
</QUALIFIER> |
|
120 |
</ROW> |
|
121 |
<ROW key="{$datasetId}" columnFamily="resultResult_publicationDataset_isRelatedTo"> |
|
122 |
<QUALIFIER name="{$resultId}" type="base64"> |
|
123 |
<xsl:value-of select="$datasetResult"/> |
|
124 |
</QUALIFIER> |
|
125 |
</ROW> |
|
126 |
</xsl:if> |
|
127 |
</xsl:for-each> |
|
128 |
|
|
129 |
<xsl:for-each select="//*[local-name()='creator']"> |
|
130 |
|
|
131 |
<xsl:if test="string-length(normalize-space(.)) > 0"> |
|
132 |
<xsl:variable name="originalPersonId"> |
|
133 |
<xsl:choose> |
|
134 |
<xsl:when test="string-length(@nameIdentifier) > 0"> |
|
135 |
<xsl:value-of select="normalize-space(@nameIdentifier)"/> |
|
136 |
</xsl:when> |
|
137 |
<xsl:otherwise> |
|
138 |
<xsl:value-of select="concat($originalid, '::', normalize-space(.))"/> |
|
139 |
</xsl:otherwise> |
|
140 |
</xsl:choose> |
|
141 |
</xsl:variable> |
|
142 |
|
|
143 |
<xsl:variable name="personId" select="dnet:oafId('person', $namespaceprefix, $originalPersonId)"/> |
|
144 |
<xsl:variable name="position" select="position()"/> |
|
145 |
|
|
146 |
<xsl:variable name="person" |
|
147 |
select="dnet:person($personId, $about, $provenance, $trust, $collectedfromid, $collectedfromname, |
|
148 |
$originalPersonId, $dateofcollection, $dateoftransformation, normalize-space(.), @nameIdentifier, @nameIdentifierScheme)"/> |
|
149 |
<xsl:variable name="personresult" |
|
150 |
select="dnet:personResult_Authorship($personId, $resultId, $position, 'isAuthorOf', |
|
151 |
$collectedfromid, $collectedfromname, $provenance, $trust, $about)"/> |
|
152 |
<xsl:variable name="resultperson" |
|
153 |
select="dnet:personResult_Authorship($resultId, $personId, $position, 'hasAuthor', |
|
154 |
$collectedfromid, $collectedfromname, $provenance, $trust, $about)"/> |
|
155 |
|
|
156 |
<xsl:if test="string-length($personId) > 0"> |
|
157 |
<ROW key="{$personId}" columnFamily="person"> |
|
158 |
<QUALIFIER name="body" type="base64"> |
|
159 |
<xsl:value-of select="$person"/> |
|
160 |
</QUALIFIER> |
|
161 |
</ROW> |
|
162 |
<ROW key="{$personId}" columnFamily="personResult_authorship_isAuthorOf"> |
|
163 |
<QUALIFIER name="{$resultId}" type="base64"> |
|
164 |
<xsl:value-of select="$personresult"/> |
|
165 |
</QUALIFIER> |
|
166 |
</ROW> |
|
167 |
<ROW key="{$resultId}" columnFamily="personResult_authorship_hasAuthor"> |
|
168 |
<QUALIFIER name="{$personId}" type="base64"> |
|
169 |
<xsl:value-of select="$resultperson"/> |
|
170 |
</QUALIFIER> |
|
171 |
</ROW> |
|
172 |
</xsl:if> |
|
173 |
|
|
174 |
<!-- COAUTHORS --> |
|
175 |
<xsl:if test="$writeCoAuthors = true()"> |
|
176 |
<xsl:for-each select="../dc:creator"> |
|
177 |
<xsl:if test="$position != position()"> |
|
178 |
|
|
179 |
<xsl:variable name="originalCoauthorId"> |
|
180 |
<xsl:choose> |
|
181 |
<xsl:when test="string-length(@nameIdentifier) > 0"> |
|
182 |
<xsl:value-of select="normalize-space(@nameIdentifier)"/> |
|
183 |
</xsl:when> |
|
184 |
<xsl:otherwise> |
|
185 |
<xsl:value-of select="concat($originalid, '::', normalize-space(.))"/> |
|
186 |
</xsl:otherwise> |
|
187 |
</xsl:choose> |
|
188 |
</xsl:variable> |
|
189 |
|
|
190 |
<xsl:variable name="coauthorId" |
|
191 |
select="dnet:oafId('person', $namespaceprefix, $originalCoauthorId)"/> |
|
192 |
|
|
193 |
<xsl:variable name="personperson" |
|
194 |
select="dnet:rel($personId, $coauthorId, 'personPerson', 'coauthorship', 'isCoAuthorOf', |
|
195 |
$collectedfromid, $collectedfromname, $provenance, $trust, $about)"/> |
|
196 |
|
|
197 |
<ROW key="{$personId}" columnFamily="personPerson_coAuthorship_isCoAuthorOf"> |
|
198 |
<QUALIFIER name="{$coauthorId}" type="base64"> |
|
199 |
<xsl:value-of select="$personperson"/> |
|
200 |
</QUALIFIER> |
|
201 |
</ROW> |
|
202 |
</xsl:if> |
|
203 |
</xsl:for-each> |
|
204 |
</xsl:if> |
|
205 |
<!-- / COAUTHORS --> |
|
206 |
</xsl:if> |
|
207 |
</xsl:for-each> |
|
208 |
|
|
209 |
</ROWS> |
|
210 |
</xsl:if> |
|
211 |
</xsl:otherwise> |
|
212 |
</xsl:choose> |
|
213 |
</xsl:template> |
|
214 |
</xsl:stylesheet> |
modules/dnet-openaireplus-mapping-utils/tags/dnet-openaireplus-mapping-utils-6.0.4/src/test/java/eu/dnetlib/openaire/exporter/model/ProjectTest.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.exporter.model; |
|
2 |
|
|
3 |
import org.junit.Before; |
|
4 |
import org.junit.Test; |
|
5 |
|
|
6 |
import static org.junit.Assert.assertEquals; |
|
7 |
|
|
8 |
public class ProjectTest { |
|
9 |
|
|
10 |
Project pMZOS; |
|
11 |
Project pFP7; |
|
12 |
|
|
13 |
@Before |
|
14 |
public void setUp() throws Exception { |
|
15 |
pMZOS = new Project() |
|
16 |
.setFunder("MZOS") |
|
17 |
.setJurisdiction("HR") |
|
18 |
.setFundingpathid("irb_hr______::MZOS") |
|
19 |
.setAcronym("") |
|
20 |
.setTitle("Project Title") |
|
21 |
.setCode("115-1152437-2500") |
|
22 |
.setStartdate("2007-01-01") |
|
23 |
.setEnddate("2009-01-01"); |
|
24 |
|
|
25 |
pFP7 = new Project() |
|
26 |
.setFunder("EC") |
|
27 |
.setJurisdiction("EU") |
|
28 |
.setFundingpathid("ec__________::EC::FP7::SP1::NMP") |
|
29 |
.setAcronym("REFFIBRE") |
|
30 |
.setTitle("Project Title") |
|
31 |
.setCode("604187") |
|
32 |
.setStartdate("2013-11-01") |
|
33 |
.setEnddate("20015-01-01"); |
|
34 |
} |
|
35 |
|
|
36 |
@Test |
|
37 |
public void testIdNamespaceMZOS(){ |
|
38 |
String ns = pMZOS.getIdnamespace(); |
|
39 |
assertEquals("info:eu-repo/grantAgreement/MZOS//115-1152437-2500/HR", ns); |
|
40 |
} |
|
41 |
|
|
42 |
@Test |
|
43 |
public void testIdNamespaceFP7(){ |
|
44 |
String ns = pFP7.getIdnamespace(); |
|
45 |
assertEquals("info:eu-repo/grantAgreement/EC/FP7/604187/EU", ns); |
|
46 |
} |
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
} |
modules/dnet-openaireplus-mapping-utils/tags/dnet-openaireplus-mapping-utils-6.0.4/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/tags/dnet-openaireplus-mapping-utils-6.0.4/src/test/resources/eu/dnetlib/openaire/exporter/model/projectDetails.csv | ||
---|---|---|
1 |
nih_________::3R01GM073898-02S1,,3R01GM073898-02S1,23188 $,,"{""orgname"":""UNIVERSITY OF CALIFORNIA SAN DIEGO"", ""activity"":""R01"", ""administeringic"":""GM"", ""serialnumber"":""73898"", ""coreprojectnum"":""R01GM073898""}","[""\u003cfundingtree\u003e\n \u003cfunder\u003e\n \u003cid\u003enih_________::NIH\u003c/id\u003e\n \u003cshortname\u003eNIH\u003c/shortname\u003e\n \u003cname\u003eNational Institutes of Health\u003c/name\u003e\n \u003cjurisdiction\u003eUS\u003c/jurisdiction\u003e\n \u003c/funder\u003e\n \u003cfunding_level_0\u003e\n \u003cid\u003enih_________::NIH::NATIONAL_INSTITUTE_OF_GENERAL_MEDICAL_SCIENCES\u003c/id\u003e\n \u003cname\u003eNATIONAL INSTITUTE OF GENERAL MEDICAL SCIENCES\u003c/name\u003e\n \u003cdescription\u003eNATIONAL INSTITUTE OF GENERAL MEDICAL SCIENCES\u003c/description\u003e\n \u003cparent/\u003e\n \u003cclass\u003enih:fundingStream\u003c/class\u003e\n \u003c/funding_level_0\u003e\n \u003c/fundingtree\u003e""]" |
|
2 |
corda_______::100202,RECOMP,100202,JTI-CP-ARTEMIS,http://cordis.europa.eu/fp7/home_en.html,{},"[""\u003cfundingtree\u003e\u003cfunder\u003e\u003cid\u003eec__________::EC\u003c/id\u003e\u003cshortname\u003eEC\u003c/shortname\u003e\u003cname\u003eEuropean Commission\u003c/name\u003e\u003cjurisdiction\u003eEU\u003c/jurisdiction\u003e\u003c/funder\u003e\u003cfunding_level_2\u003e\u003cid\u003eec__________::EC::FP7::SP1::SP1-JTI\u003c/id\u003e\u003cdescription\u003eJoint Technology Initiatives (Annex IV-SP1)\u003c/description\u003e\u003cname\u003eSP1-JTI\u003c/name\u003e\u003cclass\u003eec:program\u003c/class\u003e\u003cparent\u003e\u003cfunding_level_1\u003e\u003cid\u003eec__________::EC::FP7::SP1\u003c/id\u003e\u003cdescription\u003eSP1-Cooperation\u003c/description\u003e\u003cname\u003eSP1\u003c/name\u003e\u003cclass\u003eec:specificprogram\u003c/class\u003e\u003cparent\u003e\u003cfunding_level_0\u003e\u003cid\u003eec__________::EC::FP7\u003c/id\u003e\u003cdescription\u003eSEVENTH FRAMEWORK PROGRAMME\u003c/description\u003e\u003cname\u003eFP7\u003c/name\u003e\u003cparent/\u003e\u003cclass\u003eec:frameworkprogram\u003c/class\u003e\u003c/funding_level_0\u003e\u003c/parent\u003e\u003c/funding_level_1\u003e\u003c/parent\u003e\u003c/funding_level_2\u003e\u003c/fundingtree\u003e""]" |
|
3 |
corda__h2020::633080,MACC-III,633080,SPACE,SPACE,{},"[""\u003cfundingtree\u003e\u003cfunder\u003e\u003cid\u003eec__________::EC\u003c/id\u003e\u003cshortname\u003eEC\u003c/shortname\u003e\u003cname\u003eEuropean Commission\u003c/name\u003e\u003cjurisdiction\u003eEU\u003c/jurisdiction\u003e\u003c/funder\u003e\u003cfunding_level_1\u003e\u003cid\u003eec__________::EC::H2020::CSA\u003c/id\u003e\u003cdescription\u003eCoordination and support action\u003c/description\u003e\u003cname\u003eCSA\u003c/name\u003e\u003cclass\u003eec:h2020toas\u003c/class\u003e\u003cparent\u003e\u003cfunding_level_0\u003e\u003cid\u003eec__________::EC::H2020\u003c/id\u003e\u003cname\u003eH2020\u003c/name\u003e\u003cdescription\u003eHorizon 2020 Framework Programme\u003c/description\u003e\u003cparent/\u003e\u003cclass\u003eec:h2020fundings\u003c/class\u003e\u003c/funding_level_0\u003e\u003c/parent\u003e\u003c/funding_level_1\u003e\u003c/fundingtree\u003e""]" |
|
4 |
nsf_________::0000096,,0000096,,,{},"[""\u003cfundingtree\u003e\u003cfunder\u003e\u003cid\u003ensf_________::NSF\u003c/id\u003e\u003cshortname\u003eNSF\u003c/shortname\u003e\u003cname\u003eNational Science Foundation\u003c/name\u003e\u003cjurisdiction\u003eUS\u003c/jurisdiction\u003e\u003c/funder\u003e\u003cfunding_level_1\u003e\u003cid\u003ensf_________::NSF::OD::OD/OIA\u003c/id\u003e\u003cdescription\u003eOffice of Integrative Activities\u003c/description\u003e\u003cname\u003eOffice of Integrative Activities\u003c/name\u003e\u003cparent\u003e\u003cfunding_level_0\u003e\u003cid\u003ensf_________::NSF::OD\u003c/id\u003e\u003cdescription\u003eOffice of the Director\u003c/description\u003e\u003cname\u003eOffice of the Director\u003c/name\u003e\u003cparent/\u003e\u003cclass\u003ensf:fundingStream\u003c/class\u003e\u003c/funding_level_0\u003e\u003c/parent\u003e\u003c/funding_level_1\u003e\u003c/fundingtree\u003e""]" |
|
5 |
fct_________::100107,PTDC/SAU-ESA/100107/2008,100107,,,{},"[""\u003cfundingtree\u003e\u003cfunder\u003e\u003cid\u003efct_________::FCT\u003c/id\u003e\u003cshortname\u003eFCT\u003c/shortname\u003e\u003cname\u003eFundação para a Ciência e a Tecnologia, I.P.\u003c/name\u003e\u003cjurisdiction\u003ePT\u003c/jurisdiction\u003e\u003c/funder\u003e\u003cfunding_level_0\u003e\u003cid\u003efct_________::FCT::5876-PPCDTI\u003c/id\u003e\u003cdescription\u003e5876-PPCDTI\u003c/description\u003e\u003cname\u003e5876-PPCDTI\u003c/name\u003e\u003cparent/\u003e\u003cclass\u003efct:program\u003c/class\u003e\u003c/funding_level_0\u003e\u003c/fundingtree\u003e""]" |
modules/dnet-openaireplus-mapping-utils/tags/dnet-openaireplus-mapping-utils-6.0.4/src/test/resources/eu/dnetlib/pace/result.prod.pace.conf | ||
---|---|---|
1 |
{ |
|
2 |
"wf" : { |
|
3 |
"threshold" : "0.99", |
|
4 |
"dedupRun" : "001", |
|
5 |
"entityType" : "result", |
|
6 |
"orderField" : "title", |
|
7 |
"queueMaxSize" : "2000", |
|
8 |
"groupMaxSize" : "10", |
|
9 |
"slidingWindowSize" : "200", |
|
10 |
"rootBuilder" : [ "result", "personResult_authorship_hasAuthor", "resultProject_outcome_isProducedBy", "resultResult_publicationDataset_isRelatedTo", "resultResult_similarity_isAmongTopNSimilarDocuments", "resultResult_similarity_hasAmongTopNSimilarDocuments" ], |
|
11 |
"includeChildren" : "true" |
|
12 |
}, |
|
13 |
"pace" : { |
|
14 |
"clustering" : [ |
|
15 |
{ "name" : "ngrampairs", "fields" : [ "title" ], "params" : { "max" : "1", "ngramLen" : "3"} }, |
|
16 |
{ "name" : "suffixprefix", "fields" : [ "title" ], "params" : { "max" : "1", "len" : "3" } } |
|
17 |
], |
|
18 |
"strictConditions" : [ |
|
19 |
{ "name" : "exactMatch", "fields" : [ "pid" ] } |
|
20 |
], |
|
21 |
"conditions" : [ |
|
22 |
{ "name" : "titleVersionMatch", "fields" : [ "title" ] }, |
|
23 |
{ "name" : "sizeMatch", "fields" : [ "authors" ] } |
|
24 |
], |
|
25 |
"model" : [ |
|
26 |
{ "name" : "pid", "algo" : "Null", "type" : "String", "weight" : "0.0", "ignoreMissing" : "true", "path" : "pid[qualifier#classid = {doi}]/value", "overrideMatch" : "true" }, |
|
27 |
{ "name" : "title", "algo" : "LevensteinTitle", "type" : "String", "weight" : "1.0", "ignoreMissing" : "false", "path" : "result/metadata/title[qualifier#classid = {main title}]/value" }, |
|
28 |
{ "name" : "authors", "algo" : "Null", "type" : "String", "weight" : "0.0", "ignoreMissing" : "true", "path" : "result/author/metadata/fullname/value" } |
|
29 |
], |
|
30 |
"blacklists" : { |
|
31 |
"title" : [ |
|
32 |
"^THE ASSOCIATION AND THE GENERAL MEDICAL COUNCIL$", |
|
33 |
"^Problems with perinatal pathology\.?$", |
|
34 |
"(?i)^Cases? of Puerperal Convulsions$", |
|
35 |
"(?i)^Operative Gyna?ecology$", |
|
36 |
"(?i)^Mind the gap\!?\:?$", |
|
37 |
"^Chronic fatigue syndrome\.?$", |
|
38 |
"^Cartas? ao editor Letters? to the Editor$", |
|
39 |
"^Note from the Editor$", |
|
40 |
"^Anesthesia Abstract$", |
|
41 |
|
|
42 |
"^Annual report$", |
|
43 |
"(?i)^“?THE RADICAL PREVENTION OF VENEREAL DISEASE\.?”?$", |
|
44 |
"(?i)^Graph and Table of Infectious Diseases?$", |
|
45 |
"^Presentation$", |
|
46 |
"(?i)^Reviews and Information on Publications$", |
|
47 |
"(?i)^PUBLIC HEALTH SERVICES?$", |
|
48 |
"(?i)^COMBINED TEXT-?BOOK OF OBSTETRICS AND GYN(Æ|ae)COLOGY$", |
|
49 |
"(?i)^Adrese autora$", |
|
50 |
"(?i)^Systematic Part .*\. Catalogus Fossilium Austriae, Band 2: Echinoidea neogenica$", |
|
51 |
"(?i)^Acknowledgement to Referees$", |
|
52 |
"(?i)^Behçet's disease\.?$", |
|
53 |
"(?i)^Isolation and identification of restriction endonuclease.*$", |
|
54 |
"(?i)^CEREBROVASCULAR DISEASES?.?$", |
|
55 |
"(?i)^Screening for abdominal aortic aneurysms?\.?$", |
|
56 |
"^Event management$", |
|
57 |
"(?i)^Breakfast and Crohn's disease.*\.?$", |
|
58 |
"^Cálculo de concentraciones en disoluciones acuosas. Ejercicio interactivo\..*\.$", |
|
59 |
"(?i)^Genetic and functional analyses of SHANK2 mutations suggest a multiple hit model of Autism spectrum disorders?\.?$", |
|
60 |
"^Gushi hakubutsugaku$", |
|
61 |
|
|
62 |
"^Starobosanski nadpisi u Bosni i Hercegovini \(.*\)$", |
|
63 |
"^Intestinal spirocha?etosis$", |
|
64 |
"^Treatment of Rodent Ulcer$", |
|
65 |
"(?i)^\W*Cloud Computing\W*$", |
|
66 |
"^Compendio mathematico : en que se contienen todas las materias mas principales de las Ciencias que tratan de la cantidad$", |
|
67 |
"^Free Communications, Poster Presentations: Session [A-F]$", |
|
68 |
|
|
69 |
"^“The Historical Aspects? of Quackery\.?”$", |
|
70 |
"^A designated centre for people with disabilities operated by St John of God Community Services (Limited|Ltd), Louth$", |
|
71 |
"^P(er|re)-Mile Premiums for Auto Insurance\\.?$", |
|
72 |
"(?i)^Case Report$", |
|
73 |
"^Boletín Informativo$", |
|
74 |
"(?i)^Glioblastoma Multiforme$", |
|
75 |
"(?i)^Nuevos táxones animales descritos en la península Ibérica y Macaronesia desde 1994 \\(.*\\)$", |
|
76 |
"^Zaměstnanecké výhody$", |
|
77 |
"(?i)^The Economics of Terrorism and Counter-Terrorism: A Survey \\(Part .*\\)$", |
|
78 |
"(?i)^Carotid body tumours?\\.?$", |
|
79 |
"(?i)^\\[Españoles en Francia : La condición Emigrante.*\\]$", |
|
80 |
"^Avant-propos$", |
|
81 |
"(?i)^St\. Patrick's Cathedral, Dublin, County Dublin - Head(s)? and Capital(s)?$", |
|
82 |
"(?i)^St\. Patrick's Cathedral, Dublin, County Dublin - Bases?$", |
|
83 |
"(?i)^PUBLIC HEALTH VERSUS THE STATE$", |
|
84 |
"^Viñetas de Cortázar$", |
|
85 |
"(?i)^Search for heavy neutrinos and W(\\[|_|\\(|_\\{|-)?R(\\]|\\)|\\})? bosons with right-handed couplings in a left-right symmetric model in pp collisions at.*TeV(\.)?$", |
Also available in: Unified diff
[maven-release-plugin] copy for tag dnet-openaireplus-mapping-utils-6.0.4