diff --git a/back/default_images/type_annimation.svg b/back/default_images/type_annimation.svg
new file mode 100644
index 0000000..e16fb2b
--- /dev/null
+++ b/back/default_images/type_annimation.svg
@@ -0,0 +1,115 @@
+
+
+
diff --git a/back/default_images/type_concert.svg b/back/default_images/type_concert.svg
new file mode 100644
index 0000000..f674391
--- /dev/null
+++ b/back/default_images/type_concert.svg
@@ -0,0 +1,7 @@
+
+
+
+
\ No newline at end of file
diff --git a/back/default_images/type_documentary.svg b/back/default_images/type_documentary.svg
new file mode 100644
index 0000000..86e5f9a
--- /dev/null
+++ b/back/default_images/type_documentary.svg
@@ -0,0 +1,77 @@
+
+
+
+
diff --git a/back/default_images/type_film-short.svg b/back/default_images/type_film-short.svg
new file mode 100644
index 0000000..dbe0708
--- /dev/null
+++ b/back/default_images/type_film-short.svg
@@ -0,0 +1,132 @@
+
+
+
+
\ No newline at end of file
diff --git a/back/default_images/type_film.svg b/back/default_images/type_film.svg
new file mode 100644
index 0000000..69237ec
--- /dev/null
+++ b/back/default_images/type_film.svg
@@ -0,0 +1,118 @@
+
+
+
+
\ No newline at end of file
diff --git a/back/default_images/type_one-man-show.svg b/back/default_images/type_one-man-show.svg
new file mode 100644
index 0000000..5e8b935
--- /dev/null
+++ b/back/default_images/type_one-man-show.svg
@@ -0,0 +1,84 @@
+
+
+
+
\ No newline at end of file
diff --git a/back/default_images/type_opera.svg b/back/default_images/type_opera.svg
new file mode 100644
index 0000000..31d2eff
--- /dev/null
+++ b/back/default_images/type_opera.svg
@@ -0,0 +1,61 @@
+
+
+
diff --git a/back/default_images/type_theater.svg b/back/default_images/type_theater.svg
new file mode 100644
index 0000000..46ad104
--- /dev/null
+++ b/back/default_images/type_theater.svg
@@ -0,0 +1,7 @@
+
+
+
+
\ No newline at end of file
diff --git a/back/default_images/type_tv-show-annimation.svg b/back/default_images/type_tv-show-annimation.svg
new file mode 100644
index 0000000..2179d4f
--- /dev/null
+++ b/back/default_images/type_tv-show-annimation.svg
@@ -0,0 +1,7 @@
+
+
+
+
\ No newline at end of file
diff --git a/back/default_images/type_tv-show.svg b/back/default_images/type_tv-show.svg
new file mode 100644
index 0000000..fd5012f
--- /dev/null
+++ b/back/default_images/type_tv-show.svg
@@ -0,0 +1,82 @@
+
+
+
+
diff --git a/back/src/api/group.py b/back/src/api/group.py
index 4bf5d15..48aea04 100644
--- a/back/src/api/group.py
+++ b/back/src/api/group.py
@@ -40,24 +40,28 @@ def add(_app, _name_api):
"type": "int",
"modifiable": False,
"can_be_null": False,
- "visible": True,
+ },
+ {
+ "name": "type",
+ "type": "string",
+ "modifiable": False,
+ "can_be_null": False,
},
{
"name": "name",
"type": "str",
"modifiable": True,
"can_be_null": False,
- "visible": True,
},
{
"name": "description",
"type": "str",
"modifiable": True,
"can_be_null": False,
- "visible": True,
}
]
data_global_elements.get_interface(_name_api).set_data_model(dataModelBdd)
+ data_global_elements.get_interface(_name_api).set_add_where(" AND type='serie' ")
class DataModel:
name = str
@@ -82,7 +86,9 @@ def add(_app, _name_api):
@doc.consumes(DataModel, location='body')#, required=True)
@doc.response_success(status=201, description='If successful created')
async def create(request):
- return response.json(data_global_elements.get_interface(_name_api).post(request.json))
+ data = request.json
+ data["type"] = 'serie'
+ return response.json(data_global_elements.get_interface(_name_api).post(data))
@elem_blueprint.post('/' + _name_api + "/find", strict_slashes=True)
@doc.summary("Create new resource if the name does not already exist")
@@ -129,22 +135,18 @@ def add(_app, _name_api):
@doc.description("Add a cover data ID to the group.")
@doc.consumes(DataModel, location='body')#, required=True)
@doc.response_success(status=201, description='If successful added')
- async def create(request, id):
+ async def create_cover(request, id):
for type_key in ["data_id"]:
if type_key not in request.json.keys():
raise ServerError("Bad Request: Missing Key '" + type_key + "'", status_code=400)
- # TODO: check if it is a number...
+ data = {}
+ data["node_id"] = id
+ data["data_id"] = request.json["data_id"]
value = data_global_elements.get_interface(_name_api).get(id)
if value == None:
raise ServerError("No data found", status_code=404)
- if "covers" not in value.keys():
- value["covers"] = [];
-
- for elem in value["covers"]:
- if request.json["data_id"] == elem:
- return response.json(elem)
- value["covers"].append(request.json["data_id"]);
- data_global_elements.get_interface(_name_api).set(id, value)
+ data_global_elements.get_interface(data_global_elements.API_COVER).post(data)
+ value = data_global_elements.get_interface(_name_api).get(id)
return response.json(value)
_app.blueprint(elem_blueprint)
diff --git a/back/src/api/saison.py b/back/src/api/saison.py
index fda3e9e..340a7b6 100644
--- a/back/src/api/saison.py
+++ b/back/src/api/saison.py
@@ -64,6 +64,7 @@ def add(_app, _name_api):
},
]
data_global_elements.get_interface(_name_api).set_data_model(dataModelBdd)
+ data_global_elements.get_interface(_name_api).set_add_where(" AND type='saison' ")
class DataModel:
number = int
@@ -83,7 +84,9 @@ def add(_app, _name_api):
@doc.consumes(DataModel, location='body')#, required=True)
@doc.response_success(status=201, description='If successful created')
async def create(request):
- return response.json(data_global_elements.get_interface(_name_api).post(request.json))
+ data = request.json
+ data["type"] = 'saison'
+ return response.json(data_global_elements.get_interface(_name_api).post(data))
@elem_blueprint.post('/' + _name_api + "/find", strict_slashes=True)
@doc.summary("find a season existance")
@@ -131,22 +134,18 @@ def add(_app, _name_api):
@doc.description("Add a cover data ID to the video.")
@doc.consumes(DataModel, location='body')#, required=True)
@doc.response_success(status=201, description='If successful added')
- async def create(request, id):
+ async def create_cover(request, id):
for type_key in ["data_id"]:
if type_key not in request.json.keys():
raise ServerError("Bad Request: Missing Key '" + type_key + "'", status_code=400)
- # TODO: check if it is a number...
+ data = {}
+ data["node_id"] = id
+ data["data_id"] = request.json["data_id"]
value = data_global_elements.get_interface(_name_api).get(id)
if value == None:
raise ServerError("No data found", status_code=404)
- if "covers" not in value.keys():
- value["covers"] = [];
-
- for elem in value["covers"]:
- if request.json["data_id"] == elem:
- return response.json(elem)
- value["covers"].append(request.json["data_id"]);
- data_global_elements.get_interface(_name_api).set(id, value)
+ data_global_elements.get_interface(data_global_elements.API_COVER).post(data)
+ value = data_global_elements.get_interface(_name_api).get(id)
return response.json(value)
_app.blueprint(elem_blueprint)
diff --git a/back/src/api/type.py b/back/src/api/type.py
index 562e82c..4636a8c 100644
--- a/back/src/api/type.py
+++ b/back/src/api/type.py
@@ -58,6 +58,7 @@ def add(_app, _name_api):
},
]
data_global_elements.get_interface(_name_api).set_data_model(dataModelBdd)
+ data_global_elements.get_interface(_name_api).set_add_where(" AND type='type' ")
class DataModel:
name = str
@@ -76,7 +77,9 @@ def add(_app, _name_api):
@doc.consumes(DataModel, location='body')#, required=True)
@doc.response_success(status=201, description='If successful created')
async def create(request):
- return response.json(data_global_elements.get_interface(_name_api).post(request.json))
+ data = request.json
+ data["type"] = 'type'
+ return response.json(data_global_elements.get_interface(_name_api).post(data))
@elem_blueprint.get('/' + _name_api + '/', strict_slashes=True)
@doc.summary("Show resources")
@@ -106,4 +109,23 @@ def add(_app, _name_api):
return response.json({})
raise ServerError("No data found", status_code=404)
+ @elem_blueprint.post('/' + _name_api + "//add_cover", strict_slashes=True)
+ @doc.summary("Add cover on video")
+ @doc.description("Add a cover data ID to the video.")
+ @doc.consumes(DataModel, location='body')#, required=True)
+ @doc.response_success(status=201, description='If successful added')
+ async def create_cover(request, id):
+ for type_key in ["data_id"]:
+ if type_key not in request.json.keys():
+ raise ServerError("Bad Request: Missing Key '" + type_key + "'", status_code=400)
+ data = {}
+ data["node_id"] = id
+ data["data_id"] = request.json["data_id"]
+ value = data_global_elements.get_interface(_name_api).get(id)
+ if value == None:
+ raise ServerError("No data found", status_code=404)
+ data_global_elements.get_interface(data_global_elements.API_COVER).post(data)
+ value = data_global_elements.get_interface(_name_api).get(id)
+ return response.json(value)
+
_app.blueprint(elem_blueprint)
\ No newline at end of file
diff --git a/back/src/api/univers.py b/back/src/api/univers.py
index 732476c..11256b1 100644
--- a/back/src/api/univers.py
+++ b/back/src/api/univers.py
@@ -56,6 +56,7 @@ def add(_app, _name_api):
},
]
data_global_elements.get_interface(_name_api).set_data_model(dataModelBdd)
+ data_global_elements.get_interface(_name_api).set_add_where(" AND type='univers' ")
class DataModel:
name = str
@@ -74,7 +75,9 @@ def add(_app, _name_api):
@doc.consumes(DataModel, location='body')#, required=True)
@doc.response_success(status=201, description='If successful created')
async def create(request):
- return response.json(data_global_elements.get_interface(_name_api).post(request.json))
+ data = request.json
+ data["type"] = 'univers'
+ return response.json(data_global_elements.get_interface(_name_api).post(data))
@elem_blueprint.get('/' + _name_api + '/', strict_slashes=True)
@doc.summary("Show resources")
@@ -109,22 +112,18 @@ def add(_app, _name_api):
@doc.description("Add a cover data ID to the univers.")
@doc.consumes(DataModel, location='body')#, required=True)
@doc.response_success(status=201, description='If successful added')
- async def create(request, id):
+ async def create_cover(request, id):
for type_key in ["data_id"]:
if type_key not in request.json.keys():
raise ServerError("Bad Request: Missing Key '" + type_key + "'", status_code=400)
- # TODO: check if it is a number...
+ data = {}
+ data["node_id"] = id
+ data["data_id"] = request.json["data_id"]
value = data_global_elements.get_interface(_name_api).get(id)
if value == None:
raise ServerError("No data found", status_code=404)
- if "covers" not in value.keys():
- value["covers"] = [];
-
- for elem in value["covers"]:
- if request.json["data_id"] == elem:
- return response.json(elem)
- value["covers"].append(request.json["data_id"]);
- data_global_elements.get_interface(_name_api).set(id, value)
+ data_global_elements.get_interface(data_global_elements.API_COVER).post(data)
+ value = data_global_elements.get_interface(_name_api).get(id)
return response.json(value)
_app.blueprint(elem_blueprint)
\ No newline at end of file
diff --git a/back/src/api/video.py b/back/src/api/video.py
index 9af76b3..51fee8d 100644
--- a/back/src/api/video.py
+++ b/back/src/api/video.py
@@ -153,6 +153,7 @@ def add(_app, _name_api):
},
]
data_global_elements.get_interface(_name_api).set_data_model(dataModelBdd)
+ data_global_elements.get_interface(_name_api).set_add_where(" AND type='media' ")
class DataModel:
type_id = int
@@ -182,22 +183,16 @@ def add(_app, _name_api):
@doc.consumes(DataModel, location='body')#, required=True)
@doc.response_success(status=201, description='If successful created')
async def create(request):
- for type_key in ["data_id","type_id","name"]:
- if type_key not in request.json.keys():
+ data = request.json
+ for type_key in ["data_id","name"]:
+ if type_key not in data.keys():
raise ServerError("Bad Request: Missing Key '" + type_key + "'", status_code=400)
for type_key in ["create_date"]:
- if type_key in request.json.keys():
+ if type_key in data.keys():
raise ServerError("Forbidden: Must not be set Key '" + type_key + "'", status_code=403)
- for type_key in ["saison_id","episode","date","time","univers_id","group_id","description"]:
- if type_key not in request.json.keys():
- request.json[type_key] = None
- request.json["create_date"] = datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z'
#Find if already exist
- list_elem = data_global_elements.get_interface(_name_api).find(["group_id", "data_id"], request.json);
- for elem in list_elem:
- return response.json(elem)
-
- return response.json(data_global_elements.get_interface(_name_api).post(request.json))
+ data["type"] = 'media'
+ return response.json(data_global_elements.get_interface(_name_api).post(data))
@elem_blueprint.get('/' + _name_api + '/', strict_slashes=True)
@doc.summary("Show resources")
@@ -235,22 +230,19 @@ def add(_app, _name_api):
@doc.description("Add a cover data ID to the video.")
@doc.consumes(DataModel, location='body')#, required=True)
@doc.response_success(status=201, description='If successful added')
- async def create(request, id):
+ async def create_cover(request, id):
for type_key in ["data_id"]:
if type_key not in request.json.keys():
raise ServerError("Bad Request: Missing Key '" + type_key + "'", status_code=400)
- # TODO: check if it is a number...
+ data = {}
+ data["node_id"] = id
+ data["data_id"] = request.json["data_id"]
value = data_global_elements.get_interface(_name_api).get(id)
if value == None:
raise ServerError("No data found", status_code=404)
- if "covers" not in value.keys():
- value["covers"] = [];
+ data_global_elements.get_interface(data_global_elements.API_COVER).post(data)
+ value = data_global_elements.get_interface(_name_api).get(id)
- for elem in value["covers"]:
- if request.json["data_id"] == elem:
- return response.json(elem)
- value["covers"].append(request.json["data_id"]);
- data_global_elements.get_interface(_name_api).set(id, value)
return response.json(value)
_app.blueprint(elem_blueprint)
diff --git a/back/src/app_video.py b/back/src/app_video.py
index 053f518..58eefff 100755
--- a/back/src/app_video.py
+++ b/back/src/app_video.py
@@ -66,62 +66,17 @@ if "REST_PORT" not in app.config.keys():
app.blueprint(openapi_blueprint)
app.blueprint(swagger_blueprint)
-
-default_values_type = [
- {
- "id": 0,
- "name": "Documentary",
- "description": "Documentary (annimals, space, earth...)"
- },{
- "id": 1,
- "name": "Movie",
- "description": "Movie with real humans (film)"
- },{
- "id": 2,
- "name": "Annimation",
- "description": "Annimation movies (film)"
- },{
- "id": 3,
- "name": "Short Films",
- "description": "Small movies (less 2 minutes)"
- },{
- "id": 4,
- "name": "tv show",
- "description": "Tv show form old peoples"
- }, {
- "id": 5,
- "name": "Anniation tv show",
- "description": "Tv show form young peoples"
- }, {
- "id": 6,
- "name": "Theater",
- "description": "recorder theater pices"
- }, {
- "id": 7,
- "name": "One man show",
- "description": "Recorded stand up"
- }, {
- "id": 8,
- "name": "Concert",
- "description": "Recorded concert"
- }, {
- "id": 9,
- "name": "Opera",
- "description": "Recorded Opera"
- }
-]
-
-
-def add_interface(_name, _base_name):
- interface = data_interface.DataInterface(_name, _base_name)
+def add_interface(_name, _base_name, _name_view):
+ interface = data_interface.DataInterface(_name, _base_name, _name_view)
data_global_elements.add_interface(_name, interface)
-add_interface(data_global_elements.API_DATA, data_global_elements.API_DATA)
-add_interface(data_global_elements.API_TYPE, data_global_elements.API_TYPE)
-add_interface(data_global_elements.API_UNIVERS, data_global_elements.API_UNIVERS)
-add_interface(data_global_elements.API_GROUP, "grp")
-add_interface(data_global_elements.API_SAISON, data_global_elements.API_SAISON)
-add_interface(data_global_elements.API_VIDEO, data_global_elements.API_VIDEO)
+add_interface(data_global_elements.API_DATA, data_global_elements.API_DATA, "data")
+add_interface(data_global_elements.API_TYPE, "node", "view_type")
+add_interface(data_global_elements.API_UNIVERS, "node", "view_univers")
+add_interface(data_global_elements.API_GROUP, "node", "view_serie")
+add_interface(data_global_elements.API_SAISON, "node", "view_saison")
+add_interface(data_global_elements.API_VIDEO, "media", "view_video")
+add_interface(data_global_elements.API_COVER, data_global_elements.API_COVER, data_global_elements.API_COVER)
import api.root as api_root
api_root.add(app)
diff --git a/back/src/data_global_elements.py b/back/src/data_global_elements.py
index fbe0a7a..e1f560f 100644
--- a/back/src/data_global_elements.py
+++ b/back/src/data_global_elements.py
@@ -60,4 +60,5 @@ API_GROUP = "group"
API_SAISON = "saison"
API_VIDEO = "video"
API_DATA = "data"
+API_COVER = "cover_link"
diff --git a/back/src/data_interface.py b/back/src/data_interface.py
index 4e79fbe..c84767a 100644
--- a/back/src/data_interface.py
+++ b/back/src/data_interface.py
@@ -63,13 +63,15 @@ def is_float(s, authorise):
## @breif Generic interface to access to the BDD (no BDD, direct file IO)
##
class DataInterface():
- def __init__(self, _name, _base_name):
+ def __init__(self, _name, _base_name, _name_view):
self.model = None
self.name = _name
+ self.name_view = _name_view
self.extract_base = "*"
self.base_name = _base_name
self.connection = db.connect_bdd();
self.need_save = False
+ self.where_expand = "";
#self.conn = self.connection.cursor()
def __del__(self):
@@ -77,13 +79,16 @@ class DataInterface():
def set_data_model(self, _data_model):
self.model = _data_model
+ """
self.extract_base = ""
for elem in self.model:
if elem["visible"] == True:
if self.extract_base != "":
self.extract_base += ","
self.extract_base += elem["name"]
-
+ """
+ def set_add_where(self, _expand):
+ self.where_expand = _expand
##
## @brief Mark the current BDD to store all in File system (sync)
##
@@ -103,22 +108,15 @@ class DataInterface():
def gets(self, filter=None):
debug.info("gets " + self.name)
cursor = self.connection.cursor(cursor_factory=RealDictCursor)
- cursor.execute('SELECT ' + self.extract_base + ' FROM ' + self.base_name + ' WHERE deleted = false')
+ cursor.execute('SELECT * FROM ' + self.name_view + '')
results = cursor.fetchall()
#debug.info("gets data = " + json.dumps(results, indent=4))
if filter == None:
return results
debug.warning("BDD does not suppor filter now ...");
+ self.connection.commit()
return results
- def gets_where(self, select, filter=None, order_by=None):
- debug.info("gets " + self.name)
- """
- tmp_list = self.get_sub_list(self.bdd, select)
- tmp_list = self.order_by(tmp_list, order_by)
- return self.filter_object_values(tmp_list, filter);
- """
-
def get(self, _id):
if type(_id) != int:
debug.warning("get wrong input type...")
@@ -128,8 +126,9 @@ class DataInterface():
#results = cursor.fetchall()
#debug.info("display data = " + json.dumps(results, indent=4))
req = (_id,)
- cursor.execute('SELECT ' + self.extract_base + ' FROM ' + self.base_name + ' WHERE deleted=false AND id=%s', req)
+ cursor.execute('SELECT * FROM ' + self.name_view + ' WHERE id=%s', req)
results = cursor.fetchone()
+ self.connection.commit()
#debug.info("get specific data = " + json.dumps(results))
return results;
@@ -137,8 +136,9 @@ class DataInterface():
debug.info("delete " + self.name + ": " + str(_id))
cursor = self.connection.cursor()
req = (_id,)
- cursor.execute('UPDATE ' + self.base_name + ' SET deleted=true WHERE id=%s', req)
+ cursor.execute('UPDATE ' + self.base_name + ' SET deleted=true WHERE id=%s' + self.where_expand, req)
self.mark_to_store();
+ self.connection.commit()
return True
def is_value_modifiable_and_good_type(self, _key, _value):
@@ -168,6 +168,7 @@ class DataInterface():
# The key does not exist ...
debug.warning("The KEY: '" + str(_key) + "' Is not in the list of availlable keys");
raise ServerError("FORBIDDEN The KEY: '" + str(_key) + "' Is not in the list of availlable keys", status_code=403)
+ return False
def put(self, _id, _value):
debug.info("put in " + self.name + ": " + str(_id))
@@ -186,22 +187,40 @@ class DataInterface():
request += " , "
list_data.append(_value[elem])
request += " " + elem + " = %s"
- request += " WHERE id = %s "
+ request += " WHERE id = %s " + self.where_expand
list_data.append(_id)
debug.info("Request executed : '" + request + "'")
cursor.execute(request, list_data)
+
self.mark_to_store();
- return True
+ return self.get(iddd);
def post(self, _value):
debug.info("post " + self.name)
- """
- if self.check_with_model(_value) == False:
- raise ServerError("Corelation with BDD error", status_code=404)
- self.bdd.append(_value)
- """
+ cursor = self.connection.cursor()
+ request = 'INSERT INTO ' + self.base_name
+ list_data = []
+ first = True;
+ aaa = ""
+ bbb = ""
+ for elem in _value.keys():
+ if elem == "id":
+ continue
+ if self.is_value_modifiable_and_good_type(elem, _value[elem]) == False:
+ return;
+ if aaa != "":
+ aaa += " , "
+ if bbb != "":
+ bbb += " , "
+ aaa += elem
+ bbb += "%s"
+ list_data.append(_value[elem])
+ request += " ( " + aaa + ") VALUES ( " + bbb + ") RETURNING id"
+ debug.info("Request executed : '" + request + "'")
+ cursor.execute(request, list_data)
+ id_of_new_row = cursor.fetchone()[0]
self.mark_to_store();
- return _value
+ return self.get(id_of_new_row);
diff --git a/back/transfer_bdd/v0.0...v1.0/create_bdd.py b/back/transfer_bdd/v0.0...v1.0/create_bdd.py
index e960bea..58a5a54 100755
--- a/back/transfer_bdd/v0.0...v1.0/create_bdd.py
+++ b/back/transfer_bdd/v0.0...v1.0/create_bdd.py
@@ -24,11 +24,7 @@ debug.info("create the table:")
c = connection.cursor()
c.execute('''
-DROP TABLE IF EXISTS video;
-DROP TABLE IF EXISTS univers;
-DROP TABLE IF EXISTS saison;
-DROP TABLE IF EXISTS type;
-DROP TABLE IF EXISTS grp;
+DROP TABLE IF EXISTS media;
DROP TABLE IF EXISTS cover_link;
DROP TABLE IF EXISTS node;
DROP TABLE IF EXISTS data;
@@ -37,6 +33,11 @@ DROP SEQUENCE IF EXISTS kar_id_sequence;
''');
connection.commit()
+c.execute('''
+CREATE TYPE node_type AS ENUM ('type', 'univers', 'serie', 'saison', 'media');
+CREATE TYPE age_type AS ENUM ('-', '5', '9', '12', '14', '16', '18');
+''')
+connection.commit()
# Create table
c.execute('''
@@ -91,7 +92,6 @@ BEGIN
IF _id IS NULL THEN
RETURN 1;
END IF;
- eee = 'select 1 FROM ' || quote_ident(_table) || ' WHERE id = ' || _id;
EXECUTE 'select 1 FROM ' || quote_ident(_table) || ' WHERE id = ' || _id INTO vvv;
IF vvv = 1 THEN
RETURN 1;
@@ -103,6 +103,26 @@ $$ LANGUAGE plpgsql;
''')
connection.commit()
+c.execute("""
+CREATE OR REPLACE FUNCTION check_node_exist(_type character, _id INTEGER)
+RETURNS BOOLEAN AS $$
+DECLARE vvv int;
+DECLARE eee text;
+BEGIN
+ IF _id IS NULL THEN
+ RETURN 1;
+ END IF;
+ EXECUTE 'select 1 FROM node WHERE type = ''' || quote_ident(_type) || ''' AND id = ' || _id INTO vvv;
+ IF vvv = 1 THEN
+ RETURN 1;
+ ELSE
+ RETURN 0;
+ END IF;
+END;
+$$ LANGUAGE plpgsql;
+""")
+connection.commit()
+
# Create table
c.execute('''
CREATE TABLE object (
@@ -149,11 +169,15 @@ EXECUTE PROCEDURE trigger_set_timestamp();
''')
connection.commit()
+
+
# Create table
c.execute('''
CREATE TABLE node (
+ type node_type NOT NULL,
name TEXT NOT NULL,
- description TEXT
+ description TEXT,
+ parent_id INTEGER CHECK(check_exist('node', parent_id))
) INHERITS (object);
COMMENT ON TABLE node IS 'Node is a basic element of what must be hierarchie apears.';
COMMENT ON COLUMN node.name IS 'Name of the Node.';
@@ -187,96 +211,159 @@ connection.commit()
# Create table
c.execute('''
-CREATE TABLE grp () INHERITS (node);
-COMMENT ON TABLE grp IS 'Group of the video.';
-''')
-connection.commit()
-
-c.execute('''
-CREATE TRIGGER set_timestamp_grp
-BEFORE UPDATE ON grp
-FOR EACH ROW
-EXECUTE PROCEDURE trigger_set_timestamp();
-''')
-connection.commit()
-
-# Create table
-c.execute('''
-CREATE TABLE saison (
- group_id INTEGER CHECK(check_exist('grp', group_id))
- ) INHERITS (node);
-COMMENT ON TABLE saison IS 'Saison of the video.';
-''')
-connection.commit()
-c.execute('''
-CREATE TRIGGER set_timestamps_saison
-BEFORE UPDATE ON saison
-FOR EACH ROW
-EXECUTE PROCEDURE trigger_set_timestamp();
-''')
-connection.commit()
-
-# Create table
-c.execute('''
-CREATE TABLE type () INHERITS (node);
-COMMENT ON TABLE type IS 'Type of the video.';
-''')
-connection.commit()
-c.execute('''
-CREATE TRIGGER set_timestamp_type
-BEFORE UPDATE ON type
-FOR EACH ROW
-EXECUTE PROCEDURE trigger_set_timestamp();
-''')
-connection.commit()
-
-# Create table
-c.execute('''
-CREATE TABLE univers () INHERITS (node);
-COMMENT ON TABLE univers IS 'Univers of the video.';
-''')
-connection.commit()
-c.execute('''
-CREATE TRIGGER set_timestamp_univers
-BEFORE UPDATE ON univers
-FOR EACH ROW
-EXECUTE PROCEDURE trigger_set_timestamp();
-''')
-connection.commit()
-
-# Create table
-c.execute('''
-CREATE TABLE video (
+CREATE TABLE media (
data_id INTEGER CHECK(check_exist('data', data_id)),
- type_id INTEGER CHECK(check_exist('type', type_id)),
- univers_id INTEGER CHECK(check_exist('univers', univers_id)),
- group_id INTEGER CHECK(check_exist('grp', group_id)),
- saison_id INTEGER CHECK(check_exist('saison', saison_id)),
+ type_id INTEGER CHECK(check_node_exist('type', type_id)),
+ univers_id INTEGER CHECK(check_node_exist('univers', univers_id)),
+ serie_id INTEGER CHECK(check_node_exist('serie', serie_id)),
+ saison_id INTEGER CHECK(check_node_exist('saison', saison_id)),
episode INTEGER CHECK(episode >=0),
date INTEGER CHECK(date > 1850),
time INTEGER CHECK(time >= 0),
- age_limit INTEGER CHECK(age_limit >= 0)
+ age_limit age_type NOT NULL DEFAULT '-'
) INHERITS (node);
-COMMENT ON TABLE video IS 'Video Media that is visible.';
-COMMENT ON COLUMN video.episode IS 'Number of the episode in the saison sequence.';
-COMMENT ON COLUMN video.date IS 'Simple date in years of the creation of the media.';
-COMMENT ON COLUMN video.time IS 'Time in second of the media';
-COMMENT ON COLUMN video.age_limit IS 'Limitation of the age to show the display';
+COMMENT ON TABLE media IS 'Media Media that is visible.';
+COMMENT ON COLUMN media.episode IS 'Number of the episode in the saison sequence.';
+COMMENT ON COLUMN media.date IS 'Simple date in years of the creation of the media.';
+COMMENT ON COLUMN media.time IS 'Time in second of the media';
+COMMENT ON COLUMN media.age_limit IS 'Limitation of the age to show the display ("-" for no limitation)';
''')
# Save (commit) the changes
connection.commit()
c.execute('''
-CREATE TRIGGER set_timestamp_video
-BEFORE UPDATE ON video
+CREATE TRIGGER set_timestamp_media
+BEFORE UPDATE ON media
FOR EACH ROW
EXECUTE PROCEDURE trigger_set_timestamp();
''')
connection.commit()
+
+c.execute('''
+CREATE VIEW view_type AS
+ SELECT id, name, description,
+ array(
+ SELECT data_id
+ FROM cover_link
+ WHERE cover_link.node_id = node.id
+ ) AS covers
+ FROM node
+ WHERE deleted = false AND type = 'type'
+ ORDER BY name;
+CREATE VIEW view_univers AS
+ SELECT id, name, description,
+ array(
+ SELECT data_id
+ FROM cover_link
+ WHERE cover_link.node_id = node.id
+ ) AS covers
+ FROM node
+ WHERE deleted = false AND type = 'univers'
+ ORDER BY name;
+CREATE VIEW view_serie AS
+ SELECT id, name, description,
+ array(
+ SELECT data_id
+ FROM cover_link
+ WHERE cover_link.node_id = node.id
+ ) AS covers
+ FROM node
+ WHERE deleted = false AND type = 'serie'
+ ORDER BY name;
+CREATE VIEW view_saison AS
+ SELECT id, name, description, parent_id,
+ array(
+ SELECT data_id
+ FROM cover_link
+ WHERE cover_link.node_id = node.id
+ ) AS covers
+ FROM node
+ WHERE deleted = false AND type = 'saison'
+ ORDER BY name;
+CREATE VIEW view_video AS
+ SELECT id, name, description, data_id, type_id, univers_id, serie_id, saison_id, episode, date, time, age_limit,
+ array(
+ SELECT data_id
+ FROM cover_link
+ WHERE cover_link.node_id = media.id
+ ) AS covers
+ FROM media
+ WHERE deleted = false AND type = 'media'
+ ORDER BY name;
+''')
+connection.commit()
+
+
+"""
+default_values_type = [
+ {
+ "id": 0,
+ "name": "Documentary",
+ "description": "Documentary (annimals, space, earth...)",
+ "image": "type_documentary.svg"
+ },{
+ "id": 1,
+ "name": "Movie",
+ "description": "Movie with real humans (film)",
+ "image": "type_film.svg"
+ },{
+ "id": 2,
+ "name": "Annimation",
+ "description": "Annimation movies (film)",
+ "image": "type_annimation.svg"
+ },{
+ "id": 3,
+ "name": "Short films",
+ "description": "Small movies (less 2 minutes)",
+ "image": "type_film-short.svg"
+ },{
+ "id": 4,
+ "name": "TV show",
+ "description": "Tv show form old peoples",
+ "image": "type_tv-show.svg"
+ }, {
+ "id": 5,
+ "name": "Anniation tv show",
+ "description": "Tv show form young peoples",
+ "image": "type_tv-show-annimation.svg"
+ }, {
+ "id": 6,
+ "name": "Theater",
+ "description": "recorder theater pices",
+ "image": "type_theater.svg"
+ }, {
+ "id": 7,
+ "name": "One man show",
+ "description": "Recorded stand up",
+ "image": "type_one-man-show.svg"
+ }, {
+ "id": 8,
+ "name": "Concert",
+ "description": "Recorded concert",
+ "image": "type_concert.svg"
+ }, {
+ "id": 9,
+ "name": "Opera",
+ "description": "Recorded Opera",
+ "image": "type_opera.svg"
+ }
+]
+
+for elem in default_values_type:
+ print("add type: " + elem["name"]);
+ request_insert = (elem["name"], elem["description"])
+ c.execute('INSERT INTO node (type, name, description) VALUES (\'type\', %s, %s) RETURNING id', request_insert)
+ elem["id"] = c.fetchone()[0]
+connection.commit()
+"""
+
+
+
# We can also close the connection if we are done with it.
# Just be sure any changes have been committed or they will be lost.
connection.close()
+#exit(0);
print(" =================================================== Send DATA ");
import transfert_data
@@ -293,7 +380,7 @@ saison_mapping = transfert_saison.transfert_db(data_mapping, type_mapping, group
#print(" =================================================== Send UNIVERS ");
#import transfert_univers
#univers_mapping = transfert_univers.transfert_db(data_mapping, type_mapping, group_mapping)
-print(" =================================================== Send VIDEO ");
+print(" =================================================== Send Medias ");
import transfert_video
video_mapping = transfert_video.transfert_db(data_mapping, type_mapping, group_mapping, saison_mapping)
diff --git a/back/transfer_bdd/v0.0...v1.0/transfert_data.py b/back/transfer_bdd/v0.0...v1.0/transfert_data.py
index de5a438..356cddd 100755
--- a/back/transfer_bdd/v0.0...v1.0/transfert_data.py
+++ b/back/transfer_bdd/v0.0...v1.0/transfert_data.py
@@ -57,7 +57,8 @@ def transfert_db():
debug.info("create the table:")
c = connection.cursor()
-
+ file_object = open("data_transfer.txt", "w")
+ file_object2 = open("data_transfer2.txt", "w")
debug.info("insert elements: ")
iii = 0;
for elem in my_old_bdd:
@@ -76,9 +77,14 @@ def transfert_db():
id_of_new_row = c.fetchone()[0]
debug.info("data transform: " + str(id) + " => " + str(id_of_new_row))
out[str(id)] = id_of_new_row
- file_move("media/" + str(id) + "/video", "media2/" + str(id_of_new_row) + "/data")
- file_move("media/" + str(id) + "/meta.json", "media2/" + str(id_of_new_row) + "/meta.json")
-
+ file_object.write("mv \"media2/" + str(id_of_new_row) + "/data\" \"media/" + str(id) + "/video\"\n")
+ file_object.write("mv \"media2/" + str(id_of_new_row) + "/meta.json\" \"media/" + str(id) + "/meta.json\"\n\n")
+ file_object2.write("mv \"media/" + str(id) + "/video\" \"media2/" + str(id_of_new_row) + "/data\"\n")
+ file_object2.write("mv \"media/" + str(id) + "/meta.json\" \"media2/" + str(id_of_new_row) + "/meta.json\"\n\n")
+ #file_move("media/" + str(id) + "/video", "media2/" + str(id_of_new_row) + "/data")
+ #file_move("media/" + str(id) + "/meta.json", "media2/" + str(id_of_new_row) + "/meta.json")
+ file_object.close()
+ file_object2.close()
# Save (commit) the changes
connection.commit()
diff --git a/back/transfer_bdd/v0.0...v1.0/transfert_group.py b/back/transfer_bdd/v0.0...v1.0/transfert_group.py
index f3d1f16..6085003 100755
--- a/back/transfer_bdd/v0.0...v1.0/transfert_group.py
+++ b/back/transfer_bdd/v0.0...v1.0/transfert_group.py
@@ -65,7 +65,7 @@ def transfert_db(data_mapping, type_mapping):
if covers == None:
covers = [];
request_insert = (name, description)
- c.execute('INSERT INTO grp (name, description) VALUES (%s,%s) RETURNING id', request_insert)
+ c.execute('INSERT INTO node (type, name, description) VALUES (\'serie\', %s,%s) RETURNING id', request_insert)
id_of_new_row = c.fetchone()[0]
debug.info("data transform: " + str(id) + " => " + str(id_of_new_row))
out[str(id)] = id_of_new_row
diff --git a/back/transfer_bdd/v0.0...v1.0/transfert_saison.py b/back/transfer_bdd/v0.0...v1.0/transfert_saison.py
index 0fd7bf4..44a0a22 100755
--- a/back/transfer_bdd/v0.0...v1.0/transfert_saison.py
+++ b/back/transfer_bdd/v0.0...v1.0/transfert_saison.py
@@ -63,7 +63,7 @@ def transfert_db(data_mapping, type_mapping, group_mapping):
if covers == None:
covers = [];
request_insert = (name, description, group_mapping[str(group_id)])
- c.execute('INSERT INTO saison (name, description, group_id) VALUES (%s,%s,%s) RETURNING id', request_insert)
+ c.execute('INSERT INTO node (type, name, description, parent_id) VALUES (\'saison\', %s,%s,%s) RETURNING id', request_insert)
id_of_new_row = c.fetchone()[0]
debug.info("data transform: " + str(id) + " => " + str(id_of_new_row))
out[str(id)] = id_of_new_row
diff --git a/back/transfer_bdd/v0.0...v1.0/transfert_type.py b/back/transfer_bdd/v0.0...v1.0/transfert_type.py
index c5ffbef..73dbd73 100755
--- a/back/transfer_bdd/v0.0...v1.0/transfert_type.py
+++ b/back/transfer_bdd/v0.0...v1.0/transfert_type.py
@@ -59,7 +59,7 @@ def transfert_db(data_mapping):
if covers == None:
covers = [];
request_insert = (name, description)
- c.execute('INSERT INTO type (name, description) VALUES (%s,%s) RETURNING id', request_insert)
+ c.execute('INSERT INTO node (type, name, description) VALUES (\'type\', %s, %s) RETURNING id', request_insert)
id_of_new_row = c.fetchone()[0]
debug.info("data transform: " + str(id) + " => " + str(id_of_new_row))
out[str(id)] = id_of_new_row
diff --git a/back/transfer_bdd/v0.0...v1.0/transfert_univers.py b/back/transfer_bdd/v0.0...v1.0/transfert_univers.py
index 9fbb121..80159f5 100755
--- a/back/transfer_bdd/v0.0...v1.0/transfert_univers.py
+++ b/back/transfer_bdd/v0.0...v1.0/transfert_univers.py
@@ -59,7 +59,7 @@ def transfert_db():
if covers == None:
covers = [];
request_insert = (name, description)
- c.execute('INSERT INTO univers (name, description) VALUES (%s,%s) RETURNING id', request_insert)
+ c.execute('INSERT INTO node (type, name, description) VALUES (\'univers\', %s,%s) RETURNING id', request_insert)
id_of_new_row = c.fetchone()[0]
debug.info("data transform: " + str(id) + " => " + str(id_of_new_row))
out[str(id)] = id_of_new_row
diff --git a/back/transfer_bdd/v0.0...v1.0/transfert_video.py b/back/transfer_bdd/v0.0...v1.0/transfert_video.py
index 2ff93bd..7a1e701 100755
--- a/back/transfer_bdd/v0.0...v1.0/transfert_video.py
+++ b/back/transfer_bdd/v0.0...v1.0/transfert_video.py
@@ -103,7 +103,7 @@ def transfert_db(data_mapping, type_mapping, group_mapping, saison_mapping):
else:
time = elem["time"]
request_insert = (time_create, name, description, data_mapping[str(data_id)], type_mapping[str(type_id)], group_mapping[str(group_id)], saison_mapping[str(saison_id)], force_number(date), force_number(episode), time)
- c.execute('INSERT INTO video (create_date, name, description, data_id, type_id, group_id, saison_id, date, episode, time) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) RETURNING id', request_insert)
+ c.execute('INSERT INTO media (type, create_date, name, description, data_id, type_id, serie_id, saison_id, date, episode, time) VALUES (\'media\',%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) RETURNING id', request_insert)
id_of_new_row = c.fetchone()[0]
debug.info("data transform: " + str(id) + " => " + str(id_of_new_row))
diff --git a/front/src/app/component/element-video/element-video.component.ts b/front/src/app/component/element-video/element-video.component.ts
index a4498e1..378b565 100644
--- a/front/src/app/component/element-video/element-video.component.ts
+++ b/front/src/app/component/element-video/element-video.component.ts
@@ -68,7 +68,7 @@ export class ElementVideoComponent implements OnInit {
} else {
self.episode_display = response.episode + " - ";
}
- self.group_id = response.group_id;
+ self.group_id = response.serie_id;
self.saison_id = response.saison_id;
self.data_id = response.data_id;
self.time = response.time;
diff --git a/front/src/app/scene/saison/saison.component.ts b/front/src/app/scene/saison/saison.component.ts
index 638d9f4..4306706 100644
--- a/front/src/app/scene/saison/saison.component.ts
+++ b/front/src/app/scene/saison/saison.component.ts
@@ -48,7 +48,7 @@ export class SaisonComponent implements OnInit {
this.saisonService.get(this.id_saison)
.then(function(response) {
self.name = response.number;
- self.group_id = response.group_id;
+ self.group_id = response.parent_id;
self.description = response.description;
if (response.covers == undefined || response.covers == null || response.covers.length == 0) {
self.cover = null;
diff --git a/front/src/app/scene/video/video.component.ts b/front/src/app/scene/video/video.component.ts
index a916869..b75ea79 100644
--- a/front/src/app/scene/video/video.component.ts
+++ b/front/src/app/scene/video/video.component.ts
@@ -58,7 +58,7 @@ export class VideoComponent implements OnInit {
self.name = response.name;
self.description = response.description;
self.episode = response.episode;
- self.group_id = response.group_id;
+ self.group_id = response.serie_id;
self.saison_id = response.saison_id;
self.data_id = response.data_id;
self.time = response.time;
diff --git a/front/src/app/service/group.service.ts b/front/src/app/service/group.service.ts
index 325aed5..b2c2fe8 100644
--- a/front/src/app/service/group.service.ts
+++ b/front/src/app/service/group.service.ts
@@ -66,7 +66,7 @@ export class GroupService {
return new Promise((resolve, reject) => {
self.bdd.getVideo()
.then(function(response) {
- let data = response.gets_where([["==", "group_id", _id], ["==", "saison_id", null]], ["id"], ["episode", "name"])
+ let data = response.gets_where([["==", "serie_id", _id], ["==", "saison_id", null]], ["id"], ["episode", "name"])
resolve(data);
}).catch(function(response) {
reject(response);
@@ -82,7 +82,7 @@ export class GroupService {
return new Promise((resolve, reject) => {
self.bdd.getSaison()
.then(function(response) {
- let data = response.gets_where([["==", "group_id", _id]], ["id"], ["number"])
+ let data = response.gets_where([["==", "parent_id", _id]], ["id"], ["number"])
if (_select.length == 0) {
resolve(data);
return;
diff --git a/front/src/app/service/type.service.ts b/front/src/app/service/type.service.ts
index 8d6859b..6b8789a 100644
--- a/front/src/app/service/type.service.ts
+++ b/front/src/app/service/type.service.ts
@@ -74,7 +74,7 @@ export class TypeService {
return new Promise((resolve, reject) => {
self.bdd.getVideo()
.then(function(response) {
- let data = response.gets_where([["==", "type_id", _id], ["==", "group_id", null], ["==", "univers_id", null]], ["id"], ["name"]);
+ let data = response.gets_where([["==", "type_id", _id], ["==", "serie_id", null], ["==", "univers_id", null]], ["id"], ["name"]);
resolve(data);
}).catch(function(response) {
reject(response);
@@ -90,7 +90,7 @@ export class TypeService {
return new Promise((resolve, reject) => {
self.bdd.getVideo()
.then(function(response) {
- let data = response.gets_where([["==", "type_id", _id], ["!=", "group_id", null], ["==", "univers_id", null]], ["group_id"], ["name"]);
+ let data = response.gets_where([["==", "type_id", _id], ["!=", "serie_id", null], ["==", "univers_id", null]], ["serie_id"], ["name"]);
if (_select.length == 0) {
resolve(data);
return;
@@ -122,7 +122,7 @@ export class TypeService {
return new Promise((resolve, reject) => {
self.bdd.getVideo()
.then(function(response) {
- let data = response.data.gets_where([["==", "type_id", _id], ["==", "group_id", null], ["==", "univers_id", null]], ["univers_id"], ["name"]);
+ let data = response.data.gets_where([["==", "type_id", _id], ["==", "serie_id", null], ["==", "univers_id", null]], ["univers_id"], ["name"]);
if (_select.length == 0) {
resolve(data);
return;