Project

General

Profile

« Previous | Next » 

Revision 49527

Registration of curation plans

View differences:

modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/registry/GCubeResourceRegistrator.java
123 123
				int registeredDigitalObjects = processDigitalObjects(model, uriProcessed, jsonFactory, idMap);
124 124
				int registeredActors = processActors(model, uriProcessed, jsonFactory, idMap);
125 125
				int registeredProjects = processProjects(model, uriProcessed, jsonFactory, idMap);
126
				int registeredTypes = processTypes(model, uriProcessed, jsonFactory, idMap);
126
				int registeredTypes = processBasicResources(model, uriProcessed, jsonFactory, idMap, CRM.E55_Type);
127
				int registeredCurationPlans = processBasicResources(model, uriProcessed, jsonFactory, idMap, CRMpe.PE28_Curation_Plan);
127 128

  
128
				int total = registeredActors + registeredDigitalObjects + registeredProjects + registeredServices+registeredTypes;
129
				int total = registeredActors + registeredDigitalObjects + registeredProjects + registeredServices+registeredTypes+registeredCurationPlans;
129 130
				log.info(String.format("Registered %d resources from record with objIdentifier %s", total, objIdentifier));
130 131

  
131 132
			/* Relationships */
......
348 349
		return new ParthenosRegistryResource().setJson(json).setType(specificType).setUuid(uuid);
349 350
	}
350 351

  
351
	protected int processTypes(final InfModel model,
352
	protected int processBasicResources(final InfModel model,
352 353
			final Set<String> uriProcessed,
353 354
			final JsonFactory jsonFactory,
354
			final Map<String, ParthenosRegistryResource> idMap)
355
			final Map<String, ParthenosRegistryResource> idMap, final Resource entityType)
355 356
			throws IOException, ResourceRegistryException {
356
		log.debug("Processing types");
357
		log.debug("Processing "+entityType.getLocalName());
357 358
		int count = 0;
358 359
		int total = 0;
359
		ResIterator iter = model.listResourcesWithProperty(RDF.type, CRM.E55_Type);
360
		ResIterator iter = model.listResourcesWithProperty(RDF.type, entityType);
360 361
		while (iter.hasNext()) {
361 362
			total++;
362 363
			Resource res = iter.nextResource();
363 364
			String resourceURI = res.getURI();
364 365
			if (!uriProcessed.contains(resourceURI)) {
365
				ParthenosRegistryResource prr = processType(res, jsonFactory, idMap);
366
				ParthenosRegistryResource prr = processBasicResource(res, entityType, jsonFactory, idMap);
366 367
				//TODO: if something goes wrong we stop the registration but we are not rolling back the one that may have succeeded before.
367 368
				//Let's decide if this is ok or if we must be smarter than this
368 369
				this.resourceRegistryPublisher.createResource(prr.getRegistryType(), prr.getJson());
......
373 374
				log.debug(resourceURI + " already processed, now skipping it");
374 375
			}
375 376
		}
376
		log.debug(String.format("Registered %d/%d types", count, total));
377
		log.debug(String.format("Registered %d/%d %s", count, total, entityType.getLocalName()));
377 378
		return count;
378

  
379 379
	}
380 380

  
381
	private ParthenosRegistryResource processType(final Resource res, final JsonFactory jsonFactory, final Map<String, ParthenosRegistryResource> idMap)
381
	private ParthenosRegistryResource processBasicResource(final Resource res, final Resource basicType, final JsonFactory jsonFactory, final Map<String, ParthenosRegistryResource> idMap)
382 382
			throws IOException {
383 383
		log.debug("Processing " + res.getURI());
384 384

  
385 385
		StringWriter sw = new StringWriter();
386 386
		JsonGenerator jg = jsonFactory.createGenerator(sw);
387 387
		jg.writeStartObject();
388
		String specificType = findSpecificType(res, CRM.E55_Type).getLocalName();
388
		String specificType = findSpecificType(res, basicType).getLocalName();
389 389
		String uuid = writeCommon(res, specificType, jg, idMap);
390 390
		//******THE FACETS *******//
391 391
		jg.writeArrayFieldStart("consistsOf");

Also available in: Unified diff