Skip to content

Commit e6c7840

Browse files
committed
fix: use sdkmessage operationtype for plugin types isntead of just using other.
1 parent ba9dc1f commit e6c7840

4 files changed

Lines changed: 39 additions & 7 deletions

File tree

Generator/DTO/AttributeUsage.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,20 @@ public record AttributeUsage(
2727
OperationType OperationType,
2828
ComponentType ComponentType,
2929
bool IsFromDependencyAnalysis
30-
);
30+
)
31+
{
32+
public static OperationType MapSdkMessageToOperationType(string sdkMessageName)
33+
{
34+
return sdkMessageName?.ToLowerInvariant() switch
35+
{
36+
"create" => OperationType.Create,
37+
"update" => OperationType.Update,
38+
"delete" => OperationType.Delete,
39+
"retrieve" => OperationType.Read,
40+
"retrievemultiple" => OperationType.List,
41+
"upsert" => OperationType.Update,
42+
"merge" => OperationType.Update,
43+
_ => OperationType.Other
44+
};
45+
}
46+
};

Generator/DTO/SDKStep.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ public record SDKStep(
77
string Name,
88
string FilteringAttributes,
99
string PrimaryObjectTypeCode,
10+
string SdkMessageName,
1011
OptionSetValue State) : Analyzeable();

Generator/Queries/PluginQueries.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ public static async Task<IEnumerable<SDKStep>> GetSDKMessageProcessingStepsAsync
4444
{
4545
Columns = new ColumnSet("primaryobjecttypecode"),
4646
EntityAlias = "filter"
47+
},
48+
new LinkEntity(
49+
"sdkmessageprocessingstep",
50+
"sdkmessage",
51+
"sdkmessageid",
52+
"sdkmessageid",
53+
JoinOperator.Inner)
54+
{
55+
Columns = new ColumnSet("name"),
56+
EntityAlias = "message"
4757
}
4858
//new LinkEntity
4959
//{
@@ -66,17 +76,19 @@ public static async Task<IEnumerable<SDKStep>> GetSDKMessageProcessingStepsAsync
6676
var steps = result.Entities.Select(e =>
6777
{
6878
var sdkMessageId = e.GetAttributeValue<AliasedValue>("step.sdkmessageid")?.Value as EntityReference;
69-
var sdkMessageName = e.GetAttributeValue<AliasedValue>("step.name")?.Value as string;
79+
var sdkStepName = e.GetAttributeValue<AliasedValue>("step.name")?.Value as string;
7080
var sdkFilterAttributes = e.GetAttributeValue<AliasedValue>("step.filteringattributes")?.Value as string;
7181
var sdkState = e.GetAttributeValue<AliasedValue>("step.statecode")?.Value as OptionSetValue;
7282
var filterTypeCode = e.GetAttributeValue<AliasedValue>("filter.primaryobjecttypecode")?.Value as string;
83+
var sdkMessageName = e.GetAttributeValue<AliasedValue>("message.name")?.Value as string;
7384

7485
return new SDKStep(
75-
sdkMessageId.Id.ToString(),
76-
sdkMessageName ?? "Unknown Name",
86+
sdkMessageId?.Id.ToString() ?? "Unknown",
87+
sdkStepName ?? "Unknown Name",
7788
sdkFilterAttributes ?? "",
78-
filterTypeCode,
79-
sdkState
89+
filterTypeCode ?? "Unknown",
90+
sdkMessageName ?? "Unknown",
91+
sdkState ?? new OptionSetValue(0)
8092
);
8193
});
8294

Generator/Services/Plugins/PluginAnalyzer.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ public override async Task AnalyzeComponentAsync(SDKStep sdkStep, Dictionary<str
2222
// Retrieve the logical name of the entity from the linked SDK Message entity
2323
var logicalTableName = sdkStep.PrimaryObjectTypeCode;
2424

25+
// Map SDK message name to operation type
26+
var operationType = AttributeUsage.MapSdkMessageToOperationType(sdkStep.SdkMessageName);
27+
2528
// Populate the attributeUsages dictionary
2629
foreach (var attribute in filteringAttributes)
27-
AddAttributeUsage(attributeUsages, logicalTableName, attribute, new AttributeUsage(pluginName, $"Used in filterattributes", OperationType.Other, SupportedType, false));
30+
AddAttributeUsage(attributeUsages, logicalTableName, attribute, new AttributeUsage(pluginName, $"Used in filterattributes", operationType, SupportedType, false));
2831

2932
}
3033
catch (Exception ex)

0 commit comments

Comments
 (0)