Refactoring for running in a docker swarm cluster
and upgrade to version 7.28.0
This commit is contained in:
parent
30600ac30e
commit
e2c87e9d20
15 changed files with 254 additions and 117 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package org.chtijbug.drools.console.vaadinComponent.componentView;
|
||||
|
||||
import com.vaadin.flow.component.grid.Grid;
|
||||
import com.vaadin.flow.component.html.Label;
|
||||
import com.vaadin.flow.component.textfield.TextField;
|
||||
import com.vaadin.flow.data.provider.ConfigurableFilterDataProvider;
|
||||
import com.vaadin.flow.data.provider.ListDataProvider;
|
||||
|
|
@ -12,10 +13,11 @@ import org.chtijbug.drools.console.service.RuntimeService;
|
|||
import org.chtijbug.drools.console.service.util.AppContext;
|
||||
import org.chtijbug.drools.proxy.persistence.model.ProjectPersist;
|
||||
import org.chtijbug.drools.proxy.persistence.model.RuntimePersist;
|
||||
import com.vaadin.flow.component.html.Label;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class GridRuntime extends Grid<RuntimePersist> {
|
||||
|
||||
|
|
@ -27,31 +29,26 @@ public class GridRuntime extends Grid<RuntimePersist> {
|
|||
|
||||
private TextField status;
|
||||
|
||||
private String strRuntimeName="Runtime Name";
|
||||
private String strRuntimeName = "Runtime Name";
|
||||
|
||||
private String strHostName="Hostname";
|
||||
private String strHostName = "Hostname";
|
||||
|
||||
private String strVersion="Version";
|
||||
private String strVersion = "Version";
|
||||
|
||||
private String strStatus="State";
|
||||
private String strStatus = "State";
|
||||
|
||||
private ProjectPersistService projectPersistService;
|
||||
private RuntimeService runtimeService;
|
||||
|
||||
private ListDataProvider<RuntimePersist> dataProvider;
|
||||
private ConfigurableFilterDataProvider<RuntimePersist,Void,SerializablePredicate<RuntimePersist>> filterDataProvider;
|
||||
private ConfigurableFilterDataProvider<RuntimePersist, Void, SerializablePredicate<RuntimePersist>> filterDataProvider;
|
||||
|
||||
private ProjectPersist projectPersist;
|
||||
private ProjectPersist projectPersist = null;
|
||||
|
||||
public GridRuntime(ProjectPersist projectPersist){
|
||||
public GridRuntime(ProjectPersist projectPersist) {
|
||||
this.projectPersist = projectPersist;
|
||||
init();
|
||||
//dataProvider.get
|
||||
for (RuntimePersist runtimePersist : dataProvider.getItems()){
|
||||
if (projectPersist.getServerNames().contains(runtimePersist.getServerName())){
|
||||
getSelectionModel().select(runtimePersist);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -59,38 +56,39 @@ public class GridRuntime extends Grid<RuntimePersist> {
|
|||
init();
|
||||
|
||||
}
|
||||
private void init(){
|
||||
|
||||
private void init() {
|
||||
projectPersistService = AppContext.getApplicationContext().getBean(ProjectPersistService.class);
|
||||
runtimeService= AppContext.getApplicationContext().getBean(RuntimeService.class);
|
||||
runtimeService = AppContext.getApplicationContext().getBean(RuntimeService.class);
|
||||
|
||||
setClassName("deployment-grid-perso");
|
||||
setSelectionMode(Grid.SelectionMode.MULTI);
|
||||
|
||||
Grid.Column<RuntimePersist> runtimeNameCo=addColumn(runtimePersist -> runtimePersist.getServerName());
|
||||
runtimeName=new TextField(strRuntimeName);
|
||||
Grid.Column<RuntimePersist> runtimeNameCo = addColumn(runtimePersist -> runtimePersist.getServerName());
|
||||
runtimeName = new TextField(strRuntimeName);
|
||||
runtimeName.setValueChangeMode(ValueChangeMode.EAGER);
|
||||
runtimeName.addValueChangeListener(e -> {
|
||||
refreshtGrid(runtimeName.getValue(), strRuntimeName);
|
||||
});
|
||||
runtimeNameCo.setHeader(runtimeName);
|
||||
|
||||
Grid.Column<RuntimePersist> hostnameCo=addColumn(runtimePersist -> runtimePersist.getHostname());
|
||||
hostName=new TextField(strHostName);
|
||||
Grid.Column<RuntimePersist> hostnameCo = addColumn(runtimePersist -> runtimePersist.getServerUrl());
|
||||
hostName = new TextField(strHostName);
|
||||
hostName.setValueChangeMode(ValueChangeMode.EAGER);
|
||||
hostName.addValueChangeListener(e -> {
|
||||
refreshtGrid(hostName.getValue(), strHostName);
|
||||
});
|
||||
hostnameCo.setHeader(hostName);
|
||||
|
||||
Grid.Column<RuntimePersist> versionCo=addColumn(runtimePersist -> runtimePersist.getVersion());
|
||||
version=new TextField(strVersion);
|
||||
Grid.Column<RuntimePersist> versionCo = addColumn(runtimePersist -> runtimePersist.getVersion());
|
||||
version = new TextField(strVersion);
|
||||
version.setValueChangeMode(ValueChangeMode.EAGER);
|
||||
version.addValueChangeListener(e -> {
|
||||
refreshtGrid(version.getValue(), strVersion);
|
||||
});
|
||||
versionCo.setHeader(version);
|
||||
Grid.Column<RuntimePersist> statusCo=addColumn(runtimePersist -> runtimePersist.getStatus());
|
||||
status=new TextField(strStatus);
|
||||
Grid.Column<RuntimePersist> statusCo = addColumn(runtimePersist -> runtimePersist.getStatus());
|
||||
status = new TextField(strStatus);
|
||||
status.setValueChangeMode(ValueChangeMode.EAGER);
|
||||
status.addValueChangeListener(e -> {
|
||||
refreshtGrid(status.getValue(), strVersion);
|
||||
|
|
@ -100,44 +98,67 @@ public class GridRuntime extends Grid<RuntimePersist> {
|
|||
addColumn(new ComponentRenderer<>(runtimePersist -> {
|
||||
List<String> serverList = new ArrayList<>();
|
||||
serverList.add(runtimePersist.getServerName());
|
||||
List<ProjectPersist> projectPersists=projectPersistService.getProjectRepository().findByServerNamesIn(serverList);
|
||||
List<ProjectPersist> projectPersists = projectPersistService.getProjectRepository().findByServerNamesIn(serverList);
|
||||
|
||||
Label label=new Label(projectPersists!=null?projectPersists.size()+"":"0");
|
||||
Label label = new Label(projectPersists != null ? projectPersists.size() + "" : "0");
|
||||
|
||||
return label;
|
||||
})).setHeader("associated projects");
|
||||
|
||||
setDataProvider();
|
||||
}
|
||||
private void refreshtGrid(String value,String type){
|
||||
|
||||
filterDataProvider.setFilter(filterGrid(value.toUpperCase(),type));
|
||||
private void refreshtGrid(String value, String type) {
|
||||
|
||||
filterDataProvider.setFilter(filterGrid(value.toUpperCase(), type));
|
||||
getDataProvider().refreshAll();
|
||||
}
|
||||
private SerializablePredicate<RuntimePersist> filterGrid(String value, String type){
|
||||
|
||||
private SerializablePredicate<RuntimePersist> filterGrid(String value, String type) {
|
||||
SerializablePredicate<RuntimePersist> columnPredicate = null;
|
||||
if(value.equals(" ")||type.equals(" ")){
|
||||
if (value.equals(" ") || type.equals(" ")) {
|
||||
columnPredicate = runtimePersist -> (true);
|
||||
}else {
|
||||
} else {
|
||||
if (type.equals(strHostName)) {
|
||||
columnPredicate = runtimePersist -> (runtimePersist.getHostname()!=null&&runtimePersist.getHostname().toUpperCase().contains(value));
|
||||
columnPredicate = runtimePersist -> (runtimePersist.getServerUrl() != null && runtimePersist.getServerUrl().toUpperCase().contains(value));
|
||||
|
||||
} else if (type.equals(strRuntimeName)) {
|
||||
columnPredicate = runtimePersist -> (runtimePersist.getServerName()!=null&&runtimePersist.getServerName().toUpperCase().contains(value));
|
||||
columnPredicate = runtimePersist -> (runtimePersist.getServerName() != null && runtimePersist.getServerName().toUpperCase().contains(value));
|
||||
|
||||
} else if (type.equals(strVersion)) {
|
||||
columnPredicate = runtimePersist -> (runtimePersist.getVersion()!=null&&runtimePersist.getVersion().toUpperCase().contains(value));
|
||||
columnPredicate = runtimePersist -> (runtimePersist.getVersion() != null && runtimePersist.getVersion().toUpperCase().contains(value));
|
||||
}
|
||||
}
|
||||
return columnPredicate;
|
||||
}
|
||||
|
||||
public void setDataProvider(){
|
||||
public void setDataProvider() {
|
||||
|
||||
List<RuntimePersist> runtimePersists = runtimeService.getRuntimeRepository().findAll();
|
||||
if(runtimePersists!=null) {
|
||||
dataProvider = new ListDataProvider<>(runtimePersists);
|
||||
if (runtimePersists != null) {
|
||||
List<RuntimePersist> runtimeToShow = new ArrayList<>();
|
||||
Map<String, String> urlMap = new HashMap<>();
|
||||
for (RuntimePersist runtimePersist : runtimePersists) {
|
||||
if (urlMap.containsKey(runtimePersist.getServerName()) == false) {
|
||||
|
||||
urlMap.put(runtimePersist.getServerName(), runtimePersist.getServerUrl());
|
||||
RuntimePersist runtimePersist1 = runtimePersist.duplicate();
|
||||
if (projectPersist != null) {
|
||||
if (projectPersist.getServerNames().contains(runtimePersist1.getServerName())) {
|
||||
runtimeToShow.add(runtimePersist1);
|
||||
getSelectionModel().select(runtimePersist1);
|
||||
} else {
|
||||
if (projectPersist.getServerNames().size() == 0){
|
||||
runtimeToShow.add(runtimePersist1);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
runtimeToShow.add(runtimePersist1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dataProvider = new ListDataProvider<>(runtimeToShow);
|
||||
filterDataProvider = dataProvider.withConfigurableFilter();
|
||||
setDataProvider(filterDataProvider);
|
||||
|
||||
|
|
@ -145,7 +166,8 @@ public class GridRuntime extends Grid<RuntimePersist> {
|
|||
|
||||
}
|
||||
}
|
||||
public void reinitFilter(){
|
||||
|
||||
public void reinitFilter() {
|
||||
hostName.setValue("");
|
||||
version.setValue("");
|
||||
runtimeName.setValue("");
|
||||
|
|
|
|||
|
|
@ -18,7 +18,13 @@ import org.chtijbug.drools.console.service.model.kie.KieConfigurationData;
|
|||
import org.chtijbug.drools.console.service.util.AppContext;
|
||||
import org.chtijbug.drools.console.vaadinComponent.ComponentPerso.DialogPerso;
|
||||
import org.chtijbug.drools.console.vaadinComponent.componentView.AssetEdit;
|
||||
import org.chtijbug.drools.console.vaadinComponent.componentView.service.dtmodel.ColumnDefinition;
|
||||
import org.chtijbug.drools.console.vaadinComponent.componentView.service.dtmodel.DecisionTable;
|
||||
import org.chtijbug.drools.console.vaadinComponent.componentView.service.dtmodel.GuidedException;
|
||||
import org.chtijbug.drools.console.vaadinComponent.componentView.service.dtmodel.Row;
|
||||
import org.drools.workbench.models.datamodel.rule.InterpolationVariable;
|
||||
import org.drools.workbench.models.guided.dtable.backend.GuidedDTXMLPersistence;
|
||||
import org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52;
|
||||
import org.drools.workbench.models.guided.template.backend.RuleTemplateModelXMLPersistenceImpl;
|
||||
import org.drools.workbench.models.guided.template.shared.TemplateModel;
|
||||
import org.vaadin.olli.FileDownloadWrapper;
|
||||
|
|
@ -114,7 +120,6 @@ public class EditTemplateView extends VerticalLayout {
|
|||
TemplateModel model = RuleTemplateModelXMLPersistenceImpl.getInstance().unmarshal(assetSource);
|
||||
int id=model.getColsCount();
|
||||
model.clearRows();
|
||||
Map<String, List<String>> existingData = model.getTable();
|
||||
for (Map<String,Object> line : objects){
|
||||
String[] cols =new String[model.getColsCount()];
|
||||
int k=0;
|
||||
|
|
@ -142,11 +147,35 @@ public class EditTemplateView extends VerticalLayout {
|
|||
} else {
|
||||
List<HashMap<String, Object>> objects = decisionTableExcelService.importExcel(fileBuffer.getInputStream());
|
||||
if (objects != null && objects.size() > 0) {
|
||||
Notification.show("Unable to add columns with the excel import for the moment");
|
||||
}else{
|
||||
remove(assetEdit);
|
||||
assetEdit = new AssetEdit(objects);
|
||||
add(assetEdit);
|
||||
String assetSource=this.getAssetContent();
|
||||
GuidedDecisionTable52 model = GuidedDTXMLPersistence.getInstance().unmarshal(assetSource);
|
||||
org.chtijbug.drools.console.vaadinComponent.componentView.service.dtmodel.DecisionTable decisionTable = new DecisionTable(model);
|
||||
decisionTable.getRows().clear();
|
||||
List<ColumnDefinition> columnDefinitions = decisionTable.getColumnDefinitionList();
|
||||
int k=0;
|
||||
for (HashMap<String, Object> line : objects){
|
||||
Row row = decisionTable.createEmptyRow(k);
|
||||
for (ColumnDefinition columnDefinition : columnDefinitions){
|
||||
line.get(columnDefinition.getHeader());
|
||||
|
||||
}
|
||||
}
|
||||
k++;
|
||||
}
|
||||
|
||||
|
||||
//row.
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Notification.show("The file is incompatible, it must be in xlsx format");
|
||||
} catch (GuidedException e) {
|
||||
Notification.show("error "+e.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public class RuntimesView extends VerticalLayout {
|
|||
|
||||
public RuntimesView(){
|
||||
|
||||
add(new Label("Runtimes enrigistré"));
|
||||
add(new Label("Runtimes stored"));
|
||||
add(new GridRuntime());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
editor.link_modal.header
Reference in a new issue