Create an Application

The Data Client Base Library allows you to create HERE platform data applications. The instructions below describe the process for a basic application using the Scala Build Tool (SBT) and Maven.

Access Credentials

You need two types of credentials:

  1. HERE platform credentials -- To obtain your HERE platform credentials, create a new application via the https://platform.here.com/profile/apps-and-keys page. When you have created your application, click Create A Key to download these credentials. Place the credentials in $HOME/.here/credentials.properties.
  2. Repository Credentials -- To obtain your credentials to access the repository containing the Data Client Base Library, go to https://platform.here.com/profile/repository and click Create credentials to download the settings.xml file.

Configure the Build System

The following steps describe how to configure SBT and Maven projects.

For SBT, create a new file in ~/.ivy2/.credentials with the following content:

realm=Artifactory Realm
host=repo.platform.here.com
user=[REPOSITORY_USERNAME]
password=[REPOSITORY_PASSWORD]

where [REPOSITORY_USERNAME] and [REPOSITORY_PASSWORD] are the username and password from the downloaded settings.xml. You can find this information in the servers/server[1] XML node.

For Maven, copy the downloaded settings.xml to ~/.m2.

Create a Project

Create a new empty project directory with one of the following files: build.sbt for SBT or pom.xml for Maven.

SBT
Maven
scalaVersion := "2.11.12" // data client base library currently only supports Scala 2.11
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
resolvers += "HERE Repo" at "https://repo.platform.here.com/artifactory/open-location-platform/"
libraryDependencies ++= Seq(
  "com.here.platform.data.client.base" %% "data-client-base" % "0.3-SNAPSHOT"
)
<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.company</groupId>
    <artifactId>my-data-sample</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>com.here.platform.data.client.base</groupId>
            <artifactId>data-client-base_2.11</artifactId>
            <version>0.3-SNAPSHOT</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

You have now completed your project configuration and can start using the Data Client Base Library.

The code example below shows a simple class that prints the HERE Resource Names (HRNs) for catalogs that you have access to in the HERE platform.

Add the file containing the class to the appropriate directory in src/main/scala or src/main/java, in your project:

Scala
Java
import com.here.platform.data.client.base.generated.codecs.JsonSupport._
import com.here.platform.data.client.base.generated.scaladsl.api.config.ConfigApi
import com.here.platform.data.client.base.generated.scaladsl.model.config.CatalogsResultBase
import com.here.platform.data.client.base.scaladsl.BaseClient
import com.here.platform.data.client.base.http.IOExecutionContext.Implicits.globalIO

import scala.concurrent.Await
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration.Duration
import scala.util.{Failure, Success}

object ScalaSimpleMain {

  def main(args: Array[String]): Unit = {

    val client = BaseClient()
    val configApi = client.of[ConfigApi]

    val result =
      for {
        catalogsListResult: CatalogsResultBase <- configApi
          .getCatalogs(
            verbose = Some(false),
            organisationType = Nil,
            layerType = Nil,
            region = Nil,
            resourceType = None,
            coverage = Nil,
            access = Nil,
            marketplaceReady = None,
            sortBy = None,
            sortOrder = None
          )
          .executeToEntity()
      } yield {
        catalogsListResult
      }

    result
      .andThen {
        case Success(response) => println(s"response: $response")
        case Failure(ex) => ex.printStackTrace()
      }
      .andThen {
        case _ =>
          client.shutdown()
      }

    Await.result(result, Duration.Inf)
  }
}
import com.here.platform.data.client.base.generated.javadsl.api.config.ConfigApi;
import com.here.platform.data.client.base.generated.scaladsl.model.config.CatalogsSummaryListResult;
import com.here.platform.data.client.base.javadsl.BaseClient;
import com.here.platform.data.client.base.javadsl.BaseClientJava;
import java.util.Collections;
import java.util.Optional;

public class JavaSimpleMain {
  public static void main(String[] args) {
    BaseClient baseClient = BaseClientJava.instance();
    ConfigApi configApi = new ConfigApi(baseClient);

    CatalogsSummaryListResult listResult =
        (CatalogsSummaryListResult)
            configApi
                .getCatalogs(
                    Optional.empty(),
                    Optional.of(false),
                    Optional.empty(),
                    Optional.empty(),
                    Collections.emptyList(),
                    Collections.emptyList(),
                    Collections.emptyList(),
                    Optional.empty(),
                    Optional.empty(),
                    Collections.emptyList(),
                    Collections.emptyList(),
                    Optional.empty(),
                    Optional.empty(),
                    Optional.empty(),
                    Optional.empty())
                .executeToEntity()
                .toCompletableFuture()
                .join();

    System.out.println(listResult);
    baseClient.shutdown().toCompletableFuture().join();
  }
}

Scala vs Java

The Data Client Base Library supports both Java and Scala bindings, many classes have both javadsl and scaladsl implementations. If the class package does not include a specific Domain Specific Language (DSL), this means that the class package has getters and setters available for both Scala and Java.

Artifacts

SBT
Maven
Gradle
libraryDependencies += "com.here.platform.data.client.base" % "{data-module}" % "0.3-SNAPSHOT"
<dependency>
  <groupId>com.here.platform.data.client.base</groupId>
  <artifactId>{data-module}</artifactId>
  <version>0.3-SNAPSHOT</version>
</dependency>
dependencies {
  compile group: 'com.here.platform.data.client.base', name: '{data-module}', version: '0.3-SNAPSHOT'
}

results matching ""

    No results matching ""