Search in sources :

Example 6 with OperationProvidedRole

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

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);
        }
    }
}
Also used : EntryLevelSystemCall(org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall) OperationSignature(org.palladiosimulator.pcm.repository.OperationSignature) OperationProvidedRole(org.palladiosimulator.pcm.repository.OperationProvidedRole)

Example 8 with OperationProvidedRole

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();
}
Also used : PalladioSelectEObjectDialog(org.palladiosimulator.editors.commons.dialogs.selection.PalladioSelectEObjectDialog) OperationProvidedRole(org.palladiosimulator.pcm.repository.OperationProvidedRole) ArrayList(java.util.ArrayList) EObject(org.eclipse.emf.ecore.EObject) EReference(org.eclipse.emf.ecore.EReference)

Example 9 with OperationProvidedRole

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();
}
Also used : Repository(org.palladiosimulator.pcm.repository.Repository) OperationProvidedRole(org.palladiosimulator.pcm.repository.OperationProvidedRole) RepositoryFactory(org.palladiosimulator.pcm.repository.RepositoryFactory) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent) OperationInterface(org.palladiosimulator.pcm.repository.OperationInterface) Interface(org.palladiosimulator.pcm.repository.Interface) Test(org.junit.Test)

Example 10 with OperationProvidedRole

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;
}
Also used : Repository(org.palladiosimulator.pcm.repository.Repository) PrimitiveDataType(org.palladiosimulator.pcm.repository.PrimitiveDataType) OperationProvidedRole(org.palladiosimulator.pcm.repository.OperationProvidedRole) OperationInterface(org.palladiosimulator.pcm.repository.OperationInterface) OperationRequiredRole(org.palladiosimulator.pcm.repository.OperationRequiredRole)

Aggregations

OperationProvidedRole (org.palladiosimulator.pcm.repository.OperationProvidedRole)22 OperationInterface (org.palladiosimulator.pcm.repository.OperationInterface)10 ProvidedRole (org.palladiosimulator.pcm.repository.ProvidedRole)9 RepositoryComponent (org.palladiosimulator.pcm.repository.RepositoryComponent)9 OperationRequiredRole (org.palladiosimulator.pcm.repository.OperationRequiredRole)7 AssemblyContext (org.palladiosimulator.pcm.core.composition.AssemblyContext)5 Interface (org.palladiosimulator.pcm.repository.Interface)5 OperationSignature (org.palladiosimulator.pcm.repository.OperationSignature)5 Repository (org.palladiosimulator.pcm.repository.Repository)5 RequiredRole (org.palladiosimulator.pcm.repository.RequiredRole)5 Test (org.junit.Test)4 AssemblyConnector (org.palladiosimulator.pcm.core.composition.AssemblyConnector)4 ArrayList (java.util.ArrayList)3 Connector (org.palladiosimulator.pcm.core.composition.Connector)3 BasicComponent (org.palladiosimulator.pcm.repository.BasicComponent)3 EntryLevelSystemCall (org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall)3 EObject (org.eclipse.emf.ecore.EObject)2 System (org.palladiosimulator.pcm.system.System)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1