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;
}
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;
}
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();
}
}
}
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);
}
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;
}
Aggregations