use of org.palladiosimulator.pcm.repository.OperationProvidedRole 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.OperationProvidedRole in project Palladio-Editors-Sirius by PalladioSimulator.
the class EntryLevelSystemCallDialog method execute.
@Override
public void execute(Collection<? extends EObject> selections, Map<String, Object> parameters) {
EntryLevelSystemCall element = (EntryLevelSystemCall) parameters.get("instance");
OperationProvidedRole oldRole = element.getProvidedRole_EntryLevelSystemCall();
OperationProvidedRole role = getOperationProvidedRole(element);
if (role != null) {
element.setProvidedRole_EntryLevelSystemCall(role);
OperationSignature signature = getOperationSignature(element);
if (signature != null) {
element.setOperationSignature__EntryLevelSystemCall(signature);
} else {
element.setProvidedRole_EntryLevelSystemCall(oldRole);
}
}
}
use of org.palladiosimulator.pcm.repository.OperationProvidedRole in project Palladio-Editors-Sirius by PalladioSimulator.
the class EntryLevelSystemCallDialog method getOperationProvidedRole.
private OperationProvidedRole getOperationProvidedRole(EntryLevelSystemCall element) {
Collection<Object> filter = new ArrayList<Object>();
filter.add(System.class);
filter.add(OperationProvidedRole.class);
Collection<EReference> additionalChildReferences = new ArrayList<EReference>();
PalladioSelectEObjectDialog dialog = new PalladioSelectEObjectDialog(SHELL, filter, additionalChildReferences, element.eResource().getResourceSet());
dialog.setProvidedService(OperationProvidedRole.class);
dialog.open();
return (OperationProvidedRole) dialog.getResult();
}
use of org.palladiosimulator.pcm.repository.OperationProvidedRole in project iobserve-analysis by research-iobserve.
the class RepositoryModelProviderTest method createThenUpdateThenReadUpdated.
@Override
@Test
public void createThenUpdateThenReadUpdated() throws NodeLookupException, DBException {
final Neo4JModelResource<Repository> resource = ModelProviderTestUtils.prepareResource("createThenUpdateThenReadUpdated", this.prefix, this.ePackage);
final Interface payInterface = RepositoryModelDataFactory.findInterfaceByName(this.repository, RepositoryModelDataFactory.PAYMENT_INTERFACE);
final RepositoryComponent paymentComponent = RepositoryModelDataFactory.findComponentByName(this.repository, RepositoryModelDataFactory.PAYMENT_COMPONENT);
resource.storeModelPartition(this.testModel);
// Update the model by renaming and replacing the payment method
this.testModel.setEntityName("MyVideoOnDemandService");
final OperationProvidedRole providedPayOperation = ((RepositoryFactory) this.ePackage.getEFactoryInstance()).createOperationProvidedRole();
providedPayOperation.setEntityName("payPalPayment");
providedPayOperation.setProvidedInterface__OperationProvidedRole((OperationInterface) payInterface);
paymentComponent.getProvidedRoles_InterfaceProvidingEntity().clear();
paymentComponent.getProvidedRoles_InterfaceProvidingEntity().add(providedPayOperation);
resource.updatePartition(this.testModel);
final Repository readModel = resource.getModelRootNode(Repository.class, RepositoryPackage.Literals.REPOSITORY);
Assert.assertTrue(this.equalityHelper.comparePartition(this.testModel, readModel, readModel.eClass()));
resource.getGraphDatabaseService().shutdown();
}
use of org.palladiosimulator.pcm.repository.OperationProvidedRole in project iobserve-analysis by research-iobserve.
the class RepositoryModelDataFactory method createBookstoreRepositoryModel.
/**
* Create a repository with a strange bookstore example.
*
* @return the repository
*/
public static Repository createBookstoreRepositoryModel() {
final Repository repository = RepositoryFactory.eINSTANCE.createRepository();
repository.setEntityName("MyBookstore");
/**
* data types.
*/
final PrimitiveDataType intDataType = RepositoryFactory.eINSTANCE.createPrimitiveDataType();
intDataType.setType(PrimitiveTypeEnum.INT);
final PrimitiveDataType stringDataType = RepositoryFactory.eINSTANCE.createPrimitiveDataType();
intDataType.setType(PrimitiveTypeEnum.STRING);
repository.getDataTypes__Repository().add(intDataType);
repository.getDataTypes__Repository().add(stringDataType);
/**
* interfaces.
*/
final OperationInterface queryInterface = RepositoryModelDataFactory.createInterface(RepositoryModelDataFactory.QUERY_INTERFACE, RepositoryModelDataFactory.createSignature("getQuery", stringDataType));
final OperationInterface paymentInterface = RepositoryModelDataFactory.createInterface(RepositoryModelDataFactory.PAYMENT_INTERFACE, RepositoryModelDataFactory.createSignature("withdraw", intDataType));
final OperationInterface searchInterface = RepositoryModelDataFactory.createInterface(RepositoryModelDataFactory.SEARCH_INTERFACE, RepositoryModelDataFactory.createSignature("getPrice", intDataType));
repository.getInterfaces__Repository().add(queryInterface);
repository.getInterfaces__Repository().add(paymentInterface);
repository.getInterfaces__Repository().add(searchInterface);
/**
* roles.
*/
final OperationProvidedRole providedInputRole = RepositoryModelDataFactory.createProvidedRole(RepositoryModelDataFactory.QUERY_PROVIDED_ROLE, queryInterface);
final OperationProvidedRole providedPayRole = RepositoryModelDataFactory.createProvidedRole(RepositoryModelDataFactory.PAYMENT_PROVIDED_ROLE, paymentInterface);
final OperationProvidedRole providedSearchRole = RepositoryModelDataFactory.createProvidedRole(RepositoryModelDataFactory.CATALOG_SEARCH_PROVIDED_ROLE, searchInterface);
final OperationRequiredRole requiredQueryInputRole = RepositoryModelDataFactory.createRequiredRole(RepositoryModelDataFactory.QUERY_REQUIRED_ROLE, queryInterface);
final OperationRequiredRole requiredPayRole = RepositoryModelDataFactory.createRequiredRole(RepositoryModelDataFactory.PAYMENT_REQUIRED_ROLE, paymentInterface);
final OperationRequiredRole requiredSearchRole = RepositoryModelDataFactory.createRequiredRole(RepositoryModelDataFactory.SEARCH_REQUIRED_ROLE, searchInterface);
/**
* components.
*/
repository.getComponents__Repository().add(RepositoryModelDataFactory.createBasicComponent(RepositoryModelDataFactory.QUERY_COMPONENT, requiredQueryInputRole, null));
repository.getComponents__Repository().add(RepositoryModelDataFactory.createBasicComponent(RepositoryModelDataFactory.PROCESSING_COMPONENT, requiredSearchRole, null));
repository.getComponents__Repository().add(RepositoryModelDataFactory.createBasicComponent(RepositoryModelDataFactory.SEARCH_COMPONENT, null, providedSearchRole));
repository.getComponents__Repository().add(RepositoryModelDataFactory.createBasicComponent(RepositoryModelDataFactory.PAYMENT_COMPONENT, null, providedPayRole));
repository.getComponents__Repository().add(RepositoryModelDataFactory.createBasicComponent(RepositoryModelDataFactory.ORDER_COMPONENT, requiredPayRole, providedInputRole));
return repository;
}
Aggregations