Search in sources :

Example 51 with AssemblyContext

use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project iobserve-analysis by research-iobserve.

the class ProbeMapper method computeAllocationComponentServletId.

/**
 * Compute allocation component servlet id.
 *
 * @param entry
 * @param allocation
 * @param operationSignature
 * @return
 * @throws InvocationException
 * @throws DBException
 */
private String computeAllocationComponentServletId(final AllocationEntry entry, final AllocationContext allocation, final OperationSignature operationSignature) throws InvocationException, DBException {
    final EList<Parameter> parameterList = operationSignature.getParameters__OperationSignature();
    String parameters = null;
    for (final Parameter parameter : parameterList) {
        if (parameters == null) {
            parameters = parameter.getParameterName();
        } else {
            parameters += ", " + parameter.getParameterName();
        }
    }
    AssemblyContext assemblyContext = this.assemblyResource.resolve(allocation.getAssemblyContext_AllocationContext());
    assemblyContext = this.assemblyResource.resolve(assemblyContext);
    String component = "ERROR";
    for (final AssemblyEntry assemblyEntry : this.correspondenceResource.collectAllObjectsByType(AssemblyEntry.class, CorrespondencePackage.Literals.ASSEMBLY_ENTRY)) {
        final AssemblyContext entryRelatedContext = this.assemblyResource.resolve(assemblyEntry.getAssembly());
        // assemblyContext.eIsProxy());
        if (entryRelatedContext.getId().equals(assemblyContext.getId())) {
            component = assemblyEntry.getImplementationId();
        }
    }
    final String methodId = String.format("%s.%s (%s)", component, operationSignature.getEntityName(), parameters);
    this.logger.debug("Constructed method string: {}", methodId);
    return methodId;
}
Also used : AssemblyEntry(org.iobserve.model.correspondence.AssemblyEntry) Parameter(org.palladiosimulator.pcm.repository.Parameter) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext)

Example 52 with AssemblyContext

use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project iobserve-analysis by research-iobserve.

the class ProbeMapper method computeAllocationComponentJavaSignature.

private String computeAllocationComponentJavaSignature(final AllocationContext allocation, final OperationSignature operationSignature) throws ControlEventCreationFailedException, InvocationException, DBException {
    // there are only interfaces on model level -> therefore only public methods (no
    // getModifiers available)
    final String modifier = "public";
    final DataType returnType = operationSignature.getReturnType__OperationSignature();
    final List<DataTypeEntry> dataTypeEntries = this.correspondenceResource.collectAllObjectsByType(DataTypeEntry.class, CorrespondencePackage.Literals.DATA_TYPE_ENTRY);
    final String codeLevelReturnType = this.getCodeLevelDataType(dataTypeEntries, returnType);
    final String methodSignature = operationSignature.getEntityName();
    // TODO parameters
    final String parameterString = "*";
    final AssemblyContext assemblyContext = this.assemblyResource.resolve(allocation.getAssemblyContext_AllocationContext());
    final RepositoryComponent repositoryComponent = this.repositoryResource.resolve(assemblyContext.getEncapsulatedComponent__AssemblyContext());
    final List<ComponentEntry> componentEntries = this.correspondenceResource.collectAllObjectsByType(ComponentEntry.class, CorrespondencePackage.Literals.COMPONENT_ENTRY);
    final String codeLevelComponentIdentifier = this.getCodeLevelComponent(componentEntries, repositoryComponent);
    final String completeMethodSignature = modifier + " " + codeLevelReturnType + " " + codeLevelComponentIdentifier + "." + methodSignature + "(" + parameterString + ")";
    this.logger.debug("Constructed method string: {}", completeMethodSignature);
    return completeMethodSignature;
}
Also used : DataTypeEntry(org.iobserve.model.correspondence.DataTypeEntry) ComponentEntry(org.iobserve.model.correspondence.ComponentEntry) PrimitiveDataType(org.palladiosimulator.pcm.repository.PrimitiveDataType) CompositeDataType(org.palladiosimulator.pcm.repository.CompositeDataType) DataType(org.palladiosimulator.pcm.repository.DataType) CollectionDataType(org.palladiosimulator.pcm.repository.CollectionDataType) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent)

Example 53 with AssemblyContext

use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project iobserve-analysis by research-iobserve.

the class DataProtectionWarner method addConnectors.

/**
 * Adding connections between components to the privacy graph.
 *
 * @param graph
 *            graph
 * @throws DBException
 *             on db errors during resolving objects
 * @throws InvocationException
 *             on other errors during resolving objects
 */
private void addConnectors(final PrivacyGraph graph) throws InvocationException, DBException {
    for (final Connector connector : this.systemRootElement.getConnectors__ComposedStructure()) {
        if (connector instanceof AssemblyConnector) {
            final AssemblyConnector assemblyConnector = (AssemblyConnector) connector;
            // Providing Component
            final AssemblyContext provididingAssemblyContext = assemblyConnector.getProvidingAssemblyContext_AssemblyConnector();
            final RepositoryComponent providingComponent = this.repositoryResource.resolve(provididingAssemblyContext.getEncapsulatedComponent__AssemblyContext());
            // Requiring Component
            final AssemblyContext requiringAssemblyContext = assemblyConnector.getRequiringAssemblyContext_AssemblyConnector();
            final RepositoryComponent requiringComponent = this.repositoryResource.resolve(requiringAssemblyContext.getEncapsulatedComponent__AssemblyContext());
            if (providingComponent != null && requiringComponent != null) {
                final OperationProvidedRole providedRole = this.repositoryResource.resolve(assemblyConnector.getProvidedRole_AssemblyConnector());
                final String interfaceName = this.shortName(providedRole.getEntityName());
                // Check Interface Name in Repository and add Edge
                final OperationInterface operationInterface = this.interfaces.get(interfaceName);
                this.computePrivacyLevelsAndAddEdge(graph, operationInterface, providingComponent, requiringComponent);
            } else {
                this.logger.info("Either Providing: " + providingComponent + " was Null or Requiring: " + requiringComponent + " was Null.");
            }
        }
    }
}
Also used : AssemblyConnector(org.palladiosimulator.pcm.core.composition.AssemblyConnector) Connector(org.palladiosimulator.pcm.core.composition.Connector) AssemblyConnector(org.palladiosimulator.pcm.core.composition.AssemblyConnector) OperationProvidedRole(org.palladiosimulator.pcm.repository.OperationProvidedRole) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent) OperationInterface(org.palladiosimulator.pcm.repository.OperationInterface)

Example 54 with AssemblyContext

use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project iobserve-analysis by research-iobserve.

the class InitializeDeploymentVisualization method initialize.

/**
 * Populates the database of the deployment visualization initially and respects the changelog
 * constraints of iobserve-ui-deployment. It takes information from the system model, the
 * allocation model and the resource environment model and creates corresponding visualization
 * components, e.g. nodes and services.
 *
 * @throws IOException
 *             when post request fails
 */
public void initialize() throws IOException {
    // set up the system model and take parts from it
    final org.palladiosimulator.pcm.system.System systemModel = this.systemModelGraphProvider.readOnlyRootComponent(org.palladiosimulator.pcm.system.System.class);
    final List<AssemblyContext> assemblyContexts = systemModel.getAssemblyContexts__ComposedStructure();
    // set up the allocation model and take parts from it
    final List<String> allocationIds = this.allocationModelGraphProvider.readComponentByType(Allocation.class);
    // an allocation model contains exactly one allocation, therefore .get(0)
    final String allocationId = allocationIds.get(0);
    final Allocation allocation = this.allocationModelGraphProvider.readOnlyComponentById(Allocation.class, allocationId);
    final List<AllocationContext> allocationContexts = allocation.getAllocationContexts_Allocation();
    // set up the resource environment model and take parts from it
    final ResourceEnvironment resourceEnvironmentModel = this.resourceEnvironmentModelGraphProvider.readOnlyRootComponent(ResourceEnvironment.class);
    final List<LinkingResource> linkingResources = resourceEnvironmentModel.getLinkingResources__ResourceEnvironment();
    final List<ResourceContainer> resourceContainers = resourceEnvironmentModel.getResourceContainer_ResourceEnvironment();
    // sending created components to visualization (in predefined order stated in changelog
    // constraints)
    /**
     * system
     */
    SendHttpRequest.post(this.systemService.createSystem(systemModel), this.systemUrl, this.changelogUrl);
    /**
     * node group and node
     */
    for (int i = 0; i < resourceContainers.size(); i++) {
        final ResourceContainer resourceContainer = resourceContainers.get(i);
        SendHttpRequest.post(Changelog.create(this.nodegroupService.createNodegroup(this.systemService.getSystemId())), this.systemUrl, this.changelogUrl);
        SendHttpRequest.post(Changelog.create(this.nodeService.createNode(resourceContainer, this.systemService.getSystemId(), this.nodegroupService.getNodegroupId())), this.systemUrl, this.changelogUrl);
    }
    /**
     * service and service instance
     */
    for (int i = 0; i < assemblyContexts.size(); i++) {
        final AssemblyContext assemblyContext = assemblyContexts.get(i);
        SendHttpRequest.post(Changelog.create(this.serviceService.createService(assemblyContext, this.systemService.getSystemId())), this.systemUrl, this.changelogUrl);
    }
    for (int i = 0; i < allocationContexts.size(); i++) {
        final AllocationContext allocationContext = allocationContexts.get(i);
        final String resourceContainerId = allocationContext.getResourceContainer_AllocationContext().getId();
        final AssemblyContext assemblyContext = allocationContext.getAssemblyContext_AllocationContext();
        final String assemblyContextId = allocationContext.getAssemblyContext_AllocationContext().getId();
        SendHttpRequest.post(Changelog.create(this.serviceinstanceService.createServiceInstance(assemblyContext, this.systemService.getSystemId(), resourceContainerId, assemblyContextId)), this.systemUrl, this.changelogUrl);
    }
    /**
     * communication and communication instance
     */
    final List<Connector> connectors = systemModel.getConnectors__ComposedStructure();
    for (int i = 0; i < connectors.size(); i++) {
        final Connector connector = connectors.get(i);
        // we are only interested in AssemblyConnectors
        if (connector instanceof AssemblyConnector) {
            final String technology = this.getTechnology((AssemblyConnector) connector, linkingResources);
            SendHttpRequest.post(Changelog.create(this.communicationService.createCommunication((AssemblyConnector) connector, this.systemService.getSystemId(), technology)), this.systemUrl, this.changelogUrl);
            SendHttpRequest.post(Changelog.create(this.communicationinstanceService.createCommunicationInstance((AssemblyConnector) connector, this.systemService.getSystemId(), this.communicationService.getCommunicationId())), this.systemUrl, this.changelogUrl);
        } else {
            InitializeDeploymentVisualization.LOGGER.debug("no AssemblyConnector: connector.getEntityName()");
        }
    }
}
Also used : AssemblyConnector(org.palladiosimulator.pcm.core.composition.AssemblyConnector) Connector(org.palladiosimulator.pcm.core.composition.Connector) ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) LinkingResource(org.palladiosimulator.pcm.resourceenvironment.LinkingResource) AssemblyConnector(org.palladiosimulator.pcm.core.composition.AssemblyConnector) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) Allocation(org.palladiosimulator.pcm.allocation.Allocation) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 55 with AssemblyContext

use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project iobserve-analysis by research-iobserve.

the class InitializeUserBehaviorVisualization method initialize.

/**
 * Initialize the diagram.
 */
public void initialize() {
    // TODO not working yet
    // map elements in entryLevelSystemCalls to assemblyContexts
    final List<AssemblyContext> userInvokedServices = new ArrayList<>();
    List<EntryLevelSystemCall> entryLevelSystemCalls = new ArrayList<>();
    entryLevelSystemCalls = this.collectEntryLevelSystemCalls(this.usageScenarios);
    for (int m = 0; m < entryLevelSystemCalls.size(); m++) {
        final EntryLevelSystemCall userStep = entryLevelSystemCalls.get(m);
        final String providedRoleId = userStep.getProvidedRole_EntryLevelSystemCall().getId();
        final List<EObject> usergroupConnectors = this.systemModelProvider.readOnlyReferencingComponentsById(OperationProvidedRole.class, providedRoleId);
        final ProvidedDelegationConnectorImpl usergroupConnector = (ProvidedDelegationConnectorImpl) usergroupConnectors.get(0);
        final AssemblyContext assemblyContext = usergroupConnector.getAssemblyContext_ProvidedDelegationConnector();
        userInvokedServices.add(assemblyContext);
    }
    if (!userInvokedServices.isEmpty()) {
        // NOCS NOPMD
        this.usageModelProvider.readComponentById(UsageModel.class, "0");
    // SendHttpRequest.post(Changelog.create(
    // this.usergroupService.createUsergroup(this.systemService.getSystemId(),
    // userInvokedServices)),
    // this.systemUrl, this.changelogUrl);
    // TODO fixme
    }
}
Also used : EntryLevelSystemCall(org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) ProvidedDelegationConnectorImpl(org.palladiosimulator.pcm.core.composition.impl.ProvidedDelegationConnectorImpl)

Aggregations

AssemblyContext (org.palladiosimulator.pcm.core.composition.AssemblyContext)64 AllocationContext (org.palladiosimulator.pcm.allocation.AllocationContext)16 RepositoryComponent (org.palladiosimulator.pcm.repository.RepositoryComponent)11 ArrayList (java.util.ArrayList)9 ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)9 AssemblyConnector (org.palladiosimulator.pcm.core.composition.AssemblyConnector)8 System (org.palladiosimulator.pcm.system.System)8 Test (org.junit.Test)7 Connector (org.palladiosimulator.pcm.core.composition.Connector)7 OperationProvidedRole (org.palladiosimulator.pcm.repository.OperationProvidedRole)6 HashSet (java.util.HashSet)5 EObject (org.eclipse.emf.ecore.EObject)5 Allocation (org.palladiosimulator.pcm.allocation.Allocation)5 DataPrivacyLvl (org.palladiosimulator.pcm.compositionprivacy.DataPrivacyLvl)5 OperationRequiredRole (org.palladiosimulator.pcm.repository.OperationRequiredRole)5 ProvidedRole (org.palladiosimulator.pcm.repository.ProvidedRole)5 HashMap (java.util.HashMap)4 AssemblyEntry (org.iobserve.model.correspondence.AssemblyEntry)4 RequiredRole (org.palladiosimulator.pcm.repository.RequiredRole)4 URL (java.net.URL)3