Search in sources :

Example 1 with Context

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;
}
Also used : Context(org.locationtech.geogig.api.Context) GeoGIG(org.locationtech.geogig.api.GeoGIG) ParameterException(com.beust.jcommander.ParameterException) ConfigException(org.locationtech.geogig.api.porcelain.ConfigException) IOException(java.io.IOException) CannotRunGeogigOperationException(org.locationtech.geogig.api.hooks.CannotRunGeogigOperationException)

Example 2 with Context

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);
}
Also used : Context(org.locationtech.geogig.api.Context) TestPlatform(org.locationtech.geogig.api.TestPlatform) Platform(org.locationtech.geogig.api.Platform) TestPlatform(org.locationtech.geogig.api.TestPlatform) File(java.io.File) GeogigModule(org.locationtech.geogig.di.GeogigModule) MemoryModule(org.locationtech.geogig.api.MemoryModule) GeoGIG(org.locationtech.geogig.api.GeoGIG) Before(org.junit.Before)

Example 3 with Context

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();
}
Also used : Context(org.locationtech.geogig.api.Context) Ref(org.locationtech.geogig.api.Ref) ObjectId(org.locationtech.geogig.api.ObjectId) StagingDatabase(org.locationtech.geogig.storage.StagingDatabase) Test(org.junit.Test)

Example 4 with Context

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;
}
Also used : Context(org.locationtech.geogig.api.Context) GeogigTransaction(org.locationtech.geogig.api.GeogigTransaction)

Example 5 with Context

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;
}
Also used : Context(org.locationtech.geogig.api.Context) WorkingTree(org.locationtech.geogig.repository.WorkingTree)

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