use of org.molgenis.data.UnknownEntityTypeException in project molgenis by molgenis.
the class PlatformIT method testLanguageService.
@WithMockUser(username = USERNAME)
@Test
void testLanguageService() {
populateUserPermissions();
assertEquals("labelEn", dataService.getMeta().getEntityType(ENTITY_TYPE_META_DATA).orElseThrow(() -> new UnknownEntityTypeException(ENTITY_TYPE_META_DATA)).getAttribute("labelEn").getName());
assertEquals("label", dataService.getMeta().getEntityType(ENTITY_TYPE_META_DATA).orElseThrow(() -> new UnknownEntityTypeException(ENTITY_TYPE_META_DATA)).getLabelAttribute("en").getName());
assertEquals("label", dataService.getMeta().getEntityType(ENTITY_TYPE_META_DATA).orElseThrow(() -> new UnknownEntityTypeException(ENTITY_TYPE_META_DATA)).getLabelAttribute("pt").getName());
assertEquals("label", dataService.getMeta().getEntityType(ENTITY_TYPE_META_DATA).orElseThrow(() -> new UnknownEntityTypeException(ENTITY_TYPE_META_DATA)).getLabelAttribute("nl").getName());
assertEquals("label", dataService.getMeta().getEntityType(ENTITY_TYPE_META_DATA).orElseThrow(() -> new UnknownEntityTypeException(ENTITY_TYPE_META_DATA)).getLabelAttribute().getName());
assertEquals("en", getCurrentUserLanguageCode());
assertArrayEquals(new String[] { "en", "nl", "de", "es", "it", "pt", "fr", "xx" }, getLanguageCodes().toArray());
// NL
assertNotNull(dataService.getEntityType(L10N_STRING).getAttribute("nl"));
assertNotNull(dataService.getEntityType(ENTITY_TYPE_META_DATA).getAttribute("labelNl"));
assertNotNull(dataService.getEntityType(ENTITY_TYPE_META_DATA).getAttribute("descriptionNl"));
assertNotNull(dataService.getEntityType(ATTRIBUTE_META_DATA).getAttribute("labelNl"));
assertNotNull(dataService.getEntityType(ATTRIBUTE_META_DATA).getAttribute("descriptionNl"));
// EN
assertNotNull(dataService.getEntityType(L10N_STRING).getAttribute("en"));
assertNotNull(dataService.getEntityType(ENTITY_TYPE_META_DATA).getAttribute("labelEn"));
assertNotNull(dataService.getEntityType(ENTITY_TYPE_META_DATA).getAttribute("descriptionEn"));
assertNotNull(dataService.getEntityType(ATTRIBUTE_META_DATA).getAttribute("labelEn"));
assertNotNull(dataService.getEntityType(ATTRIBUTE_META_DATA).getAttribute("descriptionEn"));
L10nString car = l10nStringFactory.create();
car.setMessageID("car");
car.set("en", "car");
car.set("nl", "auto");
car.setNamespace("platform-it");
dataService.add(L10nStringMetadata.L10N_STRING, car);
// Test default value
assertEquals("car", getBundle().getString("car"));
}
use of org.molgenis.data.UnknownEntityTypeException in project molgenis by molgenis.
the class MappingServiceImpl method createTargetMetadata.
/**
* Package-private for testability
*/
EntityType createTargetMetadata(MappingTarget mappingTarget, String entityTypeId, String packageId, String label, Boolean addSourceAttribute) {
EntityType targetMetadata = EntityType.newInstance(mappingTarget.getTarget(), DEEP_COPY_ATTRS, attrMetaFactory);
targetMetadata.setId(entityTypeId);
if (label != null) {
targetMetadata.setLabel(label);
} else {
targetMetadata.setLabel(entityTypeId);
}
if (TRUE.equals(addSourceAttribute)) {
targetMetadata.addAttribute(attrMetaFactory.create().setName(SOURCE));
}
if (dataService.hasRepository(entityTypeId)) {
EntityType entityType = dataService.getMeta().getEntityType(entityTypeId).orElseThrow(() -> new UnknownEntityTypeException(entityTypeId));
targetMetadata.setPackage(entityType.getPackage());
} else if (packageId != null) {
Package aPackage = dataService.getMeta().getPackage(packageId).orElseThrow(() -> new UnknownEntityException(PACKAGE, packageId));
targetMetadata.setPackage(aPackage);
} else {
throw new MolgenisDataException("Package can't be null");
}
return targetMetadata;
}
use of org.molgenis.data.UnknownEntityTypeException in project molgenis by molgenis.
the class AttributeRequestMapperImpl method setRefEntityType.
private void setRefEntityType(Attribute attribute, Object value) {
EntityType refEntityType;
String refEntityTypeId = getStringValue(value);
if (refEntityTypeId != null) {
refEntityType = (EntityType) entityManager.getReference(entityTypeMetadata, refEntityTypeId);
attribute.setRefEntity(refEntityType);
} else {
throw new UnknownEntityTypeException(refEntityTypeId);
}
}
use of org.molgenis.data.UnknownEntityTypeException 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 UnknownEntityTypeException(entityType.getId());
}
return updateEntityTypeFirstPass(entityType, existingEntityType);
}
use of org.molgenis.data.UnknownEntityTypeException in project molgenis by molgenis.
the class IndexMetadataCUDOperationsPlatformIT method testIndexCreateMetaData.
public static void testIndexCreateMetaData(SearchService searchService, EntityType entityTypeStatic, EntityType entityTypeDynamic, MetaDataService metaDataService) {
Query<Entity> q1 = new QueryImpl<>();
q1.eq(EntityTypeMetadata.ID, entityTypeStatic.getId()).and().eq(EntityTypeMetadata.PACKAGE, entityTypeStatic.getPackage());
assertEquals(1, searchService.count(metaDataService.getEntityType(ENTITY_TYPE_META_DATA).orElseThrow(() -> new UnknownEntityTypeException(entityTypeStatic.getId())), q1));
Query<Entity> q2 = new QueryImpl<>();
q2.eq(EntityTypeMetadata.ID, entityTypeDynamic.getId()).and().eq(EntityTypeMetadata.PACKAGE, entityTypeDynamic.getPackage());
assertEquals(1, searchService.count(metaDataService.getEntityType(ENTITY_TYPE_META_DATA).orElseThrow(() -> new UnknownEntityTypeException(entityTypeDynamic.getId())), q2));
}
Aggregations