Search in sources :

Example 6 with Folder

use of com.epam.pipeline.entity.pipeline.Folder 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 7 with Folder

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

the class ConfigurationRunner method getIdsToProcess.

private List<Long> getIdsToProcess(RunConfigurationWithEntitiesVO runConfiguration) {
    if (CollectionUtils.isNotEmpty(runConfiguration.getEntitiesIds())) {
        return runConfiguration.getEntitiesIds();
    }
    if (StringUtils.hasText(runConfiguration.getMetadataClass())) {
        Folder folder = folderManager.load(runConfiguration.getFolderId());
        Assert.notNull(folder, "Project is required to launch whole class processing.");
        MetadataClass metadataClass = metadataEntityManager.loadClass(runConfiguration.getMetadataClass());
        return metadataEntityManager.loadMetadataEntityByClassNameAndFolderId(folder.getId(), metadataClass.getName()).stream().map(BaseEntity::getId).collect(Collectors.toList());
    }
    return Collections.emptyList();
}
Also used : MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass) Folder(com.epam.pipeline.entity.pipeline.Folder)

Example 8 with Folder

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

the class DataStorageDaoTest method buildFolder.

private Folder buildFolder(final Long parentId) {
    Folder folder = ObjectCreatorUtils.createFolder("testFolder", parentId);
    folder.setOwner(TEST_OWNER);
    folderDao.createFolder(folder);
    return folder;
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder)

Example 9 with Folder

use of com.epam.pipeline.entity.pipeline.Folder 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 10 with Folder

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

the class FolderDaoTest method testCreateAndLoadFolderWithStorages.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testCreateAndLoadFolderWithStorages() {
    Folder folder = getFolder();
    // add datastorage
    AbstractDataStorage storage = addStorage(folder);
    Folder loaded = folderDao.loadFolder(folder.getId());
    assertEquals(folder.getId(), loaded.getId());
    assertEquals(folder.getName(), loaded.getName());
    assertNull(folder.getParentId());
    checkStorageIsPresent(storage, loaded);
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) Folder(com.epam.pipeline.entity.pipeline.Folder) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) 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