@Test public void testCloneStack() throws Exception { final StackId toStackId = new StackId(stackId.getOwner(), stackId.getProject(), "clonedStack"); StackMetaData toStackMetaData = dao.getStackMetaData(toStackId); Assert.assertNull("stack should not exist before clone", toStackMetaData); List<Double> zValues = dao.getZValues(toStackId); Assert.assertEquals("no z values should exist before clone", 0, zValues.size()); StackMetaData fromStackMetaData = dao.getStackMetaData(stackId); fromStackMetaData = dao.ensureIndexesAndDeriveStats(fromStackMetaData); dao.cloneStack(stackId, toStackId, null, null); zValues = dao.getZValues(toStackId); Assert.assertEquals("invalid number of z values after clone", 2, zValues.size()); toStackMetaData = new StackMetaData(toStackId, fromStackMetaData.getCurrentVersion()); toStackMetaData = dao.ensureIndexesAndDeriveStats(toStackMetaData); final StackStats fromStats = fromStackMetaData.getStats(); Assert.assertNotNull("null fromStats", fromStats); final StackStats toStats = toStackMetaData.getStats(); Assert.assertNotNull("null toStats", toStats); Assert.assertEquals("cloned tile count does not match", fromStats.getTileCount(), toStats.getTileCount()); Assert.assertEquals("cloned transform count does not match", fromStats.getTransformCount(), toStats.getTransformCount()); final Double newZValue = 999.0; final TileSpec newTileSpec = new TileSpec(); newTileSpec.setTileId("new-tile-spec"); newTileSpec.setZ(newZValue); dao.saveTileSpec(stackId, newTileSpec); final StackId filteredStackId = new StackId(stackId.getOwner(), stackId.getProject(), "filteredStack"); final List<Double> filteredZValues = new ArrayList<>(); filteredZValues.add(newZValue); dao.cloneStack(stackId, filteredStackId, filteredZValues, null); zValues = dao.getZValues(filteredStackId); Assert.assertEquals("invalid number of z values after clone filter", 1, zValues.size()); Assert.assertEquals("invalid z value after clone filter", newZValue, zValues.get(0)); }
public void cloneStack(final StackId fromStackId, final StackId toStackId, final List<Double> zValues, final Boolean skipTransforms) throws IllegalArgumentException, IllegalStateException { MongoUtil.validateRequiredParameter("fromStackId", fromStackId); MongoUtil.validateRequiredParameter("toStackId", toStackId); if ((skipTransforms == null) || (! skipTransforms)) { final MongoCollection<Document> fromTransformCollection = getTransformCollection(fromStackId); final MongoCollection<Document> toTransformCollection = getTransformCollection(toStackId); cloneCollection(fromTransformCollection, toTransformCollection, new Document()); } final Document filterQuery = new Document(); if ((zValues != null) && (zValues.size() > 0)) { final BasicDBList list = new BasicDBList(); list.addAll(zValues); final Document zFilter = new Document(QueryOperators.IN, list); filterQuery.append("z", zFilter); } final MongoCollection<Document> fromTileCollection = getTileCollection(fromStackId); final MongoCollection<Document> toTileCollection = getTileCollection(toStackId); cloneCollection(fromTileCollection, toTileCollection, filterQuery); }
RenderDao { public void cloneStack(final StackId fromStackId, final StackId toStackId, final List<Double> zValues, final Boolean skipTransforms) throws IllegalArgumentException, IllegalStateException { MongoUtil.validateRequiredParameter("fromStackId", fromStackId); MongoUtil.validateRequiredParameter("toStackId", toStackId); if ((skipTransforms == null) || (! skipTransforms)) { final MongoCollection<Document> fromTransformCollection = getTransformCollection(fromStackId); final MongoCollection<Document> toTransformCollection = getTransformCollection(toStackId); cloneCollection(fromTransformCollection, toTransformCollection, new Document()); } final Document filterQuery = new Document(); if ((zValues != null) && (zValues.size() > 0)) { final BasicDBList list = new BasicDBList(); list.addAll(zValues); final Document zFilter = new Document(QueryOperators.IN, list); filterQuery.append("z", zFilter); } final MongoCollection<Document> fromTileCollection = getTileCollection(fromStackId); final MongoCollection<Document> toTileCollection = getTileCollection(toStackId); cloneCollection(fromTileCollection, toTileCollection, filterQuery); } }
RenderDao { public void cloneStack(final StackId fromStackId, final StackId toStackId, final List<Double> zValues, final Boolean skipTransforms) throws IllegalArgumentException, IllegalStateException { MongoUtil.validateRequiredParameter("fromStackId", fromStackId); MongoUtil.validateRequiredParameter("toStackId", toStackId); if ((skipTransforms == null) || (! skipTransforms)) { final MongoCollection<Document> fromTransformCollection = getTransformCollection(fromStackId); final MongoCollection<Document> toTransformCollection = getTransformCollection(toStackId); cloneCollection(fromTransformCollection, toTransformCollection, new Document()); } final Document filterQuery = new Document(); if ((zValues != null) && (zValues.size() > 0)) { final BasicDBList list = new BasicDBList(); list.addAll(zValues); final Document zFilter = new Document(QueryOperators.IN, list); filterQuery.append("z", zFilter); } final MongoCollection<Document> fromTileCollection = getTileCollection(fromStackId); final MongoCollection<Document> toTileCollection = getTileCollection(toStackId); cloneCollection(fromTileCollection, toTileCollection, filterQuery); } RenderDao(final MongoClient client); }
RenderDao { public void cloneStack(final StackId fromStackId, final StackId toStackId, final List<Double> zValues, final Boolean skipTransforms) throws IllegalArgumentException, IllegalStateException { MongoUtil.validateRequiredParameter("fromStackId", fromStackId); MongoUtil.validateRequiredParameter("toStackId", toStackId); if ((skipTransforms == null) || (! skipTransforms)) { final MongoCollection<Document> fromTransformCollection = getTransformCollection(fromStackId); final MongoCollection<Document> toTransformCollection = getTransformCollection(toStackId); cloneCollection(fromTransformCollection, toTransformCollection, new Document()); } final Document filterQuery = new Document(); if ((zValues != null) && (zValues.size() > 0)) { final BasicDBList list = new BasicDBList(); list.addAll(zValues); final Document zFilter = new Document(QueryOperators.IN, list); filterQuery.append("z", zFilter); } final MongoCollection<Document> fromTileCollection = getTileCollection(fromStackId); final MongoCollection<Document> toTileCollection = getTileCollection(toStackId); cloneCollection(fromTileCollection, toTileCollection, filterQuery); } 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 cloneStack(final StackId fromStackId, final StackId toStackId, final List<Double> zValues, final Boolean skipTransforms) throws IllegalArgumentException, IllegalStateException { MongoUtil.validateRequiredParameter("fromStackId", fromStackId); MongoUtil.validateRequiredParameter("toStackId", toStackId); if ((skipTransforms == null) || (! skipTransforms)) { final MongoCollection<Document> fromTransformCollection = getTransformCollection(fromStackId); final MongoCollection<Document> toTransformCollection = getTransformCollection(toStackId); cloneCollection(fromTransformCollection, toTransformCollection, new Document()); } final Document filterQuery = new Document(); if ((zValues != null) && (zValues.size() > 0)) { final BasicDBList list = new BasicDBList(); list.addAll(zValues); final Document zFilter = new Document(QueryOperators.IN, list); filterQuery.append("z", zFilter); } final MongoCollection<Document> fromTileCollection = getTileCollection(fromStackId); final MongoCollection<Document> toTileCollection = getTileCollection(toStackId); cloneCollection(fromTileCollection, toTileCollection, filterQuery); } 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; }