Skip to content
Snippets Groups Projects
Commit fd876ac9 authored by Florian Hölzl's avatar Florian Hölzl
Browse files

fixed execution service.

removed unnecessary platform transformations.
added platform executable constraint.
refs 136
parent 31cb1b1b
No related branches found
No related tags found
No related merge requests found
......@@ -129,7 +129,8 @@ public class TransformationService extends
List<ITransformationProvider> currentChain,
Set<Class<?>> seenTargets, ITransformationContext context) {
if (!currentChain.isEmpty()
&& currentChain.get(currentChain.size() - 1).getTargetClass() == targetClass) {
&& targetClass.isAssignableFrom(currentChain.get(
currentChain.size() - 1).getTargetClass())) {
// found a complete chain => add to result and backtrack
results.add(new TransformationProviderChain(currentChain));
return;
......
......@@ -33,23 +33,46 @@ import org.fortiss.tooling.kernel.service.ITransformationService;
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public final class TransformationUtil {
public final class TransformationUtils {
/**
* Searches a transformation chain for the given model element and the
* target class and returns the transformation result.
*/
@SuppressWarnings("unchecked")
public static <T extends Object> T createTransformedObjectFor(
EObject modelElement, Class<T> targetClass,
final EObject modelElement, final Class<T> targetClass,
ITransformationContext context)
throws ChainTransformationFailedException {
List<TransformationProviderChain> chainList = ITransformationService.INSTANCE
.getTransformationProviderChain(modelElement.getClass(),
targetClass, context);
ChainTransformationFailedException e = null;
if (!chainList.isEmpty()) {
return (T) chainList.get(0).transform(modelElement, context);
Object executableObject = null;
for (TransformationProviderChain chain : chainList) {
try {
executableObject = chain.transform(modelElement, context);
e = null;
} catch (ChainTransformationFailedException ctfe) {
// fall through
e = ctfe;
executableObject = null;
}
}
if (e == null && executableObject != null) {
return (T) executableObject;
}
}
return null;
if (e != null) {
throw e;
}
throw new ChainTransformationFailedException(null, null, null, null) {
/** {@inheritDoc} */
@Override
public String getMessage() {
return "No transformation chain found from " + modelElement
+ " to " + targetClass.getName();
}
};
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment