예제 #1
0
파일: PyutXmi.py 프로젝트: hasii2011/PyUt
    def _PyutLink2xml(self, pyutLink: PyutLink):
        """
        Convert a PyutLink to an miniDom Element

        Args:
            pyutLink:

        Returns:    An XML element
        """
        # adding links in dictionary
        if pyutLink in self.__savedLinks:
            return None
        self.__savedLinks[pyutLink] = 1

        root = Element('Link')
        # link name
        root.setAttribute('name', pyutLink.getName())

        # link type
        root.setAttribute('type', str(pyutLink.getType()))

        # link cardinality source
        root.setAttribute('cardSrc', pyutLink.sourceCardinality)

        # link cardinality destination
        # root.setAttribute('cardDestination', pyutLink.getDestinationCardinality())
        root.setAttribute('cardDestination', pyutLink.destinationCardinality)

        # link bidir
        root.setAttribute('bidir', str(pyutLink.getBidir()))

        # link destination
        root.setAttribute('destination', pyutLink.getDestination().getName())

        return root
예제 #2
0
    def _pyutLinkToXml(self, pyutLink: PyutLink, xmlDoc: Document) -> Element:
        """
        Exporting a PyutLink to a miniDom Element.

        Args:
            pyutLink:   Link to save
            xmlDoc:     xml document

        Returns:
            A new minidom element
        """
        root: Element = xmlDoc.createElement(
            PyutXmlConstants.ELEMENT_MODEL_LINK)

        root.setAttribute(PyutXmlConstants.ATTR_NAME, pyutLink.getName())
        root.setAttribute(PyutXmlConstants.ATTR_TYPE, pyutLink.getType().name)
        root.setAttribute(PyutXmlConstants.ATTR_CARDINALITY_SOURCE,
                          pyutLink.sourceCardinality)
        root.setAttribute(PyutXmlConstants.ATTR_CARDINALITY_DESTINATION,
                          pyutLink.destinationCardinality)
        root.setAttribute(PyutXmlConstants.ATTR_BIDIRECTIONAL,
                          str(pyutLink.getBidir()))

        srcLinkId: int = self._idFactory.getID(pyutLink.getSource())
        destLinkId: int = self._idFactory.getID(pyutLink.getDestination())

        root.setAttribute(PyutXmlConstants.ATTR_SOURCE_ID, str(srcLinkId))
        root.setAttribute(PyutXmlConstants.ATTR_DESTINATION_ID,
                          str(destLinkId))

        return root
예제 #3
0
    def _PyutLink2xml(self, pyutLink: PyutLink):
        """
        Exporting an PyutLink to an miniDom Element

        @since 2.0
        @Deve Roux <*****@*****.**>

        @param pyutLink
        @return Element
        """

        # hadding links in dictionnary
        if pyutLink in self.__savedLinks:
            return None
        self.__savedLinks[pyutLink] = 1

        root = Element('Link')
        # link name
        root.setAttribute('name', pyutLink.getName())

        # link type
        root.setAttribute('type', str(pyutLink.getType()))

        # link cardinality source
        root.setAttribute('cardSrc', pyutLink.sourceCardinality)

        # link cardinality destination
        # root.setAttribute('cardDestination', pyutLink.getDestinationCardinality())
        root.setAttribute('cardDestination', pyutLink.destinationCardinality)

        # link bidir
        root.setAttribute('bidir', str(pyutLink.getBidir()))

        # link destination
        root.setAttribute('destination', pyutLink.getDestination().getName())

        return root
예제 #4
0
    def _PyutLink2xml(self, pyutLink: PyutLink, xmlDoc):
        """
        Exporting an PyutLink to a miniDom Element.

        @param PyutLink pyutLink : Link to save
        @param xmlDoc : xml document
        @return Element : XML Node
        """

        root = xmlDoc.createElement('Link')
        # link name
        root.setAttribute('name', pyutLink.getName())

        # link type
        root.setAttribute('type', str(pyutLink.getType().value))

        # link cardinality source
        # root.setAttribute('cardSrc', pyutLink.getSourceCardinality())
        root.setAttribute('cardSrc', pyutLink.sourceCardinality)

        # link cardinality destination
        # root.setAttribute('cardDestination', pyutLink.getDestinationCardinality())
        root.setAttribute('cardDestination', pyutLink.destinationCardinality)

        # link bidir
        root.setAttribute('bidir', str(pyutLink.getBidir()))

        # link source
        srcLinkId = self._idFactory.getID(pyutLink.getSource())
        root.setAttribute('sourceId', str(srcLinkId))

        # link destination
        destLinkId = self._idFactory.getID(pyutLink.getDestination())
        root.setAttribute('destId', str(destLinkId))

        return root