Search in sources :

Example 56 with Folder

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;
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder) Transactional(org.springframework.transaction.annotation.Transactional)

Example 57 with 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);
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder) Transactional(org.springframework.transaction.annotation.Transactional)

Example 58 with Folder

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;
}
Also used : MetadataEntry(com.epam.pipeline.entity.metadata.MetadataEntry) Arrays(java.util.Arrays) MessageConstants(com.epam.pipeline.common.MessageConstants) AbstractHierarchicalEntity(com.epam.pipeline.entity.AbstractHierarchicalEntity) LoggerFactory(org.slf4j.LoggerFactory) SystemPreferences(com.epam.pipeline.manager.preference.SystemPreferences) Autowired(org.springframework.beans.factory.annotation.Autowired) MetadataEntryMapper(com.epam.pipeline.mapper.MetadataEntryMapper) Function(java.util.function.Function) ArrayList(java.util.ArrayList) MetadataManager(com.epam.pipeline.manager.metadata.MetadataManager) Value(org.springframework.beans.factory.annotation.Value) Folder(com.epam.pipeline.entity.pipeline.Folder) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) MessageHelper(com.epam.pipeline.common.MessageHelper) Pair(org.apache.commons.lang3.tuple.Pair) CollectionUtils(org.apache.commons.collections.CollectionUtils) Propagation(org.springframework.transaction.annotation.Propagation) Service(org.springframework.stereotype.Service) Map(java.util.Map) FolderWithMetadata(com.epam.pipeline.entity.metadata.FolderWithMetadata) GrantPermissionManager(com.epam.pipeline.manager.security.GrantPermissionManager) AbstractRunConfigurationMapper(com.epam.pipeline.mapper.AbstractRunConfigurationMapper) FolderDao(com.epam.pipeline.dao.pipeline.FolderDao) EntityManager(com.epam.pipeline.manager.EntityManager) MapUtils(org.apache.commons.collections4.MapUtils) BaseEntity(com.epam.pipeline.entity.BaseEntity) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) AbstractSecuredEntity(com.epam.pipeline.entity.AbstractSecuredEntity) PreferenceManager(com.epam.pipeline.manager.preference.PreferenceManager) Logger(org.slf4j.Logger) Set(java.util.Set) AbstractDataStorageMapper(com.epam.pipeline.mapper.AbstractDataStorageMapper) AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) PasswordGenerator.generateRandomString(com.epam.pipeline.utils.PasswordGenerator.generateRandomString) Collectors(java.util.stream.Collectors) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) List(java.util.List) MetadataEntityManager(com.epam.pipeline.manager.metadata.MetadataEntityManager) AclClass(com.epam.pipeline.entity.security.acl.AclClass) RunConfigurationManager(com.epam.pipeline.manager.configuration.RunConfigurationManager) Collections(java.util.Collections) DataStorageManager(com.epam.pipeline.manager.datastorage.DataStorageManager) EntityVO(com.epam.pipeline.controller.vo.EntityVO) Transactional(org.springframework.transaction.annotation.Transactional) StringUtils(org.springframework.util.StringUtils) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) PasswordGenerator.generateRandomString(com.epam.pipeline.utils.PasswordGenerator.generateRandomString) Folder(com.epam.pipeline.entity.pipeline.Folder) Map(java.util.Map) Pair(org.apache.commons.lang3.tuple.Pair) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) FolderWithMetadata(com.epam.pipeline.entity.metadata.FolderWithMetadata)

Example 59 with Folder

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;
}
Also used : AbstractHierarchicalEntity(com.epam.pipeline.entity.AbstractHierarchicalEntity) Folder(com.epam.pipeline.entity.pipeline.Folder)

Example 60 with 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;
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) PasswordGenerator.generateRandomString(com.epam.pipeline.utils.PasswordGenerator.generateRandomString) Folder(com.epam.pipeline.entity.pipeline.Folder) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline)

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