Documentation ¶
Index ¶
- Constants
- func CheckDatastreamRelationsExist(gdb *GostDatabase, d *entities.Datastream) error
- func ContainsToLower(s []*godata.SelectItem, e string) bool
- func DeleteEntity(gdb *GostDatabase, id interface{}, entityName string) error
- func EntityExists(gdb *GostDatabase, id interface{}, entityName string) bool
- func ExecuteSelect(db *sql.DB, q *QueryParseInfo, sql string, qo *odata.QueryOptions) ([]entities.Entity, bool, error)
- func ExecuteSelectCount(db *sql.DB, sql string) (int, error)
- func GetCreateDatabaseQuery(location string, schema string) (*string, error)
- func JSONToMap(data *string) (map[string]interface{}, error)
- func NewDatabase(host string, port int, user string, password string, database string, ...) models.Database
- func ToIntID(id interface{}) (int, bool)
- type GostDatabase
- func (gdb *GostDatabase) CreateSchema(location string) error
- func (gdb *GostDatabase) DatastreamExists(id int) bool
- func (gdb *GostDatabase) DeleteDatastream(id interface{}) error
- func (gdb *GostDatabase) DeleteFeatureOfInterest(id interface{}) error
- func (gdb *GostDatabase) DeleteHistoricalLocation(id interface{}) error
- func (gdb *GostDatabase) DeleteLocation(id interface{}) error
- func (gdb *GostDatabase) DeleteObservation(id interface{}) error
- func (gdb *GostDatabase) DeleteObservedProperty(id interface{}) error
- func (gdb *GostDatabase) DeleteSensor(id interface{}) error
- func (gdb *GostDatabase) DeleteThing(id interface{}) error
- func (gdb *GostDatabase) FeatureOfInterestExists(id int) bool
- func (gdb *GostDatabase) GetDatastream(id interface{}, qo *odata.QueryOptions) (*entities.Datastream, error)
- func (gdb *GostDatabase) GetDatastreamByObservation(observationID interface{}, qo *odata.QueryOptions) (*entities.Datastream, error)
- func (gdb *GostDatabase) GetDatastreams(qo *odata.QueryOptions) ([]*entities.Datastream, int, bool, error)
- func (gdb *GostDatabase) GetDatastreamsByObservedProperty(oID interface{}, qo *odata.QueryOptions) ([]*entities.Datastream, int, bool, error)
- func (gdb *GostDatabase) GetDatastreamsBySensor(sensorID interface{}, qo *odata.QueryOptions) ([]*entities.Datastream, int, bool, error)
- func (gdb *GostDatabase) GetDatastreamsByThing(thingID interface{}, qo *odata.QueryOptions) ([]*entities.Datastream, int, bool, error)
- func (gdb *GostDatabase) GetFeatureOfInterest(id interface{}, qo *odata.QueryOptions) (*entities.FeatureOfInterest, error)
- func (gdb *GostDatabase) GetFeatureOfInterestByObservation(id interface{}, qo *odata.QueryOptions) (*entities.FeatureOfInterest, error)
- func (gdb *GostDatabase) GetFeatureOfInterestIDByLocationID(id interface{}) (interface{}, error)
- func (gdb *GostDatabase) GetFeatureOfInterests(qo *odata.QueryOptions) ([]*entities.FeatureOfInterest, int, bool, error)
- func (gdb *GostDatabase) GetHistoricalLocation(id interface{}, qo *odata.QueryOptions) (*entities.HistoricalLocation, error)
- func (gdb *GostDatabase) GetHistoricalLocations(qo *odata.QueryOptions) ([]*entities.HistoricalLocation, int, bool, error)
- func (gdb *GostDatabase) GetHistoricalLocationsByLocation(locationID interface{}, qo *odata.QueryOptions) ([]*entities.HistoricalLocation, int, bool, error)
- func (gdb *GostDatabase) GetHistoricalLocationsByThing(thingID interface{}, qo *odata.QueryOptions) ([]*entities.HistoricalLocation, int, bool, error)
- func (gdb *GostDatabase) GetLocation(id interface{}, qo *odata.QueryOptions) (*entities.Location, error)
- func (gdb *GostDatabase) GetLocationByDatastreamID(datastreamID interface{}, qo *odata.QueryOptions) (*entities.Location, error)
- func (gdb *GostDatabase) GetLocations(qo *odata.QueryOptions) ([]*entities.Location, int, bool, error)
- func (gdb *GostDatabase) GetLocationsByHistoricalLocation(hlID interface{}, qo *odata.QueryOptions) ([]*entities.Location, int, bool, error)
- func (gdb *GostDatabase) GetLocationsByThing(thingID interface{}, qo *odata.QueryOptions) ([]*entities.Location, int, bool, error)
- func (gdb *GostDatabase) GetObservation(id interface{}, qo *odata.QueryOptions) (*entities.Observation, error)
- func (gdb *GostDatabase) GetObservations(qo *odata.QueryOptions) ([]*entities.Observation, int, bool, error)
- func (gdb *GostDatabase) GetObservationsByDatastream(dataStreamID interface{}, qo *odata.QueryOptions) ([]*entities.Observation, int, bool, error)
- func (gdb *GostDatabase) GetObservationsByFeatureOfInterest(foiID interface{}, qo *odata.QueryOptions) ([]*entities.Observation, int, bool, error)
- func (gdb *GostDatabase) GetObservedArea(id int) (map[string]interface{}, error)
- func (gdb *GostDatabase) GetObservedProperties(qo *odata.QueryOptions) ([]*entities.ObservedProperty, int, bool, error)
- func (gdb *GostDatabase) GetObservedProperty(id interface{}, qo *odata.QueryOptions) (*entities.ObservedProperty, error)
- func (gdb *GostDatabase) GetObservedPropertyByDatastream(id interface{}, qo *odata.QueryOptions) (*entities.ObservedProperty, error)
- func (gdb *GostDatabase) GetSensor(id interface{}, qo *odata.QueryOptions) (*entities.Sensor, error)
- func (gdb *GostDatabase) GetSensorByDatastream(id interface{}, qo *odata.QueryOptions) (*entities.Sensor, error)
- func (gdb *GostDatabase) GetSensors(qo *odata.QueryOptions) ([]*entities.Sensor, int, bool, error)
- func (gdb *GostDatabase) GetThing(id interface{}, qo *odata.QueryOptions) (*entities.Thing, error)
- func (gdb *GostDatabase) GetThingByDatastream(id interface{}, qo *odata.QueryOptions) (*entities.Thing, error)
- func (gdb *GostDatabase) GetThingByHistoricalLocation(id interface{}, qo *odata.QueryOptions) (*entities.Thing, error)
- func (gdb *GostDatabase) GetThings(qo *odata.QueryOptions) ([]*entities.Thing, int, bool, error)
- func (gdb *GostDatabase) GetThingsByLocation(id interface{}, qo *odata.QueryOptions) ([]*entities.Thing, int, bool, error)
- func (gdb *GostDatabase) HistoricalLocationExists(id interface{}) bool
- func (gdb *GostDatabase) LinkLocation(thingID interface{}, locationID interface{}) error
- func (gdb *GostDatabase) LocationExists(id interface{}) bool
- func (gdb *GostDatabase) ObservationExists(id interface{}) bool
- func (gdb *GostDatabase) ObservedPropertyExists(id interface{}) bool
- func (gdb *GostDatabase) PatchDatastream(id interface{}, ds *entities.Datastream) (*entities.Datastream, error)
- func (gdb *GostDatabase) PatchFeatureOfInterest(id interface{}, foi *entities.FeatureOfInterest) (*entities.FeatureOfInterest, error)
- func (gdb *GostDatabase) PatchHistoricalLocation(id interface{}, hl *entities.HistoricalLocation) (*entities.HistoricalLocation, error)
- func (gdb *GostDatabase) PatchLocation(id interface{}, l *entities.Location) (*entities.Location, error)
- func (gdb *GostDatabase) PatchObservation(id interface{}, o *entities.Observation) (*entities.Observation, error)
- func (gdb *GostDatabase) PatchObservedProperty(id interface{}, op *entities.ObservedProperty) (*entities.ObservedProperty, error)
- func (gdb *GostDatabase) PatchSensor(id interface{}, s *entities.Sensor) (*entities.Sensor, error)
- func (gdb *GostDatabase) PatchThing(id interface{}, thing *entities.Thing) (*entities.Thing, error)
- func (gdb *GostDatabase) PostDatastream(d *entities.Datastream) (*entities.Datastream, error)
- func (gdb *GostDatabase) PostFeatureOfInterest(f *entities.FeatureOfInterest) (*entities.FeatureOfInterest, error)
- func (gdb *GostDatabase) PostHistoricalLocation(hl *entities.HistoricalLocation) (*entities.HistoricalLocation, error)
- func (gdb *GostDatabase) PostLocation(location *entities.Location) (*entities.Location, error)
- func (gdb *GostDatabase) PostObservation(o *entities.Observation) (*entities.Observation, error)
- func (gdb *GostDatabase) PostObservedProperty(op *entities.ObservedProperty) (*entities.ObservedProperty, error)
- func (gdb *GostDatabase) PostSensor(sensor *entities.Sensor) (*entities.Sensor, error)
- func (gdb *GostDatabase) PostThing(thing *entities.Thing) (*entities.Thing, error)
- func (gdb *GostDatabase) PutDatastream(id interface{}, datastream *entities.Datastream) (*entities.Datastream, error)
- func (gdb *GostDatabase) PutFeatureOfInterest(id interface{}, f *entities.FeatureOfInterest) (*entities.FeatureOfInterest, error)
- func (gdb *GostDatabase) PutHistoricalLocation(id interface{}, hl *entities.HistoricalLocation) (*entities.HistoricalLocation, error)
- func (gdb *GostDatabase) PutLocation(id interface{}, location *entities.Location) (*entities.Location, error)
- func (gdb *GostDatabase) PutObservation(id interface{}, o *entities.Observation) (*entities.Observation, error)
- func (gdb *GostDatabase) PutObservedProperty(id interface{}, op *entities.ObservedProperty) (*entities.ObservedProperty, error)
- func (gdb *GostDatabase) PutSensor(id interface{}, sensor *entities.Sensor) (*entities.Sensor, error)
- func (gdb *GostDatabase) PutThing(id interface{}, thing *entities.Thing) (*entities.Thing, error)
- func (gdb *GostDatabase) SensorExists(id int) bool
- func (gdb *GostDatabase) Start()
- func (gdb *GostDatabase) ThingExists(id interface{}) bool
- type LikeType
- type ParamFactory
- type QueryBuilder
- func (qb *QueryBuilder) CastObservationResult(input string, castTo string) string
- func (qb *QueryBuilder) CreateCountQuery(e1 entities.Entity, e2 entities.Entity, id interface{}, ...) string
- func (qb *QueryBuilder) CreateQuery(e1 entities.Entity, e2 entities.Entity, id interface{}, ...) (string, *QueryParseInfo)
- type QueryParseInfo
- func (q *QueryParseInfo) GetMainQueryParseInfo() *QueryParseInfo
- func (q *QueryParseInfo) GetNextQueryIndex() int
- func (q *QueryParseInfo) GetParent(etl []entities.EntityType) *QueryParseInfo
- func (q *QueryParseInfo) GetQueryIDRelationMap(relationMap map[int]int) map[int]int
- func (q *QueryParseInfo) GetQueryParseInfoByQueryIndex(id int) *QueryParseInfo
- func (q *QueryParseInfo) Init(entityType entities.EntityType, queryIndex int, parent *QueryParseInfo, ...)
- func (q *QueryParseInfo) Parse(values map[string]interface{}) (entities.Entity, error)
- func (q *QueryParseInfo) QueryInfoExists(etl []entities.EntityType) (bool, *QueryParseInfo)
Constants ¶
const (
//TimeFormat describes the format in which we want our DateTime to display
TimeFormat = "YYYY-MM-DD\"T\"HH24:MI:SS.MSZ"
)
Variables ¶
This section is empty.
Functions ¶
func CheckDatastreamRelationsExist ¶
func CheckDatastreamRelationsExist(gdb *GostDatabase, d *entities.Datastream) error
CheckDatastreamRelationsExist check if the related entities exist
func ContainsToLower ¶
func ContainsToLower(s []*godata.SelectItem, e string) bool
ContainsToLower checks a string array, array and given string are set to lower-case
func DeleteEntity ¶
func DeleteEntity(gdb *GostDatabase, id interface{}, entityName string) error
DeleteEntity deletes a record from database for entity
func EntityExists ¶
func EntityExists(gdb *GostDatabase, id interface{}, entityName string) bool
EntityExists checks if entity exists in database
func ExecuteSelect ¶
func ExecuteSelect(db *sql.DB, q *QueryParseInfo, sql string, qo *odata.QueryOptions) ([]entities.Entity, bool, error)
ExecuteSelect executes the select query and creates the retrieved entities
func ExecuteSelectCount ¶
ExecuteSelectCount runs a given count query and returns the value
func GetCreateDatabaseQuery ¶
GetCreateDatabaseQuery returns the database creation script for PostgreSQL
func NewDatabase ¶
func NewDatabase(host string, port int, user string, password string, database string, schema string, ssl bool, maxIdeConns int, maxOpenConns int, maxTop int) models.Database
NewDatabase initialises the PostgreSQL database
host = TCP host:port or Unix socket depending on Network. user = database user password = database password database = name of database ssl = Whether to use secure TCP/IP connections (TLS).
Types ¶
type GostDatabase ¶
type GostDatabase struct { Host string Port int User string Password string Database string Schema string Ssl bool MaxIdeConns int MaxOpenConns int Db *sql.DB QueryBuilder *QueryBuilder }
GostDatabase implementation
func (*GostDatabase) CreateSchema ¶
func (gdb *GostDatabase) CreateSchema(location string) error
CreateSchema creates the needed schema in the database
func (*GostDatabase) DatastreamExists ¶
func (gdb *GostDatabase) DatastreamExists(id int) bool
DatastreamExists checks if a Datastream is present in the database based on a given id
func (*GostDatabase) DeleteDatastream ¶
func (gdb *GostDatabase) DeleteDatastream(id interface{}) error
DeleteDatastream tries to delete a Datastream by the given id
func (*GostDatabase) DeleteFeatureOfInterest ¶
func (gdb *GostDatabase) DeleteFeatureOfInterest(id interface{}) error
DeleteFeatureOfInterest tries to delete a FeatureOfInterest by the given id
func (*GostDatabase) DeleteHistoricalLocation ¶
func (gdb *GostDatabase) DeleteHistoricalLocation(id interface{}) error
DeleteHistoricalLocation tries to delete a HistoricalLocation by the given id
func (*GostDatabase) DeleteLocation ¶
func (gdb *GostDatabase) DeleteLocation(id interface{}) error
DeleteLocation removes a given location from the database
func (*GostDatabase) DeleteObservation ¶
func (gdb *GostDatabase) DeleteObservation(id interface{}) error
DeleteObservation tries to delete a Observation by the given id
func (*GostDatabase) DeleteObservedProperty ¶
func (gdb *GostDatabase) DeleteObservedProperty(id interface{}) error
DeleteObservedProperty tries to delete a ObservedProperty by the given id
func (*GostDatabase) DeleteSensor ¶
func (gdb *GostDatabase) DeleteSensor(id interface{}) error
DeleteSensor tries to delete a Sensor by the given id
func (*GostDatabase) DeleteThing ¶
func (gdb *GostDatabase) DeleteThing(id interface{}) error
DeleteThing tries to delete a Thing by the given id
func (*GostDatabase) FeatureOfInterestExists ¶
func (gdb *GostDatabase) FeatureOfInterestExists(id int) bool
FeatureOfInterestExists checks if a FeatureOfInterest is present in the database based on a given id.
func (*GostDatabase) GetDatastream ¶
func (gdb *GostDatabase) GetDatastream(id interface{}, qo *odata.QueryOptions) (*entities.Datastream, error)
GetDatastream retrieves a datastream by id
func (*GostDatabase) GetDatastreamByObservation ¶
func (gdb *GostDatabase) GetDatastreamByObservation(observationID interface{}, qo *odata.QueryOptions) (*entities.Datastream, error)
GetDatastreamByObservation retrieves a datastream linked to the given observation
func (*GostDatabase) GetDatastreams ¶
func (gdb *GostDatabase) GetDatastreams(qo *odata.QueryOptions) ([]*entities.Datastream, int, bool, error)
GetDatastreams retrieves all datastreams
func (*GostDatabase) GetDatastreamsByObservedProperty ¶
func (gdb *GostDatabase) GetDatastreamsByObservedProperty(oID interface{}, qo *odata.QueryOptions) ([]*entities.Datastream, int, bool, error)
GetDatastreamsByObservedProperty retrieves all datastreams linked to the given ObservedProerty
func (*GostDatabase) GetDatastreamsBySensor ¶
func (gdb *GostDatabase) GetDatastreamsBySensor(sensorID interface{}, qo *odata.QueryOptions) ([]*entities.Datastream, int, bool, error)
GetDatastreamsBySensor retrieves all datastreams linked to the given sensor
func (*GostDatabase) GetDatastreamsByThing ¶
func (gdb *GostDatabase) GetDatastreamsByThing(thingID interface{}, qo *odata.QueryOptions) ([]*entities.Datastream, int, bool, error)
GetDatastreamsByThing retrieves all datastreams linked to the given thing
func (*GostDatabase) GetFeatureOfInterest ¶
func (gdb *GostDatabase) GetFeatureOfInterest(id interface{}, qo *odata.QueryOptions) (*entities.FeatureOfInterest, error)
GetFeatureOfInterest returns a feature of interest by id
func (*GostDatabase) GetFeatureOfInterestByObservation ¶
func (gdb *GostDatabase) GetFeatureOfInterestByObservation(id interface{}, qo *odata.QueryOptions) (*entities.FeatureOfInterest, error)
GetFeatureOfInterestByObservation returns a feature of interest by given observation id
func (*GostDatabase) GetFeatureOfInterestIDByLocationID ¶
func (gdb *GostDatabase) GetFeatureOfInterestIDByLocationID(id interface{}) (interface{}, error)
GetFeatureOfInterestIDByLocationID returns the FeatureOfInterest id in the database where original_location_id equals the given parameter
func (*GostDatabase) GetFeatureOfInterests ¶
func (gdb *GostDatabase) GetFeatureOfInterests(qo *odata.QueryOptions) ([]*entities.FeatureOfInterest, int, bool, error)
GetFeatureOfInterests returns all feature of interests
func (*GostDatabase) GetHistoricalLocation ¶
func (gdb *GostDatabase) GetHistoricalLocation(id interface{}, qo *odata.QueryOptions) (*entities.HistoricalLocation, error)
GetHistoricalLocation retrieves a HistoricalLocation by id
func (*GostDatabase) GetHistoricalLocations ¶
func (gdb *GostDatabase) GetHistoricalLocations(qo *odata.QueryOptions) ([]*entities.HistoricalLocation, int, bool, error)
GetHistoricalLocations retrieves all historicallocations
func (*GostDatabase) GetHistoricalLocationsByLocation ¶
func (gdb *GostDatabase) GetHistoricalLocationsByLocation(locationID interface{}, qo *odata.QueryOptions) ([]*entities.HistoricalLocation, int, bool, error)
GetHistoricalLocationsByLocation retrieves all historicallocations linked to the given location
func (*GostDatabase) GetHistoricalLocationsByThing ¶
func (gdb *GostDatabase) GetHistoricalLocationsByThing(thingID interface{}, qo *odata.QueryOptions) ([]*entities.HistoricalLocation, int, bool, error)
GetHistoricalLocationsByThing retrieves all historicallocations linked to the given thing
func (*GostDatabase) GetLocation ¶
func (gdb *GostDatabase) GetLocation(id interface{}, qo *odata.QueryOptions) (*entities.Location, error)
GetLocation retrieves the location for the given id from the database
func (*GostDatabase) GetLocationByDatastreamID ¶
func (gdb *GostDatabase) GetLocationByDatastreamID(datastreamID interface{}, qo *odata.QueryOptions) (*entities.Location, error)
GetLocationByDatastreamID returns a location linked to an observation todo fix staticcheck error: 'argument qo is overwritten before first use' remove qo parameter? or change function
func (*GostDatabase) GetLocations ¶
func (gdb *GostDatabase) GetLocations(qo *odata.QueryOptions) ([]*entities.Location, int, bool, error)
GetLocations retrieves all locations
func (*GostDatabase) GetLocationsByHistoricalLocation ¶
func (gdb *GostDatabase) GetLocationsByHistoricalLocation(hlID interface{}, qo *odata.QueryOptions) ([]*entities.Location, int, bool, error)
GetLocationsByHistoricalLocation retrieves all locations linked to the given HistoricalLocation
func (*GostDatabase) GetLocationsByThing ¶
func (gdb *GostDatabase) GetLocationsByThing(thingID interface{}, qo *odata.QueryOptions) ([]*entities.Location, int, bool, error)
GetLocationsByThing retrieves all locations linked to the given thing
func (*GostDatabase) GetObservation ¶
func (gdb *GostDatabase) GetObservation(id interface{}, qo *odata.QueryOptions) (*entities.Observation, error)
GetObservation retrieves an observation by id from the database
func (*GostDatabase) GetObservations ¶
func (gdb *GostDatabase) GetObservations(qo *odata.QueryOptions) ([]*entities.Observation, int, bool, error)
GetObservations retrieves all observations
func (*GostDatabase) GetObservationsByDatastream ¶
func (gdb *GostDatabase) GetObservationsByDatastream(dataStreamID interface{}, qo *odata.QueryOptions) ([]*entities.Observation, int, bool, error)
GetObservationsByDatastream retrieves all observations by the given datastream id
func (*GostDatabase) GetObservationsByFeatureOfInterest ¶
func (gdb *GostDatabase) GetObservationsByFeatureOfInterest(foiID interface{}, qo *odata.QueryOptions) ([]*entities.Observation, int, bool, error)
GetObservationsByFeatureOfInterest retrieves all observations by the given FeatureOfInterest id
func (*GostDatabase) GetObservedArea ¶
func (gdb *GostDatabase) GetObservedArea(id int) (map[string]interface{}, error)
GetObservedArea returns the observed area of all observations of datastream
func (*GostDatabase) GetObservedProperties ¶
func (gdb *GostDatabase) GetObservedProperties(qo *odata.QueryOptions) ([]*entities.ObservedProperty, int, bool, error)
GetObservedProperties returns all bool, observed properties
func (*GostDatabase) GetObservedProperty ¶
func (gdb *GostDatabase) GetObservedProperty(id interface{}, qo *odata.QueryOptions) (*entities.ObservedProperty, error)
GetObservedProperty returns an ObservedProperty by id
func (*GostDatabase) GetObservedPropertyByDatastream ¶
func (gdb *GostDatabase) GetObservedPropertyByDatastream(id interface{}, qo *odata.QueryOptions) (*entities.ObservedProperty, error)
GetObservedPropertyByDatastream returns an ObservedProperty by id
func (*GostDatabase) GetSensor ¶
func (gdb *GostDatabase) GetSensor(id interface{}, qo *odata.QueryOptions) (*entities.Sensor, error)
GetSensor return a sensor by id
func (*GostDatabase) GetSensorByDatastream ¶
func (gdb *GostDatabase) GetSensorByDatastream(id interface{}, qo *odata.QueryOptions) (*entities.Sensor, error)
GetSensorByDatastream retrieves a sensor by given datastream
func (*GostDatabase) GetSensors ¶
func (gdb *GostDatabase) GetSensors(qo *odata.QueryOptions) ([]*entities.Sensor, int, bool, error)
GetSensors retrieves all sensors based on the QueryOptions
func (*GostDatabase) GetThing ¶
func (gdb *GostDatabase) GetThing(id interface{}, qo *odata.QueryOptions) (*entities.Thing, error)
GetThing returns a thing entity based on id and query
func (*GostDatabase) GetThingByDatastream ¶
func (gdb *GostDatabase) GetThingByDatastream(id interface{}, qo *odata.QueryOptions) (*entities.Thing, error)
GetThingByDatastream retrieves the thing linked to a datastream
func (*GostDatabase) GetThingByHistoricalLocation ¶
func (gdb *GostDatabase) GetThingByHistoricalLocation(id interface{}, qo *odata.QueryOptions) (*entities.Thing, error)
GetThingByHistoricalLocation retrieves the thing linked to a HistoricalLocation
func (*GostDatabase) GetThings ¶
func (gdb *GostDatabase) GetThings(qo *odata.QueryOptions) ([]*entities.Thing, int, bool, error)
GetThings returns an array of things
func (*GostDatabase) GetThingsByLocation ¶
func (gdb *GostDatabase) GetThingsByLocation(id interface{}, qo *odata.QueryOptions) ([]*entities.Thing, int, bool, error)
GetThingsByLocation retrieves the thing linked to a location
func (*GostDatabase) HistoricalLocationExists ¶
func (gdb *GostDatabase) HistoricalLocationExists(id interface{}) bool
HistoricalLocationExists checks if a HistoricalLocation is present in the database based on a given id
func (*GostDatabase) LinkLocation ¶
func (gdb *GostDatabase) LinkLocation(thingID interface{}, locationID interface{}) error
LinkLocation links a thing with a location fails when a thing or location cannot be found for the given id's
func (*GostDatabase) LocationExists ¶
func (gdb *GostDatabase) LocationExists(id interface{}) bool
LocationExists checks if a location is present in the database based on a given id
func (*GostDatabase) ObservationExists ¶
func (gdb *GostDatabase) ObservationExists(id interface{}) bool
ObservationExists checks if an Observation is present in the database based on a given id.
func (*GostDatabase) ObservedPropertyExists ¶
func (gdb *GostDatabase) ObservedPropertyExists(id interface{}) bool
ObservedPropertyExists checks if a ObservedProperty is present in the database based on a given id.
func (*GostDatabase) PatchDatastream ¶
func (gdb *GostDatabase) PatchDatastream(id interface{}, ds *entities.Datastream) (*entities.Datastream, error)
PatchDatastream updates a Datastream in the database
func (*GostDatabase) PatchFeatureOfInterest ¶
func (gdb *GostDatabase) PatchFeatureOfInterest(id interface{}, foi *entities.FeatureOfInterest) (*entities.FeatureOfInterest, error)
PatchFeatureOfInterest updates a FeatureOfInterest in the database
func (*GostDatabase) PatchHistoricalLocation ¶
func (gdb *GostDatabase) PatchHistoricalLocation(id interface{}, hl *entities.HistoricalLocation) (*entities.HistoricalLocation, error)
PatchHistoricalLocation updates a HistoricalLocation in the database
func (*GostDatabase) PatchLocation ¶
func (gdb *GostDatabase) PatchLocation(id interface{}, l *entities.Location) (*entities.Location, error)
PatchLocation updates a Location in the database
func (*GostDatabase) PatchObservation ¶
func (gdb *GostDatabase) PatchObservation(id interface{}, o *entities.Observation) (*entities.Observation, error)
PatchObservation updates a Observation in the database
func (*GostDatabase) PatchObservedProperty ¶
func (gdb *GostDatabase) PatchObservedProperty(id interface{}, op *entities.ObservedProperty) (*entities.ObservedProperty, error)
PatchObservedProperty updates a ObservedProperty in the database
func (*GostDatabase) PatchSensor ¶
PatchSensor updates a sensor in the database
func (*GostDatabase) PatchThing ¶
PatchThing receives a to be patched Thing entity and changes it in the database returns the patched Thing
func (*GostDatabase) PostDatastream ¶
func (gdb *GostDatabase) PostDatastream(d *entities.Datastream) (*entities.Datastream, error)
PostDatastream posts a datastream
func (*GostDatabase) PostFeatureOfInterest ¶
func (gdb *GostDatabase) PostFeatureOfInterest(f *entities.FeatureOfInterest) (*entities.FeatureOfInterest, error)
PostFeatureOfInterest inserts a new FeatureOfInterest into the database
func (*GostDatabase) PostHistoricalLocation ¶
func (gdb *GostDatabase) PostHistoricalLocation(hl *entities.HistoricalLocation) (*entities.HistoricalLocation, error)
PostHistoricalLocation adds a historical location to the database returns the created historical location including the generated id fails when a thing or location cannot be found for the given id's
func (*GostDatabase) PostLocation ¶
PostLocation receives a posted location entity and adds it to the database returns the created Location including the generated id
func (*GostDatabase) PostObservation ¶
func (gdb *GostDatabase) PostObservation(o *entities.Observation) (*entities.Observation, error)
PostObservation adds an observation to the database
func (*GostDatabase) PostObservedProperty ¶
func (gdb *GostDatabase) PostObservedProperty(op *entities.ObservedProperty) (*entities.ObservedProperty, error)
PostObservedProperty adds an ObservedProperty to the database
func (*GostDatabase) PostSensor ¶
PostSensor posts a sensor to the database
func (*GostDatabase) PostThing ¶
PostThing receives a posted thing entity and adds it to the database returns the created Thing including the generated id
func (*GostDatabase) PutDatastream ¶
func (gdb *GostDatabase) PutDatastream(id interface{}, datastream *entities.Datastream) (*entities.Datastream, error)
PutDatastream receives a Datastream entity and changes it in the database returns the adapted Datastream
func (*GostDatabase) PutFeatureOfInterest ¶
func (gdb *GostDatabase) PutFeatureOfInterest(id interface{}, f *entities.FeatureOfInterest) (*entities.FeatureOfInterest, error)
PutFeatureOfInterest inserts a new FeatureOfInterest into the database
func (*GostDatabase) PutHistoricalLocation ¶
func (gdb *GostDatabase) PutHistoricalLocation(id interface{}, hl *entities.HistoricalLocation) (*entities.HistoricalLocation, error)
PutHistoricalLocation updates a HistoricalLocation in the database
func (*GostDatabase) PutLocation ¶
func (gdb *GostDatabase) PutLocation(id interface{}, location *entities.Location) (*entities.Location, error)
PutLocation receives a Location entity and changes it in the database returns the adapted Location
func (*GostDatabase) PutObservation ¶
func (gdb *GostDatabase) PutObservation(id interface{}, o *entities.Observation) (*entities.Observation, error)
PutObservation replaces an observation to the database
func (*GostDatabase) PutObservedProperty ¶
func (gdb *GostDatabase) PutObservedProperty(id interface{}, op *entities.ObservedProperty) (*entities.ObservedProperty, error)
PutObservedProperty updates a ObservedProperty in the database
func (*GostDatabase) PutSensor ¶
func (gdb *GostDatabase) PutSensor(id interface{}, sensor *entities.Sensor) (*entities.Sensor, error)
PutSensor receives a Sensor entity and changes it in the database returns the Sensor
func (*GostDatabase) PutThing ¶
PutThing receives a Thing entity and changes it in the database returns the adapted Thing
func (*GostDatabase) SensorExists ¶
func (gdb *GostDatabase) SensorExists(id int) bool
SensorExists checks if a sensor is present in the database based on a given id
func (*GostDatabase) ThingExists ¶
func (gdb *GostDatabase) ThingExists(id interface{}) bool
ThingExists checks if a thing is present in the database based on a given id
type ParamFactory ¶
ParamFactory receives a map of columns (with select as names) with values an implementation should parse it to the correct entity
type QueryBuilder ¶
type QueryBuilder struct {
// contains filtered or unexported fields
}
QueryBuilder can construct queries based on entities and QueryOptions
func CreateQueryBuilder ¶
func CreateQueryBuilder(schema string, maxTop int) *QueryBuilder
CreateQueryBuilder instantiates a new queryBuilder, the queryBuilder is used to create select queries based on the given entities, id en QueryOptions (ODATA) schema is the used database schema can be empty, maxTop is the maximum top the query should return
func (*QueryBuilder) CastObservationResult ¶
func (qb *QueryBuilder) CastObservationResult(input string, castTo string) string
CastObservationResult converts an observation result query to a specified type (castTo)
func (*QueryBuilder) CreateCountQuery ¶
func (qb *QueryBuilder) CreateCountQuery(e1 entities.Entity, e2 entities.Entity, id interface{}, queryOptions *odata.QueryOptions) string
CreateCountQuery creates the correct count query based on the given info
e1: entity to get e2: from entity id: e2 == nil: where e1.id = ... | e2 != nil: where e2.id = ...
Returns an empty string if ODATA Query Count is set to false. example: Datastreams(1)/Thing = CreateCountQuery(&entities.Thing, &entities.Datastream, 1, nil)
func (*QueryBuilder) CreateQuery ¶
func (qb *QueryBuilder) CreateQuery(e1 entities.Entity, e2 entities.Entity, id interface{}, queryOptions *odata.QueryOptions) (string, *QueryParseInfo)
CreateQuery creates a new count query based on given input
e1: entity to get e2: from entity id: e2 == nil: where e1.id = ... | e2 != nil: where e2.id = ...
example: Datastreams(1)/Thing = CreateQuery(&entities.Thing, &entities.Datastream, 1, nil)
type QueryParseInfo ¶
type QueryParseInfo struct { QueryIndex int // Order of quest AsPrefix string // Extra AS that gets added to the join string Entity entities.Entity ExpandItem *godata.ExpandItem ParamFactory ParamFactory Parent *QueryParseInfo SubEntities []*QueryParseInfo }
QueryParseInfo is constructed based on the input send to the QueryBuilder, with the help of QueryParseInfo the response rows from the database can be parsed into the correct entities with their relations and sub entities
func (*QueryParseInfo) GetMainQueryParseInfo ¶
func (q *QueryParseInfo) GetMainQueryParseInfo() *QueryParseInfo
GetMainQueryParseInfo returns the first QueryParseInfo from the tree
func (*QueryParseInfo) GetNextQueryIndex ¶
func (q *QueryParseInfo) GetNextQueryIndex() int
GetNextQueryIndex returns the next query index number based on the added entities/sub entities
func (*QueryParseInfo) GetParent ¶
func (q *QueryParseInfo) GetParent(etl []entities.EntityType) *QueryParseInfo
GetParent returns the parent entity for a given list of entity types
func (*QueryParseInfo) GetQueryIDRelationMap ¶
func (q *QueryParseInfo) GetQueryIDRelationMap(relationMap map[int]int) map[int]int
GetQueryIDRelationMap returns the query index relations, ie QueryParseInfo with sub entity datastream thing qid = 0, datastream qid = 1 example: returns [1]0 - datastream (1) relates to thing (0) returns nil if no relation exists
func (*QueryParseInfo) GetQueryParseInfoByQueryIndex ¶
func (q *QueryParseInfo) GetQueryParseInfoByQueryIndex(id int) *QueryParseInfo
GetQueryParseInfoByQueryIndex returns the QueryParseInfo by a given QueryID, this func should be called from the main QueryParseInfo object
func (*QueryParseInfo) Init ¶
func (q *QueryParseInfo) Init(entityType entities.EntityType, queryIndex int, parent *QueryParseInfo, expandItem *godata.ExpandItem)
Init initialises a QueryParseInfo object by setting al the needed info
func (*QueryParseInfo) Parse ¶
func (q *QueryParseInfo) Parse(values map[string]interface{}) (entities.Entity, error)
Parse receives a map containing row names with their values and executes the set ParamFactory to parse the database response into an entity
func (*QueryParseInfo) QueryInfoExists ¶
func (q *QueryParseInfo) QueryInfoExists(etl []entities.EntityType) (bool, *QueryParseInfo)
QueryInfoExists checks if there is already a QueryParseInfo added based on the entity list