use of org.locationtech.geogig.api.Context in project GeoGig by boundlessgeo.
the class GeogigTransactionState method setTransaction.
@Override
public void setTransaction(@Nullable final Transaction transaction) {
Preconditions.checkArgument(!Transaction.AUTO_COMMIT.equals(transaction));
if (transaction != null && this.tx != null) {
throw new IllegalStateException("New transaction set without closing old transaction first.");
}
this.tx = transaction;
if (transaction == null) {
// transaction.close())
if (this.geogigTx != null) {
// throw new
// IllegalStateException("Transaction is attempting to "
// + "close a non committed or aborted geogig transaction");
geogigTx.abort();
}
this.geogigTx = null;
} else {
if (this.geogigTx != null) {
geogigTx.abort();
}
GeoGigDataStore dataStore = (GeoGigDataStore) entry.getDataStore();
Context commandLocator = dataStore.getCommandLocator(this.tx);
this.geogigTx = commandLocator.command(TransactionBegin.class).call();
// checkout the working branch
final String workingBranch = dataStore.getOrFigureOutBranch();
this.geogigTx.command(CheckoutOp.class).setForce(true).setSource(workingBranch).call();
}
}
use of org.locationtech.geogig.api.Context in project GeoGig by boundlessgeo.
the class GeoGigDataStore method findTypeRefs.
private List<NodeRef> findTypeRefs(@Nullable Transaction tx) {
final String rootRef = getRootRef(tx);
Context commandLocator = getCommandLocator(tx);
List<NodeRef> typeTrees = commandLocator.command(FindFeatureTypeTrees.class).setRootTreeRef(rootRef).call();
return typeTrees;
}
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;
}
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();
}
use of org.locationtech.geogig.api.Context in project GeoGig by boundlessgeo.
the class DiffTreeTest method setUp.
@Before
public void setUp() throws Exception {
File workingDirectory = tempFolder.newFolder("mockWorkingDir");
Platform testPlatform = new TestPlatform(workingDirectory);
Context injector = Guice.createInjector(Modules.override(new GeogigModule()).with(new MemoryModule(testPlatform))).getInstance(Context.class);
geogit = new GeoGIG(injector);
assertNotNull(geogit.getOrCreateRepository());
diffTree = geogit.command(DiffTree.class);
SimpleFeatureType ft = DataUtilities.createType("points", "sp:String,ip:Integer,pp:Point:srid=3857");
revtype = RevFeatureTypeImpl.build(ft);
metadataId = revtype.getId();
geogit.getContext().objectDatabase().put(revtype);
}
Aggregations