Skip to content

Commit 5fcfcd5

Browse files
committed
* fixes to SaveAs...
1 parent 6c9ced8 commit 5fcfcd5

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

src/AasxCsharpLibrary/AdminShellPackageEnv.cs

+26-17
Original file line numberDiff line numberDiff line change
@@ -790,9 +790,10 @@ public bool SaveAs(string fn, bool writeFreshly = false, SerializationFormat pre
790790
//delete old type, because its not according to spec or something
791791
//then replace with the current type
792792
package.DeleteRelationship(x.Rel.Id);
793-
package.CreateRelationship(
794-
originPart.Uri, TargetMode.Internal,
795-
relTypesOrigin.FirstOrDefault());
793+
package.DeletePart(absoluteURI);
794+
//package.CreateRelationship(
795+
// originPart.Uri, TargetMode.Internal,
796+
// relTypesOrigin.FirstOrDefault());
796797
originPart = null;
797798
break;
798799
}
@@ -835,20 +836,21 @@ public bool SaveAs(string fn, bool writeFreshly = false, SerializationFormat pre
835836
if (package.PartExists(absoluteURI))
836837
{
837838
specPart = package.GetPart(absoluteURI);
838-
}
839839

840-
// check if it a deprecated URI
841-
if (x.Deprecated)
842-
{
843-
//delete old type, because its not according to spec or something
844-
//then replace with the current type
845-
package.DeleteRelationship(x.Rel.Id);
846-
package.CreateRelationship(
847-
specPart.Uri, TargetMode.Internal,
848-
relTypesSpec.FirstOrDefault());
849-
specPart = null;
850-
specRel = null;
851-
break;
840+
// check if it a deprecated URI
841+
if (x.Deprecated)
842+
{
843+
//delete old type, because its not according to spec or something
844+
//then replace with the current type
845+
package.DeleteRelationship(x.Rel.Id);
846+
package.DeletePart(absoluteURI);
847+
//package.CreateRelationship(
848+
// specPart.Uri, TargetMode.Internal,
849+
// relTypesSpec.FirstOrDefault());
850+
specPart = null;
851+
specRel = null;
852+
break;
853+
}
852854
}
853855
}
854856

@@ -888,6 +890,13 @@ public bool SaveAs(string fn, bool writeFreshly = false, SerializationFormat pre
888890
else
889891
aas_spec_fn += ".xml";
890892
aas_spec_fn = aas_spec_fn.Replace("#", "" + frn);
893+
894+
// new: make sure the part is not existing anymore
895+
var aas_spec_uri = new Uri(aas_spec_fn, UriKind.RelativeOrAbsolute);
896+
if (package.PartExists(aas_spec_uri))
897+
package.DeletePart(aas_spec_uri);
898+
899+
// now create
891900
specPart = package.CreatePart(
892901
new Uri(aas_spec_fn, UriKind.RelativeOrAbsolute),
893902
System.Net.Mime.MediaTypeNames.Text.Xml, CompressionOption.Maximum);
@@ -950,7 +959,7 @@ public bool SaveAs(string fn, bool writeFreshly = false, SerializationFormat pre
950959
specPart.DeleteRelationship(x.Rel.Id);
951960
specPart.CreateRelationship(
952961
filePart.Uri, TargetMode.Internal,
953-
"http://admin-shell.io/aasx/relationships/aas-suppl");
962+
relTypesSuppl.FirstOrDefault());
954963
}
955964
}
956965
}

src/AasxPackageExplorer/options-debug.MIHO.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\Test1.aasx",
3333
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\samm-test\\SMT_and_SAMM_Showcase_v02.aasx",
3434
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\tmp\\SMT_and_SAMM_Showcase_v02_spiel.aasx",
35-
"AasxToLoad": "C:\\Users\\homi0002\\Desktop\\tmp\\SAMSON_TROVIS_3730-3_Vorlage_Demo_Achema_tmp.aasx",
35+
"AasxToLoad": "C:\\Users\\homi0002\\Desktop\\tmp\\00_FestoDemoBox-Module-2-Kopie.aasx",
36+
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\tmp\\8001203_SPAU-P10R-T-R18M-L-PNLK-PNVBA-M8D_060ff64f-9fd2-422d-81ce-b17e49f007c5_work_spiel.aasx",
3637
// "AasxToLoad": "C:\\MIHO\\Develop\\Aasx\\repo\\SMT_and_SAMM_Showcase_v02.aasx",
3738
// "AasxToLoad": "C:\\MIHO\\Develop\\Aasx\\repo\\SMT_and_SAMM_Showcase_v01.aasx",
3839
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\SAMSON_TROVIS_3730-3_Vorlage_Demo_Achema.aasx",

0 commit comments

Comments
 (0)