-
Notifications
You must be signed in to change notification settings - Fork 52
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
persistence v3 mongo #228
base: main
Are you sure you want to change the base?
persistence v3 mongo #228
Conversation
Reimplemented Interfaces for DB Use: - IAasxFileServerInterfaceService - IAdminShellPackageEnvironmentService - IConceptDescriptionService - ISubmodelService AASX Server Blazor / Startup.cs Change to DB Class (@JoTec2002 change later to dynamic switch based on startup Parameter)
Implementation of Many File operations still Missing
-> Files can be loaded into MongoDB -> Server can be stateless
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some major issues found. Please resolve them first and finish the open TODO's in your code, before we can continue the review. On any questions, please feel free to contact me.
@@ -0,0 +1 @@ | |||
/mongo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need a new gitignore here. That should also be configurable in the existing gitignore
@@ -10,7 +10,7 @@ | |||
}, | |||
"AasxServerBlazor": { | |||
"commandName": "Project", | |||
"commandLineArgs": "--no-security --secret-string-api 1234 --aasx-in-memory 1000 --data-path \"C:\\Development\\Ronny\" --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 --with-mongodb \"mongodb://mongo:mongo@localhost:27017/\"", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please revert the changes for --data-path
using System.IO; | ||
|
||
|
||
//Author: Jonas Graubner |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use personalised author tags. I know that we do not have a template for that yet, but creating your own one will be harder to resolve in the end. All your commits can be viewed in the git history and if you want to add yourself as a contributor, you can add a new entry in the CONTRIBUTORS.md
@@ -32,6 +32,8 @@ | |||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | |||
</PackageReference> | |||
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.13.1" /> | |||
<PackageReference Include="MongoDB.Driver" Version="2.25.0" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the license for these package checked, to be compatible with the open source guidelines?
|
||
public void Initialize(String connectionString) | ||
{ | ||
//_client = new MongoClient("mongodb://AAS:[email protected]:27017/?authSource=AAS"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't commit commented code. If you think this might be useful information as an example, please create a valid c# method summary
|
||
|
||
|
||
public List<IAssetAdministrationShell> GetAllAssetAdministrationShells(List<SpecificAssetId> assetIds = null, string idShort = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using LINQ for filtering to enhance readability and maintainability within this method.
|
||
public void DeleteAssetInformationThumbnail(int packageIndex, IResource defaultThumbnail) | ||
{ | ||
//TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding your TODO comments, you have two options:
- Please resolve the TODO before finalizing this PR.
- If you cannot resolve it immediately, please add detailed information on why and create a GitHub issue to keep track of it.
stream.Close(); | ||
}else | ||
{ | ||
//throw new ArgumentNullException(nameof(stream)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's important to handle exceptions appropriately rather than commenting them out. In your WriteFile
method, you've commented out the ArgumentNullException
handling for the stream
parameter. This approach can lead to unexpected behavior or silent failures if stream
is null, as it will not be properly handled or logged.
Best practice dictates that exceptions should be handled or propagated correctly to maintain application reliability and provide meaningful error messages for debugging. Commenting out exceptions can obscure issues and make troubleshooting more difficult, which is considered a code smell.
To improve, consider either uncommenting the exception handling and adding appropriate logging or refactor the method to handle null stream
scenarios more gracefully.
using (var cursor = _bucket.Find(filter, options)) | ||
{ | ||
var fileInfo = cursor.ToList().FirstOrDefault(); | ||
// fileInfo either has the matching file information or is null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could rather be used as a method summary.
/// <summary>
/// Retrieves the ObjectId of the latest file matching the specified filename in the GridFS bucket.
/// </summary>
/// <param name="filename">The filename of the file to retrieve.</param>
/// <returns>The ObjectId of the matching file, or ObjectId.Empty if no matching file is found.</returns>
}); | ||
} | ||
|
||
public void importAdminShellPackageEnv(AdminShellPackageEnv adminShellPackageEnv) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the standard C# naming for methods, which is PascalCase please
Hello,
I know it’s a relatively large Pull Request, but I still hope that it can be used. I'm open for feedback/ improvements.
This pull request is in an some what beta state of the feature but I wanted to be able to hopefully get some feedback.
Description
The gool if this pull request is adding alternatively to the Entity Framework a complete MongoDB Database integration.
Current state:
Newly added dependencies:
MongoDB.Driver
MongoDB.Driver.GridFS
Motivation and Context
The implementation is created as part of a German University Project at DHBW Stuttgart.
If added an early Version of the University Document below.
Studienarbeit_Jonas_Graubner_V0.1.pdf
The motivation for adding an alternative to the Entity Framework is, that it seems impossible to fully map the interfaces to EF. The MongoDB Driver was able to achieve this.
An Interface was created, so that new Native DB Driver still cloud be added in the Future.
For ease of use a docker compose file was added to startup an MongoDB – File will be extended to also include the server itself.
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
I used Apidog to run most of the queries against the original Server and afterwards my implementation and looked if the response was identical.
Test Environment:
Checklist: