* @return
* @throws IOException
*/
protected SimpleFeatureType testViewDefinition(VirtualTable virtualTable, boolean guessGeometrySrid) throws IOException {
// check out if the view can be used
JDBCDataStore ds = (JDBCDataStore) getCatalog().getDataStore(storeId).getDataStore(null);
String vtName = null;
try {
// use a highly random name
do {
vtName = UUID.randomUUID().toString();
} while (Arrays.asList(ds.getTypeNames()).contains(vtName));
// try adding the vt and see if that works
VirtualTable vt = new VirtualTable(vtName, virtualTable);
// hide the primary key definitions or we'll loose some columns
vt.setPrimaryKeyColumns(Collections.EMPTY_LIST);
vt.setEscapeSql(escapeSql);
ds.addVirtualTable(vt);
return guessFeatureType(ds, vt.getName(), guessGeometrySrid);
} finally {
if(vtName != null) {
ds.removeVirtualTable(name);
}
}
}