Skip to content

Commit

Permalink
#183 Show information about constraints applied on an element
Browse files Browse the repository at this point in the history
ConstraintsDocGen now displays the constraints passed in parameter
constraintsList, in a section named after parameter
constraintSectionTitle value.
New pattern AllConstraintsDocGen calls the previous pattern twice. First
call is for contained constraints, the second call is for applied and
not contained constraints.
Updated Constraints and PropertyValue API.

Add default behavior for ConstraintDocGen pattern call without values in
new parameters.

Change-Id: I2e714aa3e56796d6126f14f4962be047b6c46fd7
  • Loading branch information
arnauddieumegard committed Jun 2, 2021
1 parent ccde492 commit 381d591
Show file tree
Hide file tree
Showing 14 changed files with 334 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,29 @@
<methods xmi:id="_F9HPpVcEEeWXKstRBeKifA" name="preCondition" patternFilePath="templates/pattern._F9HPoVcEEeWXKstRBeKifA/method._F9HPpVcEEeWXKstRBeKifA.pt"/>
<methods xmi:id="_F9HPplcEEeWXKstRBeKifA" name="genConstraints" patternFilePath="templates/pattern._F9HPoVcEEeWXKstRBeKifA/method._F9HPplcEEeWXKstRBeKifA.pt"/>
<methods xmi:id="_F9HPp1cEEeWXKstRBeKifA" name="footer" patternFilePath="templates/pattern._F9HPoVcEEeWXKstRBeKifA/method._F9HPp1cEEeWXKstRBeKifA.pt"/>
<parameters xmi:id="_KfYg8FcEEeWXKstRBeKifA" name="parameter" type="http://www.polarsys.org/capella/core/core/1.4.0#//NamedElement"/>
<parameters xmi:id="_KfYg8FcEEeWXKstRBeKifA" name="parameter" type="org.polarsys.capella.core.data.capellacore.CapellaElement"/>
<parameters xmi:id="_Zn7Y8MILEeu7XfnfLZ0e8g" name="constraintsList" type="java.util.List"/>
<parameters xmi:id="_uSTWQMILEeu7XfnfLZ0e8g" name="constraintSectionTitle"
type="java.lang.String"/>
<orchestration xmi:type="pattern:SuperCall" xmi:id="_F9HPqFcEEeWXKstRBeKifA"/>
<orchestration xmi:type="pattern:MethodCall" xmi:id="_fqM44FcEEeWXKstRBeKifA"
called="#_F9HPplcEEeWXKstRBeKifA"/>
</elements>
<elements xmi:id="_MribAMILEeu7XfnfLZ0e8g" name="AllConstraintsDocGen" headerMethod="#_MribAsILEeu7XfnfLZ0e8g"
conditionMethod="#_MribBMILEeu7XfnfLZ0e8g" initMethod="#_MribA8ILEeu7XfnfLZ0e8g"
footerMethod="#_MribBsILEeu7XfnfLZ0e8g">
<nature xmi:type="jetpattern:JetNature" xmi:id="_MribAcILEeu7XfnfLZ0e8g"
name="JET"/>
<methods xmi:id="_MribAsILEeu7XfnfLZ0e8g" name="header" patternFilePath="templates/pattern._MribAMILEeu7XfnfLZ0e8g/method._MribAsILEeu7XfnfLZ0e8g.pt"/>
<methods xmi:id="_MribA8ILEeu7XfnfLZ0e8g" name="init" patternFilePath="templates/pattern._MribAMILEeu7XfnfLZ0e8g/method._MribA8ILEeu7XfnfLZ0e8g.pt"/>
<methods xmi:id="_MribBMILEeu7XfnfLZ0e8g" name="preCondition" patternFilePath="templates/pattern._MribAMILEeu7XfnfLZ0e8g/method._MribBMILEeu7XfnfLZ0e8g.pt"/>
<methods xmi:id="_MribBcILEeu7XfnfLZ0e8g" name="genConstraints" patternFilePath="templates/pattern._MribAMILEeu7XfnfLZ0e8g/method._MribBcILEeu7XfnfLZ0e8g.pt"/>
<methods xmi:id="_MribBsILEeu7XfnfLZ0e8g" name="footer" patternFilePath="templates/pattern._MribAMILEeu7XfnfLZ0e8g/method._MribBsILEeu7XfnfLZ0e8g.pt"/>
<parameters xmi:id="_MribB8ILEeu7XfnfLZ0e8g" name="parameter" type="org.polarsys.capella.core.data.capellacore.CapellaElement"/>
<orchestration xmi:type="pattern:SuperCall" xmi:id="_MribCMILEeu7XfnfLZ0e8g"/>
<orchestration xmi:type="pattern:MethodCall" xmi:id="_MribCcILEeu7XfnfLZ0e8g"
called="#_MribBcILEeu7XfnfLZ0e8g"/>
</elements>
<elements xmi:id="_mGFhcAHoEemzNsJkc2kajg" name="InterestedDiagrmsGeneration"
headerMethod="#_mGFhcgHoEemzNsJkc2kajg" conditionMethod="#_mGFhdAHoEemzNsJkc2kajg"
initMethod="#_mGFhcwHoEemzNsJkc2kajg" footerMethod="#_mGFhdgHoEemzNsJkc2kajg">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
//Generated with EGF 1.6.2.202001031546
package org.polarsys.capella.docgen.foundations;

import java.util.*;
import org.eclipse.egf.model.pattern.*;
import org.eclipse.egf.pattern.execution.*;
import org.eclipse.egf.pattern.query.*;
import org.polarsys.capella.docgen.util.ConstraintsService;
import org.polarsys.capella.common.data.modellingcore.AbstractConstraint;

public class AllConstraintsDocGen {
protected static String nl;

public static synchronized AllConstraintsDocGen create(String lineSeparator) {
nl = lineSeparator;
AllConstraintsDocGen result = new AllConstraintsDocGen();
nl = null;
return result;
}

public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
protected final String TEXT_1 = "";
protected final String TEXT_2 = NL;

public AllConstraintsDocGen() {
//Here is the constructor
StringBuffer stringBuffer = new StringBuffer();

// add initialisation of the pattern variables (declaration has been already done).

}

public String generate(Object argument) throws Exception {
final StringBuffer stringBuffer = new StringBuffer();

InternalPatternContext ctx = (InternalPatternContext) argument;
Map<String, String> queryCtx = null;
IQuery.ParameterDescription paramDesc = null;
Node.Container currentNode = ctx.getNode();

List<Object> parameterList = null;
//this pattern can only be called by another (i.e. it's not an entry point in execution)

for (Object parameterParameter : parameterList) {

this.parameter = (org.polarsys.capella.core.data.capellacore.CapellaElement) parameterParameter;

if (preCondition(ctx)) {
ctx.setNode(new Node.Container(currentNode, getClass()));
orchestration(ctx);
}

}
ctx.setNode(currentNode);
if (ctx.useReporter()) {
ctx.getReporter().executionFinished(OutputManager.computeExecutionOutput(ctx), ctx);
}

stringBuffer.append(TEXT_2);
stringBuffer.append(TEXT_2);
return stringBuffer.toString();
}

public String orchestration(PatternContext ctx) throws Exception {
InternalPatternContext ictx = (InternalPatternContext) ctx;

method_genConstraints(new StringBuffer(), ictx);

if (ictx.useReporter()) {
Map<String, Object> parameterValues = new HashMap<String, Object>();
parameterValues.put("parameter", this.parameter);
String outputWithCallBack = OutputManager.computeLoopOutput(ictx);
String loop = OutputManager.computeLoopOutputWithoutCallback(ictx);
ictx.getReporter().loopFinished(loop, outputWithCallBack, ictx, parameterValues);
}
return null;
}

protected org.polarsys.capella.core.data.capellacore.CapellaElement parameter = null;

public void set_parameter(org.polarsys.capella.core.data.capellacore.CapellaElement object) {
this.parameter = object;
}

public Map<String, Object> getParameters() {
final Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("parameter", this.parameter);
return parameters;
}

protected void method_genConstraints(final StringBuffer stringBuffer, final PatternContext ctx) throws Exception {

List<AbstractConstraint> ownedConstraintsList = parameter.getOwnedConstraints();
if (!ownedConstraintsList.isEmpty()) {
String title = "Owned Constraints";

stringBuffer.append(TEXT_1);
{
//<%@ egf:patternCall patternId="platform:/plugin/org.polarsys.capella.docgen/egf/HTMLDocGenCapella.fcore#LogicalName=org.polarsys.capella.docgen.foundations.ConstraintsDocGen" args="parameter:parameter, ownedConstraintsList:constraintsList, title:constraintSectionTitle"%>

InternalPatternContext ictx = (InternalPatternContext) ctx;
new Node.DataLeaf(ictx.getNode(), getClass(), null, stringBuffer.toString());
stringBuffer.setLength(0);

final Map<String, Object> callParameters = new HashMap<String, Object>();
callParameters.put("parameter", parameter);
callParameters.put("constraintsList", ownedConstraintsList);
callParameters.put("constraintSectionTitle", title);
CallHelper.executeWithParameterInjection(
"platform:/plugin/org.polarsys.capella.docgen/egf/HTMLDocGenCapella.fcore#_F9HPoVcEEeWXKstRBeKifA",
new ExecutionContext((InternalPatternContext) ctx), callParameters);
stringBuffer.setLength(0);
}

}

stringBuffer.append(TEXT_2);

List<AbstractConstraint> appledConstraintsList = ConstraintsService.getAppliedAndNotOwnedConstraints(parameter);
if (!appledConstraintsList.isEmpty()) {
String title = "Applied Constraints";

stringBuffer.append(TEXT_2);
{
//<%@ egf:patternCall patternId="platform:/plugin/org.polarsys.capella.docgen/egf/HTMLDocGenCapella.fcore#LogicalName=org.polarsys.capella.docgen.foundations.ConstraintsDocGen" args="parameter:parameter, appledConstraintsList:constraintsList, title:constraintSectionTitle"%>

InternalPatternContext ictx = (InternalPatternContext) ctx;
new Node.DataLeaf(ictx.getNode(), getClass(), null, stringBuffer.toString());
stringBuffer.setLength(0);

final Map<String, Object> callParameters = new HashMap<String, Object>();
callParameters.put("parameter", parameter);
callParameters.put("constraintsList", appledConstraintsList);
callParameters.put("constraintSectionTitle", title);
CallHelper.executeWithParameterInjection(
"platform:/plugin/org.polarsys.capella.docgen/egf/HTMLDocGenCapella.fcore#_F9HPoVcEEeWXKstRBeKifA",
new ExecutionContext((InternalPatternContext) ctx), callParameters);
stringBuffer.setLength(0);
}

}

InternalPatternContext ictx = (InternalPatternContext) ctx;
new Node.DataLeaf(ictx.getNode(), getClass(), "genConstraints", stringBuffer.toString());
}

public boolean preCondition(PatternContext ctx) throws Exception {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Generated with EGF 1.6.1.201906060805
//Generated with EGF 1.6.2.202001031546
package org.polarsys.capella.docgen.foundations;

import org.eclipse.egf.common.helper.*;
Expand All @@ -25,7 +25,6 @@ public static synchronized CapellaElementEndContentDocGen create(String lineSepa
protected final String TEXT_2 = NL + "<h2>Realized Elements</h2>" + NL;
protected final String TEXT_3 = NL;
protected final String TEXT_4 = NL + "<h2>Realizing Elements </h2>" + NL;
protected final String TEXT_5 = NL;

public CapellaElementEndContentDocGen() {
//Here is the constructor
Expand Down Expand Up @@ -122,26 +121,25 @@ protected void method_body(final StringBuffer stringBuffer, final PatternContext
stringBuffer.append(TEXT_3);
}
stringBuffer.append(TEXT_3);
if (element.getOwnedConstraints().isEmpty() == false) {
stringBuffer.append(TEXT_3);
{
//<%@ egf:patternCall patternId="platform:/plugin/org.polarsys.capella.docgen/egf/HTMLDocGenCapella.fcore#LogicalName=org.polarsys.capella.docgen.foundations.ConstraintsDocGen" args="element:parameter"%>

InternalPatternContext ictx = (InternalPatternContext) ctx;
new Node.DataLeaf(ictx.getNode(), getClass(), null, stringBuffer.toString());
stringBuffer.setLength(0);

final Map<String, Object> callParameters = new HashMap<String, Object>();
callParameters.put("parameter", element);
CallHelper.executeWithParameterInjection(
"platform:/plugin/org.polarsys.capella.docgen/egf/HTMLDocGenCapella.fcore#_F9HPoVcEEeWXKstRBeKifA",
new ExecutionContext((InternalPatternContext) ctx), callParameters);
stringBuffer.setLength(0);
}
// All constraints
stringBuffer.append(TEXT_3);
{
//<%@ egf:patternCall patternId="platform:/plugin/org.polarsys.capella.docgen/egf/HTMLDocGenCapella.fcore#LogicalName=org.polarsys.capella.docgen.foundations.AllConstraintsDocGen" args="element:parameter"%>

InternalPatternContext ictx = (InternalPatternContext) ctx;
new Node.DataLeaf(ictx.getNode(), getClass(), null, stringBuffer.toString());
stringBuffer.setLength(0);

final Map<String, Object> callParameters = new HashMap<String, Object>();
callParameters.put("parameter", element);
CallHelper.executeWithParameterInjection(
"platform:/plugin/org.polarsys.capella.docgen/egf/HTMLDocGenCapella.fcore#_MribAMILEeu7XfnfLZ0e8g",
new ExecutionContext((InternalPatternContext) ctx), callParameters);
stringBuffer.setLength(0);
}

stringBuffer.append(TEXT_3);
// Presented in diagrams generation
// Property values
stringBuffer.append(TEXT_3);
{
//<%@ egf:patternCall patternId="platform:/plugin/org.polarsys.capella.docgen/egf/HTMLDocGenCapella.fcore#LogicalName=org.polarsys.capella.docgen.foundations.PropertyValueGen" args="element:element, outputFolder:outputFolder, projectName:projectName"%>
Expand Down Expand Up @@ -214,9 +212,9 @@ protected void method_body(final StringBuffer stringBuffer, final PatternContext
stringBuffer.setLength(0);
}

stringBuffer.append(TEXT_5);
stringBuffer.append(TEXT_3);
// Diagrams navigation tree
stringBuffer.append(TEXT_5);
stringBuffer.append(TEXT_3);
{
//<%@ egf:patternCall patternId="platform:/plugin/org.polarsys.capella.docgen/egf/HTMLDocGenCapella.fcore#LogicalName=org.polarsys.capella.docgen.foundations.DiagramNavigationTree" args="element:element, outputFolder:outputFolder, projectName:projectName"%>

Expand All @@ -234,7 +232,7 @@ protected void method_body(final StringBuffer stringBuffer, final PatternContext
stringBuffer.setLength(0);
}

stringBuffer.append(TEXT_5);
stringBuffer.append(TEXT_3);
InternalPatternContext ictx = (InternalPatternContext) ctx;
new Node.DataLeaf(ictx.getNode(), getClass(), "body", stringBuffer.toString());
}
Expand Down
Loading

0 comments on commit 381d591

Please sign in to comment.