-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added support for form summary - Added stylesheet for html generation - Added lastchanged as new parameter to MigrationController.CreateDataElement - Support for migrating text in languages not defined in a2 app - Removed playwright - Removed System.Drawing - Added altinn 2 instance event types
- Loading branch information
1 parent
d16eef8
commit f9b9acf
Showing
11 changed files
with
121 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,6 @@ | |
|
||
using Microsoft.Extensions.Logging; | ||
using Microsoft.Extensions.Options; | ||
using Microsoft.Extensions.Primitives; | ||
using Microsoft.Net.Http.Headers; | ||
|
||
namespace Altinn.Platform.Storage.Controllers | ||
|
@@ -98,7 +97,7 @@ public async Task<ActionResult<Instance>> CreateInstance([FromBody] Instance ins | |
{ | ||
//// TODO Open issue: what about createdby and lastchangedby? | ||
|
||
Instance storedInstance = null; | ||
Instance storedInstance; | ||
try | ||
{ | ||
int a2ArchiveReference = int.Parse(instance.DataValues["A2ArchRef"]); | ||
|
@@ -124,7 +123,8 @@ public async Task<ActionResult<Instance>> CreateInstance([FromBody] Instance ins | |
/// Inserts new data element | ||
/// </summary> | ||
/// <param name="instanceGuid">The instanceGuid.</param> | ||
/// <param name="timestampTicks">Element timestamp ticks</param> | ||
/// <param name="createdTicks">Element created timestamp ticks</param> | ||
/// <param name="changedTicks">Element last changed timestamp ticks</param> | ||
/// <param name="dataType">Element data type</param> | ||
/// <param name="formid">A2 form id</param> | ||
/// <param name="lformid">A2 logical form id</param> | ||
|
@@ -141,14 +141,16 @@ public async Task<ActionResult<Instance>> CreateInstance([FromBody] Instance ins | |
[DisableRequestSizeLimit] | ||
public async Task<ActionResult<DataElement>> CreateDataElement( | ||
[FromRoute]Guid instanceGuid, | ||
[FromQuery(Name = "timestampticks")]long timestampTicks, | ||
[FromQuery(Name = "createdticks")]long createdTicks, | ||
[FromQuery(Name = "changedticks")]long changedTicks, | ||
[FromQuery(Name = "datatype")]string dataType, | ||
[FromQuery(Name = "formid")]string formid, | ||
[FromQuery(Name = "lformid")]string lformid, | ||
[FromQuery(Name = "prestext")]string presenationText, | ||
[FromQuery(Name = "vispages")]string visiblePages) | ||
{ | ||
DateTime timestamp = new DateTime(timestampTicks, DateTimeKind.Utc).ToLocalTime(); | ||
DateTime created = new DateTime(createdTicks, DateTimeKind.Utc).ToLocalTime(); | ||
DateTime lastChanged = new DateTime(changedTicks, DateTimeKind.Utc).ToLocalTime(); | ||
|
||
// TODO Open issue: what about createdby and lastchangedby? Ref. instance | ||
Check warning on line 155 in src/Storage/Controllers/MigrationController.cs
|
||
|
||
|
@@ -165,12 +167,12 @@ public async Task<ActionResult<DataElement>> CreateDataElement( | |
DataElement dataElement = new() | ||
{ | ||
Id = dataElementId, | ||
Created = timestamp, | ||
Created = created, | ||
CreatedBy = instance.CreatedBy, | ||
DataType = dataType, | ||
InstanceGuid = instanceGuid.ToString(), | ||
IsRead = true, | ||
LastChanged = timestamp, | ||
LastChanged = lastChanged, | ||
LastChangedBy = instance.LastChangedBy, // TODO: Find out what to populate here | ||
BlobStoragePath = DataElementHelper.DataFileName(instance.AppId, instanceGuid.ToString(), dataElementId), | ||
Metadata = formid == null ? null : new() | ||
|
@@ -203,6 +205,7 @@ public async Task<ActionResult<DataElement>> CreateDataElement( | |
"signature-presentation" => "ondemand/signature", | ||
"ref-data-as-pdf" => "ondemand/formdatapdf", | ||
"ref-data-as-html" => "ondemand/formdatahtml", | ||
"ref-summary-data-as-html" => "ondemand/formsummaryhtml", | ||
"payment-presentation" => "ondemand/payment", | ||
_ => throw new ArgumentException(dataElement.DataType), | ||
}; | ||
|
@@ -303,20 +306,32 @@ public async Task<ActionResult<Instance>> CreateText([FromRoute] string org, [Fr | |
{ | ||
try | ||
{ | ||
// There is allways an existing text from the app migration | ||
TextResource textResource = await _textRepository.Get(org, app, language); | ||
using var reader = new StreamReader(Request.Body); | ||
var resource = textResource.Resources.Find(resource => resource.Id == key); | ||
if (resource == null) | ||
if (textResource == null) | ||
{ | ||
textResource.Resources.Add(new() { Id = key, Value = await reader.ReadToEndAsync() }); | ||
textResource = await _textRepository.Create(org, app, new TextResource() | ||
{ | ||
Id = (await _applicationRepository.FindOne($"{org}/{app}", org)).Id, | ||
Language = language, | ||
Org = org, | ||
Resources = [new TextResourceElement() { Id = key, Value = await reader.ReadToEndAsync() }] | ||
}); | ||
} | ||
else | ||
{ | ||
resource.Value = await reader.ReadToEndAsync(); | ||
} | ||
var resource = textResource.Resources.Find(resource => resource.Id == key); | ||
if (resource == null) | ||
{ | ||
textResource.Resources.Add(new() { Id = key, Value = await reader.ReadToEndAsync() }); | ||
} | ||
else | ||
{ | ||
resource.Value = await reader.ReadToEndAsync(); | ||
} | ||
|
||
textResource = await _textRepository.Update(org, app, textResource); | ||
textResource = await _textRepository.Update(org, app, textResource); | ||
} | ||
|
||
return Created((string)null, textResource); | ||
} | ||
|
@@ -396,16 +411,17 @@ public async Task<ActionResult> CreateImage() | |
/// <param name="lformid">A2 logical form id</param> | ||
/// <param name="pagenumber">Page number</param> | ||
/// <param name="language">Language</param> | ||
/// <param name="xsltype">Xsl type</param> | ||
/// <returns>Ok</returns> | ||
[AllowAnonymous] | ||
[HttpPost("xsl/{org}/{app}/{lformid}/{pagenumber}/{language}")] | ||
[HttpPost("xsl/{org}/{app}/{lformid}/{pagenumber}/{language}/{xsltype}")] | ||
[DisableFormValueModelBinding] | ||
[ProducesResponseType(StatusCodes.Status201Created)] | ||
[Produces("application/json")] | ||
public async Task<ActionResult> CreateXsl([FromRoute] string org, [FromRoute] string app, [FromRoute] int lformid, [FromRoute] int pagenumber, [FromRoute] string language) | ||
public async Task<ActionResult> CreateXsl([FromRoute] string org, [FromRoute] string app, [FromRoute] int lformid, [FromRoute] int pagenumber, [FromRoute] string language, [FromRoute] int xsltype) | ||
{ | ||
using var reader = new StreamReader(Request.Body); | ||
await _a2Repository.CreateXsl(org, app, lformid, language, pagenumber, await reader.ReadToEndAsync()); | ||
await _a2Repository.CreateXsl(org, app, lformid, language, pagenumber, await reader.ReadToEndAsync(), xsltype); | ||
return Created(); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ALTER TABLE storage.a2xsls ADD COLUMN IF NOT EXISTS xsltype INT NOT NULL DEFAULT -1; | ||
ALTER TABLE storage.a2xsls DROP CONSTRAINT a2xslsalternateid; | ||
ALTER TABLE storage.a2xsls ADD CONSTRAINT a2xslsalternateid UNIQUE (app, org, lformid, pagenumber, language, xsltype); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.