diff --git a/src/RoleEditor/EditBerthDialog.xaml b/src/RoleEditor/EditBerthDialog.xaml
index 78ef683..234b02b 100644
--- a/src/RoleEditor/EditBerthDialog.xaml
+++ b/src/RoleEditor/EditBerthDialog.xaml
@@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:RoleEditor"
mc:Ignorable="d"
- Title="Edit berth" Height="160" Width="450" Loaded="Window_Loaded">
+ Title="Edit berth" Height="188" Width="450" Loaded="Window_Loaded">
@@ -15,25 +15,37 @@
+
-
+
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/RoleEditor/EditBerthDialog.xaml.cs b/src/RoleEditor/EditBerthDialog.xaml.cs
index 41cf0ad..9f1a0a3 100644
--- a/src/RoleEditor/EditBerthDialog.xaml.cs
+++ b/src/RoleEditor/EditBerthDialog.xaml.cs
@@ -16,7 +16,9 @@ namespace RoleEditor
public Berth Berth { get; set; } = new Berth();
- public List Participants { get; } = new List();
+ public List Owners { get; } = new List();
+
+ public List Authorities { get; } = new List();
private void buttonCancel_Click(object sender, RoutedEventArgs e)
{
@@ -28,11 +30,19 @@ namespace RoleEditor
{
this.Berth.Name = this.textBoxName.Text.Trim();
this.Berth.Lock = this.checkBoxLock.IsChecked;
- this.Berth.Participant = this.comboBoxParticipants.SelectedItem as Participant;
- if (this.Berth.Participant != null)
- this.Berth.Participant_Id = this.Berth.Participant.Id;
+
+ this.Berth.Owner = this.comboBoxParticipants.SelectedItem as Participant;
+ if (this.Berth.Owner != null)
+ this.Berth.Owner_Id = this.Berth.Owner.Id;
else
- this.Berth.Participant_Id = null;
+ this.Berth.Owner_Id = null;
+
+ this.Berth.Authority = this.comboBoxAuthorities.SelectedItem as Participant;
+ if (this.Berth.Authority != null)
+ this.Berth.Authority_Id = this.Berth.Authority.Id;
+ else
+ this.Berth.Authority_Id = null;
+
this.DialogResult = true;
this.Close();
}
@@ -40,12 +50,18 @@ namespace RoleEditor
private void Window_Loaded(object sender, RoutedEventArgs e)
{
this.DataContext = this.Berth;
- this.comboBoxParticipants.ItemsSource = this.Participants;
+ this.comboBoxParticipants.ItemsSource = this.Owners;
+ this.comboBoxAuthorities.ItemsSource = this.Authorities;
}
private void buttonResetParticipant_Click(object sender, RoutedEventArgs e)
{
this.comboBoxParticipants.SelectedItem = null;
}
+
+ private void buttonResetAuthority_Click(object sender, RoutedEventArgs e)
+ {
+ this.comboBoxAuthorities.SelectedItem = null;
+ }
}
}
diff --git a/src/RoleEditor/MainWindow.xaml b/src/RoleEditor/MainWindow.xaml
index 67e58e5..7489d21 100644
--- a/src/RoleEditor/MainWindow.xaml
+++ b/src/RoleEditor/MainWindow.xaml
@@ -261,6 +261,7 @@
+
diff --git a/src/RoleEditor/MainWindow.xaml.cs b/src/RoleEditor/MainWindow.xaml.cs
index c3b4cef..9514203 100644
--- a/src/RoleEditor/MainWindow.xaml.cs
+++ b/src/RoleEditor/MainWindow.xaml.cs
@@ -28,6 +28,9 @@ namespace RoleEditor
#region private fields
private readonly ObservableCollection _participants = new ObservableCollection();
+ private readonly ObservableCollection _terminals = new ObservableCollection();
+ private readonly ObservableCollection _authorities = new ObservableCollection();
+
private readonly ObservableCollection _roles = new ObservableCollection();
private readonly ObservableCollection _securables = new ObservableCollection();
private readonly ObservableCollection _users = new ObservableCollection();
@@ -56,8 +59,12 @@ namespace RoleEditor
// load all participants
List participants = await Participant.LoadAll(_dbManager);
- foreach(Participant p in participants)
+ foreach (Participant p in participants)
+ {
_participants.Add(p);
+ if(p.IsTypeFlagSet(Participant.ParticipantType.TERMINAL)) { _terminals.Add(p); }
+ if(p.IsTypeFlagSet(Participant.ParticipantType.PORT_ADMINISTRATION)) { _authorities.Add(p); }
+ }
this.listBoxParticipant.ItemsSource = _participants;
// load all roles
@@ -74,9 +81,13 @@ namespace RoleEditor
foreach (Berth b in await Berth.LoadAll(_dbManager))
{
_berths.Add(b);
- if(b.Participant_Id != null)
+ if (b.Owner_Id != null)
{
- b.Participant = participants.Where( p => p.Id== b.Participant_Id ).FirstOrDefault();
+ b.Owner = participants.Where(p => p.Id == b.Owner_Id).FirstOrDefault();
+ }
+ if (b.Authority_Id != null)
+ {
+ b.Authority = participants.Where(p => p.Id == b.Authority_Id).FirstOrDefault();
}
}
this.dataGridBerths.Initialize();
@@ -173,7 +184,8 @@ namespace RoleEditor
{
EditBerthDialog ebd = new();
ebd.Berth = b;
- ebd.Participants.AddRange(this._participants);
+ ebd.Owners.AddRange(this._terminals);
+ ebd.Authorities.AddRange(this._authorities);
if (ebd.ShowDialog() ?? false)
{
await b.Save(_dbManager);
@@ -188,7 +200,8 @@ namespace RoleEditor
Berth b = new();
EditBerthDialog ebd = new();
ebd.Berth = b;
- ebd.Participants.AddRange(this._participants);
+ ebd.Owners.AddRange(this._terminals);
+ ebd.Authorities.AddRange(this._authorities);
if (ebd.ShowDialog() ?? false)
{
_berths.Add(b);
@@ -634,7 +647,7 @@ namespace RoleEditor
{
if ((p.Name != null) && p.Name.Contains(participant_name, StringComparison.OrdinalIgnoreCase))
{
- b.Participant_Id = p.Id;
+ b.Owner_Id = p.Id;
found_participant = true;
break;
}
@@ -649,7 +662,7 @@ namespace RoleEditor
await p.Save(_dbManager);
_participants.Add(p);
pCounter++;
- b.Participant_Id = p.Id;
+ b.Owner_Id = p.Id;
}
await b.Save(_dbManager);
diff --git a/src/brecal.model/Berth.cs b/src/brecal.model/Berth.cs
index 11d675b..12fed2d 100644
--- a/src/brecal.model/Berth.cs
+++ b/src/brecal.model/Berth.cs
@@ -1,4 +1,7 @@
-using System;
+// Copyright (c) 2023- schick Informatik
+// Description: Model class for berth entity
+
+using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
@@ -16,11 +19,17 @@ namespace brecal.model
public bool? Lock { get; set; }
- public uint? Participant_Id { get; set; }
+ public uint? Owner_Id { get; set; }
- public Participant? Participant { get; set; }
+ public uint? Authority_Id { get; set; }
- public string? Terminal { get { if (Participant != null) return Participant.Name; else return "n/a"; } }
+ public Participant? Owner { get; set; }
+
+ public Participant? Authority { get; set; }
+
+ public string? Terminal { get { if (Owner != null) return Owner.Name; else return "n/a"; } }
+
+ public string? Authority_Text { get { if (Authority != null) return Authority.Name; else return "n/a"; } }
#endregion
@@ -37,7 +46,7 @@ namespace brecal.model
public static void SetLoadQuery(IDbCommand cmd, params object?[] list)
{
- cmd.CommandText = "SELECT id, name, participant_id, `lock`, created, modified FROM berth";
+ cmd.CommandText = "SELECT id, name, owner_id, authority_id, `lock`, created, modified FROM berth";
}
public static List LoadElems(IDataReader reader)
@@ -48,10 +57,11 @@ namespace brecal.model
Berth b = new();
b.Id = (uint)reader.GetInt32(0);
if (!reader.IsDBNull(1)) b.Name = reader.GetString(1);
- if (!reader.IsDBNull(2)) b.Participant_Id = (uint) reader.GetInt32(2);
- if (!reader.IsDBNull(3)) b.Lock = reader.GetBoolean(3);
- if (!reader.IsDBNull(4)) b.Created = reader.GetDateTime(4);
- if (!reader.IsDBNull(5)) b.Modified = reader.GetDateTime(5);
+ if (!reader.IsDBNull(2)) b.Owner_Id = (uint) reader.GetInt32(2);
+ if (!reader.IsDBNull(3)) b.Authority_Id = (uint) reader.GetInt32(3);
+ if (!reader.IsDBNull(4)) b.Lock = reader.GetBoolean(4);
+ if (!reader.IsDBNull(5)) b.Created = reader.GetDateTime(5);
+ if (!reader.IsDBNull(6)) b.Modified = reader.GetDateTime(6);
result.Add(b);
}
return result;
@@ -63,7 +73,7 @@ namespace brecal.model
public override void SetCreate(IDbCommand cmd)
{
- cmd.CommandText = "INSERT INTO berth (participant_id, name, `lock`) VALUES ( @PID, @NAME, @LOCK)";
+ cmd.CommandText = "INSERT INTO berth (owner_id, authority_id, name, `lock`) VALUES ( @PID, @AID, @NAME, @LOCK)";
this.SetParameters(cmd);
}
@@ -79,7 +89,7 @@ namespace brecal.model
public override void SetUpdate(IDbCommand cmd)
{
- cmd.CommandText = "UPDATE berth SET name = @NAME, participant_id = @PID, `lock` = @LOCK WHERE id = @ID";
+ cmd.CommandText = "UPDATE berth SET name = @NAME, owner_id = @PID, authority_id = @AID, `lock` = @LOCK WHERE id = @ID";
this.SetParameters(cmd);
}
@@ -96,9 +106,14 @@ namespace brecal.model
IDbDataParameter pid = cmd.CreateParameter();
pid.ParameterName = "PID";
- pid.Value = this.Participant_Id;
+ pid.Value = this.Owner_Id;
cmd.Parameters.Add(pid);
+ IDbDataParameter aid = cmd.CreateParameter();
+ aid.ParameterName = "AID";
+ aid.Value = this.Authority_Id;
+ cmd.Parameters.Add(aid);
+
IDbDataParameter name = cmd.CreateParameter();
name.ParameterName = "NAME";
name.Value = this.Name;