Revision 49200
Added by Alessia Bardi over 5 years ago
modules/dnet-parthenos-publisher/trunk/test/main/java/eu/dnetlib/parthenos/registry/JacksonTest.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.io.IOException; |
4 | 4 |
import java.io.StringWriter; |
5 |
import java.util.UUID; |
|
5 | 6 |
|
6 | 7 |
import com.fasterxml.jackson.core.JsonFactory; |
7 | 8 |
import com.fasterxml.jackson.core.JsonGenerator; |
... | ... | |
54 | 55 |
jgen.close(); |
55 | 56 |
System.out.println(sw.getBuffer().toString()); |
56 | 57 |
} |
58 |
|
|
59 |
@Test |
|
60 |
public void testHeader() throws IOException { |
|
61 |
JsonFactory jsonFactory = new JsonFactory(); |
|
62 |
StringWriter sw = new StringWriter(); |
|
63 |
JsonGenerator jgen = jsonFactory.createGenerator(sw); |
|
64 |
jgen.writeStartObject(); |
|
65 |
jgen.writeObjectFieldStart("header"); |
|
66 |
jgen.writeStringField("uuid", UUID.randomUUID().toString()); |
|
67 |
jgen.writeEndObject(); |
|
68 |
jgen.writeStringField("@class", "specificType"); |
|
69 |
jgen.writeArrayFieldStart("consistsOf"); |
|
70 |
jgen.writeEndArray(); |
|
71 |
jgen.writeEndObject(); |
|
72 |
|
|
73 |
jgen.close(); |
|
74 |
System.out.println(sw.getBuffer().toString()); |
|
75 |
} |
|
57 | 76 |
} |
modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/CRM.java | ||
---|---|---|
2147 | 2147 |
* Instances of E33 Linguistic Object can be expressed in many ways: e.g. as |
2148 | 2148 |
* written texts, recorded speech or sign language. However, the CRM treats instances |
2149 | 2149 |
* of E33 Linguistic Object independently from the medium or method by which |
2150 |
* they are expressed. Expressions in formal languages, such as computer code |
|
2150 |
* they are expressed. Expressions in formal languages, such as computer codeFE41_
|
|
2151 | 2151 |
* or mathematical formulae, are not treated as instances of E33 Linguistic Object |
2152 | 2152 |
* by the CRM. These should be modelled as instances of E73 Information Object. |
2153 | 2153 |
* The text of an instance of E33 Linguistic Object can be documented in a note |
modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/registry/FacetWriter.java | ||
---|---|---|
21 | 21 |
@Component |
22 | 22 |
public class FacetWriter { |
23 | 23 |
|
24 |
protected void writeIdentifierFacet(final JsonGenerator jg, final String identifier) throws IOException {
|
|
24 |
public void writeP1Facet(final JsonGenerator jg, final String value, final IdentificationType type) throws IOException {
|
|
25 | 25 |
jg.writeStartObject(); |
26 | 26 |
jg.writeStringField("@class", "P1_is_identified_by"); |
27 | 27 |
jg.writeObjectFieldStart("target"); |
28 | 28 |
jg.writeStringField("@class", "IdentifierFacet"); |
29 |
jg.writeStringField("value", value); |
|
30 |
jg.writeStringField("type", type.name()); |
|
31 |
jg.writeEndObject(); |
|
32 |
jg.writeEndObject(); |
|
33 |
} |
|
34 |
|
|
35 |
public void writeIdentifierFacet(final JsonGenerator jg, final String identifier) throws IOException { |
|
36 |
jg.writeStartObject(); |
|
37 |
jg.writeStringField("@class", "isIdentifiedBy"); |
|
38 |
jg.writeObjectFieldStart("target"); |
|
39 |
jg.writeStringField("@class", "IdentifierFacet"); |
|
29 | 40 |
jg.writeStringField("value", identifier); |
30 | 41 |
jg.writeStringField("type", IdentificationType.URI.name()); |
31 | 42 |
jg.writeEndObject(); |
32 | 43 |
jg.writeEndObject(); |
33 | 44 |
} |
34 | 45 |
|
35 |
protected void writeInfoFacet(final JsonGenerator jg, final Resource res) throws IOException {
|
|
46 |
public void writeInfoFacet(final JsonGenerator jg, final Resource res) throws IOException {
|
|
36 | 47 |
jg.writeStartObject(); |
37 | 48 |
jg.writeStringField("@class", "PE_Info_Facet"); |
38 | 49 |
jg.writeObjectFieldStart("target"); |
39 | 50 |
jg.writeStringField("title", getTitleFromRDFResource(res)); |
40 | 51 |
jg.writeStringField("description", getDescriptionFromRDFResource(res)); |
52 |
//new object comp + field value + schema="noSchema" |
|
41 | 53 |
jg.writeStringField("competence", getCompetenceFromRDFResource(res)); |
42 | 54 |
//TODO: uncomment this when George adds the rel to the model, see method getAvailabilityFromRDFResource below |
43 | 55 |
//jg.writeStringField("availability", getAvailabilityFromRDFResource(res)); |
... | ... | |
45 | 57 |
jg.writeEndObject(); |
46 | 58 |
} |
47 | 59 |
|
48 |
|
|
49 |
protected void writeEventFacet(final JsonGenerator jg){ |
|
60 |
public void writeEventFacet(final JsonGenerator jg) { |
|
50 | 61 |
//TODO: implement me. get begin/end of operation from PP42_has_declarative_time |
51 | 62 |
} |
52 | 63 |
|
53 |
protected void writeRightsFacet(final JsonGenerator jg, final Resource res) throws IOException {
|
|
64 |
public void writeRightsFacet(final JsonGenerator jg, final Resource res) throws IOException {
|
|
54 | 65 |
//TODO: implement me. E30_Right facet extends from licenseFacet but it is not correct (textUrl is mandatory, we can't use it in Parthenos) |
55 | 66 |
} |
56 | 67 |
|
57 |
protected void writeContactReferenceFacet(final JsonGenerator jg, final Resource resource) throws IOException { |
|
58 |
//PP2_provided_by |
|
59 |
final Statement s = resource.getProperty(CRMpe.PP2_provided_by); |
|
60 |
|
|
61 |
if(s!=null){ |
|
62 |
String appellation = ""; |
|
63 |
String description = ""; |
|
64 |
String legalAddress = ""; |
|
65 |
String email =""; |
|
68 |
public void writeContactReferenceFacet(final JsonGenerator jg, final Resource actor) throws IOException { |
|
69 |
if (actor != null) { |
|
70 |
String appellation = getTitleFromRDFResource(actor); |
|
71 |
String description = getDescriptionFromRDFResource(actor); |
|
72 |
String legalAddress = ""; |
|
73 |
String email = ""; |
|
66 | 74 |
String website = ""; |
67 |
String address = ""; |
|
68 |
String phoneNumber =""; |
|
69 |
|
|
70 |
Resource provider = s.getResource(); |
|
71 |
if(provider != null){ |
|
72 |
//more contact point per provider |
|
73 |
StmtIterator contactPointsStm = provider.listProperties(CRM.P76_has_contact_point); |
|
74 |
while(contactPointsStm.hasNext()){ |
|
75 |
Resource cp = contactPointsStm.nextStatement().getResource(); |
|
76 |
appellation = getLabelFromRDFResource(cp); |
|
77 |
description = getDescriptionFromRDFResource(cp); |
|
78 |
//TODO: where to find email and legaladdress, address, phoneNumber, website? |
|
79 |
jg.writeStartObject(); |
|
80 |
jg.writeStringField("@class", "PE_Contact_Reference_Facet"); |
|
81 |
jg.writeObjectFieldStart("target"); |
|
82 |
jg.writeStringField("appellation", appellation); |
|
83 |
jg.writeStringField("description", description); |
|
84 |
jg.writeStringField("legalAddress", legalAddress); |
|
85 |
jg.writeStringField("email", email); |
|
86 |
jg.writeStringField("website", website); |
|
87 |
jg.writeStringField("address", address); |
|
88 |
jg.writeStringField("phoneNumber", phoneNumber); |
|
89 |
jg.writeEndObject(); |
|
90 |
jg.writeEndObject(); |
|
75 |
String address = ""; |
|
76 |
String phoneNumber = ""; |
|
77 |
//more contact point per provider |
|
78 |
StmtIterator contactPointsStm = actor.listProperties(CRM.P76_has_contact_point); |
|
79 |
while (contactPointsStm.hasNext()) { |
|
80 |
Resource cp = contactPointsStm.nextStatement().getResource(); |
|
81 |
//contact points can bean E45_Address or E51_Contact_Point |
|
82 |
if ((cp.hasProperty(RDF.type, CRM.E45_Address) || cp.hasProperty(RDF.type, CRM.E51_Contact_Point)) && cp.hasProperty(CRM.P2_has_type)) { |
|
83 |
Resource addressType = cp.getPropertyResourceValue(CRM.P2_has_type); |
|
84 |
String info = getLabelFromRDFResource(cp); |
|
85 |
String addressTypeLabel = getLabelFromRDFResource(addressType); |
|
86 |
switch (addressTypeLabel.toLowerCase()) { |
|
87 |
case "email": |
|
88 |
email = info; |
|
89 |
break; |
|
90 |
case "legal address": |
|
91 |
legalAddress = info; |
|
92 |
break; |
|
93 |
case "address": |
|
94 |
address = info; |
|
95 |
break; |
|
96 |
case "phone": |
|
97 |
phoneNumber = info; |
|
98 |
break; |
|
99 |
case "web": |
|
100 |
website = info; |
|
101 |
break; |
|
102 |
} |
|
91 | 103 |
} |
92 | 104 |
} |
105 |
jg.writeStartObject(); |
|
106 |
jg.writeStringField("@class", "PE_Contact_Reference_Facet"); |
|
107 |
jg.writeObjectFieldStart("target"); |
|
108 |
jg.writeStringField("appellation", appellation); |
|
109 |
jg.writeStringField("description", description); |
|
110 |
jg.writeStringField("legalAddress", legalAddress); |
|
111 |
jg.writeStringField("email", email); |
|
112 |
jg.writeStringField("website", website); |
|
113 |
jg.writeStringField("address", address); |
|
114 |
jg.writeStringField("phoneNumber", phoneNumber); |
|
115 |
jg.writeEndObject(); |
|
116 |
jg.writeEndObject(); |
|
93 | 117 |
} |
94 |
|
|
95 | 118 |
} |
96 | 119 |
|
97 |
protected void writeDesignatedAccessPointFacet(final JsonGenerator jg, final Resource resource) throws IOException {
|
|
120 |
public void writeDesignatedAccessPointFacet(final JsonGenerator jg, final Resource resource) throws IOException {
|
|
98 | 121 |
//PP28_has_designated_access_point |
99 | 122 |
StmtIterator apStms = resource.listProperties(CRMpe.PP28_has_designated_access_point); |
100 |
while(apStms.hasNext()){
|
|
123 |
while (apStms.hasNext()) {
|
|
101 | 124 |
String entryName = getLabelFromRDFResource(resource); |
102 | 125 |
//(mandatory) |
103 |
String endpoint= ""; |
|
104 |
String protocol= ""; |
|
105 |
String description= getDescriptionFromRDFResource(resource); |
|
126 |
String endpoint = "";
|
|
127 |
String protocol = "";
|
|
128 |
String description = getDescriptionFromRDFResource(resource);
|
|
106 | 129 |
//TODO: authorization is a ValueSchema, I do not understand how to use it and how to map it |
107 |
String authorization= ""; |
|
130 |
String authorization = "";
|
|
108 | 131 |
Resource ap = apStms.next().getResource(); |
109 | 132 |
endpoint = ap.getURI(); |
110 | 133 |
//TODO: where to get protocol and authorization? |
... | ... | |
123 | 146 |
|
124 | 147 |
} |
125 | 148 |
|
149 |
public void writeTemporalCoverageFacet(final JsonGenerator jg, final Resource resource) { |
|
150 |
//TODO: CoverageFacet wants a value and a mandatory schema. Can't be applied to Parthenos. |
|
151 |
} |
|
126 | 152 |
|
127 |
protected String getTitleFromRDFResource(final Resource resource){ |
|
153 |
protected String getTitleFromRDFResource(final Resource resource) {
|
|
128 | 154 |
String title = ""; |
129 | 155 |
final Statement s = resource.getProperty(CRM.P1_is_identified_by); |
130 |
if(s != null){
|
|
156 |
if (s != null) {
|
|
131 | 157 |
Resource titleRes = s.getResource(); |
132 |
if(titleRes != null && (titleRes.hasProperty(RDF.type, CRM.E35_Title) || titleRes.hasProperty(RDF.type, CRM.E41_Appellation) )){
|
|
158 |
if (titleRes != null && (titleRes.hasProperty(RDF.type, CRM.E35_Title) || titleRes.hasProperty(RDF.type, CRM.E41_Appellation))) {
|
|
133 | 159 |
title = getLabelFromRDFResource(titleRes); |
134 | 160 |
} |
135 | 161 |
} |
136 | 162 |
return title; |
137 | 163 |
} |
138 | 164 |
|
139 |
protected String getDescriptionFromRDFResource(final Resource resource){ |
|
140 |
if(resource.hasProperty(CRM.P3_has_note)){
|
|
165 |
protected String getDescriptionFromRDFResource(final Resource resource) {
|
|
166 |
if (resource.hasProperty(CRM.P3_has_note)) {
|
|
141 | 167 |
return resource.getProperty(CRM.P3_has_note).getString(); |
142 |
} |
|
143 |
else return ""; |
|
168 |
} else return ""; |
|
144 | 169 |
} |
145 | 170 |
|
146 |
protected String getLabelFromRDFResource(final Resource resource){ |
|
147 |
if(resource.hasProperty(RDFS.label)){
|
|
171 |
protected String getLabelFromRDFResource(final Resource resource) {
|
|
172 |
if (resource.hasProperty(RDFS.label)) {
|
|
148 | 173 |
return resource.getProperty(RDFS.label).getString(); |
149 |
} |
|
150 |
else return ""; |
|
174 |
} else return ""; |
|
151 | 175 |
} |
152 | 176 |
|
153 |
protected String getCompetenceFromRDFResource(final Resource resource){ |
|
177 |
protected String getCompetenceFromRDFResource(final Resource resource) {
|
|
154 | 178 |
String comp = ""; |
155 |
if(resource.hasProperty(CRMpe.PP45_has_competency)){
|
|
179 |
if (resource.hasProperty(CRMpe.PP45_has_competency)) {
|
|
156 | 180 |
Resource compRes = resource.getProperty(CRMpe.PP45_has_competency).getResource(); |
157 |
if(compRes.hasProperty(RDFS.label)) |
|
181 |
if (compRes.hasProperty(RDFS.label))
|
|
158 | 182 |
comp = compRes.getProperty(RDFS.label).getString(); |
159 | 183 |
} |
160 | 184 |
return comp; |
161 | 185 |
} |
162 | 186 |
|
163 |
protected String getAvailabilityFromRDFResource(final Resource resource){ |
|
187 |
protected String getAvailabilityFromRDFResource(final Resource resource) {
|
|
164 | 188 |
//TODO: implement this when George adds the rel to the model |
165 | 189 |
return ""; |
166 | 190 |
} |
modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/registry/RelWriter.java | ||
---|---|---|
1 |
package eu.dnetlib.parthenos.registry; |
|
2 |
|
|
3 |
import org.springframework.stereotype.Component; |
|
4 |
|
|
5 |
/** |
|
6 |
* Created by Alessia Bardi on 02/10/2017. |
|
7 |
* |
|
8 |
* @author Alessia Bardi |
|
9 |
*/ |
|
10 |
@Component |
|
11 |
public class RelWriter { |
|
12 |
|
|
13 |
} |
modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/registry/GCubeResourceGenerator.java | ||
---|---|---|
44 | 44 |
|
45 | 45 |
@Autowired |
46 | 46 |
private FacetWriter facetWriter; |
47 |
@Autowired |
|
48 |
private RelWriter relWriter; |
|
47 | 49 |
|
48 | 50 |
public GCubeResourceGenerator() { |
49 |
final String url = "http://www.w3.org/TR/REC-rdf-syntax/example14.nt"; |
|
50 | 51 |
baseModel = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM_TRANS_INF); |
51 | 52 |
baseModel.read(CRMpe.RDFS_URL); |
52 | 53 |
baseModel.read(CRM.RDFS_URL); |
... | ... | |
77 | 78 |
JsonFactory jsonFactory = new JsonFactory(); |
78 | 79 |
Set<String> uriProcessed = Sets.newHashSet(); |
79 | 80 |
|
81 |
//TODO: many things in common in the code below: re-factor it! |
|
82 |
|
|
83 |
|
|
84 |
log.debug("Processing services"); |
|
80 | 85 |
//let's start with services |
81 | 86 |
ResIterator iter = model.listResourcesWithProperty(RDF.type, CRMpe.PE1_Service); |
82 | 87 |
while (iter.hasNext()) { |
... | ... | |
89 | 94 |
JsonGenerator jg = jsonFactory.createGenerator(sw); |
90 | 95 |
jg.writeStartObject(); |
91 | 96 |
|
92 |
jg.writeStringField("@class", specificType.getURI()); |
|
97 |
//TODO: generate header with uuid for all type of entities, so we can also generate the rels. Need a map for uri --> uuid. |
|
98 |
jg.writeStringField("@class", specificType.getLocalName()); |
|
93 | 99 |
|
94 | 100 |
//******THE FACETS *******// |
95 | 101 |
jg.writeArrayFieldStart("consistsOf"); |
96 | 102 |
//list of facets |
97 |
|
|
103 |
//TODO: write P1 identifier facet following the existing links (for all types) |
|
98 | 104 |
facetWriter.writeIdentifierFacet(jg, resourceURI); |
99 | 105 |
facetWriter.writeInfoFacet(jg, res); |
100 | 106 |
facetWriter.writeEventFacet(jg); |
101 | 107 |
facetWriter.writeRightsFacet(jg, res); |
102 |
facetWriter.writeContactReferenceFacet(jg, res); |
|
108 |
if(res.hasProperty(CRMpe.PP2_provided_by)){ |
|
109 |
//TODO: shouldn't this be a rel to an actor? |
|
110 |
Resource provider = res.getPropertyResourceValue(CRMpe.PP2_provided_by); |
|
111 |
facetWriter.writeContactReferenceFacet(jg, provider); |
|
112 |
} |
|
113 |
|
|
103 | 114 |
facetWriter.writeDesignatedAccessPointFacet(jg, res); |
104 | 115 |
|
105 | 116 |
jg.writeEndArray(); |
106 | 117 |
|
107 |
// ******* RELATIONSHIPS *****// |
|
108 |
jg.writeArrayFieldStart("isRelatedto"); |
|
118 |
// ******* RELATIONSHIPS ***** ??? or separately after we got the ids of everything?// |
|
119 |
//jg.writeArrayFieldStart("isRelatedto"); |
|
120 |
//jg.writeEndArray(); |
|
109 | 121 |
|
122 |
jg.writeEndObject(); |
|
123 |
jg.close(); |
|
124 |
String json = sw.toString(); |
|
125 |
log.debug(json); |
|
126 |
jsonResources.add(json); |
|
127 |
uriProcessed.add(resourceURI); |
|
128 |
} else { |
|
129 |
log.debug(resourceURI+" already processed, now skipping it"); |
|
130 |
} |
|
131 |
} |
|
132 |
|
|
133 |
log.debug("Processing digital objects (include dataset and software)"); |
|
134 |
//and then the datasets |
|
135 |
ResIterator iterDo = model.listResourcesWithProperty(RDF.type, CRMdig.D1_Digital_Object); |
|
136 |
while (iterDo.hasNext()) { |
|
137 |
Resource res = iterDo.nextResource(); |
|
138 |
String resourceURI = res.getURI(); |
|
139 |
if (!uriProcessed.contains(resourceURI)) { |
|
140 |
log.debug("Processing " + resourceURI); |
|
141 |
Resource specificType = findSpecificType(res, CRMdig.D1_Digital_Object); |
|
142 |
StringWriter sw = new StringWriter(); |
|
143 |
JsonGenerator jg = jsonFactory.createGenerator(sw); |
|
144 |
jg.writeStartObject(); |
|
145 |
|
|
146 |
jg.writeStringField("@class", specificType.getLocalName()); |
|
147 |
//******THE FACETS *******// |
|
148 |
jg.writeArrayFieldStart("consistsOf"); |
|
149 |
//list of facets |
|
150 |
facetWriter.writeIdentifierFacet(jg, resourceURI); |
|
151 |
facetWriter.writeInfoFacet(jg, res); |
|
152 |
facetWriter.writeTemporalCoverageFacet(jg, res); |
|
153 |
facetWriter.writeRightsFacet(jg, res); |
|
154 |
|
|
110 | 155 |
jg.writeEndArray(); |
156 |
jg.writeEndObject(); |
|
157 |
jg.close(); |
|
158 |
String json = sw.toString(); |
|
159 |
log.debug(json); |
|
160 |
jsonResources.add(json); |
|
161 |
uriProcessed.add(resourceURI); |
|
111 | 162 |
|
163 |
} else { |
|
164 |
log.debug(resourceURI + " already processed, now skipping it"); |
|
165 |
} |
|
166 |
} |
|
112 | 167 |
|
168 |
log.debug("Processing actors"); |
|
169 |
//and then the datasets |
|
170 |
ResIterator iterActors = model.listResourcesWithProperty(RDF.type, CRM.E39_Actor); |
|
171 |
while (iterActors.hasNext()) { |
|
172 |
Resource res = iterActors.nextResource(); |
|
173 |
String resourceURI = res.getURI(); |
|
174 |
if (!uriProcessed.contains(resourceURI)) { |
|
175 |
log.debug("Processing " + resourceURI); |
|
176 |
Resource specificType = findSpecificType(res, CRM.E39_Actor); |
|
177 |
StringWriter sw = new StringWriter(); |
|
178 |
JsonGenerator jg = jsonFactory.createGenerator(sw); |
|
179 |
jg.writeStartObject(); |
|
180 |
|
|
181 |
jg.writeStringField("@class", specificType.getLocalName()); |
|
182 |
//******THE FACETS *******// |
|
183 |
jg.writeArrayFieldStart("consistsOf"); |
|
184 |
//list of facets |
|
185 |
facetWriter.writeIdentifierFacet(jg, resourceURI); |
|
186 |
facetWriter.writeContactReferenceFacet(jg, res); |
|
187 |
|
|
188 |
jg.writeEndArray(); |
|
189 |
jg.writeEndObject(); |
|
190 |
jg.close(); |
|
191 |
String json = sw.toString(); |
|
192 |
log.debug(json); |
|
193 |
jsonResources.add(json); |
|
194 |
uriProcessed.add(resourceURI); |
|
195 |
|
|
196 |
} else { |
|
197 |
log.debug(resourceURI + " already processed, now skipping it"); |
|
198 |
} |
|
199 |
} |
|
200 |
log.debug("Processing software"); |
|
201 |
ResIterator iterSw = model.listResourcesWithProperty(RDF.type, CRMdig.D14_Software); |
|
202 |
while (iterSw.hasNext()) { |
|
203 |
Resource res = iterSw.nextResource(); |
|
204 |
String resourceURI = res.getURI(); |
|
205 |
if (!uriProcessed.contains(resourceURI)) { |
|
206 |
log.debug("Processing " + resourceURI); |
|
207 |
Resource specificType = findSpecificType(res, CRMdig.D14_Software); |
|
208 |
StringWriter sw = new StringWriter(); |
|
209 |
JsonGenerator jg = jsonFactory.createGenerator(sw); |
|
210 |
jg.writeStartObject(); |
|
211 |
|
|
212 |
jg.writeStringField("@class", specificType.getLocalName()); |
|
213 |
//******THE FACETS *******// |
|
214 |
jg.writeArrayFieldStart("consistsOf"); |
|
215 |
//list of facets |
|
216 |
facetWriter.writeIdentifierFacet(jg, resourceURI); |
|
217 |
facetWriter.writeInfoFacet(jg, res); |
|
218 |
|
|
219 |
jg.writeEndArray(); |
|
113 | 220 |
jg.writeEndObject(); |
114 | 221 |
jg.close(); |
115 | 222 |
String json = sw.toString(); |
116 | 223 |
log.debug(json); |
117 | 224 |
jsonResources.add(json); |
118 | 225 |
uriProcessed.add(resourceURI); |
226 |
|
|
119 | 227 |
} else { |
120 |
log.debug(resourceURI+" already processed, now skipping it");
|
|
228 |
log.debug(resourceURI + " already processed, now skipping it");
|
|
121 | 229 |
} |
122 | 230 |
} |
231 |
log.debug("Processing projects"); |
|
232 |
//and then the projects |
|
233 |
ResIterator iterProjects = model.listResourcesWithProperty(RDF.type, CRMpe.PE35_Project); |
|
234 |
while (iterProjects.hasNext()) { |
|
235 |
Resource res = iterProjects.nextResource(); |
|
236 |
String resourceURI = res.getURI(); |
|
237 |
if (!uriProcessed.contains(resourceURI)) { |
|
238 |
log.debug("Processing " + resourceURI); |
|
239 |
Resource specificType = findSpecificType(res, CRMpe.PE35_Project); |
|
240 |
StringWriter sw = new StringWriter(); |
|
241 |
JsonGenerator jg = jsonFactory.createGenerator(sw); |
|
242 |
jg.writeStartObject(); |
|
243 |
|
|
244 |
jg.writeStringField("@class", specificType.getLocalName()); |
|
245 |
//******THE FACETS *******// |
|
246 |
jg.writeArrayFieldStart("consistsOf"); |
|
247 |
//list of facets |
|
248 |
facetWriter.writeIdentifierFacet(jg, resourceURI); |
|
249 |
facetWriter.writeInfoFacet(jg, res); |
|
250 |
|
|
251 |
jg.writeEndArray(); |
|
252 |
jg.writeEndObject(); |
|
253 |
jg.close(); |
|
254 |
String json = sw.toString(); |
|
255 |
log.debug(json); |
|
256 |
jsonResources.add(json); |
|
257 |
uriProcessed.add(resourceURI); |
|
258 |
|
|
259 |
} else { |
|
260 |
log.debug(resourceURI + " already processed, now skipping it"); |
|
261 |
} |
|
262 |
} |
|
123 | 263 |
return jsonResources; |
124 | 264 |
} |
125 | 265 |
|
266 |
|
|
267 |
|
|
268 |
|
|
126 | 269 |
/** |
127 | 270 |
* Finds the most specific type of res. |
128 | 271 |
* @param res Resource you want to find the most specific type |
modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/registry/RegistryClient.java | ||
---|---|---|
70 | 70 |
return 0; |
71 | 71 |
} |
72 | 72 |
//TODO: get the json strings to register |
73 |
Iterable<String> resources = resourceGenerator.getGCubeER(record); |
|
74 |
for(String res : resources){ |
|
75 |
//resourceRegistryPublisher. |
|
76 |
} |
|
73 | 77 |
return 0; |
74 | 78 |
}catch(Throwable e){ |
75 | 79 |
log.error(e.getMessage()); |
Also available in: Unified diff
More mapping to gcube resources and facets