Skip to content

Commit

Permalink
Merge pull request #2402 from abarz722/develop
Browse files Browse the repository at this point in the history
Develop several fixes
  • Loading branch information
tpurschke committed May 6, 2024
2 parents 7d5f3aa + 2dac48d commit 1e730f8
Show file tree
Hide file tree
Showing 16 changed files with 628 additions and 572 deletions.
34 changes: 31 additions & 3 deletions roles/database/files/sql/idempotent/fworch-texts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5749,11 +5749,11 @@ INSERT INTO txt VALUES ('H9011', 'English', 'An application is - from the perspe
INSERT INTO txt VALUES ('H9021', 'German', 'Verbindungen sind die Hauptbestandteile des Kommunikationsprofils. Es wird zwischen verschiedenen Arten von Verbindungen unterschieden:');
INSERT INTO txt VALUES ('H9021', 'English', 'Connections are the main components of the communication profile. There are different types of connections:');
INSERT INTO txt VALUES ('H9022', 'German', 'Schnittstellen: Sie dienen in erster Linie der Modellierung von (aus Sicht der Applikation) externen Verbindungen oder der Bündelung interner Objekte.
Es müssen in der Applikation neben dem Dienst entweder Quelle oder Ziel definiert werden. Die Schnittstellen werden in den anderen Applikationen
zur Auswahl angeboten und können dort in der Definition von eigenen Verbindungen verwendet werden.
Es müssen in der Applikation neben dem Dienst entweder Quelle oder Ziel definiert werden. Die Schnittstellen können durch Setzen des entsprechendenn Häkchens veröffentlicht und dadurch in den anderen Applikationen
zur Auswahl angeboten werden. Sie können dann dort in der Definition von eigenen Verbindungen verwendet werden.
');
INSERT INTO txt VALUES ('H9022', 'English', 'Interfaces: They serve primarily the modelling of (relative to the application) external connections or the bundling of internal objects.
Besides the service either source or destination have to be defined in the application. The interfaces are offered to other applications to use
Besides the service either source or destination have to be defined in the application. The interfaces can be published by setting the respective flag and are then offered to other applications to use
them in the definition of own connections.
');
INSERT INTO txt VALUES ('H9023', 'German', 'Standard: Zentrale Objekte zur Modellierung der Kommunikationsverbindungen. Dabei müssen Quelle, Dienst und Ziel aus den in der Bibliothek
Expand Down Expand Up @@ -5812,3 +5812,31 @@ INSERT INTO txt VALUES ('H9043', 'German', 'Dienstgruppen: In Dienstgruppen k&o
INSERT INTO txt VALUES ('H9043', 'English', 'Service Groups: Simple services can be bundled in Service Groups. A name has to be given to them, comments can be added.
Again definition can be done by the modeller, but also Service Groups predefined by the administrator can be used.
');
INSERT INTO txt VALUES ('H9051', 'German', 'Beantragung neuer Schnittstellen: Wenn externe Schnittstellen von anderen Applikationen benötigt werden, können diese über die entsprechende Schaltfläche in der Bibliothek beantragt werden.
<ul>
<li>Es erscheint ein Dialog, in dem die externe Applikation ausgew&auml;hlt und eine Begr&uuml;ndung eingetragen werden m&uuml;ssen, sowie das H&auml;kchen, ob die Schnittstelle als Quelle oder Ziel genutzt werden soll.</li>
<li>Beim Abschicken der Anforderung wird
<ul>
<li>bei der externen Applikation automatisch eine Dummy-Schnittstelle angelegt, die dann in der eigenen Schnittstellen-Auswahl erscheint und direkt zur Erstellung eigener Verbindungen genutzt werden kann.
Sie wird in der Liste der eigenen Verbindungen mit Eintr&auml;gen "Schnittstelle angefordert" in Quelle/Ziel und Dienst als solche gekennzeichnet.</li>
<li>der oder die f&uuml;r die externe Applikation Verantwortlichen per Email &uuml;ber den Antrag informiert.</li>
<li>im Workflow-Modul ein Ticket mit dem Antrag erstellt. Je nach Konfiguration des Workflows kann hier der Auftrag abgelehnt, an andere Applikationen weitergeleitet, einzelnen Bearbeitern zugewiesen oder mit Kommentaren versehen werden.</li>
</ul>
</li>
<li>Wird die Schnittstelle auf der Gegenseite modelliert und ver&ouml;ffentlicht, wandelt sich auch die eigene nutzende Verbindung automatisch in eine "normale" Verbindung um, eine weiteres Eingreifen des Antragstellers ist nicht mehr notwendig.</li>
</ul>
');
INSERT INTO txt VALUES ('H9051', 'English', 'Request new interface: If external interfaces from other applications are needed, they can be requested via a button in the library.
<ul>
<li>A dialogue is displayed to select the external Application. A reason field has to be filled as well as the checkbox, if the interface should be used as source or destination.</li>
<li>If the request is submitted
<ul>
<li>a dummy interface is created automatically at the target application, which then appears in the own interface selection in the library and can be used for the definition of the own connection.
It is marked as such by the text "Interface requested" in Source/Destination and Service in the list of own the connections.</li>
<li>the responsible(s) of the external Application is informed about the request by email.</li>
<li>a ticket in the Workflow module is created. Depending on the configuration of the workflow, the request can be rejected, forwarded to other applications, assigned to aperson in charge or commented.</li>
</ul>
</li>
<li>When the requested interface is modelled and published on the other side, the own using connection is changed to a "regular" connection automatically, further action is not necessary.</li>
</ul>
');
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
mutation updateConnectionOwner(
$id: Int!
$appId: Int
) {
update_modelling_connection_by_pk(
pk_columns: { id: $id }
_set: {
app_id: $appId
}) {
UpdatedId: id
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
mutation updateConnectionPublish(
$id: Int!
$isPublished: Boolean
$isRequested: Boolean
) {
update_modelling_connection_by_pk(
pk_columns: { id: $id }
_set: {
is_requested: $isRequested
is_published: $isPublished
}) {
UpdatedId: id
}
}
17 changes: 8 additions & 9 deletions roles/lib/files/FWO.Api.Client/Data/StateMatrix.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using FWO.Api.Client.Queries;
using FWO.GlobalConstants;
using FWO.Api.Data;
using System.Text.Json.Serialization;
using Newtonsoft.Json;
Expand All @@ -20,10 +19,10 @@ public enum WorkflowPhases
public class StateMatrix
{
[JsonProperty("matrix"), JsonPropertyName("matrix")]
public Dictionary<int, List<int>> Matrix { get; set; } = new ();
public Dictionary<int, List<int>> Matrix { get; set; } = [];

[JsonProperty("derived_states"), JsonPropertyName("derived_states")]
public Dictionary<int, int> DerivedStates { get; set; } = new ();
public Dictionary<int, int> DerivedStates { get; set; } = [];

[JsonProperty("lowest_input_state"), JsonPropertyName("lowest_input_state")]
public int LowestInputState { get; set; }
Expand All @@ -37,7 +36,7 @@ public class StateMatrix
[JsonProperty("active"), JsonPropertyName("active")]
public bool Active { get; set; }

public Dictionary<WorkflowPhases, bool> PhaseActive = new Dictionary<WorkflowPhases, bool>();
public Dictionary<WorkflowPhases, bool> PhaseActive = [];
public bool IsLastActivePhase = true;
public int MinImplTasksNeeded;

Expand Down Expand Up @@ -77,7 +76,7 @@ public bool getNextActivePhase(ref WorkflowPhases phase)

public List<int> getAllowedTransitions(int stateIn)
{
return Matrix.ContainsKey(stateIn) ? Matrix[stateIn] : new ();
return Matrix.ContainsKey(stateIn) ? Matrix[stateIn] : [];
}

public int getDerivedStateFromSubStates(List<int> statesIn)
Expand All @@ -86,7 +85,7 @@ public int getDerivedStateFromSubStates(List<int> statesIn)
{
return 0;
}
int stateOut = 0;
int stateOut;
int backAssignedState = LowestInputState;
int initState = 0;
int inWorkState = LowestEndState;
Expand Down Expand Up @@ -160,7 +159,7 @@ public int getDerivedStateFromSubStates(List<int> statesIn)
public class GlobalStateMatrix
{
[JsonProperty("config_value"), JsonPropertyName("config_value")]
public Dictionary<WorkflowPhases, StateMatrix> GlobalMatrix { get; set; } = new ();
public Dictionary<WorkflowPhases, StateMatrix> GlobalMatrix { get; set; } = [];


public async Task Init(ApiConnection apiConnection, TaskType taskType = TaskType.master, bool reset = false)
Expand Down Expand Up @@ -198,11 +197,11 @@ public class GlobalStateMatrixHelper

public class StateMatrixDict
{
public Dictionary<string, StateMatrix> Matrices { get; set; } = new Dictionary<string, StateMatrix>();
public Dictionary<string, StateMatrix> Matrices { get; set; } = [];

public async Task Init(WorkflowPhases phase, ApiConnection apiConnection)
{
Matrices = new Dictionary<string, StateMatrix>();
Matrices = [];
foreach(TaskType taskType in Enum.GetValues(typeof(TaskType)))
{
Matrices.Add(taskType.ToString(), new StateMatrix());
Expand Down
4 changes: 4 additions & 0 deletions roles/lib/files/FWO.Api.Client/Queries/ModellingQueries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class ModellingQueries : Queries
public static readonly string getCommonServices;
public static readonly string newConnection;
public static readonly string updateConnection;
public static readonly string updateConnectionOwner;
public static readonly string updateConnectionPublish;
public static readonly string deleteConnection;
public static readonly string addAppServerToConnection;
public static readonly string removeAppServerFromConnection;
Expand Down Expand Up @@ -122,6 +124,8 @@ static ModellingQueries()
getCommonServices = connectionDetailsFragment + File.ReadAllText(QueryPath + "modelling/getCommonServices.graphql");
newConnection = File.ReadAllText(QueryPath + "modelling/newConnection.graphql");
updateConnection = File.ReadAllText(QueryPath + "modelling/updateConnection.graphql");
updateConnectionOwner = File.ReadAllText(QueryPath + "modelling/updateConnectionOwner.graphql");
updateConnectionPublish = File.ReadAllText(QueryPath + "modelling/updateConnectionPublish.graphql");
deleteConnection = File.ReadAllText(QueryPath + "modelling/deleteConnection.graphql");
addAppServerToConnection = File.ReadAllText(QueryPath + "modelling/addAppServerToConnection.graphql");
removeAppServerFromConnection = File.ReadAllText(QueryPath + "modelling/removeAppServerFromConnection.graphql");
Expand Down
52 changes: 35 additions & 17 deletions roles/middleware/files/FWO.Middleware.Server/AppDataImport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,49 +263,47 @@ private async Task AddAllGroupMembersToUiUser(string userGroupDn)
{
foreach (string memberDn in ldap.GetGroupMembers(userGroupDn))
{
await UiUserHandler.UpsertUiUser(apiConnection, await ConvertLdapToUiUser(apiConnection, memberDn), false);
UiUser? uiUser = await ConvertLdapToUiUser(apiConnection, memberDn);
if(uiUser != null)
{
await UiUserHandler.UpsertUiUser(apiConnection, uiUser, false);
}
}
}
}
}

private async Task<UiUser> ConvertLdapToUiUser(ApiConnection apiConnection, string userDn)
private async Task<UiUser?> ConvertLdapToUiUser(ApiConnection apiConnection, string userDn)
{
// add the modelling user to local uiuser table for later ref to email address
UiUser uiUser = new();

// find the user in all connected ldaps
foreach (Ldap ldap in connectedLdaps)
{
if (!ldap.UserSearchPath.IsNullOrEmpty() && userDn.ToLower().Contains(ldap.UserSearchPath.ToLower()))
if (!ldap.UserSearchPath.IsNullOrEmpty() && userDn.ToLower().Contains(ldap.UserSearchPath!.ToLower()))
{
LdapEntry ldapUser = ldap.GetUserDetailsFromLdap(userDn);
LdapEntry? ldapUser = ldap.GetUserDetailsFromLdap(userDn);

if (ldapUser != null)
{
// add data from ldap entry to uiUser
uiUser = new()
return new()
{
LdapConnection = new UiLdapConnection(),
LdapConnection = new UiLdapConnection(){ Id = ldap.Id },
Dn = ldapUser.Dn,
Name = ldap.GetName(ldapUser),
Firstname = ldap.GetFirstName(ldapUser),
Lastname = ldap.GetLastName(ldapUser),
Email = ldap.GetEmail(ldapUser),
Tenant = await DeriveTenantFromLdap(ldap, ldapUser)
};
uiUser.LdapConnection.Id = ldap.Id;
return uiUser;
}
}
}
return uiUser;

return null;
}

private async Task<Tenant> DeriveTenantFromLdap(Ldap ldap, LdapEntry ldapUser)
{
// try to derive the the user's tenant from the ldap settings

Tenant tenant = new()
{
Id = GlobalConst.kTenant0Id // default: tenant0 (id=1)
Expand All @@ -325,7 +323,7 @@ private async Task<Tenant> DeriveTenantFromLdap(Ldap ldap, LdapEntry ldapUser)
{
if (!ldap.GlobalTenantName.IsNullOrEmpty())
{
tenantName = ldap.GlobalTenantName;
tenantName = ldap.GlobalTenantName ?? "";
}
}

Expand All @@ -336,9 +334,7 @@ private async Task<Tenant> DeriveTenantFromLdap(Ldap ldap, LdapEntry ldapUser)
tenant.Id = tenants[0].Id;
}
}

return tenant;

}

private string CreateUserGroup(ModellingImportAppData incomingApp)
Expand Down Expand Up @@ -403,9 +399,31 @@ private string UpdateUserGroup(ModellingImportAppData incomingApp, string groupD
internalLdap.RemoveUserFromEntry(member, groupDn);
}
}
UpdateRoles(groupDn);
return groupDn;
}

private void UpdateRoles(string groupDn)
{
List<string> roles = internalLdap.GetRoles([groupDn]);
if(!roles.Contains(Roles.Modeller))
{
internalLdap.AddUserToEntry(groupDn, modellerRoleDn);
}
if(!roles.Contains(Roles.Requester))
{
internalLdap.AddUserToEntry(groupDn, requesterRoleDn);
}
if(!roles.Contains(Roles.Implementer))
{
internalLdap.AddUserToEntry(groupDn, implementerRoleDn);
}
if(!roles.Contains(Roles.Reviewer))
{
internalLdap.AddUserToEntry(groupDn, reviewerRoleDn);
}
}

private async Task ImportAppServers(ModellingImportAppData incomingApp, int applId)
{
int successCounter = 0;
Expand Down
Loading

0 comments on commit 1e730f8

Please sign in to comment.