Search in sources :

Example 21 with LogProgressIndicator

use of eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator in project hale by halestudio.

the class SkosCodeListTest method readCodeList_WithLanguage.

private CodeList readCodeList_WithLanguage(URI source, final String language) throws Exception {
    SkosCodeListReader reader = new SkosCodeListReader() {

        /**
         * @see eu.esdihumboldt.hale.io.codelist.skos.reader.SkosCodeListReader#getLangauge()
         */
        @Override
        public String getLangauge() {
            return language;
        }
    };
    reader.setSource(new DefaultInputSupplier(source));
    IOReport report = reader.execute(new LogProgressIndicator());
    assertTrue(report.isSuccess());
    return reader.getCodeList();
}
Also used : SkosCodeListReader(eu.esdihumboldt.hale.io.codelist.skos.reader.SkosCodeListReader) DefaultInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport) LogProgressIndicator(eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator)

Example 22 with LogProgressIndicator

use of eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator in project hale by halestudio.

the class CSVSchemaReaderTest method testRead4.

/**
 * Test for given property names and property types with point as a decimal
 * divisor
 *
 * @throws Exception the Exception thrown if the test fails
 */
@Test
public void testRead4() throws Exception {
    String props = "A,B,C,D,E";
    CSVSchemaReader schemaReader = new CSVSchemaReader();
    schemaReader.setSource(new DefaultInputSupplier(getClass().getResource("/data/test4-commadecimal.csv").toURI()));
    schemaReader.setParameter(CommonSchemaConstants.PARAM_TYPENAME, Value.of("TestTyp"));
    schemaReader.setParameter(CSVSchemaReader.PARAM_PROPERTY, Value.of(props));
    schemaReader.setParameter(CSVSchemaReader.PARAM_PROPERTYTYPE, Value.of("java.lang.Integer,java.lang.String,java.lang.Float,java.lang.Float,java.lang.String"));
    schemaReader.setParameter(CSVSchemaReader.PARAM_SEPARATOR, Value.of(";"));
    schemaReader.setParameter(CSVSchemaReader.PARAM_QUOTE, null);
    schemaReader.setParameter(CSVSchemaReader.PARAM_ESCAPE, null);
    schemaReader.setParameter(CSVSchemaReader.PARAM_DECIMAL, Value.of(","));
    IOReport report = schemaReader.execute(new LogProgressIndicator());
    assertTrue(report.isSuccess());
    Schema schema = schemaReader.getSchema();
    assertEquals(1, schema.getMappingRelevantTypes().size());
    TypeDefinition type = schema.getMappingRelevantTypes().iterator().next();
    assertTrue(type.getName().getLocalPart().equals("TestTyp"));
    Iterator<? extends ChildDefinition<?>> it = type.getChildren().iterator();
    while (it.hasNext()) {
        assertTrue(props.contains(it.next().getName().getLocalPart()));
    }
}
Also used : DefaultInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier) CSVSchemaReader(eu.esdihumboldt.hale.io.csv.reader.internal.CSVSchemaReader) Schema(eu.esdihumboldt.hale.common.schema.model.Schema) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport) LogProgressIndicator(eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition) Test(org.junit.Test)

Example 23 with LogProgressIndicator

use of eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator in project hale by halestudio.

the class CSVSchemaReaderTest method failTest.

/**
 * Test for no given property names and only 2 (of 4) given property types
 * (if there are not given 0 or maximum, in this case 4, property types we
 * expect an error)
 *
 * @throws Exception the Exception thrown if the test fails
 */
public void failTest() throws Exception {
    CSVSchemaReader schemaReader = new CSVSchemaReader();
    schemaReader.setSource(new DefaultInputSupplier(getClass().getResource("/data/test1.csv").toURI()));
    schemaReader.setParameter(CommonSchemaConstants.PARAM_TYPENAME, Value.of("TestTyp"));
    schemaReader.setParameter(CSVSchemaReader.PARAM_PROPERTY, null);
    schemaReader.setParameter(CSVSchemaReader.PARAM_PROPERTYTYPE, Value.of("java.lang.String,java.lang.String"));
    schemaReader.setParameter(CSVSchemaReader.PARAM_SEPARATOR, null);
    schemaReader.setParameter(CSVSchemaReader.PARAM_QUOTE, null);
    schemaReader.setParameter(CSVSchemaReader.PARAM_ESCAPE, null);
    IOReport report = schemaReader.execute(new LogProgressIndicator());
    assertFalse(report.getErrors().isEmpty());
    assertFalse(report.isSuccess());
}
Also used : DefaultInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier) CSVSchemaReader(eu.esdihumboldt.hale.io.csv.reader.internal.CSVSchemaReader) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport) LogProgressIndicator(eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator)

Example 24 with LogProgressIndicator

use of eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator in project hale by halestudio.

the class CSVSchemaReaderTest method failTest2.

/**
 * Test for no given type name. So we expect the reporter not to be
 * successful.
 *
 * @throws Exception the Exception thrown if the test fails
 */
@Test
public void failTest2() throws Exception {
    CSVSchemaReader schemaReader2 = new CSVSchemaReader();
    schemaReader2.setSource(new DefaultInputSupplier(getClass().getResource("/data/test1.csv").toURI()));
    schemaReader2.setParameter(CommonSchemaConstants.PARAM_TYPENAME, null);
    IOReport report = schemaReader2.execute(new LogProgressIndicator());
    assertFalse(report.isSuccess());
}
Also used : DefaultInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier) CSVSchemaReader(eu.esdihumboldt.hale.io.csv.reader.internal.CSVSchemaReader) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport) LogProgressIndicator(eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator) Test(org.junit.Test)

Example 25 with LogProgressIndicator

use of eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator in project hale by halestudio.

the class ActionProjectFile method executeProvider.

private <P extends IOProvider> void executeProvider(P provider, IOAdvisor<P> advisor) throws Exception {
    IOReporter reporter = provider.createReporter();
    ATransaction trans = log.begin(reporter.getTaskName());
    try {
        // use advisor to configure provider
        advisor.prepareProvider(provider);
        advisor.updateConfiguration(provider);
        // execute
        IOReport report = provider.execute(new LogProgressIndicator());
        // handle results
        if (report.isSuccess()) {
            advisor.handleResults(provider);
        } else {
            // TODO propagate report errors somehow?
            throw new IOException("Project file action was not successful");
        }
    } finally {
        trans.end();
    }
}
Also used : IOReporter(eu.esdihumboldt.hale.common.core.io.report.IOReporter) ATransaction(de.fhg.igd.slf4jplus.ATransaction) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport) IOException(java.io.IOException) LogProgressIndicator(eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator)

Aggregations

LogProgressIndicator (eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator)26 IOReport (eu.esdihumboldt.hale.common.core.io.report.IOReport)25 DefaultInputSupplier (eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier)11 Schema (eu.esdihumboldt.hale.common.schema.model.Schema)9 FileIOSupplier (eu.esdihumboldt.hale.common.core.io.supplier.FileIOSupplier)8 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)7 CSVSchemaReader (eu.esdihumboldt.hale.io.csv.reader.internal.CSVSchemaReader)7 File (java.io.File)5 Test (org.junit.Test)5 NoStreamInputSupplier (eu.esdihumboldt.hale.common.core.io.supplier.NoStreamInputSupplier)4 MsSqlURIBuilder (eu.esdihumboldt.hale.io.jdbc.mssql.MsSqlURIBuilder)4 PathUpdate (eu.esdihumboldt.hale.common.core.io.PathUpdate)2 DefaultSchemaSpace (eu.esdihumboldt.hale.common.schema.model.impl.DefaultSchemaSpace)2 JDBCSchemaReader (eu.esdihumboldt.hale.io.jdbc.JDBCSchemaReader)2 SpatiaLiteSchemaReader (eu.esdihumboldt.hale.io.jdbc.spatialite.reader.internal.SpatiaLiteSchemaReader)2 IOException (java.io.IOException)2 ATransaction (de.fhg.igd.slf4jplus.ATransaction)1 AlignmentReader (eu.esdihumboldt.hale.common.align.io.AlignmentReader)1 JaxbAlignmentReader (eu.esdihumboldt.hale.common.align.io.impl.JaxbAlignmentReader)1 Alignment (eu.esdihumboldt.hale.common.align.model.Alignment)1