Search in sources :

Example 1 with GeoLocation

use of org.iobserve.model.privacy.GeoLocation in project iobserve-analysis by research-iobserve.

the class CreatePrivacyMain method addGeoLocations.

private static void addGeoLocations(final DataProtectionModel privacyModel, final ResourceEnvironment environment) {
    for (final ResourceContainer container : environment.getResourceContainer_ResourceEnvironment()) {
        CreatePrivacyMain.LOGGER.debug(String.format("have container %s\n", container.getEntityName()));
        final GeoLocation location = PrivacyFactory.eINSTANCE.createGeoLocation();
        location.setIsocode(CreatePrivacyMain.ISO_CODE_MAPS.get(container.getEntityName()));
        location.setResourceContainer(container);
        privacyModel.getResourceContainerLocations().add(location);
    }
}
Also used : GeoLocation(org.iobserve.model.privacy.GeoLocation) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 2 with GeoLocation

use of org.iobserve.model.privacy.GeoLocation in project iobserve-analysis by research-iobserve.

the class DataProtectionWarner method addDeployedComponents.

/**
 * Adding deployment info.
 *
 * @param privacyGraph
 *            the graph containing privacy information
 * @throws DBException
 * @throws InvocationException
 */
private void addDeployedComponents(final PrivacyGraph privacyGraph) throws InvocationException, DBException {
    DeploymentLock.lock();
    for (final AllocationContext allocationContext : this.allocationRootElement.getAllocationContexts_Allocation()) {
        final AssemblyContext proxyAssemblyContext = allocationContext.getAssemblyContext_AllocationContext();
        final AssemblyContext assemblyContext = this.systemModelResource.resolve(proxyAssemblyContext);
        final RepositoryComponent proxyComponent = assemblyContext.getEncapsulatedComponent__AssemblyContext();
        final BasicComponent basicComponent = (BasicComponent) this.repositoryResource.resolve(proxyComponent);
        /**
         * Creating component vertices. *
         */
        // TODO name should be allocation name or assembly name + instance count
        final Vertex vertex = new Vertex(basicComponent.getEntityName(), this.computeStereotype(basicComponent));
        vertex.setAllocationContext(allocationContext);
        privacyGraph.addVertex(vertex);
        this.vertices.put(basicComponent.getId(), vertex);
        final ResourceContainer resourceContainer = this.resourceEnvironmentResource.resolve(allocationContext.getResourceContainer_AllocationContext());
        final GeoLocation geo = this.geolocations.get(resourceContainer.getId());
        if (geo == null) {
            this.logger.info("Geolocation infomation not available {}", resourceContainer.getId());
        } else {
            final Vertex vGeo = new Vertex(geo.getIsocode().getName(), EStereoType.GEOLOCATION);
            if (!this.vertices.containsKey(geo.getIsocode().getName())) {
                // New Geolocation
                privacyGraph.addVertex(vGeo);
                privacyGraph.addEdge(vGeo, vertex);
                this.vertices.put(geo.getIsocode().getName(), vGeo);
            } else {
                // Existing Geolocation
                privacyGraph.addEdge(this.vertices.get(geo.getIsocode().getName()), vertex);
            }
        }
    }
    DeploymentLock.unlock();
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) Vertex(org.iobserve.service.privacy.violation.transformation.analysisgraph.Vertex) BasicComponent(org.palladiosimulator.pcm.repository.BasicComponent) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) GeoLocation(org.iobserve.model.privacy.GeoLocation) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 3 with GeoLocation

use of org.iobserve.model.privacy.GeoLocation in project iobserve-analysis by research-iobserve.

the class GeoLocationStage method execute.

@Override
protected void execute(final PCMDeployedEvent event) throws Exception {
    DeploymentLock.lock();
    this.logger.debug("event received assmeblyContext={} countryCode={} resourceContainer={} service={} url={}", event.getAssemblyContext().getEntityName(), event.getCountryCode(), event.getResourceContainer().getEntityName(), event.getService(), event.getUrl());
    final GeoLocation geoLocation = this.getGeoLocationForContainer(event.getResourceContainer());
    if (geoLocation == null) {
        /**
         * create a geo location.
         */
        final DataProtectionModel privacyModel = this.privacyModelResource.getModelRootNode(DataProtectionModel.class, PrivacyPackage.Literals.DATA_PROTECTION_MODEL);
        privacyModel.getResourceContainerLocations().add(this.createGeoLocation(event.getResourceContainer(), event.getCountryCode()));
        this.privacyModelResource.updatePartition(privacyModel);
    } else {
        /**
         * update the geo location.
         */
        geoLocation.setIsocode(EISOCode.get(event.getCountryCode().getValue()));
        this.privacyModelResource.updatePartition(geoLocation);
    }
    DeploymentLock.unlock();
    this.outputPort.send(event);
}
Also used : DataProtectionModel(org.iobserve.model.privacy.DataProtectionModel) GeoLocation(org.iobserve.model.privacy.GeoLocation)

Example 4 with GeoLocation

use of org.iobserve.model.privacy.GeoLocation in project iobserve-analysis by research-iobserve.

the class GeoLocationStage method createGeoLocation.

private GeoLocation createGeoLocation(final ResourceContainer resourceContainer, final ISOCountryCode countryCode) {
    final GeoLocation geoLocation = PrivacyFactory.eINSTANCE.createGeoLocation();
    geoLocation.setIsocode(EISOCode.get(countryCode.getValue()));
    geoLocation.setResourceContainer(resourceContainer);
    return geoLocation;
}
Also used : GeoLocation(org.iobserve.model.privacy.GeoLocation)

Example 5 with GeoLocation

use of org.iobserve.model.privacy.GeoLocation in project iobserve-analysis by research-iobserve.

the class DataProtectionWarner method clearAndFillQueryMaps.

/**
 * Fills the hash maps used for queries.
 *
 * @throws DBException
 * @throws InvocationException
 */
private void clearAndFillQueryMaps() throws InvocationException, DBException {
    DeploymentLock.lock();
    this.vertices.clear();
    this.geolocations.clear();
    this.stereotypes.clear();
    this.parameterprivacy.clear();
    this.returntypeprivacy.clear();
    this.interfaces.clear();
    for (final GeoLocation location : this.privacyRootElement.getResourceContainerLocations()) {
        this.geolocations.put(this.resourceEnvironmentResource.resolve(location.getResourceContainer()).getId(), location);
    }
    for (final EncapsulatedDataSource stereotype : this.privacyRootElement.getEncapsulatedDataSources()) {
        if (stereotype != null) {
            final BasicComponent resolvedComponent = this.repositoryResource.resolve(stereotype.getComponent());
            this.stereotypes.put(resolvedComponent.getId(), stereotype);
        } else {
            this.logger.debug("missing {}", stereotype);
        }
    }
    for (final IDataProtectionAnnotation dataProectionAnnocation : this.privacyRootElement.getDataProectionLevels()) {
        if (dataProectionAnnocation instanceof ParameterDataProtection) {
            final ParameterDataProtection parameterDataProtection = (ParameterDataProtection) dataProectionAnnocation;
            final Parameter parameter = this.repositoryResource.resolve(parameterDataProtection.getParameter());
            this.parameterprivacy.put(parameter.getParameterName(), parameterDataProtection);
        }
        if (dataProectionAnnocation instanceof ReturnTypeDataProtection) {
            final ReturnTypeDataProtection returnTypeDataProection = (ReturnTypeDataProtection) dataProectionAnnocation;
            this.returntypeprivacy.put(this.repositoryResource.resolve(returnTypeDataProection.getOperationSignature()).getId(), returnTypeDataProection);
        }
    }
    for (final Interface inf : this.repositoryRootElement.getInterfaces__Repository()) {
        if (inf instanceof OperationInterface) {
            this.interfaces.put(inf.getEntityName(), (OperationInterface) inf);
        }
    }
    DeploymentLock.unlock();
}
Also used : ReturnTypeDataProtection(org.iobserve.model.privacy.ReturnTypeDataProtection) ParameterDataProtection(org.iobserve.model.privacy.ParameterDataProtection) BasicComponent(org.palladiosimulator.pcm.repository.BasicComponent) Parameter(org.palladiosimulator.pcm.repository.Parameter) GeoLocation(org.iobserve.model.privacy.GeoLocation) EncapsulatedDataSource(org.iobserve.model.privacy.EncapsulatedDataSource) IDataProtectionAnnotation(org.iobserve.model.privacy.IDataProtectionAnnotation) OperationInterface(org.palladiosimulator.pcm.repository.OperationInterface) Interface(org.palladiosimulator.pcm.repository.Interface) OperationInterface(org.palladiosimulator.pcm.repository.OperationInterface)

Aggregations

GeoLocation (org.iobserve.model.privacy.GeoLocation)5 BasicComponent (org.palladiosimulator.pcm.repository.BasicComponent)2 ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)2 DataProtectionModel (org.iobserve.model.privacy.DataProtectionModel)1 EncapsulatedDataSource (org.iobserve.model.privacy.EncapsulatedDataSource)1 IDataProtectionAnnotation (org.iobserve.model.privacy.IDataProtectionAnnotation)1 ParameterDataProtection (org.iobserve.model.privacy.ParameterDataProtection)1 ReturnTypeDataProtection (org.iobserve.model.privacy.ReturnTypeDataProtection)1 Vertex (org.iobserve.service.privacy.violation.transformation.analysisgraph.Vertex)1 AllocationContext (org.palladiosimulator.pcm.allocation.AllocationContext)1 AssemblyContext (org.palladiosimulator.pcm.core.composition.AssemblyContext)1 Interface (org.palladiosimulator.pcm.repository.Interface)1 OperationInterface (org.palladiosimulator.pcm.repository.OperationInterface)1 Parameter (org.palladiosimulator.pcm.repository.Parameter)1 RepositoryComponent (org.palladiosimulator.pcm.repository.RepositoryComponent)1