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;
}
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>());
}
}
}
}
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();
}
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();
}
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();
}
Aggregations