Search in sources :

Example 1 with EntityVO

use of com.epam.pipeline.controller.vo.EntityVO in project cloud-pipeline by epam.

the class IssueManager method createIssue.

/**
 * Creates a new issue that refers to existing {@link com.epam.pipeline.entity.AbstractSecuredEntity}.
 * If {@link com.epam.pipeline.entity.AbstractSecuredEntity} doesn't exist an error will be occurred.
 * @param issueVO {@link IssueVO} to create
 * @return create {@link Issue}
 */
@Transactional(propagation = Propagation.REQUIRED)
public Issue createIssue(IssueVO issueVO) {
    validateIssueParameters(issueVO);
    EntityVO entityVO = issueVO.getEntity();
    validateEntityParameters(entityVO);
    AbstractSecuredEntity entity = ensureEntityExists(entityVO);
    Issue issue = issueMapper.toIssue(issueVO);
    issue.setAuthor(authManager.getAuthorizedUser());
    issueDao.createIssue(issue);
    issueVO.getAttachments().forEach(a -> attachmentDao.updateAttachmentIssueId(a.getId(), issue.getId()));
    notificationManager.notifyIssue(issue, entity, StringUtils.defaultIfBlank(issueVO.getHtmlText(), issue.getText()));
    return issue;
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) Issue(com.epam.pipeline.entity.issue.Issue) AbstractSecuredEntity(com.epam.pipeline.entity.AbstractSecuredEntity) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with EntityVO

use of com.epam.pipeline.controller.vo.EntityVO in project cloud-pipeline by epam.

the class MetadataManager method updateMetadataItem.

@Transactional(propagation = Propagation.REQUIRED)
public MetadataEntry updateMetadataItem(MetadataVO metadataVO) {
    validateMetadata(metadataVO);
    EntityVO entity = metadataVO.getEntity();
    checkEntityExistence(entity.getEntityId(), entity.getEntityClass());
    MetadataEntry metadataToUpdate = metadataEntryMapper.toMetadataEntry(metadataVO);
    MetadataEntry existingMetadata = listMetadataItem(metadataToUpdate.getEntity(), false);
    if (existingMetadata == null) {
        metadataDao.registerMetadataItem(metadataToUpdate);
    } else {
        metadataDao.uploadMetadataItem(metadataToUpdate);
    }
    return metadataToUpdate;
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) MetadataEntry(com.epam.pipeline.entity.metadata.MetadataEntry) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with EntityVO

use of com.epam.pipeline.controller.vo.EntityVO 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);
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) ArrayList(java.util.ArrayList) Folder(com.epam.pipeline.entity.pipeline.Folder)

Example 4 with EntityVO

use of com.epam.pipeline.controller.vo.EntityVO 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;
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) MetadataEntry(com.epam.pipeline.entity.metadata.MetadataEntry) Folder(com.epam.pipeline.entity.pipeline.Folder)

Example 5 with EntityVO

use of com.epam.pipeline.controller.vo.EntityVO 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)

Aggregations

EntityVO (com.epam.pipeline.controller.vo.EntityVO)40 Transactional (org.springframework.transaction.annotation.Transactional)22 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)14 Test (org.junit.Test)14 Folder (com.epam.pipeline.entity.pipeline.Folder)13 MetadataEntry (com.epam.pipeline.entity.metadata.MetadataEntry)12 Issue (com.epam.pipeline.entity.issue.Issue)11 PipeConfValue (com.epam.pipeline.entity.metadata.PipeConfValue)8 HashMap (java.util.HashMap)5 IssueVO (com.epam.pipeline.controller.vo.IssueVO)4 AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)4 Before (org.junit.Before)4 Attachment (com.epam.pipeline.entity.issue.Attachment)3 AclClass (com.epam.pipeline.entity.security.acl.AclClass)3 Date (java.util.Date)3 Map (java.util.Map)3 AfterReturning (org.aspectj.lang.annotation.AfterReturning)3 MetadataVO (com.epam.pipeline.controller.vo.MetadataVO)2 MetadataEntityVO (com.epam.pipeline.controller.vo.metadata.MetadataEntityVO)2 IssueComment (com.epam.pipeline.entity.issue.IssueComment)2