| 1 | package de.uka.ipd.sdq.cip.workflow.jobs.builder; |
| 2 | |
| 3 | import java.util.ArrayList; |
| 4 | import java.util.Collection; |
| 5 | |
| 6 | import de.uka.ipd.sdq.cip.configuration.CompletionConfiguration; |
| 7 | import de.uka.ipd.sdq.cip.configuration.Transformation; |
| 8 | import de.uka.ipd.sdq.cip.configuration.TransformationType; |
| 9 | import de.uka.ipd.sdq.cip.workflow.jobs.PrettyPrintQvtJob; |
| 10 | import de.uka.ipd.sdq.cip.workflow.jobs.QVTRConfigurationJob; |
| 11 | import de.uka.ipd.sdq.cip.workflow.jobs.QVTRHotConfigurationJob; |
| 12 | import de.uka.ipd.sdq.cip.workflow.jobs.SplitTransformationResultJob; |
| 13 | import de.uka.ipd.sdq.workflow.IJob; |
| 14 | import de.uka.ipd.sdq.workflow.mdsd.blackboard.SavePartitionToDiskJob; |
| 15 | import de.uka.ipd.sdq.workflow.mdsd.emf.qvtr.jobs.QVTRTransformationJob; |
| 16 | import de.uka.ipd.sdq.workflow.mdsd.emf.qvtr.jobs.QVTRTransformationJobConfiguration; |
| 17 | |
| 18 | /** |
| 19 | * Job Builder for a QVTR transformation completion. |
| 20 | * This builder can create plain, mark, and feature completions. |
| 21 | * |
| 22 | * It creates the jobs for a given {@link Transformation} and {@link CompletionConfiguration}. |
| 23 | * |
| 24 | * @author Thomas Schuischel |
| 25 | * |
| 26 | */ |
| 27 | public class QVTRCompletionBuilder implements CompletionBuilder { |
| 28 | |
| 29 | private CompletionConfiguration completionConfiguration; |
| 30 | private Transformation transformation; |
| 31 | |
| 32 | /** |
| 33 | * Creates a new QVTRCompletionBuilder and stores the configuration parameters. |
| 34 | * |
| 35 | * @param completionConfiguration a {@link CompletionConfiguration} |
| 36 | * @param transformation a {@link Transformation} |
| 37 | */ |
| 38 | public QVTRCompletionBuilder(CompletionConfiguration completionConfiguration, |
| 39 | Transformation transformation) { |
| 40 | this.completionConfiguration = completionConfiguration; |
| 41 | this.transformation = transformation; |
| 42 | } |
| 43 | |
| 44 | /* (non-Javadoc) |
| 45 | * @see de.uka.ipd.sdq.cip.workflow.jobs.builder.CompletionBuilder#buildJobs() |
| 46 | */ |
| 47 | public |
| 48 | Collection<IJob> buildJobs() { |
| 49 | |
| 50 | Collection<IJob> jobs = new ArrayList<IJob>(); |
| 51 | |
| 52 | // HOT Completion: FeatureConfig -> HOT -> Generated QVT Completion Script |
| 53 | if(transformation.getType() == TransformationType.FEATURE) |
| 54 | { |
| 55 | // The configuration for a QVTR hot completion |
| 56 | QVTRTransformationJobConfiguration qvtrHotConfig = new QVTRTransformationJobConfiguration(); |
| 57 | |
| 58 | // configure the QVTR Job for hot completion |
| 59 | jobs.add(new QVTRHotConfigurationJob(qvtrHotConfig, completionConfiguration, transformation)); |
| 60 | |
| 61 | // create the QVT-R model from a feature configuration |
| 62 | jobs.add(new QVTRTransformationJob(qvtrHotConfig)); |
| 63 | |
| 64 | // create a QVT-R script file from a QVT-R model |
| 65 | jobs.add(new PrettyPrintQvtJob(qvtrHotConfig, completionConfiguration, transformation)); |
| 66 | } |
| 67 | |
| 68 | // Completion: Input Model -> Generated QVT Completion Script -> Output Model |
| 69 | { |
| 70 | // configure the QVTR Job |
| 71 | // The configuration for a QVTR completion |
| 72 | QVTRTransformationJobConfiguration qvtrConfig = new QVTRTransformationJobConfiguration(); |
| 73 | |
| 74 | // configure the QVTR Job for completion |
| 75 | jobs.add(new QVTRConfigurationJob(qvtrConfig, completionConfiguration, transformation)); |
| 76 | |
| 77 | // execute the completion |
| 78 | jobs.add(new QVTRTransformationJob(qvtrConfig)); |
| 79 | |
| 80 | // split the created output Resources for each top level element |
| 81 | jobs.add(new SplitTransformationResultJob(qvtrConfig, completionConfiguration, transformation)); |
| 82 | |
| 83 | // dump the partition to disk |
| 84 | jobs.add(new SavePartitionToDiskJob(completionConfiguration.getInputPartitionName())); |
| 85 | } |
| 86 | |
| 87 | return jobs; |
| 88 | |
| 89 | } |
| 90 | |
| 91 | } |