use of org.molgenis.data.meta.model.EntityType in project molgenis by molgenis.
the class EntityIdentityUtilsTest method testToIdType.
@Test(dataProvider = "testToIdTypeProvider")
public void testToIdType(AttributeType attributeType, Class<?> expectedIdType) {
EntityType entityType = mock(EntityType.class);
Attribute idAttribute = when(mock(Attribute.class).getDataType()).thenReturn(attributeType).getMock();
when(entityType.getIdAttribute()).thenReturn(idAttribute);
assertEquals(EntityIdentityUtils.toIdType(entityType), expectedIdType);
}
use of org.molgenis.data.meta.model.EntityType in project molgenis by molgenis.
the class RestService method convertMref.
private List<?> convertMref(Attribute attr, Object paramValue) {
List<?> value;
if (paramValue != null) {
List<?> mrefParamValues;
if (paramValue instanceof String) {
mrefParamValues = asList(StringUtils.split((String) paramValue, ','));
} else if (paramValue instanceof List<?>) {
mrefParamValues = (List<?>) paramValue;
} else {
throw new MolgenisDataException(format("Attribute [%s] value is of type [%s] instead of [%s] or [%s]", attr.getName(), paramValue.getClass().getSimpleName(), String.class.getSimpleName(), List.class.getSimpleName()));
}
EntityType mrefEntity = attr.getRefEntity();
Attribute mrefEntityIdAttr = mrefEntity.getIdAttribute();
value = mrefParamValues.stream().map(mrefParamValue -> toEntityValue(mrefEntityIdAttr, mrefParamValue, null)).map(mrefIdValue -> entityManager.getReference(mrefEntity, mrefIdValue)).collect(toList());
} else {
value = emptyList();
}
return value;
}
use of org.molgenis.data.meta.model.EntityType in project molgenis by molgenis.
the class RepositorySecurityDecorator method findOneById.
@Override
public Entity findOneById(Object id, Fetch fetch) {
EntityType entityType = delegate().getEntityType();
validatePermission(entityType, EntityTypePermission.READ);
return delegate().findOneById(id, fetch);
}
use of org.molgenis.data.meta.model.EntityType in project molgenis by molgenis.
the class RepositorySecurityDecorator method update.
@Override
public void update(Entity entity) {
EntityType entityType = delegate().getEntityType();
validatePermission(entityType, EntityTypePermission.WRITE);
delegate().update(entity);
}
use of org.molgenis.data.meta.model.EntityType in project molgenis by molgenis.
the class RepositorySecurityDecorator method forEachBatched.
@Override
public void forEachBatched(Fetch fetch, Consumer<List<Entity>> consumer, int batchSize) {
EntityType entityType = delegate().getEntityType();
validatePermission(entityType, EntityTypePermission.READ);
delegate().forEachBatched(fetch, consumer, batchSize);
}
Aggregations