WOrk to enhance logging of rule execution

This commit is contained in:
Nicolas Héron 2020-07-01 18:42:34 +02:00
commit 174edd8b30
2 changed files with 270 additions and 327 deletions

View file

@ -1,8 +1,13 @@
package org.chtijbug.drools.console.vaadinComponent.componentView; package org.chtijbug.drools.console.vaadinComponent.componentView;
import com.vaadin.flow.component.checkbox.Checkbox; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.grid.Grid; import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.html.Label; import com.vaadin.flow.component.html.Label;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.TextArea;
import com.vaadin.flow.component.textfield.TextField; import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.data.provider.ConfigurableFilterDataProvider; import com.vaadin.flow.data.provider.ConfigurableFilterDataProvider;
import com.vaadin.flow.data.provider.ListDataProvider; import com.vaadin.flow.data.provider.ListDataProvider;
@ -11,6 +16,8 @@ import com.vaadin.flow.data.value.ValueChangeMode;
import com.vaadin.flow.function.SerializablePredicate; import com.vaadin.flow.function.SerializablePredicate;
import org.chtijbug.drools.console.service.IndexerService; import org.chtijbug.drools.console.service.IndexerService;
import org.chtijbug.drools.console.service.util.AppContext; import org.chtijbug.drools.console.service.util.AppContext;
import org.chtijbug.drools.console.vaadinComponent.ComponentPerso.DialogPerso;
import org.chtijbug.drools.logging.Fact;
import org.chtijbug.drools.proxy.persistence.model.BusinessTransactionAction; import org.chtijbug.drools.proxy.persistence.model.BusinessTransactionAction;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
@ -31,7 +38,6 @@ public class GridActionLogging extends Grid<BusinessTransactionAction> {
private TextField ruleFlowGroup; private TextField ruleFlowGroup;
private String strEventType = "EventType"; private String strEventType = "EventType";
private String strPositionExecution = "Position"; private String strPositionExecution = "Position";
@ -40,7 +46,8 @@ public class GridActionLogging extends Grid<BusinessTransactionAction> {
private String strPackageName = "Package"; private String strPackageName = "Package";
private String strRuleFlowGroup="RuleFlouwGroup"; private String strRuleFlowGroup = "RuleFlowGroup";
private ObjectMapper mapper = new ObjectMapper();
private ListDataProvider<BusinessTransactionAction> dataProvider; private ListDataProvider<BusinessTransactionAction> dataProvider;
private ConfigurableFilterDataProvider<BusinessTransactionAction, Void, SerializablePredicate<BusinessTransactionAction>> filterDataProvider; private ConfigurableFilterDataProvider<BusinessTransactionAction, Void, SerializablePredicate<BusinessTransactionAction>> filterDataProvider;
@ -53,27 +60,27 @@ public class GridActionLogging extends Grid<BusinessTransactionAction> {
setClassName("action-log-grid-perso"); setClassName("action-log-grid-perso");
setSelectionMode(Grid.SelectionMode.SINGLE); setSelectionMode(Grid.SelectionMode.SINGLE);
setVerticalScrollingEnabled(true);
addColumn(new ComponentRenderer<>(runtimePersist -> { addColumn(new ComponentRenderer<>(runtimePersist -> {
SimpleDateFormat simpleDateFormat=new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
Label label = new Label(); Label label = new Label();
if (runtimePersist.getRuleExecution() != null) { if (runtimePersist.getRuleExecution() != null) {
label.setText(simpleDateFormat.format(runtimePersist.getRuleExecution().getStartDate())); label.setText(simpleDateFormat.format(runtimePersist.getRuleExecution().getStartDate()));
} }
return label; return label;
})).setHeader("Début"); })).setHeader("Début").setResizable(true);
addColumn(new ComponentRenderer<>(runtimePersist -> { addColumn(new ComponentRenderer<>(runtimePersist -> {
SimpleDateFormat simpleDateFormat=new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
Label label = new Label(); Label label = new Label();
if (runtimePersist.getRuleExecution() != null) { if (runtimePersist.getRuleExecution() != null) {
label.setText(simpleDateFormat.format(runtimePersist.getRuleExecution().getEndDate())); label.setText(simpleDateFormat.format(runtimePersist.getRuleExecution().getEndDate()));
} }
return label; return label;
})).setHeader("Fin"); })).setHeader("Fin").setResizable(true);
Grid.Column<BusinessTransactionAction> enventTypeC = addColumn(runtimePersist -> runtimePersist.getEventType()); Grid.Column<BusinessTransactionAction> enventTypeC = addColumn(runtimePersist -> runtimePersist.getEventType());
@ -82,7 +89,7 @@ public class GridActionLogging extends Grid<BusinessTransactionAction> {
this.eventType.addValueChangeListener(e -> { this.eventType.addValueChangeListener(e -> {
refreshtGrid(this.eventType.getValue(), strEventType); refreshtGrid(this.eventType.getValue(), strEventType);
}); });
enventTypeC.setHeader(this.eventType); enventTypeC.setHeader(this.eventType).setResizable(true);
Grid.Column<BusinessTransactionAction> positionC = addColumn(runtimePersist -> runtimePersist.getEventNumber()); Grid.Column<BusinessTransactionAction> positionC = addColumn(runtimePersist -> runtimePersist.getEventNumber());
@ -91,7 +98,7 @@ public class GridActionLogging extends Grid<BusinessTransactionAction> {
positionExecution.addValueChangeListener(e -> { positionExecution.addValueChangeListener(e -> {
refreshtGrid(positionExecution.getValue(), strPositionExecution); refreshtGrid(positionExecution.getValue(), strPositionExecution);
}); });
positionC.setHeader(positionExecution); positionC.setHeader(positionExecution).setResizable(true);
positionC.setWidth("3%"); positionC.setWidth("3%");
Grid.Column<BusinessTransactionAction> ruleNameC = addColumn(runtimePersist -> runtimePersist.getRuleExecution() != null ? runtimePersist.getRuleExecution().getRuleName() : ""); Grid.Column<BusinessTransactionAction> ruleNameC = addColumn(runtimePersist -> runtimePersist.getRuleExecution() != null ? runtimePersist.getRuleExecution().getRuleName() : "");
@ -100,7 +107,7 @@ public class GridActionLogging extends Grid<BusinessTransactionAction> {
ruleName.addValueChangeListener(e -> { ruleName.addValueChangeListener(e -> {
refreshtGrid(ruleName.getValue(), strRuleName); refreshtGrid(ruleName.getValue(), strRuleName);
}); });
ruleNameC.setHeader(ruleName); ruleNameC.setHeader(ruleName).setResizable(true);
Grid.Column<BusinessTransactionAction> versionC = addColumn(runtimePersist -> runtimePersist.getRuleExecution() != null ? runtimePersist.getRuleExecution().getPackageName() : ""); Grid.Column<BusinessTransactionAction> versionC = addColumn(runtimePersist -> runtimePersist.getRuleExecution() != null ? runtimePersist.getRuleExecution().getPackageName() : "");
packageName = new TextField(strPackageName); packageName = new TextField(strPackageName);
@ -108,7 +115,7 @@ public class GridActionLogging extends Grid<BusinessTransactionAction> {
packageName.addValueChangeListener(e -> { packageName.addValueChangeListener(e -> {
refreshtGrid(packageName.getValue(), strPackageName); refreshtGrid(packageName.getValue(), strPackageName);
}); });
versionC.setHeader(packageName); versionC.setHeader(packageName).setResizable(true);
Grid.Column<BusinessTransactionAction> ruleflowC = addColumn(runtimePersist -> runtimePersist.getRuleflowGroupName() != null ? runtimePersist.getRuleflowGroupName() : ""); Grid.Column<BusinessTransactionAction> ruleflowC = addColumn(runtimePersist -> runtimePersist.getRuleflowGroupName() != null ? runtimePersist.getRuleflowGroupName() : "");
ruleFlowGroup = new TextField(strRuleFlowGroup); ruleFlowGroup = new TextField(strRuleFlowGroup);
@ -116,36 +123,231 @@ public class GridActionLogging extends Grid<BusinessTransactionAction> {
ruleFlowGroup.addValueChangeListener(e -> { ruleFlowGroup.addValueChangeListener(e -> {
refreshtGrid(ruleFlowGroup.getValue(), strRuleFlowGroup); refreshtGrid(ruleFlowGroup.getValue(), strRuleFlowGroup);
}); });
ruleflowC.setHeader(ruleFlowGroup); ruleflowC.setHeader(ruleFlowGroup).setResizable(true);
addColumn(new ComponentRenderer<>(runtimePersist -> { addColumn(new ComponentRenderer<>(runtimePersist -> {
HorizontalLayout horizontalLayout = new HorizontalLayout();
Checkbox label=new Checkbox();
label.setEnabled(false);
label.setValue(false);
if (runtimePersist.getInputData() != null && runtimePersist.getInputData().getRealFact() != null) { if (runtimePersist.getInputData() != null && runtimePersist.getInputData().getRealFact() != null) {
label.setValue(true); Button inputData = new Button("Input data");
inputData.setClassName("menu-button");
inputData.setEnabled(true);
inputData.addClickListener(buttonClickEvent -> {
DialogPerso dialogPerso1 = new DialogPerso();
BusinessTransactionAction b = runtimePersist;
if (b != null && b.getInputData() != null && b.getInputData().getRealFact() != null) {
VerticalLayout verticalLayout = new VerticalLayout();
Label label = new Label(b.getEventType().name() );
label.setClassName("creation-runtime-title");
verticalLayout.add(label);
verticalLayout.setClassName("content-action-logging");
TextArea textArea = new TextArea(b.getInputData().getFactType().name()+"-"+b.getInputData().getFullClassName());
textArea.setReadOnly(true);
textArea.setClassName("content-log");
try {
String text = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(b.getInputData().getRealFact());
textArea.setValue(text);
} catch (JsonProcessingException e) {
textArea.setValue(
b.getInputData().getRealFact().toString().replaceAll(",", ",\n")
.replaceAll("\\{", "\\{\n")
.replaceAll("\\}", "\n\\}")
.replaceAll("\\[", "\n\\[")
);
}
verticalLayout.add(textArea);
dialogPerso1.add(verticalLayout);
}
dialogPerso1.open();
});
horizontalLayout.add(inputData);
} }
if (runtimePersist.getFact() != null && runtimePersist.getFact().getRealFact() != null) { if (runtimePersist.getFact() != null && runtimePersist.getFact().getRealFact() != null) {
label.setValue(true); Button realFact = new Button("Insert Data");
realFact.setClassName("menu-button");
realFact.setEnabled(true);
realFact.addClickListener(buttonClickEvent -> {
DialogPerso dialogPerso1 = new DialogPerso();
BusinessTransactionAction b = runtimePersist;
if (b != null && b.getFact() != null && b.getFact().getRealFact() != null) {
VerticalLayout verticalLayout = new VerticalLayout();
Label label = new Label(b.getEventType().name());
label.setClassName("creation-runtime-title");
verticalLayout.add(label);
verticalLayout.setClassName("content-action-logging");
TextArea textArea = new TextArea(b.getFact().getFactType().name()+"-"+b.getFact().getFullClassName());
textArea.setReadOnly(true);
textArea.setClassName("content-log");
try {
String text = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(b.getFact().getRealFact());
textArea.setValue(text);
} catch (JsonProcessingException e) {
textArea.setValue(
b.getFact().getRealFact().toString().replaceAll(",", ",\n")
.replaceAll("\\{", "\\{\n")
.replaceAll("\\}", "\n\\}")
.replaceAll("\\[", "\n\\[")
);
}
verticalLayout.add(textArea);
dialogPerso1.add(verticalLayout);
}
dialogPerso1.open();
});
horizontalLayout.add(realFact);
} }
if (runtimePersist.getRuleExecution() != null && runtimePersist.getRuleExecution().getThenFacts() != null && runtimePersist.getRuleExecution().getThenFacts().size() > 0) { if (runtimePersist.getRuleExecution() != null && runtimePersist.getRuleExecution().getThenFacts() != null && runtimePersist.getRuleExecution().getThenFacts().size() > 0) {
label.setValue(true); Button whenFact = new Button("When Data");
} whenFact.setClassName("menu-button");
if(runtimePersist.getRuleExecution()!=null&&runtimePersist.getRuleExecution().getWhenFacts()!=null&&runtimePersist.getRuleExecution().getWhenFacts().size()>0){ whenFact.setEnabled(true);
label.setValue(true); whenFact.addClickListener(buttonClickEvent -> {
} DialogPerso dialogPerso1 = new DialogPerso();
return label;
})).setHeader("Data?");
BusinessTransactionAction b = runtimePersist;
if (b != null && b.getRuleExecution() != null && b.getRuleExecution().getWhenFacts() != null) {
VerticalLayout verticalLayout = new VerticalLayout();
Label label = new Label(b.getEventType().name() + " - " + (b.getRuleExecution() != null && b.getRuleExecution().getRuleName() != null ? b.getRuleExecution().getRuleName() : ""));
label.setClassName("creation-runtime-title");
verticalLayout.add(label);
verticalLayout.setClassName("content-action-logging");
for (Fact fact : b.getRuleExecution().getWhenFacts()) {
if (fact != null && fact.getRealFact() != null) {
TextArea textArea = new TextArea(fact.getFactType().name()+"-"+fact.getFullClassName());
textArea.setReadOnly(true);
textArea.setClassName("content-log");
try {
String text = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(fact.getRealFact());
textArea.setValue(text);
} catch (JsonProcessingException e) {
textArea.setValue(
fact.getRealFact().toString().replaceAll(",", ",\n")
.replaceAll("\\{", "\\{\n")
.replaceAll("\\}", "\n\\}")
.replaceAll("\\[", "\n\\[")
);
}
verticalLayout.add(textArea);
}
}
dialogPerso1.add(verticalLayout);
}
dialogPerso1.open();
});
horizontalLayout.add(whenFact);
}
if (runtimePersist.getRuleExecution() != null && runtimePersist.getRuleExecution().getThenFacts() != null && runtimePersist.getRuleExecution().getThenFacts().size() > 0) {
Button thenFact = new Button("Then data");
thenFact.setClassName("menu-button");
thenFact.setEnabled(true);
thenFact.addClickListener(buttonClickEvent -> {
DialogPerso dialogPerso1 = new DialogPerso();
BusinessTransactionAction b = runtimePersist;
if (b != null && b.getRuleExecution() != null && b.getRuleExecution().getThenFacts() != null) {
VerticalLayout verticalLayout = new VerticalLayout();
Label label = new Label(b.getEventType().name() + " - " + (b.getRuleExecution() != null && b.getRuleExecution().getRuleName() != null ? b.getRuleExecution().getRuleName() : ""));
label.setClassName("creation-runtime-title");
verticalLayout.add(label);
verticalLayout.setClassName("content-action-logging");
for (Fact fact : b.getRuleExecution().getThenFacts()) {
if (fact != null && fact.getRealFact() != null) {
TextArea textArea = new TextArea(fact.getFactType().name()+"-"+fact.getFullClassName());
textArea.setReadOnly(true);
textArea.setClassName("content-log");
try {
String text = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(fact.getRealFact());
textArea.setValue(text);
} catch (JsonProcessingException e) {
textArea.setValue(
fact.getRealFact().toString().replaceAll(",", ",\n")
.replaceAll("\\{", "\\{\n")
.replaceAll("\\}", "\n\\}")
.replaceAll("\\[", "\n\\[")
);
}
verticalLayout.add(textArea);
}
}
dialogPerso1.add(verticalLayout);
}
dialogPerso1.open();
});
horizontalLayout.add(thenFact);
}
if (runtimePersist.getOutputData() != null && runtimePersist.getOutputData().getRealFact() != null) {
Button outputData = new Button("Output data");
outputData.setClassName("menu-button");
outputData.setEnabled(true);
outputData.addClickListener(buttonClickEvent -> {
DialogPerso dialogPerso1 = new DialogPerso();
BusinessTransactionAction b = runtimePersist;
if (b != null && b.getOutputData() != null && b.getOutputData().getRealFact() != null) {
VerticalLayout verticalLayout = new VerticalLayout();
Label label = new Label(b.getEventType().name() );
label.setClassName("creation-runtime-title");
verticalLayout.add(label);
verticalLayout.setClassName("content-action-logging");
TextArea textArea = new TextArea(b.getOutputData().getFactType().name()+"-"+b.getOutputData().getFullClassName());
textArea.setReadOnly(true);
textArea.setClassName("content-log");
try {
String text = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(b.getOutputData().getRealFact());
textArea.setValue(text);
} catch (JsonProcessingException e) {
textArea.setValue(
b.getOutputData().getRealFact().toString().replaceAll(",", ",\n")
.replaceAll("\\{", "\\{\n")
.replaceAll("\\}", "\n\\}")
.replaceAll("\\[", "\n\\[")
);
}
verticalLayout.add(textArea);
dialogPerso1.add(verticalLayout);
}
dialogPerso1.open();
});
horizontalLayout.add(outputData);
}
return horizontalLayout;
})).setHeader("Action");
setDataProvider(idRequest); setDataProvider(idRequest);
} }
private void refreshtGrid(String value, String type) { private void refreshtGrid(String value, String type) {
filterDataProvider.setFilter(filterGrid(value.toUpperCase(), type)); filterDataProvider.setFilter(filterGrid(value.toUpperCase(), type));
getDataProvider().refreshAll(); getDataProvider().refreshAll();
} }
private SerializablePredicate<BusinessTransactionAction> filterGrid(String value, String type) { private SerializablePredicate<BusinessTransactionAction> filterGrid(String value, String type) {
SerializablePredicate<BusinessTransactionAction> columnPredicate = null; SerializablePredicate<BusinessTransactionAction> columnPredicate = null;
if (value.equals(" ") || type.equals(" ")) { if (value.equals(" ") || type.equals(" ")) {
@ -159,11 +361,9 @@ public class GridActionLogging extends Grid<BusinessTransactionAction> {
} else if (type.equals(strRuleName)) { } else if (type.equals(strRuleName)) {
columnPredicate = runtimePersist -> (runtimePersist.getRuleExecution() != null && runtimePersist.getRuleExecution().getRuleName() != null && runtimePersist.getRuleExecution().getRuleName().toUpperCase().contains(value)); columnPredicate = runtimePersist -> (runtimePersist.getRuleExecution() != null && runtimePersist.getRuleExecution().getRuleName() != null && runtimePersist.getRuleExecution().getRuleName().toUpperCase().contains(value));
} } else if (type.equals(strPackageName)) {
else if (type.equals(strPackageName)) {
columnPredicate = runtimePersist -> (runtimePersist.getRuleExecution() != null && runtimePersist.getRuleExecution().getPackageName() != null && runtimePersist.getRuleExecution().getPackageName().toUpperCase().contains(value)); columnPredicate = runtimePersist -> (runtimePersist.getRuleExecution() != null && runtimePersist.getRuleExecution().getPackageName() != null && runtimePersist.getRuleExecution().getPackageName().toUpperCase().contains(value));
} } else if (type.equals(strRuleFlowGroup)) {
else if (type.equals(strRuleFlowGroup)) {
columnPredicate = runtimePersist -> (runtimePersist.getRuleflowGroupName() != null && runtimePersist.getRuleflowGroupName().toUpperCase().contains(value)); columnPredicate = runtimePersist -> (runtimePersist.getRuleflowGroupName() != null && runtimePersist.getRuleflowGroupName().toUpperCase().contains(value));
} }
@ -185,6 +385,7 @@ public class GridActionLogging extends Grid<BusinessTransactionAction> {
} }
} }
public void reinitFilter() { public void reinitFilter() {
positionExecution.setValue(""); positionExecution.setValue("");
ruleName.setValue(""); ruleName.setValue("");

View file

@ -1,15 +1,9 @@
package org.chtijbug.drools.console.view; package org.chtijbug.drools.console.view;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.html.Label; import com.vaadin.flow.component.html.Label;
import com.vaadin.flow.component.orderedlayout.VerticalLayout; import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.TextArea;
import org.chtijbug.drools.console.vaadinComponent.ComponentPerso.DialogPerso; import org.chtijbug.drools.console.vaadinComponent.ComponentPerso.DialogPerso;
import org.chtijbug.drools.console.vaadinComponent.componentView.GridActionLogging; import org.chtijbug.drools.console.vaadinComponent.componentView.GridActionLogging;
import org.chtijbug.drools.logging.Fact;
import org.chtijbug.drools.proxy.persistence.model.BusinessTransactionAction;
import org.chtijbug.drools.proxy.persistence.model.BusinessTransactionPersistence; import org.chtijbug.drools.proxy.persistence.model.BusinessTransactionPersistence;
@ -19,52 +13,14 @@ public class ActionLoggingView extends VerticalLayout {
private GridActionLogging gridActionLogging; private GridActionLogging gridActionLogging;
private Button inputData;
private Button realFact;
private Button whenFact;
private Button thenFact;
private Button outputData;
private ObjectMapper mapper = new ObjectMapper();
public ActionLoggingView(BusinessTransactionPersistence businessTransactionPersistence, DialogPerso dialogPerso){ public ActionLoggingView(BusinessTransactionPersistence businessTransactionPersistence, DialogPerso dialogPerso){
dialogPerso.getClose().setVisible(false); dialogPerso.getClose().setVisible(false);
//Text text = new Text("Sessino Context ");
//dialogPerso.getBar().add(text);
inputData=new Button("View InputData");
inputData.setClassName("menu-button");
inputData.setEnabled(false);
dialogPerso.getBar().add(inputData);
realFact=new Button("View RealFact");
realFact.setClassName("menu-button");
realFact.setEnabled(false);
dialogPerso.getBar().add(realFact);
whenFact=new Button("View WhenFact");
whenFact.setClassName("menu-button");
whenFact.setEnabled(false);
dialogPerso.getBar().add(whenFact);
thenFact=new Button("View ThenFact");
thenFact.setClassName("menu-button");
thenFact.setEnabled(false);
dialogPerso.getBar().add(thenFact);
outputData=new Button("View OutputData");
outputData.setClassName("menu-button");
outputData.setEnabled(false);
dialogPerso.getBar().add(outputData);
title=new Label("TransactionID : "+businessTransactionPersistence.getId()); title=new Label("TransactionID : "+businessTransactionPersistence.getId());
title.setClassName("creation-runtime-title"); title.setClassName("creation-runtime-title");
@ -75,223 +31,9 @@ public class ActionLoggingView extends VerticalLayout {
gridActionLogging=new GridActionLogging(businessTransactionPersistence.getId()); gridActionLogging=new GridActionLogging(businessTransactionPersistence.getId());
add(gridActionLogging); add(gridActionLogging);
gridActionLogging.addSelectionListener(selectionEvent -> {
BusinessTransactionAction b=gridActionLogging.getSelectedItems().stream().findFirst().get();
if(b!=null){
if(b.getInputData()!=null&&b.getInputData().getRealFact()!=null){
inputData.setEnabled(true);
}else {
inputData.setEnabled(false);
}
if(b.getFact()!=null&&b.getFact().getRealFact()!=null){
realFact.setEnabled(true);
}else {
realFact.setEnabled(false);
}
if(b.getRuleExecution()!=null&&b.getRuleExecution().getThenFacts()!=null&&b.getRuleExecution().getThenFacts().size()>0){
thenFact.setEnabled(true);
}else {
thenFact.setEnabled(false);
}
if(b.getRuleExecution()!=null&&b.getRuleExecution().getWhenFacts()!=null&&b.getRuleExecution().getWhenFacts().size()>0){
whenFact.setEnabled(true);
}else {
whenFact.setEnabled(false);
}
if(b.getOutputData()!=null&&b.getOutputData().getRealFact()!=null){
outputData.setEnabled(true);
}else {
outputData.setEnabled(false);
}
} }
});
inputData.addClickListener(buttonClickEvent -> {
DialogPerso dialogPerso1=new DialogPerso();
BusinessTransactionAction b=gridActionLogging.getSelectedItems().stream().findFirst().get();
if(b!=null&&b.getInputData()!=null&&b.getInputData().getRealFact()!=null){
VerticalLayout verticalLayout=new VerticalLayout();
Label label=new Label(b.getEventType().name()+" - "+(b.getRuleExecution()!=null&&b.getRuleExecution().getRuleName()!=null?b.getRuleExecution().getRuleName():""));
label.setClassName("creation-runtime-title");
verticalLayout.add(label);
verticalLayout.setClassName("content-action-logging");
TextArea textArea=new TextArea(b.getInputData().getFactType().name());
textArea.setReadOnly(true);
textArea.setClassName("content-log");
try {
String text = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(b.getInputData().getRealFact());
textArea.setValue(text);
} catch (JsonProcessingException e) {
textArea.setValue(
b.getInputData().getRealFact().toString().replaceAll(",",",\n")
.replaceAll("\\{","\\{\n")
.replaceAll("\\}","\n\\}")
.replaceAll("\\[","\n\\[")
);
}
verticalLayout.add(textArea);
dialogPerso1.add(verticalLayout);
}
dialogPerso1.open();
});
realFact.addClickListener(buttonClickEvent -> {
DialogPerso dialogPerso1=new DialogPerso();
BusinessTransactionAction b=gridActionLogging.getSelectedItems().stream().findFirst().get();
if(b!=null&&b.getFact()!=null&&b.getFact().getRealFact()!=null){
VerticalLayout verticalLayout=new VerticalLayout();
Label label=new Label(b.getEventType().name()+" - "+(b.getRuleExecution()!=null&&b.getRuleExecution().getRuleName()!=null?b.getRuleExecution().getRuleName():""));
label.setClassName("creation-runtime-title");
verticalLayout.add(label);
verticalLayout.setClassName("content-action-logging");
TextArea textArea=new TextArea(b.getFact().getFactType().name());
textArea.setReadOnly(true);
textArea.setClassName("content-log");
try {
String text = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(b.getFact().getRealFact());
textArea.setValue(text);
} catch (JsonProcessingException e) {
textArea.setValue(
b.getFact().getRealFact().toString().replaceAll(",",",\n")
.replaceAll("\\{","\\{\n")
.replaceAll("\\}","\n\\}")
.replaceAll("\\[","\n\\[")
);
}
verticalLayout.add(textArea);
dialogPerso1.add(verticalLayout);
}
dialogPerso1.open();
});
thenFact.addClickListener(buttonClickEvent -> {
DialogPerso dialogPerso1=new DialogPerso();
BusinessTransactionAction b=gridActionLogging.getSelectedItems().stream().findFirst().get();
if(b!=null&&b.getRuleExecution()!=null&&b.getRuleExecution().getThenFacts()!=null){
VerticalLayout verticalLayout=new VerticalLayout();
Label label=new Label(b.getEventType().name()+" - "+(b.getRuleExecution()!=null&&b.getRuleExecution().getRuleName()!=null?b.getRuleExecution().getRuleName():""));
label.setClassName("creation-runtime-title");
verticalLayout.add(label);
verticalLayout.setClassName("content-action-logging");
for (Fact fact:b.getRuleExecution().getThenFacts()){
if(fact!=null&&fact.getRealFact()!=null){
TextArea textArea=new TextArea(fact.getFactType().name());
textArea.setReadOnly(true);
textArea.setClassName("content-log");
try {
String text = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(fact.getRealFact());
textArea.setValue(text);
} catch (JsonProcessingException e) {
textArea.setValue(
fact.getRealFact().toString().replaceAll(",",",\n")
.replaceAll("\\{","\\{\n")
.replaceAll("\\}","\n\\}")
.replaceAll("\\[","\n\\[")
);
}
verticalLayout.add(textArea);
}
}
dialogPerso1.add(verticalLayout);
}
dialogPerso1.open();
});
whenFact.addClickListener(buttonClickEvent -> {
DialogPerso dialogPerso1=new DialogPerso();
BusinessTransactionAction b=gridActionLogging.getSelectedItems().stream().findFirst().get();
if(b!=null&&b.getRuleExecution()!=null&&b.getRuleExecution().getWhenFacts()!=null){
VerticalLayout verticalLayout=new VerticalLayout();
Label label=new Label(b.getEventType().name()+" - "+(b.getRuleExecution()!=null&&b.getRuleExecution().getRuleName()!=null?b.getRuleExecution().getRuleName():""));
label.setClassName("creation-runtime-title");
verticalLayout.add(label);
verticalLayout.setClassName("content-action-logging");
for (Fact fact:b.getRuleExecution().getWhenFacts()){
if(fact!=null&&fact.getRealFact()!=null){
TextArea textArea=new TextArea(fact.getFactType().name());
textArea.setReadOnly(true);
textArea.setClassName("content-log");
try {
String text = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(fact.getRealFact());
textArea.setValue(text);
} catch (JsonProcessingException e) {
textArea.setValue(
fact.getRealFact().toString().replaceAll(",",",\n")
.replaceAll("\\{","\\{\n")
.replaceAll("\\}","\n\\}")
.replaceAll("\\[","\n\\[")
);
}
verticalLayout.add(textArea);
}
}
dialogPerso1.add(verticalLayout);
}
dialogPerso1.open();
});
outputData.addClickListener(buttonClickEvent -> {
DialogPerso dialogPerso1=new DialogPerso();
BusinessTransactionAction b=gridActionLogging.getSelectedItems().stream().findFirst().get();
if(b!=null&&b.getOutputData()!=null&&b.getOutputData().getRealFact()!=null){
VerticalLayout verticalLayout=new VerticalLayout();
Label label=new Label(b.getEventType().name()+" - "+(b.getRuleExecution()!=null&&b.getRuleExecution().getRuleName()!=null?b.getRuleExecution().getRuleName():""));
label.setClassName("creation-runtime-title");
verticalLayout.add(label);
verticalLayout.setClassName("content-action-logging");
TextArea textArea=new TextArea(b.getOutputData().getFactType().name());
textArea.setReadOnly(true);
textArea.setClassName("content-log");
try {
String text = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(b.getOutputData().getRealFact());
textArea.setValue(text);
} catch (JsonProcessingException e) {
textArea.setValue(
b.getOutputData().getRealFact().toString().replaceAll(",",",\n")
.replaceAll("\\{","\\{\n")
.replaceAll("\\}","\n\\}")
.replaceAll("\\[","\n\\[")
);
}
verticalLayout.add(textArea);
dialogPerso1.add(verticalLayout);
}
dialogPerso1.open();
});
}
} }