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