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

Accept Changes Worfklow Task #619

Merged
merged 2 commits into from Jun 15, 2022
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
4 changes: 3 additions & 1 deletion backend/Origam.ReflectorCache/ReflectorCache.cs
Expand Up @@ -77,7 +77,7 @@ public object InvokeObject(string classname, string assembly)

public object InvokeObject(string typeName, object[] args)
{
Key key = args[0] as Key;
var key = args[0] as Key;
switch(typeName)
{
case "Origam.Schema.EntityModel.DataConstantReference":
Expand All @@ -102,6 +102,8 @@ public object InvokeObject(string typeName, object[] args)
return new Origam.Schema.WorkflowModel.SetWorkflowPropertyTask(key);
case "Origam.Schema.WorkflowModel.UpdateContextTask":
return new Origam.Schema.WorkflowModel.UpdateContextTask(key);
case "Origam.Schema.WorkflowModel.AcceptContextStoreChanges":
return new Origam.Schema.WorkflowModel.AcceptContextStoreChangesTask(key);
case "Origam.Schema.EntityModel.DataStructureReference":
return new Origam.Schema.EntityModel.DataStructureReference(key);
case "Origam.Schema.GuiModel.PropertyValueItem":
Expand Down
Expand Up @@ -42,6 +42,7 @@ private void Init()
this.ChildItemTypes.Add(typeof(WorkflowCallTask));
this.ChildItemTypes.Add(typeof(SetWorkflowPropertyTask));
this.ChildItemTypes.Add(typeof(UpdateContextTask));
this.ChildItemTypes.Add(typeof(AcceptContextStoreChangesTask));
this.ChildItemTypes.Add(typeof(TransactionWorkflowBlock));
this.ChildItemTypes.Add(typeof(ForeachWorkflowBlock));
this.ChildItemTypes.Add(typeof(LoopWorkflowBlock));
Expand Down
Expand Up @@ -55,6 +55,7 @@ private void Init()
this.ChildItemTypes.Add(typeof(WorkflowCallTask));
this.ChildItemTypes.Add(typeof(SetWorkflowPropertyTask));
this.ChildItemTypes.Add(typeof(UpdateContextTask));
this.ChildItemTypes.Add(typeof(AcceptContextStoreChangesTask));
this.ChildItemTypes.Add(typeof(TransactionWorkflowBlock));
this.ChildItemTypes.Add(typeof(ForeachWorkflowBlock));
this.ChildItemTypes.Add(typeof(LoopWorkflowBlock));
Expand Down
@@ -0,0 +1,69 @@
#region license
/*
Copyright 2005 - 2022 Advantage Solutions, s. r. o.

This file is part of ORIGAM (http://www.origam.org).

ORIGAM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

ORIGAM 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 General Public License for more details.

You should have received a copy of the GNU General Public License
along with ORIGAM. If not, see <http://www.gnu.org/licenses/>.
*/
#endregion

using System;
using System.ComponentModel;
using Origam.DA.Common;
using Origam.DA.ObjectPersistence;

namespace Origam.Schema.WorkflowModel
{
[SchemaItemDescription("(Task) Accept Context Store Changes", "Tasks", 16)]
[HelpTopic("Accept+Context+Store+Changes")]
[ClassMetaVersion("6.0.0")]
public class AcceptContextStoreChangesTask : AbstractWorkflowStep
{
public AcceptContextStoreChangesTask(Guid schemaExtensionId)
: base(schemaExtensionId) {}
public AcceptContextStoreChangesTask(Key primaryKey)
: base(primaryKey) {}
#region Properties
public Guid ContextStoreId;

[TypeConverter(typeof(ContextStoreConverter))]
[NotNullModelElementRule]
[XmlReference("contextStore", "ContextStoreId")]
public IContextStore ContextStore
{
get
{
var key = new ModelElementKey
{
Id = this.ContextStoreId
};
return (IContextStore)PersistenceProvider.RetrieveInstance(
typeof(AbstractSchemaItem), key);
}
set
{
if(value == null)
{
ContextStoreId = Guid.Empty;
}
else
{
ContextStoreId = (Guid)value.PrimaryKey["Id"];
}
}
}
#endregion
}
}
@@ -0,0 +1,45 @@
#region license
/*
Copyright 2005 - 2022 Advantage Solutions, s. r. o.

This file is part of ORIGAM (http://www.origam.org).

ORIGAM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

ORIGAM 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 General Public License for more details.

You should have received a copy of the GNU General Public License
along with ORIGAM. If not, see <http://www.gnu.org/licenses/>.
*/
#endregion

using System;
using Origam.Schema.WorkflowModel;
using Origam.Service.Core;

namespace Origam.Workflow.Tasks
{
public class AcceptContextStoreChangesEngineTask
: AbstractWorkflowEngineTask
{
protected override void OnExecute()
{
var acceptContextStoreChangesTask = Step as AcceptContextStoreChangesTask;
if(!(Engine.RuleEngine.GetContext(
acceptContextStoreChangesTask.ContextStore)
is IDataDocument dataDocument))
{
throw new ArgumentException(
@"Context store doesn't implement IDataDocument interface.",
$"ContextStore:{acceptContextStoreChangesTask.ContextStore.Name}");
}
dataDocument.DataSet.AcceptChanges();
}
}
}
74 changes: 28 additions & 46 deletions backend/Origam.Workflow/WorkflowTaskFactory.cs
Expand Up @@ -24,56 +24,38 @@

namespace Origam.Workflow
{
/// <summary>
/// Summary description for WorkflowTaskFactory.
/// </summary>
public class WorkflowTaskFactory
{
public static IWorkflowEngineTask GetTask(IWorkflowStep step)
{
if(step is CheckRuleStep)
{
return new Tasks.CheckRuleEngineTask();
}
else if(step is ServiceMethodCallTask)
{
return new Tasks.ServiceMethodCallEngineTask();
}
else if(step is WorkflowCallTask)
{
return new Tasks.WorkflowCallEngineTask();
}
else if(step is ForeachWorkflowBlock)
{
return new Tasks.ForEachBlockEngineTask();
}
else if(step is TransactionWorkflowBlock)
{
return new Tasks.TransactionBlockEngineTask();
}
else if(step is UIFormTask)
{
return new Tasks.UIEngineTask();
}
else if(step is SetWorkflowPropertyTask)
{
return new Tasks.SetWorkflowPropertyEngineTask();
}
else if(step is UpdateContextTask)
{
return new Tasks.UpdateContextEngineTask();
}
else if(step is LoopWorkflowBlock)
{
return new Tasks.LoopBlockEngineTask();
}
else if(step is WaitTask)
{
return new Tasks.WaitEngineTask();
}
else
{
throw new ArgumentOutOfRangeException("step", step, ResourceUtils.GetString("ErrorStepNotImplemented"));
switch(step)
{
case CheckRuleStep _:
return new Tasks.CheckRuleEngineTask();
case ServiceMethodCallTask _:
return new Tasks.ServiceMethodCallEngineTask();
case WorkflowCallTask _:
return new Tasks.WorkflowCallEngineTask();
case ForeachWorkflowBlock _:
return new Tasks.ForEachBlockEngineTask();
case TransactionWorkflowBlock _:
return new Tasks.TransactionBlockEngineTask();
case UIFormTask _:
return new Tasks.UIEngineTask();
case SetWorkflowPropertyTask _:
return new Tasks.SetWorkflowPropertyEngineTask();
case UpdateContextTask _:
return new Tasks.UpdateContextEngineTask();
case AcceptContextStoreChangesTask _:
return new Tasks.AcceptContextStoreChangesEngineTask();
case LoopWorkflowBlock _:
return new Tasks.LoopBlockEngineTask();
case WaitTask _:
return new Tasks.WaitEngineTask();
default:
throw new ArgumentOutOfRangeException(
"step", step,
ResourceUtils.GetString("ErrorStepNotImplemented"));
}
}
}
Expand Down