Search in sources :

Example 6 with DefaultIOReporter

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

the class AppSchemaIsolatedWorkspacesMappingTest method testBothIsolated.

/**
 * Isolated attribute must be true, names must match those specified in the
 * workspace configuration, unique mapping names must be generated.
 *
 * @throws IOException
 */
@Test
public void testBothIsolated() throws IOException {
    workspaceConf.getWorkspaces().forEach(ws -> ws.setIsolated(true));
    AppSchemaMappingGenerator generator = new AppSchemaMappingGenerator(alignment, targetSchemaSpace, null, featureChainingConf, workspaceConf);
    IOReporter reporter = new DefaultIOReporter(targetSchemaSpace.getSchemas().iterator().next(), "Generate App-Schema Mapping", AppSchemaIO.CONTENT_TYPE_MAPPING, false);
    generator.generateMapping(reporter);
    assertEquals(STATIONS_WS_RENAMED, generator.getMainNamespace().name());
    assertTrue((boolean) generator.getMainNamespace().getAttribute(Namespace.ISOLATED));
    assertEquals(STATIONS_WS_RENAMED, generator.getMainWorkspace().name());
    assertTrue((boolean) generator.getMainWorkspace().getAttribute(Namespace.ISOLATED));
    boolean measurementsNsFound = false;
    for (Namespace ns : generator.getSecondaryNamespaces()) {
        if (MEASUREMENTS_NS_URI.equals(ns.getAttribute(Namespace.URI))) {
            measurementsNsFound = true;
            assertEquals(MEASUREMENTS_WS_RENAMED, ns.name());
            assertTrue((boolean) ns.getAttribute(Namespace.ISOLATED));
            assertEquals(MEASUREMENTS_WS_RENAMED, generator.getWorkspace(ns).name());
            assertTrue((boolean) generator.getWorkspace(ns).getAttribute(Namespace.ISOLATED));
        }
    }
    assertTrue(measurementsNsFound);
    List<FeatureTypeMapping> typeMappings = generator.getGeneratedMapping().getAppSchemaMapping().getTypeMappings().getFeatureTypeMapping();
    assertEquals(2, typeMappings.size());
    Set<String> mappingNames = new HashSet<String>();
    for (FeatureTypeMapping typeMapping : typeMappings) {
        assertFalse(Strings.isNullOrEmpty(typeMapping.getMappingName()));
        mappingNames.add(typeMapping.getMappingName());
    }
    assertEquals(2, mappingNames.size());
}
Also used : DefaultIOReporter(eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter) IOReporter(eu.esdihumboldt.hale.common.core.io.report.IOReporter) DefaultIOReporter(eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter) FeatureTypeMapping(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.TypeMappingsPropertyType.FeatureTypeMapping) Namespace(eu.esdihumboldt.hale.io.geoserver.Namespace) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 7 with DefaultIOReporter

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

the class AppSchemaIsolatedWorkspacesMappingTest method testNonIsolatedRenamed.

/**
 * Isolated attribute must be false, names must match those specified in the
 * workspace configuration, unique mapping names must not be generated.
 *
 * @throws IOException
 */
@Test
public void testNonIsolatedRenamed() throws IOException {
    AppSchemaMappingGenerator generator = new AppSchemaMappingGenerator(alignment, targetSchemaSpace, null, featureChainingConf, workspaceConf);
    IOReporter reporter = new DefaultIOReporter(targetSchemaSpace.getSchemas().iterator().next(), "Generate App-Schema Mapping", AppSchemaIO.CONTENT_TYPE_MAPPING, false);
    generator.generateMapping(reporter);
    assertEquals(STATIONS_WS_RENAMED, generator.getMainNamespace().name());
    assertFalse((boolean) generator.getMainNamespace().getAttribute(Namespace.ISOLATED));
    assertEquals(STATIONS_WS_RENAMED, generator.getMainWorkspace().name());
    assertFalse((boolean) generator.getMainWorkspace().getAttribute(Namespace.ISOLATED));
    boolean measurementsNsFound = false;
    for (Namespace ns : generator.getSecondaryNamespaces()) {
        if (MEASUREMENTS_NS_URI.equals(ns.getAttribute(Namespace.URI))) {
            measurementsNsFound = true;
            assertEquals(MEASUREMENTS_WS_RENAMED, ns.name());
            assertFalse((boolean) ns.getAttribute(Namespace.ISOLATED));
            assertEquals(MEASUREMENTS_WS_RENAMED, generator.getWorkspace(ns).name());
            assertFalse((boolean) generator.getWorkspace(ns).getAttribute(Namespace.ISOLATED));
        }
    }
    assertTrue(measurementsNsFound);
    List<FeatureTypeMapping> typeMappings = generator.getGeneratedMapping().getAppSchemaMapping().getTypeMappings().getFeatureTypeMapping();
    assertEquals(2, typeMappings.size());
    for (FeatureTypeMapping typeMapping : typeMappings) {
        assertTrue(Strings.isNullOrEmpty(typeMapping.getMappingName()));
    }
}
Also used : DefaultIOReporter(eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter) IOReporter(eu.esdihumboldt.hale.common.core.io.report.IOReporter) DefaultIOReporter(eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter) FeatureTypeMapping(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.TypeMappingsPropertyType.FeatureTypeMapping) Namespace(eu.esdihumboldt.hale.io.geoserver.Namespace) Test(org.junit.Test)

Example 8 with DefaultIOReporter

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

the class AppSchemaIsolatedWorkspacesMappingTest method testStationsIsolated.

/**
 * Isolated attribute must be true for the stations ws and false for the
 * measurements ws, names must match those specified in the workspace
 * configuration, unique mapping names must be generated only for the
 * stations ws.
 *
 * @throws IOException
 */
@Test
public void testStationsIsolated() throws IOException {
    workspaceConf.getWorkspace(STATIONS_NS_URI).setIsolated(true);
    AppSchemaMappingGenerator generator = new AppSchemaMappingGenerator(alignment, targetSchemaSpace, null, featureChainingConf, workspaceConf);
    IOReporter reporter = new DefaultIOReporter(targetSchemaSpace.getSchemas().iterator().next(), "Generate App-Schema Mapping", AppSchemaIO.CONTENT_TYPE_MAPPING, false);
    generator.generateMapping(reporter);
    assertEquals(STATIONS_WS_RENAMED, generator.getMainNamespace().name());
    assertTrue((boolean) generator.getMainNamespace().getAttribute(Namespace.ISOLATED));
    assertEquals(STATIONS_WS_RENAMED, generator.getMainWorkspace().name());
    assertTrue((boolean) generator.getMainWorkspace().getAttribute(Namespace.ISOLATED));
    boolean measurementsNsFound = false;
    for (Namespace ns : generator.getSecondaryNamespaces()) {
        if (MEASUREMENTS_NS_URI.equals(ns.getAttribute(Namespace.URI))) {
            measurementsNsFound = true;
            assertEquals(MEASUREMENTS_WS_RENAMED, ns.name());
            assertFalse((boolean) ns.getAttribute(Namespace.ISOLATED));
            assertEquals(MEASUREMENTS_WS_RENAMED, generator.getWorkspace(ns).name());
            assertFalse((boolean) generator.getWorkspace(ns).getAttribute(Namespace.ISOLATED));
        }
    }
    assertTrue(measurementsNsFound);
    List<FeatureTypeMapping> typeMappings = generator.getGeneratedMapping().getAppSchemaMapping().getTypeMappings().getFeatureTypeMapping();
    assertEquals(2, typeMappings.size());
    boolean stationsFtFound = false, measurementsFtFound = false;
    Set<String> mappingNames = new HashSet<String>();
    for (FeatureTypeMapping typeMapping : typeMappings) {
        if ((STATIONS_WS_RENAMED + ":Station_gml32").equals(typeMapping.getTargetElement())) {
            stationsFtFound = true;
            assertFalse(Strings.isNullOrEmpty(typeMapping.getMappingName()));
        }
        if ((MEASUREMENTS_WS_RENAMED + ":Measurement_gml32").equals(typeMapping.getTargetElement())) {
            measurementsFtFound = true;
            assertTrue(Strings.isNullOrEmpty(typeMapping.getMappingName()));
        }
        if (!Strings.isNullOrEmpty(typeMapping.getMappingName())) {
            mappingNames.add(typeMapping.getMappingName());
        }
    }
    assertEquals(1, mappingNames.size());
    assertTrue(stationsFtFound);
    assertTrue(measurementsFtFound);
}
Also used : DefaultIOReporter(eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter) IOReporter(eu.esdihumboldt.hale.common.core.io.report.IOReporter) DefaultIOReporter(eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter) FeatureTypeMapping(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.TypeMappingsPropertyType.FeatureTypeMapping) Namespace(eu.esdihumboldt.hale.io.geoserver.Namespace) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 9 with DefaultIOReporter

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

the class JaxbAlignmentIO method printCell.

/**
 * Print a cell to an output stream (intended for tests/debugging).
 *
 * @param cell the cell to print
 * @param out the output stream
 * @throws Exception if an error occurs trying to print the cell
 */
public static void printCell(MutableCell cell, OutputStream out) throws Exception {
    DefaultAlignment alignment = new DefaultAlignment();
    alignment.addCell(cell);
    IOReporter reporter = new DefaultIOReporter(new Locatable() {

        @Override
        public URI getLocation() {
            return null;
        }
    }, "Print cell", null, false);
    PathUpdate pathUpdate = new PathUpdate(null, null);
    AlignmentType at = convert(alignment, reporter, pathUpdate);
    CellType ct = (CellType) at.getCellOrModifier().get(0);
    JAXBContext jc = JAXBContext.newInstance(ALIGNMENT_CONTEXT, ObjectFactory.class.getClassLoader());
    Marshaller m = jc.createMarshaller();
    m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
    ObjectFactory of = new ObjectFactory();
    try {
        m.marshal(of.createCell(ct), out);
    } finally {
        out.flush();
        out.close();
    }
}
Also used : AlignmentType(eu.esdihumboldt.hale.common.align.io.impl.internal.generated.AlignmentType) DefaultIOReporter(eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter) IOReporter(eu.esdihumboldt.hale.common.core.io.report.IOReporter) Marshaller(javax.xml.bind.Marshaller) DefaultIOReporter(eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter) ObjectFactory(eu.esdihumboldt.hale.common.align.io.impl.internal.generated.ObjectFactory) CellType(eu.esdihumboldt.hale.common.align.io.impl.internal.generated.CellType) PathUpdate(eu.esdihumboldt.hale.common.core.io.PathUpdate) DefaultAlignment(eu.esdihumboldt.hale.common.align.model.impl.DefaultAlignment) JAXBContext(javax.xml.bind.JAXBContext) URI(java.net.URI) Locatable(eu.esdihumboldt.hale.common.core.io.supplier.Locatable)

Aggregations

DefaultIOReporter (eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter)9 IOReporter (eu.esdihumboldt.hale.common.core.io.report.IOReporter)6 FeatureTypeMapping (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.TypeMappingsPropertyType.FeatureTypeMapping)5 Locatable (eu.esdihumboldt.hale.common.core.io.supplier.Locatable)4 Namespace (eu.esdihumboldt.hale.io.geoserver.Namespace)4 URI (java.net.URI)4 Test (org.junit.Test)4 PathUpdate (eu.esdihumboldt.hale.common.core.io.PathUpdate)2 LocatableURI (eu.esdihumboldt.hale.common.core.io.supplier.LocatableURI)2 BasePathResolver (eu.esdihumboldt.hale.io.haleconnect.BasePathResolver)2 HashSet (java.util.HashSet)2 AlignmentType (eu.esdihumboldt.hale.common.align.io.impl.internal.generated.AlignmentType)1 CellType (eu.esdihumboldt.hale.common.align.io.impl.internal.generated.CellType)1 ObjectFactory (eu.esdihumboldt.hale.common.align.io.impl.internal.generated.ObjectFactory)1 Alignment (eu.esdihumboldt.hale.common.align.model.Alignment)1 DefaultAlignment (eu.esdihumboldt.hale.common.align.model.impl.DefaultAlignment)1 IOProviderConfigurationException (eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException)1 IOMessageImpl (eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl)1 DefaultInputSupplier (eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier)1 AppSchemaDataAccessType (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AppSchemaDataAccessType)1