Search in sources :

Example 1 with AbstractDataStorage

use of com.epam.pipeline.entity.datastorage.AbstractDataStorage in project cloud-pipeline by epam.

the class FolderTemplateManager method createFolderFromTemplate.

void createFolderFromTemplate(Folder folder, FolderTemplate template) {
    folder.setName(template.getName());
    Folder savedFolder = crudManager.create(folder);
    if (CollectionUtils.isNotEmpty(template.getDatastorages())) {
        template.getDatastorages().forEach(storage -> {
            storage.setParentFolderId(savedFolder.getId());
            AbstractDataStorage created = dataStorageManager.create(storage, true, true, false);
            if (!MapUtils.isEmpty(storage.getMetadata())) {
                updateMetadata(storage.getMetadata(), new EntityVO(created.getId(), AclClass.DATA_STORAGE));
            }
        });
    }
    if (!MapUtils.isEmpty(template.getMetadata())) {
        updateMetadata(template.getMetadata(), new EntityVO(savedFolder.getId(), AclClass.FOLDER));
    }
    if (CollectionUtils.isNotEmpty(template.getChildren())) {
        template.getChildren().forEach(child -> {
            Folder childFolder = new Folder();
            childFolder.setParentId(folder.getId());
            createFolderFromTemplate(childFolder, child);
        });
    }
    if (CollectionUtils.isNotEmpty(template.getPermissions())) {
        template.getPermissions().forEach(permission -> {
            PermissionGrantVO permissionGrantVO = permissionGrantVOMapper.toPermissionGrantVO(permission);
            permissionGrantVO.setId(savedFolder.getId());
            permissionGrantVO.setAclClass(AclClass.FOLDER);
            permissionManager.setPermissions(permissionGrantVO);
        });
    }
}
Also used : PermissionGrantVO(com.epam.pipeline.controller.vo.PermissionGrantVO) EntityVO(com.epam.pipeline.controller.vo.EntityVO) AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) Folder(com.epam.pipeline.entity.pipeline.Folder)

Example 2 with AbstractDataStorage

use of com.epam.pipeline.entity.datastorage.AbstractDataStorage in project cloud-pipeline by epam.

the class PipelineConfigurationManager method getPipelineConfiguration.

public PipelineConfiguration getPipelineConfiguration(final PipelineStart runVO, final Tool tool) {
    PipelineConfiguration configuration;
    PipelineConfiguration defaultConfiguration = new PipelineConfiguration();
    boolean toolRun = tool != null;
    boolean pipelineRun = runVO.getPipelineId() != null;
    if (toolRun || pipelineRun) {
        defaultConfiguration = getConfigurationForToolRunOrPipelineRun(runVO, tool, toolRun);
    }
    configuration = mergeParameters(runVO, defaultConfiguration);
    if (pipelineRun) {
        configuration.setGitCredentials(gitManager.getGitCredentials(runVO.getPipelineId()));
    }
    if (toolRun) {
        mergeParametersFromTool(configuration, tool);
    }
    List<AbstractDataStorage> dataStorages = dataStorageApiService.getWritableStorages();
    configuration.setBuckets(zipToString(dataStorages, AbstractDataStorage::getPathMask));
    configuration.setNfsMountOptions(zipToString(dataStorages, mountOptionsSupplier));
    configuration.setMountPoints(zipToString(dataStorages, AbstractDataStorage::getMountPoint));
    // client always sends actual node count value
    configuration.setNodeCount(Optional.ofNullable(runVO.getNodeCount()).orElse(0));
    configuration.setAwsRegionId(runVO.getAwsRegionId());
    setEndpointsErasure(configuration);
    return configuration;
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration)

Example 3 with AbstractDataStorage

use of com.epam.pipeline.entity.datastorage.AbstractDataStorage in project cloud-pipeline by epam.

the class DataStorageDaoTest method shouldLoadExistingS3StorageByName.

@Test
public void shouldLoadExistingS3StorageByName() {
    dataStorageDao.createDataStorage(s3Bucket);
    AbstractDataStorage loaded = dataStorageDao.loadDataStorageByNameOrPath(TEST_STORAGE_NAME, null);
    validateS3Storage(loaded, s3Bucket);
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest)

Example 4 with AbstractDataStorage

use of com.epam.pipeline.entity.datastorage.AbstractDataStorage in project cloud-pipeline by epam.

the class DataStorageDaoTest method shouldLoadStorageWithFolders.

@Test
public void shouldLoadStorageWithFolders() {
    Folder root = buildFolder(null);
    root.setParentId(0L);
    Folder folder = buildFolder(root.getId());
    folder.setParent(root);
    Folder parent = buildFolder(folder.getId());
    parent.setParent(folder);
    s3Bucket.setParentFolderId(parent.getId());
    dataStorageDao.createDataStorage(s3Bucket);
    AbstractDataStorage loaded = dataStorageDao.loadStorageWithParents(s3Bucket.getId());
    validateCommonStorage(loaded, s3Bucket);
    verifyFolderTree(parent, loaded.getParent());
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) Folder(com.epam.pipeline.entity.pipeline.Folder) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest)

Example 5 with AbstractDataStorage

use of com.epam.pipeline.entity.datastorage.AbstractDataStorage in project cloud-pipeline by epam.

the class DataStorageDaoTest method shouldLoadExistingS3StorageById.

@Test
public void shouldLoadExistingS3StorageById() {
    dataStorageDao.createDataStorage(s3Bucket);
    AbstractDataStorage loaded = dataStorageDao.loadDataStorage(s3Bucket.getId());
    validateS3Storage(loaded, s3Bucket);
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest)

Aggregations

AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)62 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)22 Test (org.junit.Test)22 Transactional (org.springframework.transaction.annotation.Transactional)18 Folder (com.epam.pipeline.entity.pipeline.Folder)13 DataStorageVO (com.epam.pipeline.controller.vo.DataStorageVO)11 ArrayList (java.util.ArrayList)7 List (java.util.List)6 EntityVO (com.epam.pipeline.controller.vo.EntityVO)5 StoragePolicy (com.epam.pipeline.entity.datastorage.StoragePolicy)5 Service (org.springframework.stereotype.Service)5 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)4 UpdateDataStorageItemVO (com.epam.pipeline.controller.vo.data.storage.UpdateDataStorageItemVO)3 DataStorageDownloadFileUrl (com.epam.pipeline.entity.datastorage.DataStorageDownloadFileUrl)3 DataStorageException (com.epam.pipeline.entity.datastorage.DataStorageException)3 DataStorageFile (com.epam.pipeline.entity.datastorage.DataStorageFile)3 DataStorageLink (com.epam.pipeline.entity.pipeline.run.parameter.DataStorageLink)3 ObjectCreatorUtils.constructDataStorageVO (com.epam.pipeline.manager.ObjectCreatorUtils.constructDataStorageVO)3 IOException (java.io.IOException)3 MessageConstants (com.epam.pipeline.common.MessageConstants)2