Search in sources :

Example 51 with Context

use of org.locationtech.geogig.api.Context in project GeoGig by boundlessgeo.

the class GeogigFeatureSource method getNativeType.

SimpleFeatureType getNativeType() {
    final NodeRef typeRef = getTypeRef();
    final String treePath = typeRef.path();
    final ObjectId metadataId = typeRef.getMetadataId();
    Context commandLocator = getCommandLocator();
    Optional<RevFeatureType> revType = commandLocator.command(RevObjectParse.class).setObjectId(metadataId).call(RevFeatureType.class);
    if (!revType.isPresent()) {
        throw new IllegalStateException(String.format("Feature type for tree %s not found", treePath));
    }
    SimpleFeatureType featureType = (SimpleFeatureType) revType.get().type();
    return featureType;
}
Also used : Context(org.locationtech.geogig.api.Context) NodeRef(org.locationtech.geogig.api.NodeRef) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) ObjectId(org.locationtech.geogig.api.ObjectId) RevFeatureType(org.locationtech.geogig.api.RevFeatureType)

Example 52 with Context

use of org.locationtech.geogig.api.Context in project GeoGig by boundlessgeo.

the class GeogigFeatureSource method getTypeTree.

/**
     * @return
     */
RevTree getTypeTree() {
    String refSpec = getRootRef() + ":" + getTypeTreePath();
    Context commandLocator = getCommandLocator();
    Optional<RevTree> ref = commandLocator.command(RevObjectParse.class).setRefSpec(refSpec).call(RevTree.class);
    Preconditions.checkState(ref.isPresent(), "Ref %s not found on working tree", refSpec);
    return ref.get();
}
Also used : Context(org.locationtech.geogig.api.Context) RevTree(org.locationtech.geogig.api.RevTree)

Aggregations

Context (org.locationtech.geogig.api.Context)52 CommandContext (org.locationtech.geogig.web.api.CommandContext)24 CommandResponse (org.locationtech.geogig.web.api.CommandResponse)24 ResponseWriter (org.locationtech.geogig.web.api.ResponseWriter)24 CommandSpecException (org.locationtech.geogig.web.api.CommandSpecException)16 ObjectId (org.locationtech.geogig.api.ObjectId)13 File (java.io.File)9 GeoGIG (org.locationtech.geogig.api.GeoGIG)9 NodeRef (org.locationtech.geogig.api.NodeRef)8 Ref (org.locationtech.geogig.api.Ref)8 Before (org.junit.Before)7 RevCommit (org.locationtech.geogig.api.RevCommit)7 Optional (com.google.common.base.Optional)6 Platform (org.locationtech.geogig.api.Platform)6 RevTree (org.locationtech.geogig.api.RevTree)6 TestPlatform (org.locationtech.geogig.api.TestPlatform)6 DiffEntry (org.locationtech.geogig.api.plumbing.diff.DiffEntry)5 GeogigModule (org.locationtech.geogig.di.GeogigModule)5 MemoryModule (org.locationtech.geogig.api.MemoryModule)4 RevFeature (org.locationtech.geogig.api.RevFeature)4