use of org.locationtech.geogig.api.Context in project GeoGig by boundlessgeo.
the class GeogigCLI method newGeoGIG.
public GeoGIG newGeoGIG(Hints hints) {
Context inj = newGeogigInjector(hints);
GeoGIG geogig = new GeoGIG(inj, platform.pwd());
try {
geogig.getRepository();
} catch (Exception e) {
throw Throwables.propagate(e);
}
return geogig;
}
use of org.locationtech.geogig.api.Context in project GeoGig by boundlessgeo.
the class ParseTimestampTest method setUp.
@Before
public void setUp() {
File workingDirectory = tempFolder.newFolder("mockWorkingDir");
Platform testPlatform = new TestPlatform(workingDirectory) {
@Override
public long currentTimeMillis() {
return REFERENCE_DATE.getTime();
}
};
Context injector = Guice.createInjector(Modules.override(new GeogigModule()).with(new MemoryModule(testPlatform))).getInstance(Context.class);
fakeGeogig = new GeoGIG(injector, workingDirectory);
assertNotNull(fakeGeogig.getOrCreateRepository());
command = fakeGeogig.command(ParseTimestamp.class);
}
use of org.locationtech.geogig.api.Context in project GeoGig by boundlessgeo.
the class RevParseTest method testResolveToMultipleIds.
@Test
public void testResolveToMultipleIds() {
StagingDatabase mockIndexDb = mock(StagingDatabase.class);
Context mockCommands = mock(Context.class);
RefParse mockRefParse = mock(RefParse.class);
when(mockRefParse.setName(anyString())).thenReturn(mockRefParse);
when(mockCommands.command(eq(RefParse.class))).thenReturn(mockRefParse);
Optional<Ref> ref = Optional.absent();
when(mockRefParse.call()).thenReturn(ref);
List<ObjectId> oIds = Arrays.asList(ObjectId.forString("Object 1"), ObjectId.forString("Object 2"));
when(mockIndexDb.lookUp(anyString())).thenReturn(oIds);
when(mockCommands.stagingDatabase()).thenReturn(mockIndexDb);
RevParse command = new RevParse();
command.setContext(mockCommands);
exception.expect(IllegalArgumentException.class);
command.setRefSpec(commitId1.toString().substring(0, commitId1.toString().length() - 2)).call();
}
use of org.locationtech.geogig.api.Context in project GeoGig by boundlessgeo.
the class GeoGigDataStore method getCommandLocator.
public Context getCommandLocator(@Nullable Transaction transaction) {
Context commandLocator = null;
if (transaction != null && !Transaction.AUTO_COMMIT.equals(transaction)) {
GeogigTransactionState state;
state = (GeogigTransactionState) transaction.getState(GeogigTransactionState.class);
Optional<GeogigTransaction> geogigTransaction = state.getGeogigTransaction();
if (geogigTransaction.isPresent()) {
commandLocator = geogigTransaction.get();
}
}
if (commandLocator == null) {
commandLocator = geogig.getContext();
}
return commandLocator;
}
use of org.locationtech.geogig.api.Context in project GeoGig by boundlessgeo.
the class GeogigFeatureSource method getWorkingTree.
/**
* @return
*/
WorkingTree getWorkingTree() {
Context commandLocator = getCommandLocator();
WorkingTree workingTree = commandLocator.workingTree();
return workingTree;
}
Aggregations