Search in sources :

Example 46 with Folder

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

the class RunConfigurationVO method toEntity.

public RunConfiguration toEntity() {
    RunConfiguration configuration = new RunConfiguration();
    configuration.setId(getId());
    configuration.setName(getName());
    configuration.setDescription(getDescription());
    if (parentId != null) {
        configuration.setParent(new Folder(getParentId()));
    }
    if (CollectionUtils.isNotEmpty(entries)) {
        configuration.setEntries(entries);
    } else {
        configuration.setEntries(Collections.emptyList());
    }
    return configuration;
}
Also used : RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) Folder(com.epam.pipeline.entity.pipeline.Folder)

Example 47 with Folder

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

the class DaoHelper method fillFolder.

public static Folder fillFolder(Map<Long, Folder> folders, Folder currentFolder) {
    if (currentFolder == null) {
        return null;
    }
    Long parentId = currentFolder.getParentId();
    if (parentId == null) {
        return currentFolder;
    }
    Folder folder = folders.get(parentId);
    Folder newFolder = fillFolder(folders, folder);
    currentFolder.setParent(newFolder);
    return currentFolder;
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder)

Example 48 with Folder

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

the class MetadataEntityVO method convertToMetadataEntity.

public MetadataEntity convertToMetadataEntity() {
    MetadataEntity metadataEntity = new MetadataEntity();
    MetadataClass metadataClass = new MetadataClass();
    metadataClass.setId(classId);
    metadataClass.setName(className);
    if (parentId != null) {
        metadataEntity.setParent(new Folder(parentId));
    }
    metadataEntity.setId(entityId);
    metadataEntity.setName(entityName);
    metadataEntity.setExternalId(externalId);
    metadataEntity.setClassEntity(metadataClass);
    metadataEntity.setData(data);
    return metadataEntity;
}
Also used : MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass) Folder(com.epam.pipeline.entity.pipeline.Folder)

Example 49 with Folder

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

the class DataStorageManager method loadByNameOrId.

public AbstractDataStorage loadByNameOrId(final String identifier) {
    AbstractDataStorage dataStorage = null;
    if (NumberUtils.isDigits(identifier)) {
        dataStorage = dataStorageDao.loadDataStorage(Long.parseLong(identifier));
    }
    if (dataStorage == null) {
        String pathWithName = identifier;
        if (pathWithName.startsWith("/")) {
            pathWithName = pathWithName.substring(1);
        }
        if (pathWithName.endsWith("/")) {
            pathWithName = pathWithName.substring(0, pathWithName.length() - 1);
        }
        String[] pathParts = pathWithName.split("/");
        String dataStorageName = pathParts[pathParts.length - 1];
        Long parentFolderId = null;
        if (pathParts.length > 1) {
            Folder parentFolder = folderManager.loadByNameOrId(String.join("/", Arrays.asList(pathParts).subList(0, pathParts.length - 1)));
            if (parentFolder != null) {
                parentFolderId = parentFolder.getId();
            }
        }
        if (parentFolderId != null) {
            dataStorage = dataStorageDao.loadDataStorageByNameAndParentId(dataStorageName, parentFolderId);
        } else {
            dataStorage = dataStorageDao.loadDataStorageByNameOrPath(dataStorageName, dataStorageName);
        }
    }
    Assert.notNull(dataStorage, messageHelper.getMessage(MessageConstants.ERROR_DATASTORAGE_NOT_FOUND, identifier));
    dataStorage.setHasMetadata(metadataManager.hasMetadata(new EntityVO(dataStorage.getId(), AclClass.DATA_STORAGE)));
    return dataStorage;
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) Folder(com.epam.pipeline.entity.pipeline.Folder) DataStorageFolder(com.epam.pipeline.entity.datastorage.DataStorageFolder)

Example 50 with Folder

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

the class DataStorageManager method create.

@Transactional(propagation = Propagation.REQUIRED)
public AbstractDataStorage create(DataStorageVO dataStorageVO, Boolean proceedOnCloud, Boolean checkExistence, boolean replaceStoragePath) throws DataStorageException {
    Assert.isTrue(!StringUtils.isEmpty(dataStorageVO.getName()), messageHelper.getMessage(MessageConstants.ERROR_PARAMETER_NULL_OR_EMPTY, "name"));
    assertDataStorageMountPoint(dataStorageVO);
    dataStorageVO.setName(dataStorageVO.getName().trim());
    checkDatastorageDoesntExist(dataStorageVO.getName(), dataStorageVO.getPath());
    verifyStoragePolicy(dataStorageVO, dataStorageVO.getStoragePolicy(), true);
    AbstractDataStorage dataStorage = dataStorageFactory.convertToDataStorage(dataStorageVO);
    if (StringUtils.isBlank(dataStorage.getMountOptions())) {
        dataStorage.setMountOptions(storageProviderManager.getStorageProvider(dataStorage).getDefaultMountOptions());
    }
    if (proceedOnCloud) {
        if (replaceStoragePath) {
            dataStorage.setPath(adjustStoragePath(dataStorage.getPath(), dataStorage.getType()));
        }
        String created = storageProviderManager.createBucket(dataStorage);
        dataStorage.setPath(created);
    } else if (checkExistence && !storageProviderManager.checkStorage(dataStorage)) {
        throw new IllegalStateException(messageHelper.getMessage(MessageConstants.ERROR_DATASTORAGE_NOT_FOUND_BY_NAME, dataStorage.getName(), dataStorage.getPath()));
    }
    dataStorage.setOwner(authManager.getAuthorizedUser());
    if (dataStorage.getParentFolderId() != null) {
        Folder parent = folderManager.load(dataStorage.getParentFolderId());
        dataStorage.setParent(parent);
    }
    dataStorageDao.createDataStorage(dataStorage);
    if (dataStorage.isPolicySupported()) {
        storageProviderManager.applyStoragePolicy(dataStorage);
    }
    return dataStorage;
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) Folder(com.epam.pipeline.entity.pipeline.Folder) DataStorageFolder(com.epam.pipeline.entity.datastorage.DataStorageFolder) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Folder (com.epam.pipeline.entity.pipeline.Folder)102 Transactional (org.springframework.transaction.annotation.Transactional)53 Test (org.junit.Test)52 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)48 EntityVO (com.epam.pipeline.controller.vo.EntityVO)14 AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)14 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)14 MetadataClass (com.epam.pipeline.entity.metadata.MetadataClass)13 RunConfiguration (com.epam.pipeline.entity.configuration.RunConfiguration)11 MetadataEntity (com.epam.pipeline.entity.metadata.MetadataEntity)11 PipeConfValue (com.epam.pipeline.entity.metadata.PipeConfValue)10 AclClass (com.epam.pipeline.entity.security.acl.AclClass)10 Autowired (org.springframework.beans.factory.annotation.Autowired)8 Propagation (org.springframework.transaction.annotation.Propagation)8 MetadataEntityVO (com.epam.pipeline.controller.vo.metadata.MetadataEntityVO)7 PasswordGenerator.generateRandomString (com.epam.pipeline.utils.PasswordGenerator.generateRandomString)6 FolderWithMetadata (com.epam.pipeline.entity.metadata.FolderWithMetadata)5 DataStorageVO (com.epam.pipeline.controller.vo.DataStorageVO)4 AbstractManagerTest (com.epam.pipeline.manager.AbstractManagerTest)4 Collectors (java.util.stream.Collectors)4