Search in sources :

Example 1 with MetadataEntityReader

use of com.epam.pipeline.manager.metadata.parser.MetadataEntityReader 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);
    }
}
Also used : MetadataEntityReader(com.epam.pipeline.manager.metadata.parser.MetadataEntityReader) MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass) MetadataReadingException(com.epam.pipeline.exception.MetadataReadingException) MetadataHeader(com.epam.pipeline.manager.metadata.parser.MetadataHeader) IOException(java.io.IOException) Folder(com.epam.pipeline.entity.pipeline.Folder) MetadataEntityHeaderParser(com.epam.pipeline.manager.metadata.parser.MetadataEntityHeaderParser)

Aggregations

MetadataClass (com.epam.pipeline.entity.metadata.MetadataClass)1 Folder (com.epam.pipeline.entity.pipeline.Folder)1 MetadataReadingException (com.epam.pipeline.exception.MetadataReadingException)1 MetadataEntityHeaderParser (com.epam.pipeline.manager.metadata.parser.MetadataEntityHeaderParser)1 MetadataEntityReader (com.epam.pipeline.manager.metadata.parser.MetadataEntityReader)1 MetadataHeader (com.epam.pipeline.manager.metadata.parser.MetadataHeader)1 IOException (java.io.IOException)1