-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port to openhab2 API until compat1.x supports missing features
Details see openhab/openhab-addons#146
- Loading branch information
0 parents
commit 7f839bc
Showing
17 changed files
with
932 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
<classpathentry kind="src" path="src/main/java"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> | ||
<classpathentry kind="lib" path="lib/rrd4j-2.1.1.jar"/> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>org.openhab.persistence.rrd4j</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.ManifestBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.SchemaBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.ds.core.builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.pde.PluginNature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
4 changes: 4 additions & 0 deletions
4
org.openhab.persistence.rrd4j/.settings/org.eclipse.pde.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#Mon Oct 11 21:06:38 CEST 2010 | ||
eclipse.preferences.version=1 | ||
pluginProject.extensions=false | ||
resolve.requirebundle=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: openHAB RRD4j Persistence Bundle | ||
Bundle-SymbolicName: org.openhab.persistence.rrd4j;singleton:=true | ||
Bundle-Version: 2.0.0.qualifier | ||
Bundle-Vendor: openHAB | ||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7 | ||
Import-Package: javax.servlet;version="2.6.0", | ||
org.apache.commons.io, | ||
org.apache.commons.lang, | ||
org.openhab.core.items, | ||
org.openhab.core.library.items, | ||
org.openhab.core.library.types, | ||
org.openhab.core.persistence, | ||
org.openhab.core.types, | ||
org.openhab.io.net.http, | ||
org.osgi.framework, | ||
org.osgi.service.cm, | ||
org.osgi.service.http;version="1.2.1", | ||
org.slf4j | ||
Bundle-ClassPath: ., | ||
lib/rrd4j-2.1.1.jar | ||
Service-Component: OSGI-INF/rrd4j.xml, OSGI-INF/chartservlet.xml | ||
Bundle-Activator: org.openhab.persistence.rrd4j.internal.RRD4jActivator | ||
Require-Bundle: org.eclipse.smarthome.core, | ||
org.eclipse.smarthome.core.library, | ||
org.eclipse.smarthome.core.persistence, | ||
org.eclipse.smarthome.io.net, | ||
org.eclipse.smarthome.ui, | ||
org.eclipse.smarthome.model.sitemap;bundle-version="0.8.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2010-2015, openHAB.org and others. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License v1.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-v10.html | ||
--> | ||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="activate" deactivate="deactivate" name="org.openhab.persistence.rrd4j.chartservlet"> | ||
<implementation class="org.openhab.persistence.rrd4j.internal.charts.RRD4jChartServlet"/> | ||
<reference bind="setHttpService" cardinality="1..1" interface="org.osgi.service.http.HttpService" name="HttpService" policy="dynamic" unbind="unsetHttpService"/> | ||
<reference bind="setItemUIRegistry" cardinality="1..1" interface="org.eclipse.smarthome.ui.items.ItemUIRegistry" name="ItemUIRegistry" policy="dynamic" unbind="unsetItemUIRegistry"/> | ||
|
||
<service> | ||
<provide interface="org.eclipse.smarthome.ui.chart.ChartProvider"/> | ||
</service> | ||
</scr:component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2010-2015, openHAB.org and others. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License v1.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-v10.html | ||
--> | ||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.openhab.persistence.rrd4j"> | ||
<implementation class="org.openhab.persistence.rrd4j.internal.RRD4jService"/> | ||
<reference bind="setItemRegistry" cardinality="1..1" interface="org.eclipse.smarthome.core.items.ItemRegistry" name="ItemRegistry" policy="dynamic" unbind="unsetItemRegistry"/> | ||
<service> | ||
<provide interface="org.eclipse.smarthome.core.persistence.PersistenceService"/> | ||
</service> | ||
</scr:component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
output.. = target/classes/ | ||
bin.includes = META-INF/,\ | ||
OSGI-INF/,\ | ||
.,\ | ||
lib/rrd4j-2.1.1.jar | ||
source.. = src/main/java/ |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<parent> | ||
<groupId>org.openhab.bundles</groupId> | ||
<artifactId>persistence</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<name>openHAB RRD4j Persistence</name> | ||
|
||
<properties> | ||
<bundle.symbolicName>org.openhab.persistence.rrd4j</bundle.symbolicName> | ||
<bundle.namespace>org.openhab.persistence.rrd4j</bundle.namespace> | ||
<deb.name>openhab-addon-persistence-rrd4j</deb.name> | ||
<deb.description>${project.name}</deb.description> | ||
<deb.depends>openhab-runtime</deb.depends> | ||
</properties> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.openhab.persistence</groupId> | ||
<artifactId>org.openhab.persistence.rrd4j</artifactId> | ||
|
||
<packaging>eclipse-plugin</packaging> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.vafer</groupId> | ||
<artifactId>jdeb</artifactId> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>jdeb</goal> | ||
</goals> | ||
<configuration> | ||
<controlDir combine.self="override">${basedir}/src/deb/control</controlDir> | ||
<dataSet combine.self="override"> | ||
<data> | ||
<src>${basedir}/src/deb/etc/openhab/configurations/persistence/rrd4j.persist</src> | ||
<type>file</type> | ||
<mapper> | ||
<type>perm</type> | ||
<prefix>/etc/openhab/configurations/persistence</prefix> | ||
<user>root</user> | ||
<group>root</group> | ||
<filemode>644</filemode> | ||
</mapper> | ||
</data> | ||
<data> | ||
<src>${basedir}/target/${project.artifactId}-${project.version}.jar</src> | ||
<type>file</type> | ||
<mapper> | ||
<type>perm</type> | ||
<prefix>/usr/share/openhab/addons</prefix> | ||
<user>root</user> | ||
<group>root</group> | ||
<filemode>644</filemode> | ||
</mapper> | ||
</data> | ||
<data> | ||
<type>directory</type> | ||
<src>${basedir}/src/deb/var/lib/openhab/persistence</src> | ||
<excludes>**/.gitignore</excludes> | ||
<mapper> | ||
<type>perm</type> | ||
<prefix>/var/lib/openhab/persistence</prefix> | ||
<user>root</user> | ||
<group>openhab</group> | ||
<dirmode>2775</dirmode> | ||
</mapper> | ||
</data> | ||
<data> | ||
<!-- TODO better solution is to change rrd4j code to not save data files into configuration directory --> | ||
<type>link</type> | ||
<linkName>/etc/openhab/jetty/etc/rrd4j</linkName> | ||
<linkTarget>/var/lib/openhab/persistence/rrd4j</linkTarget> | ||
<symlink>true</symlink> | ||
</data> | ||
</dataSet> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/etc/openhab/configurations/persistence/rrd4j.persist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Package: [[deb.name]] | ||
Version: [[version]] | ||
Section: [[deb.section]] | ||
Priority: optional | ||
Architecture: all | ||
Maintainer: [[deb.maintainer]] | ||
Description: [[deb.description]] | ||
Distribution: [[deb.distribution]] | ||
Depends: [[deb.depends]] |
1 change: 1 addition & 0 deletions
1
org.openhab.persistence.rrd4j/src/deb/etc/openhab/configurations/persistence/rrd4j.persist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// Configuration file for "rrd4j" persistence module |
4 changes: 4 additions & 0 deletions
4
org.openhab.persistence.rrd4j/src/deb/var/lib/openhab/persistence/rrd4j/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Ignore everything in this directory | ||
* | ||
# Except this file | ||
!.gitignore |
41 changes: 41 additions & 0 deletions
41
...ersistence.rrd4j/src/main/java/org/openhab/persistence/rrd4j/internal/RRD4jActivator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Copyright (c) 2010-2015, openHAB.org and others. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.openhab.persistence.rrd4j.internal; | ||
|
||
import org.osgi.framework.BundleActivator; | ||
import org.osgi.framework.BundleContext; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
|
||
/** | ||
* Extension of the default OSGi bundle activator | ||
* | ||
* @author Kai Kreuzer | ||
* @since 1.0.0 | ||
*/ | ||
public final class RRD4jActivator implements BundleActivator { | ||
|
||
private static Logger logger = LoggerFactory.getLogger(RRD4jActivator.class); | ||
|
||
/** | ||
* Called whenever the OSGi framework starts our bundle | ||
*/ | ||
public void start(BundleContext bc) throws Exception { | ||
logger.debug("RRD4j persistence bundle has been started."); | ||
} | ||
|
||
/** | ||
* Called whenever the OSGi framework stops our bundle | ||
*/ | ||
public void stop(BundleContext bc) throws Exception { | ||
logger.debug("RRD4j persistence bundle has been stopped."); | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
...hab.persistence.rrd4j/src/main/java/org/openhab/persistence/rrd4j/internal/RRD4jItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* Copyright (c) 2010-2015, openHAB.org and others. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.openhab.persistence.rrd4j.internal; | ||
|
||
import java.text.DateFormat; | ||
import java.util.Date; | ||
|
||
import org.eclipse.smarthome.core.persistence.HistoricItem; | ||
import org.eclipse.smarthome.core.types.State; | ||
|
||
/** | ||
* This is a Java bean used to return historic items from a rrd4j database. | ||
* | ||
* @author Kai Kreuzer | ||
* @since 1.2.0 | ||
* | ||
*/ | ||
public class RRD4jItem implements HistoricItem { | ||
|
||
final private String name; | ||
final private State state; | ||
final private Date timestamp; | ||
|
||
public RRD4jItem(String name, State state, Date timestamp) { | ||
this.name = name; | ||
this.state = state; | ||
this.timestamp = timestamp; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public State getState() { | ||
return state; | ||
} | ||
|
||
public Date getTimestamp() { | ||
return timestamp; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return DateFormat.getDateTimeInstance().format(timestamp) + ": " + name + " -> "+ state.toString(); | ||
} | ||
|
||
} |
Oops, something went wrong.