Datahotel client

Client library for datahotel.

License

License

Categories

Categories

Data
GroupId

GroupId

no.difi.commons
ArtifactId

ArtifactId

commons-datahotel
Last Version

Last Version

0.9.0
Release Date

Release Date

Type

Type

jar
Description

Description

Datahotel client
Client library for datahotel.
Project URL

Project URL

https://github.com/difi/datahotel-client
Project Organization

Project Organization

Norwegian Agency for Public Management and eGovernment
Source Code Management

Source Code Management

https://github.com/difi/datahotel-client

Download commons-datahotel

How to add to project

<!-- https://jarcasting.com/artifacts/no.difi.commons/commons-datahotel/ -->
<dependency>
    <groupId>no.difi.commons</groupId>
    <artifactId>commons-datahotel</artifactId>
    <version>0.9.0</version>
</dependency>
// https://jarcasting.com/artifacts/no.difi.commons/commons-datahotel/
implementation 'no.difi.commons:commons-datahotel:0.9.0'
// https://jarcasting.com/artifacts/no.difi.commons/commons-datahotel/
implementation ("no.difi.commons:commons-datahotel:0.9.0")
'no.difi.commons:commons-datahotel:jar:0.9.0'
<dependency org="no.difi.commons" name="commons-datahotel" rev="0.9.0">
  <artifact name="commons-datahotel" type="jar" />
</dependency>
@Grapes(
@Grab(group='no.difi.commons', module='commons-datahotel', version='0.9.0')
)
libraryDependencies += "no.difi.commons" % "commons-datahotel" % "0.9.0"
[no.difi.commons/commons-datahotel "0.9.0"]

Dependencies

compile (4)

Group / Artifact Type Version
com.fasterxml.jackson.core : jackson-databind jar 2.6.3
org.apache.httpcomponents : httpclient jar 4.5.1
commons-beanutils : commons-beanutils jar 1.9.2
net.sourceforge.javacsv : javacsv jar 2.0

test (1)

Group / Artifact Type Version
org.testng : testng jar 6.9.9

Project Modules

There are no modules declared in this project.

Build Status

Datahotel client

Getting started

Include dependency in your pom.xml:

<dependency>
	<groupId>no.difi.commons</groupId>
	<artifactId>commons-datahotel</artifactId>
	<version>0.9.0</version>
</dependency>

Start fetching data:

// Build client for municipalities
Datahotel<DifiGeoKommune> datahotel = DatahotelBuilder.create(DifiGeoKommune.class).build();

// Find all minicipalities starting with "Os" in name
for (DifiGeoKommune municipality : datahotel.search("Os*")) {
	System.out.println(municipality.getNavn());
}

// Loop all municipalities in data set
for (DifiGeoKommune municipality : datahotel.all()) {
	System.out.println(municipality.getNavn());
}

Query datahotel using your own classes

This example shows how to extend functionality of the library.

// Create class
// Please note setters are needed when using looping whole data set.
@Dataset("difi/geo/fylke")
public class DifiGeoFylke {
    private String nummer, navn;

    public String getNummer() {
        return nummer;
    }

    public String getNavn() {
        return navn;
    }
}

// Build client for counties (using annotation)
Datahotel<DifiGeoFylke> datahotel = DatahotelBuilder.create(DifiGeoFylke.class).build();
// Build client for counties (not using annotation)
Datahotel<DifiGeoFylke> datahotel = DatahotelBuilder.create(DifiGeoFylke.class, "difi/geo/fylke").build();

// List all counties:
for (DifiGeoFylke county : datahotel.page(1)) {
	System.out.println(String.format("%s: %s", county.getNummer(), county.getNavn()));
}

// Print name of county number 14
System.out.println(datahotel.field("nummer", 14).single().getNavn());
no.difi.commons

Digitaliseringsdirektoratet (Digdir)

Versions

Version
0.9.0