Revision 51666
Added by Alessia Bardi about 6 years ago
modules/dnet-parthenos-publisher/trunk/test/main/java/eu/dnetlib/parthenos/catalogue/CatalogueRegistratorTest.java | ||
---|---|---|
55 | 55 |
} |
56 | 56 |
|
57 | 57 |
@Test |
58 |
public void readModel() throws IOException {
|
|
58 |
public void readModel() { |
|
59 | 59 |
InfModel model = loadBaseModel(); |
60 | 60 |
model.read(getInputStream(noRiot), CRMpe.NS); |
61 | 61 |
} |
... | ... | |
82 | 82 |
System.out.println(json); |
83 | 83 |
} |
84 | 84 |
} |
85 |
|
|
85 | 86 |
@Test |
87 |
public void testGetJsonForProject() throws Exception{ |
|
88 |
InfModel model = loadBaseModel(); |
|
89 |
model.read(getInputStream("eu/dnetlib/parthenos/registry/sample1.rdf"), CRMpe.NS); |
|
90 |
ResIterator subjects = model.listSubjectsWithProperty(RDF.type, CRMpe.PE35_Project); |
|
91 |
while (subjects.hasNext()) { |
|
92 |
Resource subject = subjects.nextResource(); |
|
93 |
String json = reg.getJsonForActivity(subject, "testProjectName"); |
|
94 |
System.out.println(json); |
|
95 |
} |
|
96 |
} |
|
97 |
@Test |
|
86 | 98 |
public void testAlphaNumeric(){ |
87 | 99 |
String s = "0039%2002%203232%203325"; |
88 | 100 |
System.out.println(s.replaceAll("[^A-Za-z0-9]","_").toLowerCase()); |
modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/catalogue/CatalogueRegistrator.java | ||
---|---|---|
20 | 20 |
import org.apache.commons.logging.LogFactory; |
21 | 21 |
import org.apache.jena.rdf.model.Resource; |
22 | 22 |
import org.apache.jena.rdf.model.StmtIterator; |
23 |
import org.apache.jena.vocabulary.RDF; |
|
23 | 24 |
import org.springframework.beans.factory.annotation.Autowired; |
24 | 25 |
import org.springframework.stereotype.Component; |
25 | 26 |
|
... | ... | |
148 | 149 |
JsonGenerator jg = jsonFactory.createGenerator(bos, JsonEncoding.UTF8); |
149 | 150 |
jg.writeStartObject(); |
150 | 151 |
writeCommonFields(jg, res, resNameForCatalogue); |
151 |
//TODO: from which linked E39_Actor? |
|
152 |
//for project we can take it from the maintainer team: is this correct also for other Things (like Services and Software?) |
|
153 |
jg.writeStringField("maintainer", Joiner.on(", ").join(resourceReader.getMaintainerUrls(res))); |
|
152 |
jg.writeStringField("maintainer", Joiner.on(", ").join(resourceReader.getMaintainersForManagementSection(res))); |
|
154 | 153 |
//TODO: it should be better to identify email contacts rather than generic contact labels of maintainer |
155 | 154 |
//jg.writeStringField("maintainer_email", Joiner.on(", ").join(resourceReader.getMaintainerContacts(res))); |
156 | 155 |
|
... | ... | |
161 | 160 |
if (res.getURI().startsWith(PARTHENOS_BASE_URL)) |
162 | 161 |
addExtra(jg, "Parthenos URL", res.getURI()); |
163 | 162 |
//for Services |
164 |
addExtra(jg, "competence", resourceReader.getCompetence(res)); |
|
165 |
addExtra(jg, "provided by", Joiner.on(", ").join(resourceReader.getProviderNames(res))); |
|
166 |
addExtra(jg, "declared begin/end of operation", Joiner.on(", ").join(resourceReader.getDeclarativeTimes(res))); |
|
167 |
//TODO: where to get it? |
|
168 |
addExtra(jg, "last confirmation", ""); |
|
169 |
//TODO: where to get it? |
|
170 |
addExtra(jg, "date of registration", ""); |
|
171 |
addExtra(jg, "availability", resourceReader.getAvailability(res)); |
|
172 |
//TODO: where to get it? |
|
173 |
addExtra(jg, "condition of use", resourceReader.getConditionOfUse(res)); |
|
174 |
addExtra(jg, "contact points", Joiner.on(", ").join(resourceReader.getProviderContactPoints(res))); |
|
175 |
addExtra(jg, "activity type", Joiner.on(", ").join(resourceReader.getActivityTypes(res))); |
|
176 |
addExtra(jg, "hosts", Joiner.on(", ").join(resourceReader.getHostedStuff(res))); |
|
177 |
addExtra(jg, "online access point", Joiner.on(", ").join(resourceReader.getAccessPoints(res))); |
|
178 |
addExtra(jg, "protocol", Joiner.on(", ").join(resourceReader.getProtocols(res))); |
|
179 |
addExtra(jg,"curates", Joiner.on(", ").join(resourceReader.getCuratedObjects(res))); |
|
180 |
//TODO: where to get it? |
|
181 |
addExtra(jg, "runs on request", ""); |
|
182 |
addExtra(jg, "delivers on request", Joiner.on(", ").join(resourceReader.getDeliversOnRequest(res))); |
|
183 |
addExtra(jg, "uses curation plan", Joiner.on(", ").join(resourceReader.getCurationPlans(res))); |
|
184 |
|
|
163 |
if(res.hasProperty(RDF.type, CRMpe.PE1_Service)) { |
|
164 |
addExtra(jg, "competence", resourceReader.getCompetence(res)); |
|
165 |
addExtra(jg, "provided by", Joiner.on(", ").join(resourceReader.getProviderNames(res))); |
|
166 |
addExtra(jg, "declared begin/end of operation", Joiner.on(", ").join(resourceReader.getDeclarativeTimes(res))); |
|
167 |
//TODO: where to get it? |
|
168 |
addExtra(jg, "last confirmation", ""); |
|
169 |
//TODO: where to get it? |
|
170 |
addExtra(jg, "date of registration", ""); |
|
171 |
addExtra(jg, "availability", resourceReader.getAvailability(res)); |
|
172 |
//TODO: where to get it? |
|
173 |
addExtra(jg, "condition of use", resourceReader.getConditionOfUse(res)); |
|
174 |
addExtra(jg, "contact points", Joiner.on(", ").join(resourceReader.getProviderContactPoints(res))); |
|
175 |
addExtra(jg, "activity type", Joiner.on(", ").join(resourceReader.getActivityTypes(res))); |
|
176 |
addExtra(jg, "hosts", Joiner.on(", ").join(resourceReader.getHostedStuff(res))); |
|
177 |
addExtra(jg, "online access point", Joiner.on(", ").join(resourceReader.getAccessPoints(res))); |
|
178 |
addExtra(jg, "protocol", Joiner.on(", ").join(resourceReader.getProtocols(res))); |
|
179 |
addExtra(jg, "curates", Joiner.on(", ").join(resourceReader.getCuratedObjects(res))); |
|
180 |
//TODO: where to get it? |
|
181 |
addExtra(jg, "runs on request", ""); |
|
182 |
addExtra(jg, "delivers on request", Joiner.on(", ").join(resourceReader.getDeliversOnRequest(res))); |
|
183 |
addExtra(jg, "uses curation plan", Joiner.on(", ").join(resourceReader.getCurationPlans(res))); |
|
184 |
} |
|
185 | 185 |
//for Projects |
186 |
addExtra(jg, "offers", Joiner.on(", ").join(resourceReader.getOfferedServiceUrls(res))); |
|
187 |
addExtra(jg, "started", Joiner.on(", ").join(resourceReader.getStartTimes(res))); |
|
188 |
|
|
186 |
if(res.hasProperty(RDF.type, CRMpe.PE35_Project)) { |
|
187 |
addExtra(jg, "started on", resourceReader.getStartTime(res)); |
|
188 |
addExtra(jg, "maintaining team", Joiner.on(", ").join(resourceReader.getMaintainerUrls(res))); |
|
189 |
addExtra(jg, "offers", Joiner.on(", ").join(resourceReader.getOfferedServiceUrls(res))); |
|
190 |
} |
|
189 | 191 |
jg.writeEndArray(); //end extras |
190 | 192 |
|
191 | 193 |
jg.writeEndObject(); |
modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/rdf/ResourceReader.java | ||
---|---|---|
242 | 242 |
return Iterators.transform(it, f -> f.getResource().getURI()); |
243 | 243 |
} |
244 | 244 |
|
245 |
public Iterator<String> getStartTimes(final Resource resource){
|
|
246 |
StmtIterator sit1 = resource.listProperties(CRM.P4_has_time_span);
|
|
247 |
StmtIterator sit2 = resource.listProperties(CRM.P82a_begin_of_the_begin);
|
|
248 |
Iterator<String> it1 = Iterators.transform(sit1, f -> getLabel(f.getResource()));
|
|
249 |
Iterator<String> it2 = Iterators.transform(sit2, f -> getLabel(f.getResource()));
|
|
250 |
return Iterators.concat(it1, it2);
|
|
245 |
public String getStartTime(final Resource resource){
|
|
246 |
Resource timespan = resource.getPropertyResourceValue(CRM.P4_has_time_span);
|
|
247 |
if(timespan != null){
|
|
248 |
return timespan.getProperty(CRM.P82a_begin_of_the_begin).getString();
|
|
249 |
}
|
|
250 |
else return "";
|
|
251 | 251 |
} |
252 | 252 |
|
253 | 253 |
public Iterator<String> getMaintainerUrls(final Resource resource){ |
... | ... | |
268 | 268 |
return res; |
269 | 269 |
} |
270 | 270 |
|
271 |
public Iterator<String> getMaintainersForManagementSection(final Resource resource){ |
|
272 |
StmtIterator it = resource.listProperties(CRMpe.PP44_has_maintaining_team); |
|
273 |
return Iterators.transform(it, f -> getLabel(f.getResource())); |
|
274 |
} |
|
275 |
|
|
271 | 276 |
public Iterator<String> getMaintainedUrls(final Resource resource){ |
272 | 277 |
StmtIterator it = resource.listProperties(CRMpe.PP44i_is_maintaining_team_of); |
273 | 278 |
return Iterators.transform(it, f -> f.getResource().getURI()); |
modules/dnet-parthenos-publisher/trunk/src/main/resources/eu/dnetlib/parthenos/sparql/PE35_Project.sparql | ||
---|---|---|
6 | 6 |
<${subjectURL}> a ?type . |
7 | 7 |
<${subjectURL}> rdfs:label ?label . |
8 | 8 |
|
9 |
<${subjectURL}> crm:P2_has_type ?e55Type . |
|
10 |
?e55Type rdfs:label ?e55Type . |
|
11 |
|
|
12 | 9 |
<${subjectURL}> crmpe:PP1_currently_offers ?offeredservice . |
13 | 10 |
|
14 |
<${subjectURL}> crmpe:PP25_has_maintaining_RI ?ri . |
|
15 |
?ri crm:P1_is_identified_by ?riTitle . |
|
16 |
?ri crm:P3_has_note ?riDescr . |
|
17 |
|
|
18 |
<${subjectURL}> crmpe:PP43_supported_project_activity ?activity . |
|
19 | 11 |
<${subjectURL}> crmpe:PP44_has_maintaining_team ?team . |
20 | 12 |
?team crm:P76_has_contact_point ?contactpoint . |
21 | 13 |
?contactpoint crm:P2_has_type ?contactpointType . |
22 | 14 |
?contactpoint rdfs:label ?contactpointLabel . |
23 | 15 |
?contactpointType rdfs:label ?contactpointTypeLabel . |
16 |
|
|
17 |
<${subjectURL}> crm:P4_has_time-span ?time_span . |
|
18 |
?time_span rdfs:label ?time_span_label . |
|
24 | 19 |
} |
25 | 20 |
WHERE { |
26 | 21 |
<${subjectURL}> a crmpe:PE35_Project . |
27 | 22 |
<${subjectURL}> a ?type . |
28 |
{ |
|
23 |
{
|
|
29 | 24 |
<${subjectURL}> crm:P1_is_identified_by ?titleRes . |
30 | 25 |
?titleRes rdfs:label ?title . |
31 | 26 |
} |
27 |
UNION{ <${subjectURL}> crm:P3_has_note ?description .} |
|
28 |
UNION{ <${subjectURL}> rdfs:label ?label .} |
|
29 |
|
|
32 | 30 |
UNION{ |
33 |
<${subjectURL}> crm:P3_has_note ?description . |
|
34 |
} |
|
35 |
UNION{ |
|
36 |
<${subjectURL}> rdfs:label ?label . |
|
37 |
} |
|
38 |
UNION { |
|
39 |
<${subjectURL}> crm:P2_has_type ?e55Type . |
|
40 |
?e55Type rdfs:label ?e55Type . |
|
41 |
} |
|
42 |
UNION{ |
|
43 | 31 |
<${subjectURL}> crmpe:PP1_currently_offers ?offeredservice . |
44 | 32 |
} |
45 | 33 |
UNION{ |
... | ... | |
52 | 40 |
?contactpoint rdfs:label ?contactpointLabel . |
53 | 41 |
?contactpointType rdfs:label ?contactpointTypeLabel . |
54 | 42 |
} |
55 |
UNION { |
|
56 |
<${subjectURL}> crmpe:PP25_has_maintaining_RI ?ri . |
|
57 |
?ri crm:P1_is_identified_by ?riTitle . |
|
58 |
?ri crm:P3_has_note ?riDescr . |
|
43 |
UNION { |
|
44 |
<${subjectURL}> crm:P4_has_time-span ?time_span . |
|
45 |
?time_span crm:P82a_begin_of_the_begin ?time_actual . |
|
59 | 46 |
} |
60 | 47 |
|
61 |
} |
|
48 |
} |
Also available in: Unified diff
Better mapping Projects into the catalogue