blob: fef9438dba7240889d994994ca9654456beaa39e [file] [log] [blame]
/**
********************************************************************************
* Copyright (c) 2018, 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 configuration;
import java.util.Properties;
import org.eclipse.app4mc.amalthea.model.AmaltheaFactory;
import org.eclipse.app4mc.transformation.extensions.ICustomObjectsStore;
import org.eclipse.app4mc.transformation.extensions.executiontype.IModelToTextConfig;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
import model.loader.AmaltheaMultiFileLoader;
@Component(
property= {
"transformation=Amalthea2Text"
},
service=IModelToTextConfig.class
)
public class M2TTransformationConfig implements IModelToTextConfig {
@Reference
private ICustomObjectsStore customObjsStore;
@Reference
private AmaltheaMultiFileLoader amaltheaMultiFileLoader;
@Override
public ResourceSet getInputResourceSet() {
Properties properties = customObjsStore.getInstance(Properties.class);
Logger logger = customObjsStore.getInstance(Logger.class);
if (properties != null) {
String folderPath = properties.getProperty("input_models_folder");
if (folderPath != null) {
ResourceSet resourceSet = amaltheaMultiFileLoader.loadMultipleFiles(folderPath);
if(resourceSet.getResources().size()==0) {
logger.error("no Amalthea model files are loaded. Verify if the model version is : " + AmaltheaFactory.eINSTANCE.createAmalthea().getVersion());
}
return resourceSet;
} else {
logger.error("input_models_folder parameter not set",
new NullPointerException("input_models_folder property not set"));
}
} else {
logger.error("Parameters object not set ", new NullPointerException("Parameter object is null"));
}
return null;
}
}