Search in sources :

Example 6 with DataStore

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

the class AppSchemaDataStoreConfigurationPage method updateConfiguration.

@Override
public boolean updateConfiguration(AbstractAppSchemaConfigurator provider) {
    if (!validateHost()) {
        updateMessage(Field.HOST);
        return false;
    }
    if (!validateDatabase()) {
        updateMessage(Field.DATABASE);
        return false;
    }
    if (!validateSchema()) {
        updateMessage(Field.SCHEMA);
        return false;
    }
    DataStore dataStoreParam = provider.getParameter(AppSchemaIO.PARAM_DATASTORE).as(DataStore.class);
    if (dataStoreParam == null) {
        dataStoreParam = new DataStore();
    }
    if (dataStoreParam.getParameters() == null) {
        dataStoreParam.setParameters(new Parameters());
    }
    String hostValue = host.getText();
    Parameter hostParam = new Parameter();
    hostParam.setName("host");
    hostParam.setValue(extractHost(hostValue));
    dataStoreParam.getParameters().getParameter().add(hostParam);
    Integer portValue = extractPort(hostValue);
    if (portValue != null) {
        Parameter portParam = new Parameter();
        portParam.setName("port");
        portParam.setValue(portValue.toString());
        dataStoreParam.getParameters().getParameter().add(portParam);
    }
    Parameter databaseParam = new Parameter();
    databaseParam.setName("database");
    databaseParam.setValue(database.getText());
    dataStoreParam.getParameters().getParameter().add(databaseParam);
    Parameter schemaParam = new Parameter();
    schemaParam.setName("schema");
    schemaParam.setValue(schema.getText());
    dataStoreParam.getParameters().getParameter().add(schemaParam);
    Parameter userParam = new Parameter();
    userParam.setName("user");
    userParam.setValue(user.getText());
    dataStoreParam.getParameters().getParameter().add(userParam);
    Parameter passwordParam = new Parameter();
    passwordParam.setName("passwd");
    passwordParam.setValue(password.getText());
    dataStoreParam.getParameters().getParameter().add(passwordParam);
    Parameter exposePKParam = new Parameter();
    exposePKParam.setName("Expose primary keys");
    exposePKParam.setValue(Boolean.toString(exposePK.getSelection()));
    dataStoreParam.getParameters().getParameter().add(exposePKParam);
    // TODO: only "postgis" dbtype is supported so far
    dataStoreParam.getParameters().getParameter().add(DBTYPE_PARAMETER);
    provider.setParameter(AppSchemaIO.PARAM_DATASTORE, new ComplexValue(dataStoreParam));
    return true;
}
Also used : ComplexValue(eu.esdihumboldt.hale.common.core.io.impl.ComplexValue) 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)

Example 7 with DataStore

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

the class DataStoreComplexType method fromDOM.

/**
 * @see eu.esdihumboldt.hale.common.core.io.ComplexValueType#fromDOM(org.w3c.dom.Element,
 *      java.lang.Object)
 */
@Override
public DataStore fromDOM(Element fragment, Void context) {
    DataStore dataStore = new DataStore();
    if (fragment != null) {
        Element idEl = getFirstElementByTagName(fragment, "id", APP_SCHEMA_NAMESPACE);
        if (idEl != null) {
            dataStore.setId(idEl.getTextContent());
        }
        NodeList paramElements = fragment.getElementsByTagNameNS(APP_SCHEMA_NAMESPACE, "Parameter");
        if (paramElements != null && paramElements.getLength() > 0) {
            dataStore.setParameters(new Parameters());
            for (int i = 0; i < paramElements.getLength(); i++) {
                Element paramEl = (Element) paramElements.item(i);
                Element paramNameEl = getFirstElementByTagName(paramEl, "name", APP_SCHEMA_NAMESPACE);
                Element paramValueEl = getFirstElementByTagName(paramEl, "value", APP_SCHEMA_NAMESPACE);
                if (paramNameEl != null && paramValueEl != null) {
                    Parameter param = new Parameter();
                    param.setName(paramNameEl.getTextContent());
                    param.setValue(paramValueEl.getTextContent());
                    dataStore.getParameters().getParameter().add(param);
                }
            }
        }
    }
    return dataStore;
}
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) Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList) Parameter(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.SourceDataStoresPropertyType.DataStore.Parameters.Parameter)

Example 8 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 purgeTypeMappings.

private void purgeTypeMappings(AppSchemaDataAccessType mapping, Set<FeatureTypeMapping> toBeRemoved) {
    Set<String> usedStores = new HashSet<String>();
    Iterator<FeatureTypeMapping> featureIt = mapping.getTypeMappings().getFeatureTypeMapping().iterator();
    while (featureIt.hasNext()) {
        FeatureTypeMapping ftMapping = featureIt.next();
        if (lookupTypeMapping(ftMapping, toBeRemoved) != null) {
            featureIt.remove();
        } else {
            usedStores.add(ftMapping.getSourceDataStore());
        }
    }
    // remove unnecessary DataStores
    Iterator<DataStore> storeIt = mapping.getSourceDataStores().getDataStore().iterator();
    while (storeIt.hasNext()) {
        if (!usedStores.contains(storeIt.next().getId())) {
            storeIt.remove();
        }
    }
}
Also used : 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) HashSet(java.util.HashSet)

Example 9 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 getDefaultDataStore.

/**
 * Return the configuration of the default datastore.
 *
 * <p>
 * An empty datastore configuration is created if none is available.
 * </p>
 *
 * @return the default datastore's configuration.
 */
public DataStore getDefaultDataStore() {
    List<DataStore> dataStores = appSchemaMapping.getSourceDataStores().getDataStore();
    if (dataStores.size() == 0) {
        DataStore defaultDS = new DataStore();
        defaultDS.setId(UUID.randomUUID().toString());
        defaultDS.setParameters(new Parameters());
        dataStores.add(defaultDS);
    }
    return dataStores.get(0);
}
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)

Example 10 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 cloneDataStore.

static DataStore cloneDataStore(DataStore ds) {
    DataStore clone = new DataStore();
    clone.setParameters(new Parameters());
    clone.setId(ds.getId());
    clone.setIdAttribute(ds.getIdAttribute());
    if (ds.getParameters() != null) {
        for (Parameter param : ds.getParameters().getParameter()) {
            Parameter paramClone = new Parameter();
            paramClone.setName(param.getName());
            paramClone.setValue(param.getValue());
            clone.getParameters().getParameter().add(paramClone);
        }
    }
    return clone;
}
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