Search in sources :

Example 1 with Adif3RecordTransformer

use of uk.m0nom.adif3.transform.Adif3RecordTransformer in project adif-processor by urbancamo.

the class Adif3Transformer method transform.

public Qsos transform(Adif3 log, TransformControl control, TransformResults results) throws UnsupportedHeaderException {
    Adif3RecordTransformer transformer;
    Qsos qsos = new Qsos(log);
    transformer = new CommentParsingAdifRecordTransformer(config, summits, qrzService, control, results);
    int index = 1;
    for (Adif3Record rec : log.getRecords()) {
        if ((rec.getStationCallsign() != null || rec.getOperator() != null) && rec.getCall() != null) {
            transformer.transform(qsos, rec, index++);
        }
    }
    AdifHeader header = new AdifHeader();
    header.setProgramId("M0NOM ADIF Processor");
    header.setProgramVersion("1.0");
    log.setHeader(header);
    return qsos;
}
Also used : Qsos(uk.m0nom.adif3.contacts.Qsos) Adif3Record(org.marsik.ham.adif.Adif3Record) AdifHeader(org.marsik.ham.adif.AdifHeader) CommentParsingAdifRecordTransformer(uk.m0nom.adif3.transform.CommentParsingAdifRecordTransformer) Adif3RecordTransformer(uk.m0nom.adif3.transform.Adif3RecordTransformer)

Example 2 with Adif3RecordTransformer

use of uk.m0nom.adif3.transform.Adif3RecordTransformer in project adif-processor by urbancamo.

the class AdifReaderTest method testAdifFLE.

@Test
public void testAdifFLE() throws Exception {
    AdiReader reader = new AdiReader();
    BufferedReader inputReader = resourceInput("adif/2021-01-09-Queen-Adelaides-Hill.adi");
    Optional<Adif3> result = reader.read(inputReader);
    // System.out.println(new File("tmp.txt").getAbsolutePath());
    YamlMapping config = Yaml.createYamlInput(new File("adif-processor.yaml")).readYamlMapping();
    if (result.isPresent()) {
        Adif3 log = result.get();
        Qsos qsos = new Qsos(log);
        assertThat(log.getHeader().getProgramId()).isEqualTo("FLE");
        ActivityDatabases summits = new ActivityDatabases();
        summits.loadData();
        QrzXmlService qrzXmlService = new QrzXmlService(null, null);
        if (!qrzXmlService.getSessionKey()) {
            System.err.println("Could not connect to QRZ.COM, continuing...");
        }
        TransformResults results = new TransformResults();
        Adif3RecordTransformer transformer = new CommentParsingAdifRecordTransformer(config, summits, qrzXmlService, control, results);
        int index = 1;
        for (Adif3Record rec : log.getRecords()) {
            transformer.transform(qsos, rec, index++);
        }
        assertThat(log.getRecords()).hasSize(16);
    }
}
Also used : Qsos(uk.m0nom.adif3.contacts.Qsos) TransformResults(uk.m0nom.adif3.transform.TransformResults) AdiReader(org.marsik.ham.adif.AdiReader) Adif3RecordTransformer(uk.m0nom.adif3.transform.Adif3RecordTransformer) Adif3(org.marsik.ham.adif.Adif3) Adif3Record(org.marsik.ham.adif.Adif3Record) BufferedReader(java.io.BufferedReader) YamlMapping(com.amihaiemil.eoyaml.YamlMapping) ActivityDatabases(uk.m0nom.activity.ActivityDatabases) QrzXmlService(uk.m0nom.qrz.QrzXmlService) File(java.io.File) CommentParsingAdifRecordTransformer(uk.m0nom.adif3.transform.CommentParsingAdifRecordTransformer) Test(org.junit.Test)

Aggregations

Adif3Record (org.marsik.ham.adif.Adif3Record)2 Qsos (uk.m0nom.adif3.contacts.Qsos)2 Adif3RecordTransformer (uk.m0nom.adif3.transform.Adif3RecordTransformer)2 CommentParsingAdifRecordTransformer (uk.m0nom.adif3.transform.CommentParsingAdifRecordTransformer)2 YamlMapping (com.amihaiemil.eoyaml.YamlMapping)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 Test (org.junit.Test)1 AdiReader (org.marsik.ham.adif.AdiReader)1 Adif3 (org.marsik.ham.adif.Adif3)1 AdifHeader (org.marsik.ham.adif.AdifHeader)1 ActivityDatabases (uk.m0nom.activity.ActivityDatabases)1 TransformResults (uk.m0nom.adif3.transform.TransformResults)1 QrzXmlService (uk.m0nom.qrz.QrzXmlService)1