Skip to content

Commit

Permalink
Importer now supports v0.2.0 of the AAS ontology
Browse files Browse the repository at this point in the history
  • Loading branch information
JMayrbaeurl committed Feb 15, 2022
1 parent 63a4135 commit 1363393
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 73 deletions.
26 changes: 26 additions & 0 deletions AAS API on Azure.sln
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{D3185476
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AASX Command line", "AASX Command line", "{803CDCDE-B5BD-4EE7-A873-68B352F0A275}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AASX File Service", "AASX File Service", "{37B709F4-6530-461C-BB69-2E96286F7F67}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AAS Entire services", "AAS Entire services", "{498C9BA9-D946-4D8B-BB37-AD0FC939D457}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AAS Discovery", "AAS Discovery", "{6667EF7A-F23F-46AD-B3C7-BE52355F6BE7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AAS Registry", "AAS Registry", "{0D24FB47-4A2B-4228-84C4-251642E6C1F7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AAS Shell repository", "AAS Shell repository", "{60E05FDD-8466-4A85-AF46-82C451B53C37}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{FC582922-7227-4B4C-8FE2-28BEB8D06AF4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -123,6 +135,20 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{37E281C2-FC84-4BD9-AFB5-AC55A9D92B0F} = {60E05FDD-8466-4A85-AF46-82C451B53C37}
{8246142F-9B71-424D-A219-9F4BA4C4B77B} = {FC582922-7227-4B4C-8FE2-28BEB8D06AF4}
{71AD2742-04E6-4C8C-8D94-C061DEE9D5A3} = {60E05FDD-8466-4A85-AF46-82C451B53C37}
{2295DDEC-6AD9-41A5-82A9-FA72BFBC98E8} = {60E05FDD-8466-4A85-AF46-82C451B53C37}
{5E55C6F8-30F0-46BC-8637-D5B397E04D6B} = {498C9BA9-D946-4D8B-BB37-AD0FC939D457}
{C82208F3-1191-4284-8D92-2E70C804E028} = {FC582922-7227-4B4C-8FE2-28BEB8D06AF4}
{E657B3A4-0D61-4EDB-8B42-E3B137D1AC01} = {6667EF7A-F23F-46AD-B3C7-BE52355F6BE7}
{A1582F1D-ED33-4197-A7C8-73BA6802435D} = {37B709F4-6530-461C-BB69-2E96286F7F67}
{E3D5DCB3-4CA1-4833-8A86-DA3D33D1748E} = {37B709F4-6530-461C-BB69-2E96286F7F67}
{82A9C310-4E09-4FD7-B3DB-F9E6C670A536} = {37B709F4-6530-461C-BB69-2E96286F7F67}
{F54DA57A-DC54-4F84-A0C7-0ED10B60C226} = {6667EF7A-F23F-46AD-B3C7-BE52355F6BE7}
{0D0AD4E2-C76D-43F7-B62E-6D386DF2A93E} = {0D24FB47-4A2B-4228-84C4-251642E6C1F7}
{A4F5E0BC-2400-422E-9D38-6B82BB3E1347} = {0D24FB47-4A2B-4228-84C4-251642E6C1F7}
{B3AA9231-9B5E-4A71-AE05-57A687CD9097} = {0D24FB47-4A2B-4228-84C4-251642E6C1F7}
{ECD5A9BE-8210-4BA6-A1FC-F23A3F0C7B84} = {803CDCDE-B5BD-4EE7-A873-68B352F0A275}
{5BBB7304-26FC-4690-BEF4-59782E720A68} = {803CDCDE-B5BD-4EE7-A873-68B352F0A275}
{803CDCDE-B5BD-4EE7-A873-68B352F0A275} = {D3185476-EC73-4773-BA8D-E19147F729AE}
Expand Down
26 changes: 26 additions & 0 deletions tools/aasx-cmdline-tests/SimpleAASXImportTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using AAS.AASX.CmdLine.Import;
using AAS.AASX.CmdLine.Import.ADT;
using AdminShellNS;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.IO;
using System.Net.Http;
using static AdminShellNS.AdminShellV20;

namespace AAS.AASX.CmdLine.Test.Import
Expand All @@ -14,6 +17,8 @@ public class SimpleAASXImportTests : AbstractTestSupport
{
private IAASXImporter importer;

private HttpClient httpClient;

[TestInitialize]
public void Setup()
{
Expand All @@ -25,6 +30,7 @@ public void Setup()

services.AddSingleton<IAASRepo, ADTAASRepo>();
services.AddSingleton<IAASXImporter, ADTAASXPackageImporter>();
services.AddHttpClient();
configuration = hostContext.Configuration;
})
.Build();
Expand All @@ -33,6 +39,7 @@ public void Setup()
IServiceProvider provider = serviceScope.ServiceProvider;

importer = provider.GetRequiredService<IAASXImporter>();
this.httpClient = provider.GetRequiredService<IHttpClientFactory>().CreateClient();
}

[TestMethod]
Expand All @@ -47,5 +54,24 @@ public void TestImportRelationShipElement01()
string dtId = importer.ImportRelationshipElement(relElement).GetAwaiter().GetResult();
Assert.IsFalse(String.IsNullOrEmpty(dtId));
}

[TestMethod]
public void TestImportConceptDescription()
{
string outputPath = Path.GetTempPath() + "01_Festo.aasx";
byte[] fileBytes = this.httpClient.GetByteArrayAsync(new Uri("https://admin-shell-io.com/samples/aasx/01_Festo.aasx")).GetAwaiter().GetResult();
System.IO.File.WriteAllBytes(outputPath, fileBytes);

try
{
using var package = new AdminShellPackageEnv(outputPath);

this.importer.ImportConceptDescription(package.AasEnv.ConceptDescriptions[0]).GetAwaiter().GetResult();
}
finally
{
System.IO.File.Delete(outputPath);
}
}
}
}
1 change: 1 addition & 0 deletions tools/aasx-cmdline/AASXImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public interface IAASXImporter

public Task<string> ImportRelationshipElement(RelationshipElement relElement, ImportContext processInfo = null);
public Task<string> ImportAnnotatedRelationshipElement(AnnotatedRelationshipElement relElement, ImportContext processInfo = null);
public Task ImportConceptDescription(ConceptDescription conceptDescription, ImportContext processInfo = null);
}

public class TwinRef<T>
Expand Down
17 changes: 0 additions & 17 deletions tools/aasx-cmdline/ADTAASRepo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,5 @@ public async Task<string> FindTwinForReference(AdminShellV20.Reference reference
else
return null;
}

public async Task<string> KeyExists(AdminShellV20.Key key)
{
string result = null;

string queryString = $"SELECT * FROM digitaltwins dt WHERE IS_OF_MODEL('{ADTAASOntology.MODEL_KEY}') " +
$"AND key = '{key.type}' " + $"AND idType = '{AASUtils.URITOIRI(key.idType)}' " + $"AND value = '{key.value}'";

AsyncPageable<BasicDigitalTwin> queryResult = dtClient.QueryAsync<BasicDigitalTwin>(queryString);
await foreach (BasicDigitalTwin twin in queryResult)
{
result = twin.Id;
break;
}

return result;
}
}
}
Loading

0 comments on commit 1363393

Please sign in to comment.