Search in sources :

Example 1 with MetadataEntry

use of com.epam.pipeline.entity.metadata.MetadataEntry in project cloud-pipeline by epam.

the class MetadataManager method deleteMetadataItemKey.

@Transactional(propagation = Propagation.REQUIRED)
public MetadataEntry deleteMetadataItemKey(EntityVO entityVO, String key) {
    checkEntityExistence(entityVO.getEntityId(), entityVO.getEntityClass());
    MetadataEntry metadataEntry = listMetadataItem(entityVO, true);
    if (!metadataEntry.getData().keySet().contains(key)) {
        throw new IllegalArgumentException("Could not delete non existing key.");
    }
    metadataEntry.getData().keySet().remove(key);
    metadataDao.deleteMetadataItemKey(entityVO, key);
    return metadataEntry;
}
Also used : MetadataEntry(com.epam.pipeline.entity.metadata.MetadataEntry) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with MetadataEntry

use of com.epam.pipeline.entity.metadata.MetadataEntry in project cloud-pipeline by epam.

the class MetadataManager method deleteMetadataItem.

@Transactional(propagation = Propagation.REQUIRED)
public MetadataEntry deleteMetadataItem(EntityVO entityVO) {
    checkEntityExistence(entityVO.getEntityId(), entityVO.getEntityClass());
    MetadataEntry metadataEntry = listMetadataItem(entityVO, true);
    metadataDao.deleteMetadataItem(entityVO);
    return metadataEntry;
}
Also used : MetadataEntry(com.epam.pipeline.entity.metadata.MetadataEntry) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with MetadataEntry

use of com.epam.pipeline.entity.metadata.MetadataEntry 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 4 with MetadataEntry

use of com.epam.pipeline.entity.metadata.MetadataEntry 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 MetadataEntry

use of com.epam.pipeline.entity.metadata.MetadataEntry in project cloud-pipeline by epam.

the class DockerRegistryLoaderTest method setup.

@BeforeEach
void setup() {
    EntityPermissionVO entityPermissionVO = buildEntityPermissionVO(USER_NAME, ALLOWED_USERS, DENIED_USERS, ALLOWED_GROUPS, DENIED_GROUPS);
    MetadataEntry metadataEntry = buildMetadataEntry(AclClass.DOCKER_REGISTRY, 1L, TEST_KEY + " " + TEST_VALUE);
    when(apiClient.loadUserByName(anyString())).thenReturn(USER);
    when(apiClient.loadPermissionsForEntity(anyLong(), any())).thenReturn(entityPermissionVO);
    when(apiClient.loadMetadataEntry(any())).thenReturn(Collections.singletonList(metadataEntry));
}
Also used : ObjectCreationUtils.buildEntityPermissionVO(com.epam.pipeline.elasticsearchagent.ObjectCreationUtils.buildEntityPermissionVO) EntityPermissionVO(com.epam.pipeline.vo.EntityPermissionVO) MetadataEntry(com.epam.pipeline.entity.metadata.MetadataEntry) ObjectCreationUtils.buildMetadataEntry(com.epam.pipeline.elasticsearchagent.ObjectCreationUtils.buildMetadataEntry) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

MetadataEntry (com.epam.pipeline.entity.metadata.MetadataEntry)24 EntityVO (com.epam.pipeline.controller.vo.EntityVO)12 Transactional (org.springframework.transaction.annotation.Transactional)10 ObjectCreationUtils.buildEntityPermissionVO (com.epam.pipeline.elasticsearchagent.ObjectCreationUtils.buildEntityPermissionVO)9 ObjectCreationUtils.buildMetadataEntry (com.epam.pipeline.elasticsearchagent.ObjectCreationUtils.buildMetadataEntry)9 EntityPermissionVO (com.epam.pipeline.vo.EntityPermissionVO)9 BeforeEach (org.junit.jupiter.api.BeforeEach)9 PipeConfValue (com.epam.pipeline.entity.metadata.PipeConfValue)7 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 Folder (com.epam.pipeline.entity.pipeline.Folder)2 MetadataVO (com.epam.pipeline.controller.vo.MetadataVO)1 MetadataEntityVO (com.epam.pipeline.controller.vo.metadata.MetadataEntityVO)1 Issue (com.epam.pipeline.entity.issue.Issue)1 FolderWithMetadata (com.epam.pipeline.entity.metadata.FolderWithMetadata)1 PasswordGenerator.generateRandomString (com.epam.pipeline.utils.PasswordGenerator.generateRandomString)1 EntityVO (com.epam.pipeline.vo.EntityVO)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1