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