use of com.revolsys.record.io.RecordStoreFactory in project com.revolsys.open by revolsys.
the class RecordStore method newRecordStore.
@SuppressWarnings("unchecked")
static <T extends RecordStore> T newRecordStore(final String url) {
final RecordStoreFactory factory = recordStoreFactory(url);
if (factory == null) {
throw new IllegalArgumentException("Record Store Factory not found for " + url);
} else {
final Map<String, Object> connectionProperties = new HashMap<>();
connectionProperties.put("url", url);
return (T) factory.newRecordStore(connectionProperties);
}
}
use of com.revolsys.record.io.RecordStoreFactory in project com.revolsys.open by revolsys.
the class RecordStore method newRecordStore.
/**
* Construct a new initialized record store.
* @param connectionProperties
* @return
*/
@SuppressWarnings("unchecked")
static <T extends RecordStore> T newRecordStore(final Map<String, ? extends Object> connectionProperties) {
final String url = (String) connectionProperties.get("url");
final RecordStoreFactory factory = recordStoreFactory(url);
if (factory == null) {
throw new IllegalArgumentException("Record Store Factory not found for " + url);
} else {
return (T) factory.newRecordStore(connectionProperties);
}
}
use of com.revolsys.record.io.RecordStoreFactory in project com.revolsys.open by revolsys.
the class RecordStore method recordStoreInterfaceClass.
static Class<?> recordStoreInterfaceClass(final Map<String, ? extends Object> connectionProperties) {
final String url = (String) connectionProperties.get("url");
final RecordStoreFactory factory = recordStoreFactory(url);
if (factory == null) {
throw new IllegalArgumentException("Data Source Factory not found for " + url);
} else {
return factory.getRecordStoreInterfaceClass(connectionProperties);
}
}
use of com.revolsys.record.io.RecordStoreFactory in project com.revolsys.open by revolsys.
the class RecordStoreConnectionForm method postSetFieldValues.
@Override
protected void postSetFieldValues(final Map<String, Object> newValues) {
String recordStoreType = (String) newValues.get("recordStoreType");
if (Property.hasValue(recordStoreType)) {
if (this.recordStoreTypes.contains(recordStoreType)) {
refreshUrlFromFieldValues(recordStoreType);
}
return;
}
final String url = (String) newValues.get("url");
if (Property.hasValue(url)) {
for (final RecordStoreFactory recordStoreFactory : this.recordStoreFactoryByName.values()) {
final Map<String, Object> urlFieldValues = recordStoreFactory.parseUrl(url);
if (!urlFieldValues.isEmpty()) {
Maps.retainIfNotEqual(urlFieldValues, newValues);
if (recordStoreFactory instanceof FileRecordStoreFactory) {
final FileRecordStoreFactory fileRecordStoreFactory = (FileRecordStoreFactory) recordStoreFactory;
final FileField fileField = getField("file");
if (fileRecordStoreFactory.isDirectory()) {
fileField.setFileSelectionMode(JFileChooser.FILES_ONLY);
} else {
fileField.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
}
}
setFieldValues(urlFieldValues);
return;
}
}
}
recordStoreType = getFieldValue("recordStoreType");
refreshUrlFromFieldValues(recordStoreType);
}
use of com.revolsys.record.io.RecordStoreFactory in project com.revolsys.open by revolsys.
the class RecordStoreConnectionForm method refreshUrlFromFieldValues.
private void refreshUrlFromFieldValues(final String recordStoreType) {
if (recordStoreType != null) {
final RecordStoreFactory databaseFactory = this.recordStoreFactoryByName.get(recordStoreType);
if (databaseFactory != null) {
final Map<String, Object> fieldValues = getFieldValues();
final String newUrl = databaseFactory.toUrl(fieldValues);
if (Property.hasValue(newUrl)) {
setFieldValue("url", newUrl);
return;
}
}
}
}
Aggregations