Search in sources :

Example 1 with IModelProvider

use of org.iobserve.model.provider.neo4j.IModelProvider in project iobserve-analysis by research-iobserve.

the class AnalysisMain method createConfiguration.

@Override
protected AnalysisConfiguration createConfiguration(final Configuration configuration) throws ConfigurationException {
    /**
     * Configure model handling.
     */
    // old model providers without neo4j
    final PCMModelHandler modelFileHandler = new PCMModelHandler(this.modelInitDirectory);
    final ICorrespondence correspondenceModel = modelFileHandler.getCorrespondenceModel();
    /**
     * initialize neo4j graphs.
     */
    final GraphLoader graphLoader = new GraphLoader(this.modelDatabaseDirectory);
    Graph repositoryModelGraph = graphLoader.initializeRepositoryModelGraph(modelFileHandler.getRepositoryModel());
    Graph resourceEnvironmentGraph = graphLoader.initializeResourceEnvironmentModelGraph(modelFileHandler.getResourceEnvironmentModel());
    Graph allocationModelGraph = graphLoader.initializeAllocationModelGraph(modelFileHandler.getAllocationModel());
    Graph systemModelGraph = graphLoader.initializeSystemModelGraph(modelFileHandler.getSystemModel());
    Graph usageModelGraph = graphLoader.initializeUsageModelGraph(modelFileHandler.getUsageModel());
    /**
     * load neo4j graphs.
     */
    repositoryModelGraph = graphLoader.createRepositoryModelGraph();
    resourceEnvironmentGraph = graphLoader.createResourceEnvironmentModelGraph();
    allocationModelGraph = graphLoader.createAllocationModelGraph();
    systemModelGraph = graphLoader.createSystemModelGraph();
    usageModelGraph = graphLoader.createUsageModelGraph();
    /**
     * new graphModelProvider.
     */
    final IModelProvider<Repository> repositoryModelProvider = new ModelProvider<>(repositoryModelGraph);
    final IModelProvider<ResourceEnvironment> resourceEnvironmentModelProvider = new ModelProvider<>(resourceEnvironmentGraph);
    final IModelProvider<Allocation> allocationModelProvider = new ModelProvider<>(allocationModelGraph);
    final IModelProvider<org.palladiosimulator.pcm.system.System> systemModelProvider = new ModelProvider<>(systemModelGraph);
    final IModelProvider<UsageModel> usageModelProvider = new ModelProvider<>(usageModelGraph);
    // get systemId
    final org.palladiosimulator.pcm.system.System systemModel = systemModelProvider.readOnlyRootComponent(org.palladiosimulator.pcm.system.System.class);
    final String systemId = systemModel.getId();
    try {
        /**
         * URLs for sending updates to the deployment visualization.
         */
        // TODO this should be moved to the visualization sinks
        final String[] sinks = configuration.getStringArrayProperty(ConfigurationKeys.CONTAINER_MANAGEMENT_SINK, ",");
        if (sinks.length > 0) {
            final InitializeDeploymentVisualization deploymentVisualization = new InitializeDeploymentVisualization(this.containerManagementVisualizationBaseUrl, systemId, allocationModelProvider, systemModelProvider, resourceEnvironmentModelProvider);
            deploymentVisualization.initialize();
        }
        return new AnalysisConfiguration(configuration, repositoryModelProvider, resourceEnvironmentModelProvider, allocationModelProvider, systemModelProvider, usageModelProvider, correspondenceModel);
    } catch (final MalformedURLException e) {
        AbstractServiceMain.LOGGER.debug("URL construction for deployment visualization failed.", e);
        return null;
    } catch (final IOException e) {
        AbstractServiceMain.LOGGER.debug("Deployment visualization could not connect to visualization service.", e);
        return null;
    }
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) MalformedURLException(java.net.MalformedURLException) IModelProvider(org.iobserve.model.provider.neo4j.IModelProvider) ModelProvider(org.iobserve.model.provider.neo4j.ModelProvider) Allocation(org.palladiosimulator.pcm.allocation.Allocation) ICorrespondence(org.iobserve.model.correspondence.ICorrespondence) AnalysisConfiguration(org.iobserve.analysis.configurations.AnalysisConfiguration) PCMModelHandler(org.iobserve.model.PCMModelHandler) IOException(java.io.IOException) Repository(org.palladiosimulator.pcm.repository.Repository) Graph(org.iobserve.model.provider.neo4j.Graph) GraphLoader(org.iobserve.model.provider.neo4j.GraphLoader) UsageModel(org.palladiosimulator.pcm.usagemodel.UsageModel)

Aggregations

IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 AnalysisConfiguration (org.iobserve.analysis.configurations.AnalysisConfiguration)1 PCMModelHandler (org.iobserve.model.PCMModelHandler)1 ICorrespondence (org.iobserve.model.correspondence.ICorrespondence)1 Graph (org.iobserve.model.provider.neo4j.Graph)1 GraphLoader (org.iobserve.model.provider.neo4j.GraphLoader)1 IModelProvider (org.iobserve.model.provider.neo4j.IModelProvider)1 ModelProvider (org.iobserve.model.provider.neo4j.ModelProvider)1 Allocation (org.palladiosimulator.pcm.allocation.Allocation)1 Repository (org.palladiosimulator.pcm.repository.Repository)1 ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)1 UsageModel (org.palladiosimulator.pcm.usagemodel.UsageModel)1