From e46185cefd73ae8b18848ed07beff22aef91d212 Mon Sep 17 00:00:00 2001 From: Humberto Sanchez II Date: Sat, 30 Sep 2023 15:22:08 -0500 Subject: [PATCH] [Pyut Model]: [ * IDs not calculated correctly with ID Factory * Use common source and destination ID spelling * Need to consider move the Ogl serialize code out of OGLIO ] [ https://github.com/hasii2011/oglio/issues/48 https://github.com/hasii2011/oglio/issues/49 ] --- oglio/_version.py | 2 +- oglio/toXmlV11/BaseXml.py | 13 ----------- oglio/toXmlV11/PyutToXml.py | 23 ++++++++++--------- oglio/toXmlV11/XmlConstants.py | 4 ++-- tests/oglio/toXmlV11/TestOglToXmlV11.py | 2 +- .../testdata/ComplexSequenceDiagramV11.xml | 6 ++--- .../testdata/MultiLinkDocumentV11.xml | 6 ++--- .../testdata/TextAndLinkedNotesV11.xml | 4 ++-- .../testdata/UseCasesTextNotesV11.xml | 6 ++--- 9 files changed, 27 insertions(+), 39 deletions(-) delete mode 100644 oglio/toXmlV11/BaseXml.py diff --git a/oglio/_version.py b/oglio/_version.py index c440c06..2526b0e 100644 --- a/oglio/_version.py +++ b/oglio/_version.py @@ -1 +1 @@ -__version__: str = '1.1.5' +__version__: str = '1.2.0' diff --git a/oglio/toXmlV11/BaseXml.py b/oglio/toXmlV11/BaseXml.py deleted file mode 100644 index 4a0c662..0000000 --- a/oglio/toXmlV11/BaseXml.py +++ /dev/null @@ -1,13 +0,0 @@ - -from logging import Logger -from logging import getLogger - -from oglio.IDFactory import IDFactory - - -class BaseXml: - def __init__(self): - self.logger: Logger = getLogger(__name__) - - self._idFactory: IDFactory = IDFactory() - diff --git a/oglio/toXmlV11/PyutToXml.py b/oglio/toXmlV11/PyutToXml.py index 95d8ba6..0dc0a86 100644 --- a/oglio/toXmlV11/PyutToXml.py +++ b/oglio/toXmlV11/PyutToXml.py @@ -23,12 +23,11 @@ from pyutmodel.PyutText import PyutText from pyutmodel.PyutUseCase import PyutUseCase -from oglio.toXmlV11.BaseXml import BaseXml from oglio.toXmlV11.InternalTypes import ElementAttributes from oglio.toXmlV11.XmlConstants import XmlConstants -class PyutToXml(BaseXml): +class PyutToXml: """ Serializes Pyut Models classes to DOM """ @@ -106,7 +105,8 @@ def pyutLinkToXml(self, pyutLink: PyutLink, oglLinkElement: Element) -> Element: def pyutInterfaceToXml(self, pyutInterface: PyutInterface, interface2Element: Element) -> Element: - classId: int = self._idFactory.getID(pyutInterface) + classId: int = pyutInterface.id + attributes: ElementAttributes = ElementAttributes({ XmlConstants.ATTR_ID: str(classId), XmlConstants.ATTR_NAME: pyutInterface.name, @@ -125,7 +125,7 @@ def pyutInterfaceToXml(self, pyutInterface: PyutInterface, interface2Element: El def pyutNoteToXml(self, pyutNote: PyutNote, oglNoteElement: Element) -> Element: - noteId: int = self._idFactory.getID(pyutNote) + noteId: int = pyutNote.id content: str = pyutNote.content fixedContent: str = content.replace(osLineSep, PyutToXml.END_OF_LINE_MARKER) if pyutNote.fileName is None: @@ -142,7 +142,7 @@ def pyutNoteToXml(self, pyutNote: PyutNote, oglNoteElement: Element) -> Element: def pyutTextToXml(self, pyutText: PyutText, oglTextElement: Element) -> Element: - textId: int = self._idFactory.getID(pyutText) + textId: int = pyutText.id content: str = pyutText.content fixedContent: str = content.replace(osLineSep, PyutToXml.END_OF_LINE_MARKER) @@ -156,7 +156,7 @@ def pyutTextToXml(self, pyutText: PyutText, oglTextElement: Element) -> Element: def pyutActorToXml(self, pyutActor: PyutActor, oglActorElement: Element) -> Element: - actorId: int = self._idFactory.getID(pyutActor) + actorId: int = pyutActor.id fileName: str = pyutActor.fileName if fileName is None: fileName = '' @@ -172,7 +172,7 @@ def pyutActorToXml(self, pyutActor: PyutActor, oglActorElement: Element) -> Elem def pyutUseCaseToXml(self, pyutUseCase: PyutUseCase, oglUseCaseElement: Element) -> Element: - useCaseId: int = self._idFactory.getID(pyutUseCase) + useCaseId: int = pyutUseCase.id fileName: str = pyutUseCase.fileName if fileName is None: fileName = '' @@ -188,7 +188,8 @@ def pyutUseCaseToXml(self, pyutUseCase: PyutUseCase, oglUseCaseElement: Element) def pyutSDInstanceToXml(self, pyutSDInstance: PyutSDInstance, oglSDInstanceElement: Element) -> Element: - sdInstanceId: int = self._idFactory.getID(pyutSDInstance) + sdInstanceId: int = pyutSDInstance.id + attributes: ElementAttributes = ElementAttributes({ XmlConstants.ATTR_ID: str(sdInstanceId), XmlConstants.ATTR_INSTANCE_NAME: pyutSDInstance.instanceName, @@ -201,13 +202,13 @@ def pyutSDInstanceToXml(self, pyutSDInstance: PyutSDInstance, oglSDInstanceEleme def pyutSDMessageToXml(self, pyutSDMessage: PyutSDMessage, oglSDMessageElement: Element) -> Element: - sdMessageId: int = self._idFactory.getID(pyutSDMessage) + sdMessageId: int = pyutSDMessage.id srcInstance: PyutSDInstance = pyutSDMessage.getSource() dstInstance: PyutSDInstance = pyutSDMessage.getDestination() - idSrc: int = self._idFactory.getID(srcInstance) - idDst: int = self._idFactory.getID(dstInstance) + idSrc: int = srcInstance.id + idDst: int = dstInstance.id attributes: ElementAttributes = ElementAttributes({ XmlConstants.ATTR_ID: str(sdMessageId), diff --git a/oglio/toXmlV11/XmlConstants.py b/oglio/toXmlV11/XmlConstants.py index 34149c0..08ba175 100644 --- a/oglio/toXmlV11/XmlConstants.py +++ b/oglio/toXmlV11/XmlConstants.py @@ -96,8 +96,8 @@ class XmlConstants: ATTR_SOURCE_TIME: str = 'sourceTime' ATTR_DESTINATION_TIME: str = 'destinationTime' - ATTR_SD_MESSAGE_SOURCE_ID: str = 'sourceID' - ATTR_SD_MESSAGE_DESTINATION_ID: str = 'destinationID' + ATTR_SD_MESSAGE_SOURCE_ID: str = 'sourceId' + ATTR_SD_MESSAGE_DESTINATION_ID: str = 'destinationId' ATTR_CODE_PATH: str = 'CodePath' diff --git a/tests/oglio/toXmlV11/TestOglToXmlV11.py b/tests/oglio/toXmlV11/TestOglToXmlV11.py index 5b5f18c..5f93bd7 100644 --- a/tests/oglio/toXmlV11/TestOglToXmlV11.py +++ b/tests/oglio/toXmlV11/TestOglToXmlV11.py @@ -92,7 +92,7 @@ def testSplines(self): def testTextAndLinkedNotes(self): oglDocument: OglDocument = self._getOglDocument(baseFileName=TEXT_AND_LINKED_NOTES_V10, documentName='TextNotes') - self._assertGeneratedFile(oglDocument=oglDocument, baseFileNameV11=TEXT_AND_LINKED_NOTES_V11, assertionMessage='Diff multi link document serialization failed') + self._assertGeneratedFile(oglDocument=oglDocument, baseFileNameV11=TEXT_AND_LINKED_NOTES_V11, assertionMessage='Diff text & linked notes serialization failed') def testUseCases(self): """ diff --git a/tests/resources/testdata/ComplexSequenceDiagramV11.xml b/tests/resources/testdata/ComplexSequenceDiagramV11.xml index 712a166..ddc7653 100644 --- a/tests/resources/testdata/ComplexSequenceDiagramV11.xml +++ b/tests/resources/testdata/ComplexSequenceDiagramV11.xml @@ -11,13 +11,13 @@ - + - + - + \ No newline at end of file diff --git a/tests/resources/testdata/MultiLinkDocumentV11.xml b/tests/resources/testdata/MultiLinkDocumentV11.xml index 7a0d1e0..0172922 100644 --- a/tests/resources/testdata/MultiLinkDocumentV11.xml +++ b/tests/resources/testdata/MultiLinkDocumentV11.xml @@ -61,7 +61,7 @@ - + @@ -72,10 +72,10 @@ - + - + \ No newline at end of file diff --git a/tests/resources/testdata/TextAndLinkedNotesV11.xml b/tests/resources/testdata/TextAndLinkedNotesV11.xml index ed99446..1d886fe 100644 --- a/tests/resources/testdata/TextAndLinkedNotesV11.xml +++ b/tests/resources/testdata/TextAndLinkedNotesV11.xml @@ -8,10 +8,10 @@ - + - + \ No newline at end of file diff --git a/tests/resources/testdata/UseCasesTextNotesV11.xml b/tests/resources/testdata/UseCasesTextNotesV11.xml index 099917f..7bd152d 100644 --- a/tests/resources/testdata/UseCasesTextNotesV11.xml +++ b/tests/resources/testdata/UseCasesTextNotesV11.xml @@ -11,13 +11,13 @@ - + - + - + \ No newline at end of file