saving is possible (again), fixed the nested parameter
This commit is contained in:
parent
dc30fe9c53
commit
c1a2f78a14
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
//----------------------
|
//----------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// Generated REST API Client Code Generator v1.8.4.0 on 04.10.2023 07:39:32
|
// Generated REST API Client Code Generator v1.8.4.0 on 09.10.2023 09:18:15
|
||||||
// Using the tool OpenAPI Generator v7.0.0
|
// Using the tool OpenAPI Generator v7.0.0
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//----------------------
|
//----------------------
|
||||||
@ -3770,7 +3770,7 @@ namespace BreCalClient.misc.Client
|
|||||||
/// <example>
|
/// <example>
|
||||||
/// ApiKeyPrefix["Authorization"] = "Bearer";
|
/// ApiKeyPrefix["Authorization"] = "Bearer";
|
||||||
/// </example>
|
/// </example>
|
||||||
/// … where ApiKey["Authorization"] would then be used to set the value of your bearer token.
|
/// <EFBFBD> where ApiKey["Authorization"] would then be used to set the value of your bearer token.
|
||||||
///
|
///
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// OAuth2 workflows should set tokens via AccessToken.
|
/// OAuth2 workflows should set tokens via AccessToken.
|
||||||
@ -4913,16 +4913,18 @@ namespace BreCalClient.misc.Model
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">id.</param>
|
/// <param name="id">id.</param>
|
||||||
/// <param name="name">name.</param>
|
/// <param name="name">name.</param>
|
||||||
/// <param name="participantId">participantId.</param>
|
/// <param name="ownerId">ownerId.</param>
|
||||||
|
/// <param name="authorityId">authorityId.</param>
|
||||||
/// <param name="varLock">varLock.</param>
|
/// <param name="varLock">varLock.</param>
|
||||||
/// <param name="created">created.</param>
|
/// <param name="created">created.</param>
|
||||||
/// <param name="modified">modified.</param>
|
/// <param name="modified">modified.</param>
|
||||||
/// <param name="deleted">deleted (default to false).</param>
|
/// <param name="deleted">deleted (default to false).</param>
|
||||||
public Berth(int id = default(int), string name = default(string), int? participantId = default(int?), bool? varLock = default(bool?), DateTime created = default(DateTime), DateTime? modified = default(DateTime?), bool deleted = false)
|
public Berth(int id = default(int), string name = default(string), int? ownerId = default(int?), int? authorityId = default(int?), bool? varLock = default(bool?), DateTime created = default(DateTime), DateTime? modified = default(DateTime?), bool deleted = false)
|
||||||
{
|
{
|
||||||
this.Id = id;
|
this.Id = id;
|
||||||
this.Name = name;
|
this.Name = name;
|
||||||
this.ParticipantId = participantId;
|
this.OwnerId = ownerId;
|
||||||
|
this.AuthorityId = authorityId;
|
||||||
this.VarLock = varLock;
|
this.VarLock = varLock;
|
||||||
this.Created = created;
|
this.Created = created;
|
||||||
this.Modified = modified;
|
this.Modified = modified;
|
||||||
@ -4939,10 +4941,15 @@ namespace BreCalClient.misc.Model
|
|||||||
[DataMember(Name = "name", EmitDefaultValue = true)]
|
[DataMember(Name = "name", EmitDefaultValue = true)]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or Sets ParticipantId
|
/// Gets or Sets OwnerId
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataMember(Name = "participant_id", EmitDefaultValue = true)]
|
[DataMember(Name = "owner_id", EmitDefaultValue = true)]
|
||||||
public int? ParticipantId { get; set; }
|
public int? OwnerId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or Sets AuthorityId
|
||||||
|
/// </summary>
|
||||||
|
[DataMember(Name = "authority_id", EmitDefaultValue = true)]
|
||||||
|
public int? AuthorityId { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or Sets VarLock
|
/// Gets or Sets VarLock
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -4973,7 +4980,8 @@ namespace BreCalClient.misc.Model
|
|||||||
sb.Append("class Berth {\n");
|
sb.Append("class Berth {\n");
|
||||||
sb.Append(" Id: ").Append(Id).Append("\n");
|
sb.Append(" Id: ").Append(Id).Append("\n");
|
||||||
sb.Append(" Name: ").Append(Name).Append("\n");
|
sb.Append(" Name: ").Append(Name).Append("\n");
|
||||||
sb.Append(" ParticipantId: ").Append(ParticipantId).Append("\n");
|
sb.Append(" OwnerId: ").Append(OwnerId).Append("\n");
|
||||||
|
sb.Append(" AuthorityId: ").Append(AuthorityId).Append("\n");
|
||||||
sb.Append(" VarLock: ").Append(VarLock).Append("\n");
|
sb.Append(" VarLock: ").Append(VarLock).Append("\n");
|
||||||
sb.Append(" Created: ").Append(Created).Append("\n");
|
sb.Append(" Created: ").Append(Created).Append("\n");
|
||||||
sb.Append(" Modified: ").Append(Modified).Append("\n");
|
sb.Append(" Modified: ").Append(Modified).Append("\n");
|
||||||
@ -5020,9 +5028,14 @@ namespace BreCalClient.misc.Model
|
|||||||
this.Name.Equals(input.Name))
|
this.Name.Equals(input.Name))
|
||||||
) &&
|
) &&
|
||||||
(
|
(
|
||||||
this.ParticipantId == input.ParticipantId ||
|
this.OwnerId == input.OwnerId ||
|
||||||
(this.ParticipantId != null &&
|
(this.OwnerId != null &&
|
||||||
this.ParticipantId.Equals(input.ParticipantId))
|
this.OwnerId.Equals(input.OwnerId))
|
||||||
|
) &&
|
||||||
|
(
|
||||||
|
this.AuthorityId == input.AuthorityId ||
|
||||||
|
(this.AuthorityId != null &&
|
||||||
|
this.AuthorityId.Equals(input.AuthorityId))
|
||||||
) &&
|
) &&
|
||||||
(
|
(
|
||||||
this.VarLock == input.VarLock ||
|
this.VarLock == input.VarLock ||
|
||||||
@ -5058,9 +5071,13 @@ namespace BreCalClient.misc.Model
|
|||||||
{
|
{
|
||||||
hashCode = (hashCode * 59) + this.Name.GetHashCode();
|
hashCode = (hashCode * 59) + this.Name.GetHashCode();
|
||||||
}
|
}
|
||||||
if (this.ParticipantId != null)
|
if (this.OwnerId != null)
|
||||||
{
|
{
|
||||||
hashCode = (hashCode * 59) + this.ParticipantId.GetHashCode();
|
hashCode = (hashCode * 59) + this.OwnerId.GetHashCode();
|
||||||
|
}
|
||||||
|
if (this.AuthorityId != null)
|
||||||
|
{
|
||||||
|
hashCode = (hashCode * 59) + this.AuthorityId.GetHashCode();
|
||||||
}
|
}
|
||||||
if (this.VarLock != null)
|
if (this.VarLock != null)
|
||||||
{
|
{
|
||||||
@ -6153,6 +6170,125 @@ namespace BreCalClient.misc.Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bremen calling API
|
||||||
|
*
|
||||||
|
* Administer DEBRE ship calls, times and notifications
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 0.6.0
|
||||||
|
* Contact: info@textbausteine.net
|
||||||
|
* Generated by: https://github.com/openapitools/openapi-generator.git
|
||||||
|
*/
|
||||||
|
namespace BreCalClient.misc.Model
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Participant assigned to a shipcall with a given role (type)
|
||||||
|
/// </summary>
|
||||||
|
[DataContract(Name = "participant_assignment")]
|
||||||
|
public partial class ParticipantAssignment : IEquatable<ParticipantAssignment>, IValidatableObject
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="ParticipantAssignment" /> class.
|
||||||
|
/// </summary>
|
||||||
|
[JsonConstructorAttribute]
|
||||||
|
protected ParticipantAssignment() { }
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="ParticipantAssignment" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="participantId">participantId (required).</param>
|
||||||
|
/// <param name="type">type (required).</param>
|
||||||
|
public ParticipantAssignment(int participantId = default(int), int type = default(int))
|
||||||
|
{
|
||||||
|
this.ParticipantId = participantId;
|
||||||
|
this.Type = type;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or Sets ParticipantId
|
||||||
|
/// </summary>
|
||||||
|
[DataMember(Name = "participant_id", IsRequired = true, EmitDefaultValue = true)]
|
||||||
|
public int ParticipantId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or Sets Type
|
||||||
|
/// </summary>
|
||||||
|
[DataMember(Name = "type", IsRequired = true, EmitDefaultValue = true)]
|
||||||
|
public int Type { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the string presentation of the object
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>String presentation of the object</returns>
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.Append("class ParticipantAssignment {\n");
|
||||||
|
sb.Append(" ParticipantId: ").Append(ParticipantId).Append("\n");
|
||||||
|
sb.Append(" Type: ").Append(Type).Append("\n");
|
||||||
|
sb.Append("}\n");
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the JSON string presentation of the object
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>JSON string presentation of the object</returns>
|
||||||
|
public virtual string ToJson()
|
||||||
|
{
|
||||||
|
return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if objects are equal
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input">Object to be compared</param>
|
||||||
|
/// <returns>Boolean</returns>
|
||||||
|
public override bool Equals(object input)
|
||||||
|
{
|
||||||
|
return this.Equals(input as ParticipantAssignment);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if ParticipantAssignment instances are equal
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input">Instance of ParticipantAssignment to be compared</param>
|
||||||
|
/// <returns>Boolean</returns>
|
||||||
|
public bool Equals(ParticipantAssignment input)
|
||||||
|
{
|
||||||
|
if (input == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return
|
||||||
|
(
|
||||||
|
this.ParticipantId == input.ParticipantId ||
|
||||||
|
this.ParticipantId.Equals(input.ParticipantId)
|
||||||
|
) &&
|
||||||
|
(
|
||||||
|
this.Type == input.Type ||
|
||||||
|
this.Type.Equals(input.Type)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the hash code
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Hash code</returns>
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
unchecked // Overflow is fine, just wrap
|
||||||
|
{
|
||||||
|
int hashCode = 41;
|
||||||
|
hashCode = (hashCode * 59) + this.ParticipantId.GetHashCode();
|
||||||
|
hashCode = (hashCode * 59) + this.Type.GetHashCode();
|
||||||
|
return hashCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// To validate all properties of the instance
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="validationContext">Validation context</param>
|
||||||
|
/// <returns>Validation Result</returns>
|
||||||
|
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Bremen calling API
|
* Bremen calling API
|
||||||
*
|
*
|
||||||
@ -6513,7 +6649,7 @@ namespace BreCalClient.misc.Model
|
|||||||
/// <param name="participants">participants.</param>
|
/// <param name="participants">participants.</param>
|
||||||
/// <param name="created">created.</param>
|
/// <param name="created">created.</param>
|
||||||
/// <param name="modified">modified.</param>
|
/// <param name="modified">modified.</param>
|
||||||
public Shipcall(int id = default(int), int shipId = default(int), int type = default(int), DateTime eta = default(DateTime), string voyage = default(string), DateTime? etd = default(DateTime?), int? arrivalBerthId = default(int?), int? departureBerthId = default(int?), bool? tugRequired = default(bool?), bool? pilotRequired = default(bool?), int? flags = default(int?), bool? pierSide = default(bool?), bool? bunkering = default(bool?), bool? replenishingTerminal = default(bool?), bool? replenishingLock = default(bool?), float? draft = default(float?), DateTime? tidalWindowFrom = default(DateTime?), DateTime? tidalWindowTo = default(DateTime?), bool? rainSensitiveCargo = default(bool?), int? recommendedTugs = default(int?), bool? anchored = default(bool?), bool? mooredLock = default(bool?), bool? canceled = default(bool?), int? evaluation = default(int?), string evaluationMessage = default(string), List<int> participants = default(List<int>), DateTime created = default(DateTime), DateTime? modified = default(DateTime?))
|
public Shipcall(int id = default(int), int shipId = default(int), int type = default(int), DateTime eta = default(DateTime), string voyage = default(string), DateTime? etd = default(DateTime?), int? arrivalBerthId = default(int?), int? departureBerthId = default(int?), bool? tugRequired = default(bool?), bool? pilotRequired = default(bool?), int? flags = default(int?), bool? pierSide = default(bool?), bool? bunkering = default(bool?), bool? replenishingTerminal = default(bool?), bool? replenishingLock = default(bool?), float? draft = default(float?), DateTime? tidalWindowFrom = default(DateTime?), DateTime? tidalWindowTo = default(DateTime?), bool? rainSensitiveCargo = default(bool?), int? recommendedTugs = default(int?), bool? anchored = default(bool?), bool? mooredLock = default(bool?), bool? canceled = default(bool?), int? evaluation = default(int?), string evaluationMessage = default(string), List<ParticipantAssignment> participants = default(List<ParticipantAssignment>), DateTime created = default(DateTime), DateTime? modified = default(DateTime?))
|
||||||
{
|
{
|
||||||
this.Id = id;
|
this.Id = id;
|
||||||
this.ShipId = shipId;
|
this.ShipId = shipId;
|
||||||
@ -6673,9 +6809,8 @@ namespace BreCalClient.misc.Model
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or Sets Participants
|
/// Gets or Sets Participants
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <example>[1,5,7]</example>
|
|
||||||
[DataMember(Name = "participants", EmitDefaultValue = true)]
|
[DataMember(Name = "participants", EmitDefaultValue = true)]
|
||||||
public List<int> Participants { get; set; }
|
public List<ParticipantAssignment> Participants { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or Sets Created
|
/// Gets or Sets Created
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -7639,4 +7774,3 @@ namespace BreCalClient.misc.Model
|
|||||||
#pragma warning restore CS8073 // The result of the expression is always the same since a value of this type is never equal to 'null'
|
#pragma warning restore CS8073 // The result of the expression is always the same since a value of this type is never equal to 'null'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -332,6 +332,17 @@ components:
|
|||||||
shipcallId:
|
shipcallId:
|
||||||
description: The unique identifier of a ship call
|
description: The unique identifier of a ship call
|
||||||
type: integer
|
type: integer
|
||||||
|
participant_assignment:
|
||||||
|
description: Participant assigned to a shipcall with a given role (type)
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- participant_id
|
||||||
|
- type
|
||||||
|
properties:
|
||||||
|
participant_id:
|
||||||
|
type: integer
|
||||||
|
type:
|
||||||
|
type: integer
|
||||||
shipcall:
|
shipcall:
|
||||||
type: object
|
type: object
|
||||||
required:
|
required:
|
||||||
@ -421,13 +432,7 @@ components:
|
|||||||
participants:
|
participants:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
type: object
|
$ref: "#/components/schemas/participant_assignment"
|
||||||
properties:
|
|
||||||
participant_id:
|
|
||||||
type: integer
|
|
||||||
type:
|
|
||||||
type: integer
|
|
||||||
example: [{ "participant_id" : 1, "type" : 1}, { "participant_id" : 5, "type": 2}, { "participant_id" : 7, "type" : 3} ]
|
|
||||||
created:
|
created:
|
||||||
type: string
|
type: string
|
||||||
format: date-time
|
format: date-time
|
||||||
|
|||||||
@ -163,23 +163,42 @@ namespace BreCalClient
|
|||||||
participant = (Participant?)this.comboBoxAgency.SelectedItem;
|
participant = (Participant?)this.comboBoxAgency.SelectedItem;
|
||||||
if (participant != null)
|
if (participant != null)
|
||||||
{
|
{
|
||||||
this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
|
ParticipantAssignment pa = new()
|
||||||
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.AGENCY] = participant;
|
{
|
||||||
|
ParticipantId = participant.Id,
|
||||||
|
Type = (int)Extensions.ParticipantType.AGENCY
|
||||||
|
};
|
||||||
|
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.AGENCY] = pa;
|
||||||
}
|
}
|
||||||
|
|
||||||
// BSMD and port authority are always added
|
// BSMD and port authority are always added
|
||||||
foreach (Participant p in BreCalLists.Participants)
|
|
||||||
|
// get port authority from berth
|
||||||
|
|
||||||
|
int? berthId = this.ShipcallModel.Shipcall.ArrivalBerthId;
|
||||||
|
if (berthId == null) berthId = this.ShipcallModel.Shipcall.DepartureBerthId;
|
||||||
|
if (berthId != null)
|
||||||
{
|
{
|
||||||
if (p.Type == (int)Extensions.ParticipantType.PORT_ADMINISTRATION)
|
Berth? selectedBerth = BreCalLists.Berths.Find((x) => x.Id == berthId);
|
||||||
|
if (selectedBerth?.AuthorityId != null)
|
||||||
{
|
{
|
||||||
this.ShipcallModel.Shipcall.Participants.Add(p.Id);
|
if (BreCalLists.ParticipantLookupDict.ContainsKey(selectedBerth.AuthorityId.Value))
|
||||||
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.PORT_ADMINISTRATION] = p;
|
{
|
||||||
|
ParticipantAssignment pab = new()
|
||||||
|
{
|
||||||
|
ParticipantId = selectedBerth.AuthorityId.Value,
|
||||||
|
Type = (int)Extensions.ParticipantType.PORT_ADMINISTRATION
|
||||||
|
};
|
||||||
|
this.ShipcallModel.AssignedParticipants[ParticipantType.PORT_ADMINISTRATION] = pab;
|
||||||
}
|
}
|
||||||
if (p.Type == (int)Extensions.ParticipantType.BSMD)
|
|
||||||
{
|
|
||||||
this.ShipcallModel.Shipcall.Participants.Add(p.Id);
|
|
||||||
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.BSMD] = p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ParticipantAssignment pa = new()
|
||||||
|
{
|
||||||
|
ParticipantId = App.Participant.Id,
|
||||||
|
Type = (int)Extensions.ParticipantType.BSMD
|
||||||
|
};
|
||||||
|
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.BSMD] = pa;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,9 +219,9 @@ namespace BreCalClient
|
|||||||
|
|
||||||
if (this.ShipcallModel.Shipcall.Participants == null) this.ShipcallModel.Shipcall.Participants = new();
|
if (this.ShipcallModel.Shipcall.Participants == null) this.ShipcallModel.Shipcall.Participants = new();
|
||||||
|
|
||||||
foreach (int participant_id in this.ShipcallModel.Shipcall.Participants)
|
foreach (ParticipantAssignment participantAssignment in this.ShipcallModel.Shipcall.Participants)
|
||||||
{
|
{
|
||||||
if (((List<Participant>)this.comboBoxAgency.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxAgency.SelectedValue = participant_id;
|
if (((List<Participant>)this.comboBoxAgency.ItemsSource).Any(x => x.Id == participantAssignment.ParticipantId)) this.comboBoxAgency.SelectedValue = participantAssignment.ParticipantId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -98,26 +98,42 @@ namespace BreCalClient
|
|||||||
Participant? participant = (Participant?)this.comboBoxMooring.SelectedItem;
|
Participant? participant = (Participant?)this.comboBoxMooring.SelectedItem;
|
||||||
if (participant != null)
|
if (participant != null)
|
||||||
{
|
{
|
||||||
this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
|
ParticipantAssignment participantAssignment = new() {
|
||||||
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.MOORING] = participant;
|
ParticipantId = participant.Id,
|
||||||
|
Type = (int)Extensions.ParticipantType.MOORING
|
||||||
|
};
|
||||||
|
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.MOORING] = participantAssignment;
|
||||||
}
|
}
|
||||||
|
|
||||||
participant = (Participant?)this.comboBoxPilot.SelectedItem;
|
participant = (Participant?)this.comboBoxPilot.SelectedItem;
|
||||||
if (participant != null)
|
if (participant != null)
|
||||||
{
|
{
|
||||||
this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
|
ParticipantAssignment participantAssignment = new()
|
||||||
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.PILOT] = participant;
|
{
|
||||||
|
ParticipantId = participant.Id,
|
||||||
|
Type = (int)Extensions.ParticipantType.PILOT
|
||||||
|
};
|
||||||
|
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.PILOT] = participantAssignment;
|
||||||
}
|
}
|
||||||
participant = (Participant?)this.comboBoxTerminal.SelectedItem;
|
participant = (Participant?)this.comboBoxTerminal.SelectedItem;
|
||||||
if (participant != null)
|
if (participant != null)
|
||||||
{
|
{
|
||||||
this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
|
ParticipantAssignment participantAssignment = new()
|
||||||
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.TERMINAL] = participant;
|
{
|
||||||
|
ParticipantId = participant.Id,
|
||||||
|
Type = (int)Extensions.ParticipantType.TERMINAL
|
||||||
|
};
|
||||||
|
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.TERMINAL] = participantAssignment;
|
||||||
}
|
}
|
||||||
participant = (Participant?)this.comboBoxTug.SelectedItem;
|
participant = (Participant?)this.comboBoxTug.SelectedItem;
|
||||||
if (participant != null)
|
if (participant != null)
|
||||||
{
|
{
|
||||||
this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
|
ParticipantAssignment participantAssignment = new()
|
||||||
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.TUG] = participant;
|
{
|
||||||
|
ParticipantId = participant.Id,
|
||||||
|
Type = (int)Extensions.ParticipantType.TUG
|
||||||
|
};
|
||||||
|
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.TUG] = participantAssignment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -168,12 +184,12 @@ namespace BreCalClient
|
|||||||
if(!string.IsNullOrEmpty(this.Times.Remarks))
|
if(!string.IsNullOrEmpty(this.Times.Remarks))
|
||||||
this.textBoxRemarks.Text = this.Times.Remarks;
|
this.textBoxRemarks.Text = this.Times.Remarks;
|
||||||
|
|
||||||
foreach (int participant_id in this.ShipcallModel.Shipcall.Participants)
|
foreach (ParticipantAssignment participantAssignment in this.ShipcallModel.Shipcall.Participants)
|
||||||
{
|
{
|
||||||
if (((List<Participant>)this.comboBoxMooring.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxMooring.SelectedValue = participant_id;
|
if (((List<Participant>)this.comboBoxMooring.ItemsSource).Any(x => x.Id == participantAssignment.ParticipantId)) this.comboBoxMooring.SelectedValue = participantAssignment.ParticipantId;
|
||||||
if (((List<Participant>)this.comboBoxPilot.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxPilot.SelectedValue = participant_id;
|
if (((List<Participant>)this.comboBoxPilot.ItemsSource).Any(x => x.Id == participantAssignment.ParticipantId)) this.comboBoxPilot.SelectedValue = participantAssignment.ParticipantId;
|
||||||
if (((List<Participant>)this.comboBoxTerminal.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxTerminal.SelectedValue = participant_id;
|
if (((List<Participant>)this.comboBoxTerminal.ItemsSource).Any(x => x.Id == participantAssignment.ParticipantId)) this.comboBoxTerminal.SelectedValue = participantAssignment.ParticipantId;
|
||||||
if (((List<Participant>)this.comboBoxTug.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxTug.SelectedValue = participant_id;
|
if (((List<Participant>)this.comboBoxTug.ItemsSource).Any(x => x.Id == participantAssignment.ParticipantId)) this.comboBoxTug.SelectedValue = participantAssignment.ParticipantId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -93,26 +93,42 @@ namespace BreCalClient
|
|||||||
Participant? participant = (Participant?)this.comboBoxMooring.SelectedItem;
|
Participant? participant = (Participant?)this.comboBoxMooring.SelectedItem;
|
||||||
if (participant != null)
|
if (participant != null)
|
||||||
{
|
{
|
||||||
this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
|
ParticipantAssignment participantAssignment = new()
|
||||||
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.MOORING] = participant;
|
{
|
||||||
|
ParticipantId = participant.Id,
|
||||||
|
Type = (int)Extensions.ParticipantType.MOORING
|
||||||
|
};
|
||||||
|
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.MOORING] = participantAssignment;
|
||||||
}
|
}
|
||||||
participant = (Participant?)this.comboBoxPilot.SelectedItem;
|
participant = (Participant?)this.comboBoxPilot.SelectedItem;
|
||||||
if (participant != null)
|
if (participant != null)
|
||||||
{
|
{
|
||||||
this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
|
ParticipantAssignment participantAssignment = new()
|
||||||
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.PILOT] = participant;
|
{
|
||||||
|
ParticipantId = participant.Id,
|
||||||
|
Type = (int)Extensions.ParticipantType.PILOT
|
||||||
|
};
|
||||||
|
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.PILOT] = participantAssignment;
|
||||||
}
|
}
|
||||||
participant = (Participant?)this.comboBoxTerminal.SelectedItem;
|
participant = (Participant?)this.comboBoxTerminal.SelectedItem;
|
||||||
if (participant != null)
|
if (participant != null)
|
||||||
{
|
{
|
||||||
this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
|
ParticipantAssignment participantAssignment = new()
|
||||||
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.TERMINAL] = participant;
|
{
|
||||||
|
ParticipantId = participant.Id,
|
||||||
|
Type = (int)Extensions.ParticipantType.TERMINAL
|
||||||
|
};
|
||||||
|
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.TERMINAL] = participantAssignment;
|
||||||
}
|
}
|
||||||
participant = (Participant?)this.comboBoxTug.SelectedItem;
|
participant = (Participant?)this.comboBoxTug.SelectedItem;
|
||||||
if (participant != null)
|
if (participant != null)
|
||||||
{
|
{
|
||||||
this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
|
ParticipantAssignment participantAssignment = new()
|
||||||
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.TUG] = participant;
|
{
|
||||||
|
ParticipantId = participant.Id,
|
||||||
|
Type = (int)Extensions.ParticipantType.TUG
|
||||||
|
};
|
||||||
|
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.TUG] = participantAssignment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,12 +174,12 @@ namespace BreCalClient
|
|||||||
if(!string.IsNullOrEmpty(this.Times.Remarks))
|
if(!string.IsNullOrEmpty(this.Times.Remarks))
|
||||||
this.textBoxRemarks.Text = this.Times.Remarks;
|
this.textBoxRemarks.Text = this.Times.Remarks;
|
||||||
|
|
||||||
foreach (int participant_id in this.ShipcallModel.Shipcall.Participants)
|
foreach (ParticipantAssignment participantAssignment in this.ShipcallModel.Shipcall.Participants)
|
||||||
{
|
{
|
||||||
if (((List<Participant>)this.comboBoxMooring.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxMooring.SelectedValue = participant_id;
|
if (((List<Participant>)this.comboBoxMooring.ItemsSource).Any(x => x.Id == participantAssignment.ParticipantId)) this.comboBoxMooring.SelectedValue = participantAssignment.ParticipantId;
|
||||||
if (((List<Participant>)this.comboBoxPilot.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxPilot.SelectedValue = participant_id;
|
if (((List<Participant>)this.comboBoxPilot.ItemsSource).Any(x => x.Id == participantAssignment.ParticipantId)) this.comboBoxPilot.SelectedValue = participantAssignment.ParticipantId;
|
||||||
if (((List<Participant>)this.comboBoxTerminal.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxTerminal.SelectedValue = participant_id;
|
if (((List<Participant>)this.comboBoxTerminal.ItemsSource).Any(x => x.Id == participantAssignment.ParticipantId)) this.comboBoxTerminal.SelectedValue = participantAssignment.ParticipantId;
|
||||||
if (((List<Participant>)this.comboBoxTug.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxTug.SelectedValue = participant_id;
|
if (((List<Participant>)this.comboBoxTug.ItemsSource).Any(x => x.Id == participantAssignment.ParticipantId)) this.comboBoxTug.SelectedValue = participantAssignment.ParticipantId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -98,26 +98,42 @@ namespace BreCalClient
|
|||||||
Participant? participant = (Participant?)this.comboBoxMooring.SelectedItem;
|
Participant? participant = (Participant?)this.comboBoxMooring.SelectedItem;
|
||||||
if (participant != null)
|
if (participant != null)
|
||||||
{
|
{
|
||||||
this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
|
ParticipantAssignment pa = new()
|
||||||
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.MOORING] = participant;
|
{
|
||||||
|
ParticipantId = participant.Id,
|
||||||
|
Type = (int)Extensions.ParticipantType.MOORING
|
||||||
|
};
|
||||||
|
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.MOORING] = pa;
|
||||||
}
|
}
|
||||||
participant = (Participant?)this.comboBoxPilot.SelectedItem;
|
participant = (Participant?)this.comboBoxPilot.SelectedItem;
|
||||||
if (participant != null)
|
if (participant != null)
|
||||||
{
|
{
|
||||||
this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
|
ParticipantAssignment pa = new()
|
||||||
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.PILOT] = participant;
|
{
|
||||||
|
ParticipantId = participant.Id,
|
||||||
|
Type = (int)Extensions.ParticipantType.PILOT
|
||||||
|
};
|
||||||
|
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.PILOT] = pa;
|
||||||
}
|
}
|
||||||
participant = (Participant?)this.comboBoxTerminal.SelectedItem;
|
participant = (Participant?)this.comboBoxTerminal.SelectedItem;
|
||||||
if (participant != null)
|
if (participant != null)
|
||||||
{
|
{
|
||||||
this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
|
ParticipantAssignment pa = new()
|
||||||
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.TERMINAL] = participant;
|
{
|
||||||
|
ParticipantId = participant.Id,
|
||||||
|
Type = (int)Extensions.ParticipantType.TERMINAL
|
||||||
|
};
|
||||||
|
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.TERMINAL] = pa;
|
||||||
}
|
}
|
||||||
participant = (Participant?)this.comboBoxTug.SelectedItem;
|
participant = (Participant?)this.comboBoxTug.SelectedItem;
|
||||||
if (participant != null)
|
if (participant != null)
|
||||||
{
|
{
|
||||||
this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
|
ParticipantAssignment pa = new()
|
||||||
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.TUG] = participant;
|
{
|
||||||
|
ParticipantId = participant.Id,
|
||||||
|
Type = (int)Extensions.ParticipantType.TUG
|
||||||
|
};
|
||||||
|
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.TUG] = pa;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -175,12 +191,12 @@ namespace BreCalClient
|
|||||||
if(!string.IsNullOrEmpty(this.Times.Remarks))
|
if(!string.IsNullOrEmpty(this.Times.Remarks))
|
||||||
this.textBoxRemarks.Text = this.Times.Remarks;
|
this.textBoxRemarks.Text = this.Times.Remarks;
|
||||||
|
|
||||||
foreach (int participant_id in this.ShipcallModel.Shipcall.Participants)
|
foreach (ParticipantAssignment participantAssignment in this.ShipcallModel.Shipcall.Participants)
|
||||||
{
|
{
|
||||||
if (((List<Participant>)this.comboBoxMooring.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxMooring.SelectedValue = participant_id;
|
if (((List<Participant>)this.comboBoxMooring.ItemsSource).Any(x => x.Id == participantAssignment.ParticipantId)) this.comboBoxMooring.SelectedValue = participantAssignment.ParticipantId;
|
||||||
if (((List<Participant>)this.comboBoxPilot.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxPilot.SelectedValue = participant_id;
|
if (((List<Participant>)this.comboBoxPilot.ItemsSource).Any(x => x.Id == participantAssignment.ParticipantId)) this.comboBoxPilot.SelectedValue = participantAssignment.ParticipantId;
|
||||||
if (((List<Participant>)this.comboBoxTerminal.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxTerminal.SelectedValue = participant_id;
|
if (((List<Participant>)this.comboBoxTerminal.ItemsSource).Any(x => x.Id == participantAssignment.ParticipantId)) this.comboBoxTerminal.SelectedValue = participantAssignment.ParticipantId;
|
||||||
if (((List<Participant>)this.comboBoxTug.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxTug.SelectedValue = participant_id;
|
if (((List<Participant>)this.comboBoxTug.ItemsSource).Any(x => x.Id == participantAssignment.ParticipantId)) this.comboBoxTug.SelectedValue = participantAssignment.ParticipantId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -172,6 +172,9 @@ namespace BreCalClient
|
|||||||
{
|
{
|
||||||
this.UpdateUI();
|
this.UpdateUI();
|
||||||
|
|
||||||
|
esc.ShipcallModel.Shipcall?.Participants.Clear();
|
||||||
|
foreach (ParticipantAssignment pa in esc.ShipcallModel.AssignedParticipants.Values)
|
||||||
|
esc.ShipcallModel.Shipcall?.Participants.Add(pa);
|
||||||
this._api.ShipcallsPost(esc.ShipcallModel.Shipcall); // save new ship call
|
this._api.ShipcallsPost(esc.ShipcallModel.Shipcall); // save new ship call
|
||||||
this.AddShipcall(esc.ShipcallModel);
|
this.AddShipcall(esc.ShipcallModel);
|
||||||
|
|
||||||
@ -365,7 +368,7 @@ namespace BreCalClient
|
|||||||
scm.Ship = BreCalLists.ShipLookupDict[shipcall.ShipId];
|
scm.Ship = BreCalLists.ShipLookupDict[shipcall.ShipId];
|
||||||
if (BreCalLists.BerthLookupDict.ContainsKey(shipcall.ArrivalBerthId ?? 0))
|
if (BreCalLists.BerthLookupDict.ContainsKey(shipcall.ArrivalBerthId ?? 0))
|
||||||
scm.Berth = BreCalLists.BerthLookupDict[shipcall.ArrivalBerthId ?? 0].Name;
|
scm.Berth = BreCalLists.BerthLookupDict[shipcall.ArrivalBerthId ?? 0].Name;
|
||||||
scm.AssignParticipants(BreCalLists.Participants);
|
scm.AssignParticipants();
|
||||||
|
|
||||||
this.Dispatcher.Invoke(() =>
|
this.Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
@ -390,7 +393,7 @@ namespace BreCalClient
|
|||||||
scm.Ship = BreCalLists.ShipLookupDict[shipcall.ShipId];
|
scm.Ship = BreCalLists.ShipLookupDict[shipcall.ShipId];
|
||||||
if (BreCalLists.BerthLookupDict.ContainsKey(shipcall.ArrivalBerthId ?? 0))
|
if (BreCalLists.BerthLookupDict.ContainsKey(shipcall.ArrivalBerthId ?? 0))
|
||||||
scm.Berth = BreCalLists.BerthLookupDict[shipcall.ArrivalBerthId ?? 0].Name;
|
scm.Berth = BreCalLists.BerthLookupDict[shipcall.ArrivalBerthId ?? 0].Name;
|
||||||
scm.AssignParticipants(BreCalLists.Participants);
|
scm.AssignParticipants();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RemoveShipcall(int shipcallId)
|
private void RemoveShipcall(int shipcallId)
|
||||||
@ -533,6 +536,9 @@ namespace BreCalClient
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
obj.ShipcallControlModel.Shipcall?.Participants.Clear();
|
||||||
|
foreach(ParticipantAssignment pa in obj.ShipcallControlModel.AssignedParticipants.Values)
|
||||||
|
obj.ShipcallControlModel.Shipcall?.Participants.Add(pa);
|
||||||
await _api.ShipcallsPutAsync(obj.ShipcallControlModel.Shipcall);
|
await _api.ShipcallsPutAsync(obj.ShipcallControlModel.Shipcall);
|
||||||
obj.RefreshData();
|
obj.RefreshData();
|
||||||
_refreshImmediately = true;
|
_refreshImmediately = true;
|
||||||
@ -637,6 +643,9 @@ namespace BreCalClient
|
|||||||
|
|
||||||
sc.ShipcallControlModel?.Times.Add(editControl.Times);
|
sc.ShipcallControlModel?.Times.Add(editControl.Times);
|
||||||
}
|
}
|
||||||
|
editControl.ShipcallModel.Shipcall?.Participants.Clear();
|
||||||
|
foreach (ParticipantAssignment pa in editControl.ShipcallModel.AssignedParticipants.Values)
|
||||||
|
editControl.ShipcallModel.Shipcall?.Participants.Add(pa);
|
||||||
await _api.ShipcallsPutAsync(editControl.ShipcallModel.Shipcall);
|
await _api.ShipcallsPutAsync(editControl.ShipcallModel.Shipcall);
|
||||||
_refreshImmediately = true;
|
_refreshImmediately = true;
|
||||||
_tokenSource.Cancel();
|
_tokenSource.Cancel();
|
||||||
|
|||||||
@ -47,7 +47,7 @@ namespace BreCalClient
|
|||||||
|
|
||||||
public string? Berth { get; set; }
|
public string? Berth { get; set; }
|
||||||
|
|
||||||
internal Dictionary<Extensions.ParticipantType, Participant> AssignedParticipants { get; } = new();
|
internal Dictionary<Extensions.ParticipantType, ParticipantAssignment> AssignedParticipants { get; } = new();
|
||||||
|
|
||||||
public List<Times> Times { get; set; } = new();
|
public List<Times> Times { get; set; } = new();
|
||||||
|
|
||||||
@ -79,22 +79,14 @@ namespace BreCalClient
|
|||||||
|
|
||||||
#region public methods
|
#region public methods
|
||||||
|
|
||||||
public void AssignParticipants(List<Participant> participants)
|
public void AssignParticipants()
|
||||||
{
|
{
|
||||||
this.AssignedParticipants.Clear();
|
this.AssignedParticipants.Clear();
|
||||||
if (Shipcall != null)
|
if (Shipcall != null)
|
||||||
{
|
{
|
||||||
foreach (int participantId in Shipcall.Participants)
|
foreach (ParticipantAssignment participantAssignment in Shipcall.Participants)
|
||||||
{
|
{
|
||||||
Participant? participant = participants.Find((x) => x.Id == participantId);
|
AssignedParticipants[(Extensions.ParticipantType)participantAssignment.Type] = participantAssignment;
|
||||||
if (participant != null)
|
|
||||||
{
|
|
||||||
foreach(Extensions.ParticipantType participantType in Enum.GetValues(typeof(Extensions.ParticipantType)))
|
|
||||||
{
|
|
||||||
if(participant.IsTypeFlagSet(participantType))
|
|
||||||
AssignedParticipants[participantType] = participant;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,7 +95,7 @@ namespace BreCalClient
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (AssignedParticipants.ContainsKey(type)) {
|
if (AssignedParticipants.ContainsKey(type)) {
|
||||||
int participantId = AssignedParticipants[type].Id;
|
int participantId = AssignedParticipants[type].ParticipantId;
|
||||||
foreach (Times times in this.Times)
|
foreach (Times times in this.Times)
|
||||||
{
|
{
|
||||||
if ((times.ParticipantId == participantId) && (times.ParticipantType == (int) type))
|
if ((times.ParticipantId == participantId) && (times.ParticipantType == (int) type))
|
||||||
@ -145,11 +137,9 @@ namespace BreCalClient
|
|||||||
|
|
||||||
internal Participant? GetParticipantForType(Extensions.ParticipantType participantType)
|
internal Participant? GetParticipantForType(Extensions.ParticipantType participantType)
|
||||||
{
|
{
|
||||||
foreach(Participant p in AssignedParticipants.Values)
|
if(AssignedParticipants.ContainsKey(participantType) && BreCalLists.ParticipantLookupDict.ContainsKey(AssignedParticipants[participantType].ParticipantId))
|
||||||
{
|
return BreCalLists.ParticipantLookupDict[AssignedParticipants[participantType].ParticipantId];
|
||||||
if (p.IsTypeFlagSet(participantType))
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,8 @@ def GetShipcalls(options):
|
|||||||
participant_query = "SELECT participant_id, type FROM shipcall_participant_map WHERE shipcall_id=?shipcall_id?";
|
participant_query = "SELECT participant_id, type FROM shipcall_participant_map WHERE shipcall_id=?shipcall_id?";
|
||||||
for record in commands.query(participant_query, model=dict, param={"shipcall_id" : shipcall.id}, buffered=False):
|
for record in commands.query(participant_query, model=dict, param={"shipcall_id" : shipcall.id}, buffered=False):
|
||||||
# model.Participant_Assignment = model.Participant_Assignment()
|
# model.Participant_Assignment = model.Participant_Assignment()
|
||||||
shipcall.participants.append(record["participant_id"])
|
pa = model.Participant_Assignment(record["participant_id"], record["type"])
|
||||||
|
shipcall.participants.append(pa)
|
||||||
|
|
||||||
pooledConnection.close()
|
pooledConnection.close()
|
||||||
|
|
||||||
@ -93,11 +94,9 @@ def PostShipcalls(schemaModel):
|
|||||||
new_id = commands.execute_scalar("select last_insert_id()")
|
new_id = commands.execute_scalar("select last_insert_id()")
|
||||||
|
|
||||||
# add participant assignments
|
# add participant assignments
|
||||||
# TODO: make sure there are not two participants of the same type
|
pquery = "INSERT INTO shipcall_participant_map (shipcall_id, participant_id, type) VALUES (?shipcall_id?, ?participant_id?, ?type?)"
|
||||||
|
for participant_assignment in schemaModel["participants"]:
|
||||||
pquery = "INSERT INTO shipcall_participant_map (shipcall_id, participant_id) VALUES (?shipcall_id?, ?participant_id?)"
|
commands.execute(pquery, param={"shipcall_id" : new_id, "participant_id" : participant_assignment["participant_id"], "type" : participant_assignment["type"]})
|
||||||
for participant_id in schemaModel["participants"]:
|
|
||||||
commands.execute(pquery, param={"shipcall_id" : new_id, "participant_id" : participant_id})
|
|
||||||
|
|
||||||
pooledConnection.close()
|
pooledConnection.close()
|
||||||
|
|
||||||
@ -154,27 +153,26 @@ def PutShipcalls(schemaModel):
|
|||||||
query += "WHERE id = ?id?"
|
query += "WHERE id = ?id?"
|
||||||
affected_rows = commands.execute(query, param=schemaModel)
|
affected_rows = commands.execute(query, param=schemaModel)
|
||||||
|
|
||||||
pquery = "SELECT id, participant_id FROM shipcall_participant_map where shipcall_id = ?id?"
|
pquery = "SELECT id, participant_id, type FROM shipcall_participant_map where shipcall_id = ?id?"
|
||||||
pdata = commands.query(pquery,param={"id" : schemaModel["id"]}) # existing list of assignments
|
pdata = commands.query(pquery,param={"id" : schemaModel["id"]}) # existing list of assignments
|
||||||
|
|
||||||
# loop across passed participant ids, creating entries for those not present in pdata
|
# loop across passed participant ids, creating entries for those not present in pdata
|
||||||
# TODO: make sure there are not two participants of the same type
|
|
||||||
|
|
||||||
for participant_id in schemaModel["participants"]:
|
for participant_assignment in schemaModel["participants"]:
|
||||||
found_participant = False
|
found_participant = False
|
||||||
for elem in pdata:
|
for elem in pdata:
|
||||||
if elem["participant_id"] == participant_id:
|
if elem["participant_id"] == participant_assignment["participant_id"] and elem["type"] == participant_assignment["type"]:
|
||||||
found_participant = True
|
found_participant = True
|
||||||
break
|
break
|
||||||
if not found_participant:
|
if not found_participant:
|
||||||
nquery = "INSERT INTO shipcall_participant_map (shipcall_id, participant_id) VALUES (?shipcall_id?, ?participant_id?)"
|
nquery = "INSERT INTO shipcall_participant_map (shipcall_id, participant_id, type) VALUES (?shipcall_id?, ?participant_id?, ?type?)"
|
||||||
commands.execute(nquery, param={"shipcall_id" : schemaModel["id"], "participant_id" : participant_id})
|
commands.execute(nquery, param={"shipcall_id" : schemaModel["id"], "participant_id" : participant_assignment["participant_id"], "type" : participant_assignment["type"]})
|
||||||
|
|
||||||
# loop across existing pdata entries, deleting those not present in participant list
|
# loop across existing pdata entries, deleting those not present in participant list
|
||||||
for elem in pdata:
|
for elem in pdata:
|
||||||
found_participant = False
|
found_participant = False
|
||||||
for participant_id in schemaModel["participants"]:
|
for participant_assignment in schemaModel["participants"]:
|
||||||
if(participant_id == elem["participant_id"]):
|
if(participant_assignment["participant_id"] == elem["participant_id"] and participant_assignment["type"] == elem["type"]):
|
||||||
found_participant = True
|
found_participant = True
|
||||||
break;
|
break;
|
||||||
if not found_participant:
|
if not found_participant:
|
||||||
|
|||||||
@ -59,6 +59,10 @@ class Participant(Schema):
|
|||||||
class ParticipantList(Participant):
|
class ParticipantList(Participant):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class ParticipantAssignmentSchema(Schema):
|
||||||
|
participant_id = fields.Int()
|
||||||
|
type = fields.Int()
|
||||||
|
|
||||||
class ShipcallSchema(Schema):
|
class ShipcallSchema(Schema):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(unknown=None)
|
super().__init__(unknown=None)
|
||||||
@ -89,12 +93,17 @@ class ShipcallSchema(Schema):
|
|||||||
canceled = fields.Bool(Required = False, allow_none=True)
|
canceled = fields.Bool(Required = False, allow_none=True)
|
||||||
evaluation = fields.Int(Required = False, allow_none=True)
|
evaluation = fields.Int(Required = False, allow_none=True)
|
||||||
evaluation_message = fields.Str(Required = False, allow_none=True)
|
evaluation_message = fields.Str(Required = False, allow_none=True)
|
||||||
participants = fields.List(fields.Int)
|
participants = fields.List(fields.Nested(ParticipantAssignmentSchema))
|
||||||
created = fields.DateTime(Required = False, allow_none=True)
|
created = fields.DateTime(Required = False, allow_none=True)
|
||||||
modified = fields.DateTime(Required = False, allow_none=True)
|
modified = fields.DateTime(Required = False, allow_none=True)
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Participant_Assignment:
|
class Participant_Assignment:
|
||||||
|
def __init__(self, participant_id, type):
|
||||||
|
self.participant_id = participant_id
|
||||||
|
self.type = type
|
||||||
|
pass
|
||||||
|
|
||||||
participant_id: int
|
participant_id: int
|
||||||
type: int
|
type: int
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user