Search in sources :

Example 1 with MskimpactSeqDate

use of org.cbioportal.cmo.pipelines.cvr.model.staging.MskimpactSeqDate in project cmo-pipelines by knowledgesystems.

the class MskimpactSeqDateFieldSetMapper method mapFieldSet.

@Override
public MskimpactSeqDate mapFieldSet(FieldSet fs) throws BindException {
    MskimpactSeqDate record = new MskimpactSeqDate();
    List<String> fields = MskimpactSeqDate.getFieldNames();
    for (int i = 0; i < fields.size(); i++) {
        String field = fields.get(i);
        try {
            record.getClass().getMethod("set" + field, String.class).invoke(record, fs.readString(i));
        } catch (Exception e) {
            if (e.getClass().equals(NoSuchMethodException.class)) {
                log.info("No set method exists for " + field);
            }
        }
    }
    return record;
}
Also used : BindException(org.springframework.validation.BindException) MskimpactSeqDate(org.cbioportal.cmo.pipelines.cvr.model.staging.MskimpactSeqDate)

Example 2 with MskimpactSeqDate

use of org.cbioportal.cmo.pipelines.cvr.model.staging.MskimpactSeqDate in project cmo-pipelines by knowledgesystems.

the class CVRClinicalDataReader method processSeqDateFile.

private void processSeqDateFile(ExecutionContext ec) {
    File mskimpactSeqDateFile = new File(stagingDirectory, CVRUtilities.SEQ_DATE_CLINICAL_FILE);
    if (!mskimpactSeqDateFile.exists()) {
        log.error("File does not exist - skipping data loading from seq date file: " + mskimpactSeqDateFile.getName());
        return;
    }
    log.info("Loading seq date data from: " + mskimpactSeqDateFile.getName());
    DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer(DelimitedLineTokenizer.DELIMITER_TAB);
    DefaultLineMapper<MskimpactSeqDate> mapper = new DefaultLineMapper<>();
    mapper.setLineTokenizer(tokenizer);
    mapper.setFieldSetMapper(new MskimpactSeqDateFieldSetMapper());
    FlatFileItemReader<MskimpactSeqDate> reader = new FlatFileItemReader<>();
    reader.setResource(new FileSystemResource(mskimpactSeqDateFile));
    reader.setLineMapper(mapper);
    reader.setLinesToSkip(1);
    reader.open(ec);
    MskimpactSeqDate mskimpactSeqDate;
    try {
        while ((mskimpactSeqDate = reader.read()) != null) {
            // of samples, we might want a separate sampleToRecordMap for performance
            if (patientToRecordMap.keySet().contains(mskimpactSeqDate.getPATIENT_ID())) {
                for (CVRClinicalRecord record : patientToRecordMap.get(mskimpactSeqDate.getPATIENT_ID())) {
                    if (record.getSAMPLE_ID().equals(mskimpactSeqDate.getSAMPLE_ID())) {
                        record.setSEQ_DATE(mskimpactSeqDate.getSEQ_DATE());
                        break;
                    }
                }
            }
        }
    } catch (Exception e) {
        log.error("Error reading data from seq date file: " + mskimpactSeqDateFile.getName());
        throw new ItemStreamException(e);
    } finally {
        reader.close();
    }
}
Also used : DelimitedLineTokenizer(org.springframework.batch.item.file.transform.DelimitedLineTokenizer) FlatFileItemReader(org.springframework.batch.item.file.FlatFileItemReader) CVRClinicalRecord(org.cbioportal.cmo.pipelines.cvr.model.staging.CVRClinicalRecord) DefaultLineMapper(org.springframework.batch.item.file.mapping.DefaultLineMapper) FileSystemResource(org.springframework.core.io.FileSystemResource) MskimpactSeqDate(org.cbioportal.cmo.pipelines.cvr.model.staging.MskimpactSeqDate)

Aggregations

MskimpactSeqDate (org.cbioportal.cmo.pipelines.cvr.model.staging.MskimpactSeqDate)2 CVRClinicalRecord (org.cbioportal.cmo.pipelines.cvr.model.staging.CVRClinicalRecord)1 FlatFileItemReader (org.springframework.batch.item.file.FlatFileItemReader)1 DefaultLineMapper (org.springframework.batch.item.file.mapping.DefaultLineMapper)1 DelimitedLineTokenizer (org.springframework.batch.item.file.transform.DelimitedLineTokenizer)1 FileSystemResource (org.springframework.core.io.FileSystemResource)1 BindException (org.springframework.validation.BindException)1