Revision 31996
Added by Claudio Atzori over 9 years ago
OafTest.java | ||
---|---|---|
74 | 74 |
.setDatasource( |
75 | 75 |
Datasource.newBuilder().setMetadata( |
76 | 76 |
Datasource.Metadata.newBuilder().setOfficialname(sf("officialname")).setEnglishname(sf("englishname")) |
77 |
.setWebsiteurl(sf("websiteurl")).setContactemail(sf("contactemail")).addAccessinfopackage(sf("accessinforpackage"))
|
|
78 |
.setNamespaceprefix(sf("namespaceprofix")).setDescription(sf("description")).setOdnumberofitems(sf("numberofitems"))
|
|
79 |
.setOdnumberofitemsdate(sf("numberofitems date"))
|
|
80 |
// .addOdsubjects("subjects")
|
|
81 |
.setOdpolicies(sf("policies")).addOdlanguages(sf("languages")).addOdcontenttypes(sf("contenttypes"))
|
|
82 |
.setDatasourcetype(getQualifier("type class", "type scheme")))).build();
|
|
77 |
.setWebsiteurl(sf("websiteurl")).setContactemail(sf("contactemail")).addAccessinfopackage(sf("accessinforpackage")) |
|
78 |
.setNamespaceprefix(sf("namespaceprofix")).setDescription(sf("description")).setOdnumberofitems(sf("numberofitems")) |
|
79 |
.setOdnumberofitemsdate(sf("numberofitems date")) |
|
80 |
// .addOdsubjects("subjects") |
|
81 |
.setOdpolicies(sf("policies")).addOdlanguages(sf("languages")).addOdcontenttypes(sf("contenttypes")) |
|
82 |
.setDatasourcetype(getQualifier("type class", "type scheme")))).build(); |
|
83 | 83 |
} |
84 | 84 |
|
85 | 85 |
public static OafEntity getResult(final String id) { |
... | ... | |
89 | 89 |
.setId(id) |
90 | 90 |
.setResult( |
91 | 91 |
Result.newBuilder() |
92 |
.setMetadata(
|
|
93 |
Result.Metadata
|
|
94 |
.newBuilder()
|
|
95 |
.addTitle(
|
|
96 |
getStructuredproperty(
|
|
97 |
"Analysis of cell viability in intervertebral disc: Effect of endplate permeability on cell population",
|
|
98 |
"main title", "dnet:result_titles", getDataInfo()))
|
|
92 |
.setMetadata( |
|
93 |
Result.Metadata |
|
94 |
.newBuilder() |
|
95 |
.addTitle( |
|
96 |
getStructuredproperty( |
|
97 |
"Analysis of cell viability in intervertebral disc: Effect of endplate permeability on cell population", |
|
98 |
"main title", "dnet:result_titles", getDataInfo())) |
|
99 | 99 |
.addSubject(getStructuredproperty("Biophysics", "subject", "dnet:result_sujects")) |
100 | 100 |
.setDateofacceptance(sf("2010-01-01")).addSource(sf("sourceA")).addSource(sf("sourceB")) |
101 | 101 |
.addContext(Context.newBuilder().setId("egi::virtual::970")) |
... | ... | |
106 | 106 |
.addDescription(sf("Responsible for making and maintaining the extracellular matrix ...")) |
107 | 107 |
.setPublisher(sf("ELSEVIER SCI LTD")).setResulttype(getQualifier("publication", "dnet:result_types")) |
108 | 108 |
.setLanguage(getQualifier("eng", "dnet:languages"))).addInstance(getInstance("10|od__10", "Uk pubmed")) |
109 |
.addInstance(getInstance("10|od__10", "arxiv"))) |
|
110 |
.addCollectedfrom(getKV("opendoar____::1064", "Oxford University Research Archive")) |
|
111 |
.addPid(getStructuredproperty("doi:74293", "doi", "dnet:pids")).setDateofcollection("").build(); |
|
109 |
.addInstance(getInstance("10|od__10", "arxiv")))
|
|
110 |
.addCollectedfrom(getKV("opendoar____::1064", "Oxford University Research Archive"))
|
|
111 |
.addPid(getStructuredproperty("doi:74293", "doi", "dnet:pids")).setDateofcollection("").build();
|
|
112 | 112 |
} |
113 | 113 |
|
114 | 114 |
public static DataInfo getDataInfo() { |
... | ... | |
143 | 143 |
.setPersonResult( |
144 | 144 |
PersonResult.newBuilder().setAuthorship( |
145 | 145 |
Authorship.newBuilder().setRanking(ranking).setRelMetadata(relMetadata(relClass, "dnet:personResult_relations")))) |
146 |
.setCachedTarget(getPerson()).build(); |
|
146 |
.setCachedTarget(getPerson()).build();
|
|
147 | 147 |
} |
148 | 148 |
|
149 | 149 |
public static OafEntity getPerson() { |
... | ... | |
154 | 154 |
.setPerson( |
155 | 155 |
Person.newBuilder().setMetadata( |
156 | 156 |
Person.Metadata.newBuilder().addSecondnames(sf("Shirazi-Adl")).setFullname(sf("A. Shirazi-Adl")) |
157 |
.setEmail(sf("name.surname@gmail.com")).setPhone(sf("12345")).setNationality(getQualifier("EN", "dnet:countries"))))
|
|
158 |
.build(); |
|
157 |
.setEmail(sf("name.surname@gmail.com")).setPhone(sf("12345")).setNationality(getQualifier("EN", "dnet:countries")))) |
|
158 |
.build();
|
|
159 | 159 |
} |
160 | 160 |
|
161 | 161 |
public static OafRel getProjectOrganization(final String source, final String target, final String relClass) throws InvalidProtocolBufferException { |
162 | 162 |
OafRel.Builder oafRel = |
163 | 163 |
OafRel.newBuilder() |
164 |
.setSource(source)
|
|
165 |
.setTarget(target)
|
|
166 |
.setRelType(RelType.projectOrganization)
|
|
167 |
.setSubRelType(SubRelType.participation)
|
|
168 |
.setRelClass(relClass)
|
|
169 |
.setChild(false)
|
|
170 |
.setProjectOrganization(
|
|
171 |
ProjectOrganization.newBuilder().setParticipation(
|
|
172 |
Participation.newBuilder().setParticipantnumber("" + 1)
|
|
173 |
.setRelMetadata(relMetadata(relClass, "dnet:project_organization_relations"))));
|
|
164 |
.setSource(source) |
|
165 |
.setTarget(target) |
|
166 |
.setRelType(RelType.projectOrganization) |
|
167 |
.setSubRelType(SubRelType.participation) |
|
168 |
.setRelClass(relClass) |
|
169 |
.setChild(false) |
|
170 |
.setProjectOrganization( |
|
171 |
ProjectOrganization.newBuilder().setParticipation( |
|
172 |
Participation.newBuilder().setParticipantnumber("" + 1) |
|
173 |
.setRelMetadata(relMetadata(relClass, "dnet:project_organization_relations")))); |
|
174 | 174 |
switch (Participation.RelName.valueOf(relClass)) { |
175 | 175 |
case hasParticipant: |
176 | 176 |
oafRel.setCachedTarget(getProjectFP7(target)); |
... | ... | |
187 | 187 |
public static OafRel getDatasourceOrganization(final String source, final String target, final String relClass) throws InvalidProtocolBufferException { |
188 | 188 |
OafRel.Builder oafRel = |
189 | 189 |
OafRel.newBuilder() |
190 |
.setSource(source)
|
|
191 |
.setTarget(target)
|
|
192 |
.setRelType(RelType.datasourceOrganization)
|
|
193 |
.setSubRelType(SubRelType.provision)
|
|
194 |
.setRelClass(relClass)
|
|
195 |
.setChild(false)
|
|
196 |
.setDatasourceOrganization(
|
|
197 |
DatasourceOrganization.newBuilder().setProvision(
|
|
198 |
Provision.newBuilder().setRelMetadata(relMetadata(relClass, "dnet:datasource_organization_relations"))));
|
|
190 |
.setSource(source) |
|
191 |
.setTarget(target) |
|
192 |
.setRelType(RelType.datasourceOrganization) |
|
193 |
.setSubRelType(SubRelType.provision) |
|
194 |
.setRelClass(relClass) |
|
195 |
.setChild(false) |
|
196 |
.setDatasourceOrganization( |
|
197 |
DatasourceOrganization.newBuilder().setProvision( |
|
198 |
Provision.newBuilder().setRelMetadata(relMetadata(relClass, "dnet:datasource_organization_relations")))); |
|
199 | 199 |
switch (Provision.RelName.valueOf(relClass)) { |
200 | 200 |
case isProvidedBy: |
201 | 201 |
oafRel.setCachedTarget(getOrganization(target)); |
... | ... | |
221 | 221 |
.setProjectPerson( |
222 | 222 |
ProjectPerson.newBuilder().setContactPerson( |
223 | 223 |
ContactPerson.newBuilder().setRelMetadata(relMetadata(relClass, "dnet:project_result_relations")))) |
224 |
.setCachedTarget(getPerson()).build(); |
|
224 |
.setCachedTarget(getPerson()).build();
|
|
225 | 225 |
} |
226 | 226 |
|
227 | 227 |
public static OafRel getSimilarityRel(final String sourceId, final String targetId, final OafEntity result, final String relClass) { |
... | ... | |
233 | 233 |
.setSubRelType(SubRelType.similarity) |
234 | 234 |
.setRelClass(relClass) |
235 | 235 |
.setChild(false) |
236 |
.setCachedTarget(result) |
|
236 | 237 |
.setResultResult( |
237 | 238 |
ResultResult.newBuilder().setSimilarity( |
238 | 239 |
Similarity.newBuilder().setRelMetadata(relMetadata(relClass, "dnet:resultResult_relations")).setSimilarity(.4f) |
239 |
.setType(Similarity.Type.STANDARD))).build();
|
|
240 |
.setType(Similarity.Type.STANDARD))).build(); |
|
240 | 241 |
} |
241 | 242 |
|
242 | 243 |
public static RelMetadata.Builder relMetadata(final String classname, final String schemename) { |
... | ... | |
252 | 253 |
.setOrganization( |
253 | 254 |
Organization.newBuilder().setMetadata( |
254 | 255 |
Organization.Metadata.newBuilder().setLegalname(sf("CENTRE D'APPUI A LA RECHERCHE ET A LA FORMATION GIE")) |
255 |
.setLegalshortname(sf("CAREF")).setWebsiteurl(sf("www.caref-mali.org"))
|
|
256 |
.setCountry(getQualifier("ML", "dnet:countries")))).build();
|
|
256 |
.setLegalshortname(sf("CAREF")).setWebsiteurl(sf("www.caref-mali.org")) |
|
257 |
.setCountry(getQualifier("ML", "dnet:countries")))).build(); |
|
257 | 258 |
} |
258 | 259 |
|
259 | 260 |
public static OafRel getResultProject(final String from, final String to, final OafEntity project, final String relClass) |
... | ... | |
268 | 269 |
.setChild(false) |
269 | 270 |
.setResultProject( |
270 | 271 |
ResultProject.newBuilder().setOutcome(Outcome.newBuilder().setRelMetadata(relMetadata(relClass, "dnet:result_project_relations")))) |
271 |
.setCachedTarget(project).build(); |
|
272 |
.setCachedTarget(project).build();
|
|
272 | 273 |
} |
273 | 274 |
|
274 | 275 |
public static OafEntity getProjectFP7(final String projectId) throws InvalidProtocolBufferException { |
... | ... | |
279 | 280 |
.addCollectedfrom(getKV("opendoar_1234", "UK pubmed")) |
280 | 281 |
.setProject( |
281 | 282 |
Project.newBuilder() |
282 |
.setMetadata(
|
|
283 |
Project.Metadata
|
|
284 |
.newBuilder()
|
|
285 |
.setAcronym(sf("5CYRQOL"))
|
|
286 |
.setTitle(sf("Cypriot Researchers Contribute to our Quality of Life"))
|
|
287 |
.setStartdate(sf("2007-05-01"))
|
|
288 |
.setEnddate(sf("2007-10-31"))
|
|
289 |
.setEcsc39(sf("false"))
|
|
290 |
.setContracttype(getQualifier("CSA", "ec:FP7contractTypes"))
|
|
291 |
.addFundingtree(
|
|
292 |
sf("{\"funding_level_2\":{\"class\":\"ec:program\", \"id\":\"corda_______::FP7::SP3::PEOPLE\", \"description\":\"Marie-Curie Actions\", \"name\":\"PEOPLE\", \"parent\":{\"funding_level_1\":{\"class\":\"ec:specificprogram\", \"id\":\"corda_______::FP7::SP3\", \"description\":\"SP3-People\", \"name\":\"SP3\", \"parent\":{\"funding_level_0\":{\"class\":\"ec:frameworkprogram\", \"id\":\"corda_______::FP7\", \"description\":\"SEVENTH FRAMEWORK PROGRAMME\", \"name\":\"FP7\", \"parent\":{}}}}}}}"))))
|
|
293 |
.build(); |
|
283 |
.setMetadata( |
|
284 |
Project.Metadata |
|
285 |
.newBuilder() |
|
286 |
.setAcronym(sf("5CYRQOL")) |
|
287 |
.setTitle(sf("Cypriot Researchers Contribute to our Quality of Life")) |
|
288 |
.setStartdate(sf("2007-05-01")) |
|
289 |
.setEnddate(sf("2007-10-31")) |
|
290 |
.setEcsc39(sf("false")) |
|
291 |
.setContracttype(getQualifier("CSA", "ec:FP7contractTypes")) |
|
292 |
.addFundingtree( |
|
293 |
sf("{\"funding_level_2\":{\"class\":\"ec:program\", \"id\":\"corda_______::FP7::SP3::PEOPLE\", \"description\":\"Marie-Curie Actions\", \"name\":\"PEOPLE\", \"parent\":{\"funding_level_1\":{\"class\":\"ec:specificprogram\", \"id\":\"corda_______::FP7::SP3\", \"description\":\"SP3-People\", \"name\":\"SP3\", \"parent\":{\"funding_level_0\":{\"class\":\"ec:frameworkprogram\", \"id\":\"corda_______::FP7\", \"description\":\"SEVENTH FRAMEWORK PROGRAMME\", \"name\":\"FP7\", \"parent\":{}}}}}}}")))) |
|
294 |
.build();
|
|
294 | 295 |
} |
295 | 296 |
|
296 | 297 |
public static OafEntity getProjectWT() throws InvalidProtocolBufferException { |
... | ... | |
301 | 302 |
.addCollectedfrom(getKV("wellcomeTrust", "wellcome trust")) |
302 | 303 |
.setProject( |
303 | 304 |
Project.newBuilder() |
304 |
.setMetadata(
|
|
305 |
Project.Metadata
|
|
306 |
.newBuilder()
|
|
307 |
.setAcronym(sf("UNKNOWN"))
|
|
308 |
.setTitle(sf("Research Institute for Infectious Diseases of Poverty (IIDP)."))
|
|
309 |
.setStartdate(sf("2007-05-01"))
|
|
310 |
.setEnddate(sf("2007-10-31"))
|
|
311 |
.setEcsc39(sf("false"))
|
|
312 |
.setContracttype(getQualifier("UNKNOWN", "wt:contractTypes"))
|
|
313 |
.addFundingtree(
|
|
314 |
sf("{\"funding_level_1\":{\"class\":\"wt:fundingStream\", \"id\":\"welcometrust::Immunology and Infectious Disease\", \"description\":\"Immunology and Infectious Disease\", \"name\":\"Immunology and Infectious Disease\", \"parent\":{\"funding_level_0\":{\"class\":\"wt:fundingStream\", \"id\":\"wt::WT\", \"description\":\"Wellcome Trust\", \"name\":\"WT\", \"parent\":{}}}}}"))
|
|
315 |
.addFundingtree(
|
|
316 |
sf("{\"funding_level_1\":{\"class\":\"wt:fundingStream\", \"id\":\"welcometrust::Voices of the Sick Poor: the Patients' Experience of Medical Negligence under the New Poor Law.\", \"description\":\"Voices of the Sick Poor: the Patients' Experience of Medical Negligence under the New Poor Law.\", \"name\":\"Voices of the Sick Poor: the Patients' Experience of Medical Negligence under the New Poor Law.\", \"parent\":{\"funding_level_0\":{\"class\":\"wt:fundingStream\", \"id\":\"wt::WT\", \"description\":\"Wellcome Trust\", \"name\":\"WT\", \"parent\":{}}}}}"))))
|
|
317 |
.build(); |
|
305 |
.setMetadata( |
|
306 |
Project.Metadata |
|
307 |
.newBuilder() |
|
308 |
.setAcronym(sf("UNKNOWN")) |
|
309 |
.setTitle(sf("Research Institute for Infectious Diseases of Poverty (IIDP).")) |
|
310 |
.setStartdate(sf("2007-05-01")) |
|
311 |
.setEnddate(sf("2007-10-31")) |
|
312 |
.setEcsc39(sf("false")) |
|
313 |
.setContracttype(getQualifier("UNKNOWN", "wt:contractTypes")) |
|
314 |
.addFundingtree( |
|
315 |
sf("{\"funding_level_1\":{\"class\":\"wt:fundingStream\", \"id\":\"welcometrust::Immunology and Infectious Disease\", \"description\":\"Immunology and Infectious Disease\", \"name\":\"Immunology and Infectious Disease\", \"parent\":{\"funding_level_0\":{\"class\":\"wt:fundingStream\", \"id\":\"wt::WT\", \"description\":\"Wellcome Trust\", \"name\":\"WT\", \"parent\":{}}}}}")) |
|
316 |
.addFundingtree( |
|
317 |
sf("{\"funding_level_1\":{\"class\":\"wt:fundingStream\", \"id\":\"welcometrust::Voices of the Sick Poor: the Patients' Experience of Medical Negligence under the New Poor Law.\", \"description\":\"Voices of the Sick Poor: the Patients' Experience of Medical Negligence under the New Poor Law.\", \"name\":\"Voices of the Sick Poor: the Patients' Experience of Medical Negligence under the New Poor Law.\", \"parent\":{\"funding_level_0\":{\"class\":\"wt:fundingStream\", \"id\":\"wt::WT\", \"description\":\"Wellcome Trust\", \"name\":\"WT\", \"parent\":{}}}}}")))) |
|
318 |
.build();
|
|
318 | 319 |
} |
319 | 320 |
|
320 | 321 |
public static ExtraInfo extraInfo(final String name, final String provenance, final String trust, final String typology, final String value) { |
... | ... | |
426 | 427 |
|
427 | 428 |
Oaf.Builder oaf = |
428 | 429 |
Oaf.newBuilder() |
429 |
.setKind(kind)
|
|
430 |
.setTimestamp(System.currentTimeMillis())
|
|
431 |
.setDataInfo(
|
|
432 |
DataInfo.newBuilder().setDeletedbyinference(deletedByInference).setInferred(inferred).setTrust("0.5")
|
|
433 |
.setInferenceprovenance(provenance).setProvenanceaction(getQualifier(action, action)));
|
|
430 |
.setKind(kind) |
|
431 |
.setTimestamp(System.currentTimeMillis()) |
|
432 |
.setDataInfo( |
|
433 |
DataInfo.newBuilder().setDeletedbyinference(deletedByInference).setInferred(inferred).setTrust("0.5") |
|
434 |
.setInferenceprovenance(provenance).setProvenanceaction(getQualifier(action, action))); |
|
434 | 435 |
switch (kind) { |
435 | 436 |
case entity: |
436 | 437 |
oaf.setEntity((OafEntity) msg); |
Also available in: Unified diff
mapping relatedDataset identifiers to build proper relationships on hbase