Skip to content

Commit 3be2ca0

Browse files
committed
Merge branch 'main' into 193-incquery-autosar-uml-bridge
2 parents 0280943 + 6f8a883 commit 3be2ca0

File tree

37 files changed

+13603
-0
lines changed

37 files changed

+13603
-0
lines changed

.github/workflows/SVGUpdate.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Copyright (c) LieberLieber Software GmbH
2+
# This Source Code Form is subject to the terms of the Mozilla Public
3+
# License, v. 2.0. If a copy of the MPL was not distributed with this
4+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
6+
name: LemonTree.Automation SVG Update in Repo
7+
8+
on:
9+
push:
10+
11+
env:
12+
ModelName: DemoModel
13+
ModelExtension: eapx
14+
SVGFolder: .\svg\
15+
16+
jobs:
17+
SVGUpdateInRepo:
18+
defaults:
19+
run:
20+
shell: pwsh
21+
runs-on: windows-latest
22+
timeout-minutes: 15
23+
steps:
24+
- uses: actions/checkout@v3
25+
with:
26+
lfs: true
27+
fetch-depth: 0
28+
29+
# download Lemontree.Automation on a runner and setup the license
30+
- uses: LieberLieber/setup-LemonTree.Automation@v1
31+
id: GetLTA
32+
with:
33+
License: ${{secrets.LTALICENSE}}
34+
#ExeLocation &"${{steps.GetLTA.outputs.LemonTreeAutomationExecutable}}"
35+
36+
- name: PrepareForSVGExport
37+
id: prep
38+
run: |
39+
#Check if the Folder Exists
40+
$folderPath = "${{env.SVGFolder}}"
41+
if (Test-Path $folderPath) {
42+
Write-Output "Folder $folderPath exists"
43+
} else {
44+
Write-Output "Folder $folderPath does not exist, we create it "
45+
New-Item -ItemType Directory -Force -Path $folderPath
46+
}
47+
48+
#delete all SVG files from the Folder - so deletion of diagrams is also reflected in git. existing diagrams will be recreated anyway.
49+
$filesSVG = $folderPath+"*.svg"
50+
Write-Output "deleting files $filesSVG"
51+
Remove-Item "$filesSVG"
52+
Write-Output "filesSVG=$filesSVG" >>$env:GITHUB_OUTPUT
53+
54+
- name: ExportLatestSVGDiagrams
55+
run: |
56+
&"${{steps.GetLTA.outputs.LemonTreeAutomationExecutable}}" SVGExport --Model ${{env.ModelName}}.${{env.ModelExtension}} --DiagramDirectory ${{env.SVGFolder}}
57+
58+
- name: createCommitandPush
59+
run: |
60+
Write-Output "set user config"
61+
git config --global user.name 'LemonTree.Automation'
62+
git config --global user.email 'support@lieberlieber.com'
63+
Write-Output "setting remote state"
64+
git remote set-url origin https://x-access-token:${{secrets.PAT}}@github.com/${{github.repository}}
65+
git add ${{steps.prep.outputs.filesSVG}}
66+
git commit -m "LemonTree.Automation SVG Update"
67+
git push
68+
Write-Output "SVG Updated in Repository"
69+
70+
71+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Copyright (c) LieberLieber Software GmbH
2+
# This Source Code Form is subject to the terms of the Mozilla Public
3+
# License, v. 2.0. If a copy of the MPL was not distributed with this
4+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
6+
#This script will export the "mine" diagrams from a LemonTree xml diffreport into SVG files
7+
#LemonTree.Automation needs to be called with --ReportIncludeDiagrams see: https://help.lieberlieber.com/LemonTree/LTA-Diff.html
8+
#LemonTree.Automation.exe diff --base base.eapx --mine mine.eapx --theirs theirs.eapx --DiffReportFilename "DiffReport.xml" --ReportIncludeDiagrams
9+
10+
param (
11+
[string]$xmlFilePath = "DiffReport.xml"
12+
)
13+
14+
15+
[xml]$xmlContent = Get-Content -Path $xmlFilePath
16+
17+
# Define the XML namespaces
18+
$ns = New-Object Xml.XmlNamespaceManager $xmlContent.NameTable
19+
$ns.AddNamespace("ns", "http://www.lieberlieber.com")
20+
21+
# Select all diagramPicture elements using the defined namespace
22+
$diagramPictures = $xmlContent.SelectNodes('//ns:diagramPictures/ns:diagramPicture', $ns)
23+
24+
# Output the count of found elements
25+
Write-Host "Found $($diagramPictures.Count) Diagrams."
26+
27+
foreach ($diagramPicture in $diagramPictures) {
28+
$diagramGuid = $diagramPicture.guid
29+
if($diagramGuid){
30+
$cdata_b = $diagramPicture.diagramPictureB.InnerText
31+
32+
# Check if the CDATA section is empty
33+
if (![string]::IsNullOrEmpty($cdata_b)) {
34+
$qualifiedName = $diagramPicture.diagramPictureB.qualifiedName
35+
write-host $qualifiedName
36+
$fileGuid = $diagramGuid.Replace('{','').Replace('}','')
37+
$filename = "$fileGuid.svg"
38+
write-output "$qualifiedName ==> $filename"
39+
$cdata_b | %{[Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($_))}|Set-Content -Encoding UTF8 -Path $filename
40+
}
41+
}
42+
}
43+
44+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright (c) LieberLieber Software GmbH
2+
# This Source Code Form is subject to the terms of the Mozilla Public
3+
# License, v. 2.0. If a copy of the MPL was not distributed with this
4+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
6+
#This script will update the "mine" diagrams from a LemonTree xml diffreport into SVG files
7+
8+
#Check if the Folder Exists
9+
$folderPath = ".\svg"
10+
if (Test-Path $folderPath) {
11+
Write-Output "Folder $folderPath exists"
12+
} else {
13+
Write-Output "Folder $folderPath does not exist, we create it "
14+
New-Item -ItemType Directory -Force -Path $folderPath
15+
}
16+
17+
#delete all SVG files from the Folder - so deletion of diagrams is also reflected in git. existing diagrams will be recreated anyway.
18+
$filesSVG = $folderPath+"\*.svg"
19+
Write-Output "deleting files $filesSVG"
20+
Remove-Item "$filesSVG"
21+
22+
#create SVG Files
23+
&'C:\Program Files\LieberLieber\LemonTree.Automation\LemonTree.Automation.exe' SVGExport --Model .\DemoModel.eapx --DiagramDirectory '.\svg'
24+
25+
#git commit
26+
git add -A
27+
git commit -m "LemonTree.Automation SVG Update"
28+
29+
#git push
30+
#git push
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
param (
2+
[string]$xmlFilePath = $args[0]
3+
)
4+
5+
# Check if an XML file path is provided as an argument
6+
if (-not $xmlFilePath) {
7+
# If no argument is provided, find the first XML file in the current directory
8+
$xmlFiles = Get-ChildItem -Path . -Filter *.xml
9+
if ($xmlFiles -eq $null -or $xmlFiles.Count -eq 0) {
10+
Write-Host "No XML files found in the current directory."
11+
Exit
12+
} else {
13+
$xmlFilePath = $xmlFiles[0].FullName
14+
}
15+
}
16+
17+
# Load the XML file
18+
[xml]$xml = Get-Content -Path $xmlFilePath
19+
20+
# Define the XML namespaces
21+
$ns = New-Object Xml.XmlNamespaceManager $xml.NameTable
22+
$ns.AddNamespace("ns", "http://www.lieberlieber.com")
23+
24+
# Select all diagramPicture elements using the defined namespace
25+
$diagramPictures = $xml.SelectNodes('//ns:diagramPictures/ns:diagramPicture', $ns)
26+
27+
# Output the count of found elements
28+
Write-Host "Found $($diagramPictures.Count) Diagrams in $xmlFilePath."
29+
30+
# Create an HTML header
31+
$html = '<html><head><title>Diagram Pictures</title></head><body>'
32+
33+
# Iterate through each diagram picture
34+
foreach ($diagramPicture in $diagramPictures) {
35+
$guid = $diagramPicture.guid
36+
$diagramType = $diagramPicture.diagramType
37+
$name = $diagramPicture.diagramPictureA.name
38+
39+
# Extract the CDATA content for diagramPictureA and diagramPictureB
40+
$cdata_a = $diagramPicture.diagramPictureA.InnerText
41+
$cdata_b = $diagramPicture.diagramPictureB.InnerText
42+
43+
# Check if the CDATA sections are empty
44+
if (![string]::IsNullOrEmpty($cdata_a) -or ![string]::IsNullOrEmpty($cdata_b)) {
45+
# Create an HTML element for the diagram pictures
46+
$html += @"
47+
<div>
48+
<h2>Name: $name</h2>
49+
<p>GUID: $guid</p>
50+
<p>Type: $diagramType</p>
51+
<div style="display: flex;">
52+
<div style="flex: 1;">
53+
<p>Diagram A:</p>
54+
<img src='data:image/svg+xml;base64,$cdata_a' />
55+
</div>
56+
<div style="flex: 1;">
57+
<p>Diagram B:</p>
58+
<img src='data:image/svg+xml;base64,$cdata_b' />
59+
</div>
60+
</div>
61+
</div>
62+
"@
63+
} else {
64+
Write-Host "Empty CDATA section found for diagram with name: $name"
65+
}
66+
}
67+
68+
# Close the HTML page
69+
$html += '</body></html>'
70+
71+
# Save the HTML page to a file
72+
$html | Set-Content -Path 'output.html' -Force
73+
74+
Write-Host "HTML page has been generated and saved as 'output.html'."

example-scripts/powershell/rebase.ps1

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
$env:GIT_EDITOR = "true"
2+
3+
$lta = 'C:\Program Files\LieberLieber\LemonTree.Automation\LemonTree.Automation.exe'
4+
$gitcmd = 'C:\Program Files\Git\git-cmd.exe'
5+
6+
git rebase main
7+
8+
while($LASTEXITCODE -ne 0) {
9+
&$gitcmd "git cat-file blob HEAD:DemoModel.eapx | git lfs smudge > DemoModel_base.eapx & exit"
10+
&$gitcmd "git cat-file blob REBASE_HEAD:DemoModel.eapx | git lfs smudge > DemoModel_mine.eapx & exit"
11+
12+
&$lta merge --Theirs DemoModel_base.eapx --Mine DemoModel_mine.eapx --out DemoModel.eapx
13+
14+
git add DemoModel.eapx
15+
Remove-Item -Path DemoModel_base.eapx
16+
Remove-Item -Path DemoModel_mine.eapx
17+
18+
git rebase --continue
19+
}
20+
21+
$env:GIT_EDITOR = ""

extractImages_saveLocal.ps1

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
param (
2+
[string]$xmlFilePath = $args[0],
3+
[string]$outputDirectory = 'output_images'
4+
)
5+
6+
# Check if an XML file path is provided as an argument
7+
if (-not $xmlFilePath) {
8+
$xmlFiles = Get-ChildItem -Path . -Filter *.xml
9+
10+
if ($xmlFiles -eq $null -or $xmlFiles.Count -eq 0) {
11+
Write-Host "No XML files found in the current directory."
12+
Exit
13+
} else {
14+
$xmlFilePath = $xmlFiles[0].FullName
15+
}
16+
}
17+
18+
Write-Host "Using XML file: $xmlFilePath"
19+
20+
try {
21+
[xml]$xml = Get-Content -Path $xmlFilePath
22+
} catch {
23+
Write-Host "Failed to load the XML file: $_"
24+
Exit
25+
}
26+
27+
# Ensure the output directory exists
28+
if (-not (Test-Path -Path $outputDirectory)) {
29+
New-Item -ItemType Directory -Path $outputDirectory -Force > $null
30+
}
31+
32+
# Define the XML namespaces
33+
$ns = New-Object Xml.XmlNamespaceManager $xml.NameTable
34+
$ns.AddNamespace("ns", "http://www.lieberlieber.com")
35+
36+
# Select all diagramPicture elements using the defined namespace
37+
$diagramPictures = $xml.SelectNodes('//ns:diagramPictures/ns:diagramPicture', $ns)
38+
39+
# Output the count of found elements
40+
Write-Host "Found $($diagramPictures.Count) Diagrams in $xmlFilePath."
41+
42+
# Create an HTML header
43+
$html = '<html><head><title>Diagram Pictures</title></head><body>'
44+
45+
# Iterate through each diagram picture
46+
foreach ($diagramPicture in $diagramPictures) {
47+
$guid = $diagramPicture.guid
48+
$diagramType = $diagramPicture.diagramType
49+
$name = $diagramPicture.diagramPictureA.name
50+
$nameB = $diagramPicture.diagramPictureB.name
51+
52+
# Extract the CDATA content for diagramPictureA and diagramPictureB
53+
$cdata_a = $diagramPicture.diagramPictureA.InnerText
54+
$cdata_b = $diagramPicture.diagramPictureB.InnerText
55+
56+
# Check if the CDATA sections are empty
57+
if (![string]::IsNullOrEmpty($cdata_a) -or ![string]::IsNullOrEmpty($cdata_b)) {
58+
# Generate unique filenames for the images
59+
$filename_a = Join-Path -Path $outputDirectory -ChildPath "$name-DiagramA.svg"
60+
$filename_b = Join-Path -Path $outputDirectory -ChildPath "$nameB-DiagramB.svg"
61+
62+
# Save the images as files
63+
if (![string]::IsNullOrEmpty($cdata_a)) {
64+
[System.Convert]::FromBase64String($cdata_a) | Set-Content -Path $filename_a -Encoding Byte
65+
}
66+
if (![string]::IsNullOrEmpty($cdata_b)) {
67+
[System.Convert]::FromBase64String($cdata_b) | Set-Content -Path $filename_b -Encoding Byte
68+
}
69+
70+
# Create an HTML element for the diagram pictures
71+
$html += @"
72+
<div>
73+
<h2>Name: $name</h2>
74+
<p>GUID: $guid</p>
75+
<p>Type: $diagramType</p>
76+
<div style="display: flex;">
77+
<div style="flex: 1;">
78+
<p>Diagram A:</p>
79+
<img src='data:image/svg+xml;base64,$cdata_a' />
80+
</div>
81+
<div style="flex: 1;">
82+
<p>Diagram B:</p>
83+
<img src='data:image/svg+xml;base64,$cdata_b' />
84+
</div>
85+
</div>
86+
</div>
87+
"@
88+
} else {
89+
Write-Host "Empty CDATA section found for diagram with name: $name"
90+
}
91+
}
92+
93+
# Close the HTML page
94+
$html += '</body></html>'
95+
96+
# Save the HTML page to a file
97+
$html | Set-Content -Path 'output.html' -Force
98+
99+
Write-Host "HTML page has been generated and saved as 'output.html'."
100+
Write-Host "Images saved in $outputDirectory."

0 commit comments

Comments
 (0)