Search in sources :

Example 1 with OsgiClassResolver

use of eu.esdihumboldt.hale.common.schema.model.constraint.factory.OsgiClassResolver in project hale by halestudio.

the class HaleSchemaReaderJson method execute.

@Override
protected IOReport execute(ProgressIndicator progress, IOReporter reporter) throws IOProviderConfigurationException, IOException {
    progress.begin("Load schema", ProgressIndicator.UNKNOWN);
    try (InputStream in = getSource().getInput();
        Reader reader = new InputStreamReader(in, getCharset())) {
        Iterable<Schema> schemas = new JsonToSchema(null, new OsgiClassResolver(), reporter).parseSchemas(reader);
        List<Schema> schemaList = StreamSupport.stream(schemas.spliterator(), false).collect(Collectors.toList());
        if (!schemaList.isEmpty()) {
            schema = HaleSchemaUtil.combineSchema(schemaList, reporter);
            reporter.setSuccess(true);
        } else {
            reporter.setSuccess(false);
            reporter.setSummary("No schema definition found");
        }
    } catch (Exception e) {
        reporter.error(new IOMessageImpl(e.getMessage(), e));
        reporter.setSuccess(false);
    } finally {
        progress.end();
    }
    return reporter;
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) Schema(eu.esdihumboldt.hale.common.schema.model.Schema) IOMessageImpl(eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) AbstractSchemaReader(eu.esdihumboldt.hale.common.schema.io.impl.AbstractSchemaReader) OsgiClassResolver(eu.esdihumboldt.hale.common.schema.model.constraint.factory.OsgiClassResolver) IOProviderConfigurationException(eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException) IOException(java.io.IOException)

Example 2 with OsgiClassResolver

use of eu.esdihumboldt.hale.common.schema.model.constraint.factory.OsgiClassResolver in project hale by halestudio.

the class AbstractCachedSchemaReader method loadFromCache.

@Override
protected Schema loadFromCache(Value cache, ProgressIndicator progress, IOReporter reporter) {
    Schema schema = null;
    progress.begin("Load schema from cached schema definition", ProgressIndicator.UNKNOWN);
    try {
        schema = XmlToSchema.parseSchema(cache.getDOMRepresentation(), new OsgiClassResolver(), reporter);
        reporter.setSuccess(true);
    } catch (Exception e) {
        reporter.error(new IOMessageImpl(e.getMessage(), e));
        reporter.setSuccess(false);
    } finally {
        progress.end();
    }
    return schema;
}
Also used : XmlToSchema(eu.esdihumboldt.hale.common.schema.persist.hsd.XmlToSchema) Schema(eu.esdihumboldt.hale.common.schema.model.Schema) IOMessageImpl(eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl) OsgiClassResolver(eu.esdihumboldt.hale.common.schema.model.constraint.factory.OsgiClassResolver)

Example 3 with OsgiClassResolver

use of eu.esdihumboldt.hale.common.schema.model.constraint.factory.OsgiClassResolver in project hale by halestudio.

the class HaleSchemaReader method execute.

@Override
protected IOReport execute(ProgressIndicator progress, IOReporter reporter) throws IOProviderConfigurationException, IOException {
    progress.begin("Load schema", ProgressIndicator.UNKNOWN);
    try (InputStream in = getSource().getInput();
        Reader reader = new InputStreamReader(in, getCharset())) {
        schema = XmlToSchema.parseSchema(reader, new OsgiClassResolver(), reporter);
        reporter.setSuccess(true);
    } catch (Exception e) {
        reporter.error(new IOMessageImpl(e.getMessage(), e));
        reporter.setSuccess(false);
    } finally {
        progress.end();
    }
    return reporter;
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) IOMessageImpl(eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl) AbstractSchemaReader(eu.esdihumboldt.hale.common.schema.io.impl.AbstractSchemaReader) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) OsgiClassResolver(eu.esdihumboldt.hale.common.schema.model.constraint.factory.OsgiClassResolver) IOProviderConfigurationException(eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException) IOException(java.io.IOException)

Aggregations

IOMessageImpl (eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl)3 OsgiClassResolver (eu.esdihumboldt.hale.common.schema.model.constraint.factory.OsgiClassResolver)3 IOProviderConfigurationException (eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException)2 AbstractSchemaReader (eu.esdihumboldt.hale.common.schema.io.impl.AbstractSchemaReader)2 Schema (eu.esdihumboldt.hale.common.schema.model.Schema)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 InputStreamReader (java.io.InputStreamReader)2 Reader (java.io.Reader)2 XmlToSchema (eu.esdihumboldt.hale.common.schema.persist.hsd.XmlToSchema)1