本文整理汇总了Java中org.geomajas.global.ExceptionCode.LAYER_MODEL_IO_EXCEPTION属性的典型用法代码示例。如果您正苦于以下问题:Java ExceptionCode.LAYER_MODEL_IO_EXCEPTION属性的具体用法?Java ExceptionCode.LAYER_MODEL_IO_EXCEPTION怎么用?Java ExceptionCode.LAYER_MODEL_IO_EXCEPTION使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.geomajas.global.ExceptionCode
的用法示例。
在下文中一共展示了ExceptionCode.LAYER_MODEL_IO_EXCEPTION属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: delete
@Override
@Transactional(rollbackFor = { Throwable.class })
public void delete(String featureId) throws LayerException {
SimpleFeatureSource source = getFeatureSource();
if (source instanceof SimpleFeatureStore) {
SimpleFeatureStore store = (SimpleFeatureStore) source;
Filter filter = filterService.createFidFilter(new String[] { featureId });
transactionSynchronization.synchTransaction(store);
try {
store.removeFeatures(filter);
if (log.isDebugEnabled()) {
log.debug("Deleted feature {} in {}", featureId, getFeatureSourceName());
}
} catch (IOException ioe) {
featureModelUsable = false;
throw new LayerException(ioe, ExceptionCode.LAYER_MODEL_IO_EXCEPTION);
}
} else {
log.error("Don't know how to delete from " + getFeatureSourceName() + ", class "
+ source.getClass().getName() + " does not implement SimpleFeatureStore");
throw new LayerException(ExceptionCode.DELETE_NOT_IMPLEMENTED, getFeatureSourceName(), source.getClass()
.getName());
}
}
示例2: create
@Override
@Transactional(rollbackFor = { Throwable.class })
public Object create(Object feature) throws LayerException {
SimpleFeatureSource source = getFeatureSource();
if (source instanceof SimpleFeatureStore) {
SimpleFeatureStore store = (SimpleFeatureStore) source;
DefaultFeatureCollection collection = new DefaultFeatureCollection();
collection.add((SimpleFeature) feature);
transactionSynchronization.synchTransaction(store);
try {
List<FeatureId> ids = store.addFeatures(collection);
// fetch it again to get the generated values !!!
if (ids.size() == 1) {
return read(ids.get(0).getID());
}
} catch (IOException ioe) {
featureModelUsable = false;
throw new LayerException(ioe, ExceptionCode.LAYER_MODEL_IO_EXCEPTION);
}
return feature;
} else {
log.error("Don't know how to create or update " + getFeatureSourceName() + ", class "
+ source.getClass().getName() + " does not implement SimpleFeatureStore");
throw new LayerException(ExceptionCode.CREATE_OR_UPDATE_NOT_IMPLEMENTED, getFeatureSourceName(), source
.getClass().getName());
}
}
示例3: update
/**
* Update an existing feature. Made package private for testing purposes.
*
* @param feature feature to update
* @throws LayerException oops
*/
void update(Object feature) throws LayerException {
SimpleFeatureSource source = getFeatureSource();
if (source instanceof SimpleFeatureStore) {
SimpleFeatureStore store = (SimpleFeatureStore) source;
String featureId = getFeatureModel().getId(feature);
Filter filter = filterService.createFidFilter(new String[] { featureId });
transactionSynchronization.synchTransaction(store);
List<Name> names = new ArrayList<Name>();
Map<String, Attribute> attrMap = getFeatureModel().getAttributes(feature);
List<Object> values = new ArrayList<Object>();
for (Map.Entry<String, Attribute> entry : attrMap.entrySet()) {
String name = entry.getKey();
names.add(store.getSchema().getDescriptor(name).getName());
values.add(entry.getValue().getValue());
}
try {
store.modifyFeatures(names.toArray(new Name[names.size()]), values.toArray(), filter);
store.modifyFeatures(store.getSchema().getGeometryDescriptor().getName(), getFeatureModel()
.getGeometry(feature), filter);
log.debug("Updated feature {} in {}", featureId, getFeatureSourceName());
} catch (IOException ioe) {
featureModelUsable = false;
throw new LayerException(ioe, ExceptionCode.LAYER_MODEL_IO_EXCEPTION);
}
} else {
log.error("Don't know how to create or update " + getFeatureSourceName() + ", class "
+ source.getClass().getName() + " does not implement SimpleFeatureStore");
throw new LayerException(ExceptionCode.CREATE_OR_UPDATE_NOT_IMPLEMENTED, getFeatureSourceName(), source
.getClass().getName());
}
}
示例4: renderMap
private byte[] renderMap(ClientMapInfo mapInfo) throws GeomajasException {
ByteArrayOutputStream imageStream = new ByteArrayOutputStream(1024 * 10);
try {
imageService.writeMap(imageStream, mapInfo);
recorder.record(CacheCategory.RASTER, "Rasterization success");
} catch (Exception ex) { // NOSONAR
recorder.record(CacheCategory.RASTER, "Rasterization failed");
log.error("Problem while rasterizing tile, no image will be returned.", ex);
throw new GeomajasException(ExceptionCode.LAYER_MODEL_IO_EXCEPTION, ex);
}
return imageStream.toByteArray();
}
示例5: initFeatures
/**
* Finish initializing the layer.
*
* @throws LayerException oops
*/
@PostConstruct
protected void initFeatures() throws LayerException {
if (null == layerInfo) {
return;
}
crs = geoService.getCrs2(layerInfo.getCrs());
setFeatureSourceName(layerInfo.getFeatureInfo().getDataSourceName());
try {
if (null == super.getDataStore()) {
Map<String, Object> params = new HashMap<String, Object>();
if (null != url) {
params.put(ShapefileDataStoreFactory.URLP.key, url);
}
if (null != dbtype) {
params.put(JDBCDataStoreFactory.DBTYPE.key, dbtype);
}
if (null != parameters) {
for (Parameter parameter : parameters) {
params.put(parameter.getName(), parameter.getValue());
}
}
if (null != dataSource) {
params.put(JDBCDataStoreFactory.DATASOURCE.key, dataSource);
// these are apparently required but not used
params.put(JDBCDataStoreFactory.DATABASE.key, "some_database");
params.put(JDBCDataStoreFactory.USER.key, "some_user");
params.put(JDBCDataStoreFactory.PASSWD.key, "some_password");
params.put(JDBCDataStoreFactory.HOST.key, "some host");
params.put(JDBCDataStoreFactory.PORT.key, "0");
}
DataStore store = DataStoreFactory.create(params);
super.setDataStore(store);
}
if (null == super.getDataStore()) {
return;
}
this.featureModel = new GeoToolsFeatureModel(super.getDataStore(), layerInfo.getFeatureInfo()
.getDataSourceName(), geoService.getSridFromCrs(layerInfo.getCrs()), converterService);
featureModel.setLayerInfo(layerInfo);
featureModelUsable = true;
} catch (IOException ioe) {
if (MAGIC_STRING_LIBRARY_MISSING.equals(ioe.getMessage())) {
throw new LayerException(ioe, ExceptionCode.LAYER_MODEL_IO_EXCEPTION, url);
} else {
featureModelUsable = false;
log.warn("The layer could not be correctly initialized: " + getId(), ioe);
}
} catch (LayerException le) {
featureModelUsable = false;
log.warn("The layer could not be correctly initialized: " + getId(), le);
} catch (RuntimeException e) {
featureModelUsable = false;
log.warn("The layer could not be correctly initialized: " + getId(), e);
}
}