Search in sources :

Example 6 with UnknownEntityException

use of org.molgenis.data.UnknownEntityException in project molgenis by molgenis.

the class DataPersisterImpl method updateEntityTypeFirstPass.

private EntityType updateEntityTypeFirstPass(EntityType entityType) {
    String entityTypeId = entityType.getId();
    EntityType existingEntityType = dataService.findOneById(ENTITY_TYPE_META_DATA, entityTypeId, EntityType.class);
    if (existingEntityType == null) {
        throw new UnknownEntityException(format("Unknown entity type [%s]", entityType.getId()));
    }
    return updateEntityTypeFirstPass(entityType, existingEntityType);
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) UnknownEntityException(org.molgenis.data.UnknownEntityException)

Example 7 with UnknownEntityException

use of org.molgenis.data.UnknownEntityException in project molgenis by molgenis.

the class PackageRepositoryValidationDecorator method deleteById.

@Override
public void deleteById(Object id) {
    Package package_ = findOneById(id);
    if (package_ == null) {
        throw new UnknownEntityException(format("Unknown package [%s]", id.toString()));
    }
    packageValidator.validate(package_);
    super.deleteById(id);
}
Also used : UnknownEntityException(org.molgenis.data.UnknownEntityException) Package(org.molgenis.data.meta.model.Package)

Example 8 with UnknownEntityException

use of org.molgenis.data.UnknownEntityException in project molgenis by molgenis.

the class FairController method getCatalog.

@GetMapping(produces = TEXT_TURTLE_VALUE, value = "/{catalogID}")
@ResponseBody
@RunAsSystem
public Model getCatalog(@PathVariable("catalogID") String catalogID) {
    String subjectIRI = getBaseUri().pathSegment(catalogID).toUriString();
    Entity subjectEntity = dataService.findOneById("fdp_Catalog", catalogID);
    if (subjectEntity == null) {
        throw new UnknownEntityException(format("Catalog with id [%s] does not exist", catalogID));
    }
    return entityModelWriter.createRdfModel(subjectIRI, subjectEntity);
}
Also used : Entity(org.molgenis.data.Entity) UnknownEntityException(org.molgenis.data.UnknownEntityException) RunAsSystem(org.molgenis.security.core.runas.RunAsSystem)

Example 9 with UnknownEntityException

use of org.molgenis.data.UnknownEntityException in project molgenis by molgenis.

the class UntypedTagService method addEntityTag.

@Override
public void addEntityTag(SemanticTag<EntityType, LabeledResource, LabeledResource> tag) {
    Entity entity = findEntity(tag.getSubject());
    if (entity == null) {
        throw new UnknownEntityException("Unknown entity [" + tag.getSubject().getId() + "]");
    }
    ImmutableList<SemanticTag<EntityType, LabeledResource, LabeledResource>> existingTags = ImmutableList.copyOf(getTagsForEntity(tag.getSubject()));
    if (existingTags.contains(tag)) {
        LOG.debug("Tag already present");
        return;
    }
    ImmutableList.Builder<Entity> builder = ImmutableList.builder();
    builder.addAll(entity.getEntities(EntityTypeMetadata.TAGS));
    builder.add(getTagEntity(tag));
    entity.set(EntityTypeMetadata.TAGS, builder.build());
    dataService.update(ENTITY_TYPE_META_DATA, entity);
}
Also used : Entity(org.molgenis.data.Entity) ImmutableList(com.google.common.collect.ImmutableList) UnknownEntityException(org.molgenis.data.UnknownEntityException) SemanticTag(org.molgenis.data.semantic.SemanticTag)

Aggregations

UnknownEntityException (org.molgenis.data.UnknownEntityException)9 Entity (org.molgenis.data.Entity)6 EntityType (org.molgenis.data.meta.model.EntityType)3 SemanticTag (org.molgenis.data.semantic.SemanticTag)3 RunAsSystem (org.molgenis.security.core.runas.RunAsSystem)3 QueryImpl (org.molgenis.data.support.QueryImpl)2 ImmutableList (com.google.common.collect.ImmutableList)1 Multimap (com.google.common.collect.Multimap)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 UncheckedIOException (java.io.UncheckedIOException)1 Attribute (org.molgenis.data.meta.model.Attribute)1 Package (org.molgenis.data.meta.model.Package)1 DynamicEntity (org.molgenis.data.support.DynamicEntity)1 Ontology (org.molgenis.ontology.core.model.Ontology)1 AttributeMapping (org.molgenis.semanticmapper.mapping.model.AttributeMapping)1 EntityMapping (org.molgenis.semanticmapper.mapping.model.EntityMapping)1 ClassPathResource (org.springframework.core.io.ClassPathResource)1 Resource (org.springframework.core.io.Resource)1