Skip to content

Commit

Permalink
Merge pull request #23 from CrossBreezeNL/feature/update-issues
Browse files Browse the repository at this point in the history
Feature/update issues
  • Loading branch information
harmen-xb authored Aug 2, 2023
2 parents d3cec0d + a914ad8 commit cfa74fc
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 15 deletions.
6 changes: 3 additions & 3 deletions .github/actions/build-addin/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ runs:
run: msbuild -t:restore
# Install GitVersion
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.15
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: '5.5.x'
versionSpec: '5.x'
# Update the version numbers.
- name: Determine Version
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/execute@v0.9.15
uses: gittools/actions/gitversion/execute@v0
with:
updateAssemblyInfo: true
# Build the solution (without installer).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
<Version>5.8.5</Version>
</PackageReference>
<PackageReference Include="Microsoft.OData.Edm">
<Version>7.12.3</Version>
<Version>7.17.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down
19 changes: 18 additions & 1 deletion PowerDesigner_OData_AddIn/PdLogger.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
using System;
using System.CodeDom;

namespace CrossBreeze.Tools.PowerDesigner.AddIn.OData
{
public class PdLogger
{
// Set the name of the PowerDesigner variable to use, to enable the debug mode.
private static String DEBUG_MODE_VARIABLE_TEMPLATE = "%$ODATA_DEBUG_MODE%";

// A reference to the PowerDesigner Application object.
private PdCommon.Application _app;

Expand All @@ -12,6 +16,17 @@ public PdLogger(PdCommon.Application app)
this._app = app;
}

/// <summary>
/// Function to check whether debug mode is eanbled.
/// </summary>
/// <returns></returns>
private bool IsDebugMode()
{
if (this._app.ActiveModel != null)
return (((PdCommon.BaseModel)this._app.ActiveModel).EvaluateText(DEBUG_MODE_VARIABLE_TEMPLATE).ToLower().Equals("true"));
return false;
}

/// <summary>
/// Helper method to write a debug message in the PowerDesigner output window with a PowerDesigner object class name.
/// </summary>
Expand Down Expand Up @@ -57,7 +72,9 @@ public void Error(String message)
/// <param name="message">The debug message to write in the PowerDesigner output window</param>
public void Debug(String message)
{
this.Log(message, "DEBUG");
// Only write debug messages if debug mode is enabled.
if (this.IsDebugMode())
this.Log(message, "DEBUG");
}

/// <summary>
Expand Down
7 changes: 5 additions & 2 deletions PowerDesigner_OData_AddIn/PdODataModelUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class PdODataModelUpdater
{
// Name of the metadata file.
const string ODATA_METADATA_FILE_NAME = "OData Metadata";
const string ODATA_METADATA_FILE_CODE = "ODATA_METADATA";
const string ODATA_METADATA_FILE_CODE = "OData_Metadata";

/// <summary>
/// A list of supported OData authentication methods.
Expand Down Expand Up @@ -46,7 +46,7 @@ public PdODataModelUpdater(PdLogger logger, PdCommon.Application app)
/// <returns></returns>
public static PdCommon.FileObject GetODataMetadataFile(PdPDM.Model pdmModel)
{
var oDataMetadataFile = pdmModel.FindChildByCode(PdODataModelUpdater.ODATA_METADATA_FILE_CODE, (int)PdCommon.PdCommon_Classes.cls_FileObject);
var oDataMetadataFile = pdmModel.FindChildByCode(PdODataModelUpdater.ODATA_METADATA_FILE_CODE, (int)PdCommon.PdCommon_Classes.cls_FileObject, "", null, false, false);
if (oDataMetadataFile == null)
{
return null;
Expand Down Expand Up @@ -248,6 +248,9 @@ public void UpdatePdmModel(PdPDM.Model pdmModel)
oImportDataModel.SetNameToCode();
// Copy the model options from the existing model to the new model.
oImportDataModel.ModelOptionsText = pdmModel.ModelOptionsText;
// If the DBMS is set on the existing model, set the same DBMS on the import model.
if (pdmModel.DBMS != null)
oImportDataModel.DBMS = pdmModel.DBMS;
// Update the new model from the metadata feed.
UpdatePdmModelFromODataMetadata(oImportDataModel, oDataMetadataFile.Location, oDataAuthType);

Expand Down
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,28 @@
An AddIn for PowerDesigner to synchronize OData metadata with a PDM model

## Installation
In order to use the plugin, execute the MSI installer which can be downloaded as a build artifact on the latest stable [main build](https://github.com/CrossBreezeNL/PowerDesigner-OData-AddIn/actions/workflows/main.yml).
In order to use the plugin, execute the MSI installer which can be downloaded from the asserts list from the latest [stable release](https://github.com/CrossBreezeNL/PowerDesigner-OData-AddIn/releases).

Make sure to restart PowerDesigner after the installation. Then open Tools -> General Options -> Add-Ins and enable the 'OData' Add-In (by ticking the tick box before it).
Make sure to restart PowerDesigner after the installation. Then open Tools > General Options > Add-Ins and enable the 'OData' Add-In (by ticking the tick box before it).

![General options - Add-In](./screenshots/general-options-addins.png)

## Usage
In the following sections the usage of the Add In is explained.
### Reverse engineer OData
In order to reverse engineer an OData service follow the following steps:

1. In the main menu of PowerDesigner click on `File` > `Reverse Engineer` > `OData...`.

![PowerDesigner Reverse Engineer OData](./screenshots/file-reverse-engineer-odata.png)

1. A model dialog will popup to ask for the new model name, the metadata URI and the authentication type. The new model name will be the name of the new Physical Data Model containing the structure of the OData service.
![Reverse engineer OData to PDM](./screenshots/model-dialog-reverse-odata.png)

![Reverse engineer OData to PDM](./screenshots/model-dialog-reverse-odata.png)

1. If you have selected an authentication type other then `None` another model dialog will popup where you can pass the username and password.
![OData authentcation](./screenshots/model-dialog-authentication.png)

![OData authentcation](./screenshots/model-dialog-authentication.png)

After the previous steps are completed a new PDM model will be created in the active workspace and will be populated with tables (with columns) based on the metadata of the OData service.

Expand All @@ -33,7 +39,7 @@ Next to the tables there will also be a file named 'OData Metadata', which is a
> The authentication information is not stored in the model. The authentication information will be asked for every time you update the model.
### Updating existing reverse engineered OData model
For any physical data model which contains a file with the code 'ODATA_METADATA' the menu option `Update model from OData metadata` will be available.
For any physical data model which contains a file with the code 'OData_Metadata' the menu option `Update model from OData metadata` will be available.

![Model menu update model](./screenshots/model-menu-update-option.png)

Expand All @@ -44,7 +50,7 @@ If the authentication type is not `None`, a dialog will popup where the authenti
### Manually adding OData Metadata file
When you want to update an existing model which was not reverse engineered using the Reverse Engineer menu option, you can manually add the OData Metadata file. Follow the steps below to do so:
1. Right-click on the model, choose `New` > `File`.
1. Given the new file the `Name` 'OData Metadata' and the `Code` 'ODATA_METADATA'.
1. Given the new file the `Name` 'OData Metadata' and the `Code` 'OData_Metadata'.
1. Set the `Location type` to 'URL'.
1. Set the `Location` to the URL to the $metadata location of the OData metadata service.
1. Set the `Comment` value either to 'None' or 'Basic', depending on the required authentication method.
Expand All @@ -53,15 +59,18 @@ When you want to update an existing model which was not reverse engineered using

![Model OData Metadata file](./screenshots/model-metadata-file-properties.png)

Once you have completed the above steps the update menu opion will be available as explained in [Updating existing reverse engineered OData model](#updating-existing-reverse-engineered-odata-model).
Once you have completed the above steps the update menu option will be available as explained in [Updating existing reverse engineered OData model](#updating-existing-reverse-engineered-odata-model).

## Debugging
To debug the plugin:

- Open the [solution](./PowerDesigner_OData_AddIn.sln) in Visual Studio which is running as Administator (so it can register new DLLs)
- Build the project in Debug (this will also register the Add-In in the Windows Registry for PowerDesigner).
- Enable debug mode in PowerDesigner for the OData Add-In by creating a variable named 'ODATA_DEBUG_MODE' and give it the value 'True'.

![Enable debug mode](./screenshots/general-options-debug-mode.png)

Now you can enable the Add-In in PowerDesigner in Tools -> General Options -> Add-Ins. The name of the Add-In is 'OData'. If the OData add-in is disabled in PowerDesigner (checkbox is grayed out) it might be needed to run PowerDesigner as Administrator.
Now you can enable the Add-In in PowerDesigner in Tools > General Options > Add-Ins. The name of the Add-In is 'OData'. If the OData add-in is disabled in PowerDesigner (checkbox is grayed out) it might be needed to run PowerDesigner as Administrator.

## Resources

Expand Down
Binary file added screenshots/general-options-debug-mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/model-metadata-file-properties.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cfa74fc

Please sign in to comment.