Search in sources :

Example 6 with MetadataEntry

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

the class ToolGroupLoaderTest method setup.

@BeforeEach
void setup() {
    EntityPermissionVO entityPermissionVO = buildEntityPermissionVO(USER_NAME, ALLOWED_USERS, DENIED_USERS, ALLOWED_GROUPS, DENIED_GROUPS);
    MetadataEntry metadataEntry = buildMetadataEntry(AclClass.TOOL_GROUP, 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)

Example 7 with MetadataEntry

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

the class RunConfigurationLoaderTest method setup.

@BeforeEach
void setup() {
    EntityPermissionVO entityPermissionVO = buildEntityPermissionVO(USER_NAME, ALLOWED_USERS, DENIED_USERS, ALLOWED_GROUPS, DENIED_GROUPS);
    MetadataEntry metadataEntry = buildMetadataEntry(AclClass.CONFIGURATION, 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)

Example 8 with MetadataEntry

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

the class MetadataManager method updateMetadataItemKey.

@Transactional(propagation = Propagation.REQUIRED)
public MetadataEntry updateMetadataItemKey(MetadataVO metadataVO) {
    validateMetadata(metadataVO);
    EntityVO entity = metadataVO.getEntity();
    checkEntityExistence(entity.getEntityId(), entity.getEntityClass());
    MetadataEntry metadataToSave = metadataEntryMapper.toMetadataEntry(metadataVO);
    MetadataEntry existingMetadata = listMetadataItem(metadataToSave.getEntity(), false);
    if (existingMetadata == null) {
        LOGGER.debug("Could not find such metadata. A new one will be created.");
        metadataDao.registerMetadataItem(metadataToSave);
    } else {
        Map.Entry<String, PipeConfValue> metadataEntry = metadataToSave.getData().entrySet().iterator().next();
        metadataDao.uploadMetadataItemKey(metadataToSave.getEntity(), metadataEntry.getKey(), metadataEntry.getValue().getValue(), metadataEntry.getValue().getType());
    }
    return metadataDao.loadMetadataItem(entity);
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) MetadataEntry(com.epam.pipeline.entity.metadata.MetadataEntry) Map(java.util.Map) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with MetadataEntry

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

the class MetadataManager method deleteMetadataItemKeys.

@Transactional(propagation = Propagation.REQUIRED)
public MetadataEntry deleteMetadataItemKeys(MetadataVO metadataWithKeysToDelete) {
    validateMetadata(metadataWithKeysToDelete);
    EntityVO entity = metadataWithKeysToDelete.getEntity();
    checkEntityExistence(entity.getEntityId(), entity.getEntityClass());
    MetadataEntry metadataEntry = listMetadataItem(entity, true);
    Set<String> existingKeys = metadataEntry.getData().keySet();
    Set<String> keysToDelete = metadataWithKeysToDelete.getData().keySet();
    if (!existingKeys.containsAll(keysToDelete)) {
        throw new IllegalArgumentException("Could not delete non existing key.");
    }
    return metadataDao.deleteMetadataItemKeys(metadataEntry, keysToDelete);
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) MetadataEntry(com.epam.pipeline.entity.metadata.MetadataEntry) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with MetadataEntry

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

the class MetadataManager method updateMetadataItemKeys.

@Transactional(propagation = Propagation.REQUIRED)
public MetadataEntry updateMetadataItemKeys(MetadataVO metadataVO) {
    validateMetadata(metadataVO);
    EntityVO entity = metadataVO.getEntity();
    checkEntityExistence(entity.getEntityId(), entity.getEntityClass());
    MetadataEntry metadataToSave = metadataEntryMapper.toMetadataEntry(metadataVO);
    MetadataEntry existingMetadata = listMetadataItem(metadataToSave.getEntity(), false);
    if (existingMetadata == null) {
        LOGGER.debug("Could not find such metadata. A new one will be created.");
        metadataDao.registerMetadataItem(metadataToSave);
    } else {
        existingMetadata.getData().putAll(metadataToSave.getData());
        metadataDao.uploadMetadataItem(existingMetadata);
    }
    return metadataDao.loadMetadataItem(entity);
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) MetadataEntry(com.epam.pipeline.entity.metadata.MetadataEntry) Transactional(org.springframework.transaction.annotation.Transactional)

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