Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Work queue screen opening error #1780

Merged
merged 2 commits into from Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -23,6 +23,7 @@
using System;
using System.Collections;
using System.ComponentModel;
using System.Linq;
using System.Xml.Serialization;
using Origam.DA.ObjectPersistence;
using Origam.Schema.EntityModel;
Expand Down Expand Up @@ -135,6 +136,7 @@ public EntityFilter ConditionFilter
[TypeConverter(typeof(DataStructureConverter))]
[RefreshProperties(RefreshProperties.Repaint)]
[NotNullModelElementRule()]
[StructureMustHaveGetByIdFilterRule]
[XmlReference("workQueueStructure", "WorkQueueStructureId")]
public DataStructure WorkQueueStructure
{
Expand Down Expand Up @@ -358,4 +360,37 @@ public DataStructureMethod NotificationLoadMethod
public string DefaultPanelConfiguration { get; set; } = "";
#endregion
}

[AttributeUsage(AttributeTargets.Property)]
public class StructureMustHaveGetByIdFilterRule : AbstractModelElementRuleAttribute
{
public override Exception CheckRule(object instance)
{
if (!(instance is WorkQueueClass workQueueClass))
{
throw new Exception(
$"{nameof(StructureMustHaveGetByIdFilterRule)} can be only applied to type {nameof(WorkQueueClass)}");
}
if (workQueueClass.WorkQueueStructure == null)
{
return null;
}

DataStructureFilterSet getByIdFilterSet = workQueueClass.WorkQueueStructure
.ChildItems.ToGeneric()
.OfType<DataStructureFilterSet>()
.FirstOrDefault(filterSet => filterSet.Name == "GetById");

return getByIdFilterSet == null
? new Exception($"The {nameof(workQueueClass.WorkQueueStructure)} of " +
$"{nameof(WorkQueueClass)} {workQueueClass.Name}, " +
$"Id: {workQueueClass.Id} does not have filter set named GetById which is required.")
: null;
}

public override Exception CheckRule(object instance, string memberName)
{
return CheckRule(instance);
}
}
}
13 changes: 9 additions & 4 deletions backend/Origam.Server/Session Stores/WorkQueueSessionStore.cs
Expand Up @@ -139,11 +139,16 @@ public override ArrayList GetRowData(string entity, object id, bool ignoreDirtyS

private DataSet LoadDataPiece(object parentId)
{
Guid methodId = WQClass
Guid? methodId = WQClass
.WorkQueueStructure.Methods.Cast<DataStructureFilterSet>()
.First(x => x.Name == "GetById")
.Id;
return core.DataService.Instance.LoadData(WQClass.WorkQueueStructureId, methodId,
.FirstOrDefault(x => x.Name == "GetById")
?.Id;
if (methodId == null)
{
throw new Exception($"Data structure filter set with name GetById was not found under WorkQueueStructure {WQClass.WorkQueueStructure.Id}");
}

return core.DataService.Instance.LoadData(WQClass.WorkQueueStructureId, methodId.Value,
Guid.Empty, WQClass.WorkQueueStructureSortSetId, null,
"WorkQueueEntry_parId", parentId);
}
Expand Down