Skip to content

Commit

Permalink
FasTnT EPCIS 2.0.1 (#175)
Browse files Browse the repository at this point in the history
* Bump Microsoft.Extensions.DependencyInjection from 3.1.1 to 3.1.2

Bumps [Microsoft.Extensions.DependencyInjection](https://github.com/aspnet/Extensions) from 3.1.1 to 3.1.2.
- [Release notes](https://github.com/aspnet/Extensions/releases)
- [Commits](dotnet/extensions@v3.1.1...v3.1.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Bump Microsoft.Extensions.Logging.Abstractions from 3.1.1 to 3.1.2

Bumps [Microsoft.Extensions.Logging.Abstractions](https://github.com/aspnet/Extensions) from 3.1.1 to 3.1.2.
- [Release notes](https://github.com/aspnet/Extensions/releases)
- [Commits](dotnet/extensions@v3.1.1...v3.1.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Bump Microsoft.Extensions.Logging from 3.1.1 to 3.1.2

Bumps [Microsoft.Extensions.Logging](https://github.com/aspnet/Extensions) from 3.1.1 to 3.1.2.
- [Release notes](https://github.com/aspnet/Extensions/releases)
- [Commits](dotnet/extensions@v3.1.1...v3.1.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Bump Npgsql from 4.1.3 to 4.1.3.1

Bumps [Npgsql](https://github.com/npgsql/npgsql) from 4.1.3 to 4.1.3.1.
- [Release notes](https://github.com/npgsql/npgsql/releases)
- [Commits](npgsql/npgsql@v4.1.3...v4.1.3.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Add command lines parameters (#159)

* Add command lines parameters

* Add unit tests

* Bump MediatR from 8.0.0 to 8.0.1 (#160)

Bumps [MediatR](https://github.com/jbogard/mediatr) from 8.0.0 to 8.0.1.
- [Release notes](https://github.com/jbogard/mediatr/releases)
- [Commits](jbogard/MediatR@v8.0.0...v8.0.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Implement parameters (#161)

* Implement parameters

- EQATTR
- HASATTR
- "**_"-like parameters
- "**_INNER_"-like parameters

* Bump Microsoft.Extensions.Configuration.CommandLine from 3.1.2 to 3.1.3 (#162)

Bumps [Microsoft.Extensions.Configuration.CommandLine](https://github.com/aspnet/Extensions) from 3.1.2 to 3.1.3.
- [Release notes](https://github.com/aspnet/Extensions/releases)
- [Commits](dotnet/extensions@v3.1.2...v3.1.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* Bump Microsoft.Extensions.Logging.Abstractions from 3.1.2 to 3.1.3 (#163)

Bumps [Microsoft.Extensions.Logging.Abstractions](https://github.com/aspnet/Extensions) from 3.1.2 to 3.1.3.
- [Release notes](https://github.com/aspnet/Extensions/releases)
- [Commits](dotnet/extensions@v3.1.2...v3.1.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* Bump Microsoft.Extensions.DependencyInjection from 3.1.2 to 3.1.3 (#167)

Bumps [Microsoft.Extensions.DependencyInjection](https://github.com/aspnet/Extensions) from 3.1.2 to 3.1.3.
- [Release notes](https://github.com/aspnet/Extensions/releases)
- [Commits](dotnet/extensions@v3.1.2...v3.1.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* Bump Microsoft.Extensions.Logging from 3.1.2 to 3.1.3 (#164)

Bumps [Microsoft.Extensions.Logging](https://github.com/aspnet/Extensions) from 3.1.2 to 3.1.3.
- [Release notes](https://github.com/aspnet/Extensions/releases)
- [Commits](dotnet/extensions@v3.1.2...v3.1.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* Add XML/SOAP parsing tests (#168)

* Add unit tests

* Add XML parsing unit tests

* Update WhenParsingXmlGetSubscriptionIDsRequest.cs

* Add XML parsing unit tests

* Add SOAP parsing unit tests

Co-authored-by: Louis-Axel Ambroise <ambroise.la@gmail.com>

* Use .NET Core 3.1 LTS (#169)

* Update solution to use .NET Core 3.1

Use the latest LTS 3.1 framework

* Update dotnetcore.yml

Use .NET Core 3.1 in Github workflow

Co-authored-by: Louis-Axel Ambroise <ambroise.la@gmail.com>

* Fix/http status code (#170)

* Return 200 instead of 204

As specified in compliance document

* Fix tests

Co-authored-by: Louis-Axel Ambroise <ambroise.la@gmail.com>

* Update README.md

Update .NET Core version requirement

* Cleanup code (#171)

* Cleanup Host code

* Cleanup and update NuGet

Co-authored-by: Louis-Axel Ambroise <ambroise.la@gmail.com>

* Fix XML formatting (#172)

Add missing condition on ErrorDeclaration field existance

Co-authored-by: Louis-Axel Ambroise <ambroise.la@gmail.com>

* Fix azure deployment (#173)

Use IIS Integration instead of Kestrel

Co-authored-by: Louis-Axel Ambroise <ambroise.la@gmail.com>

* Bump version to 2.0.1 & cleanup code (#174)

Co-authored-by: Louis-Axel Ambroise <ambroise.la@gmail.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Louis-Axel Ambroise <ambroise.la@gmail.com>
  • Loading branch information
3 people authored Mar 27, 2020
1 parent 9b89ba9 commit 613937c
Show file tree
Hide file tree
Showing 69 changed files with 1,054 additions and 335 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 2.2.108
dotnet-version: 3.1.100
- name: Build with dotnet
run: dotnet build -c Release

Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@

# FasTnT EPCIS

FasTnT EPCIS is a lightweight GS1 EPCIS 1.2 repository written in C# using .NET Core 2.2, backed with PostGreSQL database.
FasTnT EPCIS is a lightweight GS1 EPCIS 1.2 repository written in C# using .NET Core 3.1, backed with PostGreSQL database.

## Setup

Prerequisites:
Prerequisites:
- PostGreSQL 9.5 or higher
- .NET Core 2.2 SDK
- .NET Core 3.1 SDK

Steps:
1. Download the source code, and create a new user/database in PostGreSQL for FasTnT ;
2. Update the connection string: `$ dotnet user-secrets set ConnectionStrings:FasTnT.Database "{your connectionstring}" -p src\FasTnT.Host\FasTnT.Host.csproj` ;
3. Start the repository with the command `$ dotnet run -p src\FasTnT.Host\FasTnT.Host.csproj` ;
4. Create the SQL schemas and tables: `curl -X POST http://localhost:54805/Setup/Database/Migrate` ;
3. Start the repository with the command `$ dotnet run -p src\FasTnT.Host\FasTnT.Host.csproj --urls "http://localhost:5102/"` ;
4. Create the SQL schemas and tables: `curl -X POST http://localhost:5102/Setup/Database/Migrate -d ""` ;
5. That's it! You have a properly working EPCIS 1.2 repository.

## HTTP Endpoints
Expand All @@ -25,7 +25,7 @@ Steps:

The API is secured using HTTP Basic authentication. The default username:password value is `admin:P@ssw0rd`

- Capture: `POST /v1_2/Capture`
- Capture: `POST /v1_2/Capture`
- Queries : `POST /v1_2/Query` or `POST /v1_2/Query.svc`
- Subscription trigger : `GET /v1_2/Subscription/Trigger/{triggerName}`

Expand Down Expand Up @@ -54,18 +54,18 @@ See the [wiki](https://github.com/FasTnT/epcis/wiki) for more details.
- GetStandardVersion
- GetQueryNames
- GetSubsciptionIDs
- Poll
- Poll
- SimpleEventQuery
- SimpleMasterDataQuery
- Query Callback:
- CallbackResults
- CallbackQueryTooLargeException
- CallbackImplementationException
- Subscriptions:
- Subscribe to an EPCIS request
- Subscribe to an EPCIS request
- Unsubscribe from EPCIS repository
- Trigger subscriptions that register to specific trigger name

# Authors

External contributions on FasTnT EPCIS repository are welcome from anyone. Many thanks to the people who already shown interest or contributed to this project ([@grudolf](https://github.com/grudolf), [@jnoruzi](https://github.com/jnoruzi) and many others).
Expand All @@ -78,4 +78,4 @@ This project is licensed under the Apache 2.0 license - see the LICENSE file for

Contact: fastnt@pm.me

_Last update: February 2020_
_Last update: March 2020_
118 changes: 87 additions & 31 deletions documents/EPCIS Examples - 1.2.postman_collection.json

Large diffs are not rendered by default.

189 changes: 0 additions & 189 deletions documents/EPCIS Examples - 2.0.postman_collection.json

This file was deleted.

5 changes: 4 additions & 1 deletion src/FasTnT.Data.PostgreSql/DataRetrieval/EventFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ public EventFetcher(IDbConnection connection)
public void Apply(EqualsCorrectiveEventIdFilter filter) => _query = _query.Where($"EXISTS(SELECT edi.event_id FROM epcis.event_declaration_eventid edi WHERE edi.corrective_eventid = ANY({_parameters.Add(filter.Values)}) AND edi.event_id = event.id)");
public void Apply(MasterdataHierarchyFilter filter) => _query = _query.Where($"({filter.Field.ToPgSql()} = ANY({_parameters.Add(filter.Values)}) OR EXISTS(SELECT h.parent_id FROM cbv.masterdata_hierarchy h WHERE h.parent_id = ANY({_parameters.Last}) AND h.children_id = {filter.Field.ToPgSql()} AND h.type = '{filter.Field.ToCbvType()}'))");
public void Apply(SourceDestinationFilter filter) => _query = _query.Where($"EXISTS(SELECT sd.event_id FROM epcis.source_destination sd WHERE sd.direction = {filter.Type.Id} AND sd.type = {_parameters.Add(filter.Name)} AND sd.source_dest_id = ANY({_parameters.Add(filter.Values)}) AND sd.event_id = event.id)");
public void Apply(CustomFieldFilter filter) => throw new System.NotImplementedException();
public void Apply(ExistsAttributeFilter filter) => _query = _query.Where($"EXISTS(SELECT at.id FROM cbv.attribute at WHERE at.masterdata_id = {filter.Field.ToPgSql()} AND at.id = {_parameters.Add(filter.AttributeName)})");
public void Apply(AttributeFilter filter) => _query = _query.Where($"EXISTS(SELECT at.id FROM cbv.attribute at WHERE at.masterdata_id = {filter.Field.ToPgSql()} AND at.id = {_parameters.Add(filter.AttributeName)} AND at.value = ANY({_parameters.Add(filter.Values)}))");
public void Apply(CustomFieldFilter filter) => _query = _query.Where($"EXISTS(SELECT cf.event_id FROM epcis.custom_field cf WHERE cf.event_id = event.id AND cf.type = {filter.Field.Type.Id} AND cf.namespace = {_parameters.Add(filter.Field.Namespace)} AND cf.name = {_parameters.Add(filter.Field.Name)} AND cf.parent_id IS {(filter.IsInner ? "NOT" : "")} NULL AND cf.text_value = ANY({_parameters.Add(filter.Values)}))");
public void Apply(ComparisonCustomFieldFilter filter) => _query = _query.Where($"EXISTS(SELECT cf.event_id FROM epcis.custom_field cf WHERE cf.event_id = event.id AND cf.type = {filter.Field.Type.Id} AND cf.namespace = {_parameters.Add(filter.Field.Namespace)} AND cf.name = {_parameters.Add(filter.Field.Name)} AND cf.parent_id IS {(filter.IsInner ? "NOT" : "")} NULL AND {filter.Value.GetCustomFieldName()} {filter.Comparator.ToSql()} {_parameters.Add(filter.Value)})");
public void Apply(LimitFilter filter) => _limit = filter.Value;

public async Task<IEnumerable<EpcisEvent>> Fetch(CancellationToken cancellationToken)
Expand Down
2 changes: 2 additions & 0 deletions src/FasTnT.Data.PostgreSql/DataRetrieval/ModelExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using FasTnT.Model.Events.Enums;
using FasTnT.Model.Utils;
using System;
using System.Collections.Generic;
using Mapping = System.Collections.Generic.Dictionary<FasTnT.Model.Utils.Enumeration, string>;

namespace FasTnT.Data.PostgreSql.DataRetrieval
Expand Down Expand Up @@ -44,6 +45,7 @@ public static class ModelExtensions
public static string ToPgSql(this OrderDirection direction) => GetValue(direction, SortOperators) ?? throw new Exception($"Unknown simple EPCIS event field: '{direction.DisplayName}'");
public static string ToPgSql(this EpcisField field) => GetValue(field, SimpleFields) ?? throw new Exception($"Unknown simple EPCIS event field: '{field.DisplayName}'");
public static string ToCbvType(this EpcisField field) => GetValue(field, CbvTypes) ?? throw new Exception($"Cannot convert to CBV type: '{field.DisplayName}'");
public static string GetCustomFieldName(this object value) => value is DateTime ? "cf.date_value" : "cf.numeric_value";

private static string GetValue(Enumeration value, Mapping mapping) => mapping.TryGetValue(value, out string result) ? result : null;
}
Expand Down
6 changes: 3 additions & 3 deletions src/FasTnT.Data.PostgreSql/FasTnT.Data.PostgreSql.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<LangVersion>7.1</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.30" />
<PackageReference Include="Dapper.SqlBuilder" Version="2.0.30" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.3" />
<PackageReference Include="morelinq" Version="3.3.2" />
<PackageReference Include="Npgsql" Version="4.1.3" />
<PackageReference Include="Npgsql" Version="4.1.3.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/FasTnT.Domain/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace FasTnT.Domain
{
public static class Constants
{
public static string VendorVersion = "2.0.0";
public static string VendorVersion = "2.0.1";
public static string StandardVersion = "1.2";

public static Assembly Assembly = typeof(Constants).Assembly;
Expand Down
3 changes: 3 additions & 0 deletions src/FasTnT.Domain/Data/IEventFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ public interface IEventFetcher
void Apply(LimitFilter filter);
void Apply(QuantityFilter filter);
void Apply(CustomFieldFilter filter);
void Apply(ComparisonCustomFieldFilter filter);
void Apply(ExistCustomFieldFilter filter);
void Apply(ExistsErrorDeclarationFilter filter);
void Apply(EqualsErrorReasonFilter filter);
void Apply(EqualsCorrectiveEventIdFilter filter);
void Apply(MasterdataHierarchyFilter filter);
void Apply(SourceDestinationFilter filter);
void Apply(ExistsAttributeFilter filter);
void Apply(AttributeFilter filter);
Task<IEnumerable<EpcisEvent>> Fetch(CancellationToken cancellationToken);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using FasTnT.Model;
using FasTnT.Model.Events.Enums;

namespace FasTnT.Domain.Data.Model.Filters
{
public class ComparisonCustomFieldFilter
{
public CustomField Field { get; set; }
public object Value { get; set; }
public bool IsInner { get; set; }
public FilterComparator Comparator { get; set; }
}
}
5 changes: 1 addition & 4 deletions src/FasTnT.Domain/Data/Model/Filters/CustomFieldFilter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using FasTnT.Model;
using FasTnT.Model.Events.Enums;

namespace FasTnT.Domain.Data.Model.Filters
{
Expand All @@ -8,6 +7,4 @@ public class CustomFieldFilter
public CustomField Field { get; set; }
public object[] Values { get; set; }
public bool IsInner { get; set; }
public FilterComparator Comparator { get; set; }
}
}
}}
14 changes: 14 additions & 0 deletions src/FasTnT.Domain/Data/Model/Filters/ExistCustomFieldFilter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FasTnT.Model;
using FasTnT.Model.Events.Enums;

namespace FasTnT.Domain.Data.Model.Filters
{
Expand All @@ -7,4 +8,17 @@ public class ExistCustomFieldFilter
public CustomField Field { get; set; }
public bool IsInner { get; set; }
}

public class ExistsAttributeFilter
{
public EpcisField Field { get; set; }
public string AttributeName { get; set; }
}

public class AttributeFilter
{
public EpcisField Field { get; set; }
public string AttributeName { get; set; }
public string[] Values { get; set; }
}
}
Loading

0 comments on commit 613937c

Please sign in to comment.