Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
Add H2SQL persistence bundle
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Jackson <[email protected]>
  • Loading branch information
cdjackson committed Jul 22, 2016
1 parent dfbbf7a commit b0791d3
Show file tree
Hide file tree
Showing 17 changed files with 865 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ private Response deletePersistenceItemData(String serviceName, String itemName,
// This is necessary for values that don't change often otherwise data will start after the start of the graph
// (or not at all if there's no change during the graph period)
filter = new FilterCriteria();
filter.setEndDate(dateTimeBegin);
filter.setBeginDate(dateTimeBegin);
filter.setEndDate(dateTimeEnd);
filter.setItemName(itemName);
mService.remove(filter);

Expand Down
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.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="java"/>
<classpathentry kind="lib" path="lib/h2-1.3.176.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.smarthome.persistence.h2sql</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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
formatter_settings_version=12
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
eclipse.preferences.version=1
pluginProject.extensions=false
resolve.requirebundle=false
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Eclipse SmartHome H2SQL Persistence Service
Bundle-SymbolicName: org.eclipse.smarthome.persistence.h2sql
Bundle-Version: 0.9.0.qualifier
Bundle-Vendor: openHAB.org
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
DynamicImport-Package: *
Import-Package: org.apache.commons.io,
org.apache.commons.lang,
org.eclipse.smarthome.core.items,
org.eclipse.smarthome.core.library.items,
org.eclipse.smarthome.core.library.types,
org.eclipse.smarthome.core.persistence,
org.eclipse.smarthome.core.types,
org.openhab.core.library.types,
org.osgi.framework,
org.osgi.service.cm,
org.slf4j
Bundle-ClassPath: .,
lib/h2-1.3.176.jar
Service-Component: OSGI-INF/h2sql.xml
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.eclipse.smarthome.persistence.h2sql.internal.H2SqlPersistenceServiceActivator
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.eclipse.smarthome.persistence.h2sql">
<implementation class="org.eclipse.smarthome.persistence.h2sql.internal.H2SqlPersistenceService"/>
<service>
<provide interface="org.osgi.service.cm.ManagedService"/>
<provide interface="org.eclipse.smarthome.core.persistence.PersistenceService"/>
</service>
<reference bind="setItemRegistry" cardinality="0..1" interface="org.eclipse.smarthome.core.items.ItemRegistry" name="ItemRegistry" policy="dynamic" unbind="unsetItemRegistry"/>
<property name="service.pid" type="String" value="org.eclipse.smarthome.persistence.h2sql"/>
</scr:component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
output.. = target/classes/
bin.includes = META-INF/,\
OSGI-INF/,\
.,\
lib/h2-1.3.176.jar
source.. = java/
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.eclipse.smarthome.persistence.h2sql.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 SQL database.
*
* @author Chris Jackson - Initial contribution
*
*/
public class H2SqlHistoricItem implements HistoricItem {

final private String name;
final private State state;
final private Date timestamp;

public H2SqlHistoricItem(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();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* 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.eclipse.smarthome.persistence.h2sql.internal;

import org.eclipse.smarthome.core.persistence.PersistenceItemInfo;

/**
* This is a Java bean used to return items from a SQL database.
*
* @author Chris Jackson - Initial contribution
*
*/
public class H2SqlPersistenceItem implements PersistenceItemInfo {

final private String name;
final private Integer rows;

public H2SqlPersistenceItem(String name, Integer rows) {
this.name = name;
this.rows = rows;
}

public String getName() {
return name;
}

public Integer getRows() {
return rows;
}
}
Loading

0 comments on commit b0791d3

Please sign in to comment.