Search in sources :

Example 1 with DataStore

use of eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.SourceDataStoresPropertyType.DataStore in project hale by halestudio.

the class AppSchemaFileWriterTest method writeAlignment.

private void writeAlignment(File targetFile, String contentType) throws IOException, IOProviderConfigurationException {
    AbstractAppSchemaConfigurator alignWriter = new AppSchemaMappingFileWriter();
    prepareProvider(alignWriter, project, tempDir.toURI());
    alignWriter.setAlignment(alignment);
    alignWriter.setSourceSchema(sourceSchemaSpace);
    alignWriter.setTargetSchema(targetSchemaSpace);
    alignWriter.setTarget(new FileIOSupplier(targetFile));
    DataStore dataStoreParam = createDataStoreParam();
    alignWriter.setParameter(AppSchemaIO.PARAM_DATASTORE, new ComplexValue(dataStoreParam));
    alignWriter.setContentType(HalePlatform.getContentTypeManager().getContentType(contentType));
    IOReport report = alignWriter.execute(new LogProgressIndicator());
    assertNotNull(report);
    assertTrue(report.isSuccess());
}
Also used : ComplexValue(eu.esdihumboldt.hale.common.core.io.impl.ComplexValue) DataStore(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.SourceDataStoresPropertyType.DataStore) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport) FileIOSupplier(eu.esdihumboldt.hale.common.core.io.supplier.FileIOSupplier) LogProgressIndicator(eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator)

Example 2 with DataStore

use of eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.SourceDataStoresPropertyType.DataStore in project hale by halestudio.

the class AbstractAppSchemaConfigurator method generateMapping.

/**
 * Uses a fresh {@link AppSchemaMappingGenerator} instance to generates the
 * mapping configuration based on the current provider's configuration
 * parameters.
 *
 * @param reporter the status reporter
 * @throws IOProviderConfigurationException if something is wrong with the
 *             provider configuration
 * @throws IOException if an error occurs loading the mapping template file
 */
public void generateMapping(IOReporter reporter) throws IOProviderConfigurationException, IOException {
    if (getAlignment() == null) {
        throw new IOProviderConfigurationException("No alignment was provided.");
    }
    if (getTargetSchema() == null) {
        throw new IOProviderConfigurationException("No target schema was provided.");
    }
    if (getTarget() == null) {
        throw new IOProviderConfigurationException("No target was provided.");
    }
    DataStore dataStoreParam = getDataStoreParameter();
    FeatureChaining featureChainingParam = getFeatureChainingParameter();
    // resolve property entity definitions here, could't do it on project
    // loading
    resolvePropertyTypes(featureChainingParam, getTargetSchema(), SchemaSpaceID.TARGET);
    WorkspaceConfiguration workspaceConfParam = getWorkspaceConfigurationParameter();
    generator = new AppSchemaMappingGenerator(getAlignment(), getTargetSchema(), dataStoreParam, featureChainingParam, workspaceConfParam);
    generator.generateMapping(reporter);
}
Also used : IOProviderConfigurationException(eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException) FeatureChaining(eu.esdihumboldt.hale.io.appschema.model.FeatureChaining) DataStore(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.SourceDataStoresPropertyType.DataStore) WorkspaceConfiguration(eu.esdihumboldt.hale.io.appschema.model.WorkspaceConfiguration)

Example 3 with DataStore

use of eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.SourceDataStoresPropertyType.DataStore in project hale by halestudio.

the class AppSchemaMappingGenerator method applyDataStoreConfig.

private void applyDataStoreConfig() {
    if (dataStore != null && dataStore.getParameters() != null) {
        DataStore targetDS = mappingWrapper.getDefaultDataStore();
        List<Parameter> inputParameters = dataStore.getParameters().getParameter();
        List<Parameter> targetParameters = targetDS.getParameters().getParameter();
        // update destination parameters
        for (Parameter inputParam : inputParameters) {
            boolean updated = false;
            for (Parameter targetParam : targetParameters) {
                if (inputParam.getName().equals(targetParam.getName())) {
                    targetParam.setValue(inputParam.getValue());
                    updated = true;
                    break;
                }
            }
            if (!updated) {
                // parameter was not already present: add it to the list
                targetParameters.add(inputParam);
            }
        }
    }
}
Also used : AppSchemaDataStore(eu.esdihumboldt.hale.io.geoserver.AppSchemaDataStore) DataStore(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.SourceDataStoresPropertyType.DataStore) Parameter(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.SourceDataStoresPropertyType.DataStore.Parameters.Parameter)

Example 4 with DataStore

use of eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.SourceDataStoresPropertyType.DataStore in project hale by halestudio.

the class AppSchemaMappingWrapper method cloneMapping.

static AppSchemaDataAccessType cloneMapping(AppSchemaDataAccessType mapping) {
    AppSchemaDataAccessType clone = new AppSchemaDataAccessType();
    initMapping(clone);
    clone.setCatalog(mapping.getCatalog());
    clone.getIncludedTypes().getInclude().addAll(mapping.getIncludedTypes().getInclude());
    for (Namespace ns : mapping.getNamespaces().getNamespace()) {
        clone.getNamespaces().getNamespace().add(cloneNamespace(ns));
    }
    for (DataStore ds : mapping.getSourceDataStores().getDataStore()) {
        clone.getSourceDataStores().getDataStore().add(cloneDataStore(ds));
    }
    clone.getTargetTypes().getFeatureType().getSchemaUri().addAll(mapping.getTargetTypes().getFeatureType().getSchemaUri());
    for (FeatureTypeMapping ftMapping : mapping.getTypeMappings().getFeatureTypeMapping()) {
        clone.getTypeMappings().getFeatureTypeMapping().add(cloneFeatureTypeMapping(ftMapping));
    }
    return clone;
}
Also used : AppSchemaDataAccessType(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AppSchemaDataAccessType) DataStore(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.SourceDataStoresPropertyType.DataStore) FeatureTypeMapping(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.TypeMappingsPropertyType.FeatureTypeMapping) Namespace(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.NamespacesPropertyType.Namespace)

Example 5 with DataStore

use of eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.SourceDataStoresPropertyType.DataStore in project hale by halestudio.

the class AppSchemaFileWriterTest method createDataStoreParam.

private DataStore createDataStoreParam() {
    DataStore dataStoreParam = new DataStore();
    dataStoreParam.setParameters(new Parameters());
    Parameter hostParam = new Parameter();
    hostParam.setName("host");
    hostParam.setValue("localhost");
    Parameter dbParam = new Parameter();
    dbParam.setName("database");
    dbParam.setValue("postgres");
    Parameter userParam = new Parameter();
    userParam.setName("user");
    userParam.setValue("postgres");
    Parameter passwdParam = new Parameter();
    passwdParam.setName("passwd");
    passwdParam.setValue("postgres");
    Parameter dbtypeParam = new Parameter();
    dbtypeParam.setName("dbtype");
    dbtypeParam.setValue("postgis");
    dataStoreParam.getParameters().getParameter().addAll(Arrays.asList(hostParam, dbParam, dbtypeParam, userParam, passwdParam));
    return dataStoreParam;
}
Also used : Parameters(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.SourceDataStoresPropertyType.DataStore.Parameters) DataStore(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.SourceDataStoresPropertyType.DataStore) Parameter(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.SourceDataStoresPropertyType.DataStore.Parameters.Parameter)

Aggregations

DataStore (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.SourceDataStoresPropertyType.DataStore)10 Parameters (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.SourceDataStoresPropertyType.DataStore.Parameters)5 Parameter (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.SourceDataStoresPropertyType.DataStore.Parameters.Parameter)5 ComplexValue (eu.esdihumboldt.hale.common.core.io.impl.ComplexValue)2 FeatureTypeMapping (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.TypeMappingsPropertyType.FeatureTypeMapping)2 IOProviderConfigurationException (eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException)1 LogProgressIndicator (eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator)1 IOReport (eu.esdihumboldt.hale.common.core.io.report.IOReport)1 FileIOSupplier (eu.esdihumboldt.hale.common.core.io.supplier.FileIOSupplier)1 AppSchemaDataAccessType (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AppSchemaDataAccessType)1 Namespace (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.NamespacesPropertyType.Namespace)1 FeatureChaining (eu.esdihumboldt.hale.io.appschema.model.FeatureChaining)1 WorkspaceConfiguration (eu.esdihumboldt.hale.io.appschema.model.WorkspaceConfiguration)1 AppSchemaDataStore (eu.esdihumboldt.hale.io.geoserver.AppSchemaDataStore)1 HashSet (java.util.HashSet)1 Element (org.w3c.dom.Element)1 NodeList (org.w3c.dom.NodeList)1