use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class FolderCrudManager method create.
/**
* Creates a new {@link Folder} and persists it to DB. Folder name must be
* unique within parent folder.
* @param folder DTO representation
* @return created {@link Folder} with ID value
*/
@Transactional(propagation = Propagation.REQUIRED)
public Folder create(final Folder folder) {
Assert.isTrue(StringUtils.hasText(folder.getName()), messageHelper.getMessage(MessageConstants.ERROR_FOLDER_NAME_IS_EMPTY));
Assert.isNull(loadByNameAndParentId(folder.getName(), folder.getParentId()), messageHelper.getMessage(MessageConstants.ERROR_FOLDER_NAME_EXISTS, folder.getName(), folder.getParentId()));
folder.setName(validateName(folder.getName()));
folder.setCreatedDate(DateUtils.now());
folder.setOwner(authManager.getAuthorizedUser());
if (folder.getParentId() != null) {
Folder parent = load(folder.getParentId());
folder.setParent(parent);
}
folderDao.createFolder(folder);
return folder;
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class FolderManager method unlockFolder.
/**
* Removes lock from a folder
* @param id
* @return
*/
@Transactional(propagation = Propagation.REQUIRED)
public Folder unlockFolder(Long id) {
Folder folder = crudManager.load(id);
updateTreeLocks(folder, false);
permissionManager.unlockEntity(folder);
return crudManager.load(id);
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class FolderManager method loadAllProjects.
public Folder loadAllProjects() {
Folder root = new Folder();
Set<Pair<String, String>> indicator = parseProjectIndicator();
Map<String, PipeConfValue> projectAttributes = indicator.stream().collect(Collectors.toMap(Pair::getLeft, pair -> new PipeConfValue(null, pair.getRight())));
if (MapUtils.isEmpty(projectAttributes)) {
return root;
}
List<Folder> projects = folderDao.loadAllProjects(projectAttributes).stream().filter(folder -> {
if (folder instanceof FolderWithMetadata) {
FolderWithMetadata folderWithMetadata = (FolderWithMetadata) folder;
Map<String, PipeConfValue> attributes = folderWithMetadata.getData();
return containsProjectIndicator(indicator, attributes);
}
return false;
}).collect(Collectors.toList());
root.setChildFolders(projects);
return root;
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class FolderManager method deleteForce.
/**
* Deletes a folder with all contents, specified by ID.
* @param id of {@link Folder} to delete
* @return deleted {@link Folder} instance
*/
public Folder deleteForce(Long id) {
Folder folder = crudManager.load(id);
if (!CollectionUtils.isEmpty(folder.getChildren())) {
for (AbstractHierarchicalEntity hierarchicalEntity : folder.getChildren()) {
deleteForce(hierarchicalEntity.getId());
}
}
deleteChildren(folder);
return folder;
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class FolderManager method loadTree.
public Folder loadTree() {
List<Folder> result = folderDao.loadAllFolders();
List<Pipeline> rootPipelines = pipelineManager.loadRootPipelines();
List<AbstractDataStorage> rootDataStorages = dataStorageManager.loadRootDataStorages();
List<RunConfiguration> rootRunConfigurations = configurationManager.loadRootConfigurations();
Map<String, Integer> rootMetadataEntityCount = metadataEntityManager.loadRootMetadataEntities();
Folder root = new Folder();
root.setChildFolders(result);
if (!CollectionUtils.isEmpty(rootPipelines)) {
root.setPipelines(rootPipelines);
}
if (!CollectionUtils.isEmpty(rootDataStorages)) {
root.setStorages(rootDataStorages);
}
if (!CollectionUtils.isEmpty(rootRunConfigurations)) {
root.setConfigurations(rootRunConfigurations);
}
if (!CollectionUtils.sizeIsEmpty(rootMetadataEntityCount)) {
root.setMetadata(rootMetadataEntityCount);
}
return root;
}
Aggregations