@Test public void testRenameStack() throws Exception { StackId fromStackId = stackId; final List<Double> fromZValues = dao.getZValues(fromStackId); StackId toStackId = new StackId(fromStackId.getOwner(), fromStackId.getProject(), "renamedStackA"); StackMetaData toStackMetaData = dao.getStackMetaData(toStackId); Assert.assertNull("toStack should not exist before rename", toStackMetaData); dao.renameStack(fromStackId, toStackId); toStackMetaData = dao.getStackMetaData(toStackId); Assert.assertNotNull("toStack should exist after rename", toStackMetaData); StackMetaData fromStackMetaData = dao.getStackMetaData(fromStackId); Assert.assertNull("fromStack should not exist after rename", fromStackMetaData); List<Double> toZValues = dao.getZValues(toStackId); Assert.assertArrayEquals("z values do not match after rename", fromZValues.toArray(), toZValues.toArray()); fromStackId = toStackId; fromStackMetaData = toStackMetaData; fromStackMetaData = dao.ensureIndexesAndDeriveStats(fromStackMetaData); final StackStats fromStats = fromStackMetaData.getStats(); toStackId = new StackId(fromStackId.getOwner(), fromStackId.getProject(), "renamedStackB"); toStackMetaData = dao.getStackMetaData(toStackId); Assert.assertNull("toStack should not exist before rename", toStackMetaData); dao.renameStack(fromStackId, toStackId); toStackMetaData = dao.getStackMetaData(toStackId); Assert.assertNotNull("toStack should exist after rename", toStackMetaData); fromStackMetaData = dao.getStackMetaData(fromStackId); Assert.assertNull("fromStack should not exist after rename", fromStackMetaData); toZValues = dao.getZValues(toStackId); Assert.assertArrayEquals("z values do not match after rename", fromZValues.toArray(), toZValues.toArray()); final StackStats toStats = toStackMetaData.getStats(); Assert.assertEquals("incorrect stats after rename", fromStats.toJson(), toStats.toJson()); }
public void renameStack(final StackId fromStackId, final StackId toStackId) throws IllegalArgumentException, ObjectNotFoundException { MongoUtil.validateRequiredParameter("fromStackId", fromStackId); MongoUtil.validateRequiredParameter("toStackId", toStackId); final StackMetaData fromStackMetaData = getStackMetaData(fromStackId); if (fromStackMetaData == null) { throw new ObjectNotFoundException(fromStackId + " does not exist"); } if (fromStackMetaData.isReadOnly() || fromStackMetaData.isOffline()) { throw new IllegalArgumentException(fromStackId + " cannot be modified because it is " + fromStackMetaData.getState() + "."); } StackMetaData toStackMetaData = getStackMetaData(toStackId); if (toStackMetaData != null) { throw new IllegalArgumentException(toStackId + " already exists"); } MongoUtil.renameCollection(renderDatabase, fromStackId.getSectionCollectionName(), toStackId.getSectionCollectionName()); MongoUtil.renameCollection(renderDatabase, fromStackId.getTransformCollectionName(), toStackId.getTransformCollectionName()); MongoUtil.renameCollection(renderDatabase, fromStackId.getTileCollectionName(), toStackId.getTileCollectionName()); toStackMetaData = StackMetaData.buildDerivedMetaData(toStackId, fromStackMetaData); final MongoCollection<Document> stackMetaDataCollection = getStackMetaDataCollection(); final Document query = getStackIdQuery(fromStackId); final Document stackMetaDataObject = Document.parse(toStackMetaData.toJson()); final UpdateResult result = stackMetaDataCollection.replaceOne(query, stackMetaDataObject, MongoUtil.UPSERT_OPTION); LOG.debug("renameStack: ran {}.{},({}), upsertedId is {}", MongoUtil.fullName(stackMetaDataCollection), MongoUtil.action(result), query.toJson(), result.getUpsertedId()); }
RenderDao { public void renameStack(final StackId fromStackId, final StackId toStackId) throws IllegalArgumentException, ObjectNotFoundException { MongoUtil.validateRequiredParameter("fromStackId", fromStackId); MongoUtil.validateRequiredParameter("toStackId", toStackId); final StackMetaData fromStackMetaData = getStackMetaData(fromStackId); if (fromStackMetaData == null) { throw new ObjectNotFoundException(fromStackId + " does not exist"); } if (fromStackMetaData.isReadOnly() || fromStackMetaData.isOffline()) { throw new IllegalArgumentException(fromStackId + " cannot be modified because it is " + fromStackMetaData.getState() + "."); } StackMetaData toStackMetaData = getStackMetaData(toStackId); if (toStackMetaData != null) { throw new IllegalArgumentException(toStackId + " already exists"); } MongoUtil.renameCollection(renderDatabase, fromStackId.getSectionCollectionName(), toStackId.getSectionCollectionName()); MongoUtil.renameCollection(renderDatabase, fromStackId.getTransformCollectionName(), toStackId.getTransformCollectionName()); MongoUtil.renameCollection(renderDatabase, fromStackId.getTileCollectionName(), toStackId.getTileCollectionName()); toStackMetaData = StackMetaData.buildDerivedMetaData(toStackId, fromStackMetaData); final MongoCollection<Document> stackMetaDataCollection = getStackMetaDataCollection(); final Document query = getStackIdQuery(fromStackId); final Document stackMetaDataObject = Document.parse(toStackMetaData.toJson()); final UpdateResult result = stackMetaDataCollection.replaceOne(query, stackMetaDataObject, MongoUtil.UPSERT_OPTION); LOG.debug("renameStack: ran {}.{},({}), upsertedId is {}", MongoUtil.fullName(stackMetaDataCollection), MongoUtil.action(result), query.toJson(), result.getUpsertedId()); } }
RenderDao { public void renameStack(final StackId fromStackId, final StackId toStackId) throws IllegalArgumentException, ObjectNotFoundException { MongoUtil.validateRequiredParameter("fromStackId", fromStackId); MongoUtil.validateRequiredParameter("toStackId", toStackId); final StackMetaData fromStackMetaData = getStackMetaData(fromStackId); if (fromStackMetaData == null) { throw new ObjectNotFoundException(fromStackId + " does not exist"); } if (fromStackMetaData.isReadOnly() || fromStackMetaData.isOffline()) { throw new IllegalArgumentException(fromStackId + " cannot be modified because it is " + fromStackMetaData.getState() + "."); } StackMetaData toStackMetaData = getStackMetaData(toStackId); if (toStackMetaData != null) { throw new IllegalArgumentException(toStackId + " already exists"); } MongoUtil.renameCollection(renderDatabase, fromStackId.getSectionCollectionName(), toStackId.getSectionCollectionName()); MongoUtil.renameCollection(renderDatabase, fromStackId.getTransformCollectionName(), toStackId.getTransformCollectionName()); MongoUtil.renameCollection(renderDatabase, fromStackId.getTileCollectionName(), toStackId.getTileCollectionName()); toStackMetaData = StackMetaData.buildDerivedMetaData(toStackId, fromStackMetaData); final MongoCollection<Document> stackMetaDataCollection = getStackMetaDataCollection(); final Document query = getStackIdQuery(fromStackId); final Document stackMetaDataObject = Document.parse(toStackMetaData.toJson()); final UpdateResult result = stackMetaDataCollection.replaceOne(query, stackMetaDataObject, MongoUtil.UPSERT_OPTION); LOG.debug("renameStack: ran {}.{},({}), upsertedId is {}", MongoUtil.fullName(stackMetaDataCollection), MongoUtil.action(result), query.toJson(), result.getUpsertedId()); } RenderDao(final MongoClient client); }
RenderDao { public void renameStack(final StackId fromStackId, final StackId toStackId) throws IllegalArgumentException, ObjectNotFoundException { MongoUtil.validateRequiredParameter("fromStackId", fromStackId); MongoUtil.validateRequiredParameter("toStackId", toStackId); final StackMetaData fromStackMetaData = getStackMetaData(fromStackId); if (fromStackMetaData == null) { throw new ObjectNotFoundException(fromStackId + " does not exist"); } if (fromStackMetaData.isReadOnly() || fromStackMetaData.isOffline()) { throw new IllegalArgumentException(fromStackId + " cannot be modified because it is " + fromStackMetaData.getState() + "."); } StackMetaData toStackMetaData = getStackMetaData(toStackId); if (toStackMetaData != null) { throw new IllegalArgumentException(toStackId + " already exists"); } MongoUtil.renameCollection(renderDatabase, fromStackId.getSectionCollectionName(), toStackId.getSectionCollectionName()); MongoUtil.renameCollection(renderDatabase, fromStackId.getTransformCollectionName(), toStackId.getTransformCollectionName()); MongoUtil.renameCollection(renderDatabase, fromStackId.getTileCollectionName(), toStackId.getTileCollectionName()); toStackMetaData = StackMetaData.buildDerivedMetaData(toStackId, fromStackMetaData); final MongoCollection<Document> stackMetaDataCollection = getStackMetaDataCollection(); final Document query = getStackIdQuery(fromStackId); final Document stackMetaDataObject = Document.parse(toStackMetaData.toJson()); final UpdateResult result = stackMetaDataCollection.replaceOne(query, stackMetaDataObject, MongoUtil.UPSERT_OPTION); LOG.debug("renameStack: ran {}.{},({}), upsertedId is {}", MongoUtil.fullName(stackMetaDataCollection), MongoUtil.action(result), query.toJson(), result.getUpsertedId()); } RenderDao(final MongoClient client); static RenderDao build(); RenderParameters getParameters(final StackId stackId,
                                          final String groupId,
                                          final Double x,
                                          final Double y,
                                          final Double z,
                                          final Integer width,
                                          final Integer height,
                                          final Double scale); RenderParameters getParameters(final StackId stackId,
                                          final Double z,
                                          final Double scale); long getTileCount(final StackId stackId,
                             final Double x,
                             final Double y,
                             final Double z,
                             final Integer width,
                             final Integer height); TileSpec getTileSpec(final StackId stackId,
                                final String tileId,
                                final boolean resolveTransformReferences); List<TileSpec> getTileSpecs(final StackId stackId,
                                       final Double x,
                                       final Double y,
                                       final Double z); List<TileSpec> getTileSpecs(final StackId stackId,
                                       final List<String> tileIds); void writeCoordinatesWithTileIds(final StackId stackId,
                                            final Double z,
                                            final List<TileCoordinates> worldCoordinatesList,
                                            final OutputStream outputStream); List<TileSpec> getTileSpecs(final StackId stackId,
                                       final Double z); ResolvedTileSpecCollection getResolvedTiles(final StackId stackId,
                                                       final Double z); ResolvedTileSpecCollection getResolvedTiles(final StackId stackId,
                                                       final Double minZ,
                                                       final Double maxZ,
                                                       final String groupId,
                                                       final Double minX,
                                                       final Double maxX,
                                                       final Double minY,
                                                       final Double maxY); void saveResolvedTiles(final StackId stackId,
                                  final ResolvedTileSpecCollection resolvedTileSpecs); TransformSpec getTransformSpec(final StackId stackId,
                                          final String transformId); List<Double> getZValues(final StackId stackId); List<Double> getZValues(final StackId stackId,
                                   final Double minZ,
                                   final Double maxZ); Double getZForSection(final StackId stackId,
                                 final String sectionId); void updateZForSection(final StackId stackId,
                                  final String sectionId,
                                  final Double z); void updateZForTiles(final StackId stackId,
                                final Double z,
                                final List<String> tileIds); List<SectionData> getSectionData(final StackId stackId,
                                            final Double minZ,
                                            final Double maxZ); List<String> getOwners(); List<String> getProjects(final String owner); List<StackMetaData> getStackMetaDataList(final String owner,
                                                    final String project); StackMetaData getStackMetaData(final StackId stackId); void saveStackMetaData(final StackMetaData stackMetaData); StackMetaData ensureIndexesAndDeriveStats(final StackMetaData stackMetaData); void removeStack(final StackId stackId,
                            final boolean includeMetaData); void removeTilesWithSectionId(final StackId stackId,
                                         final String sectionId); void removeTilesWithZ(final StackId stackId,
                                 final Double z); void removeTile(final StackId stackId,
                           final String tileId); Bounds getLayerBounds(final StackId stackId,
                                 final Double z); List<SectionData> getSectionDataForZ(final StackId stackId,
                                                final Double z); List<TileBounds> getTileBoundsForZ(final StackId stackId,
                                              final Double z); List<TileBounds> getTileBoundsForSection(final StackId stackId,
                                                    final String sectionId); void cloneStack(final StackId fromStackId,
                           final StackId toStackId,
                           final List<Double> zValues,
                           final Boolean skipTransforms); void renameStack(final StackId fromStackId,
                            final StackId toStackId); void writeLayoutFileData(final StackMetaData stackMetaData,
                                    final String stackRequestUri,
                                    final Double minZ,
                                    final Double maxZ,
                                    TileSpecLayout.Format format,
                                    final OutputStream outputStream); void writeTileIds(final StackId stackId,
                             final OutputStream outputStream); }
RenderDao { public void renameStack(final StackId fromStackId, final StackId toStackId) throws IllegalArgumentException, ObjectNotFoundException { MongoUtil.validateRequiredParameter("fromStackId", fromStackId); MongoUtil.validateRequiredParameter("toStackId", toStackId); final StackMetaData fromStackMetaData = getStackMetaData(fromStackId); if (fromStackMetaData == null) { throw new ObjectNotFoundException(fromStackId + " does not exist"); } if (fromStackMetaData.isReadOnly() || fromStackMetaData.isOffline()) { throw new IllegalArgumentException(fromStackId + " cannot be modified because it is " + fromStackMetaData.getState() + "."); } StackMetaData toStackMetaData = getStackMetaData(toStackId); if (toStackMetaData != null) { throw new IllegalArgumentException(toStackId + " already exists"); } MongoUtil.renameCollection(renderDatabase, fromStackId.getSectionCollectionName(), toStackId.getSectionCollectionName()); MongoUtil.renameCollection(renderDatabase, fromStackId.getTransformCollectionName(), toStackId.getTransformCollectionName()); MongoUtil.renameCollection(renderDatabase, fromStackId.getTileCollectionName(), toStackId.getTileCollectionName()); toStackMetaData = StackMetaData.buildDerivedMetaData(toStackId, fromStackMetaData); final MongoCollection<Document> stackMetaDataCollection = getStackMetaDataCollection(); final Document query = getStackIdQuery(fromStackId); final Document stackMetaDataObject = Document.parse(toStackMetaData.toJson()); final UpdateResult result = stackMetaDataCollection.replaceOne(query, stackMetaDataObject, MongoUtil.UPSERT_OPTION); LOG.debug("renameStack: ran {}.{},({}), upsertedId is {}", MongoUtil.fullName(stackMetaDataCollection), MongoUtil.action(result), query.toJson(), result.getUpsertedId()); } RenderDao(final MongoClient client); static RenderDao build(); RenderParameters getParameters(final StackId stackId,
                                          final String groupId,
                                          final Double x,
                                          final Double y,
                                          final Double z,
                                          final Integer width,
                                          final Integer height,
                                          final Double scale); RenderParameters getParameters(final StackId stackId,
                                          final Double z,
                                          final Double scale); long getTileCount(final StackId stackId,
                             final Double x,
                             final Double y,
                             final Double z,
                             final Integer width,
                             final Integer height); TileSpec getTileSpec(final StackId stackId,
                                final String tileId,
                                final boolean resolveTransformReferences); List<TileSpec> getTileSpecs(final StackId stackId,
                                       final Double x,
                                       final Double y,
                                       final Double z); List<TileSpec> getTileSpecs(final StackId stackId,
                                       final List<String> tileIds); void writeCoordinatesWithTileIds(final StackId stackId,
                                            final Double z,
                                            final List<TileCoordinates> worldCoordinatesList,
                                            final OutputStream outputStream); List<TileSpec> getTileSpecs(final StackId stackId,
                                       final Double z); ResolvedTileSpecCollection getResolvedTiles(final StackId stackId,
                                                       final Double z); ResolvedTileSpecCollection getResolvedTiles(final StackId stackId,
                                                       final Double minZ,
                                                       final Double maxZ,
                                                       final String groupId,
                                                       final Double minX,
                                                       final Double maxX,
                                                       final Double minY,
                                                       final Double maxY); void saveResolvedTiles(final StackId stackId,
                                  final ResolvedTileSpecCollection resolvedTileSpecs); TransformSpec getTransformSpec(final StackId stackId,
                                          final String transformId); List<Double> getZValues(final StackId stackId); List<Double> getZValues(final StackId stackId,
                                   final Double minZ,
                                   final Double maxZ); Double getZForSection(final StackId stackId,
                                 final String sectionId); void updateZForSection(final StackId stackId,
                                  final String sectionId,
                                  final Double z); void updateZForTiles(final StackId stackId,
                                final Double z,
                                final List<String> tileIds); List<SectionData> getSectionData(final StackId stackId,
                                            final Double minZ,
                                            final Double maxZ); List<String> getOwners(); List<String> getProjects(final String owner); List<StackMetaData> getStackMetaDataList(final String owner,
                                                    final String project); StackMetaData getStackMetaData(final StackId stackId); void saveStackMetaData(final StackMetaData stackMetaData); StackMetaData ensureIndexesAndDeriveStats(final StackMetaData stackMetaData); void removeStack(final StackId stackId,
                            final boolean includeMetaData); void removeTilesWithSectionId(final StackId stackId,
                                         final String sectionId); void removeTilesWithZ(final StackId stackId,
                                 final Double z); void removeTile(final StackId stackId,
                           final String tileId); Bounds getLayerBounds(final StackId stackId,
                                 final Double z); List<SectionData> getSectionDataForZ(final StackId stackId,
                                                final Double z); List<TileBounds> getTileBoundsForZ(final StackId stackId,
                                              final Double z); List<TileBounds> getTileBoundsForSection(final StackId stackId,
                                                    final String sectionId); void cloneStack(final StackId fromStackId,
                           final StackId toStackId,
                           final List<Double> zValues,
                           final Boolean skipTransforms); void renameStack(final StackId fromStackId,
                            final StackId toStackId); void writeLayoutFileData(final StackMetaData stackMetaData,
                                    final String stackRequestUri,
                                    final Double minZ,
                                    final Double maxZ,
                                    TileSpecLayout.Format format,
                                    final OutputStream outputStream); void writeTileIds(final StackId stackId,
                             final OutputStream outputStream); static final String RENDER_DB_NAME; static final String STACK_META_DATA_COLLECTION_NAME; }