Search in sources :

Example 1 with Schema

use of eu.esdihumboldt.hale.schemaprovider.Schema in project hale by halestudio.

the class UrlToAlignmentDigester method translate.

/**
 * Translates an {@link URL} into a HALE {@link Alignment}.
 *
 * @param source
 *            {@link URL} the source URL
 * @return {@link Alignment}
 * @throws TranslationException
 *             if anything goes wrong during the translation
 */
@Override
public HaleAlignment translate(URL source) throws TranslationException {
    if (source == null) {
        // $NON-NLS-1$
        throw new TranslationException("url is null");
    }
    Alignment al = new OmlRdfReader().read(source);
    ApacheSchemaProvider sp = new ApacheSchemaProvider();
    Schema s, t;
    try {
        URI suri = new URI(al.getSchema1().getLocation());
        // if (!suri.isAbsolute()) {
        // suri = source.toURI();
        // suri = new URI(suri.getScheme(), suri.getUserInfo(),
        // suri.getHost(), suri.getPort(),
        // al.getSchema1().getLocation(), null, null);
        // }
        s = sp.loadSchema(suri, null);
        t = sp.loadSchema(new URI(al.getSchema2().getLocation()), null);
    } catch (Exception e) {
        // $NON-NLS-1$
        throw new TranslationException("Error loading schemas", e);
    }
    return new HaleAlignment(al, s.getElements().values(), t.getElements().values());
}
Also used : HaleAlignment(com.onespatial.jrc.tns.oml_to_rif.HaleAlignment) Alignment(eu.esdihumboldt.commons.goml.align.Alignment) HaleAlignment(com.onespatial.jrc.tns.oml_to_rif.HaleAlignment) Schema(eu.esdihumboldt.hale.schemaprovider.Schema) ApacheSchemaProvider(eu.esdihumboldt.hale.schemaprovider.provider.ApacheSchemaProvider) TranslationException(com.onespatial.jrc.tns.oml_to_rif.api.TranslationException) OmlRdfReader(eu.esdihumboldt.commons.goml.oml.io.OmlRdfReader) URI(java.net.URI) URISyntaxException(java.net.URISyntaxException) TranslationException(com.onespatial.jrc.tns.oml_to_rif.api.TranslationException)

Aggregations

HaleAlignment (com.onespatial.jrc.tns.oml_to_rif.HaleAlignment)1 TranslationException (com.onespatial.jrc.tns.oml_to_rif.api.TranslationException)1 Alignment (eu.esdihumboldt.commons.goml.align.Alignment)1 OmlRdfReader (eu.esdihumboldt.commons.goml.oml.io.OmlRdfReader)1 Schema (eu.esdihumboldt.hale.schemaprovider.Schema)1 ApacheSchemaProvider (eu.esdihumboldt.hale.schemaprovider.provider.ApacheSchemaProvider)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1