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