Index: modules/dnet-parthenos-publisher/trunk/test/main/java/eu/dnetlib/parthenos/registry/JacksonTest.java
===================================================================
--- modules/dnet-parthenos-publisher/trunk/test/main/java/eu/dnetlib/parthenos/registry/JacksonTest.java	(revision 49199)
+++ modules/dnet-parthenos-publisher/trunk/test/main/java/eu/dnetlib/parthenos/registry/JacksonTest.java	(revision 49200)
@@ -2,6 +2,7 @@
 
 import java.io.IOException;
 import java.io.StringWriter;
+import java.util.UUID;
 
 import com.fasterxml.jackson.core.JsonFactory;
 import com.fasterxml.jackson.core.JsonGenerator;
@@ -54,4 +55,22 @@
 		jgen.close();
 		System.out.println(sw.getBuffer().toString());
 	}
+
+	@Test
+	public void testHeader() throws IOException {
+		JsonFactory jsonFactory = new JsonFactory();
+		StringWriter sw = new StringWriter();
+		JsonGenerator jgen = jsonFactory.createGenerator(sw);
+		jgen.writeStartObject();
+		jgen.writeObjectFieldStart("header");
+		jgen.writeStringField("uuid", UUID.randomUUID().toString());
+		jgen.writeEndObject();
+		jgen.writeStringField("@class", "specificType");
+		jgen.writeArrayFieldStart("consistsOf");
+		jgen.writeEndArray();
+		jgen.writeEndObject();
+
+		jgen.close();
+		System.out.println(sw.getBuffer().toString());
+	}
 }
Index: modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/CRM.java
===================================================================
--- modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/CRM.java	(revision 49199)
+++ modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/CRM.java	(revision 49200)
@@ -2147,7 +2147,7 @@
 	 * Instances of E33 Linguistic Object can be expressed in many ways: e.g. as
 	 * written texts, recorded speech or sign language. However, the CRM treats instances
 	 * of E33 Linguistic Object independently from the medium or method by which
-	 * they are expressed. Expressions in formal languages, such as computer code
+	 * they are expressed. Expressions in formal languages, such as computer codeFE41_
 	 * or mathematical formulae, are not treated as instances of E33 Linguistic Object
 	 * by the CRM. These should be modelled as instances of E73 Information Object.
 	 * The text of an instance of E33 Linguistic Object can be documented in a note
Index: modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/registry/FacetWriter.java
===================================================================
--- modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/registry/FacetWriter.java	(revision 49199)
+++ modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/registry/FacetWriter.java	(revision 49200)
@@ -21,11 +21,22 @@
 @Component
 public class FacetWriter {
 
-	protected void writeIdentifierFacet(final JsonGenerator jg, final String identifier) throws IOException {
+	public void writeP1Facet(final JsonGenerator jg, final String value, final IdentificationType type) throws IOException {
 		jg.writeStartObject();
 		jg.writeStringField("@class", "P1_is_identified_by");
 		jg.writeObjectFieldStart("target");
 		jg.writeStringField("@class", "IdentifierFacet");
+		jg.writeStringField("value", value);
+		jg.writeStringField("type", type.name());
+		jg.writeEndObject();
+		jg.writeEndObject();
+	}
+
+	public void writeIdentifierFacet(final JsonGenerator jg, final String identifier) throws IOException {
+		jg.writeStartObject();
+		jg.writeStringField("@class", "isIdentifiedBy");
+		jg.writeObjectFieldStart("target");
+		jg.writeStringField("@class", "IdentifierFacet");
 		jg.writeStringField("value", identifier);
 		jg.writeStringField("type", IdentificationType.URI.name());
 		jg.writeEndObject();
@@ -32,12 +43,13 @@
 		jg.writeEndObject();
 	}
 
-	protected void writeInfoFacet(final JsonGenerator jg, final Resource res) throws IOException {
+	public void writeInfoFacet(final JsonGenerator jg, final Resource res) throws IOException {
 		jg.writeStartObject();
 		jg.writeStringField("@class", "PE_Info_Facet");
 		jg.writeObjectFieldStart("target");
 		jg.writeStringField("title", getTitleFromRDFResource(res));
 		jg.writeStringField("description", getDescriptionFromRDFResource(res));
+		//new object comp + field value + schema="noSchema"
 		jg.writeStringField("competence", getCompetenceFromRDFResource(res));
 		//TODO: uncomment this when George adds the rel to the model, see method getAvailabilityFromRDFResource below
 		//jg.writeStringField("availability", getAvailabilityFromRDFResource(res));
@@ -45,66 +57,77 @@
 		jg.writeEndObject();
 	}
 
-
-	protected void writeEventFacet(final JsonGenerator jg){
+	public void writeEventFacet(final JsonGenerator jg) {
 		//TODO: implement me. get begin/end of operation from PP42_has_declarative_time
 	}
 
-	protected void writeRightsFacet(final JsonGenerator jg, final Resource res) throws IOException {
+	public void writeRightsFacet(final JsonGenerator jg, final Resource res) throws IOException {
 		//TODO: implement me. E30_Right facet extends from licenseFacet but it is not correct (textUrl is mandatory, we can't use it in Parthenos)
 	}
 
-	protected void writeContactReferenceFacet(final JsonGenerator jg, final Resource resource) throws IOException {
-		//PP2_provided_by
-		final Statement s = resource.getProperty(CRMpe.PP2_provided_by);
-
-		if(s!=null){
-			String appellation = "";
-			String description = "";
-			String legalAddress  = "";
-			String email ="";
+	public void writeContactReferenceFacet(final JsonGenerator jg, final Resource actor) throws IOException {
+		if (actor != null) {
+			String appellation = getTitleFromRDFResource(actor);
+			String description = getDescriptionFromRDFResource(actor);
+			String legalAddress = "";
+			String email = "";
 			String website = "";
-			String address  = "";
-			String phoneNumber ="";
-
-			Resource provider = s.getResource();
-			if(provider != null){
-				//more contact point per provider
-				StmtIterator contactPointsStm = provider.listProperties(CRM.P76_has_contact_point);
-				while(contactPointsStm.hasNext()){
-					Resource cp = contactPointsStm.nextStatement().getResource();
-					appellation = getLabelFromRDFResource(cp);
-					description = getDescriptionFromRDFResource(cp);
-					//TODO: where to find email and legaladdress, address, phoneNumber, website?
-					jg.writeStartObject();
-					jg.writeStringField("@class", "PE_Contact_Reference_Facet");
-					jg.writeObjectFieldStart("target");
-					jg.writeStringField("appellation", appellation);
-					jg.writeStringField("description", description);
-					jg.writeStringField("legalAddress", legalAddress);
-					jg.writeStringField("email", email);
-					jg.writeStringField("website", website);
-					jg.writeStringField("address", address);
-					jg.writeStringField("phoneNumber", phoneNumber);
-					jg.writeEndObject();
-					jg.writeEndObject();
+			String address = "";
+			String phoneNumber = "";
+			//more contact point per provider
+			StmtIterator contactPointsStm = actor.listProperties(CRM.P76_has_contact_point);
+			while (contactPointsStm.hasNext()) {
+				Resource cp = contactPointsStm.nextStatement().getResource();
+				//contact points can bean E45_Address or E51_Contact_Point
+				if ((cp.hasProperty(RDF.type, CRM.E45_Address) || cp.hasProperty(RDF.type, CRM.E51_Contact_Point)) && cp.hasProperty(CRM.P2_has_type)) {
+					Resource addressType = cp.getPropertyResourceValue(CRM.P2_has_type);
+					String info = getLabelFromRDFResource(cp);
+					String addressTypeLabel = getLabelFromRDFResource(addressType);
+					switch (addressTypeLabel.toLowerCase()) {
+					case "email":
+						email = info;
+						break;
+					case "legal address":
+						legalAddress = info;
+						break;
+					case "address":
+						address = info;
+						break;
+					case "phone":
+						phoneNumber = info;
+						break;
+					case "web":
+						website = info;
+						break;
+					}
 				}
 			}
+			jg.writeStartObject();
+			jg.writeStringField("@class", "PE_Contact_Reference_Facet");
+			jg.writeObjectFieldStart("target");
+			jg.writeStringField("appellation", appellation);
+			jg.writeStringField("description", description);
+			jg.writeStringField("legalAddress", legalAddress);
+			jg.writeStringField("email", email);
+			jg.writeStringField("website", website);
+			jg.writeStringField("address", address);
+			jg.writeStringField("phoneNumber", phoneNumber);
+			jg.writeEndObject();
+			jg.writeEndObject();
 		}
-
 	}
 
-	protected void writeDesignatedAccessPointFacet(final JsonGenerator jg, final Resource resource) throws IOException {
+	public void writeDesignatedAccessPointFacet(final JsonGenerator jg, final Resource resource) throws IOException {
 		//PP28_has_designated_access_point
 		StmtIterator apStms = resource.listProperties(CRMpe.PP28_has_designated_access_point);
-		while(apStms.hasNext()){
+		while (apStms.hasNext()) {
 			String entryName = getLabelFromRDFResource(resource);
 			//(mandatory)
-			String endpoint= "";
-			String protocol= "";
-			String description= getDescriptionFromRDFResource(resource);
+			String endpoint = "";
+			String protocol = "";
+			String description = getDescriptionFromRDFResource(resource);
 			//TODO: authorization is a ValueSchema, I do not understand how to use it and how to map it
-			String authorization= "";
+			String authorization = "";
 			Resource ap = apStms.next().getResource();
 			endpoint = ap.getURI();
 			//TODO: where to get protocol and authorization?
@@ -123,13 +146,16 @@
 
 	}
 
+	public void writeTemporalCoverageFacet(final JsonGenerator jg, final Resource resource) {
+		//TODO: CoverageFacet wants a value and a mandatory schema. Can't be applied to Parthenos.
+	}
 
-	protected String getTitleFromRDFResource(final Resource resource){
+	protected String getTitleFromRDFResource(final Resource resource) {
 		String title = "";
 		final Statement s = resource.getProperty(CRM.P1_is_identified_by);
-		if(s != null){
+		if (s != null) {
 			Resource titleRes = s.getResource();
-			if(titleRes != null && (titleRes.hasProperty(RDF.type, CRM.E35_Title) || titleRes.hasProperty(RDF.type, CRM.E41_Appellation) )){
+			if (titleRes != null && (titleRes.hasProperty(RDF.type, CRM.E35_Title) || titleRes.hasProperty(RDF.type, CRM.E41_Appellation))) {
 				title = getLabelFromRDFResource(titleRes);
 			}
 		}
@@ -136,31 +162,29 @@
 		return title;
 	}
 
-	protected String getDescriptionFromRDFResource(final Resource resource){
-		if(resource.hasProperty(CRM.P3_has_note)){
+	protected String getDescriptionFromRDFResource(final Resource resource) {
+		if (resource.hasProperty(CRM.P3_has_note)) {
 			return resource.getProperty(CRM.P3_has_note).getString();
-		}
-		else return "";
+		} else return "";
 	}
 
-	protected String getLabelFromRDFResource(final Resource resource){
-		if(resource.hasProperty(RDFS.label)){
+	protected String getLabelFromRDFResource(final Resource resource) {
+		if (resource.hasProperty(RDFS.label)) {
 			return resource.getProperty(RDFS.label).getString();
-		}
-		else return "";
+		} else return "";
 	}
 
-	protected String getCompetenceFromRDFResource(final Resource resource){
+	protected String getCompetenceFromRDFResource(final Resource resource) {
 		String comp = "";
-		if(resource.hasProperty(CRMpe.PP45_has_competency)){
+		if (resource.hasProperty(CRMpe.PP45_has_competency)) {
 			Resource compRes = resource.getProperty(CRMpe.PP45_has_competency).getResource();
-			if(compRes.hasProperty(RDFS.label))
+			if (compRes.hasProperty(RDFS.label))
 				comp = compRes.getProperty(RDFS.label).getString();
 		}
 		return comp;
 	}
 
-	protected String getAvailabilityFromRDFResource(final Resource resource){
+	protected String getAvailabilityFromRDFResource(final Resource resource) {
 		//TODO: implement this when George adds the rel to the model
 		return "";
 	}
Index: modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/registry/RelWriter.java
===================================================================
--- modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/registry/RelWriter.java	(nonexistent)
+++ modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/registry/RelWriter.java	(revision 49200)
@@ -0,0 +1,13 @@
+package eu.dnetlib.parthenos.registry;
+
+import org.springframework.stereotype.Component;
+
+/**
+ * Created by Alessia Bardi on 02/10/2017.
+ *
+ * @author Alessia Bardi
+ */
+@Component
+public class RelWriter {
+
+}
Index: modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/registry/GCubeResourceGenerator.java
===================================================================
--- modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/registry/GCubeResourceGenerator.java	(revision 49199)
+++ modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/registry/GCubeResourceGenerator.java	(revision 49200)
@@ -44,9 +44,10 @@
 
 	@Autowired
 	private FacetWriter facetWriter;
+	@Autowired
+	private RelWriter relWriter;
 
 	public GCubeResourceGenerator() {
-		final String url = "http://www.w3.org/TR/REC-rdf-syntax/example14.nt";
 		baseModel = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM_TRANS_INF);
 		baseModel.read(CRMpe.RDFS_URL);
 		baseModel.read(CRM.RDFS_URL);
@@ -77,6 +78,10 @@
 		JsonFactory jsonFactory = new JsonFactory();
 		Set<String> uriProcessed = Sets.newHashSet();
 
+		//TODO: many things in common in the code below: re-factor it!
+
+
+		log.debug("Processing services");
 		//let's start with services
 		ResIterator iter = model.listResourcesWithProperty(RDF.type, CRMpe.PE1_Service);
 		while (iter.hasNext()) {
@@ -89,27 +94,129 @@
 				JsonGenerator jg = jsonFactory.createGenerator(sw);
 				jg.writeStartObject();
 
-				jg.writeStringField("@class", specificType.getURI());
+				//TODO: generate header with uuid for all type of entities, so we can also generate the rels. Need a map for uri --> uuid.
+				jg.writeStringField("@class", specificType.getLocalName());
 
 				//******THE FACETS *******//
 				jg.writeArrayFieldStart("consistsOf");
 				//list of facets
-
+				//TODO: write P1 identifier facet following the existing links (for all types)
 				facetWriter.writeIdentifierFacet(jg, resourceURI);
 				facetWriter.writeInfoFacet(jg, res);
 				facetWriter.writeEventFacet(jg);
 				facetWriter.writeRightsFacet(jg, res);
-				facetWriter.writeContactReferenceFacet(jg, res);
+				if(res.hasProperty(CRMpe.PP2_provided_by)){
+					//TODO: shouldn't this be a rel to an actor?
+					Resource provider = res.getPropertyResourceValue(CRMpe.PP2_provided_by);
+					facetWriter.writeContactReferenceFacet(jg, provider);
+				}
+
 				facetWriter.writeDesignatedAccessPointFacet(jg, res);
 
 				jg.writeEndArray();
 
-				// ******* RELATIONSHIPS *****//
-				jg.writeArrayFieldStart("isRelatedto");
+				// ******* RELATIONSHIPS ***** ??? or separately after we got the ids of everything?//
+				//jg.writeArrayFieldStart("isRelatedto");
+				//jg.writeEndArray();
 
+				jg.writeEndObject();
+				jg.close();
+				String json = sw.toString();
+				log.debug(json);
+				jsonResources.add(json);
+				uriProcessed.add(resourceURI);
+			} else {
+				log.debug(resourceURI+" already processed, now skipping it");
+			}
+		}
+
+		log.debug("Processing digital objects (include dataset and software)");
+		//and then the datasets
+		ResIterator iterDo = model.listResourcesWithProperty(RDF.type, CRMdig.D1_Digital_Object);
+		while (iterDo.hasNext()) {
+			Resource res = iterDo.nextResource();
+			String resourceURI = res.getURI();
+			if (!uriProcessed.contains(resourceURI)) {
+				log.debug("Processing " + resourceURI);
+				Resource specificType = findSpecificType(res, CRMdig.D1_Digital_Object);
+				StringWriter sw = new StringWriter();
+				JsonGenerator jg = jsonFactory.createGenerator(sw);
+				jg.writeStartObject();
+
+				jg.writeStringField("@class", specificType.getLocalName());
+				//******THE FACETS *******//
+				jg.writeArrayFieldStart("consistsOf");
+				//list of facets
+				facetWriter.writeIdentifierFacet(jg, resourceURI);
+				facetWriter.writeInfoFacet(jg, res);
+				facetWriter.writeTemporalCoverageFacet(jg, res);
+				facetWriter.writeRightsFacet(jg, res);
+
 				jg.writeEndArray();
+				jg.writeEndObject();
+				jg.close();
+				String json = sw.toString();
+				log.debug(json);
+				jsonResources.add(json);
+				uriProcessed.add(resourceURI);
 
+			} else {
+				log.debug(resourceURI + " already processed, now skipping it");
+			}
+		}
 
+			log.debug("Processing actors");
+			//and then the datasets
+			ResIterator iterActors = model.listResourcesWithProperty(RDF.type, CRM.E39_Actor);
+			while (iterActors.hasNext()) {
+				Resource res = iterActors.nextResource();
+				String resourceURI = res.getURI();
+				if (!uriProcessed.contains(resourceURI)) {
+					log.debug("Processing " + resourceURI);
+					Resource specificType = findSpecificType(res, CRM.E39_Actor);
+					StringWriter sw = new StringWriter();
+					JsonGenerator jg = jsonFactory.createGenerator(sw);
+					jg.writeStartObject();
+
+					jg.writeStringField("@class", specificType.getLocalName());
+					//******THE FACETS *******//
+					jg.writeArrayFieldStart("consistsOf");
+					//list of facets
+					facetWriter.writeIdentifierFacet(jg, resourceURI);
+					facetWriter.writeContactReferenceFacet(jg, res);
+
+					jg.writeEndArray();
+					jg.writeEndObject();
+					jg.close();
+					String json = sw.toString();
+					log.debug(json);
+					jsonResources.add(json);
+					uriProcessed.add(resourceURI);
+
+				} else {
+					log.debug(resourceURI + " already processed, now skipping it");
+				}
+			}
+		log.debug("Processing software");
+		ResIterator iterSw = model.listResourcesWithProperty(RDF.type, CRMdig.D14_Software);
+		while (iterSw.hasNext()) {
+			Resource res = iterSw.nextResource();
+			String resourceURI = res.getURI();
+			if (!uriProcessed.contains(resourceURI)) {
+				log.debug("Processing " + resourceURI);
+				Resource specificType = findSpecificType(res, CRMdig.D14_Software);
+				StringWriter sw = new StringWriter();
+				JsonGenerator jg = jsonFactory.createGenerator(sw);
+				jg.writeStartObject();
+
+				jg.writeStringField("@class", specificType.getLocalName());
+				//******THE FACETS *******//
+				jg.writeArrayFieldStart("consistsOf");
+				//list of facets
+				facetWriter.writeIdentifierFacet(jg, resourceURI);
+				facetWriter.writeInfoFacet(jg, res);
+
+				jg.writeEndArray();
 				jg.writeEndObject();
 				jg.close();
 				String json = sw.toString();
@@ -116,13 +223,49 @@
 				log.debug(json);
 				jsonResources.add(json);
 				uriProcessed.add(resourceURI);
+
 			} else {
-				log.debug(resourceURI+" already processed, now skipping it");
+				log.debug(resourceURI + " already processed, now skipping it");
 			}
 		}
+		log.debug("Processing projects");
+		//and then the projects
+		ResIterator iterProjects = model.listResourcesWithProperty(RDF.type, CRMpe.PE35_Project);
+		while (iterProjects.hasNext()) {
+			Resource res = iterProjects.nextResource();
+			String resourceURI = res.getURI();
+			if (!uriProcessed.contains(resourceURI)) {
+				log.debug("Processing " + resourceURI);
+				Resource specificType = findSpecificType(res, CRMpe.PE35_Project);
+				StringWriter sw = new StringWriter();
+				JsonGenerator jg = jsonFactory.createGenerator(sw);
+				jg.writeStartObject();
+
+				jg.writeStringField("@class", specificType.getLocalName());
+				//******THE FACETS *******//
+				jg.writeArrayFieldStart("consistsOf");
+				//list of facets
+				facetWriter.writeIdentifierFacet(jg, resourceURI);
+				facetWriter.writeInfoFacet(jg, res);
+
+				jg.writeEndArray();
+				jg.writeEndObject();
+				jg.close();
+				String json = sw.toString();
+				log.debug(json);
+				jsonResources.add(json);
+				uriProcessed.add(resourceURI);
+
+			} else {
+				log.debug(resourceURI + " already processed, now skipping it");
+			}
+		}
 		return jsonResources;
 	}
 
+
+
+
 	/**
 	 * Finds the most specific type of res.
 	 * @param res Resource you want to find the most specific type
Index: modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/registry/RegistryClient.java
===================================================================
--- modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/registry/RegistryClient.java	(revision 49199)
+++ modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/registry/RegistryClient.java	(revision 49200)
@@ -70,6 +70,10 @@
 				return 0;
 			}
 			//TODO: get the json strings to register
+			Iterable<String> resources = resourceGenerator.getGCubeER(record);
+			for(String res : resources){
+				//resourceRegistryPublisher.
+			}
 			return 0;
 		}catch(Throwable e){
 			log.error(e.getMessage());
