Project

General

Profile

« Previous | Next » 

Revision 53306

Get timespan with "timewithin" (for CulturaItalia temporal coverages) and exclude specific coverages from the generic "subject"

View differences:

modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/rdf/ResourceReader.java
281 281

  
282 282
	public Iterator<String> getSubjects(final Resource resource){
283 283
		StmtIterator it = resource.listProperties(CRM.P129_is_about);
284
		return Iterators.transform(it, f -> getLabel(f.getResource()));
284
		return Iterators.transform( Iterators.filter(it, f -> !f.getResource().hasProperty(RDF.type, CRM.E4_Period) && !f.getResource().hasProperty(RDF.type, CRM.E52_Time_Span) && !f.getResource().hasProperty(RDF.type, CRM.E53_Place)), f -> getLabel(f.getResource()));
285 285
	}
286 286

  
287 287
	public List<String> getTemporalCoverages(final Resource resource){
288
		return getCoverages(resource, CRM.E4_Period);
288
		List<String> temporalCoverages = getCoverages(resource, CRM.E4_Period);
289
		temporalCoverages.addAll(getCoverageTimeSpan(resource));
290
		return temporalCoverages;
289 291
	}
290 292

  
291 293
	public List<String> getSpatialCoverages(final Resource resource){
......
304 306
		return cov;
305 307
	}
306 308

  
309
	private List<String> getCoverageTimeSpan(final Resource resource){
310
		List<String> cov = Lists.newArrayList();
311
		StmtIterator it = resource.listProperties(CRM.P129_is_about);
312
		while(it.hasNext()){
313
			Resource r = it.next().getResource();
314
			if(r.hasProperty(RDF.type, CRM.E52_Time_Span)){
315
				StmtIterator times = r.listProperties(CRM.P82_at_some_time_within);
316
				while(times.hasNext()){
317
					Resource t = times.next().getResource();
318
					cov.add(t.toString());
319
				}
320
			}
321
		}
322
		return cov;
323
	}
324

  
307 325
	public Iterator<String> getEncodings(final Resource resource){
308 326
		StmtIterator it = resource.listProperties(encodingProperty);
309 327
		return Iterators.transform(it, f -> f.getString());

Also available in: Unified diff