@Override protected void runInternal(GeogigCLI cli) throws InvalidParameterException, CommandFailedException, IOException { Repository repo = cli.getGeogig().getRepository(); Envelope envelope = SpatialOps.parseNonReferencedBBOX(bbox); Index index = repo.command(UpdateIndexOp.class)// .setTreeRefSpec(treeRefSpec)// .setAttributeName(attribute)// .setExtraAttributes(extraAttributes)// .setOverwrite(overwrite)// .setAdd(add)// .setIndexHistory(indexHistory)// .setBounds(envelope)// .setProgressListener(cli.getProgressListener())// .call(); if (cli.getProgressListener().isCanceled()) { cli.getConsole().println("Index update cancelled."); } else { cli.getConsole().println( "Index updated successfully: " + index.indexTreeId().toString().substring(0, 8)); } } }
private Index updateIndex(String treeName, @Nullable String... extraAttributes) { List<String> extraAtts = null; if (extraAttributes != null) { extraAtts = Lists.newArrayList(extraAttributes); } Index index = geogig.command(UpdateIndexOp.class)// .setOverwrite(true)// .setTreeRefSpec(treeName)// .setExtraAttributes(extraAtts)// .setBounds(new Envelope(-180, 180, -90, 90))// .call(); return index; } }
.setTreeRefSpec(treeRefSpec)// .setAttributeName(geometryAttributeName)// .setExtraAttributes(extraAttributes)// .setIndexHistory(indexHistory)// .setAdd(add)// .setOverwrite(overwrite)// .setBounds(bounds)// .call();
@Test public void testUpdateIndexAddSameAttribute() { createIndex("x", "y"); exception.expect(IllegalStateException.class); exception.expectMessage("Nothing to update..."); geogig.command(UpdateIndexOp.class)// .setTreeRefSpec(worldPointsLayer.getName())// .setExtraAttributes(Lists.newArrayList("x"))// .setAdd(true)// .call(); }
@Test public void testUpdateNoExistingIndex() { exception.expect(IllegalArgumentException.class); exception.expectMessage("A matching index could not be found."); geogig.command(UpdateIndexOp.class)// .setTreeRefSpec(worldPointsLayer.getName())// .setExtraAttributes(Lists.newArrayList("y"))// .call(); }
@Test public void testUpdateIndexWrongTreeName() { exception.expect(IllegalArgumentException.class); exception.expectMessage("Can't find feature tree 'nonexistent'"); geogig.command(UpdateIndexOp.class)// .setTreeRefSpec("nonexistent")// .call(); }
@Test public void testUpdateNoMatchingIndex() { indexdb.createIndexInfo(worldPointsLayer.getName(), "x", IndexType.QUADTREE, null); exception.expect(IllegalArgumentException.class); exception.expectMessage("A matching index could not be found."); geogig.command(UpdateIndexOp.class)// .setTreeRefSpec(worldPointsLayer.getName())// .setAttributeName("y")// .call(); }
.setTreeRefSpec(worldPointsLayer.getName())// .setBounds(newBounds)// .call();
@Test public void testUpdateIndexNoTreeName() { exception.expect(IllegalArgumentException.class); exception.expectMessage("Tree ref spec not provided."); geogig.command(UpdateIndexOp.class).call(); }
Index index = command.setAdd(true) .setExtraAttributes(indexAttributes) .setTreeRefSpec(treeRefSpec) .setIndexHistory(true).call(); return Optional.of(index.info().getId());
@Test public void testUpdateNoExistingIndex() { exception.expect(IllegalStateException.class); exception.expectMessage("A matching index could not be found."); geogig.command(UpdateIndexOp.class)// .setTreeRefSpec(worldPointsLayer.getName())// .setExtraAttributes(Lists.newArrayList("y"))// .call(); }
@Test public void testUpdateIndexWrongTreeName() { exception.expect(IllegalArgumentException.class); exception.expectMessage("Can't find feature tree 'nonexistent'"); geogig.command(UpdateIndexOp.class)// .setTreeRefSpec("nonexistent")// .call(); }
@Test public void testUpdateNoMatchingIndex() { indexdb.createIndexInfo(worldPointsLayer.getName(), "x", IndexType.QUADTREE, null); exception.expect(IllegalStateException.class); exception.expectMessage("A matching index could not be found."); geogig.command(UpdateIndexOp.class)// .setTreeRefSpec(worldPointsLayer.getName())// .setAttributeName("y")// .call(); }
.setTreeRefSpec(worldPointsLayer.getName())// .setBounds(newBounds)// .call();
@Test public void testUpdateIndexNoTreeName() { exception.expect(IllegalArgumentException.class); exception.expectMessage("Tree ref spec not provided."); geogig.command(UpdateIndexOp.class).call(); }
private Index updateIndex(String treeName, @Nullable String... extraAttributes) { List<String> extraAtts = null; if (extraAttributes != null) { extraAtts = Lists.newArrayList(extraAttributes); } Index index = geogig.command(UpdateIndexOp.class)// .setOverwrite(true)// .setTreeRefSpec(treeName)// .setExtraAttributes(extraAtts)// .setBounds(new Envelope(-180, 180, -90, 90))// .call(); return index; } }
try { index = repo.command(UpdateIndexOp.class)// .setTreeRefSpec(treeRefSpec)// .setAttributeName(attribute)// .setExtraAttributes(extraAttributes)// .setOverwrite(overwrite)// .setAdd(add)// .setIndexHistory(indexHistory)// .setBounds(envelope)// .setProgressListener(cli.getProgressListener())// .call(); } catch (IllegalStateException e) {
@Test public void testUpdateIndexAddSameAttribute() { createIndex("x", "y"); exception.expect(IllegalArgumentException.class); exception.expectMessage("Nothing to update..."); geogig.command(UpdateIndexOp.class)// .setTreeRefSpec(worldPointsLayer.getName())// .setExtraAttributes(Lists.newArrayList("x"))// .setAdd(true)// .call(); }
@Test public void testUpdateIndexAttributesNoFlagSpecified() { createIndex("x"); exception.expect(IllegalArgumentException.class); exception.expectMessage( "Extra attributes already exist on index, specify add or overwrite to update."); geogig.command(UpdateIndexOp.class)// .setTreeRefSpec(worldPointsLayer.getName())// .setExtraAttributes(Lists.newArrayList("y"))// .call(); }
@Test public void testUpdateIndexDoNothing() { createIndex("x"); exception.expect(IllegalStateException.class); exception.expectMessage("Nothing to update..."); geogig.command(UpdateIndexOp.class)// .setTreeRefSpec(worldPointsLayer.getName())// .call(); }