Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/RHEAGROUP/CDP4-WebSe…
Browse files Browse the repository at this point in the history
  • Loading branch information
lxatrhea committed Jun 11, 2021
2 parents 90ccb57 + 5bbe90f commit 6b53951
Show file tree
Hide file tree
Showing 514 changed files with 40,828 additions and 3,972 deletions.
98 changes: 88 additions & 10 deletions CDP4Orm/AutoGenDao/ActionItemDao.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ActionItemDao.cs" company="RHEA System S.A.">
// Copyright (c) 2015-2020 RHEA System S.A.
// Copyright (c) 2015-2021 RHEA System S.A.
//
// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft, Kamil Wojnowski,
// Nathanael Smiechowski
// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft, Nathanael Smiechowski
//
// This file is part of CDP4 Web Services Community Edition.
// The CDP4 Web Services Community Edition is the RHEA implementation of ECSS-E-TM-10-25 Annex A and Annex C.
// This file is part of COMET Web Services Community Edition.
// The COMET Web Services Community Edition is the RHEA implementation of ECSS-E-TM-10-25 Annex A and Annex C.
// This is an auto-generated class. Any manual changes to this file will be overwritten!
//
// The CDP4 Web Services Community Edition is free software; you can redistribute it and/or
// The COMET Web Services Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Affero General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// The CDP4 Web Services Community Edition is distributed in the hope that it will be useful,
// The COMET Web Services Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// </copyright>
// <summary>
// This is an auto-generated Dao class. Any manual changes on this file will be overwritten.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

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

/// <summary>
/// Insert a new database record, or updates one if it already exists from the supplied data transfer object.
/// This is typically used during the import of existing data to the Database.
/// </summary>
/// <param name="transaction">
/// The current <see cref="NpgsqlTransaction"/> to the database.
/// </param>
/// <param name="partition">
/// The database partition (schema) where the requested resource will be stored.
/// </param>
/// <param name="actionItem">
/// The actionItem DTO that is to be persisted.
/// </param>
/// <param name="container">
/// The container of the DTO to be persisted.
/// </param>
/// <returns>
/// True if the concept was successfully persisted.
/// </returns>
public virtual bool Upsert(NpgsqlTransaction transaction, string partition, CDP4Common.DTO.ActionItem actionItem, CDP4Common.DTO.Thing container = null)
{
var valueTypeDictionaryAdditions = new Dictionary<string, string>();
base.Upsert(transaction, partition, actionItem, container);

var valueTypeDictionaryContents = new Dictionary<string, string>
{
{ "CloseOutDate", !this.IsDerived(actionItem, "CloseOutDate") && actionItem.CloseOutDate.HasValue ? actionItem.CloseOutDate.Value.ToString(Utils.DateTimeUtcSerializationFormat) : null },
{ "CloseOutStatement", !this.IsDerived(actionItem, "CloseOutStatement") ? actionItem.CloseOutStatement.Escape() : null },
{ "DueDate", !this.IsDerived(actionItem, "DueDate") ? actionItem.DueDate.ToString(Utils.DateTimeUtcSerializationFormat) : string.Empty },
}.Concat(valueTypeDictionaryAdditions).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);

using (var command = new NpgsqlCommand())
{
var sqlBuilder = new System.Text.StringBuilder();

sqlBuilder.AppendFormat("INSERT INTO \"{0}\".\"ActionItem\"", partition);
sqlBuilder.AppendFormat(" (\"Iid\", \"ValueTypeDictionary\", \"Actionee\")");
sqlBuilder.AppendFormat(" VALUES (:iid, :valueTypeDictionary, :actionee)");

command.Parameters.Add("iid", NpgsqlDbType.Uuid).Value = actionItem.Iid;
command.Parameters.Add("valueTypeDictionary", NpgsqlDbType.Hstore).Value = valueTypeDictionaryContents;
command.Parameters.Add("actionee", NpgsqlDbType.Uuid).Value = !this.IsDerived(actionItem, "Actionee") ? actionItem.Actionee : Utils.NullableValue(null);
sqlBuilder.Append(" ON CONFLICT (\"Iid\")");
sqlBuilder.Append(" DO UPDATE ");
sqlBuilder.Append(" SET (\"ValueTypeDictionary\", \"Actionee\")");
sqlBuilder.Append(" = (:valueTypeDictionary, :actionee);");

command.CommandText = sqlBuilder.ToString();
command.Connection = transaction.Connection;
command.Transaction = transaction;

this.ExecuteAndLogCommand(command);
}

return true;
}

/// <summary>
/// Update a database record from the supplied data transfer object.
/// </summary>
Expand Down Expand Up @@ -372,5 +425,30 @@ public override bool Delete(NpgsqlTransaction transaction, string partition, Gui

return this.AfterDelete(beforeDelete, transaction, partition, iid);
}

/// <summary>
/// Delete a database record from the supplied data transfer object.
/// A "Raw" Delete means that the delete is performed without calling BeforeDelete or AfterDelete.
/// This is typically used during the import of existing data to the Database.
/// </summary>
/// <param name="transaction">
/// The current <see cref="NpgsqlTransaction"/> to the database.
/// </param>
/// <param name="partition">
/// The database partition (schema) where the requested resource will be deleted.
/// </param>
/// <param name="iid">
/// The <see cref="CDP4Common.DTO.ActionItem"/> id that is to be deleted.
/// </param>
/// <returns>
/// True if the concept was successfully deleted.
/// </returns>
public override bool RawDelete(NpgsqlTransaction transaction, string partition, Guid iid)
{
var result = false;

result = base.Delete(transaction, partition, iid);
return result;
}
}
}
140 changes: 130 additions & 10 deletions CDP4Orm/AutoGenDao/ActualFiniteStateDao.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ActualFiniteStateDao.cs" company="RHEA System S.A.">
// Copyright (c) 2015-2020 RHEA System S.A.
// Copyright (c) 2015-2021 RHEA System S.A.
//
// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft, Kamil Wojnowski,
// Nathanael Smiechowski
// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft, Nathanael Smiechowski
//
// This file is part of CDP4 Web Services Community Edition.
// The CDP4 Web Services Community Edition is the RHEA implementation of ECSS-E-TM-10-25 Annex A and Annex C.
// This file is part of COMET Web Services Community Edition.
// The COMET Web Services Community Edition is the RHEA implementation of ECSS-E-TM-10-25 Annex A and Annex C.
// This is an auto-generated class. Any manual changes to this file will be overwritten!
//
// The CDP4 Web Services Community Edition is free software; you can redistribute it and/or
// The COMET Web Services Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Affero General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// The CDP4 Web Services Community Edition is distributed in the hope that it will be useful,
// The COMET Web Services Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// </copyright>
// <summary>
// This is an auto-generated Dao class. Any manual changes on this file will be overwritten.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

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

/// <summary>
/// Insert a new database record, or updates one if it already exists from the supplied data transfer object.
/// This is typically used during the import of existing data to the Database.
/// </summary>
/// <param name="transaction">
/// The current <see cref="NpgsqlTransaction"/> to the database.
/// </param>
/// <param name="partition">
/// The database partition (schema) where the requested resource will be stored.
/// </param>
/// <param name="actualFiniteState">
/// The actualFiniteState DTO that is to be persisted.
/// </param>
/// <param name="container">
/// The container of the DTO to be persisted.
/// </param>
/// <returns>
/// True if the concept was successfully persisted.
/// </returns>
public virtual bool Upsert(NpgsqlTransaction transaction, string partition, CDP4Common.DTO.ActualFiniteState actualFiniteState, CDP4Common.DTO.Thing container = null)
{
var valueTypeDictionaryAdditions = new Dictionary<string, string>();
base.Upsert(transaction, partition, actualFiniteState, container);

var valueTypeDictionaryContents = new Dictionary<string, string>
{
{ "Kind", !this.IsDerived(actualFiniteState, "Kind") ? actualFiniteState.Kind.ToString() : string.Empty },
}.Concat(valueTypeDictionaryAdditions).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);

using (var command = new NpgsqlCommand())
{
var sqlBuilder = new System.Text.StringBuilder();

sqlBuilder.AppendFormat("INSERT INTO \"{0}\".\"ActualFiniteState\"", partition);
sqlBuilder.AppendFormat(" (\"Iid\", \"ValueTypeDictionary\", \"Container\")");
sqlBuilder.AppendFormat(" VALUES (:iid, :valueTypeDictionary, :container)");

command.Parameters.Add("iid", NpgsqlDbType.Uuid).Value = actualFiniteState.Iid;
command.Parameters.Add("valueTypeDictionary", NpgsqlDbType.Hstore).Value = valueTypeDictionaryContents;
command.Parameters.Add("container", NpgsqlDbType.Uuid).Value = container.Iid;
sqlBuilder.Append(" ON CONFLICT (\"Iid\")");
sqlBuilder.Append(" DO UPDATE ");
sqlBuilder.Append(" SET (\"ValueTypeDictionary\", \"Container\")");
sqlBuilder.Append(" = (:valueTypeDictionary, :container);");

command.CommandText = sqlBuilder.ToString();
command.Connection = transaction.Connection;
command.Transaction = transaction;

this.ExecuteAndLogCommand(command);
}
actualFiniteState.PossibleState.ForEach(x => this.UpsertPossibleState(transaction, partition, actualFiniteState.Iid, x));

return true;
}

/// <summary>
/// Add the supplied value collection to the association link table indicated by the supplied property name
/// </summary>
Expand Down Expand Up @@ -306,6 +358,49 @@ public bool AddPossibleState(NpgsqlTransaction transaction, string partition, Gu
}
}

/// <summary>
/// Insert a new association record in the link table, or update if it already exists.
/// This is typically used during the import of existing data to the Database.
/// </summary>
/// <param name="transaction">
/// The current <see cref="NpgsqlTransaction"/> to the database.
/// </param>
/// <param name="partition">
/// The database partition (schema) where the requested resource will be stored.
/// </param>
/// <param name="iid">
/// The <see cref="CDP4Common.DTO.ActualFiniteState"/> id that will be the source for each link table record.
/// </param>
/// <param name="possibleState">
/// The value for which a link table record wil be created.
/// </param>
/// <returns>
/// True if the value link was successfully created.
/// </returns>
public bool UpsertPossibleState(NpgsqlTransaction transaction, string partition, Guid iid, Guid possibleState)
{
using (var command = new NpgsqlCommand())
{
var sqlBuilder = new System.Text.StringBuilder();
sqlBuilder.AppendFormat("INSERT INTO \"{0}\".\"ActualFiniteState_PossibleState\"", partition);
sqlBuilder.AppendFormat(" (\"ActualFiniteState\", \"PossibleState\")");
sqlBuilder.Append(" VALUES (:actualFiniteState, :possibleState)");
sqlBuilder.Append(" ON CONFLICT ON CONSTRAINT \"ActualFiniteState_PossibleState_PK\"");
sqlBuilder.Append(" DO UPDATE ");
sqlBuilder.Append(" SET (\"ActualFiniteState\", \"PossibleState\")");
sqlBuilder.Append(" = (:actualFiniteState, :possibleState);");

command.Parameters.Add("actualFiniteState", NpgsqlDbType.Uuid).Value = iid;
command.Parameters.Add("possibleState", NpgsqlDbType.Uuid).Value = possibleState;

command.CommandText = sqlBuilder.ToString();
command.Connection = transaction.Connection;
command.Transaction = transaction;

return this.ExecuteAndLogCommand(command) > 0;
}
}

/// <summary>
/// Update a database record from the supplied data transfer object.
/// </summary>
Expand Down Expand Up @@ -388,6 +483,31 @@ public override bool Delete(NpgsqlTransaction transaction, string partition, Gui
return this.AfterDelete(beforeDelete, transaction, partition, iid);
}

/// <summary>
/// Delete a database record from the supplied data transfer object.
/// A "Raw" Delete means that the delete is performed without calling BeforeDelete or AfterDelete.
/// This is typically used during the import of existing data to the Database.
/// </summary>
/// <param name="transaction">
/// The current <see cref="NpgsqlTransaction"/> to the database.
/// </param>
/// <param name="partition">
/// The database partition (schema) where the requested resource will be deleted.
/// </param>
/// <param name="iid">
/// The <see cref="CDP4Common.DTO.ActualFiniteState"/> id that is to be deleted.
/// </param>
/// <returns>
/// True if the concept was successfully deleted.
/// </returns>
public override bool RawDelete(NpgsqlTransaction transaction, string partition, Guid iid)
{
var result = false;

result = base.Delete(transaction, partition, iid);
return result;
}

/// <summary>
/// Delete the supplied value from the association link table indicated by the supplied property name.
/// </summary>
Expand Down
Loading

0 comments on commit 6b53951

Please sign in to comment.