Skip to content

Commit 5c7f3d0

Browse files
committed
commit
1 parent 2c2006b commit 5c7f3d0

File tree

5 files changed

+27
-48
lines changed

5 files changed

+27
-48
lines changed

src/opengeodeweb_back/geode_functions.py

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# Local application imports
1111
from .geode_objects import geode_objects_dict
1212
from . import utils_functions
13+
from .data import Data
1314

1415

1516
def geode_object_value(geode_object: str):
@@ -41,17 +42,35 @@ def object_priority(geode_object: str, file_absolute_path: str) -> int:
4142
return geode_object_value(geode_object)["object_priority"](file_absolute_path)
4243

4344

44-
def load(geode_object: str, file_absolute_path: str): # La fonction n'est plus utile
45+
def load(geode_object: str, file_absolute_path: str):
4546
return geode_object_value(geode_object)["load"](file_absolute_path)
4647

4748

48-
# c'est le point d'entrée après l'upload et l'inscription dans la database, virer les paramètres de fonctions réutilisants l'id de data afin de simplifier les appels et virer les params également dans les schemas. Corriger ensuite les erreurs dans les routes
49-
def data_file_path(data_id: str) -> str:
49+
def data_file_path(data_id: str, filename: str = None) -> str:
5050
data_folder_path = flask.current_app.config["DATA_FOLDER_PATH"]
51-
return os.path.join(
52-
data_folder_path,
53-
data_id,
54-
)
51+
if filename:
52+
return os.path.join(data_folder_path, data_id, filename)
53+
return os.path.join(data_folder_path, data_id)
54+
55+
56+
# Get data from database using data_id
57+
def get_data_info(data_id: str):
58+
data_entry = Data.query.get(data_id)
59+
if not data_entry:
60+
flask.abort(404, f"Data with id {data_id} not found")
61+
return data_entry
62+
63+
64+
# Using data_id, load data directly
65+
def load_data_by_id(data_id: str):
66+
data_entry = Data.query.get(data_id)
67+
if not data_entry:
68+
flask.abort(404, f"Data with id {data_id} not found")
69+
70+
file_absolute_path = data_file_path(data_id, data_entry.native_file_name)
71+
72+
return load(data_entry.geode_object, file_absolute_path)
73+
5574

5675
def load_data(geode_object: str, data_id: str, filename: str):
5776
file_absolute_path = data_file_path(data_id, filename)

src/opengeodeweb_back/routes/schemas/polygon_attribute_names.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,12 @@
55
],
66
"type": "object",
77
"properties": {
8-
"input_geode_object": {
9-
"type": "string",
10-
"minLength": 1
11-
},
12-
"filename": {
13-
"type": "string",
14-
"minLength": 1
15-
},
168
"id": {
179
"type": "string",
1810
"minLength": 1
1911
}
2012
},
2113
"required": [
22-
"input_geode_object",
23-
"filename",
2414
"id"
2515
],
2616
"additionalProperties": false

src/opengeodeweb_back/routes/schemas/polyhedron_attribute_names.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,12 @@
55
],
66
"type": "object",
77
"properties": {
8-
"input_geode_object": {
9-
"type": "string",
10-
"minLength": 1
11-
},
12-
"filename": {
13-
"type": "string",
14-
"minLength": 1
15-
},
168
"id": {
179
"type": "string",
1810
"minLength": 1
1911
}
2012
},
2113
"required": [
22-
"input_geode_object",
23-
"filename",
2414
"id"
2515
],
2616
"additionalProperties": false

src/opengeodeweb_back/routes/schemas/texture_coordinates.json

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,13 @@
55
],
66
"type": "object",
77
"properties": {
8-
"input_geode_object": {
9-
"type": "string",
10-
"minLength": 1
11-
},
12-
"filename": {
13-
"type": "string",
14-
"minLength": 1
15-
},
168
"id": {
179
"type": "string",
1810
"minLength": 1
1911
}
2012
},
2113
"required": [
22-
"input_geode_object",
23-
"id",
24-
"filename"
14+
"id"
2515
],
2616
"additionalProperties": false
2717
}

src/opengeodeweb_back/routes/schemas/vertex_attribute_names.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,12 @@
55
],
66
"type": "object",
77
"properties": {
8-
"input_geode_object": {
9-
"type": "string",
10-
"minLength": 1
11-
},
12-
"filename": {
13-
"type": "string",
14-
"minLength": 1
15-
},
168
"id": {
179
"type": "string",
1810
"minLength": 1
1911
}
2012
},
2113
"required": [
22-
"input_geode_object",
23-
"filename",
2414
"id"
2515
],
2616
"additionalProperties": false

0 commit comments

Comments
 (0)