| /** |
| * ******************************************************************************* |
| * Copyright (c) 2020 Robert Bosch GmbH. |
| * |
| * This program and the accompanying materials are made |
| * available under the terms of the Eclipse Public License 2.0 |
| * which is available at https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Robert Bosch GmbH - initial API and implementation |
| * ******************************************************************************* |
| */ |
| |
| package org.eclipse.app4mc.slg.commons.m2t.transformers |
| |
| import com.google.inject.Inject |
| import org.eclipse.app4mc.amalthea.model.Amalthea |
| import org.eclipse.app4mc.slg.config.ConfigModel |
| import org.eclipse.app4mc.slg.config.util.ConfigurationFileLoader |
| import org.eclipse.app4mc.slg.commons.m2t.CustomObjectsStore |
| import org.eclipse.emf.ecore.resource.ResourceSet |
| import org.slf4j.Logger |
| import org.slf4j.LoggerFactory |
| import org.eclipse.app4mc.slg.commons.m2t.SLGBaseTransformer |
| |
| class AmaltheaModel2TextTransformer extends SLGBaseTransformer { |
| |
| static final Logger LOG = LoggerFactory.getLogger(typeof(AmaltheaModel2TextTransformer)) |
| |
| @Inject CustomObjectsStore customObjsStore |
| |
| public ConfigModel configModel; |
| |
| def void transform(Amalthea model, String outputPath) { |
| } |
| |
| def m2tTransformation(ResourceSet inputResourceSet) { |
| |
| for (resource : inputResourceSet.resources) { |
| for (model : resource.contents) { |
| // check javadoc : https://www.eclipse.org/xtend/documentation/204_activeannotations.html#active-annotations-expression |
| LOG.info("Processing file : " + resource.URI) |
| |
| val String outputFolder = getProperty("m2t_output_folder"); |
| |
| var String configurationFilePath = getProperty("configurationFile"); |
| |
| if (configurationFilePath !== null) { |
| |
| configModel = new ConfigurationFileLoader().loadConfigurationFile(configurationFilePath) |
| |
| // Z.B. println(ConfigurationModelUtil.getkeyWordValue(configModel,"hppHeader")) |
| // Injected ConfigurationModel into CustomObjsStore so that it can be used across several transformer classes |
| customObjsStore.injectMembers(ConfigModel, configModel) |
| |
| } else { |
| LOG.error("configuration file path is not supplied as a command line argument") |
| } |
| if (configModel === null) { |
| LOG.error( |
| "As no configuration model is available , unable to proceed with the load generator application !!") |
| } |
| |
| if (model instanceof Amalthea) { |
| transform(model as Amalthea, outputFolder) |
| } |
| |
| // TODO: save the file here |
| LOG.info("Script file generated at : {}", outputFolder) |
| } |
| } |
| |
| } |
| } |