Search in sources :

Example 1 with RecordStoreFactory

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);
    }
}
Also used : HashMap(java.util.HashMap) RecordStoreFactory(com.revolsys.record.io.RecordStoreFactory)

Example 2 with RecordStoreFactory

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);
    }
}
Also used : RecordStoreFactory(com.revolsys.record.io.RecordStoreFactory)

Example 3 with RecordStoreFactory

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);
    }
}
Also used : RecordStoreFactory(com.revolsys.record.io.RecordStoreFactory)

Example 4 with RecordStoreFactory

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);
}
Also used : FileRecordStoreFactory(com.revolsys.record.io.FileRecordStoreFactory) RecordStoreFactory(com.revolsys.record.io.RecordStoreFactory) FileRecordStoreFactory(com.revolsys.record.io.FileRecordStoreFactory) FileField(com.revolsys.swing.field.FileField)

Example 5 with RecordStoreFactory

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;
            }
        }
    }
}
Also used : FileRecordStoreFactory(com.revolsys.record.io.FileRecordStoreFactory) RecordStoreFactory(com.revolsys.record.io.RecordStoreFactory)

Aggregations

RecordStoreFactory (com.revolsys.record.io.RecordStoreFactory)5 FileRecordStoreFactory (com.revolsys.record.io.FileRecordStoreFactory)2 FileField (com.revolsys.swing.field.FileField)1 HashMap (java.util.HashMap)1