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

FEATURE: Workflow api now accepts an unnamed object or list of object… #2371

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
@@ -0,0 +1,41 @@
#region license

/*
Copyright 2005 - 2024 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.Collections.Generic;
using System.Xml.Linq;

namespace Origam.DA.Service.MetaModelUpgrade.UpdateScriptContainers
{
class PageParameterMappingScriptContainer : UpgradeScriptContainer
{
public override string FullTypeName { get; } = "Origam.Schema.GuiModel.PageParameterMapping";
public override List<string> OldFullTypeNames { get; }
public override string[] OldPropertyXmlNames { get; }

public PageParameterMappingScriptContainer()
{
AddEmptyUpgrade("6.0.0", "6.0.1");
}
}
}
17 changes: 14 additions & 3 deletions backend/Origam.Schema.GuiModel/Pages/PageParameterMapping.cs
Expand Up @@ -32,7 +32,7 @@ namespace Origam.Schema.GuiModel
[SchemaItemDescription("Parameter Mapping", "Parameter Mappings", "file-mapping.png")]
[HelpTopic("Parameter+Mapping")]
[XmlModelRoot(CategoryConst)]
[ClassMetaVersion("6.0.0")]
[ClassMetaVersion("6.0.1")]
public class PageParameterMapping : AbstractSchemaItem
{
public const string CategoryConst = "PageParameterMapping";
Expand All @@ -50,10 +50,21 @@ private void Init()
[Description("Name of url query string parameter, e.g. in case http://my-api/my-page?searchstring=value the mapped parametr should be 'searchstring'")]
[XmlAttribute ("mappedParameter")]
public string MappedParameter { get; set; } = "";

public Guid DataConstantId;

[Category("Mapping")]
[Description("Name of a datastructure entity in a mapped context "
+ "store's datastructure. If defined, the incoming json body is "
+ "wrapped by a new object with the given name. So that way, the"
+ " original input json object is expected as just datastructure "
+ "entity object itself or a list of datastructure entity objects"
+ " on json top level.")]
[DefaultValue("")]
[XmlAttribute("entityName")]
public string DatastructureEntityName { get; set; } = "";

public Guid DataConstantId;

[Category("Mapping")]
[TypeConverter(typeof(DataConstantConverter))]
[RefreshProperties(RefreshProperties.Repaint)]
[XmlReference("defaultValue", "DataConstantId")]
Expand Down
15 changes: 14 additions & 1 deletion backend/Origam.Server/Pages/UserApiProcessor.cs
Expand Up @@ -42,6 +42,7 @@
using Origam.Extensions;
using Origam.Service.Core;
using ImageMagick;
using IdentityServer4.Extensions;

namespace Origam.Server.Pages
{
Expand Down Expand Up @@ -508,7 +509,19 @@ private static void MapFileToParameter(IHttpContextWrapper context, Dictionary<s
// DataSet ds = JsonConvert.DeserializeObject<DataSet>(body);
XmlDocument xd = new XmlDocument();
// deserialize from JSON to XML
xd = (XmlDocument)JsonConvert.DeserializeXmlNode(body, "ROOT");
if (ppm.DatastructureEntityName.IsNullOrEmpty())
{
xd = (XmlDocument)JsonConvert
.DeserializeXmlNode(body, "ROOT");
}
else
{
xd = (XmlDocument)JsonConvert
.DeserializeXmlNode(
"{\"" + ppm.DatastructureEntityName
+ "\" :" + body + "}"
, "ROOT");
}
if (log.IsDebugEnabled)
{
log.Debug("Intermediate JSON deserialized XML:");
Expand Down
@@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<x:file xmlns:ap="http://schemas.origam.com/Origam.Schema.GuiModel.AbstractPage/6.0.0" xmlns:asi="http://schemas.origam.com/Origam.Schema.AbstractSchemaItem/6.0.0" xmlns:ppm="http://schemas.origam.com/Origam.Schema.GuiModel.PageParameterMapping/6.0.0" xmlns:x="http://schemas.origam.com/model-persistence/1.0.0" xmlns:xdp="http://schemas.origam.com/Origam.Schema.GuiModel.XsltDataPage/6.0.0">
<x:file
xmlns:x="http://schemas.origam.com/model-persistence/1.0.0"
xmlns:ap="http://schemas.origam.com/Origam.Schema.GuiModel.AbstractPage/6.0.0"
xmlns:asi="http://schemas.origam.com/Origam.Schema.AbstractSchemaItem/6.0.0"
xmlns:ppm="http://schemas.origam.com/Origam.Schema.GuiModel.PageParameterMapping/6.0.1"
xmlns:xdp="http://schemas.origam.com/Origam.Schema.GuiModel.XsltDataPage/6.0.0">
<xdp:Page
asi:abstract="false"
ap:allowDelete="false"
Expand Down
@@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<x:file xmlns:ap="http://schemas.origam.com/Origam.Schema.GuiModel.AbstractPage/6.0.0" xmlns:asi="http://schemas.origam.com/Origam.Schema.AbstractSchemaItem/6.0.0" xmlns:ppm="http://schemas.origam.com/Origam.Schema.GuiModel.PageParameterMapping/6.0.0" xmlns:wp="http://schemas.origam.com/Origam.Schema.WorkflowModel.WorkflowPage/6.0.0" xmlns:x="http://schemas.origam.com/model-persistence/1.0.0">
<x:file
xmlns:x="http://schemas.origam.com/model-persistence/1.0.0"
xmlns:ap="http://schemas.origam.com/Origam.Schema.GuiModel.AbstractPage/6.0.0"
xmlns:asi="http://schemas.origam.com/Origam.Schema.AbstractSchemaItem/6.0.0"
xmlns:ppm="http://schemas.origam.com/Origam.Schema.GuiModel.PageParameterMapping/6.0.1"
xmlns:wp="http://schemas.origam.com/Origam.Schema.WorkflowModel.WorkflowPage/6.0.0">
<wp:Page
asi:abstract="false"
ap:allowDelete="false"
Expand Down
2 changes: 1 addition & 1 deletion model-tests/model/Security/Page/adminaddUser.origam
Expand Up @@ -3,7 +3,7 @@
xmlns:x="http://schemas.origam.com/model-persistence/1.0.0"
xmlns:ap="http://schemas.origam.com/Origam.Schema.GuiModel.AbstractPage/6.0.0"
xmlns:asi="http://schemas.origam.com/Origam.Schema.AbstractSchemaItem/6.0.0"
xmlns:ppm="http://schemas.origam.com/Origam.Schema.GuiModel.PageParameterMapping/6.0.0"
xmlns:ppm="http://schemas.origam.com/Origam.Schema.GuiModel.PageParameterMapping/6.0.1"
xmlns:wp="http://schemas.origam.com/Origam.Schema.WorkflowModel.WorkflowPage/6.0.0">
<wp:Page
asi:abstract="false"
Expand Down
Expand Up @@ -3,7 +3,7 @@
xmlns:x="http://schemas.origam.com/model-persistence/1.0.0"
xmlns:ap="http://schemas.origam.com/Origam.Schema.GuiModel.AbstractPage/6.0.0"
xmlns:asi="http://schemas.origam.com/Origam.Schema.AbstractSchemaItem/6.0.0"
xmlns:ppm="http://schemas.origam.com/Origam.Schema.GuiModel.PageParameterMapping/6.0.0"
xmlns:ppm="http://schemas.origam.com/Origam.Schema.GuiModel.PageParameterMapping/6.0.1"
xmlns:wp="http://schemas.origam.com/Origam.Schema.WorkflowModel.WorkflowPage/6.0.0">
<wp:Page
asi:abstract="false"
Expand Down
2 changes: 1 addition & 1 deletion model-tests/model/Widgets/Page/Attachment.origam
Expand Up @@ -4,7 +4,7 @@
xmlns:ap="http://schemas.origam.com/Origam.Schema.GuiModel.AbstractPage/6.0.0"
xmlns:asi="http://schemas.origam.com/Origam.Schema.AbstractSchemaItem/6.0.0"
xmlns:fdp="http://schemas.origam.com/Origam.Schema.GuiModel.FileDownloadPage/6.0.0"
xmlns:ppm="http://schemas.origam.com/Origam.Schema.GuiModel.PageParameterMapping/6.0.0">
xmlns:ppm="http://schemas.origam.com/Origam.Schema.GuiModel.PageParameterMapping/6.0.1">
<fdp:Page
asi:abstract="false"
ap:allowDelete="false"
Expand Down