-
Notifications
You must be signed in to change notification settings - Fork 781
Initial commit of persistence extensions #1872
Changes from all commits
12c7c31
b532fa5
dfbbf7a
bcaa729
6779175
81fe974
c192e76
5b1238c
4632f69
406327b
acdf26a
c11d8c1
ad90d05
4a22703
1d36e4b
2bcb6af
04e65e9
1c0c9fd
1c3aa20
829fd5d
d093a17
6610b71
cbcd900
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Copyright (c) 2014-2016 by the respective copyright holders. | ||
* 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.core.persistence; | ||
|
||
import java.util.Date; | ||
|
||
import org.eclipse.smarthome.core.items.Item; | ||
import org.eclipse.smarthome.core.types.State; | ||
|
||
/** | ||
* This class provides an interface to the a {@link PersistenceService} to allow data to be stored | ||
* at a specific time. This allows bindings that interface to devices that store data internally, | ||
* and then periodically provide it to the server to be accommodated. | ||
* | ||
* @author Chris Jackson - Initial implementation and API | ||
* | ||
*/ | ||
public interface ModifiablePersistenceService extends QueryablePersistenceService { | ||
/** | ||
* <p> | ||
* Stores the historic item value. This allows the item, time and value to be specified. | ||
* </p> | ||
* <p> | ||
* Adding data with the same time as an existing record should update the current record value rather than adding a | ||
* new record. | ||
* </p> | ||
* <p> | ||
* Implementors should keep in mind that all registered {@link PersistenceService}s are called synchronously. Hence | ||
* long running operations should be processed asynchronously. E.g. <code>store</code> adds things to a queue which | ||
* is processed by some asynchronous workers (Quartz Job, Thread, etc.). | ||
* </p> | ||
* | ||
* @param item the data to be stored | ||
* @param date the date of the record | ||
* @param state the state to be recorded | ||
*/ | ||
void store(Item item, Date date, State state); | ||
|
||
/** | ||
* Removes data associated with an item from a persistence service. | ||
* If all data is removed for the specified item, the persistence service should free any resources associated with | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please update the javadoc - the filtercriteria might not filter for a specific item at all, so this method is applicable for many items at the same time as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I follow. I assumed that there must be an item name provided - it's not possible to add a filter with multiple item names, and I think it would be dangerous to add a filter with no item name. As discussed elsewhere, in the REST interface at least, it is required. Technically it would be possible to implement a filter that removed data from multiple items, but is it a good idea? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, if you look at FilterCriteria, it reads: So in general, it allows that the itemName is null and hence the filter is applicable for ANY item. As your method accepts a filter criteria as a parameter, you have to deal with that fact. If you do not want to allow itemName to be null, you should document this in the JavaDoc and declare an exception that you will throw in that case. |
||
* the item (eg. remove any tables or delete files from the storage). | ||
* | ||
* @param filter the filter to apply to the data removal. ItemName can not be null. | ||
* @return true if the query executed successfully | ||
* @throws {@link IllegalArgumentException} if item name is null. | ||
*/ | ||
boolean remove(FilterCriteria filter) throws IllegalArgumentException; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Copyright (c) 2014-2016 by the respective copyright holders. | ||
* 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.core.persistence; | ||
|
||
import java.util.Date; | ||
|
||
/** | ||
* This class provides information about an item that is stored in a persistence service. | ||
* It is used to return information about the item to the system | ||
* | ||
* @author Chris Jackson - Initial contribution | ||
* | ||
*/ | ||
public interface PersistenceItemInfo { | ||
/** | ||
* Returns the item name. | ||
* It should be noted that the item name is as stored in the persistence service and as such may not be linked to an | ||
* item. This may be the case if the item was removed from the system, but data still exists in the persistence | ||
* service. | ||
* | ||
* @return Item name | ||
*/ | ||
String getName(); | ||
|
||
/** | ||
* Returns a counter with the number of rows of data associated with the item | ||
* Note that this should be used as a guide to the amount of data and may note be 100% accurate. If accurate | ||
* information is required, the {@link QueryablePersistenceService#query} method should be used. | ||
* | ||
* @return count of the number of rows of data. May return null if the persistence service doesn't support this. | ||
*/ | ||
Integer getCount(); | ||
|
||
/** | ||
* Returns the earliest timestamp from data in the persistence database | ||
* | ||
* @return the earliest {@link Date} stored in the database. May return null if the persistence service doesn't | ||
* support this. | ||
*/ | ||
Date getEarliest(); | ||
|
||
/** | ||
* Returns the latest timestamp from data in the persistence database | ||
* | ||
* @return the latest {@link Date} stored in the database. May return null if the persistence service doesn't | ||
* support this. | ||
*/ | ||
Date getLatest(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you re-run "mvn license:format" to update the headers to the latest version?