summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Pielmann2012-01-03 08:49:46 (EST)
committerStephan Born2012-04-24 04:17:05 (EDT)
commit88aeb9410c203a436b2230c032201577e9cce2c6 (patch)
tree378f2dd666f6d5301d94aa81dc7dd94d7cd7615d
parent1dffe76afbe4e6e24c89df3f2cbc779a17dfaf9a (diff)
downloadorg.eclipse.stardust.ide-88aeb9410c203a436b2230c032201577e9cce2c6.zip
org.eclipse.stardust.ide-88aeb9410c203a436b2230c032201577e9cce2c6.tar.gz
org.eclipse.stardust.ide-88aeb9410c203a436b2230c032201577e9cce2c6.tar.bz2
Jira-ID: CRNT-22261 Add standard formula and configuration parameters needed in JavaScript default criticality formula upon creation of a new model
git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ide@52465 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--model/org.eclipse.stardust.model.xpdl/src/org/eclipse/stardust/model/xpdl/carnot/util/VariableContext.java67
-rw-r--r--model/org.eclipse.stardust.model.xpdl/src/org/eclipse/stardust/model/xpdl/carnot/util/VariableContextHelper.java10
-rw-r--r--modeling/org.eclipse.stardust.modeling.core/src/org/eclipse/stardust/modeling/core/wizards/NewWorkflowDiagramWizard.java69
3 files changed, 116 insertions, 30 deletions
diff --git a/model/org.eclipse.stardust.model.xpdl/src/org/eclipse/stardust/model/xpdl/carnot/util/VariableContext.java b/model/org.eclipse.stardust.model.xpdl/src/org/eclipse/stardust/model/xpdl/carnot/util/VariableContext.java
index 16ffc82..de69cd8 100644
--- a/model/org.eclipse.stardust.model.xpdl/src/org/eclipse/stardust/model/xpdl/carnot/util/VariableContext.java
+++ b/model/org.eclipse.stardust.model.xpdl/src/org/eclipse/stardust/model/xpdl/carnot/util/VariableContext.java
@@ -116,17 +116,7 @@ public class VariableContext
}
}
- private void removeAttributeSet(ModelVariable modelVariable, int j)
- {
- AttributeUtil.setAttribute((IExtensibleElement) model, "ipp:variables[" + j
- + "]:name", "String", null);
- AttributeUtil.setAttribute((IExtensibleElement) model, "ipp:variables[" + j
- + "]:defaultValue", "String", null);
- AttributeUtil.setAttribute((IExtensibleElement) model, "ipp:variables[" + j
- + "]:description", "String", null);
- }
-
- private void createAttributeSet(ModelVariable modelVariable, int j)
+ public void createAttributeSet(ModelVariable modelVariable, int j)
{
if (!modelVariable.isRemoved())
{
@@ -142,6 +132,16 @@ public class VariableContext
}
}
+ private void removeAttributeSet(ModelVariable modelVariable, int j)
+ {
+ AttributeUtil.setAttribute((IExtensibleElement) model, "ipp:variables[" + j
+ + "]:name", "String", null);
+ AttributeUtil.setAttribute((IExtensibleElement) model, "ipp:variables[" + j
+ + "]:defaultValue", "String", null);
+ AttributeUtil.setAttribute((IExtensibleElement) model, "ipp:variables[" + j
+ + "]:description", "String", null);
+ }
+
private ModelVariable createModelVariable(AttributeType attribute)
{
ModelVariable modelVariable;
@@ -249,26 +249,30 @@ public class VariableContext
{
Matcher matcher = pattern.matcher(modelElement.toString());
if (modelElement.eContainer() != null)
- {
+ {
while (matcher.find())
- {
- if ((matcher.start() == 0) || ((matcher.start() > 0)
- && (modelElement.toString().charAt(matcher.start() - 1) != '\\')))
+ {
+ if ((matcher.start() == 0)
+ || ((matcher.start() > 0) && (modelElement.toString().charAt(
+ matcher.start() - 1) != '\\')))
{
String ref = modelElement.toString().substring(matcher.start(),
matcher.end());
ref = ref.trim();
- List<EObject> refList = variableReferences.get(ref);
- if (refList == null)
- {
- refList = new ArrayList<EObject>();
- variableReferences.put(ref, refList);
- ModelVariable modelVariable = new ModelVariable(ref, "", "");
- variables.add(modelVariable);
- }
- if (!containedReference(modelElement, refList))
+ if (!variableExists(ref))
{
- refList.add(modelElement);
+ List<EObject> refList = variableReferences.get(ref);
+ if (refList == null)
+ {
+ refList = new ArrayList<EObject>();
+ variableReferences.put(ref, refList);
+ ModelVariable modelVariable = new ModelVariable(ref, "", "");
+ variables.add(modelVariable);
+ }
+ if (!containedReference(modelElement, refList))
+ {
+ refList.add(modelElement);
+ }
}
}
}
@@ -279,6 +283,19 @@ public class VariableContext
}
}
+ private boolean variableExists(String ref)
+ {
+ for (Iterator<ModelVariable> i = variables.iterator(); i.hasNext();)
+ {
+ ModelVariable variable = i.next();
+ if (variable.getName().equalsIgnoreCase(ref))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
private boolean containedReference(EObject modelElement, List<EObject> refList)
{
for (Iterator<EObject> i = refList.iterator(); i.hasNext();)
diff --git a/model/org.eclipse.stardust.model.xpdl/src/org/eclipse/stardust/model/xpdl/carnot/util/VariableContextHelper.java b/model/org.eclipse.stardust.model.xpdl/src/org/eclipse/stardust/model/xpdl/carnot/util/VariableContextHelper.java
index 8c2795d..e4b4cae 100644
--- a/model/org.eclipse.stardust.model.xpdl/src/org/eclipse/stardust/model/xpdl/carnot/util/VariableContextHelper.java
+++ b/model/org.eclipse.stardust.model.xpdl/src/org/eclipse/stardust/model/xpdl/carnot/util/VariableContextHelper.java
@@ -22,7 +22,7 @@ public class VariableContextHelper
private static VariableContextHelper instance = null;
- private Map<ModelType, VariableContext> contextMap = new HashMap<ModelType, VariableContext>();
+ private Map<String, VariableContext> contextMap = new HashMap<String, VariableContext>();
public VariableContextHelper()
{
@@ -45,17 +45,17 @@ public class VariableContextHelper
public synchronized void createContext(ModelType modelType)
{
- contextMap.put(modelType, new VariableContext());
+ contextMap.put(modelType.getId(), new VariableContext());
}
public synchronized void removeContext(ModelType modelType)
{
- contextMap.remove(modelType);
+ contextMap.remove(modelType.getId());
}
public synchronized VariableContext getContext(ModelType modelType)
{
- return contextMap.get(modelType);
+ return contextMap.get(modelType.getId());
}
public synchronized VariableContext getContext(IModelElement element)
@@ -70,7 +70,7 @@ public class VariableContextHelper
{
createContext(modelType);
}
- return contextMap.get(modelType);
+ return contextMap.get(modelType.getId());
}
return null;
}
diff --git a/modeling/org.eclipse.stardust.modeling.core/src/org/eclipse/stardust/modeling/core/wizards/NewWorkflowDiagramWizard.java b/modeling/org.eclipse.stardust.modeling.core/src/org/eclipse/stardust/modeling/core/wizards/NewWorkflowDiagramWizard.java
index f9bdca7..6a591ce 100644
--- a/modeling/org.eclipse.stardust.modeling.core/src/org/eclipse/stardust/modeling/core/wizards/NewWorkflowDiagramWizard.java
+++ b/modeling/org.eclipse.stardust.modeling.core/src/org/eclipse/stardust/modeling/core/wizards/NewWorkflowDiagramWizard.java
@@ -50,14 +50,19 @@ import org.eclipse.stardust.model.xpdl.carnot.DataType;
import org.eclipse.stardust.model.xpdl.carnot.DataTypeType;
import org.eclipse.stardust.model.xpdl.carnot.DiagramModeType;
import org.eclipse.stardust.model.xpdl.carnot.DiagramType;
+import org.eclipse.stardust.model.xpdl.carnot.IExtensibleElement;
import org.eclipse.stardust.model.xpdl.carnot.ModelType;
import org.eclipse.stardust.model.xpdl.carnot.OrientationType;
import org.eclipse.stardust.model.xpdl.carnot.ProcessDefinitionType;
import org.eclipse.stardust.model.xpdl.carnot.RoleType;
import org.eclipse.stardust.model.xpdl.carnot.spi.SpiExtensionRegistry;
+import org.eclipse.stardust.model.xpdl.carnot.util.AttributeUtil;
import org.eclipse.stardust.model.xpdl.carnot.util.CarnotConstants;
import org.eclipse.stardust.model.xpdl.carnot.util.DiagramUtil;
import org.eclipse.stardust.model.xpdl.carnot.util.ModelUtils;
+import org.eclipse.stardust.model.xpdl.carnot.util.ModelVariable;
+import org.eclipse.stardust.model.xpdl.carnot.util.VariableContext;
+import org.eclipse.stardust.model.xpdl.carnot.util.VariableContextHelper;
import org.eclipse.stardust.model.xpdl.carnot.util.WorkflowModelManager;
import org.eclipse.stardust.model.xpdl.xpdl2.ScriptType;
import org.eclipse.stardust.model.xpdl.xpdl2.XpdlFactory;
@@ -196,6 +201,7 @@ public class NewWorkflowDiagramWizard extends Wizard implements INewWizard
createDefaultData(model);
createDefaultPerformers(model);
createDefaultProcess(model);
+ createDefaultCriticalityAttributes(model);
}
private void createDefaultProcess(ModelType model)
@@ -377,6 +383,69 @@ public class NewWorkflowDiagramWizard extends Wizard implements INewWizard
createAttribute(currentModel, PredefinedConstants.CLASS_NAME_ATT, null,
"ag.carnot.workflow.runtime.DeployedModelDescription"); //$NON-NLS-1$
}
+
+ private void createDefaultCriticalityAttributes(ModelType model)
+ {
+ VariableContextHelper.getInstance().createContext(model);
+ VariableContext context = VariableContextHelper.getInstance().getContext(model);
+ context.initializeVariables(model);
+
+ // TDefault
+ ModelVariable modelVariable = new ModelVariable("${TDefault}", "86400", "Target execution time");
+ context.createAttributeSet(modelVariable, 0);
+
+ // CLow
+ modelVariable = new ModelVariable("${CLow}", "0", "Initial criticality (Low)");
+ context.createAttributeSet(modelVariable, 0);
+
+ // CMed
+ modelVariable = new ModelVariable("${CMed}", "0.33", "Initial criticality (Medium)");
+ context.createAttributeSet(modelVariable, 1);
+
+ // CHigh
+ modelVariable = new ModelVariable("${CHigh}", "0.66", "Initial criticality (High)");
+ context.createAttributeSet(modelVariable, 2);
+
+ // MLow
+ modelVariable = new ModelVariable("${MLow}", "10", "Multiple of target execution time (Low)");
+ context.createAttributeSet(modelVariable, 3);
+
+ // MMed
+ modelVariable = new ModelVariable("${MMed}", "10", "Multiple of target execution time (Medium)");
+ context.createAttributeSet(modelVariable, 4);
+
+ // MHigh
+ modelVariable = new ModelVariable("${MHigh}", "10", "Multiple of target execution time (High)");
+ context.createAttributeSet(modelVariable, 5);
+
+ //Default criticality formula
+ String formula =
+ "if(activityInstance.getActivity().getTargetExecutionTime() == 0)\n" +
+ "{\n" +
+ " T = ${TDefault};\n" +
+ "}\n" +
+ "else\n" +
+ "{\n" +
+ " T = activityInstance.getActivity().getTargetExecutionTime();\n" +
+ "}\n" +
+ "if(PROCESS_PRIORITY == -1)\n" +
+ "{\n"+
+ " Cp = ${CLow};\n" +
+ " Mp = ${MLow};\n" +
+ "}\n" +
+ "if(PROCESS_PRIORITY == 0)\n" +
+ "{\n" +
+ " Cp = ${CMed};\n" +
+ " Mp = ${MLow};\n" +
+ "}\n" +
+ "if(PROCESS_PRIORITY == 1)\n" +
+ "{\n" +
+ " Cp = ${CHigh};\n" +
+ " Mp = ${MHigh};\n" +
+ "}\n" +
+ "t = activityInstance.getAge() / 1000;\n";
+ AttributeUtil.setAttribute((IExtensibleElement) model, "ipp:criticalityFormula", "String", formula);
+ }
private void createAttribute(DataType data, String name, String type, String value)
{