| 1 | package de.uka.ipd.sdq.pcm.transformations.builder.seff; |
| 2 | |
| 3 | import de.uka.ipd.sdq.pcm.core.CoreFactory; |
| 4 | import de.uka.ipd.sdq.pcm.core.PCMRandomVariable; |
| 5 | import de.uka.ipd.sdq.pcm.resourcetype.ProcessingResourceType; |
| 6 | import de.uka.ipd.sdq.pcm.seff.AbstractAction; |
| 7 | import de.uka.ipd.sdq.pcm.seff.InternalAction; |
| 8 | import de.uka.ipd.sdq.pcm.seff.SeffFactory; |
| 9 | import de.uka.ipd.sdq.pcm.seff.seff_performance.ParametricResourceDemand; |
| 10 | import de.uka.ipd.sdq.pcm.seff.seff_performance.Seff_performanceFactory; |
| 11 | |
| 12 | /** |
| 13 | * @author Snowball |
| 14 | */ |
| 15 | public abstract class AbstractInternalActionDescriptor extends AbstractActionDescriptor { |
| 16 | |
| 17 | private ProcessingResourceType resourceType; |
| 18 | |
| 19 | public AbstractInternalActionDescriptor( |
| 20 | ProcessingResourceType resourceType) { |
| 21 | super(); |
| 22 | this.resourceType = resourceType; |
| 23 | } |
| 24 | |
| 25 | public abstract String getResourceDemand(); |
| 26 | |
| 27 | /** |
| 28 | * @return |
| 29 | */ |
| 30 | public ProcessingResourceType getResourceType() { |
| 31 | return resourceType; |
| 32 | } |
| 33 | |
| 34 | @Override |
| 35 | public AbstractAction createAction() { |
| 36 | return createInternalAction(getResourceType(), getResourceDemand()); |
| 37 | } |
| 38 | |
| 39 | private InternalAction createInternalAction(ProcessingResourceType type, String resourceDemandSpec) { |
| 40 | InternalAction action = SeffFactory.eINSTANCE.createInternalAction(); |
| 41 | ParametricResourceDemand d = Seff_performanceFactory.eINSTANCE.createParametricResourceDemand(); |
| 42 | d.setRequiredResource_ParametricResourceDemand(type); |
| 43 | PCMRandomVariable specification = CoreFactory.eINSTANCE.createPCMRandomVariable(); |
| 44 | specification.setSpecification(getSaveResourceDemand(resourceDemandSpec)); |
| 45 | d.setSpecification_ParametericResourceDemand(specification); |
| 46 | action.getResourceDemand_Action().add(d); |
| 47 | |
| 48 | return action; |
| 49 | } |
| 50 | |
| 51 | private String getSaveResourceDemand(String resourceDemandSpec) { |
| 52 | if (resourceDemandSpec == null) |
| 53 | return "0"; |
| 54 | if (resourceDemandSpec.equals("")) |
| 55 | return "0"; |
| 56 | return resourceDemandSpec; |
| 57 | } |
| 58 | } |