Skip to content

Commit e5df4b2

Browse files
committed
Initial V2.0 commit
1 parent ef0df86 commit e5df4b2

27 files changed

+334
-1351
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
/.settings
33
/.classpath
44
/.project
5+
/.gradle
6+
/gradle
7+
/build
8+
/.idea
9+
gradlew
10+
gradlew.bat
11+
*.iml
12+
local.properties
513

614
*.class
715

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015 Databox
3+
Copyright (c) 2016 Databox
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 16 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,31 @@
1-
# Databox Java SDK
1+
# Databox Java SDK 2.0 [![Build Status](https://travis-ci.org/umajeric/databox-java-sdk.png?branch=master)](https://travis-ci.org/umajeric/databox-java-sdk)
22

3-
[![Build Status](https://travis-ci.org/databox/databox-java.png?branch=master)](https://travis-ci.org/databox/databox-java)
4-
5-
The Java SDK for interacting with the Databox Push API.
6-
7-
## Features
8-
9-
* Built on top of a solid and extensively tested framework [Apache HttpComponents](http://hc.apache.org/)
10-
* Uses Java library to convert JSON to Java objects and vice-versa [google-gson](https://code.google.com/p/google-gson)
11-
* Tested and well-documented
3+
The Java SDK for interacting with the Databox Push API v 2.0.
124

135
## Requirements
146

157
* Java >= 1.5 or later,
16-
* Maven >= 3.0.3 (optional but highly recomended)
17-
18-
## Maven supported
19-
20-
Add a maven repository to your pom file:
21-
```xml
22-
<repository>
23-
<id>umajeric-public-repo</id>
24-
<name>Umajeric Releases</name>
25-
<releases>
26-
<enabled>true</enabled>
27-
</releases>
28-
<snapshots>
29-
<enabled>false</enabled>
30-
</snapshots>
31-
<url>https://raw.github.com/umajeric/maven-public-repo/releases</url>
32-
</repository>
33-
```
34-
35-
Then add a dependency for Databox Custom DataSource artefact (see [here](https://github.com/umajeric/maven-public-repo/tree/releases/com/databox/custom-datasource-sdk) to find the latest version):
36-
```xml
37-
<dependency>
38-
<groupId>com.databox</groupId>
39-
<artifactId>java-push-sdk</artifactId>
40-
<version>LATEST</version>
41-
</dependency>
42-
```
43-
44-
## Basic usage of the Databox's `custom-datasource-sdk` client
45-
46-
Most basic sample:
47-
48-
```java
49-
DataSink<DataboxDataSource> sink = new DataboxSink();
50-
51-
String accessToken = "hd32o1ga8sf7sad0fu9sdufs8440442kj2";
52-
DataboxDataSource dataSource = new DataboxDataSource(accessToken);
53-
54-
DefaultDataProvider dataProvider = new DefaultDataProvider();
55-
dataProvider.addKPI(new KPI.Builder().setKey("new_signups").setValue(234D).withAttribute("no_of_items", 12).build());
56-
dataProvider.addKPI(new KPI.Builder().setKey("new_signups").setValue(234D).build());
57-
dataSource.addDataProvider(dataProvider);
58-
59-
sink.push(dataSource);
60-
```
8+
* Maven >= 3.0.3 OR Gradle 2.x
619

62-
One more advanced example (XSLDailyDataProvider implements DataProvider interface) that reads data from [Excel file](https://github.com/umajeric/databox-java-sdk/blob/master/sample/src/main/resources/cycling.xlsx):
10+
## Basic usage of the Databox's `databox-sdk` client
6311

6412
```java
65-
DataboxSink sink = new DataboxSink();
66-
List<DataboxDataSource> dataSources = new ArrayList<DataboxDataSource>();
67-
68-
String accessToken = "hd32o1ga8sf7sad0fu9sdufs8440442kj2";
69-
DataboxDataSource dataSource = new DataboxDataSource(accessToken);
70-
71-
XSLDailyDataProvider xlsxDataProvider = new XSLDailyDataProvider("cycling.xlsx");
72-
dataSource.addDataProvider(xlsxDataProvider);
73-
/* You can implement your own data provider that implements DataProvider interface */
74-
// dataSource.addDataProvider(new MyCustomDataProviderImpl());
75-
dataSources.add(dataSource);
76-
77-
/* For each data source we add a separate connection to the sink (each uses a different API Key and URL postfix) */
78-
// dataSource2 = new DataboxDataSource("5r4w91ga8sf7sad0fu9sdufs844044");
79-
/* We can use the same data provider for different connections */
80-
// dataSource2.addDataProvider(xlsxDataProvider);
81-
// dataSources.add(dataSource2);
82-
83-
for (DataSource ds : dataSources) {
84-
sink.push(ds);
13+
String TOKEN = "your_token_goes_here";
14+
Databox databox = new Databox(TOKEN);
15+
try {
16+
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
17+
databox.send("kitchen_light", 341d, sdf.parse("2015-12-25 00:00:00"));
18+
} catch (Exception e) {
19+
System.err.println(e.getLocalizedMessage());
8520
}
86-
8721
```
88-
89-
Snippet from excel file:
90-
91-
|Date |Total Time |Moving Time |Distance |Distance Unit |Average Speed |Max Speed |Speed Unit|
92-
| -------:| ------:| ------:| ------:|:------ | ------:| ------:|:------|
93-
|7/6/13 | 56 | 56 | 27.00 | km | 28.93 | 34.00 | km/h |
94-
|7/7/13 | 34 | 34 | 13 | km | 22.94 | 30 | km/h |
95-
|7/8/13 | 56 | 56 | 23 | km | 24.54 | 38 | km/h |
96-
|7/9/13 | 63 | 63 | 28 | km | 26.67 | 35 | km/h |
97-
|7/10/13 | 22 | 22 | 9 | km | 24.55 | 35 | km/h |
98-
99-
100-
101-
More examples can be found here [Example project](https://github.com/umajeric/databox-java-sdk/tree/master/sample)
102-
103-
## Documentation
104-
105-
See [wiki page](https://github.com/umajeric/databox-java-sdk/wiki) for additional documentation.
106-
10722
## License
10823

109-
Databox `databox-java` is licensed under the Apache License, Version 2.0 - see the [LICENSE](http://www.apache.org/licenses/LICENSE-2.0) file for details
24+
`databox-sdk` is licensed under the Apache License, Version 2.0 - see the [LICENSE](http://www.apache.org/licenses/LICENSE-2.0) file for details
25+
26+
## Credits
11027

111-
### Contributors & Credits
28+
### Contributors
11229

113-
- [Uros Majeric](http://github.com/umajeric)
11430

31+
- [Uros Majeric](http://github.com/umajeric)

build.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apply plugin: 'java'
2+
archivesBaseName = 'databox-sdk'
3+
group = 'com.databox'
4+
version = '2.0'
5+
6+
repositories {
7+
mavenCentral()
8+
}
9+
10+
dependencies {
11+
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.+'
12+
testCompile group: 'junit', name: 'junit', version: '4.+'
13+
}

pom.xml

Lines changed: 0 additions & 165 deletions
This file was deleted.

sample/src/main/resources/config.properties

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/main/java/com/databox/Environment.java

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)