Search in sources :

Example 1 with MetadataVO

use of com.epam.pipeline.controller.vo.MetadataVO in project cloud-pipeline by epam.

the class FolderTemplateManager method updateMetadata.

private void updateMetadata(Map<String, PipeConfValue> data, EntityVO entity) {
    MetadataVO metadataVO = new MetadataVO();
    metadataVO.setData(data);
    metadataVO.setEntity(entity);
    metadataManager.updateMetadataItemKeys(metadataVO);
}
Also used : MetadataVO(com.epam.pipeline.controller.vo.MetadataVO)

Example 2 with MetadataVO

use of com.epam.pipeline.controller.vo.MetadataVO in project cloud-pipeline by epam.

the class MetadataManager method uploadMetadataFromFile.

@Transactional(propagation = Propagation.REQUIRED)
public MetadataEntry uploadMetadataFromFile(final EntityVO entityVO, final MultipartFile file, final boolean mergeWithExistingMetadata) {
    checkEntityExistence(entityVO.getEntityId(), entityVO.getEntityClass());
    final MetadataVO metadataVO = new MetadataVO();
    metadataVO.setEntity(entityVO);
    metadataVO.setData(convertFileContentToMetadata(file));
    if (mergeWithExistingMetadata) {
        return updateMetadataItemKeys(metadataVO);
    } else {
        return updateMetadataItem(metadataVO);
    }
}
Also used : MetadataVO(com.epam.pipeline.controller.vo.MetadataVO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with MetadataVO

use of com.epam.pipeline.controller.vo.MetadataVO in project cloud-pipeline by epam.

the class FolderManagerTest method testListProjectsShouldReturnFolderWithIndicatorSet.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testListProjectsShouldReturnFolderWithIndicatorSet() {
    folderManager.create(folder);
    MetadataVO metadataVO = new MetadataVO();
    metadataVO.setEntity(new EntityVO(folder.getId(), AclClass.FOLDER));
    metadataVO.setData(Collections.singletonMap(PROJECT_INDICATOR_TYPE, new PipeConfValue(DEFAULT_PARAM_TYPE, PROJECT_INDICATOR_VALUE)));
    metadataManager.updateMetadataItem(metadataVO);
    List<Folder> folders = folderManager.loadAllProjects().getChildFolders();
    assertThat(folders.size(), is(1));
    assertThat(folders.get(0).getId(), is(folder.getId()));
}
Also used : MetadataEntityVO(com.epam.pipeline.controller.vo.metadata.MetadataEntityVO) EntityVO(com.epam.pipeline.controller.vo.EntityVO) MetadataVO(com.epam.pipeline.controller.vo.MetadataVO) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) Folder(com.epam.pipeline.entity.pipeline.Folder) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with MetadataVO

use of com.epam.pipeline.controller.vo.MetadataVO in project cloud-pipeline by epam.

the class FolderManagerTest method shouldCloneFolderWithFolderMetadata.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void shouldCloneFolderWithFolderMetadata() {
    Folder sourceFolder = new Folder();
    sourceFolder.setName(FOLDER_TO_CLONE);
    folderManager.create(sourceFolder);
    Map<String, PipeConfValue> metadata = new HashMap<>();
    metadata.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
    MetadataVO metadataVO = new MetadataVO();
    metadataVO.setEntity(new EntityVO(sourceFolder.getId(), AclClass.FOLDER));
    metadataVO.setData(metadata);
    MetadataEntry expectedMetadata = metadataManager.updateMetadataItem(metadataVO);
    Folder childSourceFolder = new Folder();
    childSourceFolder.setName(CHILD_FOLDER_TO_CLONE);
    childSourceFolder.setParentId(sourceFolder.getId());
    folderManager.create(childSourceFolder);
    metadataVO.setEntity(new EntityVO(childSourceFolder.getId(), AclClass.FOLDER));
    metadataManager.updateMetadataItem(metadataVO);
    Folder destinationFolder = new Folder();
    destinationFolder.setName(TEST_NAME);
    folderManager.create(destinationFolder);
    folderManager.cloneFolder(sourceFolder.getId(), destinationFolder.getId(), TEST_CLONE_PREFIX);
    destinationFolder = folderManager.load(folderManager.loadByNameOrId(TEST_NAME).getId());
    Folder clonedFolder = destinationFolder.getChildFolders().get(0);
    MetadataEntry clonedFolderMetadata = metadataManager.loadMetadataItem(clonedFolder.getId(), AclClass.FOLDER);
    assertEquals(clonedFolder.getId(), clonedFolderMetadata.getEntity().getEntityId());
    assertFolderMetadata(expectedMetadata, clonedFolderMetadata);
    Folder clonedChildFolder = clonedFolder.getChildFolders().get(0);
    clonedFolderMetadata = metadataManager.loadMetadataItem(clonedChildFolder.getId(), AclClass.FOLDER);
    assertEquals(clonedChildFolder.getId(), clonedFolderMetadata.getEntity().getEntityId());
    assertFolderMetadata(expectedMetadata, clonedFolderMetadata);
}
Also used : MetadataEntityVO(com.epam.pipeline.controller.vo.metadata.MetadataEntityVO) EntityVO(com.epam.pipeline.controller.vo.EntityVO) HashMap(java.util.HashMap) MetadataVO(com.epam.pipeline.controller.vo.MetadataVO) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) MetadataEntry(com.epam.pipeline.entity.metadata.MetadataEntry) PasswordGenerator.generateRandomString(com.epam.pipeline.utils.PasswordGenerator.generateRandomString) Folder(com.epam.pipeline.entity.pipeline.Folder) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

MetadataVO (com.epam.pipeline.controller.vo.MetadataVO)4 Transactional (org.springframework.transaction.annotation.Transactional)3 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)2 EntityVO (com.epam.pipeline.controller.vo.EntityVO)2 MetadataEntityVO (com.epam.pipeline.controller.vo.metadata.MetadataEntityVO)2 PipeConfValue (com.epam.pipeline.entity.metadata.PipeConfValue)2 Folder (com.epam.pipeline.entity.pipeline.Folder)2 Test (org.junit.Test)2 MetadataEntry (com.epam.pipeline.entity.metadata.MetadataEntry)1 PasswordGenerator.generateRandomString (com.epam.pipeline.utils.PasswordGenerator.generateRandomString)1 HashMap (java.util.HashMap)1