Skip to content

Commit

Permalink
#166 Fix docgen requirements icons
Browse files Browse the repository at this point in the history
  • Loading branch information
arnauddieumegard authored and pdulth committed Jul 21, 2022
1 parent 3f5ca5b commit fa96198
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 114 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Generated with EGF 1.5.1.v20180423-0901
//Generated with EGF 1.6.3.202110291409
package org.polarsys.kitalpha.vp.requirements.docgen.extensions;

import org.eclipse.egf.common.helper.*;
Expand All @@ -11,108 +11,114 @@
import org.polarsys.kitalpha.doc.gen.business.core.extension.page.PageExtensionElement.PageExtensionActivationStatus;

public class RequirementsContent {
protected static String nl;

public static synchronized RequirementsContent create(String lineSeparator) {
nl = lineSeparator;
RequirementsContent result = new RequirementsContent();
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 RequirementsContent() {
//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> elementList = null;
//this pattern can only be called by another (i.e. it's not an entry point in execution)
List<Object> documentTitleList = null;
//this pattern can only be called by another (i.e. it's not an entry point in execution)

for (Object elementParameter : elementList) {
for (Object documentTitleParameter : documentTitleList) {

this.element = (org.eclipse.emf.ecore.EObject) elementParameter;
this.documentTitle = (java.lang.String) documentTitleParameter;

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_1);
stringBuffer.append(TEXT_2);
return stringBuffer.toString();
}

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

method_content(new StringBuffer(), ictx);

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

protected org.eclipse.emf.ecore.EObject element = null;

public void set_element(org.eclipse.emf.ecore.EObject object) {
this.element = object;
}

protected java.lang.String documentTitle = null;

public void set_documentTitle(java.lang.String object) {
this.documentTitle = object;
}

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

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

stringBuffer.append(org.polarsys.kitalpha.vp.requirements.docgen.helper.RequirementHelper
.generateRequirementRelations((org.polarsys.capella.core.data.capellacore.CapellaElement) element));
InternalPatternContext ictx = (InternalPatternContext) ctx;
new Node.DataLeaf(ictx.getNode(), getClass(), "content", stringBuffer.toString());
}

public boolean preCondition(PatternContext ctx) throws Exception {
return PageExtensionRegistry.getInstance().getCategoryActivationStatus("Capella", "Requirement Viewpoint")
.equals(PageExtensionActivationStatus.Active);
}
}
protected static String nl;

public static synchronized RequirementsContent create(String lineSeparator) {
nl = lineSeparator;
RequirementsContent result = new RequirementsContent();
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 RequirementsContent() {
//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> elementList = null;
//this pattern can only be called by another (i.e. it's not an entry point in execution)
List<Object> documentTitleList = null;
//this pattern can only be called by another (i.e. it's not an entry point in execution)

for (Object elementParameter : elementList) {
for (Object documentTitleParameter : documentTitleList) {

this.element = (org.eclipse.emf.ecore.EObject) elementParameter;
this.documentTitle = (java.lang.String) documentTitleParameter;

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_content(new StringBuffer(), ictx);

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

protected org.eclipse.emf.ecore.EObject element = null;

public void set_element(org.eclipse.emf.ecore.EObject object) {
this.element = object;
}

protected java.lang.String documentTitle = null;

public void set_documentTitle(java.lang.String object) {
this.documentTitle = object;
}

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

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

String outputFolder = ctx.getValue("outputFolder").toString();
String projectName = ctx.getValue("projectName").toString();

stringBuffer.append(TEXT_1);
stringBuffer.append(TEXT_2);
stringBuffer.append(org.polarsys.kitalpha.vp.requirements.docgen.helper.RequirementHelper.generateRequirementRelations((org.polarsys.capella.core.data.capellacore.CapellaElement) element,
outputFolder, projectName));
InternalPatternContext ictx = (InternalPatternContext) ctx;
new Node.DataLeaf(ictx.getNode(), getClass(), "content", stringBuffer.toString());
}

public boolean preCondition(PatternContext ctx) throws Exception {
return PageExtensionRegistry.getInstance().getCategoryActivationStatus("Capella", "Requirement Viewpoint").equals(PageExtensionActivationStatus.Active);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public static String genTableRow(boolean header, String... values) {
return sb.toString();
}

public static String generateRequirementRelations(CapellaElement capellaElement) {
public static String generateRequirementRelations(CapellaElement capellaElement, String outputFolder, String projectName) {
StringBuilder builder = new StringBuilder();

List<EObject> incomingRelations = EObjectExt.getReferencers(capellaElement,
Expand All @@ -362,17 +362,17 @@ public static String generateRequirementRelations(CapellaElement capellaElement)
}

if (!incomingRelations.isEmpty()) {
builder.append(generateElementRequirementsIncomingAllocation(incomingRelations));
builder.append(generateElementRequirementsIncomingAllocation(incomingRelations, outputFolder, projectName));
}

if (!outgoingRelations.isEmpty()) {
builder.append(generateElementRequirementsOutgoingAllocation(outgoingRelations));
builder.append(generateElementRequirementsOutgoingAllocation(outgoingRelations, outputFolder, projectName));
}

return builder.toString();
}

public static String generateElementRequirementsIncomingAllocation(List<EObject> incomingRelations) {
public static String generateElementRequirementsIncomingAllocation(List<EObject> incomingRelations, String outputFolder, String projectName) {
StringBuilder builder = new StringBuilder();

if (!incomingRelations.isEmpty()) {
Expand All @@ -382,7 +382,7 @@ public static String generateElementRequirementsIncomingAllocation(List<EObject>
for (EObject eObject : incomingRelations) {
String relationTypeName = getRelationTypeName((AbstractRelation) eObject);
Requirement source = ((CapellaIncomingRelation) eObject).getSource();
String hyperlinkFromElement = RequirementsServices.getHyperlinkFromElement(source);
String hyperlinkFromElement = getImageHyperlinkFromElement(source, projectName, outputFolder, RequirementsServices.NO_TARGET_DEFINED);
builder.append(genTableRow(false, hyperlinkFromElement, relationTypeName));
}
builder.append(RequirementsServices.TABLE_CLOSE).append("</div>");
Expand All @@ -391,7 +391,7 @@ public static String generateElementRequirementsIncomingAllocation(List<EObject>
return builder.toString();
}

public static String generateElementRequirementsOutgoingAllocation(List<EObject> outgoingRelations) {
public static String generateElementRequirementsOutgoingAllocation(List<EObject> outgoingRelations, String outputFolder, String projectName) {
StringBuilder builder = new StringBuilder();

if (!outgoingRelations.isEmpty()) {
Expand All @@ -401,7 +401,7 @@ public static String generateElementRequirementsOutgoingAllocation(List<EObject>
for (EObject eObject : outgoingRelations) {
String relationTypeName = getRelationTypeName((AbstractRelation) eObject);
Requirement target = ((CapellaOutgoingRelation) eObject).getTarget();
String hyperlinkFromElement = RequirementsServices.getHyperlinkFromElement(target);
String hyperlinkFromElement = getImageHyperlinkFromElement(target, projectName, outputFolder, RequirementsServices.NO_TARGET_DEFINED);
builder.append(genTableRow(false, hyperlinkFromElement, relationTypeName));
}
builder.append(RequirementsServices.TABLE_CLOSE).append("</div>");
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<%= org.polarsys.kitalpha.vp.requirements.docgen.helper.RequirementHelper.generateRequirementRelations((org.polarsys.capella.core.data.capellacore.CapellaElement) element)%>
<%
String outputFolder = ctx.getValue("outputFolder").toString();
String projectName = ctx.getValue("projectName").toString();
%>

<%= org.polarsys.kitalpha.vp.requirements.docgen.helper.RequirementHelper.generateRequirementRelations((org.polarsys.capella.core.data.capellacore.CapellaElement) element, outputFolder, projectName)%>

0 comments on commit fa96198

Please sign in to comment.