use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class MetadataManager method loadEntitiesMetadataFromFolder.
public List<MetadataEntryWithIssuesCount> loadEntitiesMetadataFromFolder(Long parentFolderId) {
List<EntityVO> entities = new ArrayList<>();
Folder folder;
if (parentFolderId == null) {
folder = folderManager.loadTree();
} else {
folder = folderManager.load(parentFolderId);
entities.add(new EntityVO(parentFolderId, AclClass.FOLDER));
}
if (!CollectionUtils.isEmpty(folder.getPipelines())) {
folder.getPipelines().forEach(pipeline -> entities.add(new EntityVO(pipeline.getId(), AclClass.PIPELINE)));
}
if (!CollectionUtils.isEmpty(folder.getConfigurations())) {
folder.getConfigurations().forEach(configuration -> entities.add(new EntityVO(configuration.getId(), AclClass.CONFIGURATION)));
}
if (!CollectionUtils.isEmpty(folder.getStorages())) {
folder.getStorages().forEach(storage -> entities.add(new EntityVO(storage.getId(), AclClass.DATA_STORAGE)));
}
if (!CollectionUtils.isEmpty(folder.getChildren())) {
folder.getChildren().forEach(childFolder -> entities.add(new EntityVO(childFolder.getId(), AclClass.FOLDER)));
}
if (CollectionUtils.isEmpty(entities)) {
return Collections.emptyList();
}
return metadataDao.loadMetadataItemsWithIssues(entities);
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class FolderCrudManager method delete.
/**
* Deletes a folder specified by ID. Folder may be deleted only if it doesn't have
* any children from specified list: pipeline, folder, storage, configuration.
* If some {@link com.epam.pipeline.entity.metadata.MetadataEntity} instances exist in Folder,
* they will deleted before actual deletion of the folder
* @param id of {@link Folder} to delete
* @return deleted {@link Folder} instance
*/
@Transactional(propagation = Propagation.REQUIRED)
public Folder delete(final Long id) {
Folder folder = load(id);
checkChildrenNotPresent(folder.getChildFolders(), folder.getName(), "folders");
checkChildrenNotPresent(folder.getPipelines(), folder.getName(), "pipelines");
checkChildrenNotPresent(folder.getStorages(), folder.getName(), "storages");
checkChildrenNotPresent(folder.getConfigurations(), folder.getName(), "configurations");
if (MapUtils.isNotEmpty(folder.getMetadata())) {
LOGGER.debug("Clearing metadata before folder deletion");
metadataEntityManager.deleteMetadataFromFolder(id);
}
folderDao.deleteFolder(id);
return folder;
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class FolderCrudManager method update.
/**
* Updates a {@link Folder} specified by id. Method checks name uniqueness and
* recursive dependencies.
* @param folder to update
* @return updated {@link Folder}
*/
@Transactional(propagation = Propagation.REQUIRED)
public Folder update(final Folder folder) {
Folder dbFolder = load(folder.getId());
if (StringUtils.hasText(folder.getName())) {
dbFolder.setName(validateName(folder.getName()));
}
Long parentId = folder.getParentId();
Assert.isNull(loadByNameAndParentId(folder.getName(), parentId), messageHelper.getMessage(MessageConstants.ERROR_FOLDER_NAME_EXISTS, folder.getName(), parentId));
if (parentId != null) {
Assert.isTrue(!dbFolder.getId().equals(parentId), messageHelper.getMessage(MessageConstants.ERROR_FOLDER_RECURSIVE_DEPENDENCY, folder.getId(), parentId));
boolean recursiveDependency = checkChildrenFolders(folder, parentId);
Assert.isTrue(!recursiveDependency, messageHelper.getMessage(MessageConstants.ERROR_FOLDER_RECURSIVE_DEPENDENCY, folder.getId(), parentId));
dbFolder.setParent(load(parentId));
}
dbFolder.setParentId(folder.getParentId());
folderDao.updateFolder(dbFolder);
return dbFolder;
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class FolderManager method lockFolder.
/**
* Prohibits any changes to a folder
* Sets NO_WRITE & NO_EXECUTE permissions for an entity and all it's children
* @param id specifies entity
* @return
*/
@Transactional(propagation = Propagation.REQUIRED)
public Folder lockFolder(Long id) {
Folder folder = crudManager.load(id);
updateTreeLocks(folder, true);
permissionManager.lockEntity(folder);
return crudManager.load(id);
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class FolderManager method createCloneFolder.
private Folder createCloneFolder(Folder folderToClone, Long parentId) {
Long sourceFolderId = folderToClone.getId();
folderToClone.setParentId(parentId);
Folder clonedFolder = crudManager.create(folderToClone);
if (!CollectionUtils.isEmpty(folderToClone.getStorages())) {
folderToClone.getStorages().forEach(storage -> {
storage.setParentFolderId(clonedFolder.getId());
dataStorageManager.create(dataStorageMapper.toDataStorageVO(storage), true, true, false);
});
}
if (!CollectionUtils.isEmpty(folderToClone.getConfigurations())) {
folderToClone.getConfigurations().forEach(runConfiguration -> {
runConfiguration.setParent(clonedFolder);
configurationManager.create(runConfigurationMapper.toRunConfigurationVO(runConfiguration));
});
}
MetadataEntry metadataEntry = metadataManager.loadMetadataItem(sourceFolderId, AclClass.FOLDER);
if (metadataEntry != null && !MapUtils.isEmpty(metadataEntry.getData())) {
metadataEntry.setEntity(new EntityVO(clonedFolder.getId(), AclClass.FOLDER));
metadataManager.updateMetadataItem(metadataEntryMapper.toMetadataVO(metadataEntry));
}
metadataEntityManager.insertCopiesOfExistentMetadataEntities(sourceFolderId, clonedFolder.getId());
if (!CollectionUtils.isEmpty(folderToClone.getChildFolders())) {
folderToClone.getChildFolders().forEach(child -> createCloneFolder(child, clonedFolder.getId()));
}
return clonedFolder;
}
Aggregations