/** * Creates a list of storage unit entities from a list of storage unit create requests. * * @param storageUnitCreateRequests the storage unit create requests * @param businessObjectDataEntity the business object data entity * * @return the list of storage unit entities. */ private List<StorageUnitEntity> createStorageUnitEntitiesFromStorageUnits(List<StorageUnitCreateRequest> storageUnitCreateRequests, BusinessObjectDataEntity businessObjectDataEntity) { // Create the storage units for the data. List<StorageUnitEntity> storageUnitEntities = new ArrayList<>(); for (StorageUnitCreateRequest storageUnit : storageUnitCreateRequests) { // Get the storage entity per request and verify that it exists. StorageEntity storageEntity = storageDaoHelper.getStorageEntity(storageUnit.getStorageName()); // Create storage unit and add it to the result list. storageUnitEntities.add( createStorageUnitEntity(businessObjectDataEntity, storageEntity, storageUnit.getStorageDirectory(), storageUnit.getStorageFiles(), storageUnit.isDiscoverStorageFiles())); } return storageUnitEntities; }
/** * Creates a list of storage unit entities from a list of storage unit create requests. * * @param storageUnitCreateRequests the storage unit create requests * @param businessObjectDataEntity the business object data entity * * @return the list of storage unit entities. */ private List<StorageUnitEntity> createStorageUnitEntitiesFromStorageUnits(List<StorageUnitCreateRequest> storageUnitCreateRequests, BusinessObjectDataEntity businessObjectDataEntity) { // Create the storage units for the data. List<StorageUnitEntity> storageUnitEntities = new ArrayList<>(); for (StorageUnitCreateRequest storageUnit : storageUnitCreateRequests) { // Get the storage entity per request and verify that it exists. StorageEntity storageEntity = storageDaoHelper.getStorageEntity(storageUnit.getStorageName()); // Create storage unit and add it to the result list. storageUnitEntities.add( createStorageUnitEntity(businessObjectDataEntity, storageEntity, storageUnit.getStorageDirectory(), storageUnit.getStorageFiles(), storageUnit.isDiscoverStorageFiles())); } return storageUnitEntities; }
when(storageDaoHelper.getStorageEntity(STORAGE_NAME)).thenReturn(storageEntity); when(businessObjectDataDaoHelper .createStorageUnitEntity(businessObjectDataEntity, storageEntity, storageDirectory, storageFiles, NO_DISCOVER_STORAGE_FILES)) .thenReturn(storageUnitEntity); when(businessObjectDataHelper.createBusinessObjectDataKeyFromEntity(businessObjectDataEntity)).thenReturn(businessObjectDataKey); verify(storageDaoHelper).getStorageEntity(STORAGE_NAME); verify(businessObjectDataDaoHelper) .createStorageUnitEntity(businessObjectDataEntity, storageEntity, storageDirectory, storageFiles, NO_DISCOVER_STORAGE_FILES); verify(businessObjectDataHelper).createBusinessObjectDataKeyFromEntity(businessObjectDataEntity); verify(storageUnitHelper).createBusinessObjectDataStorageUnitKey(businessObjectDataKey, STORAGE_NAME);
/** * Creates new storage unit for a given business object data and storage. * * @param request the create business object data storage unit create request * * @return the create business object data storage unit create response */ protected BusinessObjectDataStorageUnitCreateResponse createBusinessObjectDataStorageUnitImpl(BusinessObjectDataStorageUnitCreateRequest request) { // Validate the request. validateBusinessObjectDataStorageUnitCreateRequest(request); // Retrieve and validate that business object data exists. BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoHelper.getBusinessObjectDataEntity(storageUnitHelper.getBusinessObjectDataKey(request.getBusinessObjectDataStorageUnitKey())); // Retrieve and validate that storage exists. StorageEntity storageEntity = storageDaoHelper.getStorageEntity(request.getBusinessObjectDataStorageUnitKey().getStorageName()); // Create a storage unit entity. StorageUnitEntity storageUnitEntity = businessObjectDataDaoHelper .createStorageUnitEntity(businessObjectDataEntity, storageEntity, request.getStorageDirectory(), request.getStorageFiles(), request.isDiscoverStorageFiles()); // Persist the newly created storage unit entity. storageUnitDao.saveAndRefresh(storageUnitEntity); // Construct and return the response. return createBusinessObjectDataStorageUnitCreateResponse(storageUnitEntity); }
/** * Creates new storage unit for a given business object data and storage. * * @param request the create business object data storage unit create request * * @return the create business object data storage unit create response */ protected BusinessObjectDataStorageUnitCreateResponse createBusinessObjectDataStorageUnitImpl(BusinessObjectDataStorageUnitCreateRequest request) { // Validate the request. validateBusinessObjectDataStorageUnitCreateRequest(request); // Retrieve and validate that business object data exists. BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoHelper.getBusinessObjectDataEntity(storageUnitHelper.getBusinessObjectDataKey(request.getBusinessObjectDataStorageUnitKey())); // Retrieve and validate that storage exists. StorageEntity storageEntity = storageDaoHelper.getStorageEntity(request.getBusinessObjectDataStorageUnitKey().getStorageName()); // Create a storage unit entity. StorageUnitEntity storageUnitEntity = businessObjectDataDaoHelper .createStorageUnitEntity(businessObjectDataEntity, storageEntity, request.getStorageDirectory(), request.getStorageFiles(), request.isDiscoverStorageFiles()); // Persist the newly created storage unit entity. storageUnitDao.saveAndRefresh(storageUnitEntity); // Construct and return the response. return createBusinessObjectDataStorageUnitCreateResponse(storageUnitEntity); }