use of org.molgenis.data.semantic.SemanticTag in project molgenis by molgenis.
the class UntypedTagService method getTagsForPackage.
@Override
@RunAsSystem
public Iterable<SemanticTag<Package, LabeledResource, LabeledResource>> getTagsForPackage(Package p) {
Entity packageEntity = dataService.findOne(PACKAGE, new QueryImpl<>().eq(PackageMetadata.ID, p.getId()));
if (packageEntity == null) {
throw new UnknownEntityException("Unknown package [" + p.getId() + "]");
}
List<SemanticTag<Package, LabeledResource, LabeledResource>> tags = Lists.newArrayList();
for (Entity tagEntity : packageEntity.getEntities(PackageMetadata.TAGS)) {
tags.add(SemanticTag.asTag(p, tagEntity));
}
return tags;
}
use of org.molgenis.data.semantic.SemanticTag in project molgenis by molgenis.
the class OntologyTagServiceImpl method getTagsForPackage.
@Override
public Iterable<SemanticTag<Package, OntologyTerm, Ontology>> getTagsForPackage(Package package_) {
Entity packageEntity = dataService.findOneById(PACKAGE, package_.getId());
if (packageEntity == null) {
throw new UnknownEntityException("Unknown package [" + package_.getId() + "]");
}
List<SemanticTag<Package, OntologyTerm, Ontology>> tags = Lists.newArrayList();
for (Entity tagEntity : packageEntity.getEntities(PackageMetadata.TAGS)) {
tags.add(asTag(package_, tagEntity));
}
return tags;
}
use of org.molgenis.data.semantic.SemanticTag in project molgenis by molgenis.
the class OntologyTagServiceImpl method asTag.
private <SubjectType> SemanticTag<SubjectType, OntologyTerm, Ontology> asTag(SubjectType subjectType, Entity tagEntity) {
String identifier = tagEntity.getString(TagMetadata.ID);
Relation relation = asRelation(tagEntity);
Ontology ontology = asOntology(tagEntity);
OntologyTerm ontologyTerm = asOntologyTerm(tagEntity);
if (relation == null || ontologyTerm == null) {
return null;
}
return new SemanticTag<>(identifier, subjectType, relation, ontologyTerm, ontology);
}
use of org.molgenis.data.semantic.SemanticTag in project molgenis by molgenis.
the class EntityModelWriterTest method testAddStatementsForEntityType.
@Test
public void testAddStatementsForEntityType() {
Model model = new LinkedHashModel();
Resource subject = valueFactory.createIRI("http://example.org/subject");
LabeledResource object = new LabeledResource("http://example.org/object", "object");
LabeledResource codeSystem = new LabeledResource("ex:object");
SemanticTag<EntityType, LabeledResource, LabeledResource> tag = new SemanticTag<>("tagId", entityType, Relation.isAssociatedWith, object, codeSystem);
when(tagService.getTagsForEntity(entityType)).thenReturn(singletonList(tag));
writer.addStatementsForEntityTags(model, subject, entityType);
Statement statement = valueFactory.createStatement(subject, TYPE, valueFactory.createIRI("http://example.org/object"));
assertEquals(newArrayList(model), singletonList(statement));
}
use of org.molgenis.data.semantic.SemanticTag in project molgenis by molgenis.
the class UntypedTagService method getTagsForEntity.
@Override
@RunAsSystem
public Iterable<SemanticTag<EntityType, LabeledResource, LabeledResource>> getTagsForEntity(EntityType entityType) {
List<SemanticTag<EntityType, LabeledResource, LabeledResource>> result = new ArrayList<>();
Entity entity = findEntity(entityType);
if (entity == null) {
LOG.warn("No known entity with name " + entityType.getId() + ".");
} else {
for (Entity tagEntity : entity.getEntities(EntityTypeMetadata.TAGS)) {
result.add(SemanticTag.asTag(entityType, tagEntity));
}
}
return result;
}
Aggregations