1 | package de.uka.ipd.sdq.workflow.pcm.jobs; |
2 | |
3 | import org.apache.log4j.Logger; |
4 | import org.eclipse.core.runtime.IProgressMonitor; |
5 | import org.eclipse.emf.common.util.URI; |
6 | |
7 | import de.uka.ipd.sdq.workflow.IBlackboardInteractingJob; |
8 | import de.uka.ipd.sdq.workflow.IJob; |
9 | import de.uka.ipd.sdq.workflow.exceptions.JobFailedException; |
10 | import de.uka.ipd.sdq.workflow.exceptions.RollbackFailedException; |
11 | import de.uka.ipd.sdq.workflow.exceptions.UserCanceledException; |
12 | import de.uka.ipd.sdq.workflow.mdsd.blackboard.MDSDBlackboard; |
13 | import de.uka.ipd.sdq.workflow.mdsd.blackboard.ResourceSetPartition; |
14 | import de.uka.ipd.sdq.workflow.pcm.blackboard.PCMResourceSetPartition; |
15 | import de.uka.ipd.sdq.workflow.pcm.configurations.AbstractPCMWorkflowRunConfiguration; |
16 | |
17 | public class PreparePCMBlackboardPartionJob |
18 | implements IJob, IBlackboardInteractingJob<MDSDBlackboard> { |
19 | |
20 | private static final Logger logger = Logger.getLogger(PreparePCMBlackboardPartionJob.class); |
21 | private MDSDBlackboard blackboard; |
22 | |
23 | static final URI PCM_PALLADIO_RESOURCE_TYPE_URI = URI.createURI("pathmap://PCM_MODELS/Palladio.resourcetype"); |
24 | static final URI PCM_PALLADIO_PRIMITIVE_TYPE_REPOSITORY_URI = URI.createURI("pathmap://PCM_MODELS/PrimitiveTypes.repository"); |
25 | |
26 | @Override |
27 | public void execute(IProgressMonitor monitor) throws JobFailedException, |
28 | UserCanceledException { |
29 | // Create and add the PCM and middleware model partition |
30 | logger.debug("Creating PCM Model Partition"); |
31 | PCMResourceSetPartition myPartion = new PCMResourceSetPartition(); |
32 | this.blackboard.addPartition(LoadPCMModelsIntoBlackboardJob.PCM_MODELS_PARTITION_ID, myPartion); |
33 | |
34 | ResourceSetPartition middlewareRepositoryPartition = new ResourceSetPartition(); |
35 | this.blackboard.addPartition(LoadPCMModelsIntoBlackboardJob.MIDDLEWARE_PARTITION_ID, middlewareRepositoryPartition); |
36 | |
37 | ResourceSetPartition eventMiddlewareRepositoryPartition = new ResourceSetPartition(); |
38 | this.blackboard.addPartition(LoadPCMModelsIntoBlackboardJob.EVENT_MIDDLEWARE_PARTITION_ID, eventMiddlewareRepositoryPartition); |
39 | |
40 | logger.debug("Initialising PCM EPackages"); |
41 | myPartion.initialiseResourceSetEPackages(AbstractPCMWorkflowRunConfiguration.PCM_EPACKAGES); |
42 | middlewareRepositoryPartition.initialiseResourceSetEPackages(AbstractPCMWorkflowRunConfiguration.PCM_EPACKAGES); |
43 | |
44 | myPartion.loadModel(PCM_PALLADIO_PRIMITIVE_TYPE_REPOSITORY_URI); |
45 | myPartion.loadModel(PCM_PALLADIO_RESOURCE_TYPE_URI); |
46 | } |
47 | |
48 | @Override |
49 | public String getName() { |
50 | return "Prepare PCM Blackboard Partions"; |
51 | } |
52 | |
53 | @Override |
54 | public void rollback(IProgressMonitor monitor) |
55 | throws RollbackFailedException { |
56 | this.blackboard.removePartition(LoadPCMModelsIntoBlackboardJob.EVENT_MIDDLEWARE_PARTITION_ID); |
57 | this.blackboard.removePartition(LoadPCMModelsIntoBlackboardJob.MIDDLEWARE_PARTITION_ID); |
58 | this.blackboard.removePartition(LoadPCMModelsIntoBlackboardJob.PCM_MODELS_PARTITION_ID); |
59 | } |
60 | |
61 | @Override |
62 | public void setBlackboard(MDSDBlackboard blackboard) { |
63 | this.blackboard = blackboard; |
64 | } |
65 | |
66 | } |