Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XMI work #1298

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

XMI work #1298

wants to merge 9 commits into from

Conversation

daniel-santos
Copy link

@daniel-santos daniel-santos commented Feb 22, 2023

Hello! This is based off of v2023.1 but isn't ready. It turned out that the problem I was having was because I can't figure out how to properly run the thing under jdb (to do whatever the manifest is supposed to do) and when I build the jar file, it tries to use a graphical generator and blows up on the file type.

Exception in thread "main" java.lang.UnsupportedOperationException: XMI_STANDARD
        at net.sourceforge.plantuml.ugraphic.ImageBuilder.createUGraphic(ImageBuilder.java:474)
        at net.sourceforge.plantuml.ugraphic.ImageBuilder.writeImageInternal(ImageBuilder.java:298)
        at net.sourceforge.plantuml.ugraphic.ImageBuilder.write(ImageBuilder.java:256)
        at net.sourceforge.plantuml.PlainDiagram.exportDiagramNow(PlainDiagram.java:66)
        at net.sourceforge.plantuml.error.PSystemError.exportDiagramNow(PSystemError.java:245)
        at net.sourceforge.plantuml.AbstractPSystem.exportDiagram(AbstractPSystem.java:188)
        at net.sourceforge.plantuml.PSystemUtils.exportDiagramsDefault(PSystemUtils.java:204)
        at net.sourceforge.plantuml.PSystemUtils.exportDiagrams(PSystemUtils.java:93)
        at net.sourceforge.plantuml.SourceFileReaderAbstract.getGeneratedImages(SourceFileReaderAbstract.java:188)
        at net.sourceforge.plantuml.Run.manageFileInternal(Run.java:521)
        at net.sourceforge.plantuml.Run.processArgs(Run.java:404)
        at net.sourceforge.plantuml.Run.manageAllFiles(Run.java:371)
        at net.sourceforge.plantuml.Run.main(Run.java:205)

Obviously, this is far from ready, but I haven't yet figured out what's causing it to try to use an image builder and then blow up instead of using net.sourceforge.plantuml.xmi classes.

Once I get it working I'll rebase back onto master and use the new code classes.

@daniel-santos
Copy link
Author

daniel-santos commented Feb 22, 2023

I forgot to mention Issue #1294 in the commit message.

First this adds a stack-based helper class to clean up XML building
called net.sourceforge.plantuml.xml.XmlStackBuilderThingy.
net.sourceforge.plantuml.xmi.XmiClassDiagramAbstract now uses this in
the ctor to build XMI head.
… an unclosed node

This may not be necessary since I don't think there are any constraints
to when you add a child to it's parent or parent-to-be, but it keeps
with the motif of shoving things into a stack and not popping elements
until we're done adding everything into it. But this motif also adds the
complexity of needing to read it's return value and pop the number of
elements off when done.
This commit still needs clean up.

We're walking the model hierarchically and adding elements. Probably
doesn't fix associations yet.
@arnaudroques
Copy link
Contributor

The code is more stable now, so I think you should move to very last version, and check if it is working.

@daniel-santos
Copy link
Author

@arnaudroques Thank you! I've rebased back to it and it's working! I just need to fix up associations and I'll push and start getting ready to do this seriously.

And OMG, the new core layout makes this SO much easier! Now you already have the objects arranged according to their namespace hierarchy. My only other comment would be to try to eventually separate the model code from the presentation code. Thank you!

@arnaudroques
Copy link
Contributor

Two comments:

  • I don't get why you need XmlStackBuilderThingy. To me, this is not needed
  • last version does work with ArgoUML (well, I think :-)

@daniel-santos
Copy link
Author

daniel-santos commented Feb 22, 2023

Hello @arnaudroques !

I don't get why you need XmlStackBuilderThingy. To me, this is not needed

Well I don't care in the end. It's just an attempt to clean up repetitive code. But now that I've worked with this a bit more, I think I can make it prettier and cleaner than the current thingy (less verbose source code, essentially the same performance).

last version does work with ArgoUML (well, I think :-)

Well, it didn't work so well for me in Issue #1294 :(

I've got support a class that extends another class and implements an interface apparently working! But in order to determine what type of link I'm working with I made

final LinkStyle.Type linkStyleType = link.getType().getStyle().getType();
final boolean isExtends = link.getType().getDecor2() == LinkDecor.EXTENDS;
final boolean isRealization = isExtends && linkStyleType == LinkStyle.Type.DASHED;

For this to work I made net.sourceforge.plantuml.klimt.UStroke.LinkStyle.Type public and added a getType(). Is there a better way to do this or is this correct? EDIT: Oh, I see. This analysis should be added to Link et. al. if it isn't already there. I see I missed isExtendsLike()

I would love to just ask if this link is a this or that, but I presume that when I declare a class extends another, it just becomes shorthand for adding the link the old way and that's how it's stored?

I shall push shortly!

EDIT: Oh, it's only going to correctly support extends and implements for what I'm pushing. I'll need to work out how to properly render all link types.

@daniel-santos
Copy link
Author

Hello. I finally have something I can work with to get my very large Go project modeled! I'll have some more time to go over better ways to do things tomorrow.

I see you have a hot log of changes on the grill!

@arnaudroques
Copy link
Contributor

I think the best option is to add expected results here: https://github.com/plantuml/plantuml/tree/master/test/nonreg/xmi/clazz
Thanks!

@evantill
Copy link
Collaborator

seem to have problems related to namespace

expected:

<?xml version="1.0" encoding="UTF-8"?><XMI xmlns:UML="href://org.omg/UML/1.3" xmi.version="1.1">
    <XMI.header>
        <XMI.metamodel xmi.name="UML" xmi.version="1.3"/>
    </XMI.header>
    <XMI.content>
        <UML:Model name="PlantUML" xmi.id="model1">
            <UML:Namespace.ownedElement>
                <UML:Class name="foo" namespace="model1" visibility="private" xmi.id="cl0002">
                    <UML:Classifier.feature>
                        <UML:Attribute name="field1 : type" visibility="protected" xmi.id="att3"/>
                    </UML:Classifier.feature>
                </UML:Class>
            </UML:Namespace.ownedElement>
        </UML:Model>
    </XMI.content>
</XMI>

actual:

<?xml version="1.0" encoding="UTF-8"?><XMI xmlns:UML="org.omg.xmi.namespace.UML" xmi.version="1.2">
    <XMI.header>
        <XMI.documentation>
            <XMI.exporter>PlantUML</XMI.exporter>
            <XMI.exporterVersion>PlantUML 1.2022</XMI.exporterVersion>
        </XMI.documentation>
        <XMI.metamodel xmi.name="UML" xmi.version="1.4"/>
    </XMI.header>
    <XMI.content>
        <UML:Model name="PlantUML" xmi.id="model1">
            <UML:Namespace.ownedElement>
                <UML:Class name="foo" visibility="private" xmi.id="cl0002">
                    <UML:Classifier.feature>
                        <UML:Attribute name="field1 : type" visibility="protected" xmi.id="att3"/>
                    </UML:Classifier.feature>
                </UML:Class>
            </UML:Namespace.ownedElement>
        </UML:Model>
    </XMI.content>
</XMI>

@evantill evantill added t:info-needed Further information is requested and removed PR: needs rebase labels Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t:info-needed Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants