+
Skip to content

inst.getActor() contains no incoming or outgoing port map #139

@robstewart57

Description

@robstewart57

When I obtain an actor from an instance with instance.getActor(), the .getIncomingPortMap() and .getOutgoingPortMap() methods both return empty maps. This is the case even for actors that are connected to predecessor and successor actors with connections, so the returned map container should contain entries.

For example, here is a simple XDF graphiti feature:

public class MyFeature extends AbstractTimeConsumingCustomFeature {
    @Override
    public void execute(ICustomContext context, IProgressMonitor parentMonitor) {
        final Network currentNetwork = (Network)
            getBusinessObjectForPictogramElement( getDiagram() );
        for (Vertex ver : currentNetwork.getVertices()) {
            if (ver instanceof Instance) {
                Instance inst = (Instance) ver;
                Actor actor = inst.getActor();
                System.out.println(actor.getName() + ": " + actor.getIncomingPortMap().size());
            }
        }
    }
}

It prints an empty entry set for actors in my network that have incoming connections.

I've tried to find the root cause of this issue. It may be something to do with EMF resources. Below is the code used to fill the dialog box with instances and networks, to update a refinement for a graphiti container shape (a box).

First, here's the code of interest, modified with a print statement to inspect the incomingPortMap() for the actor consumed with emfResourceSet.getResource(uri, true);

if (DfPackage.eINSTANCE.getNetwork().equals(classz)
    || DfPackage.eINSTANCE.getActor().equals(classz)) {
     if (DfPackage.eINSTANCE.getActor().equals(classz)) {
          Actor actor = (Actor) eobject;
         System.out.println("Adding: " + actor.getName() + ", " + actor.getIncomingPortMap());
     }
    objects.add(eobject);
}

This also prints an empty entry set for actors that do have incoming connections. Here's it in full:

public class EntitySelectionDialog extends FilteredItemsSelectionDialog {

    /* other methods (omitted) */

    private void fillEntitiesList(IFolder folder) throws CoreException {

        final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
        URI.createPlatformResourceURI(resource.getFullPath().toString(),
                                      true);
        injector.getInstance(IGenerator.class);
        for (IResource resource : folder.members()) {
            if (resource.getType() == IResource.FOLDER) {
                fillEntitiesList((IFolder) resource);
            } else if (resource.getType() == IResource.FILE) {
                final String suffix = resource.getFileExtension();
                if (!OrccUtil.IR_SUFFIX.equals(suffix)
                    && !OrccUtil.NETWORK_SUFFIX.equals(suffix)) {
                    continue;
                }
                final URI uri =
                    URI.createPlatformResourceURI(resource.getFullPath().toString(),
                                                  true);
                if (!root.exists(resource.getFullPath())) {
                    continue;
                }

                EObject eobject = null;
                try {
                    final Resource emfRes = emfResourceSet.getResource(uri, true);
                    if (emfRes == null || emfRes.getContents().size() == 0) {
                        continue;
                    }
                    eobject = emfRes.getContents().get(0);
                    if (eobject == null) {
                        continue;
                    }
                } catch (NullPointerException e) {
                    continue;
                } catch (Exception e) {
                    continue;
                }

                final EClass classz = eobject.eClass();
                if (classz == null) {
                    continue;
                }
                if (DfPackage.eINSTANCE.getNetwork().equals(classz)
                    || DfPackage.eINSTANCE.getActor().equals(classz)) {
                    if (DfPackage.eINSTANCE.getActor().equals(classz)) {
                        Actor actor = (Actor) eobject;
                        System.out.println("Adding: " + actor.getName() + ", " + actor.getIncomingPortMap());
                    }
                    objects.add(eobject);
                }
            }
        }
    }
}

I don't know how this works:

 final Resource emfRes = emfResourceSet.getResource(uri, true);

It looks a bit magical to me, given that I'm not familiar with the EMF framework. Even so, it does appear that it doesn't seem to be getting the entire resource correctly, namely for actors it does not be getting information about incoming or outgoing port maps.

What's the resolution? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载