From 9ec9d46412bba57325e111e01b94187ae98ae0a2 Mon Sep 17 00:00:00 2001
From: Jonas Graubner <82174634+JoTec2002@users.noreply.github.com>
Date: Wed, 21 Feb 2024 17:42:49 +0100
Subject: [PATCH 01/17] Create docker-compose for MongoDB
---
content-for-demo/docker-compose.yaml | 13 +++++++++++++
1 file changed, 13 insertions(+)
create mode 100644 content-for-demo/docker-compose.yaml
diff --git a/content-for-demo/docker-compose.yaml b/content-for-demo/docker-compose.yaml
new file mode 100644
index 000000000..c248196c5
--- /dev/null
+++ b/content-for-demo/docker-compose.yaml
@@ -0,0 +1,13 @@
+version: '3.8'
+services:
+ mongodb:
+ image: mongo
+ hostname: "mongo"
+ restart: always
+ volumes:
+ - ./mongo/data:/data/db
+ ports:
+ - '27017:27017'
+ environment:
+ - MONGO_INITDB_ROOT_USERNAME=mongo
+ - MONGO_INITDB_ROOT_PASSWORD=mongo
\ No newline at end of file
From 7753a39e2c0542af0145596e3d85fb9194305dc2 Mon Sep 17 00:00:00 2001
From: Jonas Graubner <82174634+JoTec2002@users.noreply.github.com>
Date: Wed, 21 Feb 2024 17:43:50 +0100
Subject: [PATCH 02/17] Add MongoDB Driver
---
src/AasxServerBlazor/Properties/launchSettings.json | 2 +-
src/AasxServerStandardBib/AasxServerStandardBib.csproj | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/AasxServerBlazor/Properties/launchSettings.json b/src/AasxServerBlazor/Properties/launchSettings.json
index ecd4b048a..e345b36a6 100644
--- a/src/AasxServerBlazor/Properties/launchSettings.json
+++ b/src/AasxServerBlazor/Properties/launchSettings.json
@@ -10,7 +10,7 @@
},
"AasxServerBlazor": {
"commandName": "Project",
- "commandLineArgs": "--no-security --aasx-in-memory 1000 --data-path \"C:\\Development\\PCF View\" --edit --external-blazor http://localhost:5001",
+ "commandLineArgs": "--no-security --aasx-in-memory 1000 --data-path \"C:\\GitClones\\aasx-server\\content-for-demo\\aasxs\" --edit --external-blazor http://localhost:5001",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
diff --git a/src/AasxServerStandardBib/AasxServerStandardBib.csproj b/src/AasxServerStandardBib/AasxServerStandardBib.csproj
index 1409baa9c..c4738e816 100644
--- a/src/AasxServerStandardBib/AasxServerStandardBib.csproj
+++ b/src/AasxServerStandardBib/AasxServerStandardBib.csproj
@@ -32,6 +32,7 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
+
From f333ec03198e175a0b699e664a7380de11262623 Mon Sep 17 00:00:00 2001
From: Jonas Graubner <82174634+JoTec2002@users.noreply.github.com>
Date: Wed, 21 Feb 2024 17:44:15 +0100
Subject: [PATCH 03/17] Insert AssetEnv into MongoDB on startup
---
src/AasxServerStandardBib/Database.cs | 81 +++++++++++++++++++++++++++
src/AasxServerStandardBib/Program.cs | 12 ++++
2 files changed, 93 insertions(+)
create mode 100644 src/AasxServerStandardBib/Database.cs
diff --git a/src/AasxServerStandardBib/Database.cs b/src/AasxServerStandardBib/Database.cs
new file mode 100644
index 000000000..ed673a082
--- /dev/null
+++ b/src/AasxServerStandardBib/Database.cs
@@ -0,0 +1,81 @@
+using MongoDB.Bson.Serialization.Serializers;
+using MongoDB.Bson.Serialization;
+using MongoDB.Driver;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using AasxServerStandardBib.Exceptions;
+using MongoDB.Bson;
+
+
+//Author: Jonas Graubner
+//contact: jogithub@graubner-bayern.de
+namespace AasxServerStandardBib
+{
+ public interface IDatabase
+ {
+ void Initialize(String connectionString);
+ public void writeDB(String collectionName, object data, bool throwError = false);
+ public void importAASCoreEnvironment(AasCore.Aas3_0.Environment environment);
+ }
+ public class MongoDatabase : IDatabase
+ {
+ private MongoClient _client;
+ private IMongoDatabase _database;
+
+ public void Initialize(String connectionString)
+ {
+ //_client = new MongoClient("mongodb://AAS:SefuSWE63811!@192.168.0.22:27017/?authSource=AAS");
+ _client = new MongoClient(connectionString);
+ try
+ {
+ _client.StartSession();
+ }
+ catch (System.TimeoutException ex)
+ {
+ System.Console.WriteLine(ex.Message);
+ System.Environment.Exit(1);
+ }
+
+ _database = _client.GetDatabase("AAS");
+ var objectSerializer = new ObjectSerializer(type => ObjectSerializer.DefaultAllowedTypes(type) || type.FullName.StartsWith("AasCore") || type.FullName.StartsWith("MongoDB"));
+ BsonSerializer.RegisterSerializer(objectSerializer);
+ }
+
+ public void writeDB(String collectionName, object data, bool throwError = false)
+ {
+ var collection = _database.GetCollection