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