Commit 14bebfbc authored by Müller, Marco's avatar Müller, Marco
Browse files

Merge branch '74-unused-never-referenced-classes'

Resolved Conflict:
	Core/java.embed.transformation/src/main/java/de/mkonersmann/advert/java/embed/transformation/ModelCodeTransformationRegistry.java
parents 83bbf469 cc4ea322
Loading
Loading
Loading
Loading
+0 −57
Original line number Diff line number Diff line
package de.mkonersmann.henshin.tgg.api.impl.actions;

import java.util.List;
import java.util.Map;

import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.impl.EStructuralFeatureImpl;
import org.eclipse.emf.henshin.interpreter.util.HenshinEGraph;

import de.tub.tfs.henshin.tgg.TNode;
import de.tub.tfs.henshin.tgg.TripleGraph;

public class ExportModelInstanceAction {

	TripleGraph graph;
	Map<TNode, EObject> tNode2instance;

	public ExportModelInstanceAction(TripleGraph graph,
			Map<TNode, EObject> tNode2instance) {
		this.graph = graph;
		this.tNode2instance = tNode2instance;
	}

	public List<EObject> execute() {
		// TODO: This seems to create new eobjects. I would like them to be
		// changed instead.
		HenshinEGraph gr = new HenshinEGraph(graph);

		// Set default values of attributes to "" where necessary
		for (EObject eObject : gr.getRoots()) {
			EList<EStructuralFeature> features = eObject.eClass()
					.getEAllStructuralFeatures();
			for (EStructuralFeature feature : features) {
				if (feature.getDefaultValueLiteral() == null) {
					((EStructuralFeatureImpl) feature)
							.setDefaultValueLiteral("");
				}
			}
		}

		List<EObject> ret = gr.getRoots();

		// Reset the changed attributes to null where necessary
		for (EObject eObject : gr.getRoots()) {
			EList<EStructuralFeature> features = eObject.eClass()
					.getEAllStructuralFeatures();
			for (EStructuralFeature feature : features) {
				if (feature.getDefaultValueLiteral() == null) {
					feature.setDefaultValueLiteral(null);
				}
			}
		}
		return ret;
	}
}