| 1 | package de.uka.ipd.sdq.workflow.pcm.jobs; |
| 2 | |
| 3 | import java.io.IOException; |
| 4 | |
| 5 | import org.apache.log4j.Logger; |
| 6 | import org.eclipse.core.runtime.IProgressMonitor; |
| 7 | |
| 8 | import de.uka.ipd.sdq.workflow.IBlackboardInteractingJob; |
| 9 | import de.uka.ipd.sdq.workflow.IJob; |
| 10 | import de.uka.ipd.sdq.workflow.exceptions.JobFailedException; |
| 11 | import de.uka.ipd.sdq.workflow.exceptions.RollbackFailedException; |
| 12 | import de.uka.ipd.sdq.workflow.exceptions.UserCanceledException; |
| 13 | import de.uka.ipd.sdq.workflow.mdsd.blackboard.MDSDBlackboard; |
| 14 | import de.uka.ipd.sdq.workflow.pcm.blackboard.PCMResourceSetPartition; |
| 15 | import de.uka.ipd.sdq.workflow.pcm.configurations.AbstractPCMWorkflowRunConfiguration; |
| 16 | |
| 17 | /** |
| 18 | * Job to store the loaded PCM models. |
| 19 | * |
| 20 | * Prerequisite of this job: |
| 21 | * The working copy must have been created. E.g. by {@link CreateWorkingCopyOfModelsJob}. |
| 22 | * |
| 23 | * @author groenda |
| 24 | * |
| 25 | */ |
| 26 | public class StoreAllPCMModelsJob implements IJob, |
| 27 | IBlackboardInteractingJob<MDSDBlackboard> { |
| 28 | |
| 29 | /** The logger for this class */ |
| 30 | private static final Logger logger = Logger.getLogger(StoreAllPCMModelsJob.class); |
| 31 | |
| 32 | /** The blackboard to interact with */ |
| 33 | private MDSDBlackboard blackboard = null; |
| 34 | |
| 35 | /** |
| 36 | * Constructor requiring the necessary configuration object. |
| 37 | * |
| 38 | * @param configuration The configuration for this job. |
| 39 | */ |
| 40 | public StoreAllPCMModelsJob(AbstractPCMWorkflowRunConfiguration configuration) { |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Execute this job and create the model copy. |
| 45 | */ |
| 46 | public void execute(IProgressMonitor monitor) throws JobFailedException, |
| 47 | UserCanceledException { |
| 48 | |
| 49 | PCMResourceSetPartition partition = (PCMResourceSetPartition) this.blackboard.getPartition(LoadPCMModelsIntoBlackboardJob.PCM_MODELS_PARTITION_ID); |
| 50 | try { |
| 51 | partition.storeAllResources(); |
| 52 | } catch (IOException e) { |
| 53 | logger.error("unable to store all resources",e); |
| 54 | throw new JobFailedException("Unable to store all Resources",e); |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | public String getName() { |
| 59 | return "Update working copy of models"; |
| 60 | } |
| 61 | |
| 62 | public void rollback(IProgressMonitor monitor) |
| 63 | throws RollbackFailedException { |
| 64 | // nothing to roll back |
| 65 | } |
| 66 | |
| 67 | public void setBlackboard(MDSDBlackboard blackboard) { |
| 68 | this.blackboard = blackboard; |
| 69 | } |
| 70 | |
| 71 | } |