diff --git a/src/BreCalClient/Resources/Resources.de.resx b/src/BreCalClient/Resources/Resources.de.resx
index 59c71bb..9e42cb4 100644
--- a/src/BreCalClient/Resources/Resources.de.resx
+++ b/src/BreCalClient/Resources/Resources.de.resx
@@ -544,8 +544,9 @@
Für das Tidenfenster müssen beide Zeiten angegeben werden
-
+
Eine Zeiteingabe ist zu weit in der Zukunft
+
Hafen
diff --git a/src/server/BreCal/__init__.py b/src/server/BreCal/__init__.py
index 0d2ff39..288cab0 100644
--- a/src/server/BreCal/__init__.py
+++ b/src/server/BreCal/__init__.py
@@ -52,7 +52,7 @@ def create_app(test_config=None, instance_path=None):
try:
import os
print(f'Instance path = {app.instance_path}')
- os.makedirs(app.instance_path)
+ os.makedirs(app.instance_path, exist_ok=True)
except OSError:
pass
diff --git a/src/server/BreCal/database/sql_queries.py b/src/server/BreCal/database/sql_queries.py
index 5917081..6d2c9d5 100644
--- a/src/server/BreCal/database/sql_queries.py
+++ b/src/server/BreCal/database/sql_queries.py
@@ -10,22 +10,38 @@ def create_sql_query_shipcall_get(options:dict)->str:
options : dict. A dictionary, which must contains the 'past_days' key (int). Determines the range
by which shipcalls are filtered.
"""
- query = ("SELECT s.id as id, ship_id, port_id, type, eta, voyage, etd, arrival_berth_id, departure_berth_id, tug_required, pilot_required, " +
- "flags, s.pier_side, bunkering, replenishing_terminal, replenishing_lock, draft, tidal_window_from, " +
- "tidal_window_to, rain_sensitive_cargo, recommended_tugs, anchored, moored_lock, canceled, evaluation, " +
- "evaluation_message, evaluation_time, evaluation_notifications_sent, s.created as created, s.modified as modified, time_ref_point " +
- "FROM shipcall s " +
- "LEFT JOIN times t ON t.shipcall_id = s.id AND t.participant_type = 8 " +
- "WHERE " +
- "port_id in (SELECT port_id FROM participant_port_map WHERE participant_id = %d)" +
- " AND (" +
- "(type = 1 AND " +
- "((t.id IS NOT NULL AND t.eta_berth >= DATE(NOW() - INTERVAL %d DAY)) OR " +
- "(eta >= DATE(NOW() - INTERVAL %d DAY)))) OR " +
- "((type = 2 OR type = 3) AND " +
- "((t.id IS NOT NULL AND t.etd_berth >= DATE(NOW() - INTERVAL %d DAY)) OR " +
- "(etd >= DATE(NOW() - INTERVAL %d DAY))))) " +
- "ORDER BY eta") % (options["participant_id"], options["past_days"], options["past_days"], options["past_days"], options["past_days"])
+ if "participant_id" not in options: # if no participant_id is given, all shipcalls are selected
+ query = ("SELECT s.id as id, ship_id, port_id, type, eta, voyage, etd, arrival_berth_id, departure_berth_id, tug_required, pilot_required, " +
+ "flags, s.pier_side, bunkering, replenishing_terminal, replenishing_lock, draft, tidal_window_from, " +
+ "tidal_window_to, rain_sensitive_cargo, recommended_tugs, anchored, moored_lock, canceled, evaluation, " +
+ "evaluation_message, evaluation_time, evaluation_notifications_sent, s.created as created, s.modified as modified, time_ref_point " +
+ "FROM shipcall s " +
+ "LEFT JOIN times t ON t.shipcall_id = s.id AND t.participant_type = 8 " +
+ "WHERE " +
+ "(type = 1 AND " +
+ "((t.id IS NOT NULL AND t.eta_berth >= DATE(NOW() - INTERVAL %d DAY)) OR " +
+ "(eta >= DATE(NOW() - INTERVAL %d DAY)))) OR " +
+ "((type = 2 OR type = 3) AND " +
+ "((t.id IS NOT NULL AND t.etd_berth >= DATE(NOW() - INTERVAL %d DAY)) OR " +
+ "(etd >= DATE(NOW() - INTERVAL %d DAY)))) " +
+ "ORDER BY eta") % (options["past_days"], options["past_days"], options["past_days"], options["past_days"])
+ else:
+ query = ("SELECT s.id as id, ship_id, port_id, type, eta, voyage, etd, arrival_berth_id, departure_berth_id, tug_required, pilot_required, " +
+ "flags, s.pier_side, bunkering, replenishing_terminal, replenishing_lock, draft, tidal_window_from, " +
+ "tidal_window_to, rain_sensitive_cargo, recommended_tugs, anchored, moored_lock, canceled, evaluation, " +
+ "evaluation_message, evaluation_time, evaluation_notifications_sent, s.created as created, s.modified as modified, time_ref_point " +
+ "FROM shipcall s " +
+ "LEFT JOIN times t ON t.shipcall_id = s.id AND t.participant_type = 8 " +
+ "WHERE " +
+ "port_id in (SELECT port_id FROM participant_port_map WHERE participant_id = %d)" +
+ " AND (" +
+ "(type = 1 AND " +
+ "((t.id IS NOT NULL AND t.eta_berth >= DATE(NOW() - INTERVAL %d DAY)) OR " +
+ "(eta >= DATE(NOW() - INTERVAL %d DAY)))) OR " +
+ "((type = 2 OR type = 3) AND " +
+ "((t.id IS NOT NULL AND t.etd_berth >= DATE(NOW() - INTERVAL %d DAY)) OR " +
+ "(etd >= DATE(NOW() - INTERVAL %d DAY))))) " +
+ "ORDER BY eta") % (options["participant_id"], options["past_days"], options["past_days"], options["past_days"], options["past_days"])
return query
diff --git a/src/server/BreCal/impl/berths.py b/src/server/BreCal/impl/berths.py
index 0eaa7df..f00a9e8 100644
--- a/src/server/BreCal/impl/berths.py
+++ b/src/server/BreCal/impl/berths.py
@@ -15,10 +15,15 @@ def GetBerths(options):
commands = pydapper.using(pooledConnection)
# only load berths to ports that the participant is assigned to
- query = ("SELECT id, name, `lock`, owner_id, port_id, authority_id, created, modified, deleted FROM berth WHERE " +
- "deleted = 0 AND + "
- "port_id IN (SELECT port_id FROM participant_port_map WHERE participant_id = %d) " +
- "ORDER BY name") % (options["participant_id"])
+ if "participant_id" in options:
+ query = ("SELECT id, name, `lock`, owner_id, port_id, authority_id, created, modified, deleted FROM berth WHERE " +
+ "deleted = 0 AND + "
+ "port_id IN (SELECT port_id FROM participant_port_map WHERE participant_id = %d) " +
+ "ORDER BY name") % (options["participant_id"])
+ else:
+ query = ("SELECT id, name, `lock`, owner_id, port_id, authority_id, created, modified, deleted FROM berth WHERE " +
+ "deleted = 0 ORDER BY name")
+
data = commands.query(query, model=model.Berth)
return json.dumps(data, default=model.obj_dict), 200, {'Content-Type': 'application/json; charset=utf-8'}
diff --git a/src/server/BreCal/impl/participant.py b/src/server/BreCal/impl/participant.py
index 50ba344..0365d8a 100644
--- a/src/server/BreCal/impl/participant.py
+++ b/src/server/BreCal/impl/participant.py
@@ -23,15 +23,21 @@ def GetParticipant(options):
data = commands.query(query, model=model.Participant)
else:
# query = SQLQuery.get_participants()
-
- # list only participants that are assigned to the same ports than participant of caller
- query = ("SELECT p.id as id, name, street, postal_code, city, type, flags, p.created, p.modified, p.deleted " +
- "FROM participant p " +
- "JOIN participant_port_map ON p.id = participant_port_map.participant_id " +
- "WHERE participant_port_map.port_id IN " +
- "(SELECT port_id FROM participant_port_map where participant_id = %d) " +
- "GROUP BY id " +
- "ORDER BY p.name") % options["participant_id"]
+ if "participant_id" in options:
+ # list only participants that are assigned to the same ports than participant of caller
+ query = ("SELECT p.id as id, name, street, postal_code, city, type, flags, p.created, p.modified, p.deleted " +
+ "FROM participant p " +
+ "JOIN participant_port_map ON p.id = participant_port_map.participant_id " +
+ "WHERE participant_port_map.port_id IN " +
+ "(SELECT port_id FROM participant_port_map where participant_id = %d) " +
+ "GROUP BY id " +
+ "ORDER BY p.name") % options["participant_id"]
+ else:
+ query = ("SELECT p.id as id, name, street, postal_code, city, type, flags, p.created, p.modified, p.deleted " +
+ "FROM participant p " +
+ "JOIN participant_port_map ON p.id = participant_port_map.participant_id " +
+ "GROUP BY id " +
+ "ORDER BY p.name")
data = commands.query(query, model=model.Participant)
for participant in data:
diff --git a/src/server/BreCal/schemas/model.py b/src/server/BreCal/schemas/model.py
index c2391f3..b8e80c4 100644
--- a/src/server/BreCal/schemas/model.py
+++ b/src/server/BreCal/schemas/model.py
@@ -216,6 +216,7 @@ class ShipcallSchema(Schema):
id = fields.Integer(required=True)
ship_id = fields.Integer(required=True)
+ port_id = fields.Integer(required=True)
type = fields.Enum(ShipcallType, default=ShipcallType.undefined)
eta = fields.DateTime(required=False, allow_none=True)
voyage = fields.String(allow_none=True, required=False, validate=[validate.Length(max=16)])
diff --git a/src/server/BreCal/validators/input_validation_utils.py b/src/server/BreCal/validators/input_validation_utils.py
index 8c2c2ed..7056f32 100644
--- a/src/server/BreCal/validators/input_validation_utils.py
+++ b/src/server/BreCal/validators/input_validation_utils.py
@@ -26,7 +26,7 @@ def get_participant_id_dictionary():
def get_berth_id_dictionary():
# get all berths
- response,status_code,header = GetBerths(token=None)
+ response,status_code,header = GetBerths(options={})
# build a dictionary of id:item pairs, so one can select the respective participant
berths = json.loads(response)