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);
});
}
}
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();
}
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;
}
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());
}
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);
}
Aggregations