Created on 03/02/2014 This file includes all the daos that support the access to the data
author: | Weso |
---|
Bases: app.daos.DAO
Dao for auth user entity
Method that returns a country by its given code
Parameters: | username – name of the username requested |
---|---|
Returns: | user with given username |
Method to update an existing auth user, its username will not be changed
Parameters: | auth – user auth to be updated, with updated attributes |
---|
Bases: app.daos.DAO
Dao for country entity
Method that returns a country by its given code
Parameters: | code – iso3 of the country requested |
---|---|
Returns: | country with given iso3 |
Method that returns a country by its given id
Parameters: | code – id of the country requested |
---|---|
Returns: | country with given id |
Returns the list of countries that belong to a region
Parameters: | id – id of the region |
---|---|
Returns: | list of countries |
Returns the countries that have data if they belong to a given region
Parameters: | id – id of the given region |
---|---|
Returns: | list of countries |
Returns the given country that belongs to the given region
Parameters: |
|
---|---|
Returns: | country |
Method to update an existing country, its code will not be changed
Parameters: | country – country to be updated, with updated attributes |
---|
Bases: object
Generic DAO for all classes, only the class is needed
Method to delete an existing element by its code
Parameters: | code – id of the object to be deleted |
---|
Method that returns all countries in the database
Returns: | a collection of all elements |
---|
Method that returns a element by its given code
Parameters: | code – id of the element requested |
---|---|
Returns: | element with the given id |
Method that inserts a new element
Parameters: | object – element to be inserted |
---|
Method to set the database to use
Parameters: | session – session of the database used |
---|
Method to update an existing element, its code will not be changed
Parameters: | object – object to be updated, with updated attributes |
---|
Bases: app.daos.DAO
Dao for indicator entity
Returns the average of values for an indicator given
Parameters: | indicator_id – indicator id of the given indicator |
---|---|
Returns: | average |
Method to get an indicator of a given country
Parameters: |
|
---|
Method to get all the indicators of a given country
Parameters: | iso3 – iso3 code of the given country |
---|---|
Returns: | indicators of the given country |
Returns the indicators of a datasource
Parameters: | datasource_id – datasource id for the given datasource |
---|---|
Returns: | indicators of the given datasource |
Returns indicators that are starred
Returns: | starred indicators |
---|
Bases: app.daos.DAO
Dao for indicator translation entity
Method that deletes the indicator translation by its given code
Parameters: | indicator_id – id of requested indicator |
---|---|
Param: | lang_code: code of the language like: ‘en’, ‘es’, ‘fr’ |
Method that returns translated indicator
Parameters: | indicator_id – id of requested indicator |
---|---|
Param: | lang_code: code of the language like: ‘en’, ‘es’, ‘fr’ |
Returns: | indicator translation |
Method to update an existing indicator translation, its code will not be changed
Parameters: | indicator_translation – updated indicator translation, with updated attributes |
---|
Bases: app.daos.DAO
Returns observations of a given indicator and a given country
Parameters: |
|
---|
Returns the observations of a given indicator
Parameters: | indicator_id – id of the given indicator |
---|---|
Returns: | list of observations |
Returns observations of a given region and a given indicator
Parameters: |
|
---|---|
Returns: | list of observations |
Returns starred indicators of a country
Parameters: | iso3 – iso3 of the given country |
---|---|
Returns: | list of observations |
Returns observations of a given indicator and a given region.
Parameters: |
|
---|---|
Returns: | list of observations |
Bases: app.daos.DAO
Dao for region entity
Returns a list of all regions, countries are not included
Returns: | list of regions |
---|
Method that returns a region by its given code
Parameters: | code – id of the region |
---|---|
Returns: | region with given id |
Method that returns a region by its given code
Parameters: | code – un_code of the region |
---|---|
Returns: | region with given un_ocde |
Returns a list of regions that belong to a given region
Parameters: | id – id of the given region |
---|---|
Returns: | list of regions |
Returns the regions that have data for a given indicator
Parameters: | indicator_id – id of the given indicator |
---|---|
Returns: | list of regions |
Method to update an existing country, its code will not be changed
Parameters: | region – region to be updated, with updated attributes |
---|
Bases: app.daos.DAO
Dao for region translation entity
Method that deletes the region translation by its given code
Parameters: | region_id – id of requested region |
---|---|
Param: | lang_code: code of the language like: ‘en’, ‘es’, ‘fr’ |
Method that returns translated region
Parameters: | region_id – id of requested region |
---|---|
Param: | lang_code: code of the language like: ‘en’, ‘es’, ‘fr’ |
Returns: | region translation |
Method to update an existing region translation, its code will not be changed
Parameters: | region_translation – updated region translation, with updated attributes |
---|
Bases: app.daos.DAO
Dao for topic translation entity
Method that deletes the topic translation by its given code calling the dao
Parameters: | topic_id – id of requested indicator |
---|---|
Param: | lang_code: code of the language like: ‘en’, ‘es’, ‘fr’ |
Method that returns translated topic
Parameters: | topic_id – id of requested topic |
---|---|
Param: | lang_code: code of the language like: ‘en’, ‘es’, ‘fr’ |
Returns: | topic translation |
Method to update an existing country, its code will not be changed
Parameters: | topic_translation – updated topic translation, with updated attributes |
---|
Produce a descending ORDER BY clause element.
e.g.:
from sqlalchemy import desc
stmt = select([users_table]).order_by(desc(users_table.c.name))
will produce SQL as:
SELECT id, name FROM user ORDER BY name DESC
The desc() function is a standalone version of the ColumnElement.desc() method available on all SQL expressions, e.g.:
stmt = select([users_table]).order_by(users_table.c.name.desc())
Parameters: | column – A ColumnElement (e.g. scalar SQL expression) with which to apply the desc() operation. |
---|
See also
asc()
nullsfirst()
nullslast()
Select.order_by()
Updates all the attributes of an object with other object values all attributes beginning with ‘_’ will not be updated
Parameters: |
|
---|
Created on 03/02/2014 This file includes all the services that communicate views.py and daos.py
author: | Weso |
---|
Bases: app.services.GenericService
Service for auth user dao
Bases: app.services.GenericService
Service for country dao
Method that deletes all countries by calling the dao
Attention: | Take care of what you do, all countries will be destroyed |
---|
Returns the country with the given id
Parameters: | id – iso3 of the country to search |
---|---|
Returns: | country |
Returns the countries that belong to the given region
Parameters: | un_code – un_code of the given region |
---|---|
Returns: | list of countries |
Returns the countries that have data and belong to a given region
Parameters: | un_code – un_code of the given region |
---|---|
Returns: | list of countries |
Returns the country that belongs to a given region
Parameters: |
|
---|
Bases: app.services.GenericService
Service for DataSource dao
Bases: app.services.GenericService
Service for Dataset dao
Method that inserts a dataset calling the dao
Parameters: | dataset – dataset to be persisted |
---|
Bases: object
Generic Service, it provides all default methods that could be used with the majority of the daos
Method that deletes the element by its given code calling the dao
Parameters: | code – id of the element to be deleted |
---|
Method that deletes all elements by calling the dao
Attention: | Take care of what you do, all countries will be destroyed |
---|
Method that returns all elements given by the dao
Returns: | collection of elements |
---|
Method that returns element given by the dao
Parameters: | code – usually the id |
---|---|
Returns: | element that owns the given id |
Method that inserts a element calling the dao
Parameters: | object – element to be persisted |
---|
Method that updates the element by calling the dao
Parameters: | object – element to be updated with updated attributes |
---|
Method that updates all the elements given by calling the dao
Params objects: | list of objects to be updated with updated attributes |
---|
Bases: app.services.GenericService
Service for IsPartOf dao
Bases: app.services.GenericService
Service for indicator dao
Returns the values averages of a given indicator
Parameters: | indicator_id – id of the given indicator |
---|---|
Returns: | average |
Returns the indicator with the given id and also that belongs to the given country
Parameters: |
|
---|
Returns the indicators of a given country
Parameters: | iso3 – iso3 code of the given country |
---|---|
Returns: | list of indicators |
Returns the indicators of a given datasource
Parameters: | datasource_id – id of the given datasource |
---|---|
Returns: | list of indicators |
Returns the indicators that are starred
Returns: | list of indicators |
---|
Bases: app.services.GenericService
Service for indicator translation dao
Method that deletes the indicator translation by its given code calling the dao
Parameters: |
|
---|
Method that deletes all indicator translations by calling the dao
Attention: | Take care of what you do, all countries will be destroyed |
---|
Method that returns translated indicator given by the dao
Parameters: |
|
---|---|
Returns: | indicator translation |
Bases: app.services.GenericService
Service for measurement unit dao
Bases: app.services.GenericService
Service for organization dao
Returns observations of a given country and a given indicator
Parameters: |
|
---|---|
Returns: | list of observations |
Returns observations of a given indicator
Parameters: | indicator_id – id of the given indicator |
---|---|
Returns: | list of observations |
Returns observations of a given region and indicator
Parameters: |
|
---|---|
Returns: | list of observations |
Returns observations of starred indicators for a given country
Parameters: |
|
---|---|
Returns: | list of observations |
Returns observations of a given indicator and a given region, with a top
Parameters: |
|
---|---|
Returns: | list of observations |
Bases: app.services.GenericService
Service for organization dao
Bases: app.services.GenericService
Service for region dao
Method that deletes all regions by calling the dao
Attention: | Take care of what you do, all regions will be destroyed |
---|
Returns all regions. Countries are not included
Returns: | list of regions |
---|
Returns the region that owns the given code
Parameters: | code – id of the region to search |
---|
Returns regions that belong to a given region
Parameters: | un_code – un_code of the given region |
---|---|
Returns: | list of regions |
Returns regions with countries that have data for a given indicator
Parameters: | indicator_id – id of the given indicator |
---|---|
Returns: | list of regions |
Bases: app.services.GenericService
Service for region translation dao
Method that deletes the region translation by its given code calling the dao
Parameters: |
|
---|
Method that deletes all region translation by calling the dao
Attention: | Take care of what you do, all countries will be destroyed |
---|
Method that returns translated region given by the dao
Parameters: |
|
---|---|
Returns: | region translation |
Bases: app.services.GenericService
Service for Topic dao
Bases: app.services.GenericService
Service for topic translation dao
Method that deletes the topic translation by its given code calling the dao
Parameters: |
|
---|
Method that deletes all countries by calling the dao
Attention: | Take care of what you do, all topic translations will be destroyed |
---|
Method that returns translated topic given by the dao
Parameters: |
|
---|---|
Returns: | topic translation |
Bases: object
Transaction manager that helps to abstract from the execution
Abstraction for all calls to the dao methods, like command executor
Bases: app.services.GenericService
Service for user dao
Bases: app.services.GenericService
Service for Value dao
Created on 03/02/2014 This file includes some util features like marshalling
author: | Weso |
---|
Bases: object
CSV converter from objects and list
Convert a list to its csv equivalent
Parameters: | elements_list – collection to be converted |
---|---|
Returns: | csv string |
Convert a object to its csv equivalent
Parameters: |
|
---|---|
Returns: | csv string |
Bases: object
Class to convert from a list of dictionaries to a list of objects
Convert a list of dictionaries in a list of objects
Parameters: | given_list – list of dictionaries |
---|---|
Returns: | list of object |
Bases: object
JSON converter from objects and list
Convert a list to its json equivalent
Parameters: | elements_list – list of elements to be converted |
---|---|
Returns: | json array ready be returned as string |
Convert a object to its json equivalent
Parameters: | element – element to be converted |
---|---|
Returns: | json object in string format |
Bases: object
Class to convert from dictionary to object
See: | http://stackoverflow.com/questions/1305532/convert-python-dict-to-object/1305663#1305663 |
---|
Bases: object
XML converter from objects and list
Convert a list to its XML equivalent
Parameters: |
|
---|---|
Returns: | Xml string |
Convert a object to its XML equivalent
Parameters: |
|
---|---|
Returns: | Xml string |
Convert a date field into long format
Parameters: |
|
---|
Return the attributes of an object
Parameters: | object – the object to get attributes from |
---|---|
Returns: | list of attributes |
Check whether a object is of a primitive type or not
Parameters: | thing – object to check if its type is primitive |
---|---|
Returns: | True if it is primitive, else False |
Converts a row of SQLAlchemy into a dictionary
See: | http://stackoverflow.com/questions/1958219/convert-sqlalchemy-row-object-to-python-dict |
---|---|
Parameters: | row – SQLAlchemy row |
Returns: | dictionary |
Created on 03/02/2014 This file includes all the URI implementation and calls
author: | Weso |
---|
Bases: flask_restful.Resource
Auth URI
Bases: flask_restful.Resource
Countries Indicator element URI
Show a indicators by its country id and its indicator id If found Response 200 OK Else Response 404 NOT FOUND
Bases: flask_restful.Resource
More recent indicators of a country collection URI
Show indicators last_update by a given country Response 200 OK
Bases: flask_restful.Resource
Countries Indicator collection URI
List all indicators of a given country Response 200 OK
Bases: flask_restful.Resource
Countries element URI
Show country Response 200 OK
Bases: flask_restful.Resource
Countries collection URI
List all countries Response 200 OK
Bases: flask_restful.Resource
Datasources element URI
Show datasource Response 200 OK
Bases: flask_restful.Resource
Datasource Indicator element URI
Show indicator by its datasource id and indicator id Response 200 OK
Bases: flask_restful.Resource
DataSource Indicator collection URI
List all indicators of a given datasource Response 200 OK
Bases: flask_restful.Resource
DataSource collection URI
List all datasources Response 200 OK
Bases: flask_restful.Resource
Dataset element URI
Show dataset Response 200 OK
Bases: flask_restful.Resource
Dataset collection URI
List all datasets Response 200 OK
Bases: flask_restful.Resource
Delete cache URI
Class to create object without attributes, to be included dynamically
Bases: flask_restful.Resource
Indicators element URI
Show indicator Response 200 OK
Bases: flask_restful.Resource
Indicator average api
Show the average value for a indicator of all countries Response 200 OK
Bases: flask_restful.Resource
Average of indicator observation by period range
Show average of indicator observations Observations will be filtered between two dates, if they are not supplied whole range will be returned Response 200 OK
Bases: flask_restful.Resource
Countries element URI
Show observations by its indicator id and countyr id Observations will be filtered between two dates, if they are not supplied whole range will be returned Response 200 OK
Bases: flask_restful.Resource
Indicator by period element URI
Show observations by its given indicator Observations will be filtered between two dates, if they are not supplied whole range will be returned Response 200 OK
Bases: flask_restful.Resource
Indicator compatible api
Show the compatible indicators of the given indicator Response 200 OK
Bases: flask_restful.Resource
Indicator country tendency element URI
Show indicator tendency for a country and indicator Response 200 OK
Bases: flask_restful.Resource
Indicators collection URI
List all indicators Response 200 OK
Bases: flask_restful.Resource
Indicator regions without data element URI
Show observations by its given indicator Observations will be filtered between two dates, if they are not supplied whole range will be returned Response 200 OK
Bases: flask_restful.Resource
Indicator by period element URI
Show regions with data for the given indicator Response 200 OK
Bases: flask_restful.Resource
Indicator related collection URI
Show related indicators Response 200 OK
Bases: flask_restful.Resource
Indicators starred URI
List starred indicators Response 200 OK
Bases: flask_restful.Resource
Indicator top api
Show top 10 countries with the highest value for a given indicator Response 200 OK
Bases: flask_restful.Resource
Indicators translations element URI
Show indicator translation Response 200 OK
Bases: flask_restful.Resource
Indicators translations collection URI
List all indicators translations Response 200 OK
Bases: flask_restful.Resource
More recent indicator of a country element URI
Show indicator last_update by its country id and indicator id Response 200 OK
Bases: flask_restful.Resource
Measurement unit element URI
Show measurement unit Response 200 OK
Bases: flask_restful.Resource
Measurement unit collection URI
List all measurement untis Response 200 OK
Bases: flask_restful.Resource
Observations element URI
Show observations Response 200 OK
Bases: flask_restful.Resource
Observation by country and starred indicator collection URI
Show observations filtering by country and showed if the indicator is starred. Response 200 OK
Parameters: | iso3 – iso3 of the country to filter |
---|
Bases: flask_restful.Resource
Observations by period element URI
Show observations of one of this given as parameter: * Country as iso3 * Indicator as indicator id * Region as un_code Observations will be filtered between two dates, if they are not supplied whole range will be returned Response 200 OK
Bases: flask_restful.Resource
Observation by two collection URI
Show observations filtering by two ids. It could be one of three next:
- Indicator id and country iso3
- Country iso3 and indicator id
- Region un_code and indicator id
Parameters: |
|
---|
Response 200 OK
Bases: flask_restful.Resource
Observations by two average URI
Show observations average filtering by two ids. It could be one of three next:
- Indicator id and country iso3
- Country iso3 and indicator id
- Region un_code and indicator id
Parameters: |
|
---|
Response 200 OK
Bases: flask_restful.Resource
Observations collection URI
Bases: flask_restful.Resource
Organizations element URI
Show organization Response 200 OK
Bases: flask_restful.Resource
Organizations collection URI
List all organizations Response 200 OK
Bases: flask_restful.Resource
Organizations users element URI
Show a user by its organization id and its user id If found Response 200 OK Else Response 404 NOT FOUND
Bases: flask_restful.Resource
Organizations users collection URI
List all users of a given organization Response 200 OK
Bases: flask_restful.Resource
Regions element URI
Show region Response 200 OK
Bases: flask_restful.Resource
Countries with data by region element URI
Show country that have some observations by a given region (country is_part_of region) Response 200 OK
Bases: flask_restful.Resource
Regions collection URI
List all region Response 200 OK
Bases: flask_restful.Resource
Region translation element URI
Show region translation Response 200 OK
Bases: flask_restful.Resource
Region translation collection URI
List all translations of a region Response 200 OK
Bases: flask_restful.Resource
Countries Indicator element URI
Show country by its region id and its country id Response 200 OK
Bases: flask_restful.Resource
Regions Country collection URI
List all countries of a given region Response 200 OK
Bases: flask_restful.Resource
Regions Region collection URI
List all regions of a given region Response 200 OK
Bases: flask_restful.Resource
Topic element URI
Show topic Response 200 OK
Bases: flask_restful.Resource
Topics Indicator element URI
Show indicators by its topic id and indicator id Response 200 OK
Bases: flask_restful.Resource
Topics Indicator collection URI
List all indicators by a given topic Response 200 OK
Bases: flask_restful.Resource
Topic collection URI
List all topics Response 200 OK
Bases: flask_restful.Resource
Topic translations element URI
Show country topic translation Response 200 OK
Bases: flask_restful.Resource
Topic translations collection URI
List all topic translations Response 200 OK
Bases: flask_restful.Resource
Users element URI
Show user Response 200 OK
Bases: flask_restful.Resource
Users collection URI
List all users Response 200 OK
Bases: flask_restful.Resource
Value element URI
Show value Response 200 OK
Bases: flask_restful.Resource
Value collection URI
Visualization of areachart
Sends a 401 response that enables basic auth
Visualization of barchart
This function is called to check if a username / password combination is valid.
Visualization of donutchart
Filter by region and a top given
Returns: | countries top and top observations |
---|
Filters observations by a given date range
Parameters: |
|
---|---|
Returns: | filtered list of observations |
Return intervals to xAxis on the graphic
Parameters: | times – times collection |
---|---|
Returns: | times in the format of the graphic |
Returns limit and offset in the request, if not provided limit=30 and offset=0
Returns: | limit and offset |
---|
Return observations filtering by two ids. It could be one of three next:
- Indicator id and country iso3
- Country iso3 and indicator id
- Region un_code and indicator id
Parameters: |
|
---|---|
Returns: | Filtered observations |
Returns the regions that belong to another region
Parameters: | id – id of the region |
---|---|
Returns: | list of regions |
Return all the regions with data for a given indicator
Parameters: | id – id of the given indicator |
---|---|
Returns: | list of regions with data |
Returns the lang request
Returns: | language requested by the client if not given en as default |
---|
Create json object through a dict by request parameters given
Parameters: |
|
---|---|
Returns: | json_object, dict to make json.dumps; title, title of the graphic; description, descriptions of the graphic |
Create json object for map through a dict by request parameters given
Parameters: | request – request object from the client |
---|---|
Returns: | json_object, dict to make json.dumps; title, title of the graphic; description, descriptions of the graphic |
Returns a list of observations grouped by years
Parameters: | observations – list of observations to group |
---|---|
Returns: | list of grouped observations |
Main URI with the documentation redirection
Returns if csv is accepted or not
Returns: | True if csv is accepted, False otherwise |
---|
Returns if jsonp is accepted or not
Returns: | True if jsonp is accepted, False otherwise |
---|
Returns if xml is accepted or not
Returns: | True if xml is accepted, False otherwise |
---|
Visualization of linechart
Decorator that allows connections only from localhost, if not it will return a 403 FORBIDDEN error code
Function that allows creating a unique id for every request There was a problem caching and changing arguments of the URL, so this is one possible solution
See: | http://stackoverflow.com/questions/9413566/flask-cache-memoize-url-query-string-parameters-as-well |
---|
Visualization of map
Returns the average of observations values
Parameters: | observations – observations to calculate the average |
---|---|
Returns: | average |
Visualization of piechart
Visualization of polarchart
Reponses with a page containing the requested graphic
Parameters: |
|
---|
Reponses with a page containing the requested graphic
Parameters: |
|
---|
Return response with the content in the format requested Available formats: * JSON * XML * JSONP * CSV
Parameters: |
|
---|---|
Returns: | response in the requested format |
Return response with the content in the format requested Available formats: * JSON * XML * JSONP * CSV
Parameters: |
|
---|---|
Returns: | response in the requested format |
Visualization of scatterchart
Returns the sliced list
Visualization of stackedchart
Statitics URI, json returned
Convert two dates in str format to date object Format: YYYYMMDD
Parameters: |
|
---|---|
Returns: | from_date and to_date equivalent of given in date objects |
Visualization of table
Translate an indicator object into given language
Parameters: |
|
---|
Translate an indicator list into given language
Parameters: | indicators – list of indicators to be translated |
---|
Translate a region object into given language
Parameters: |
|
---|
Translate a region list into given language
Parameters: | regions – list of regions to be translated |
---|
Translate a topic object into given language
Parameters: |
|
---|
Translate a topic list into given language
Parameters: | topics – list of topics to be translated |
---|
Created on 03/02/2014 This file make the setup configuration for the Flask-Server
author: | Weso |
---|