} else { boolean unique = !indexInfo.getBoolean("NON_UNIQUE"); index = new Index(typeName, indexName, unique, columnName); indexes.put(indexName, index);
String escape = getNameEscape(); sql.append("CREATE "); if (index.isUnique()) { sql.append("UNIQUE "); sql.append("."); sql.append(escape).append(index.getIndexName()).append(escape); sql.append(" ON "); if (databaseSchema != null) { sql.append("."); sql.append(escape).append(index.getTypeName()).append(escape).append("("); for (String attribute : index.getAttributes()) { sql.append(escape).append(attribute).append(escape).append(", ");
Index stringIndex = new Index(ft1TypeName, indexName, false, aname("stringProperty")); dataStore.createIndex(stringIndex); assertEquals(initialSize + 1, indexes.size()); for (Index index : indexes) { assertEquals(ft1TypeName, index.getTypeName()); if (index.getIndexName().equals(indexName)) { List<String> attributes = index.getAttributes(); assertEquals(1, attributes.size()); assertEquals(aname("stringProperty"), attributes.get(0)); assertFalse(index.isUnique()); assertEquals(initialSize, indexes.size()); for (Index index : indexes) { assertEquals(ft1TypeName, index.getTypeName()); if (index.getIndexName().equals(indexName)) { fail("the index has not been removed");
private SimpleFeatureStore getTargetFeatureStore( SimpleFeatureType sourceSchema, DataStore targetStore, String coverage) throws IOException { // do we have to create it? List<String> existingTypeNames = Arrays.asList(targetStore.getTypeNames()); if (!existingTypeNames.contains(coverage)) { synchronized (coverage) { existingTypeNames = Arrays.asList(targetStore.getTypeNames()); if (!existingTypeNames.contains(coverage)) { final SimpleFeatureType schema = buildTargetSchema(sourceSchema); targetStore.createSchema(schema); // create indexes if we can if (targetStore instanceof JDBCDataStore) { ((JDBCDataStore) targetStore) .createIndex( new Index( schema.getTypeName(), schema.getTypeName() + "_loc_idx", true, "location", CoverageSlicesCatalog.IMAGE_INDEX_ATTR)); } } } } // TODO: handle Oracle casing issue? return (SimpleFeatureStore) targetStore.getFeatureSource(coverage); }
new Index( ft1TypeName, indexName, assertEquals(initialSize + 1, indexes.size()); for (Index index : indexes) { assertEquals(ft1TypeName, index.getTypeName()); if (index.getIndexName().equals(indexName)) { List<String> attributes = index.getAttributes(); assertEquals(2, attributes.size()); assertEquals(aname("stringProperty"), attributes.get(0)); assertEquals(initialSize, indexes.size()); for (Index index : indexes) { assertEquals(ft1TypeName, index.getTypeName()); if (index.getIndexName().equals(indexName)) { fail("the index has not been removed");
private void initialize(Map<String, Object> manualParameters) throws DaoException { try { PostGISVersionChecker versionChecker = new PostGISVersionChecker(); versionChecker.verifyVersion(manualParameters); store = (JDBCDataStore)DataStoreFinder.getDataStore(manualParameters); if (needsToBeInitialized()){ // needs to be initialized LOG.info("Initializing spatial database tables"); try { SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.setName(SPATIAL_DB_NAME); builder.add(ITEM_ID_FIELD_NAME, Integer.class); builder.add(LAYER_FIELD_NAME, String.class); builder.add(REF_SYS_FIELD_NAME, String.class); builder.add(GEOM_FIELD_NAME, Geometry.class); SimpleFeatureType featureType = builder.buildFeatureType(); store.createSchema(featureType); // note: gist index is created automatically above Index regIndex = new Index(SPATIAL_DB_NAME, "rs_layer_type", true, ITEM_ID_FIELD_NAME,LAYER_FIELD_NAME,REF_SYS_FIELD_NAME); Index itemIdIndex = new Index(SPATIAL_DB_NAME, "geometries_item_id", false, ITEM_ID_FIELD_NAME); store.createIndex(itemIdIndex); }catch(Exception e){ throw new DaoException(e); } }else{ LOG.info("Spatial database tables have already been initialized"); } }catch(Exception e){ throw new DaoException(e); } }
private void initialize(Map<String, Object> manualParameters) throws DaoException { try { PostGISVersionChecker versionChecker = new PostGISVersionChecker(); versionChecker.verifyVersion(manualParameters); store = (JDBCDataStore)DataStoreFinder.getDataStore(manualParameters); if (needsToBeInitialized()){ // needs to be initialized LOG.info("Initializing spatial database tables"); try { SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.setName(SPATIAL_DB_NAME); builder.add(ITEM_ID_FIELD_NAME, Integer.class); builder.add(LAYER_FIELD_NAME, String.class); builder.add(REF_SYS_FIELD_NAME, String.class); builder.add(GEOM_FIELD_NAME, Geometry.class); SimpleFeatureType featureType = builder.buildFeatureType(); store.createSchema(featureType); // note: gist index is created automatically above Index regIndex = new Index(SPATIAL_DB_NAME, "rs_layer_type", true, ITEM_ID_FIELD_NAME,LAYER_FIELD_NAME,REF_SYS_FIELD_NAME); Index itemIdIndex = new Index(SPATIAL_DB_NAME, "geometries_item_id", false, ITEM_ID_FIELD_NAME); store.createIndex(itemIdIndex); }catch(Exception e){ throw new DaoException(e); } }else{ LOG.info("Spatial database tables have already been initialized"); } }catch(Exception e){ throw new DaoException(e); } }