Search in sources :

Example 46 with MetadataEntity

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

the class MetadataWriterTest method entity.

private MetadataEntity entity(final String entityClass, final String id, final Map<String, PipeConfValue> data) {
    final MetadataEntity metadataEntity = new MetadataEntity();
    metadataEntity.setExternalId(id);
    metadataEntity.setData(data);
    final MetadataClass metadataClass = new MetadataClass();
    metadataClass.setName(entityClass);
    metadataEntity.setClassEntity(metadataClass);
    return metadataEntity;
}
Also used : MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass)

Example 47 with MetadataEntity

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

the class ParameterMapperTest method mapParameters.

@Test
public void mapParameters() throws Exception {
    Map<String, PipeConfValueVO> parametersToResolve = new HashMap<>();
    parametersToResolve.put(PATIENT_PIPE_PARAM, new PipeConfValueVO("this.Patient.Patient_ID"));
    parametersToResolve.put(SAMPLE_PIPE_PARAM, new PipeConfValueVO("this.Sample_Name"));
    parametersToResolve.put(REFERENCE_PIPE_PARAM, new PipeConfValueVO(SCALAR_VALUE));
    parametersToResolve.put(BATCHES_PIPE_PARAM, new PipeConfValueVO("this.Patient.Batch.Batch_Name"));
    Map<ParameterMapper.MetadataKey, MetadataEntity> references = new HashMap<>();
    MetadataEntity sample = new MetadataEntity();
    sample.setExternalId(SAMPLE_ID);
    Map<String, PipeConfValue> sampleData = new HashMap<>();
    sampleData.put("Patient", new PipeConfValue("Participant:ID", PATIENT_ID));
    sampleData.put("Sample_Name", new PipeConfValue(PipeConfValueVO.DEFAULT_TYPE, SAMPLE_NAME));
    sample.setData(sampleData);
    references.put(new ParameterMapper.MetadataKey("Sample", SAMPLE_ID), sample);
    MetadataEntity patient = new MetadataEntity();
    patient.setExternalId(PATIENT_ID);
    Map<String, PipeConfValue> patientData = new HashMap<>();
    patientData.put("Patient_ID", new PipeConfValue(PipeConfValueVO.DEFAULT_TYPE, PATIENT_UID));
    patientData.put("Batch", new PipeConfValue("Array[Batch]", "[\"b1\", \"b2\"]"));
    patient.setData(patientData);
    references.put(new ParameterMapper.MetadataKey("Participant", PATIENT_ID), patient);
    MetadataEntity batch1 = new MetadataEntity();
    batch1.setExternalId(BATCH1_ID);
    Map<String, PipeConfValue> batch1Data = new HashMap<>();
    batch1Data.put(BATCH_NAME_PARAMETER, new PipeConfValue(PipeConfValueVO.DEFAULT_TYPE, BATCH1_NAME));
    batch1.setData(batch1Data);
    references.put(new ParameterMapper.MetadataKey(BATCH_CLASS, BATCH1_ID), batch1);
    MetadataEntity batch2 = new MetadataEntity();
    batch2.setExternalId(BATCH2_ID);
    Map<String, PipeConfValue> batch2Data = new HashMap<>();
    batch2Data.put(BATCH_NAME_PARAMETER, new PipeConfValue(PipeConfValueVO.DEFAULT_TYPE, BATCH2_NAME));
    batch2.setData(batch2Data);
    references.put(new ParameterMapper.MetadataKey(BATCH_CLASS, BATCH2_ID), batch2);
    Map<String, PipeConfValueVO> result = parameterMapper.mapParameters(sample, null, parametersToResolve, references);
    assertEquals(SAMPLE_NAME, result.get(SAMPLE_PIPE_PARAM).getValue());
    assertEquals(PATIENT_UID, result.get(PATIENT_PIPE_PARAM).getValue());
    assertEquals(SCALAR_VALUE, result.get(REFERENCE_PIPE_PARAM).getValue());
    assertEquals(BATCH1_NAME + "," + BATCH2_NAME, result.get(BATCHES_PIPE_PARAM).getValue());
}
Also used : MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) PipeConfValueVO(com.epam.pipeline.entity.configuration.PipeConfValueVO) HashMap(java.util.HashMap) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest) Test(org.junit.Test)

Example 48 with MetadataEntity

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

the class MetadataEntityMapperTest method shouldMapMetadataEntity.

@Test
void shouldMapMetadataEntity() throws IOException {
    MetadataEntityMapper mapper = new MetadataEntityMapper();
    MetadataClass metadataClass = new MetadataClass(1L, "Sample");
    MetadataEntity metadataEntity = new MetadataEntity();
    metadataEntity.setClassEntity(metadataClass);
    metadataEntity.setId(1L);
    metadataEntity.setExternalId("external");
    metadataEntity.setParent(new Folder(1L));
    metadataEntity.setName(TEST_NAME);
    metadataEntity.setData(Collections.singletonMap(TEST_KEY, new PipeConfValue("string", TEST_VALUE)));
    EntityContainer<MetadataEntity> container = EntityContainer.<MetadataEntity>builder().entity(metadataEntity).permissions(PERMISSIONS_CONTAINER).build();
    XContentBuilder contentBuilder = mapper.map(container);
    verifyMetadataEntity(metadataEntity, EXPECTED_METADATA, contentBuilder);
    verifyPermissions(PERMISSIONS_CONTAINER, contentBuilder);
}
Also used : MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) MapperVerificationUtils.verifyMetadataEntity(com.epam.pipeline.elasticsearchagent.MapperVerificationUtils.verifyMetadataEntity) MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) Folder(com.epam.pipeline.entity.pipeline.Folder) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

MetadataEntity (com.epam.pipeline.entity.metadata.MetadataEntity)48 PipeConfValue (com.epam.pipeline.entity.metadata.PipeConfValue)22 Test (org.junit.Test)22 Transactional (org.springframework.transaction.annotation.Transactional)14 MetadataClass (com.epam.pipeline.entity.metadata.MetadataClass)12 Folder (com.epam.pipeline.entity.pipeline.Folder)10 HashMap (java.util.HashMap)9 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)7 List (java.util.List)7 Map (java.util.Map)6 MetadataEntityVO (com.epam.pipeline.controller.vo.metadata.MetadataEntityVO)5 IOException (java.io.IOException)5 MetadataReadingException (com.epam.pipeline.exception.MetadataReadingException)4 FolderManager (com.epam.pipeline.manager.pipeline.FolderManager)4 InputStream (java.io.InputStream)4 ArrayList (java.util.ArrayList)4 Autowired (org.springframework.beans.factory.annotation.Autowired)4 Propagation (org.springframework.transaction.annotation.Propagation)4 AclClass (com.epam.pipeline.entity.security.acl.AclClass)3 com.epam.pipeline.manager.metadata.parser (com.epam.pipeline.manager.metadata.parser)3