use of org.iobserve.model.ModelImporter 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.ModelImporter in project iobserve-analysis by research-iobserve.
the class ModelGraphCreator method execute.
@Override
protected void execute(final AdaptationData adaptationData) throws Exception {
final HostComponentAllocationGraphFactory runtimeFactory = new HostComponentAllocationGraphFactory();
final HostComponentAllocationGraphFactory redeploymentFactory = new HostComponentAllocationGraphFactory();
final File runtimeModelDir = adaptationData.getRuntimeModelDir();
final File redeploymentModelDir = adaptationData.getReDeploymentModelDir();
final HostComponentAllocationGraph runtimeModelGraph = runtimeFactory.buildGraph(new ModelImporter(runtimeModelDir), ModelGraphRevision.RUNTIME);
final HostComponentAllocationGraph redeploymentModelGraph = redeploymentFactory.buildGraph(new ModelImporter(redeploymentModelDir), ModelGraphRevision.REDEPLOYMENT);
adaptationData.setRuntimeGraph(runtimeModelGraph);
adaptationData.setReDeploymentGraph(redeploymentModelGraph);
this.getOutputPort().send(adaptationData);
}
use of org.iobserve.model.ModelImporter in project iobserve-analysis by research-iobserve.
the class ModelComparer method execute.
@Override
protected void execute(final URI element) throws Exception {
boolean equalGraphs = false;
if (this.baseAdaptationData != null) {
// TODO finish
final ModelImporter modelProviders = new ModelImporter(new File(element.toFileString()));
final HostComponentAllocationGraphFactory graphFactory = new HostComponentAllocationGraphFactory();
final HostComponentAllocationGraph runtimeGraph = graphFactory.buildGraph(modelProviders, ModelGraphRevision.RUNTIME);
if (runtimeGraph.equals(this.baseAdaptationData.getReDeploymentGraph()) && this.baseAdaptationData.getReDeploymentGraph().equals(runtimeGraph)) {
equalGraphs = true;
SystemEvaluation.disableEvaluation();
}
}
this.outputPort.send(Boolean.valueOf(equalGraphs));
}
use of org.iobserve.model.ModelImporter in project iobserve-analysis by research-iobserve.
the class ComposedActionFactoryInitialization method execute.
@Override
protected void execute(final AdaptationData adaptationData) throws Exception {
// Set up ActionFactory because the rule engine will invoke it in ComposedActionComputation
if (!this.isTestRun) {
ActionFactory.setRuntimeModels(new ModelImporter(adaptationData.getRuntimeModelDir()));
ActionFactory.setRedeploymentModels(new ModelImporter(adaptationData.getReDeploymentModelDir()));
}
this.outputPort.send(adaptationData);
}
use of org.iobserve.model.ModelImporter in project iobserve-analysis by research-iobserve.
the class ModelProcessing method initModelTransformation.
private void initModelTransformation(final File originalModelDirectory) throws IOException, InitializationException {
final ModelImporter originalModelHandler = new ModelImporter(originalModelDirectory);
this.processedModelDirectory = new File(originalModelDirectory, ModelProcessing.PROCESSED_MODEL_FOLDER);
FileUtils.copyDirectory(originalModelDirectory, this.processedModelDirectory);
this.processedModelHandler = new ModelImporter(this.processedModelDirectory);
this.allocationModel = this.processedModelHandler.getAllocationModel();
this.cloudProfileModel = this.processedModelHandler.getCloudProfileModel();
this.costModel = this.processedModelHandler.getCostModel();
this.decisionModel = this.processedModelHandler.getDesignDecisionModel();
this.resourceEnvironmentModel = this.processedModelHandler.getResourceEnvironmentModel();
this.systemModel = this.processedModelHandler.getSystemModel();
if (this.decisionModel == null) {
this.decisionModel = DesignDecisionModelFactory.createDecisionSpace("processedDecision");
}
this.originalAllocationGroups = new AllocationGroupsContainer(originalModelHandler.getAllocationModel());
}
Aggregations