| 1 | package de.uka.ipd.sdq.cip.workflow.jobs; |
| 2 | |
| 3 | import de.uka.ipd.sdq.cip.configuration.CompletionConfiguration; |
| 4 | import de.uka.ipd.sdq.cip.configuration.CompletionConfigurationProvider; |
| 5 | import de.uka.ipd.sdq.cip.configuration.Transformation; |
| 6 | import de.uka.ipd.sdq.cip.workflow.jobs.builder.QVTOCompletionBuilder; |
| 7 | import de.uka.ipd.sdq.cip.workflow.jobs.builder.QVTRCompletionBuilder; |
| 8 | import de.uka.ipd.sdq.workflow.IBlackboardInteractingJob; |
| 9 | import de.uka.ipd.sdq.workflow.OrderPreservingBlackboardCompositeJob; |
| 10 | import de.uka.ipd.sdq.workflow.exceptions.JobFailedException; |
| 11 | import de.uka.ipd.sdq.workflow.mdsd.blackboard.MDSDBlackboard; |
| 12 | |
| 13 | /** |
| 14 | * CompletionJob iterates over all configured completions and creates the required jobs |
| 15 | * |
| 16 | * @author Thomas Schuischel |
| 17 | * |
| 18 | */ |
| 19 | public class CompletionJob extends |
| 20 | OrderPreservingBlackboardCompositeJob<MDSDBlackboard> implements |
| 21 | IBlackboardInteractingJob<MDSDBlackboard> { |
| 22 | |
| 23 | /** |
| 24 | * Creates a composite job for completions from a {@link CompletionConfigurationProvider} |
| 25 | * |
| 26 | * @param configurationProvider A class providing a {@link CompletionConfiguration} through |
| 27 | * the interface {@link CompletionConfigurationProvider} |
| 28 | */ |
| 29 | public CompletionJob(CompletionConfigurationProvider configurationProvider) { |
| 30 | this(configurationProvider.getCompletionConfiguration()); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Creates a composite job for completions from a {@link CompletionConfiguration} |
| 35 | * |
| 36 | * @param configuration The configuration for all completions |
| 37 | */ |
| 38 | public CompletionJob(CompletionConfiguration configuration) { |
| 39 | super(); |
| 40 | |
| 41 | // only continue if there is a configuration and |
| 42 | // at least one transformation configured |
| 43 | if(configuration == null || configuration.getTransformations().size() < 1) |
| 44 | return; |
| 45 | |
| 46 | // Prepare the necessary preconditions for completions |
| 47 | add(new PrepareTransformationsJob(configuration)); |
| 48 | |
| 49 | for(Transformation transformation : configuration.getTransformations()) { |
| 50 | switch(transformation.getQVTType()) { |
| 51 | |
| 52 | // Handle QVTR completions |
| 53 | case QVTR: |
| 54 | addAll(new QVTRCompletionBuilder( |
| 55 | configuration, |
| 56 | transformation) |
| 57 | .buildJobs()); |
| 58 | break; |
| 59 | |
| 60 | // Handle QVTO completions |
| 61 | case QVTO: |
| 62 | addAll(new QVTOCompletionBuilder( |
| 63 | configuration, |
| 64 | transformation) |
| 65 | .buildJobs()); |
| 66 | break; |
| 67 | |
| 68 | // Handle wrong completion type |
| 69 | default: |
| 70 | JobFailedException e = new JobFailedException("Unable to create ComplitionJob"); |
| 71 | logger.error("unknown QVT type: " + transformation.getQVTType(), e); |
| 72 | } |
| 73 | |
| 74 | } |
| 75 | |
| 76 | } |
| 77 | } |