Skip to content

Commit

Permalink
<XML>[Pyut Model]: <Fix sequence diagrams>
Browse files Browse the repository at this point in the history
[
* 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
]

[
#48
#49
]
  • Loading branch information
Humberto Sanchez II committed Sep 30, 2023
1 parent 5ac159c commit e46185c
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 39 deletions.
2 changes: 1 addition & 1 deletion oglio/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__: str = '1.1.5'
__version__: str = '1.2.0'
13 changes: 0 additions & 13 deletions oglio/toXmlV11/BaseXml.py

This file was deleted.

23 changes: 12 additions & 11 deletions oglio/toXmlV11/PyutToXml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down Expand Up @@ -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,
Expand All @@ -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:
Expand All @@ -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)

Expand All @@ -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 = ''
Expand All @@ -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 = ''
Expand All @@ -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,
Expand All @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions oglio/toXmlV11/XmlConstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
2 changes: 1 addition & 1 deletion tests/oglio/toXmlV11/TestOglToXmlV11.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
6 changes: 3 additions & 3 deletions tests/resources/testdata/ComplexSequenceDiagramV11.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
<PyutSDInstance id="3" instanceName="OzzeeInstance" lifeLineLength="200" />
</OglSDInstance>
<OglSDMessage>
<PyutSDMessage id="4" message="calls()" sourceTime="148" destinationTime="150" sourceID="1" destinationID="2" />
<PyutSDMessage id="4" message="calls()" sourceTime="148" destinationTime="150" sourceId="1" destinationId="2" />
</OglSDMessage>
<OglSDMessage>
<PyutSDMessage id="5" message="spanks()" sourceTime="201" destinationTime="194" sourceID="2" destinationID="3" />
<PyutSDMessage id="5" message="spanks()" sourceTime="201" destinationTime="194" sourceId="2" destinationId="3" />
</OglSDMessage>
<OglSDMessage>
<PyutSDMessage id="6" message="bites()" sourceTime="328" destinationTime="338" sourceID="3" destinationID="2" />
<PyutSDMessage id="6" message="bites()" sourceTime="328" destinationTime="338" sourceId="3" destinationId="2" />
</OglSDMessage>
</PyutDocument>
</PyutProject>
6 changes: 3 additions & 3 deletions tests/resources/testdata/MultiLinkDocumentV11.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<PyutLink name="" type="INTERFACE" cardinalitySource="" cardinalityDestination="" bidirectional="False" sourceId="6" destinationId="5" />
</OglLink>
<OglInterface2 attachmentPoint="EAST" x="465" y="649">
<PyutInterface id="1" name="IClassInterface" description="">
<PyutInterface id="10" name="IClassInterface" description="">
<PyutMethod name="methodWithParameters" visibility="PUBLIC" returnType="">
<SourceCode />
<PyutParameter name="strParam" type="str" defaultValue="''" />
Expand All @@ -72,10 +72,10 @@
</PyutInterface>
</OglInterface2>
<OglText width="221" height="73" x="500" y="400">
<PyutText id="2" content="Aggregation associates two objects describes the 'have a' relationship." />
<PyutText id="8" content="Aggregation associates two objects describes the 'have a' relationship." />
</OglText>
<OglText width="206" height="74" x="125" y="400">
<PyutText id="3" content="Composition is a specific type of Aggregation which implies ownership." />
<PyutText id="9" content="Composition is a specific type of Aggregation which implies ownership." />
</OglText>
</PyutDocument>
</PyutProject>
4 changes: 2 additions & 2 deletions tests/resources/testdata/TextAndLinkedNotesV11.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<PyutLink name="Notelink-6" type="NOTELINK" cardinalitySource="" cardinalityDestination="" bidirectional="False" sourceId="4" destinationId="3" />
</OglLink>
<OglNote width="128" height="49" x="175" y="300">
<PyutNote id="1" content="I am a note linked to&amp;#xA;the LinkedToClass" fileName="" />
<PyutNote id="4" content="I am a note linked to&amp;#xA;the LinkedToClass" fileName="" />
</OglNote>
<OglText width="150" height="81" x="425" y="125">
<PyutText id="2" content="I am standalone text&amp;#xwith line breaks;&amp;#xTest that baby" />
<PyutText id="5" content="I am standalone text&amp;#xwith line breaks;&amp;#xTest that baby" />
</OglText>
</PyutDocument>
</PyutProject>
6 changes: 3 additions & 3 deletions tests/resources/testdata/UseCasesTextNotesV11.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
<PyutNote id="1" content="This is the note text&amp;#xA;With Line feeds&amp;#xA;Maybe more coming" fileName="" />
</OglNote>
<OglText width="138" height="88" x="100" y="325">
<PyutText id="2" content="This plain text&amp;#xA;With line breaks&amp;#xA;At least a few" />
<PyutText id="4" content="This plain text&amp;#xA;With line breaks&amp;#xA;At least a few" />
</OglText>
<OglActor width="87" height="114" x="50" y="100">
<PyutActor id="3" name="BasicActor" fileName="" />
<PyutActor id="2" name="BasicActor" fileName="" />
</OglActor>
<OglUseCase width="100" height="60" x="475" y="275">
<PyutUseCase id="4" name="Basic Use Case" fileName="" />
<PyutUseCase id="3" name="Basic Use Case" fileName="" />
</OglUseCase>
</PyutDocument>
</PyutProject>

0 comments on commit e46185c

Please sign in to comment.