Search in sources :

Example 1 with DataProtectionModel

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

the class AnalysisMain method createTeetimeConfiguration.

@Override
protected AnalysisConfiguration createTeetimeConfiguration() throws ConfigurationException {
    /**
     * Configure model handling.
     */
    if (this.parameterConfiguration.isPcmFeature()) {
        try {
            final ModelImporter modelHandler = new ModelImporter(this.parameterConfiguration.getModelInitDirectory());
            /**
             * initialize neo4j graphs.
             */
            final Neo4JModelResource<CorrespondenceModel> correspondenceModelResource = new Neo4JModelResource<>(CorrespondencePackage.eINSTANCE, new File(this.parameterConfiguration.getModelDatabaseDirectory(), "correspondence"));
            correspondenceModelResource.storeModelPartition(modelHandler.getCorrespondenceModel());
            final Neo4JModelResource<Repository> repositoryModelResource = new Neo4JModelResource<>(RepositoryPackage.eINSTANCE, new File(this.parameterConfiguration.getModelDatabaseDirectory(), "repository"));
            repositoryModelResource.storeModelPartition(modelHandler.getRepositoryModel());
            final Neo4JModelResource<ResourceEnvironment> resourceEnvironmentModelResource = new Neo4JModelResource<>(ResourceenvironmentPackage.eINSTANCE, // add
            new File(this.parameterConfiguration.getModelDatabaseDirectory(), "resourceenvironment"));
            resourceEnvironmentModelResource.storeModelPartition(modelHandler.getResourceEnvironmentModel());
            final Neo4JModelResource<System> systemModelResource = new Neo4JModelResource<>(SystemPackage.eINSTANCE, new File(this.parameterConfiguration.getModelDatabaseDirectory(), "system"));
            systemModelResource.storeModelPartition(modelHandler.getSystemModel());
            final Neo4JModelResource<Allocation> allocationModelResource = new Neo4JModelResource<>(AllocationPackage.eINSTANCE, new File(this.parameterConfiguration.getModelDatabaseDirectory(), "allocation"));
            allocationModelResource.storeModelPartition(modelHandler.getAllocationModel());
            final Neo4JModelResource<UsageModel> usageModelResource = new Neo4JModelResource<>(UsagemodelPackage.eINSTANCE, new File(this.parameterConfiguration.getModelDatabaseDirectory(), "usageModel"));
            usageModelResource.storeModelPartition(modelHandler.getUsageModel());
            final Neo4JModelResource<DataProtectionModel> privacyModelResource = new Neo4JModelResource<>(PrivacyPackage.eINSTANCE, new File(this.parameterConfiguration.getModelDatabaseDirectory(), "privacy"));
            privacyModelResource.storeModelPartition(modelHandler.getPrivacyModel());
            // get systemId
            final System systemModel = systemModelResource.getModelRootNode(System.class, SystemPackage.Literals.SYSTEM);
            this.kiekerConfiguration.setProperty(ConfigurationKeys.SYSTEM_ID, systemModel.getId());
            return new AnalysisConfiguration(this.kiekerConfiguration, repositoryModelResource, resourceEnvironmentModelResource, systemModelResource, allocationModelResource, usageModelResource, correspondenceModelResource);
        } catch (final IOException e) {
            // TODO should be replaced by logger
            // NOPMD
            java.lang.System.err.println("Cannot load all models " + e.getLocalizedMessage());
            // required
            return null;
        } catch (final DBException e) {
            // TODO should be replaced by logger
            // NOPMD
            java.lang.System.err.println("Cannot store all models in DB " + e.getLocalizedMessage());
            // required
            return null;
        }
    } else {
        return new AnalysisConfiguration(this.kiekerConfiguration);
    }
}
Also used : Neo4JModelResource(org.iobserve.model.persistence.neo4j.Neo4JModelResource) DBException(org.iobserve.model.persistence.DBException) ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) DataProtectionModel(org.iobserve.model.privacy.DataProtectionModel) CorrespondenceModel(org.iobserve.model.correspondence.CorrespondenceModel) IOException(java.io.IOException) System(org.palladiosimulator.pcm.system.System) ModelImporter(org.iobserve.model.ModelImporter) Repository(org.palladiosimulator.pcm.repository.Repository) Allocation(org.palladiosimulator.pcm.allocation.Allocation) UsageModel(org.palladiosimulator.pcm.usagemodel.UsageModel) File(java.io.File)

Example 2 with DataProtectionModel

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

the class CreatePrivacyMain method main.

/**
 * @param args
 *            arguments
 */
public static void main(final String[] args) {
    CreatePrivacyMain.createIsoCodes();
    CreatePrivacyMain.createPrivacyAnnotations();
    final String pcmDirectory = "/home/reiner/Projects/iObserve/experiments/distributed-jpetstore-experiment/pcm/JPetStore";
    try {
        final ModelImporter modelHandler = new ModelImporter(new File(pcmDirectory));
        final Repository repository = modelHandler.getRepositoryModel();
        final ResourceEnvironment environment = modelHandler.getResourceEnvironmentModel();
        final DataProtectionModel privacyModel = PrivacyFactory.eINSTANCE.createDataProtectionModel();
        CreatePrivacyMain.addGeoLocations(privacyModel, environment);
        CreatePrivacyMain.addPrivacyAnnotations(privacyModel, repository);
        final URI outputURI = URI.createFileURI("/home/reiner/privacyTestModel.privacy");
        CreatePrivacyMain.save(privacyModel, outputURI);
    } catch (final IOException e) {
        CreatePrivacyMain.LOGGER.error("Canot load all models {}", e.getLocalizedMessage());
    }
}
Also used : Repository(org.palladiosimulator.pcm.repository.Repository) ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) DataProtectionModel(org.iobserve.model.privacy.DataProtectionModel) IOException(java.io.IOException) File(java.io.File) URI(org.eclipse.emf.common.util.URI)

Example 3 with DataProtectionModel

use of org.iobserve.model.privacy.DataProtectionModel 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 DataProtectionModel

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

the class PrivacyViolationDetectionServiceMain method createTeetimeConfiguration.

@Override
protected PipelineConfiguration createTeetimeConfiguration() throws ConfigurationException {
    /**
     * load models.
     */
    try {
        final ModelImporter modelHandler = new ModelImporter(this.parameterConfiguration.getModelInitDirectory());
        /**
         * initialize database.
         */
        final IModelResource<CorrespondenceModel> correspondenceModelResource = this.loadResourceAndInitDB(CorrespondencePackage.eINSTANCE, modelHandler.getCorrespondenceModel());
        final IModelResource<Repository> repositoryModelResource = this.loadResourceAndInitDB(RepositoryPackage.eINSTANCE, modelHandler.getRepositoryModel());
        final IModelResource<ResourceEnvironment> resourceEnvironmentModelResource = this.loadResourceAndInitDB(ResourceenvironmentPackage.eINSTANCE, modelHandler.getResourceEnvironmentModel());
        final IModelResource<System> systemModelResource = this.loadResourceAndInitDB(SystemPackage.eINSTANCE, modelHandler.getSystemModel());
        final IModelResource<Allocation> allocationModelResource = this.loadResourceAndInitDB(AllocationPackage.eINSTANCE, modelHandler.getAllocationModel());
        final IModelResource<DataProtectionModel> privacyModelResource = this.loadResourceAndInitDB(PrivacyPackage.eINSTANCE, modelHandler.getPrivacyModel());
        return new PipelineConfiguration(this.kiekerConfiguration, correspondenceModelResource, repositoryModelResource, resourceEnvironmentModelResource, systemModelResource, allocationModelResource, privacyModelResource, this.parameterConfiguration.getWarningFile(), this.parameterConfiguration.getAlarmsFile(), this.parameterConfiguration.getModelDumpDirectory());
    } catch (final DBException | IOException e) {
        throw new ConfigurationException(e);
    }
}
Also used : DBException(org.iobserve.model.persistence.DBException) ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) DataProtectionModel(org.iobserve.model.privacy.DataProtectionModel) CorrespondenceModel(org.iobserve.model.correspondence.CorrespondenceModel) IOException(java.io.IOException) System(org.palladiosimulator.pcm.system.System) ModelImporter(org.iobserve.model.ModelImporter) Repository(org.palladiosimulator.pcm.repository.Repository) Allocation(org.palladiosimulator.pcm.allocation.Allocation) ConfigurationException(kieker.common.exception.ConfigurationException)

Aggregations

DataProtectionModel (org.iobserve.model.privacy.DataProtectionModel)4 IOException (java.io.IOException)3 Repository (org.palladiosimulator.pcm.repository.Repository)3 ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)3 File (java.io.File)2 ModelImporter (org.iobserve.model.ModelImporter)2 CorrespondenceModel (org.iobserve.model.correspondence.CorrespondenceModel)2 DBException (org.iobserve.model.persistence.DBException)2 Allocation (org.palladiosimulator.pcm.allocation.Allocation)2 System (org.palladiosimulator.pcm.system.System)2 ConfigurationException (kieker.common.exception.ConfigurationException)1 URI (org.eclipse.emf.common.util.URI)1 Neo4JModelResource (org.iobserve.model.persistence.neo4j.Neo4JModelResource)1 GeoLocation (org.iobserve.model.privacy.GeoLocation)1 UsageModel (org.palladiosimulator.pcm.usagemodel.UsageModel)1