use of org.molgenis.data.meta.model.EntityType in project molgenis by molgenis.
the class IndexDependencyModel method getReferencingEntities.
private Set<String> getReferencingEntities(String entityTypeId) {
ImmutableSet.Builder<String> result = ImmutableSet.builder();
EntityType entityType = entityTypes.get(entityTypeId);
if (entityType == null) {
return emptySet();
}
for (Map.Entry<String, EntityType> candidate : entityTypes.entrySet()) {
EntityType candidateEntityType = candidate.getValue();
if (hasAttributeThatReferences(candidateEntityType, entityTypeId)) {
if (candidateEntityType.isAbstract()) {
result.addAll(getDescendants(candidate.getKey()));
} else {
result.add(candidate.getKey());
}
}
}
return result.build();
}
use of org.molgenis.data.meta.model.EntityType in project molgenis by molgenis.
the class IndexBootstrapper method registerIndexAction.
private void registerIndexAction(IndexAction action) {
String entityTypeId = action.getEntityTypeId();
EntityType entityType = dataService.findOneById(ENTITY_TYPE_META_DATA, entityTypeId, EntityType.class);
if (entityType != null) {
Object typedEntityId = getTypedValue(action.getEntityId(), entityType.getIdAttribute());
indexActionRegisterService.register(entityType, typedEntityId);
}
}
use of org.molgenis.data.meta.model.EntityType in project molgenis by molgenis.
the class DataPersisterImpl method persistSecondPass.
private void persistSecondPass(DataProvider dataProvider, List<EntityType> topologicalSortedEntityTypes) {
topologicalSortedEntityTypes.forEach(entityType -> {
EntityType persistedEntityType = persistEntityTypeSecondPass(entityType);
if (dataProvider.hasEntities(entityType)) {
Stream<Entity> entities = dataProvider.getEntities(entityType);
persistEntitiesSecondPass(persistedEntityType, entities);
}
});
}
use of org.molgenis.data.meta.model.EntityType in project molgenis by molgenis.
the class ImportWriter method groupEntityTypes.
private GroupedEntityTypes groupEntityTypes(ImmutableCollection<EntityType> entities) {
return runAsSystem(() -> {
Map<String, EntityType> existingEntityTypeMap = new HashMap<>();
for (EntityType entityType : entities) {
EntityType existing = metaDataService.getEntityTypeById(entityType.getId());
if (existing != null) {
existingEntityTypeMap.put(entityType.getId(), entityType);
}
}
ImmutableCollection<EntityType> newEntityTypes = entities.stream().filter(entityType -> !existingEntityTypeMap.containsKey(entityType.getId())).collect(collectingAndThen(toList(), ImmutableList::copyOf));
ImmutableCollection<EntityType> existingEntityTypes = entities.stream().filter(entityType -> existingEntityTypeMap.containsKey(entityType.getId())).collect(collectingAndThen(toList(), ImmutableList::copyOf));
return new GroupedEntityTypes(newEntityTypes, existingEntityTypes);
});
}
use of org.molgenis.data.meta.model.EntityType in project molgenis by molgenis.
the class FileMetaRepositoryDecoratorTest method setUpBeforeMethod.
@BeforeMethod
public void setUpBeforeMethod() {
EntityType entityType = when(mock(EntityType.class).getLabel()).thenReturn("file metadata").getMock();
when(delegateRepository.getEntityType()).thenReturn(entityType);
when(fileStore.delete(anyString())).thenReturn(true);
fileMetaRepositoryDecorator = new FileMetaRepositoryDecorator(delegateRepository, fileStore);
}
Aggregations