Package org.locationtech.geogig.repository

Examples of org.locationtech.geogig.repository.WorkingTree$BlobInsertTask


        if (Transaction.AUTO_COMMIT.equals(getTransaction())) {
            throw new UnsupportedOperationException("GeoGIG does not support AUTO_COMMIT");
        }
        Preconditions.checkState(getDataStore().isAllowTransactions(),
                "Transactions not supported; head is not a local branch");
        final WorkingTree workingTree = delegate.getWorkingTree();
        final String path = delegate.getTypeTreePath();

        ProgressListener listener = new DefaultProgressListener();

        final List<FeatureId> insertedFids = Lists.newArrayList();
        List<Node> deferringTarget = new AbstractList<Node>() {

            @Override
            public boolean add(Node node) {
                String fid = node.getName();
                String version = node.getObjectId().toString();
                insertedFids.add(new FeatureIdVersionedImpl(fid, version));
                return true;
            }

            @Override
            public Node get(int index) {
                throw new UnsupportedOperationException();
            }

            @Override
            public int size() {
                return 0;
            }
        };
        Integer count = (Integer) null;

        FeatureIterator<SimpleFeature> featureIterator = featureCollection.features();
        try {
            Iterator<SimpleFeature> features;
            features = new FeatureIteratorIterator<SimpleFeature>(featureIterator);
            /*
             * Make sure to transform the incoming features to the native schema to avoid situations
             * where geogig would change the metadataId of the RevFeature nodes due to small
             * differences in the default and incoming schema such as namespace or missing
             * properties
             */
            final SimpleFeatureType nativeSchema = delegate.getNativeType();

            features = Iterators.transform(features, new SchemaInforcer(nativeSchema));

            workingTree.insert(path, features, listener, deferringTarget, count);
        } catch (Exception e) {
            throw new IOException(e);
        } finally {
            featureIterator.close();
        }
View Full Code Here


    @Override
    public void modifyFeatures(Name[] names, Object[] values, Filter filter) throws IOException {
        Preconditions.checkState(getDataStore().isAllowTransactions(),
                "Transactions not supported; head is not a local branch");

        final WorkingTree workingTree = delegate.getWorkingTree();
        final String path = delegate.getTypeTreePath();
        Iterator<SimpleFeature> features = modifyingFeatureIterator(names, values, filter);
        /*
         * Make sure to transform the incoming features to the native schema to avoid situations
         * where geogig would change the metadataId of the RevFeature nodes due to small differences
         * in the default and incoming schema such as namespace or missing properties
         */
        final SimpleFeatureType nativeSchema = delegate.getNativeType();

        features = Iterators.transform(features, new SchemaInforcer(nativeSchema));

        try {
            ProgressListener listener = new DefaultProgressListener();
            Integer count = (Integer) null;
            List<Node> target = (List<Node>) null;
            workingTree.insert(path, features, listener, target, count);
        } catch (Exception e) {
            throw new IOException(e);
        }
    }
View Full Code Here

    @Override
    public void removeFeatures(Filter filter) throws IOException {
        Preconditions.checkState(getDataStore().isAllowTransactions(),
                "Transactions not supported; head is not a local branch");
        final WorkingTree workingTree = delegate.getWorkingTree();
        final String typeTreePath = delegate.getTypeTreePath();
        filter = (Filter) filter.accept(new SimplifyingFilterVisitor(), null);
        if (Filter.INCLUDE.equals(filter)) {
            workingTree.delete(typeTreePath);
            return;
        }
        if (Filter.EXCLUDE.equals(filter)) {
            return;
        }

        Iterator<SimpleFeature> featureIterator = featureIterator(filter);
        Iterator<String> affectedFeaturePaths = Iterators.transform(featureIterator,
                new Function<SimpleFeature, String>() {

                    @Override
                    public String apply(SimpleFeature input) {
                        String fid = input.getID();
                        return NodeRef.appendChild(typeTreePath, fid);
                    }
                });
        workingTree.delete(affectedFeaturePaths);
    }
View Full Code Here

        Preconditions.checkArgument(!(locator instanceof GeogigTransaction));
        this.injector = locator;
        this.transactionId = transactionId;

        transactionIndex = new TransactionStagingArea(new Index(this), transactionId);
        transactionWorkTree = new WorkingTree(this);
        transactionRefDatabase = new TransactionRefDatabase(locator.refDatabase(), transactionId);
    }
View Full Code Here

    @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();
    }
View Full Code Here

    public static void deleteAndReplaceFeatureType() throws Exception {

        GeoGIG geogig = geogigCLI.newGeoGIG();
        try {
            final WorkingTree workTree = geogig.getRepository().workingTree();
            workTree.delete(points1.getType().getName());
            Name name = points1_FTmodified.getType().getName();
            String parentPath = name.getLocalPart();
            workTree.insert(parentPath, points1_FTmodified);
        } finally {
            geogig.close();
        }
    }
View Full Code Here

        GeoGIG geogig = geogigCLI.newGeoGIG(Hints.readWrite());
        Preconditions.checkNotNull(geogig);
        List<ObjectId> ids = Lists.newArrayListWithCapacity(features.length);
        try {
            Repository repository = geogig.getRepository();
            final WorkingTree workTree = repository.workingTree();
            for (Feature f : features) {
                Name name = f.getType().getName();
                String parentPath = name.getLocalPart();
                Node ref = workTree.insert(parentPath, f);
                ObjectId objectId = ref.getObjectId();
                ids.add(objectId);
            }
        } finally {
            geogig.close();
View Full Code Here

    }

    public static boolean delete(Feature f) throws Exception {
        GeoGIG geogig = geogigCLI.newGeoGIG();
        try {
            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;
        } finally {
            geogig.close();
        }
    }
View Full Code Here

    /**
     * @return
     */
    WorkingTree getWorkingTree() {
        Context commandLocator = getCommandLocator();
        WorkingTree workingTree = commandLocator.workingTree();
        return workingTree;
    }
View Full Code Here

        assertNull(commitCommand3.setAllowEmpty(true).call());
    }

    @Test
    public void testCommitEmptyTreeOnEmptyRepo() throws Exception {
        WorkingTree workingTree = geogig.getRepository().workingTree();
        final String emptyTreeName = "emptyTree";

        workingTree.createTypeTree(emptyTreeName, pointsType);
        geogig.command(AddOp.class).addPattern(emptyTreeName).call();

        CommitOp commitCommand = geogig.command(CommitOp.class);
        RevCommit commit = commitCommand.call();
        assertNotNull(commit);
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.repository.WorkingTree$BlobInsertTask

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.