org.locationtech.geogig.repository.Hints类的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.locationtech.geogig.repository.Hints类的一些代码示例,展示了Hints类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hints类的具体详情如下:
包路径:org.locationtech.geogig.repository.Hints
类名称:Hints

Hints介绍

[英]Hints that guice created dependencies can accept on their constructors, contains flags to enable/disable operational modes on databases. In the future may provide other kind of hints to other components.
[中]guice创建的依赖项可以在其构造函数上接受的提示,包含在数据库上启用/禁用操作模式的标志。将来可能会向其他组件提供其他类型的提示。

代码示例

代码示例来源:origin: locationtech/geogig

/**
 * @return a new {@code Hints} object with the hints for a read only repository
 */
public static Hints readOnly() {
  Hints hints = new Hints();
  hints.set(Hints.OBJECTS_READ_ONLY, Boolean.TRUE);
  hints.set(Hints.REMOTES_READ_ONLY, Boolean.TRUE);
  return hints;
}

代码示例来源:origin: locationtech/geogig

@Override
public ConfigDatabase getConfigDatabase(URI repoURI, Context repoContext, boolean rootUri) {
  Hints hints = new Hints().uri(repoURI);
  Platform platform = repoContext.platform();
  return new IniFileConfigDatabase(platform, hints, rootUri);
}

代码示例来源:origin: org.locationtech.geogig/geogig-cli

private Context newGeogigInjector(Hints hints) {
  if (repositoryURI != null) {
    LOGGER.debug("using REPO_URL '{}'", repositoryURI);
    hints.set(Hints.REPOSITORY_URL, repositoryURI);
  }
  if (!hints.get(Hints.PLATFORM).isPresent()) {
    hints.set(Hints.PLATFORM, this.platform);
  }
  Context geogigInjector = GlobalContextBuilder.builder().build(hints);
  return geogigInjector;
}

代码示例来源:origin: org.locationtech.geogig/geogig-bdbje

@Override
  protected Context createInjector() {
    Hints hints = new Hints().uri(repositoryDirectory.toURI()).platform(createPlatform());
    return new JETestContextBuilder().build(hints);
  }
}

代码示例来源:origin: locationtech/geogig

@Test
public void testHints() {
  Hints hints = new Hints();
  assertTrue(hints.getAll().isEmpty());
  assertFalse(hints.get("not present").isPresent());
  hints.set("key", "myValue");
  assertEquals("myValue", hints.get("key").get());
  assertFalse(hints.getBoolean("key"));
  hints.set("key2", true);
  assertTrue(hints.getBoolean("key2"));
}

代码示例来源:origin: locationtech/geogig

@Test
public void testUri() throws URISyntaxException {
  Hints hints = new Hints();
  assertFalse(hints.get(Hints.REPOSITORY_URL).isPresent());
  URI repoURI = new URI("repoURI");
  hints.uri(repoURI);
  assertEquals(repoURI, hints.get(Hints.REPOSITORY_URL).get());
}

代码示例来源:origin: org.locationtech.geogig/geogig-web-api

final String newRepoName = hints.get(Hints.REPOSITORY_NAME).get().toString();
  final URI parentUri = new File(parentDir).getCanonicalFile().toURI();
  final RepositoryResolver resolver = RepositoryResolver.lookup(parentUri);
  hints.uri(repoURI);
} else if (dbName != null && dbPassword != null) {
  final String repoName = hints.get(Hints.REPOSITORY_NAME).get().toString();
  final StringBuilder pathBuilder = new StringBuilder(128);
  hints.set(Hints.REPOSITORY_URL, repoUri);

代码示例来源:origin: locationtech/geogig

Hints hints = new Hints();
assertFalse(hints.get(Hints.PLATFORM).isPresent());
hints.platform(platform);
assertEquals(platform, hints.get(Hints.PLATFORM).get());

代码示例来源:origin: locationtech/geogig

@Override
protected ObjectStore createObjectStore() throws IOException {
  Platform platform = new DefaultPlatform();
  platform.setWorkingDir(tmp.getRoot());
  tmp.newFolder(".geogig");
  Hints hints = Hints.readWrite().platform(platform);
  try {
    hints.set(Hints.REPOSITORY_URL, tmp.getRoot().toURI().toURL());
  } catch (MalformedURLException e) {
    throw new RuntimeException(e);
  }
  return new RocksdbObjectStore(platform, hints);
}

代码示例来源:origin: locationtech/geogig

public @Before 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(),
          new HintsModule(new Hints().platform(testPlatform))))
      .getInstance(Context.class);
  GeoGIG geogig = new GeoGIG(injector);
  repo = geogig.getOrCreateRepository();
  command = repo.command(FindChangedTrees.class);
  ftproto = DataUtilities.createType("points", "sp:String,ip:Integer,pp:Point:srid=3857");
}

代码示例来源:origin: locationtech/geogig

@Override
public String getName(URI repoURI) {
  String repoName = null;
  // if the repo exists, get the name from it
  if (repoExists(repoURI)) {
    // it exists, load it and fetch the name
    Hints hints = Hints.readOnly().uri(repoURI);
    Context context = GlobalContextBuilder.builder().build(hints);
    ConfigDatabase configDatabase = context.configDatabase();
    repoName = configDatabase.get("repo.name").orNull();
  }
  if (repoName == null) {
    // the repo doesn't exist or name is not configured, derive the name from the
    // location
    File file = toFile(repoURI);
    try {
      file = file.getCanonicalFile();
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
    if (file.getName().equals(".geogig")) {
      file = file.getParentFile();
    }
    repoName = file.getName();
  }
  return repoName;
}

代码示例来源:origin: org.geoserver.community/gs-geogig

private static Ref pingRemote(Remote remote) throws Exception {
  Optional<IRemoteRepo> remoteRepo;
  try {
    Hints hints = Hints.readOnly();
    Repository localRepo = GlobalContextBuilder.builder().build(hints).repository();
    remoteRepo = RemoteResolver.newRemote(remote, null);
    if (!remoteRepo.isPresent()) {
      throw new IllegalArgumentException("Repository not found or not reachable");
    } else {
      IRemoteRepo repo = remoteRepo.get();
      try {
        repo.open();
        Optional<Ref> head = repo.headRef();
        return head.orNull();
      } finally {
        repo.close();
      }
    }
  } catch (Exception e) {
    throw new IllegalArgumentException("Unable to connect: " + e.getMessage(), e);
  }
}

代码示例来源:origin: org.locationtech.geogig/geogig-cli-core

@Given("^I have a merge conflict state$")
public void I_have_a_merge_conflict_state() throws Throwable {
  I_have_conflicting_branches();
  Ref branch = localRepo.geogigCLI.getGeogig(Hints.readOnly()).command(RefParse.class)
      .setName("branch1").call().get();
  try {
    localRepo.geogigCLI.getGeogig(Hints.readWrite()).command(MergeOp.class)
        .addCommit(branch.getObjectId()).call();
    fail();
  } catch (MergeConflictsException e) {
  }
}

代码示例来源:origin: locationtech/geogig

/**
 * Constructs and returns a new read-write geogig facade, which will not be managed by this
 * GeogigCLI instance, so the calling code is responsible for closing/disposing it after usage
 * 
 * @return the constructed GeoGIG.
 */
public GeoGIG newGeoGIG() {
  return newGeoGIG(Hints.readWrite());
}

代码示例来源:origin: locationtech/geogig

public EnvironmentBuilder(Hints hints) throws URISyntaxException {
  Optional<Serializable> repoUrl = hints.get(Hints.REPOSITORY_URL);
  checkArgument(repoUrl.isPresent(), "%s was not given", Hints.REPOSITORY_URL);
  URI url = new URI(String.valueOf(repoUrl.get()));
  init(url, false);
}

代码示例来源:origin: locationtech/geogig

/**
 * Sets a hint for the provided repository URI.
 * 
 * @param repoURI the URI to use
 * @return {@code this}
 */
public Hints uri(URI repoURI) {
  set(REPOSITORY_URL, repoURI);
  return this;
}

代码示例来源:origin: locationtech/geogig

@Override
public Context build(Hints hints) {
  if (!hints.get(Hints.PLATFORM).isPresent() && this.platform != null) {
    hints = hints.platform(platform);
  }
  Module[] overrides = { new MemoryModule(), new HintsModule(hints) };
  if (this.additionalOverrides != null) {
    List<Module> list = Lists.newArrayList(overrides);
    list.addAll(Arrays.asList(additionalOverrides));
    overrides = list.toArray(new Module[list.size()]);
  }
  GeogigModule geogigModule = new GeogigModule();
  Module override = Modules.override(geogigModule).with(overrides);
  return Guice.createInjector(override).getInstance(Context.class);
}

代码示例来源:origin: org.locationtech.geogig/geogig-bdbje

public Impl(final ConfigDatabase config, final EnvironmentBuilder envProvider,
    final TupleBinding<NodeData> binding, final String formatVersion, final Hints hints) {
  this.configDb = config;
  this.envProvider = envProvider;
  this.BINDING = binding;
  this.formatVersion = formatVersion;
  this.envName = JEGraphDatabase.ENVIRONMENT_NAME;
  this.readOnly = hints.getBoolean(Hints.OBJECTS_READ_ONLY);
}

代码示例来源:origin: locationtech/geogig

@Before
public void setUp() throws IOException {
  File root = folder.getRoot();
  folder.newFolder(".geogig");
  File home = folder.newFolder("home");
  platform = new TestPlatform(root);
  platform.setUserHome(home);
  hints = new Hints();
  configDB = new IniFileConfigDatabase(platform);
  db = new RocksdbObjectDatabase(platform, hints, configDB);
  db.open();
}

代码示例来源:origin: locationtech/geogig

@Test
public void testReadOnly() {
  Hints hints = Hints.readOnly();
  assertTrue(hints.getBoolean(Hints.OBJECTS_READ_ONLY));
  assertTrue(hints.getBoolean(Hints.REMOTES_READ_ONLY));
}

相关文章