use of org.molgenis.data.Entity in project molgenis by molgenis.
the class FairController method getDataset.
@GetMapping(produces = TEXT_TURTLE_VALUE, value = "/{catalogID}/{datasetID}")
@ResponseBody
@RunAsSystem
public Model getDataset(@PathVariable("catalogID") String catalogID, @PathVariable("datasetID") String datasetID) {
String subjectIRI = getBaseUri().pathSegment(catalogID, datasetID).toUriString();
Entity subjectEntity = dataService.findOneById("fdp_Dataset", datasetID);
return entityModelWriter.createRdfModel(subjectIRI, subjectEntity);
}
use of org.molgenis.data.Entity in project molgenis by molgenis.
the class FairController method getMetadata.
@GetMapping(produces = TEXT_TURTLE_VALUE)
@ResponseBody
@RunAsSystem
public Model getMetadata() {
String subjectIRI = getBaseUri().toUriString();
Entity subjectEntity = dataService.findOne("fdp_Metadata", new QueryImpl<>());
return entityModelWriter.createRdfModel(subjectIRI, subjectEntity);
}
use of org.molgenis.data.Entity in project molgenis by molgenis.
the class EntityModelWriterTest method testCreateRfdModelDECIMAL.
@Test
public void testCreateRfdModelDECIMAL() {
// public Model createRdfModel(String subjectIRI, Entity objectEntity)
Entity objectEntity = mock(Entity.class);
EntityType entityType = mock(EntityType.class);
Attribute attribute = mock(Attribute.class);
List<Attribute> attributeList = singletonList(attribute);
when(objectEntity.getEntityType()).thenReturn(entityType);
double value = 10.0;
when(objectEntity.get("attributeName")).thenReturn(value);
when(objectEntity.getDouble("attributeName")).thenReturn(value);
when(entityType.getAtomicAttributes()).thenReturn(attributeList);
when(attribute.getName()).thenReturn("attributeName");
when(attribute.getDataType()).thenReturn(AttributeType.DECIMAL);
LabeledResource tag = new LabeledResource("http://IRI.nl", "tag label");
Multimap<Relation, LabeledResource> tags = ImmutableMultimap.of(Relation.isAssociatedWith, tag);
when(tagService.getTagsForAttribute(entityType, attribute)).thenReturn(tags);
Model result = writer.createRdfModel("http://molgenis01.gcc.rug.nl/fdp/catolog/test/this", objectEntity);
assertEquals(result.size(), 1);
Iterator results = result.iterator();
assertEquals(results.next().toString(), "(http://molgenis01.gcc.rug.nl/fdp/catolog/test/this, http://IRI.nl, \"10.0\"^^<http://www.w3.org/2001/XMLSchema#double>) [null]");
}
use of org.molgenis.data.Entity in project molgenis by molgenis.
the class EntityModelWriterTest method testCreateRfdModelLONG.
@Test
public void testCreateRfdModelLONG() {
// public Model createRdfModel(String subjectIRI, Entity objectEntity)
Entity objectEntity = mock(Entity.class);
EntityType entityType = mock(EntityType.class);
Attribute attribute = mock(Attribute.class);
List<Attribute> attributeList = singletonList(attribute);
when(objectEntity.getEntityType()).thenReturn(entityType);
long value = 987654321L;
when(objectEntity.get("attributeName")).thenReturn(value);
when(objectEntity.getLong("attributeName")).thenReturn(value);
when(entityType.getAtomicAttributes()).thenReturn(attributeList);
when(attribute.getName()).thenReturn("attributeName");
when(attribute.getDataType()).thenReturn(AttributeType.LONG);
LabeledResource tag = new LabeledResource("http://IRI.nl", "tag label");
Multimap<Relation, LabeledResource> tags = ImmutableMultimap.of(Relation.isAssociatedWith, tag);
when(tagService.getTagsForAttribute(entityType, attribute)).thenReturn(tags);
Model result = writer.createRdfModel("http://molgenis01.gcc.rug.nl/fdp/catolog/test/this", objectEntity);
assertEquals(result.size(), 1);
Iterator results = result.iterator();
assertEquals(results.next().toString(), "(http://molgenis01.gcc.rug.nl/fdp/catolog/test/this, http://IRI.nl, \"987654321\"^^<http://www.w3.org/2001/XMLSchema#long>) [null]");
}
use of org.molgenis.data.Entity in project molgenis by molgenis.
the class EntityModelWriterTest method testCreateRfdModelNullValuePlusHyperlink.
@Test
public void testCreateRfdModelNullValuePlusHyperlink() {
// public Model createRdfModel(String subjectIRI, Entity objectEntity)
Entity objectEntity = mock(Entity.class);
EntityType entityType = mock(EntityType.class);
Attribute attribute1 = mock(Attribute.class);
Attribute attribute2 = mock(Attribute.class);
List<Attribute> attributeList = Arrays.asList(attribute1, attribute2);
when(objectEntity.getEntityType()).thenReturn(entityType);
when(objectEntity.get("attribute1Name")).thenReturn(null);
String value = "http://molgenis.org/index.html";
doReturn(value).when(objectEntity).get("attribute2Name");
when(objectEntity.getString("attribute2Name")).thenReturn(value);
when(entityType.getAtomicAttributes()).thenReturn(attributeList);
when(attribute1.getName()).thenReturn("attribute1Name");
when(attribute2.getName()).thenReturn("attribute2Name");
when(attribute2.getDataType()).thenReturn(AttributeType.HYPERLINK);
LabeledResource tag2 = new LabeledResource("http://IRI1.nl", "tag1 label");
Multimap<Relation, LabeledResource> tags2 = ImmutableMultimap.of(Relation.isAssociatedWith, tag2);
doReturn(tags2).when(tagService).getTagsForAttribute(entityType, attribute2);
Model result = writer.createRdfModel("http://molgenis01.gcc.rug.nl/fdp/catolog/test/this", objectEntity);
assertEquals(result.size(), 1);
Iterator results = result.iterator();
assertEquals(results.next().toString(), "(http://molgenis01.gcc.rug.nl/fdp/catolog/test/this, http://IRI1.nl, http://molgenis.org/index.html) [null]");
}
Aggregations