@Test public void testGetUnitGraphByIds_emptyIdSet() throws Exception { String dataSetFile = "DataMigrationR6/30UnitDataSet/R6UnitDataSet.json"; importUnitDataSetFile(dataSetFile); Map<String, Unit> unitGraphByIds = repository.getUnitGraphByIds(Collections.EMPTY_LIST); assertThat(unitGraphByIds).isEmpty(); }
public Map<String, Unit> getUnitGraphByIds(Collection<String> unitIds) { FindIterable<Unit> iterable = MetadataCollections.UNIT.getCollection() .find(in(Unit.ID, unitIds)) .batchSize(unitIds.size()) .projection(UNIT_VITAM_GRAPH_PROJECTION); Map<String, Unit> directParentById = new HashMap<>(); try (MongoCursor<Unit> cursor = iterable.iterator()) { while (cursor.hasNext()) { Unit unit = cursor.next(); directParentById.put(unit.getId(), unit); } } return directParentById; }
DataMigrationRepository { public Map<String, Unit> getUnitGraphByIds(Collection<String> unitIds) { FindIterable<Unit> iterable = MetadataCollections.UNIT.getCollection() .find(in(Unit.ID, unitIds)) .batchSize(unitIds.size()) .projection(UNIT_VITAM_GRAPH_PROJECTION); Map<String, Unit> directParentById = new HashMap<>(); try (MongoCursor<Unit> cursor = iterable.iterator()) { while (cursor.hasNext()) { Unit unit = cursor.next(); directParentById.put(unit.getId(), unit); } } return directParentById; } }
DataMigrationRepository { public Map<String, Unit> getUnitGraphByIds(Collection<String> unitIds) { FindIterable<Unit> iterable = MetadataCollections.UNIT.getCollection() .find(in(Unit.ID, unitIds)) .batchSize(unitIds.size()) .projection(UNIT_VITAM_GRAPH_PROJECTION); Map<String, Unit> directParentById = new HashMap<>(); try (MongoCursor<Unit> cursor = iterable.iterator()) { while (cursor.hasNext()) { Unit unit = cursor.next(); directParentById.put(unit.getId(), unit); } } return directParentById; } DataMigrationRepository(); @VisibleForTesting  DataMigrationRepository(int bulkSize); }
DataMigrationRepository { public Map<String, Unit> getUnitGraphByIds(Collection<String> unitIds) { FindIterable<Unit> iterable = MetadataCollections.UNIT.getCollection() .find(in(Unit.ID, unitIds)) .batchSize(unitIds.size()) .projection(UNIT_VITAM_GRAPH_PROJECTION); Map<String, Unit> directParentById = new HashMap<>(); try (MongoCursor<Unit> cursor = iterable.iterator()) { while (cursor.hasNext()) { Unit unit = cursor.next(); directParentById.put(unit.getId(), unit); } } return directParentById; } DataMigrationRepository(); @VisibleForTesting  DataMigrationRepository(int bulkSize); CloseableIterator<List<Unit>> selectUnitBulkInTopDownHierarchyLevel(); Map<String, Unit> getUnitGraphByIds(Collection<String> unitIds); void bulkReplaceUnits(List<Unit> updatedUnits); CloseableIterator<List<String>> selectObjectGroupBulk(); void bulkUpgradeObjectGroups(List<String> objectGroupIds); }
DataMigrationRepository { public Map<String, Unit> getUnitGraphByIds(Collection<String> unitIds) { FindIterable<Unit> iterable = MetadataCollections.UNIT.getCollection() .find(in(Unit.ID, unitIds)) .batchSize(unitIds.size()) .projection(UNIT_VITAM_GRAPH_PROJECTION); Map<String, Unit> directParentById = new HashMap<>(); try (MongoCursor<Unit> cursor = iterable.iterator()) { while (cursor.hasNext()) { Unit unit = cursor.next(); directParentById.put(unit.getId(), unit); } } return directParentById; } DataMigrationRepository(); @VisibleForTesting  DataMigrationRepository(int bulkSize); CloseableIterator<List<Unit>> selectUnitBulkInTopDownHierarchyLevel(); Map<String, Unit> getUnitGraphByIds(Collection<String> unitIds); void bulkReplaceUnits(List<Unit> updatedUnits); CloseableIterator<List<String>> selectObjectGroupBulk(); void bulkUpgradeObjectGroups(List<String> objectGroupIds);  }