Skip to content

Commit 6b53951

Browse files
author
lxatrhea
committed
Merge branch 'development' of https://github.com/RHEAGROUP/CDP4-WebServices-Community-Edition into development
2 parents 90ccb57 + 5bbe90f commit 6b53951

File tree

514 files changed

+40828
-3972
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

514 files changed

+40828
-3972
lines changed

CDP4Orm/AutoGenDao/ActionItemDao.cs

Lines changed: 88 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
11
// --------------------------------------------------------------------------------------------------------------------
22
// <copyright file="ActionItemDao.cs" company="RHEA System S.A.">
3-
// Copyright (c) 2015-2020 RHEA System S.A.
3+
// Copyright (c) 2015-2021 RHEA System S.A.
44
//
5-
// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft, Kamil Wojnowski,
6-
// Nathanael Smiechowski
5+
// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft, Nathanael Smiechowski
76
//
8-
// This file is part of CDP4 Web Services Community Edition.
9-
// The CDP4 Web Services Community Edition is the RHEA implementation of ECSS-E-TM-10-25 Annex A and Annex C.
7+
// This file is part of COMET Web Services Community Edition.
8+
// The COMET Web Services Community Edition is the RHEA implementation of ECSS-E-TM-10-25 Annex A and Annex C.
109
// This is an auto-generated class. Any manual changes to this file will be overwritten!
1110
//
12-
// The CDP4 Web Services Community Edition is free software; you can redistribute it and/or
11+
// The COMET Web Services Community Edition is free software; you can redistribute it and/or
1312
// modify it under the terms of the GNU Affero General Public
1413
// License as published by the Free Software Foundation; either
1514
// version 3 of the License, or (at your option) any later version.
1615
//
17-
// The CDP4 Web Services Community Edition is distributed in the hope that it will be useful,
16+
// The COMET Web Services Community Edition is distributed in the hope that it will be useful,
1817
// but WITHOUT ANY WARRANTY; without even the implied warranty of
1918
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2019
// Lesser General Public License for more details.
2120
//
2221
// You should have received a copy of the GNU Affero General Public License
2322
// along with this program. If not, see <http://www.gnu.org/licenses/>.
2423
// </copyright>
25-
// <summary>
26-
// This is an auto-generated Dao class. Any manual changes on this file will be overwritten.
27-
// </summary>
2824
// --------------------------------------------------------------------------------------------------------------------
2925

3026
namespace CDP4Orm.Dao
@@ -289,6 +285,63 @@ public virtual bool Write(NpgsqlTransaction transaction, string partition, CDP4C
289285
return this.AfterWrite(beforeWrite, transaction, partition, actionItem, container);
290286
}
291287

288+
/// <summary>
289+
/// Insert a new database record, or updates one if it already exists from the supplied data transfer object.
290+
/// This is typically used during the import of existing data to the Database.
291+
/// </summary>
292+
/// <param name="transaction">
293+
/// The current <see cref="NpgsqlTransaction"/> to the database.
294+
/// </param>
295+
/// <param name="partition">
296+
/// The database partition (schema) where the requested resource will be stored.
297+
/// </param>
298+
/// <param name="actionItem">
299+
/// The actionItem DTO that is to be persisted.
300+
/// </param>
301+
/// <param name="container">
302+
/// The container of the DTO to be persisted.
303+
/// </param>
304+
/// <returns>
305+
/// True if the concept was successfully persisted.
306+
/// </returns>
307+
public virtual bool Upsert(NpgsqlTransaction transaction, string partition, CDP4Common.DTO.ActionItem actionItem, CDP4Common.DTO.Thing container = null)
308+
{
309+
var valueTypeDictionaryAdditions = new Dictionary<string, string>();
310+
base.Upsert(transaction, partition, actionItem, container);
311+
312+
var valueTypeDictionaryContents = new Dictionary<string, string>
313+
{
314+
{ "CloseOutDate", !this.IsDerived(actionItem, "CloseOutDate") && actionItem.CloseOutDate.HasValue ? actionItem.CloseOutDate.Value.ToString(Utils.DateTimeUtcSerializationFormat) : null },
315+
{ "CloseOutStatement", !this.IsDerived(actionItem, "CloseOutStatement") ? actionItem.CloseOutStatement.Escape() : null },
316+
{ "DueDate", !this.IsDerived(actionItem, "DueDate") ? actionItem.DueDate.ToString(Utils.DateTimeUtcSerializationFormat) : string.Empty },
317+
}.Concat(valueTypeDictionaryAdditions).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
318+
319+
using (var command = new NpgsqlCommand())
320+
{
321+
var sqlBuilder = new System.Text.StringBuilder();
322+
323+
sqlBuilder.AppendFormat("INSERT INTO \"{0}\".\"ActionItem\"", partition);
324+
sqlBuilder.AppendFormat(" (\"Iid\", \"ValueTypeDictionary\", \"Actionee\")");
325+
sqlBuilder.AppendFormat(" VALUES (:iid, :valueTypeDictionary, :actionee)");
326+
327+
command.Parameters.Add("iid", NpgsqlDbType.Uuid).Value = actionItem.Iid;
328+
command.Parameters.Add("valueTypeDictionary", NpgsqlDbType.Hstore).Value = valueTypeDictionaryContents;
329+
command.Parameters.Add("actionee", NpgsqlDbType.Uuid).Value = !this.IsDerived(actionItem, "Actionee") ? actionItem.Actionee : Utils.NullableValue(null);
330+
sqlBuilder.Append(" ON CONFLICT (\"Iid\")");
331+
sqlBuilder.Append(" DO UPDATE ");
332+
sqlBuilder.Append(" SET (\"ValueTypeDictionary\", \"Actionee\")");
333+
sqlBuilder.Append(" = (:valueTypeDictionary, :actionee);");
334+
335+
command.CommandText = sqlBuilder.ToString();
336+
command.Connection = transaction.Connection;
337+
command.Transaction = transaction;
338+
339+
this.ExecuteAndLogCommand(command);
340+
}
341+
342+
return true;
343+
}
344+
292345
/// <summary>
293346
/// Update a database record from the supplied data transfer object.
294347
/// </summary>
@@ -372,5 +425,30 @@ public override bool Delete(NpgsqlTransaction transaction, string partition, Gui
372425

373426
return this.AfterDelete(beforeDelete, transaction, partition, iid);
374427
}
428+
429+
/// <summary>
430+
/// Delete a database record from the supplied data transfer object.
431+
/// A "Raw" Delete means that the delete is performed without calling BeforeDelete or AfterDelete.
432+
/// This is typically used during the import of existing data to the Database.
433+
/// </summary>
434+
/// <param name="transaction">
435+
/// The current <see cref="NpgsqlTransaction"/> to the database.
436+
/// </param>
437+
/// <param name="partition">
438+
/// The database partition (schema) where the requested resource will be deleted.
439+
/// </param>
440+
/// <param name="iid">
441+
/// The <see cref="CDP4Common.DTO.ActionItem"/> id that is to be deleted.
442+
/// </param>
443+
/// <returns>
444+
/// True if the concept was successfully deleted.
445+
/// </returns>
446+
public override bool RawDelete(NpgsqlTransaction transaction, string partition, Guid iid)
447+
{
448+
var result = false;
449+
450+
result = base.Delete(transaction, partition, iid);
451+
return result;
452+
}
375453
}
376454
}

CDP4Orm/AutoGenDao/ActualFiniteStateDao.cs

Lines changed: 130 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
11
// --------------------------------------------------------------------------------------------------------------------
22
// <copyright file="ActualFiniteStateDao.cs" company="RHEA System S.A.">
3-
// Copyright (c) 2015-2020 RHEA System S.A.
3+
// Copyright (c) 2015-2021 RHEA System S.A.
44
//
5-
// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft, Kamil Wojnowski,
6-
// Nathanael Smiechowski
5+
// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft, Nathanael Smiechowski
76
//
8-
// This file is part of CDP4 Web Services Community Edition.
9-
// The CDP4 Web Services Community Edition is the RHEA implementation of ECSS-E-TM-10-25 Annex A and Annex C.
7+
// This file is part of COMET Web Services Community Edition.
8+
// The COMET Web Services Community Edition is the RHEA implementation of ECSS-E-TM-10-25 Annex A and Annex C.
109
// This is an auto-generated class. Any manual changes to this file will be overwritten!
1110
//
12-
// The CDP4 Web Services Community Edition is free software; you can redistribute it and/or
11+
// The COMET Web Services Community Edition is free software; you can redistribute it and/or
1312
// modify it under the terms of the GNU Affero General Public
1413
// License as published by the Free Software Foundation; either
1514
// version 3 of the License, or (at your option) any later version.
1615
//
17-
// The CDP4 Web Services Community Edition is distributed in the hope that it will be useful,
16+
// The COMET Web Services Community Edition is distributed in the hope that it will be useful,
1817
// but WITHOUT ANY WARRANTY; without even the implied warranty of
1918
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2019
// Lesser General Public License for more details.
2120
//
2221
// You should have received a copy of the GNU Affero General Public License
2322
// along with this program. If not, see <http://www.gnu.org/licenses/>.
2423
// </copyright>
25-
// <summary>
26-
// This is an auto-generated Dao class. Any manual changes on this file will be overwritten.
27-
// </summary>
2824
// --------------------------------------------------------------------------------------------------------------------
2925

3026
namespace CDP4Orm.Dao
@@ -226,6 +222,62 @@ public virtual bool Write(NpgsqlTransaction transaction, string partition, CDP4C
226222
return this.AfterWrite(beforeWrite, transaction, partition, actualFiniteState, container);
227223
}
228224

225+
/// <summary>
226+
/// Insert a new database record, or updates one if it already exists from the supplied data transfer object.
227+
/// This is typically used during the import of existing data to the Database.
228+
/// </summary>
229+
/// <param name="transaction">
230+
/// The current <see cref="NpgsqlTransaction"/> to the database.
231+
/// </param>
232+
/// <param name="partition">
233+
/// The database partition (schema) where the requested resource will be stored.
234+
/// </param>
235+
/// <param name="actualFiniteState">
236+
/// The actualFiniteState DTO that is to be persisted.
237+
/// </param>
238+
/// <param name="container">
239+
/// The container of the DTO to be persisted.
240+
/// </param>
241+
/// <returns>
242+
/// True if the concept was successfully persisted.
243+
/// </returns>
244+
public virtual bool Upsert(NpgsqlTransaction transaction, string partition, CDP4Common.DTO.ActualFiniteState actualFiniteState, CDP4Common.DTO.Thing container = null)
245+
{
246+
var valueTypeDictionaryAdditions = new Dictionary<string, string>();
247+
base.Upsert(transaction, partition, actualFiniteState, container);
248+
249+
var valueTypeDictionaryContents = new Dictionary<string, string>
250+
{
251+
{ "Kind", !this.IsDerived(actualFiniteState, "Kind") ? actualFiniteState.Kind.ToString() : string.Empty },
252+
}.Concat(valueTypeDictionaryAdditions).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
253+
254+
using (var command = new NpgsqlCommand())
255+
{
256+
var sqlBuilder = new System.Text.StringBuilder();
257+
258+
sqlBuilder.AppendFormat("INSERT INTO \"{0}\".\"ActualFiniteState\"", partition);
259+
sqlBuilder.AppendFormat(" (\"Iid\", \"ValueTypeDictionary\", \"Container\")");
260+
sqlBuilder.AppendFormat(" VALUES (:iid, :valueTypeDictionary, :container)");
261+
262+
command.Parameters.Add("iid", NpgsqlDbType.Uuid).Value = actualFiniteState.Iid;
263+
command.Parameters.Add("valueTypeDictionary", NpgsqlDbType.Hstore).Value = valueTypeDictionaryContents;
264+
command.Parameters.Add("container", NpgsqlDbType.Uuid).Value = container.Iid;
265+
sqlBuilder.Append(" ON CONFLICT (\"Iid\")");
266+
sqlBuilder.Append(" DO UPDATE ");
267+
sqlBuilder.Append(" SET (\"ValueTypeDictionary\", \"Container\")");
268+
sqlBuilder.Append(" = (:valueTypeDictionary, :container);");
269+
270+
command.CommandText = sqlBuilder.ToString();
271+
command.Connection = transaction.Connection;
272+
command.Transaction = transaction;
273+
274+
this.ExecuteAndLogCommand(command);
275+
}
276+
actualFiniteState.PossibleState.ForEach(x => this.UpsertPossibleState(transaction, partition, actualFiniteState.Iid, x));
277+
278+
return true;
279+
}
280+
229281
/// <summary>
230282
/// Add the supplied value collection to the association link table indicated by the supplied property name
231283
/// </summary>
@@ -306,6 +358,49 @@ public bool AddPossibleState(NpgsqlTransaction transaction, string partition, Gu
306358
}
307359
}
308360

361+
/// <summary>
362+
/// Insert a new association record in the link table, or update if it already exists.
363+
/// This is typically used during the import of existing data to the Database.
364+
/// </summary>
365+
/// <param name="transaction">
366+
/// The current <see cref="NpgsqlTransaction"/> to the database.
367+
/// </param>
368+
/// <param name="partition">
369+
/// The database partition (schema) where the requested resource will be stored.
370+
/// </param>
371+
/// <param name="iid">
372+
/// The <see cref="CDP4Common.DTO.ActualFiniteState"/> id that will be the source for each link table record.
373+
/// </param>
374+
/// <param name="possibleState">
375+
/// The value for which a link table record wil be created.
376+
/// </param>
377+
/// <returns>
378+
/// True if the value link was successfully created.
379+
/// </returns>
380+
public bool UpsertPossibleState(NpgsqlTransaction transaction, string partition, Guid iid, Guid possibleState)
381+
{
382+
using (var command = new NpgsqlCommand())
383+
{
384+
var sqlBuilder = new System.Text.StringBuilder();
385+
sqlBuilder.AppendFormat("INSERT INTO \"{0}\".\"ActualFiniteState_PossibleState\"", partition);
386+
sqlBuilder.AppendFormat(" (\"ActualFiniteState\", \"PossibleState\")");
387+
sqlBuilder.Append(" VALUES (:actualFiniteState, :possibleState)");
388+
sqlBuilder.Append(" ON CONFLICT ON CONSTRAINT \"ActualFiniteState_PossibleState_PK\"");
389+
sqlBuilder.Append(" DO UPDATE ");
390+
sqlBuilder.Append(" SET (\"ActualFiniteState\", \"PossibleState\")");
391+
sqlBuilder.Append(" = (:actualFiniteState, :possibleState);");
392+
393+
command.Parameters.Add("actualFiniteState", NpgsqlDbType.Uuid).Value = iid;
394+
command.Parameters.Add("possibleState", NpgsqlDbType.Uuid).Value = possibleState;
395+
396+
command.CommandText = sqlBuilder.ToString();
397+
command.Connection = transaction.Connection;
398+
command.Transaction = transaction;
399+
400+
return this.ExecuteAndLogCommand(command) > 0;
401+
}
402+
}
403+
309404
/// <summary>
310405
/// Update a database record from the supplied data transfer object.
311406
/// </summary>
@@ -388,6 +483,31 @@ public override bool Delete(NpgsqlTransaction transaction, string partition, Gui
388483
return this.AfterDelete(beforeDelete, transaction, partition, iid);
389484
}
390485

486+
/// <summary>
487+
/// Delete a database record from the supplied data transfer object.
488+
/// A "Raw" Delete means that the delete is performed without calling BeforeDelete or AfterDelete.
489+
/// This is typically used during the import of existing data to the Database.
490+
/// </summary>
491+
/// <param name="transaction">
492+
/// The current <see cref="NpgsqlTransaction"/> to the database.
493+
/// </param>
494+
/// <param name="partition">
495+
/// The database partition (schema) where the requested resource will be deleted.
496+
/// </param>
497+
/// <param name="iid">
498+
/// The <see cref="CDP4Common.DTO.ActualFiniteState"/> id that is to be deleted.
499+
/// </param>
500+
/// <returns>
501+
/// True if the concept was successfully deleted.
502+
/// </returns>
503+
public override bool RawDelete(NpgsqlTransaction transaction, string partition, Guid iid)
504+
{
505+
var result = false;
506+
507+
result = base.Delete(transaction, partition, iid);
508+
return result;
509+
}
510+
391511
/// <summary>
392512
/// Delete the supplied value from the association link table indicated by the supplied property name.
393513
/// </summary>

0 commit comments

Comments
 (0)