Search in sources :

Example 1 with DefaultIOReporter

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

the class HaleConnectProjectWriter method createReporter.

/**
 * @see IOProvider#createReporter()
 */
@Override
public IOReporter createReporter() {
    if (!(haleConnect instanceof BasePathResolver) || !HaleConnectUrnBuilder.isValidProjectUrn(getTarget().getLocation())) {
        return super.createReporter();
    }
    try {
        URI targetUri = getTarget().getLocation();
        Locatable prettifiedTarget = new LocatableURI(prettifyTarget(targetUri));
        return new DefaultIOReporter(prettifiedTarget, MessageFormat.format("{0} export", getTypeName()), getActionId(), true);
    } catch (Throwable t) {
        return super.createReporter();
    }
}
Also used : LocatableURI(eu.esdihumboldt.hale.common.core.io.supplier.LocatableURI) DefaultIOReporter(eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter) URI(java.net.URI) LocatableURI(eu.esdihumboldt.hale.common.core.io.supplier.LocatableURI) BasePathResolver(eu.esdihumboldt.hale.io.haleconnect.BasePathResolver) Locatable(eu.esdihumboldt.hale.common.core.io.supplier.Locatable)

Example 2 with DefaultIOReporter

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

the class AppSchemaIsolatedWorkspacesMappingTest method testNullWorkspaceConfiguration.

/**
 * Isolated attribute must be false, names must match the default ones,
 * unique mapping names must not be generated.
 *
 * @throws IOException
 */
@Test
public void testNullWorkspaceConfiguration() throws IOException {
    AppSchemaMappingGenerator generator = new AppSchemaMappingGenerator(alignment, targetSchemaSpace, null, featureChainingConf, null);
    IOReporter reporter = new DefaultIOReporter(targetSchemaSpace.getSchemas().iterator().next(), "Generate App-Schema Mapping", AppSchemaIO.CONTENT_TYPE_MAPPING, false);
    generator.generateMapping(reporter);
    assertEquals(STATIONS_WS_DEFAULT, generator.getMainNamespace().name());
    assertFalse((boolean) generator.getMainNamespace().getAttribute(Namespace.ISOLATED));
    assertEquals(STATIONS_WS_DEFAULT, 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_DEFAULT, ns.name());
            assertFalse((boolean) ns.getAttribute(Namespace.ISOLATED));
            assertEquals(MEASUREMENTS_WS_DEFAULT, 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 3 with DefaultIOReporter

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

the class WorkspaceConfigurationPage method updateWorkspaceTable.

private void updateWorkspaceTable() {
    AbstractAppSchemaConfigurator configurator = getWizard().getProvider();
    DefaultIOReporter reporter = new DefaultIOReporter(configurator.getTarget(), "Generate Temporary App-Schema Mapping", AppSchemaIO.CONTENT_TYPE_MAPPING, true);
    AppSchemaMappingGenerator generator;
    try {
        configurator.generateMapping(reporter);
        generator = configurator.getMappingGenerator();
        AppSchemaDataAccessType appSchemaMapping = generator.getGeneratedMapping().getAppSchemaMapping();
        List<FeatureTypeMapping> typeMappings = appSchemaMapping.getTypeMappings().getFeatureTypeMapping();
        for (FeatureTypeMapping typeMapping : typeMappings) {
            String[] workspaceAndType = typeMapping.getTargetElement().split(":");
            String workspaceName = workspaceAndType[0];
            String typeName = workspaceAndType[1];
            List<Namespace> namespaces = appSchemaMapping.getNamespaces().getNamespace();
            for (Namespace namespace : namespaces) {
                if (workspaceName.equals(namespace.getPrefix())) {
                    String uri = namespace.getUri();
                    if (workspaceConf.hasWorkspace(uri)) {
                        workspaceConf.getWorkspace(uri).getFeatureTypes().add(typeName);
                    } else {
                        WorkspaceMetadata workspace = new WorkspaceMetadata(workspaceName, uri);
                        workspace.getFeatureTypes().add(typeName);
                        workspaceConf.addWorkspace(workspace);
                    }
                }
            }
        }
        // remove workspaces that contain no features
        workspaceConf.getWorkspaces().forEach((ws) -> {
            if (ws.getFeatureTypes().isEmpty()) {
                workspaceConf.removeWorkspace(ws.getNamespaceUri());
            }
        });
        workspaceTableViewer.setInput(workspaceConf.getWorkspaces());
        reporter.setSuccess(true);
    } catch (Exception e) {
        reporter.error(new IOMessageImpl(e.getMessage(), e));
        reporter.setSuccess(false);
    }
}
Also used : DefaultIOReporter(eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter) WorkspaceMetadata(eu.esdihumboldt.hale.io.appschema.model.WorkspaceMetadata) IOMessageImpl(eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl) FeatureTypeMapping(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.TypeMappingsPropertyType.FeatureTypeMapping) AbstractAppSchemaConfigurator(eu.esdihumboldt.hale.io.appschema.writer.AbstractAppSchemaConfigurator) Namespace(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.NamespacesPropertyType.Namespace) AppSchemaDataAccessType(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AppSchemaDataAccessType) AppSchemaMappingGenerator(eu.esdihumboldt.hale.io.appschema.writer.AppSchemaMappingGenerator)

Example 4 with DefaultIOReporter

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

the class TestUtil method loadAlignment.

/**
 * Loads the specified alignment. Assumes that its base alignments don't
 * need a location update.
 *
 * @param location the URI specifying the location of the alignment
 * @param sourceTypes the source type index
 * @param targetTypes the target type index
 * @return the loaded alignment
 * @throws Exception if the alignment or other resources could not be loaded
 */
public static Alignment loadAlignment(final URI location, Schema sourceTypes, Schema targetTypes) throws Exception {
    DefaultInputSupplier input = new DefaultInputSupplier(location);
    IOReporter report = new DefaultIOReporter(new Locatable() {

        @Override
        public URI getLocation() {
            return location;
        }
    }, "Load alignment", AlignmentIO.ACTION_LOAD_ALIGNMENT, true);
    Alignment alignment;
    try {
        alignment = CastorAlignmentIO.load(input.getInput(), report, sourceTypes, targetTypes, new PathUpdate(null, null));
    } catch (Exception e) {
        alignment = JaxbAlignmentIO.load(input.getInput(), report, sourceTypes, targetTypes, new PathUpdate(null, null), null, null);
    }
    assertTrue("Errors are contained in the report", report.getErrors().isEmpty());
    return alignment;
}
Also used : DefaultIOReporter(eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter) IOReporter(eu.esdihumboldt.hale.common.core.io.report.IOReporter) Alignment(eu.esdihumboldt.hale.common.align.model.Alignment) DefaultInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier) DefaultIOReporter(eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter) PathUpdate(eu.esdihumboldt.hale.common.core.io.PathUpdate) URI(java.net.URI) IOProviderConfigurationException(eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException) BundleException(org.osgi.framework.BundleException) IOException(java.io.IOException) Locatable(eu.esdihumboldt.hale.common.core.io.supplier.Locatable)

Example 5 with DefaultIOReporter

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

the class HaleConnectProjectReader method createReporter.

/**
 * @see eu.esdihumboldt.hale.common.core.io.impl.AbstractImportProvider#createReporter()
 */
@Override
public IOReporter createReporter() {
    if (!(getSource() instanceof HaleConnectInputSupplier) || !HaleConnectUrnBuilder.isValidProjectUrn(getSource().getLocation())) {
        return super.createReporter();
    }
    try {
        BasePathResolver resolver = ((HaleConnectInputSupplier) getSource()).getBasePathResolver();
        URI sourceUri = getSource().getLocation();
        Owner owner = HaleConnectUrnBuilder.extractProjectOwner(sourceUri);
        String projectId = HaleConnectUrnBuilder.extractProjectId(sourceUri);
        String clientBasePath = resolver.getBasePath(HaleConnectServices.WEB_CLIENT);
        Locatable prettifiedTarget = new LocatableURI(HaleConnectUrnBuilder.buildClientAccessUrl(clientBasePath, owner, projectId));
        return new DefaultIOReporter(prettifiedTarget, MessageFormat.format("{0} import", getTypeName()), getActionId(), true);
    } catch (Throwable t) {
        return super.createReporter();
    }
}
Also used : Owner(eu.esdihumboldt.hale.io.haleconnect.Owner) LocatableURI(eu.esdihumboldt.hale.common.core.io.supplier.LocatableURI) DefaultIOReporter(eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter) HaleConnectInputSupplier(eu.esdihumboldt.hale.io.haleconnect.HaleConnectInputSupplier) URI(java.net.URI) LocatableURI(eu.esdihumboldt.hale.common.core.io.supplier.LocatableURI) BasePathResolver(eu.esdihumboldt.hale.io.haleconnect.BasePathResolver) 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