Skip to content

Commit

Permalink
Merge pull request #19 from RADAR-CNS/0.1_release
Browse files Browse the repository at this point in the history
0.1 release request
  • Loading branch information
blootsvoets committed Apr 6, 2017
2 parents a9b334b + 760325f commit 11e25c7
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 10 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

[![Build Status](https://travis-ci.org/RADAR-CNS/RADAR-Schemas.svg?branch=master)](https://travis-ci.org/RADAR-CNS/RADAR-Schemas)

[Avro schemas](https://avro.apache.org/docs/1.8.1/spec.html) used in RADAR-CNS.
[Avro schemas](https://avro.apache.org/docs/1.8.1/spec.html) used in RADAR-CNS. The schemas are divided into three parts: `commons` for the passive remote monitoring application and the backend, `restapi` for the REST API, and `questionnaire` for the active remote monitoring application.

Java SDKs for each of the components are provided in the `java-sdk` folder, see installation instructions there. They are automatically generated from the Avro schemas using the Avro 1.8.1 specification.

## Contributing

The Avro schemas in the `common` directory adhere to the [Google JSON style](https://google.github.io/styleguide/jsoncstyleguide.xml). In addition:
The Avro schemas should follow the [Google JSON style guide](https://google.github.io/styleguide/jsoncstyleguide.xml).

In addition, schemas in the `commons` directory should follow the following guidelines:

- Try to avoid abbreviations in the field names and write out the field name instead.
- There should be no need to add `value` at the end of a field name.
Expand Down
43 changes: 43 additions & 0 deletions java-sdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# RADAR Schemas Java SDK

The Java SDKs are published as JARs on bintray. To use them in Gradle, add the following code to your `build.gradle`:

```gradle
repositories {
maven { url 'http://dl.bintray.com/radar-cns/org.radarcns' }
}
dependencies {
// Commons schemas (backend, passive remote monitoring app)
compile 'org.radarcns:radar-schemas-commons:0.1'
// REST API schemas (REST API, testing)
compile 'org.radarcns:radar-schemas-restapi:0.1'
// Questionnaire schemas (active remote monitoring app)
compile 'org.radarcns:radar-schemas-questionnaire:0.1'
}
```
Usually, you only need to include the schemas you actually need in your dependencies.

The generated code each refers to a single schema. The classes of Avro records will extend `org.apache.avro.specific.SpecificRecord`. They each have a static `getClassSchema()` function that returns the `Schema` that it was generated from. To read JSON serialized data for example, use the following code:

```java
public class Deserialize {
public static void main(String args[]) throws Exception {
//Instantiating the Schema.Parser class.
DatumReader<PhoneBatteryLevel> datumReader = new SpecificDatumReader<>(PhoneBatteryLevel.class);
DataFileReader<PhoneBatteryLevel> dataFileReader = new DataFileReader<>(new File("/path/to/mydata.avro"), datumReader);

System.out.println("Reading phone battery levels");
PhoneBatteryLevel batteryLevel = null;
while (dataFileReader.hasNext()) {
batteryLevel = dataFileReader.next(batteryLevel);
System.out.println("Phone battery level: " + batteryLevel);
}
System.out.println("Done");
}
}
```

Alternatively, use `org.radarcns.data.SpecificRecordEncoder` and `org.radarcns.data.SpecificRecordDecoder` from the `radar-commons` package.
13 changes: 5 additions & 8 deletions java-sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ subprojects {
apply plugin: 'com.commercehub.gradle.plugin.avro-base'
apply plugin: 'maven-publish'

version = '0.1-SNAPSHOT'
// Configuration
version = '0.1'
group = 'org.radarcns'
ext.githubRepo = 'RADAR-CNS/RADAR-Schemas'

Expand All @@ -27,15 +28,16 @@ subprojects {
ext.issueUrl = 'https://github.com/' + githubRepo + '/issues'
ext.website = 'http://radar-cns.org'

// dependencies
repositories {
jcenter()
maven { url 'http://dl.bintray.com/typesafe/maven-releases' }
}

dependencies {
api group: 'org.apache.avro', name: 'avro', version: avroVersion
}

// publishing
ext.pomConfig = {
licenses {
license {
Expand Down Expand Up @@ -103,19 +105,14 @@ subprojects {
archives sourcesJar, javadocJar
}

// Generated avro files
ext.avroOutputDir = file('src/main/java')

clean {
delete avroOutputDir
}
}

//---------------------------------------------------------------------------//
// Testing //
//---------------------------------------------------------------------------//



task wrapper(type: Wrapper) {
gradleVersion = '3.4.1'
distributionUrl distributionUrl.replace("bin", "all")
Expand Down
File renamed without changes.

0 comments on commit 11e25c7

Please sign in to comment.