Package com.gears42.iot.webthing
Class DatabaseHandlerImpl
- java.lang.Object
-
- android.database.sqlite.SQLiteOpenHelper
-
- com.gears42.iot.webthing.DatabaseHandlerImpl
-
- All Implemented Interfaces:
DatabaseHandlerI,java.lang.AutoCloseable
public class DatabaseHandlerImpl extends android.database.sqlite.SQLiteOpenHelper implements DatabaseHandlerI
Manages Database operations of the Framework.
-
-
Constructor Summary
Constructors Constructor Description DatabaseHandlerImpl(android.content.Context context)Clean compliance data based on intersection of current and old compliance job.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddComplianceConfig(java.lang.String thingId, java.lang.String ruleName, java.lang.String deviceProperty, java.lang.String ruleCondition, int duration, java.lang.String ruleValue, java.lang.String pollingType)Add compliance configuration.voidaddComplianceProperty(java.lang.String thingId, java.lang.String property, java.lang.String value, java.lang.String type)Add compliance property data.voidaddEvent(java.lang.String requestId, java.lang.String data)Add a compliance event.voidaddJobXML(java.lang.String thingId, java.lang.String jobXML)Add JobXML.voidaddOrUpdateCompianceProperty(java.lang.String thingId, java.lang.String property, java.lang.String value, java.lang.String type)Add or update compliance property data.voidaddOrUpdateComplianceConfig(java.lang.String thingId, java.lang.String ruleName, java.lang.String deviceProperty, java.lang.String ruleCondition, int duration, java.lang.String ruleValue, java.lang.String pollingType)Add or update compliance configuration based on existence.voidaddOrUpdateJobXML(java.lang.String thingId, java.lang.String jobXML)Add or Update JobXML.booleancleanDB(java.lang.String thingId, java.util.List<java.lang.String> properties)Clean compliance DB data based on intersection of current and old compliance job.voiddeleteCompliance(java.lang.String thingId)Delete compliance for a thing.booleandeleteComplianceConfig(java.lang.String thingId, java.lang.String property)Delete compliance configuration for a property.booleandeleteComplianceProperty(java.lang.String thingId, java.lang.String property)Delete compliance data for a property.voiddeleteEvent(java.lang.String requestId)Delete a compliance event.voiddeleteJobXML(java.lang.String thingId)Delete JobXML.org.json.JSONObjectgetAllConfig()Get compliance configuration for all properties.org.json.JSONObjectgetAllEvents()Get all compliance events.org.json.JSONObjectgetAllPendingEvents()Get all pending compliance events.org.json.JSONArraygetComplianceProperties()Get all compliance properties data.org.json.JSONObjectgetConfigForProperty(java.lang.String thingId, java.lang.String property)Get compliance configuration for a property.java.util.List<java.lang.String>getConfigPropertyNames(java.lang.String thingId, boolean onlyNormalPoll)List of compliance configured properties.java.lang.StringgetJobXML(java.lang.String thingId)Get JobXML.java.util.List<java.lang.String>getThingIDs()List of thingIds on which the compliance is configured.booleanisCompliancePropertyExists(java.lang.String thingId, java.lang.String property)Check if compliance data of a property exists.voidonCreate(android.database.sqlite.SQLiteDatabase db)voidonUpgrade(android.database.sqlite.SQLiteDatabase db, int oldVersion, int newVersion)voidsetCompliance(java.lang.String thingId, java.lang.String property, int isCompliant, long complianceTime)Set compliance status of a property.voidsetNixNotify(java.lang.String requestId, int nixNotified, int notifyCount)Set nix notify status of a property.voidupdateComplianceConfig(java.lang.String thingId, java.lang.String ruleName, java.lang.String deviceProperty, java.lang.String ruleCondition, int duration, java.lang.String ruleValue, java.lang.String pollingType)Update compliance configuration based on existence.voidupdateComplianceProperty(java.lang.String thingId, java.lang.String property, java.lang.String value)Update compliance property data.voidupdateJobXML(java.lang.String thingId, java.lang.String jobXML)Update JobXML.
-
-
-
Method Detail
-
onCreate
public void onCreate(android.database.sqlite.SQLiteDatabase db)
- Specified by:
onCreatein classandroid.database.sqlite.SQLiteOpenHelper
-
onUpgrade
public void onUpgrade(android.database.sqlite.SQLiteDatabase db, int oldVersion, int newVersion)- Specified by:
onUpgradein classandroid.database.sqlite.SQLiteOpenHelper
-
addOrUpdateComplianceConfig
public void addOrUpdateComplianceConfig(java.lang.String thingId, java.lang.String ruleName, java.lang.String deviceProperty, java.lang.String ruleCondition, int duration, java.lang.String ruleValue, java.lang.String pollingType)Add or update compliance configuration based on existence.- Specified by:
addOrUpdateComplianceConfigin interfaceDatabaseHandlerI- Parameters:
thingId- Id of the thing.ruleName- Name of the rule.deviceProperty- Compliance configured property.ruleCondition- Condition to decide compliance.duration- Duration till which the property should stay out of compliance to decide it as the later.ruleValue- Threshold value.pollingType- Property polling type.
-
addComplianceConfig
public void addComplianceConfig(java.lang.String thingId, java.lang.String ruleName, java.lang.String deviceProperty, java.lang.String ruleCondition, int duration, java.lang.String ruleValue, java.lang.String pollingType)Add compliance configuration.- Specified by:
addComplianceConfigin interfaceDatabaseHandlerI- Parameters:
thingId- Id of the thing.ruleName- Name of the rule.deviceProperty- Compliance configured property.ruleCondition- Condition to decide compliance.duration- Duration till which the property should stay out of compliance to decide it as the later.ruleValue- Threshold value.pollingType- Property polling type.
-
updateComplianceConfig
public void updateComplianceConfig(java.lang.String thingId, java.lang.String ruleName, java.lang.String deviceProperty, java.lang.String ruleCondition, int duration, java.lang.String ruleValue, java.lang.String pollingType)Update compliance configuration based on existence.- Specified by:
updateComplianceConfigin interfaceDatabaseHandlerI- Parameters:
thingId- Id of the thing.ruleName- Name of the rule.deviceProperty- Compliance configured property.ruleCondition- Condition to decide compliance.duration- Duration till which the property should stay out of compliance to decide it as the later.ruleValue- Threshold value.pollingType- Property polling type.
-
cleanDB
public boolean cleanDB(java.lang.String thingId, java.util.List<java.lang.String> properties)Clean compliance DB data based on intersection of current and old compliance job.- Specified by:
cleanDBin interfaceDatabaseHandlerI- Parameters:
thingId- Id of the thing.properties- List of current job properties.- Returns:
- is cleanDB success.
-
getThingIDs
public java.util.List<java.lang.String> getThingIDs()
List of thingIds on which the compliance is configured.- Specified by:
getThingIDsin interfaceDatabaseHandlerI- Returns:
- List of thingIds.
-
getConfigPropertyNames
public java.util.List<java.lang.String> getConfigPropertyNames(java.lang.String thingId, boolean onlyNormalPoll)List of compliance configured properties.- Specified by:
getConfigPropertyNamesin interfaceDatabaseHandlerI- Parameters:
thingId- Id of the thing.onlyNormalPoll- Property polling type.- Returns:
- List of Property names.
-
addOrUpdateCompianceProperty
public void addOrUpdateCompianceProperty(java.lang.String thingId, java.lang.String property, java.lang.String value, java.lang.String type)Add or update compliance property data.- Specified by:
addOrUpdateCompiancePropertyin interfaceDatabaseHandlerI- Parameters:
thingId- Id of the thing.property- property name.value- Latest value of the property.type- Value type of the property.
-
addComplianceProperty
public void addComplianceProperty(java.lang.String thingId, java.lang.String property, java.lang.String value, java.lang.String type)Add compliance property data.- Specified by:
addCompliancePropertyin interfaceDatabaseHandlerI- Parameters:
thingId- Id of the thing.property- property name.value- Latest value of the property.type- Value type of the property.
-
updateComplianceProperty
public void updateComplianceProperty(java.lang.String thingId, java.lang.String property, java.lang.String value)Update compliance property data.- Specified by:
updateCompliancePropertyin interfaceDatabaseHandlerI- Parameters:
thingId- Id of the thing.property- property name.value- Latest value of the property.
-
isCompliancePropertyExists
public boolean isCompliancePropertyExists(java.lang.String thingId, java.lang.String property)Check if compliance data of a property exists.- Specified by:
isCompliancePropertyExistsin interfaceDatabaseHandlerI- Parameters:
thingId- Id of the thing.property- property name.- Returns:
- true if compliance data of a property exists.
-
getComplianceProperties
public org.json.JSONArray getComplianceProperties()
Get all compliance properties data.- Specified by:
getCompliancePropertiesin interfaceDatabaseHandlerI- Returns:
- All compliance properties data.
-
getConfigForProperty
public org.json.JSONObject getConfigForProperty(java.lang.String thingId, java.lang.String property)Get compliance configuration for a property.- Specified by:
getConfigForPropertyin interfaceDatabaseHandlerI- Parameters:
thingId- Id of the thing.property- property name.- Returns:
- Compliance configuration for a property.
-
getAllConfig
public org.json.JSONObject getAllConfig()
Get compliance configuration for all properties.- Specified by:
getAllConfigin interfaceDatabaseHandlerI- Returns:
- Compliance configuration for all properties.
-
setCompliance
public void setCompliance(java.lang.String thingId, java.lang.String property, int isCompliant, long complianceTime)Set compliance status of a property.- Specified by:
setCompliancein interfaceDatabaseHandlerI- Parameters:
thingId- Id of the thing.property- property name.isCompliant- compliant status.complianceTime- Time of compliance status change.
-
deleteCompliance
public void deleteCompliance(java.lang.String thingId)
Delete compliance for a thing.- Specified by:
deleteCompliancein interfaceDatabaseHandlerI- Parameters:
thingId- thingId.
-
deleteComplianceConfig
public boolean deleteComplianceConfig(java.lang.String thingId, java.lang.String property)Delete compliance configuration for a property.- Specified by:
deleteComplianceConfigin interfaceDatabaseHandlerI- Parameters:
thingId- thingId.property- compliance property.- Returns:
- true if successful, false otherwise.
-
deleteComplianceProperty
public boolean deleteComplianceProperty(java.lang.String thingId, java.lang.String property)Delete compliance data for a property.- Specified by:
deleteCompliancePropertyin interfaceDatabaseHandlerI- Parameters:
thingId- thingId.property- compliance property.- Returns:
- true if successful, false otherwise.
-
addEvent
public void addEvent(java.lang.String requestId, java.lang.String data)Add a compliance event.- Specified by:
addEventin interfaceDatabaseHandlerI- Parameters:
requestId- Event requestId.data- Event data.
-
deleteEvent
public void deleteEvent(java.lang.String requestId)
Delete a compliance event.- Specified by:
deleteEventin interfaceDatabaseHandlerI- Parameters:
requestId- Event requestId.
-
setNixNotify
public void setNixNotify(java.lang.String requestId, int nixNotified, int notifyCount)Set nix notify status of a property.- Specified by:
setNixNotifyin interfaceDatabaseHandlerI- Parameters:
requestId- requestId of event.nixNotified- Nix notified status.notifyCount- notify try count.
-
getAllPendingEvents
public org.json.JSONObject getAllPendingEvents()
Get all pending compliance events.- Specified by:
getAllPendingEventsin interfaceDatabaseHandlerI- Returns:
- Pending events.
-
getAllEvents
public org.json.JSONObject getAllEvents()
Get all compliance events.- Specified by:
getAllEventsin interfaceDatabaseHandlerI- Returns:
- All compliance events.
-
deleteJobXML
public void deleteJobXML(java.lang.String thingId)
Delete JobXML.- Specified by:
deleteJobXMLin interfaceDatabaseHandlerI- Parameters:
thingId- thingId.
-
addOrUpdateJobXML
public void addOrUpdateJobXML(java.lang.String thingId, java.lang.String jobXML)Add or Update JobXML.- Specified by:
addOrUpdateJobXMLin interfaceDatabaseHandlerI- Parameters:
thingId- thingId.jobXML- jobXML.
-
addJobXML
public void addJobXML(java.lang.String thingId, java.lang.String jobXML)Add JobXML.- Specified by:
addJobXMLin interfaceDatabaseHandlerI- Parameters:
thingId- thingId.jobXML- jobXML.
-
updateJobXML
public void updateJobXML(java.lang.String thingId, java.lang.String jobXML)Update JobXML.- Specified by:
updateJobXMLin interfaceDatabaseHandlerI- Parameters:
thingId- thingId.jobXML- jobXML.
-
getJobXML
public java.lang.String getJobXML(java.lang.String thingId)
Get JobXML.- Specified by:
getJobXMLin interfaceDatabaseHandlerI- Parameters:
thingId- thingId.- Returns:
- jobXML.
-
-