当前位置: 首页>>代码示例>>Java>>正文


Java EMFModel.getResource方法代码示例

本文整理汇总了Java中org.eclipse.m2m.atl.core.emf.EMFModel.getResource方法的典型用法代码示例。如果您正苦于以下问题:Java EMFModel.getResource方法的具体用法?Java EMFModel.getResource怎么用?Java EMFModel.getResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.m2m.atl.core.emf.EMFModel的用法示例。


在下文中一共展示了EMFModel.getResource方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: typing

import org.eclipse.m2m.atl.core.emf.EMFModel; //导入方法依赖的package包/类
public void typing(String atlTransformationFile, Object[] metamodels, String[] names) throws Exception {
	this.atlTransformationFile = atlTransformationFile;

	long diffs = 0;

	AtlParser atlParser = new AtlParser();
	ModelFactory modelFactory = new EMFModelFactory();
	IReferenceModel atlMetamodel = modelFactory
			.getBuiltInResource("ATL.ecore");
	EMFModel atlModel = (EMFModel) modelFactory.newModel(atlMetamodel);

	atlParser.inject(atlModel, atlTransformationFile);

	this.mm = loadMetamodels(metamodels, names);
	this.atlTransformation = new ATLModel(atlModel.getResource(), atlTransformationFile);
	this.analyser = new Analyser(mm, atlTransformation);

	long initTime = System.currentTimeMillis();
	analyser.perform();
	analysisData = new AnalysisResult(analyser);
	
	long finishTime = System.currentTimeMillis();
	diffs += (finishTime - initTime);
	// }
	System.out.println("Time: " + (diffs / 1000.0));
}
 
开发者ID:anatlyzer,项目名称:anatlyzer,代码行数:27,代码来源:BaseTest.java

示例2: loadAtlTransformation

import org.eclipse.m2m.atl.core.emf.EMFModel; //导入方法依赖的package包/类
private Resource loadAtlTransformation() {
	ModelFactory modelFactory = new EMFModelFactory();

	IReferenceModel atlMetamodel;
	try {
		atlMetamodel = modelFactory.getBuiltInResource("ATL.ecore");
		EMFModel loadedAtlModel = (EMFModel) modelFactory
				.newModel(atlMetamodel);

		AtlParser atlParser = new AtlParser();

		String srcFile = original.getTemplate();
		String anURI   = filePathResolver.resolveTransformation(component, srcFile);
				
		
		atlParser.inject(loadedAtlModel, anURI); 
				//filePathResolver.resolve(srcFile));

		loadedAtlModel.setIsTarget(true);
		return loadedAtlModel.getResource();
	} catch ( ATLCoreException e ) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:jesusc,项目名称:bento,代码行数:25,代码来源:AtlMemoryTemplate.java

示例3: generateMutants

import org.eclipse.m2m.atl.core.emf.EMFModel; //导入方法依赖的package包/类
@Override
public void generateMutants(EMFModel atlModel, MetaModel inputMM, MetaModel outputMM, String outputFolder) {
	// initialize list of helpers in the transformation
	helpers_by_return  = new Hashtable<String, List<String>>();
	helpers_by_context = new Hashtable<String, List<String>>();
	
	// obtain helper definitions in transformation (both attribute and operation helpers)
	ATLModel     wrapper = new ATLModel(atlModel.getResource());
	List<Helper> helpers = (List<Helper>)wrapper.allObjectsOf(Helper.class);
	for (Helper helper : helpers) {
		if (helper.getDefinition()!=null &&
			helper.getDefinition().getContext_()!=null &&
			helper.getDefinition().getContext_().getContext_()!=null &&
			(helper.getDefinition().getFeature() instanceof Operation || helper.getDefinition().getFeature() instanceof Attribute)) {
			String helper_context = helper.getDefinition().getContext_().getContext_().getName();
			String helper_return  = helper.getDefinition().getFeature() instanceof Operation? 
					                toString(((Operation)helper.getDefinition().getFeature()).getReturnType()):
			                        toString(((Attribute)helper.getDefinition().getFeature()).getType());
			String helper_name    = helper.getDefinition().getFeature() instanceof Operation?
					                ((Operation)helper.getDefinition().getFeature()).getName():
			                        ((Attribute)helper.getDefinition().getFeature()).getName();
			if (!helpers_by_return. containsKey(helper_return )) helpers_by_return. put(helper_return,  new ArrayList<String>());
			if (!helpers_by_context.containsKey(helper_context)) helpers_by_context.put(helper_context, new ArrayList<String>());
			helpers_by_return. get(helper_return ).add(helper_name);
			helpers_by_context.get(helper_context).add(helper_name);
		}
	}
	
	// generate mutants
	this.genericAttributeModification(atlModel, outputFolder, OperationCallExp.class, "operationName", outputMM, true);
	this.genericAttributeModification(atlModel, outputFolder, NavigationOrAttributeCallExp.class, "name", outputMM, true);
}
 
开发者ID:anatlyzer,项目名称:anatlyzer,代码行数:33,代码来源:HelperOperationModificationMutator.java

示例4: exec

import org.eclipse.m2m.atl.core.emf.EMFModel; //导入方法依赖的package包/类
public TranslationResult exec(String oclExpr) {
	String aQuery = "query dummy = \n" + oclExpr + ";";

	EMFModel libModel = AtlEngineUtils.loadATLText(aQuery);
	if ( libModel.getResource().getErrors().size() > 0 ) {
		System.out.println(libModel.getResource().getErrors());
		return TranslationResult.error(libModel.getResource().getErrors().stream().map(o -> o.toString()).collect(Collectors.toList()));
	}
	ATLModel model = new ATLModel(libModel.getResource());
	Query q = (Query) model.getRoot();
	return new TranslationResult(q.getBody());
}
 
开发者ID:anatlyzer,项目名称:anatlyzer,代码行数:13,代码来源:OCLinATL.java

示例5: load

import org.eclipse.m2m.atl.core.emf.EMFModel; //导入方法依赖的package包/类
public static Resource load(String fname) throws ATLCoreException {
	AtlParser atlParser = new AtlParser();
	ModelFactory modelFactory = new EMFModelFactory();
	IReferenceModel atlMetamodel = modelFactory.getBuiltInResource("ATL.ecore");
	EMFModel atlDynModel = (EMFModel) modelFactory.newModel(atlMetamodel);
	atlParser.inject(atlDynModel, fname);
	
	
	Resource originalTrafo = atlDynModel.getResource();
	return originalTrafo;
}
 
开发者ID:anatlyzer,项目名称:anatlyzer,代码行数:12,代码来源:AtlLoader.java

示例6: exec

import org.eclipse.m2m.atl.core.emf.EMFModel; //导入方法依赖的package包/类
public AnalyserData exec(InputStream stream) throws IOException, CoreException, CannotLoadMetamodel, PreconditionParseError  {
	EMFModel atlEMFModel = AtlEngineUtils.loadATLFile(null, stream, false);
	if ( atlEMFModel == null )
		return null;
			
	ATLModel  atlModel = new ATLModel(atlEMFModel.getResource(), null);
	return exec(null, atlModel, false);
}
 
开发者ID:anatlyzer,项目名称:anatlyzer,代码行数:9,代码来源:AnalyserExecutor.java

示例7: fillMetamodelTable

import org.eclipse.m2m.atl.core.emf.EMFModel; //导入方法依赖的package包/类
private void fillMetamodelTable(IFile file) {
	if ( ! atlTransformation.getMetamodels().isEmpty() ) 
		return;
		
	EMFModel model = AtlEngineUtils.loadATLFile(file);
	ATLModel atlModel = new ATLModel(model.getResource());				
	if ( model != null ) {			
		for(ModelInfo m : ATLUtils.getModelInfo(atlModel)) {
			Metamodel mm = RevengFactory.eINSTANCE.createMetamodel();
			mm.setName(m.getMetamodelName());
			mm.setModelName(m.getModelName());
			
			if ( m.hasMetamodelInfo() ) {
				mm.setPath(m.getURIorPath());
			}
			
			if ( m.isInput() ) {
				mm.setBecomeConcept(true);
			}
			
			this.atlTransformation.getMetamodels().add(mm);
		}
		markAsDirty();
		listMetamodels.refresh();				
	}		

}
 
开发者ID:jesusc,项目名称:bento,代码行数:28,代码来源:TransformationConfigurationPage.java

示例8: generateMutants

import org.eclipse.m2m.atl.core.emf.EMFModel; //导入方法依赖的package包/类
@Override
public void generateMutants(EMFModel atlModel, MetaModel inputMM, MetaModel outputMM, String outputFolder) {
	
	ATLModel          wrapper   = new ATLModel(atlModel.getResource());
	List<VariableExp> variables = (List<VariableExp>)wrapper.allObjectsOf(VariableExp.class);
	
	// we will add a comment to the module, documenting the mutation 
	Module module = wrapper.getModule();
	EDataTypeEList<String> comments = null;
	if (module!=null) {
		EStructuralFeature f = wrapper.source(module).eClass().getEStructuralFeature("commentsBefore");	
		comments = (EDataTypeEList<String>)wrapper.source(module).eGet(f);
	}
	
	// navigate navigation expressions starting from each variable
	for (VariableExp variable : variables) {
		
		EObject navigationExpression = variable.eContainer();
		while  (navigationExpression != null) {

			if (navigationExpression instanceof NavigationOrAttributeCallExp) {

				EStructuralFeature featureDefinition = wrapper.source(navigationExpression).eClass().getEStructuralFeature("name");

				// obtain list of replacements
				String type       = getType(navigationExpression, variable, inputMM, outputMM); 
				String navigation = ((NavigationOrAttributeCallExp)navigationExpression).getName();
				List<Object> replacements = this.featureReplacements(type, navigation, inputMM);

				for (Object replacement : replacements) {
					wrapper.source(navigationExpression).eSet(featureDefinition, replacement);

					// mutation: documentation
					if (comments!=null) comments.add("\n-- MUTATION \"" + this.getDescription() + "\" from " + toString(navigationExpression, variable) + navigation + " to " + toString(navigationExpression, variable) + replacement  + " (line " + ((LocatedElement)navigationExpression).getLocation() + " of original transformation)\n");

					// save mutant
					this.save(atlModel, outputFolder);

					// remove comment
					if (comments!=null) comments.remove(comments.size()-1);
				}

				// restore original value
				wrapper.source(navigationExpression).eSet(featureDefinition, navigation);					
			}
			
			// continue navigation in current expression (e.g. object.feature1.feature2)
			if (navigationExpression instanceof NavigationOrAttributeCallExp && navigationExpression.eContainer() instanceof NavigationOrAttributeCallExp) {
				navigationExpression = navigationExpression.eContainer();
			}
			else navigationExpression = null;
		}
	}
}
 
开发者ID:anatlyzer,项目名称:anatlyzer,代码行数:55,代码来源:NavigationModificationMutator.java

示例9: genericAttributeModification

import org.eclipse.m2m.atl.core.emf.EMFModel; //导入方法依赖的package包/类
/**
 * Generic modification. The parameter 'exactContainerType' allows configuring whether the type of  
 * the class to modify must be exactly the one received, or if the subtypes should be also considered.  
 * @param atlModel
 * @param outputFolder
 * @param ToModifyClass class of objects to modify (example Binding)
 * @param featureName feature to modify (example propertyName)
 * @param metamodel metamodel containing the candidate types for the modification   
 * @param exactToModifyType false to consider also subtypes of the class ToModify, true to discard subtypes of the class ToModify  
 */ 
protected <ToModify extends LocatedElement> 
void genericAttributeModification(EMFModel atlModel, String outputFolder, Class<ToModify> ToModifyClass, String feature, MetaModel metamodel, boolean exactToModifyType) {

	ATLModel       wrapper    = new ATLModel(atlModel.getResource());
	List<ToModify> modifiable = (List<ToModify>)wrapper.allObjectsOf(ToModifyClass);

	// we will add a comment to the module, documenting the mutation 
	Module module = wrapper.getModule();
	EDataTypeEList<String> comments = null;
	if (module!=null) {
		EStructuralFeature f = wrapper.source(module).eClass().getEStructuralFeature("commentsBefore");	
		comments = (EDataTypeEList<String>)wrapper.source(module).eGet(f);
	}
	
	// filter subtypes (only if parameter exactToModifyType is true)
	if (exactToModifyType) filterSubtypes(modifiable, ToModifyClass);
	
	for (ToModify object2modify : modifiable) {
		EStructuralFeature featureDefinition = wrapper.source(object2modify).eClass().getEStructuralFeature(feature);
		
		if (featureDefinition!=null && featureDefinition.getUpperBound() == 1) {
			EObject object2modify_src = wrapper.source(object2modify);			
			Object oldFeatureValue = object2modify_src.eGet(featureDefinition); 

			List<Object> replacements = this.replacements(object2modify, oldFeatureValue.toString(), metamodel);
			for (Object replacement : replacements) {
				if (replacement!=null) {	
					wrapper.source(object2modify).eSet(featureDefinition, replacement);
				
					// mutation: documentation
					if (comments!=null) comments.add("\n-- MUTATION \"" + this.getDescription() + "\" from " + oldFeatureValue.toString() + " to " + replacement  + " (line " + object2modify.getLocation() + " of original transformation)\n");

					// save mutant
					this.save(atlModel, outputFolder);
						
					// remove comment
					if (comments!=null) comments.remove(comments.size()-1);
				}
			}
			
			// restore original value
			object2modify_src.eSet(featureDefinition, oldFeatureValue);					
		}
	}
}
 
开发者ID:anatlyzer,项目名称:anatlyzer,代码行数:56,代码来源:AbstractModificationMutator.java

示例10: createATLModel

import org.eclipse.m2m.atl.core.emf.EMFModel; //导入方法依赖的package包/类
protected ATLModel createATLModel(IFile file, EMFModel atlEMFModel) {
	return new ATLModel(atlEMFModel.getResource(), file.getFullPath().toPortableString());
}
 
开发者ID:anatlyzer,项目名称:anatlyzer,代码行数:4,代码来源:AbstractATLExperiment.java


注:本文中的org.eclipse.m2m.atl.core.emf.EMFModel.getResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。