This commit is contained in:
Wolfgang Hottgenroth 2017-11-22 17:30:56 +01:00
commit 81dfb547e7
11 changed files with 230 additions and 0 deletions

26
.classpath Normal file
View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
target

23
.project Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>SmarthomeLib</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,5 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8

View File

@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "automatic"
}

32
pom.xml Normal file
View File

@ -0,0 +1,32 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.hottis.smarthomelib</groupId>
<artifactId>SmarthomeLib</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>SmarthomeLib</name>
<url>http://maven.apache.org</url>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.9.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.9.1</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,53 @@
package de.hottis.smarthomelib;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public abstract class ADataObject implements Serializable {
private static final long serialVersionUID = 1L;
final protected Logger logger = LogManager.getRootLogger();
private LocalDateTime timestamp;
private String name;
private Map<String, Object> values;
public ADataObject(LocalDateTime timestamp, String name) {
this.timestamp = timestamp;
this.name = name;
}
public void setValues(Map<String, Object> values) {
this.values = values;
}
abstract public String getTableName();
public LocalDateTime getTimestamp() {
return timestamp;
}
public Map<String, Object> getValues() {
return values;
}
public String getName() {
return name;
}
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("<");
sb.append(name);
sb.append(", ");
sb.append(timestamp);
sb.append(", ");
sb.append(values.toString());
sb.append(">");
return sb.toString();
}
}

View File

@ -0,0 +1,24 @@
package de.hottis.smarthomelib;
import java.time.LocalDateTime;
import java.util.HashMap;
public class ElectricEnergyDataObject extends ADataObject {
private static final long serialVersionUID = 1L;
static final String ENERGY_KEY = "energy";
static final String POWER_KEY = "power";
static final String TABLE_NAME = "ElectricEnergy";
public ElectricEnergyDataObject(LocalDateTime timestamp, String name, double energy, double power) {
super(timestamp, name);
HashMap<String, Object> values = new HashMap<String, Object>();
values.put(ENERGY_KEY, energy);
values.put(POWER_KEY, power);
setValues(values);
}
@Override
public String getTableName() {
return TABLE_NAME;
}
}

View File

@ -0,0 +1,21 @@
package de.hottis.smarthomelib;
import java.time.LocalDateTime;
import java.util.HashMap;
public class TemperatureDataObject extends ADataObject {
private static final long serialVersionUID = 1L;
static final String TEMPERATURE_KEY = "temperature";
static final String TABLE_NAME = "Temperature";
public TemperatureDataObject(LocalDateTime timestamp, String name, double temperature) {
super(timestamp, name);
HashMap<String, Object> values = new HashMap<String, Object>();
values.put(TEMPERATURE_KEY, temperature);
setValues(values);
}
public String getTableName() {
return TABLE_NAME;
}
}

View File

@ -0,0 +1,38 @@
package de.hottis.smarthomelib;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}