@Test public void bulkFindNotExisting() throws ObjectReferentialException { List<TapeObjectReferentialEntity> tapeObjectReferentialEntities = objectReferentialRepository.bulkFind("container", ImmutableSet.of("objectName1", "objectName2", "objectName3")); assertThat(tapeObjectReferentialEntities).isEmpty(); }
public List<TapeObjectReferentialEntity> bulkFind(String containerName, Set<String> objectNames) throws ObjectReferentialException { try (MongoCursor<Document> iterator = collection.find( Filters.in(TapeObjectReferentialEntity.ID, objectNames.stream() .map(objectName -> toBson(new TapeLibraryObjectReferentialId(containerName, objectName))) .collect(Collectors.toList()))).iterator()) { List<TapeObjectReferentialEntity> result = new ArrayList<>(); while (iterator.hasNext()) { Document document = iterator.next(); try { result.add(fromBson(document, TapeObjectReferentialEntity.class)); } catch (InvalidParseOperationException e) { throw new IllegalStateException("Could not parse documents from DB " + BsonHelper.stringify(document), e); } } return result; } catch (MongoException ex) { throw new ObjectReferentialException("Could not find storage location by ids " + objectNames + " in container " + containerName, ex); } }
ObjectReferentialRepository { public List<TapeObjectReferentialEntity> bulkFind(String containerName, Set<String> objectNames) throws ObjectReferentialException { try (MongoCursor<Document> iterator = collection.find( Filters.in(TapeObjectReferentialEntity.ID, objectNames.stream() .map(objectName -> toBson(new TapeLibraryObjectReferentialId(containerName, objectName))) .collect(Collectors.toList()))).iterator()) { List<TapeObjectReferentialEntity> result = new ArrayList<>(); while (iterator.hasNext()) { Document document = iterator.next(); try { result.add(fromBson(document, TapeObjectReferentialEntity.class)); } catch (InvalidParseOperationException e) { throw new IllegalStateException("Could not parse documents from DB " + BsonHelper.stringify(document), e); } } return result; } catch (MongoException ex) { throw new ObjectReferentialException("Could not find storage location by ids " + objectNames + " in container " + containerName, ex); } } }
ObjectReferentialRepository { public List<TapeObjectReferentialEntity> bulkFind(String containerName, Set<String> objectNames) throws ObjectReferentialException { try (MongoCursor<Document> iterator = collection.find( Filters.in(TapeObjectReferentialEntity.ID, objectNames.stream() .map(objectName -> toBson(new TapeLibraryObjectReferentialId(containerName, objectName))) .collect(Collectors.toList()))).iterator()) { List<TapeObjectReferentialEntity> result = new ArrayList<>(); while (iterator.hasNext()) { Document document = iterator.next(); try { result.add(fromBson(document, TapeObjectReferentialEntity.class)); } catch (InvalidParseOperationException e) { throw new IllegalStateException("Could not parse documents from DB " + BsonHelper.stringify(document), e); } } return result; } catch (MongoException ex) { throw new ObjectReferentialException("Could not find storage location by ids " + objectNames + " in container " + containerName, ex); } } ObjectReferentialRepository(MongoCollection<Document> collection); }
ObjectReferentialRepository { public List<TapeObjectReferentialEntity> bulkFind(String containerName, Set<String> objectNames) throws ObjectReferentialException { try (MongoCursor<Document> iterator = collection.find( Filters.in(TapeObjectReferentialEntity.ID, objectNames.stream() .map(objectName -> toBson(new TapeLibraryObjectReferentialId(containerName, objectName))) .collect(Collectors.toList()))).iterator()) { List<TapeObjectReferentialEntity> result = new ArrayList<>(); while (iterator.hasNext()) { Document document = iterator.next(); try { result.add(fromBson(document, TapeObjectReferentialEntity.class)); } catch (InvalidParseOperationException e) { throw new IllegalStateException("Could not parse documents from DB " + BsonHelper.stringify(document), e); } } return result; } catch (MongoException ex) { throw new ObjectReferentialException("Could not find storage location by ids " + objectNames + " in container " + containerName, ex); } } ObjectReferentialRepository(MongoCollection<Document> collection); void insertOrUpdate(TapeObjectReferentialEntity tapeObjectReferentialEntity); Optional<TapeObjectReferentialEntity> find(String containerName, String objectName); List<TapeObjectReferentialEntity> bulkFind(String containerName, Set<String> objectNames); void updateStorageLocation(String containerName, String objectName, String storageId,
        TapeLibraryTarObjectStorageLocation tapeLibraryTarStorageLocation); boolean delete(TapeLibraryObjectReferentialId tapeLibraryObjectReferentialId); }
ObjectReferentialRepository { public List<TapeObjectReferentialEntity> bulkFind(String containerName, Set<String> objectNames) throws ObjectReferentialException { try (MongoCursor<Document> iterator = collection.find( Filters.in(TapeObjectReferentialEntity.ID, objectNames.stream() .map(objectName -> toBson(new TapeLibraryObjectReferentialId(containerName, objectName))) .collect(Collectors.toList()))).iterator()) { List<TapeObjectReferentialEntity> result = new ArrayList<>(); while (iterator.hasNext()) { Document document = iterator.next(); try { result.add(fromBson(document, TapeObjectReferentialEntity.class)); } catch (InvalidParseOperationException e) { throw new IllegalStateException("Could not parse documents from DB " + BsonHelper.stringify(document), e); } } return result; } catch (MongoException ex) { throw new ObjectReferentialException("Could not find storage location by ids " + objectNames + " in container " + containerName, ex); } } ObjectReferentialRepository(MongoCollection<Document> collection); void insertOrUpdate(TapeObjectReferentialEntity tapeObjectReferentialEntity); Optional<TapeObjectReferentialEntity> find(String containerName, String objectName); List<TapeObjectReferentialEntity> bulkFind(String containerName, Set<String> objectNames); void updateStorageLocation(String containerName, String objectName, String storageId,
        TapeLibraryTarObjectStorageLocation tapeLibraryTarStorageLocation); boolean delete(TapeLibraryObjectReferentialId tapeLibraryObjectReferentialId);  }