use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.
the class Project method readLayers.
protected void readLayers(final Project rootProject, final Resource resource) {
final Resource layerGroupResource = resource.newChildResource("rgLayerGroup.rgobject");
if (!layerGroupResource.exists()) {
Logs.error(this, "File not found: " + layerGroupResource);
} else {
final Resource oldResource = Resource.setBaseResource(resource);
try {
final Map<String, Object> properties = Json.toMap(layerGroupResource);
loadLayers(rootProject, properties);
} catch (final RuntimeException e) {
Logs.error(this, "Unable to read: " + layerGroupResource, e);
} finally {
Resource.setBaseResource(oldResource);
}
}
}
use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.
the class Project method readProperties.
protected void readProperties(final Resource resource) {
final Resource layerGroupResource = resource.newChildResource("rgLayerGroup.rgobject");
if (!layerGroupResource.exists()) {
Logs.error(this, "File not found: " + layerGroupResource);
} else {
final Resource oldResource = Resource.setBaseResource(resource);
try {
final Map<String, Object> properties = Json.toMap(layerGroupResource);
setProperties(properties);
} catch (final Throwable e) {
Logs.error(this, "Unable to read: " + layerGroupResource, e);
} finally {
Resource.setBaseResource(oldResource);
}
}
}
use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.
the class Project method readProject.
public void readProject(final Project rootProject, final Resource resource) {
this.resource = resource;
if (this.resource.exists()) {
String name;
try (final BaseCloseable booleanValueCloseable = eventsDisabled()) {
final RecordStoreConnectionRegistry oldRecordStoreConnections = RecordStoreConnectionRegistry.getForThread();
try {
final boolean readOnly = isReadOnly();
final Resource folderConnectionsDirectory = this.resource.newChildResource("Folder Connections");
this.folderConnections.clear(folderConnectionsDirectory, readOnly);
final Resource recordStoresDirectory = this.resource.newChildResource("Record Stores");
this.recordStores.clear(recordStoresDirectory, readOnly);
final Resource webServicesDirectory = this.resource.newChildResource("Web Services");
this.webServices.clear(webServicesDirectory, readOnly);
if (rootProject == null) {
RecordStoreConnectionRegistry.setForThread(this.recordStores);
} else {
final WebServiceConnectionRegistry rootWebServices = rootProject.getWebServices();
importConnections("Web Service", this, this.webServices, rootWebServices);
final RecordStoreConnectionRegistry rootRecordStores = rootProject.getRecordStores();
rootProject.importConnections("Record Store", this, this.recordStores, rootRecordStores);
final FolderConnectionRegistry rootFolderConnections = rootProject.getFolderConnections();
rootProject.importConnections("Folder Connection", this, this.folderConnections, rootFolderConnections);
}
final Resource layersDir = this.resource.newChildResource("Layers");
final boolean hasLayers = layersDir.exists();
if (hasLayers) {
readProperties(layersDir);
}
if (hasLayers) {
readLayers(rootProject, layersDir);
}
readBaseMapsLayers(rootProject, this.resource);
} finally {
RecordStoreConnectionRegistry.setForThread(oldRecordStoreConnections);
}
name = getName();
setName(null);
}
setName(name);
}
}
use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.
the class Project method saveAllSettingsAs.
public Path saveAllSettingsAs() {
final Resource resource = this.resource;
try {
this.resource = null;
final Path projectPath = getSaveAsDirectory();
if (projectPath != null) {
setName(Paths.getBaseName(projectPath));
saveAllSettings();
}
return projectPath;
} finally {
if (this.resource == null) {
this.resource = resource;
}
}
}
use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.
the class OracleJdbcClobFieldDefinition method setPreparedStatementValue.
@Override
public int setPreparedStatementValue(final PreparedStatement statement, final int parameterIndex, final Object value) throws SQLException {
if (value == null) {
final int sqlType = getSqlType();
statement.setNull(parameterIndex, sqlType);
} else {
if (value instanceof Clob) {
final Clob clob = (Clob) value;
statement.setClob(parameterIndex, clob);
} else {
Reader in;
if (value instanceof Resource) {
final Resource resource = (Resource) value;
in = resource.newBufferedReader();
} else if (value instanceof Clob) {
final Clob clob = (Clob) value;
in = clob.getCharacterStream();
} else if (value instanceof String) {
final String string = (String) value;
in = new StringReader(string);
} else if (value instanceof File) {
final File file = (File) value;
final PathResource resource = new PathResource(file);
in = resource.newBufferedReader();
} else {
throw new IllegalArgumentException("Not valid for a clob column");
}
statement.setCharacterStream(parameterIndex, in);
}
}
return parameterIndex + 1;
}
Aggregations