use of com.epam.pipeline.entity.metadata.MetadataClass in project cloud-pipeline by epam.
the class MetadataEntityLoaderTest method shouldLoadMetadataEntityTest.
@Test
void shouldLoadMetadataEntityTest() throws EntityNotFoundException {
MetadataClass metadataClass = new MetadataClass(1L, "Sample");
MetadataEntity expectedMetadataEntity = new MetadataEntity();
expectedMetadataEntity.setClassEntity(metadataClass);
expectedMetadataEntity.setId(1L);
expectedMetadataEntity.setExternalId("external");
expectedMetadataEntity.setParent(new Folder(1L));
expectedMetadataEntity.setName(TEST_NAME);
expectedMetadataEntity.setOwner(TEST_NAME);
expectedMetadataEntity.setData(Collections.singletonMap(TEST_KEY, new PipeConfValue("string", TEST_VALUE)));
MetadataEntityLoader metadataEntityLoader = new MetadataEntityLoader(apiClient);
when(apiClient.loadMetadataEntity(anyLong())).thenReturn(expectedMetadataEntity);
Optional<EntityContainer<MetadataEntity>> container = metadataEntityLoader.loadEntity(1L);
EntityContainer<MetadataEntity> metadataEntityContainer = container.orElseThrow(AssertionError::new);
MetadataEntity actualMetadataEntity = metadataEntityContainer.getEntity();
assertNotNull(actualMetadataEntity);
verifyMetadataEntity(expectedMetadataEntity, actualMetadataEntity);
verifyPermissions(PERMISSIONS_CONTAINER_WITH_OWNER, metadataEntityContainer.getPermissions());
verifyMetadata(EXPECTED_METADATA, new ArrayList<>(metadataEntityContainer.getMetadata().values()));
}
use of com.epam.pipeline.entity.metadata.MetadataClass in project cloud-pipeline by epam.
the class MetadataEntityVO method convertToMetadataEntity.
public MetadataEntity convertToMetadataEntity() {
MetadataEntity metadataEntity = new MetadataEntity();
MetadataClass metadataClass = new MetadataClass();
metadataClass.setId(classId);
metadataClass.setName(className);
if (parentId != null) {
metadataEntity.setParent(new Folder(parentId));
}
metadataEntity.setId(entityId);
metadataEntity.setName(entityName);
metadataEntity.setExternalId(externalId);
metadataEntity.setClassEntity(metadataClass);
metadataEntity.setData(data);
return metadataEntity;
}
use of com.epam.pipeline.entity.metadata.MetadataClass in project cloud-pipeline by epam.
the class MetadataEntityManager method deleteMetadataClass.
@Transactional(propagation = Propagation.REQUIRED)
public MetadataClass deleteMetadataClass(Long id) {
Assert.notNull(id, messageHelper.getMessage(MessageConstants.ERROR_INVALID_METADATA_ENTITY_CLASS_ID, id));
MetadataClass metadataClass = loadClass(id);
metadataClassDao.deleteMetadataClass(id);
return metadataClass;
}
use of com.epam.pipeline.entity.metadata.MetadataClass in project cloud-pipeline by epam.
the class MetadataEntityManager method updateExternalClassName.
@Transactional(propagation = Propagation.REQUIRED)
public MetadataClass updateExternalClassName(Long id, FireCloudClass externalClassName) {
Assert.notNull(id, messageHelper.getMessage(MessageConstants.ERROR_INVALID_METADATA_ENTITY_CLASS_ID, id));
MetadataClass metadataClass = loadClass(id);
Assert.notNull(metadataClass, messageHelper.getMessage(MessageConstants.ERROR_METADATA_ENTITY_CLASS_NOT_FOUND, id));
metadataClass.setFireCloudClassName(externalClassName);
metadataClassDao.updateMetadataClass(metadataClass);
return metadataClass;
}
use of com.epam.pipeline.entity.metadata.MetadataClass in project cloud-pipeline by epam.
the class MetadataUploadManager method readFile.
private MetadataParsingResult readFile(Long parentId, MultipartFile file) {
try {
final Folder parent = folderManager.load(parentId);
String delimiter = MetadataParsingUtils.getDelimiterFromFileExtension(file.getOriginalFilename());
byte[] inputData = file.getBytes();
MetadataHeader header = new MetadataEntityHeaderParser(delimiter).readHeader(ByteSource.wrap(inputData).openStream());
validateTypes(header, parentId);
MetadataClass metadataClass = getOrCreateClass(header.getClassName());
return new MetadataEntityReader(delimiter, parent, metadataClass).readData(ByteSource.wrap(inputData).openStream(), header.getFields());
} catch (IOException e) {
throw new MetadataReadingException(e.getMessage(), e);
}
}
Aggregations