Search in sources :

Example 6 with WorkingTree

use of org.locationtech.geogig.repository.WorkingTree in project GeoGig by boundlessgeo.

the class StatusOp method _call.

@Override
protected StatusSummary _call() {
    WorkingTree workTree = workingTree();
    StagingArea index = index();
    StatusSummary summary = new StatusSummary();
    summary.countStaged = index.countStaged(null).count();
    summary.countUnstaged = workTree.countUnstaged(null).count();
    summary.countConflicted = index.countConflicted(null);
    if (summary.countStaged > 0) {
        summary.staged = command(DiffIndex.class).setReportTrees(true);
    }
    if (summary.countUnstaged > 0) {
        summary.unstaged = command(DiffWorkTree.class).setReportTrees(true);
    }
    if (summary.countConflicted > 0) {
        summary.conflicts = command(ConflictsReadOp.class);
    }
    return summary;
}
Also used : WorkingTree(org.locationtech.geogig.repository.WorkingTree) ConflictsReadOp(org.locationtech.geogig.api.plumbing.merge.ConflictsReadOp) StagingArea(org.locationtech.geogig.repository.StagingArea)

Example 7 with WorkingTree

use of org.locationtech.geogig.repository.WorkingTree in project GeoGig by boundlessgeo.

the class RemoteRepositoryTestCase method delete.

protected boolean delete(GeoGIG geogig, Feature f) throws Exception {
    final WorkingTree workTree = geogig.getRepository().workingTree();
    Name name = f.getType().getName();
    String localPart = name.getLocalPart();
    String id = f.getIdentifier().getID();
    boolean existed = workTree.delete(localPart, id);
    return existed;
}
Also used : WorkingTree(org.locationtech.geogig.repository.WorkingTree) Name(org.opengis.feature.type.Name)

Example 8 with WorkingTree

use of org.locationtech.geogig.repository.WorkingTree in project GeoGig by boundlessgeo.

the class Add method runInternal.

/**
     * Executes the add command using the provided options.
     * 
     * @param cli
     * @see org.locationtech.geogig.cli.AbstractCommand#runInternal(org.locationtech.geogig.cli.GeogigCLI)
     */
@Override
public void runInternal(GeogigCLI cli) throws IOException {
    final GeoGIG geogig = cli.getGeogig();
    final ConsoleReader console = cli.getConsole();
    String pathFilter = null;
    if (patterns.size() == 1) {
        pathFilter = patterns.get(0);
    } else if (patterns.size() > 1) {
        throw new InvalidParameterException("Only a single path is supported so far");
    }
    List<Conflict> conflicts = geogig.command(ConflictsReadOp.class).call();
    console.print("Counting unstaged elements...");
    console.flush();
    DiffObjectCount unstaged = geogig.getRepository().workingTree().countUnstaged(pathFilter);
    if (0 == unstaged.count() && conflicts.isEmpty()) {
        console.println();
        console.println("No unstaged elements, exiting.");
        return;
    } else {
        console.println(String.valueOf(unstaged.count()));
    }
    console.println("Staging changes...");
    AddOp op = geogig.command(AddOp.class);
    if (patterns.size() == 1) {
        op.addPattern(patterns.get(0));
    }
    WorkingTree workTree = op.setUpdateOnly(updateOnly).setProgressListener(cli.getProgressListener()).call();
    DiffObjectCount staged = geogig.getRepository().index().countStaged(null);
    unstaged = workTree.countUnstaged(null);
    console.println(staged.featureCount() + " features and " + staged.treeCount() + " trees staged for commit");
    console.println(unstaged.featureCount() + " features and " + unstaged.treeCount() + " trees not staged for commit");
}
Also used : AddOp(org.locationtech.geogig.api.porcelain.AddOp) InvalidParameterException(org.locationtech.geogig.cli.InvalidParameterException) WorkingTree(org.locationtech.geogig.repository.WorkingTree) DiffObjectCount(org.locationtech.geogig.api.plumbing.diff.DiffObjectCount) ConsoleReader(jline.console.ConsoleReader) ConflictsReadOp(org.locationtech.geogig.api.plumbing.merge.ConflictsReadOp) Conflict(org.locationtech.geogig.api.plumbing.merge.Conflict) GeoGIG(org.locationtech.geogig.api.GeoGIG)

Example 9 with WorkingTree

use of org.locationtech.geogig.repository.WorkingTree in project GeoGig by boundlessgeo.

the class ApplyPatchOpTest method testRemoveEmptyFeatureTypePatch.

@Test
public void testRemoveEmptyFeatureTypePatch() throws Exception {
    WorkingTree workingTree = geogig.getRepository().workingTree();
    workingTree.createTypeTree(pointsName, pointsType);
    geogig.command(AddOp.class).setUpdateOnly(false).call();
    Patch patch = new Patch();
    RevFeatureType featureType = RevFeatureTypeImpl.build(pointsType);
    patch.addFeatureType(featureType);
    patch.addAlteredTree(new FeatureTypeDiff(pointsName, featureType.getId(), null));
    geogig.command(ApplyPatchOp.class).setPatch(patch).call();
    RevTree root = repo.workingTree().getTree();
    assertNotNull(root);
    Optional<Node> typeTree = findTreeChild(root, pointsName);
    assertFalse(typeTree.isPresent());
}
Also used : WorkingTree(org.locationtech.geogig.repository.WorkingTree) FeatureTypeDiff(org.locationtech.geogig.api.plumbing.diff.FeatureTypeDiff) Node(org.locationtech.geogig.api.Node) Patch(org.locationtech.geogig.api.plumbing.diff.Patch) RevFeatureType(org.locationtech.geogig.api.RevFeatureType) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 10 with WorkingTree

use of org.locationtech.geogig.repository.WorkingTree in project GeoGig by boundlessgeo.

the class DefaultStepDefinitions method I_have_unstaged_an_empty_feature_type.

@Given("^I have unstaged an empty feature type$")
public void I_have_unstaged_an_empty_feature_type() throws Throwable {
    insert(points1);
    GeoGIG geogig = geogigCLI.newGeoGIG();
    final WorkingTree workTree = geogig.getRepository().workingTree();
    workTree.delete(pointsName, idP1);
    geogig.close();
}
Also used : WorkingTree(org.locationtech.geogig.repository.WorkingTree) GeoGIG(org.locationtech.geogig.api.GeoGIG) Given(cucumber.annotation.en.Given)

Aggregations

WorkingTree (org.locationtech.geogig.repository.WorkingTree)54 Test (org.junit.Test)32 AddOp (org.locationtech.geogig.api.porcelain.AddOp)25 List (java.util.List)18 ImmutableList (com.google.common.collect.ImmutableList)17 File (java.io.File)17 ArrayList (java.util.ArrayList)16 RevFeature (org.locationtech.geogig.api.RevFeature)15 Optional (com.google.common.base.Optional)12 SimpleFeature (org.opengis.feature.simple.SimpleFeature)12 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)11 NodeRef (org.locationtech.geogig.api.NodeRef)10 RevObjectParse (org.locationtech.geogig.api.plumbing.RevObjectParse)9 Name (org.opengis.feature.type.Name)9 GeoGIG (org.locationtech.geogig.api.GeoGIG)7 Node (org.locationtech.geogig.api.Node)7 ProgressListener (org.locationtech.geogig.api.ProgressListener)6 RevCommit (org.locationtech.geogig.api.RevCommit)6 Coordinate (com.vividsolutions.jts.geom.Coordinate)5 SimpleFeatureBuilder (org.geotools.feature.simple.SimpleFeatureBuilder)5