8000 inst.getActor() contains no incoming or outgoing port map · Issue #139 · orcc/orcc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

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

Open
robstewart57 opened this issue Mar 8, 2016 · 0 comments
Open

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

robstewart57 opened this issue Mar 8, 2016 · 0 comments

Comments

@robstewart57
Copy link
Contributor

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0