Search in sources :

Example 1 with RequiredRole

use of org.palladiosimulator.pcm.repository.RequiredRole in project iobserve-analysis by research-iobserve.

the class SystemGeneration method connectRequiredInterfaces.

/*
     * This method tries to connect all required interfaces to the open provided interfaces.
     *
     * If this is not possible the interface will be added to the open required interfaces for later
     * connecting.
     */
private int connectRequiredInterfaces(final AssemblyContext newAC, final EList<RequiredRole> requRoles) {
    int connectionsCreated = 0;
    for (final RequiredRole requRole : requRoles) {
        // Connect all providing interfaces!
        if (!(requRole instanceof OperationRequiredRole)) {
            continue;
        }
        boolean connected = false;
        final OperationRequiredRole reqInterface = (OperationRequiredRole) requRole;
        final String interfaceID = reqInterface.getRequiredInterface__OperationRequiredRole().getId();
        if (this.openProvidedInterfaces.get(interfaceID).size() > 0) {
            // Open provided interface is available
            final List<AssemblyContext> openProvidingAC = this.openProvidedInterfaces.get(interfaceID);
            final AssemblyContext providingAC = this.getAndRemoveRandomAC(openProvidingAC, newAC);
            if (providingAC != null) {
                this.createAssemblyConnector(newAC, providingAC, interfaceID);
                this.connectedProvidedInterfaces.get(interfaceID).add(providingAC);
                connectionsCreated++;
                connected = true;
            }
        }
        if (!connected) {
            // Add to open, but required interfaces to connect later!
            final List<AssemblyContext> acs = this.openRequiredInterfaces.get(interfaceID);
            acs.add(newAC);
        }
    }
    return connectionsCreated;
}
Also used : RequiredRole(org.palladiosimulator.pcm.repository.RequiredRole) OperationRequiredRole(org.palladiosimulator.pcm.repository.OperationRequiredRole) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) OperationRequiredRole(org.palladiosimulator.pcm.repository.OperationRequiredRole)

Example 2 with RequiredRole

use of org.palladiosimulator.pcm.repository.RequiredRole in project iobserve-analysis by research-iobserve.

the class SystemGeneration method initInterfaceMaps.

private void initInterfaceMaps() {
    this.openRequiredInterfaces = new HashMap<>();
    this.openProvidedInterfaces = new HashMap<>();
    this.connectedProvidedInterfaces = new HashMap<>();
    this.unconnectedAssemblyContextes = new HashSet<>();
    for (final RepositoryComponent component : this.components) {
        for (final ProvidedRole provRole : component.getProvidedRoles_InterfaceProvidingEntity()) {
            if (!(provRole instanceof OperationProvidedRole)) {
                continue;
            }
            final OperationProvidedRole provInterface = (OperationProvidedRole) provRole;
            final String interfaceID = provInterface.getProvidedInterface__OperationProvidedRole().getId();
            if (!this.openProvidedInterfaces.containsKey(interfaceID)) {
                this.openProvidedInterfaces.put(interfaceID, new LinkedList<AssemblyContext>());
                this.openRequiredInterfaces.put(interfaceID, new LinkedList<AssemblyContext>());
                this.connectedProvidedInterfaces.put(interfaceID, new LinkedList<AssemblyContext>());
            }
        }
        for (final RequiredRole requRole : component.getRequiredRoles_InterfaceRequiringEntity()) {
            if (!(requRole instanceof OperationRequiredRole)) {
                continue;
            }
            final OperationRequiredRole reqInterface = (OperationRequiredRole) requRole;
            final String interfaceID = reqInterface.getRequiredInterface__OperationRequiredRole().getId();
            if (!this.openProvidedInterfaces.containsKey(interfaceID)) {
                this.openProvidedInterfaces.put(interfaceID, new LinkedList<AssemblyContext>());
                this.openRequiredInterfaces.put(interfaceID, new LinkedList<AssemblyContext>());
                this.connectedProvidedInterfaces.put(interfaceID, new LinkedList<AssemblyContext>());
            }
        }
    }
}
Also used : OperationProvidedRole(org.palladiosimulator.pcm.repository.OperationProvidedRole) ProvidedRole(org.palladiosimulator.pcm.repository.ProvidedRole) RequiredRole(org.palladiosimulator.pcm.repository.RequiredRole) OperationRequiredRole(org.palladiosimulator.pcm.repository.OperationRequiredRole) OperationProvidedRole(org.palladiosimulator.pcm.repository.OperationProvidedRole) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent) OperationRequiredRole(org.palladiosimulator.pcm.repository.OperationRequiredRole)

Example 3 with RequiredRole

use of org.palladiosimulator.pcm.repository.RequiredRole in project iobserve-analysis by research-iobserve.

the class SystemModification method caluclateInterfaceSignature.

/*
     * Calculates the inteface signuature of a component.
     */
private String caluclateInterfaceSignature(final RepositoryComponent comp) {
    final StringBuilder sb = new StringBuilder();
    // Calculate Providing Signature
    final List<OperationProvidedRole> provInterfaces = new ArrayList<>();
    for (final ProvidedRole provInterface : comp.getProvidedRoles_InterfaceProvidingEntity()) {
        if (provInterface instanceof OperationProvidedRole) {
            provInterfaces.add((OperationProvidedRole) provInterface);
        }
    }
    // Order Interfaces
    Collections.sort(provInterfaces, (final OperationProvidedRole a1, final OperationProvidedRole a2) -> a1.getProvidedInterface__OperationProvidedRole().getId().compareTo(a2.getProvidedInterface__OperationProvidedRole().getId()));
    // Build sig part from Prefix + Interface ID
    for (final OperationProvidedRole provInterface : provInterfaces) {
        sb.append(";p_").append(provInterface.getProvidedInterface__OperationProvidedRole().getId());
    }
    // Calculate Requiring Signature
    // Get Operation Interfaces
    final List<OperationRequiredRole> reqInterfaces = new ArrayList<>();
    for (final RequiredRole reqInterface : comp.getRequiredRoles_InterfaceRequiringEntity()) {
        if (reqInterface instanceof OperationRequiredRole) {
            reqInterfaces.add((OperationRequiredRole) reqInterface);
        }
    }
    // Order Interfaces
    Collections.sort(reqInterfaces, (final OperationRequiredRole a1, final OperationRequiredRole a2) -> a1.getRequiredInterface__OperationRequiredRole().getId().compareTo(a2.getRequiredInterface__OperationRequiredRole().getId()));
    // Build sig part from Prefix + Interface ID
    for (final OperationRequiredRole reqInterface : reqInterfaces) {
        sb.append(";r_").append(reqInterface.getRequiredInterface__OperationRequiredRole().getId());
    }
    return sb.toString();
}
Also used : OperationProvidedRole(org.palladiosimulator.pcm.repository.OperationProvidedRole) ProvidedRole(org.palladiosimulator.pcm.repository.ProvidedRole) OperationRequiredRole(org.palladiosimulator.pcm.repository.OperationRequiredRole) RequiredRole(org.palladiosimulator.pcm.repository.RequiredRole) OperationProvidedRole(org.palladiosimulator.pcm.repository.OperationProvidedRole) ArrayList(java.util.ArrayList) OperationRequiredRole(org.palladiosimulator.pcm.repository.OperationRequiredRole)

Example 4 with RequiredRole

use of org.palladiosimulator.pcm.repository.RequiredRole in project Palladio-Editors-Sirius by PalladioSimulator.

the class SetInfrastructureSignature method getSignature.

private InfrastructureSignature getSignature(InfrastructureCall call) {
    Collection<Object> filter = new ArrayList<Object>();
    filter.add(Repository.class);
    filter.add(InfrastructureInterface.class);
    filter.add(InfrastructureSignature.class);
    Collection<EReference> additionalChildReferences = new ArrayList<EReference>();
    PalladioSelectEObjectDialog dialog = new PalladioSelectEObjectDialog(SHELL, filter, additionalChildReferences, call.eResource().getResourceSet());
    dialog.setProvidedService(InfrastructureSignature.class);
    // only take required InfrastructureInterfaces
    for (Object o : dialog.getTreeViewer().getExpandedElements()) {
        if (!(o instanceof InfrastructureInterface))
            continue;
        ServiceEffectSpecification seff = (ServiceEffectSpecification) call.getAction__InfrastructureCall().getResourceDemandingBehaviour_AbstractAction();
        BasicComponent parent = seff.getBasicComponent_ServiceEffectSpecification();
        boolean found = false;
        for (RequiredRole r : parent.getRequiredRoles_InterfaceRequiringEntity()) {
            if (!(r instanceof InfrastructureRequiredRole))
                continue;
            InfrastructureRequiredRole ir = (InfrastructureRequiredRole) r;
            if (ir.getRequiredInterface__InfrastructureRequiredRole().equals(o)) {
                found = true;
                call.setRequiredRole__InfrastructureCall(ir);
            }
        }
        if (!found)
            dialog.getTreeViewer().remove(o);
    }
    dialog.open();
    return (InfrastructureSignature) dialog.getResult();
}
Also used : InfrastructureRequiredRole(org.palladiosimulator.pcm.repository.InfrastructureRequiredRole) RequiredRole(org.palladiosimulator.pcm.repository.RequiredRole) ArrayList(java.util.ArrayList) ServiceEffectSpecification(org.palladiosimulator.pcm.seff.ServiceEffectSpecification) InfrastructureInterface(org.palladiosimulator.pcm.repository.InfrastructureInterface) InfrastructureSignature(org.palladiosimulator.pcm.repository.InfrastructureSignature) PalladioSelectEObjectDialog(org.palladiosimulator.editors.commons.dialogs.selection.PalladioSelectEObjectDialog) InfrastructureRequiredRole(org.palladiosimulator.pcm.repository.InfrastructureRequiredRole) BasicComponent(org.palladiosimulator.pcm.repository.BasicComponent) EObject(org.eclipse.emf.ecore.EObject) EReference(org.eclipse.emf.ecore.EReference)

Example 5 with RequiredRole

use of org.palladiosimulator.pcm.repository.RequiredRole in project Palladio-Editors-Sirius by PalladioSimulator.

the class AddEmitEventAction method getEventType.

private EventType getEventType(EmitEventAction emitEventAction) {
    Collection<Object> filter = new ArrayList<Object>();
    filter.add(Repository.class);
    filter.add(EventGroup.class);
    filter.add(EventType.class);
    Collection<EReference> additionalChildReferences = new ArrayList<EReference>();
    PalladioSelectEObjectDialog dialog = new PalladioSelectEObjectDialog(SHELL, filter, additionalChildReferences, emitEventAction.eResource().getResourceSet());
    dialog.setProvidedService(EventType.class);
    // Only show EventTypes from EventGroups from SourceRoles of the parent BasicComponent
    for (Object o : dialog.getTreeViewer().getExpandedElements()) {
        if (!(o instanceof EventGroup))
            continue;
        ServiceEffectSpecification seff = SEFFUtil.getEnclosingSEFF(emitEventAction.getResourceDemandingBehaviour_AbstractAction());
        BasicComponent parent = seff.getBasicComponent_ServiceEffectSpecification();
        boolean found = false;
        for (RequiredRole r : parent.getRequiredRoles_InterfaceRequiringEntity()) {
            if (!(r instanceof SourceRole))
                continue;
            SourceRole sourceRole = (SourceRole) r;
            if (sourceRole.getEventGroup__SourceRole().equals(o)) {
                found = true;
                emitEventAction.setSourceRole__EmitEventAction(sourceRole);
            }
        }
        if (!found)
            dialog.getTreeViewer().remove(o);
    }
    dialog.open();
    return (EventType) dialog.getResult();
}
Also used : SourceRole(org.palladiosimulator.pcm.repository.SourceRole) RequiredRole(org.palladiosimulator.pcm.repository.RequiredRole) EventType(org.palladiosimulator.pcm.repository.EventType) ArrayList(java.util.ArrayList) ServiceEffectSpecification(org.palladiosimulator.pcm.seff.ServiceEffectSpecification) EventGroup(org.palladiosimulator.pcm.repository.EventGroup) PalladioSelectEObjectDialog(org.palladiosimulator.editors.commons.dialogs.selection.PalladioSelectEObjectDialog) BasicComponent(org.palladiosimulator.pcm.repository.BasicComponent) EObject(org.eclipse.emf.ecore.EObject) EReference(org.eclipse.emf.ecore.EReference)

Aggregations

RequiredRole (org.palladiosimulator.pcm.repository.RequiredRole)8 OperationRequiredRole (org.palladiosimulator.pcm.repository.OperationRequiredRole)6 OperationProvidedRole (org.palladiosimulator.pcm.repository.OperationProvidedRole)5 ProvidedRole (org.palladiosimulator.pcm.repository.ProvidedRole)5 ArrayList (java.util.ArrayList)4 AssemblyContext (org.palladiosimulator.pcm.core.composition.AssemblyContext)4 RepositoryComponent (org.palladiosimulator.pcm.repository.RepositoryComponent)3 EObject (org.eclipse.emf.ecore.EObject)2 EReference (org.eclipse.emf.ecore.EReference)2 PalladioSelectEObjectDialog (org.palladiosimulator.editors.commons.dialogs.selection.PalladioSelectEObjectDialog)2 BasicComponent (org.palladiosimulator.pcm.repository.BasicComponent)2 ServiceEffectSpecification (org.palladiosimulator.pcm.seff.ServiceEffectSpecification)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 EList (org.eclipse.emf.common.util.EList)1