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