Correct naming for eploying

Handle Correctly decision table
This commit is contained in:
Nicolas Héron 2019-09-20 12:05:54 +02:00
commit b885e04aae
25 changed files with 1001 additions and 258 deletions

View file

@ -16,7 +16,6 @@
<spring-boot.version>2.1.2.RELEASE</spring-boot.version>
<spring-version>5.1.2.RELEASE</spring-version>
<webapp.directory>src/main/webapp</webapp.directory>
<jbpm.version>7.15.0.Final</jbpm.version>
</properties>
@ -89,6 +88,18 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-workbench-models-guided-dtable</artifactId>
<version>${jbpm.version}</version>
<exclusions>
<exclusion>
<groupId>org.uberfire</groupId>
<artifactId>uberfire-commons</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.offbytwo.jenkins</groupId>
<artifactId>jenkins-client</artifactId>
@ -243,6 +254,7 @@
<configuration>
<jvmArguments>-Dvaadin.productionMode</jvmArguments>
<executable>true</executable>
</configuration>
<executions>
<execution>

View file

@ -1,30 +1,22 @@
package org.chtijbug.drools.console.vaadinComponent.componentView;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.datepicker.DatePicker;
import com.vaadin.flow.component.dependency.StyleSheet;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.data.binder.Binder;
import org.chtijbug.drools.console.service.KieRepositoryService;
import org.chtijbug.drools.console.service.UserConnectedService;
import org.chtijbug.drools.console.service.model.UserConnected;
import org.chtijbug.drools.console.service.model.kie.KieConfigurationData;
import org.chtijbug.drools.console.service.util.AppContext;
import org.drools.workbench.models.datamodel.rule.InterpolationVariable;
import org.chtijbug.drools.console.vaadinComponent.componentView.service.GuidedDecisionTableModelTransformer;
import org.chtijbug.drools.console.vaadinComponent.componentView.service.GuidedRuleTemplateModelTransformer;
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 java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@StyleSheet("css/accueil.css")
public class AssetEdit extends Grid<HashMap<String, Object>> {
@ -48,21 +40,19 @@ public class AssetEdit extends Grid<HashMap<String, Object>> {
userConnectedService.getSpace(),
userConnectedService.getProject(),
userConnectedService.getAsset());
TemplateModel model = RuleTemplateModelXMLPersistenceImpl.getInstance().unmarshal(assetContent);
InterpolationVariable[] variablesList = model.getInterpolationVariablesList();
setClassName("grid-perso");
Binder<HashMap<String, Object>> binder = new Binder<>();
getEditor().setBinder(binder);
setClassName("grid-perso");
if (assetContent.startsWith("<decision-table52")==true){
GuidedDecisionTable52 model = GuidedDTXMLPersistence.getInstance().unmarshal(assetContent);
GuidedDecisionTableModelTransformer transform = new GuidedDecisionTableModelTransformer(model, binder, this);
transform.run();
}else {
TemplateModel model = RuleTemplateModelXMLPersistenceImpl.getInstance().unmarshal(assetContent);
GuidedRuleTemplateModelTransformer transform = new GuidedRuleTemplateModelTransformer(model,binder,this);
transform.run();
for (InterpolationVariable i : variablesList) {
addColumn(hashmap -> hashmap.get(i.getVarName())).setHeader(i.getVarName());
}
fillTable(model);
}
public AssetEdit(List<HashMap<String, Object>> objects) {
@ -93,22 +83,5 @@ public class AssetEdit extends Grid<HashMap<String, Object>> {
}
private void fillTable(TemplateModel model) {
InterpolationVariable[] variablesList = model.getInterpolationVariablesList();
DateFormat format = new SimpleDateFormat("dd-MMM-yyyy", Locale.FRANCE);
String[][] contenuTable = model.getTableAsArray();
List<HashMap<String, Object>> rows = new ArrayList<>();
for (int i = 0; i < model.getRowsCount(); i++) {
HashMap<String, Object> newRow = new HashMap<>();
rows.add(newRow);
String[] ligne = contenuTable[i];
int k = 0;
for (InterpolationVariable j : variablesList) {
newRow.put(j.getVarName(), ligne[k]);
k++;
}
}
setItems(rows);
}
}

View file

@ -0,0 +1,63 @@
package org.chtijbug.drools.console.vaadinComponent.componentView.service;
import com.vaadin.flow.data.binder.Binder;
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.guided.dtable.shared.model.GuidedDecisionTable52;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
public class GuidedDecisionTableModelTransformer {
private GuidedDecisionTable52 model;
private Binder binder;
private AssetEdit assetEdit;
public GuidedDecisionTableModelTransformer(GuidedDecisionTable52 model, Binder binder, AssetEdit assetEdit) {
this.model = model;
this.binder = binder;
this.assetEdit = assetEdit;
}
public void run() {
try {
DecisionTable decisionTable = new DecisionTable(model);
for (ColumnDefinition columnDefinition : decisionTable.getColumnDefinitionList()) {
assetEdit.addColumn(hashmap -> hashmap.get(columnDefinition.getHeader())).setHeader(columnDefinition.getHeader());
}
fillTable(decisionTable);
} catch (GuidedException e) {
e.printStackTrace();
}
}
private void fillTable(DecisionTable decisionTable) {
List<ColumnDefinition> columnDefinitions = decisionTable.getColumnDefinitionList();
DateFormat format = new SimpleDateFormat("dd-MMM-yyyy", Locale.FRANCE);
List<HashMap<String, Object>> rows = new ArrayList<>();
for (int i = 0; i < decisionTable.getRows().size(); i++) {
Row row = decisionTable.getRows().get(i);
HashMap<String, Object> newRow = new HashMap<>();
rows.add(newRow);
int k = 0;
for (ColumnDefinition columnDefinition : decisionTable.getColumnDefinitionList()) {
newRow.put(columnDefinition.getHeader(), row.getRowElements().get(k).getValue());
k++;
}
}
assetEdit.setItems(rows);
}
}

View file

@ -0,0 +1,53 @@
package org.chtijbug.drools.console.vaadinComponent.componentView.service;
import com.vaadin.flow.data.binder.Binder;
import org.chtijbug.drools.console.vaadinComponent.componentView.AssetEdit;
import org.drools.workbench.models.datamodel.rule.InterpolationVariable;
import org.drools.workbench.models.guided.template.shared.TemplateModel;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
public class GuidedRuleTemplateModelTransformer {
private TemplateModel model;
private Binder binder;
private AssetEdit assetEdit;
public GuidedRuleTemplateModelTransformer(TemplateModel model, Binder binder,AssetEdit assetEdit) {
this.model = model;
this.binder = binder;
this.assetEdit = assetEdit;
}
public void run(){
InterpolationVariable[] variablesList = model.getInterpolationVariablesList();
for (InterpolationVariable i : variablesList) {
assetEdit.addColumn(hashmap -> hashmap.get(i.getVarName())).setHeader(i.getVarName());
}
fillTable(model);
}
private void fillTable(TemplateModel model) {
InterpolationVariable[] variablesList = model.getInterpolationVariablesList();
DateFormat format = new SimpleDateFormat("dd-MMM-yyyy", Locale.FRANCE);
String[][] contenuTable = model.getTableAsArray();
List<HashMap<String, Object>> rows = new ArrayList<>();
for (int i = 0; i < model.getRowsCount(); i++) {
HashMap<String, Object> newRow = new HashMap<>();
rows.add(newRow);
String[] ligne = contenuTable[i];
int k = 0;
for (InterpolationVariable j : variablesList) {
newRow.put(j.getVarName(), ligne[k]);
k++;
}
}
assetEdit.setItems(rows);
}
}

View file

@ -0,0 +1,217 @@
/*
* Copyright 2014 Pymma Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.chtijbug.drools.console.vaadinComponent.componentView.service.dtmodel;
import org.drools.workbench.models.guided.dtable.shared.model.*;
import org.kie.soup.project.datamodel.oracle.DataType;
/**
* Created by IntelliJ IDEA.
* Date: 26/04/12
* Time: 14:29
* To change this template use File | Settings | File Templates.
*/
public class ColumnDefinition {
private int columnNumber;
private ColumnType columnType;
private boolean hideColumn;
private boolean hasDefaultValue;
private String defaultValue;
private String fieldType;
private String header;
private RowNumberCol52 rowNumberCol52;
private DescriptionCol52 descriptionCol52;
private AttributeCol52 attributeCol52;
private ConditionCol52 conditionCol52;
private ActionInsertFactCol52 actionInsertFact52;
private DTCellValue52 defaultValueCell;
private ActionSetFieldCol52 actionSetFieldCol52;
public ColumnDefinition(int columnNumber, RowNumberCol52 rowNumberCol52) {
this.columnNumber = columnNumber;
this.columnType = ColumnType.rowNumber;
this.fieldType = DataType.TYPE_NUMERIC_INTEGER.toString();
this.rowNumberCol52 = rowNumberCol52;
this.header = rowNumberCol52.getHeader();
}
public ColumnDefinition(int columnNumber, DescriptionCol52 descriptionCol52) {
this.columnNumber = columnNumber;
this.columnType = ColumnType.description;
this.header = descriptionCol52.getHeader();
this.fieldType = DataType.TYPE_STRING.toString();
this.descriptionCol52 = descriptionCol52;
}
public ColumnDefinition(int columnNumber, AttributeCol52 attributeCol52) {
this.attributeCol52 = attributeCol52;
this.columnNumber = columnNumber;
this.columnType = ColumnType.attribute;
this.fieldType = DataType.TYPE_STRING.toString();
if (attributeCol52.getDefaultValue() != null) {
this.hasDefaultValue = true;
this.defaultValueCell = attributeCol52.getDefaultValue();
this.defaultValue = getValue(attributeCol52.getDefaultValue());
}
this.header = attributeCol52.getHeader();
this.hideColumn = attributeCol52.isHideColumn();
}
public ColumnDefinition(int columnNumber, ConditionCol52 conditionCol52) {
this.conditionCol52 = conditionCol52;
this.columnNumber = columnNumber;
this.columnType = ColumnType.condition;
this.fieldType = conditionCol52.getFieldType();
if (conditionCol52.getDefaultValue() != null) {
this.hasDefaultValue = true;
this.defaultValue = getValue(conditionCol52.getDefaultValue());
}
this.hideColumn = conditionCol52.isHideColumn();
this.header = conditionCol52.getHeader();
}
public ColumnDefinition(int columnNumber, ActionSetFieldCol52 actionSetFieldCol52) {
this.actionSetFieldCol52 = actionSetFieldCol52;
this.columnNumber = columnNumber;
this.columnType = ColumnType.action;
this.fieldType = actionSetFieldCol52.getType();
this.header = actionSetFieldCol52.getHeader();
if (actionSetFieldCol52.getDefaultValue() != null) {
DTCellValue52 defaultValue = actionSetFieldCol52.getDefaultValue();
if (!(DataType.TYPE_STRING.equals(defaultValue.getDataType()) && defaultValue.getStringValue().isEmpty())) {
this.hasDefaultValue = true;
this.defaultValue = getValue(actionSetFieldCol52.getDefaultValue());
}
}
this.hideColumn = actionSetFieldCol52.isHideColumn();
this.header = actionSetFieldCol52.getHeader();
}
public ColumnDefinition(int columnNumber, ActionInsertFactCol52 actionInsertFact52) {
this.actionInsertFact52 = actionInsertFact52;
this.columnNumber = columnNumber;
this.columnType = ColumnType.action;
this.fieldType = actionInsertFact52.getType();
this.header = actionInsertFact52.getHeader();
if (actionInsertFact52.getDefaultValue() != null) {
DTCellValue52 defaultValue = actionInsertFact52.getDefaultValue();
if (!(DataType.TYPE_STRING.equals(defaultValue.getDataType()) && defaultValue.getStringValue().isEmpty())) {
this.hasDefaultValue = true;
this.defaultValue = getValue(actionInsertFact52.getDefaultValue());
}
}
this.hideColumn = actionInsertFact52.isHideColumn();
this.header = actionInsertFact52.getHeader();
}
public static String getValue(DTCellValue52 cell) {
String value = null;
switch (cell.getDataType()) {
case BOOLEAN:
value = Boolean.toString(cell.getBooleanValue());
break;
case NUMERIC:
if (cell.getNumericValue()!= null) {
value = cell.getNumericValue().toString();
}else{
value="";
}
break;
case NUMERIC_INTEGER:
if (cell.getNumericValue()!= null) {
value = cell.getNumericValue().toString();
}else{
value="";
}
break;
case NUMERIC_DOUBLE:
if (cell.getNumericValue()!= null) {
value = cell.getNumericValue().toString();
}else{
value="";
}
break;
case STRING:
value = cell.getStringValue();
break;
case DATE:
if (cell.getDateValue()!= null) {
value = cell.getDateValue().toString();
}else{
value="";
}
break;
}
/**
* STRING,
NUMERIC,
NUMERIC_BIGDECIMAL,
NUMERIC_BIGINTEGER,
NUMERIC_BYTE,
NUMERIC_DOUBLE,
NUMERIC_FLOAT,
NUMERIC_INTEGER,
NUMERIC_LONG,
NUMERIC_SHORT,
DATE,
BOOLEAN
*/
return value;
}
public int getColumnNumber() {
return columnNumber;
}
public ColumnType getColumnDefinition() {
return columnType;
}
public boolean isHideColumn() {
return hideColumn;
}
public boolean isHasDefaultValue() {
return hasDefaultValue;
}
public String getDefaultValue() {
return defaultValue;
}
public AttributeCol52 getAttributeCol52() {
return attributeCol52;
}
public ConditionCol52 getPattern52() {
return conditionCol52;
}
public ActionInsertFactCol52 getActionInsertFact52() {
return actionInsertFact52;
}
public String getFieldType() {
return fieldType;
}
public String getHeader() {
return header;
}
public void setHeader(String header) {
this.header = header;
}
}

View file

@ -0,0 +1,26 @@
/*
* Copyright 2014 Pymma Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.chtijbug.drools.console.vaadinComponent.componentView.service.dtmodel;
/**
* Created by IntelliJ IDEA.
* Date: 26/04/12
* Time: 14:31
* To change this template use File | Settings | File Templates.
*/
public enum ColumnType {
rowNumber, description, attribute, condition, action
}

View file

@ -0,0 +1,122 @@
/*
* Copyright 2014 Pymma Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.chtijbug.drools.console.vaadinComponent.componentView.service.dtmodel;
import org.drools.workbench.models.guided.dtable.shared.model.*;
import java.util.ArrayList;
import java.util.List;
public class DecisionTable {
private String name;
private GuidedDecisionTable52 guidedDecisionTable52;
private List<ColumnDefinition> columnDefinitionList = new ArrayList<ColumnDefinition>();
private List<Row> rows = new ArrayList<Row>();
public DecisionTable(GuidedDecisionTable52 guidedDecisionTable52) throws GuidedException {
this.guidedDecisionTable52 = guidedDecisionTable52;
this.name = this.guidedDecisionTable52.getTableName();
ColumnDefinition rowNumberColumn = new ColumnDefinition(0, guidedDecisionTable52.getRowNumberCol());
rowNumberColumn.setHeader("ID");
columnDefinitionList.add(rowNumberColumn);
ColumnDefinition descriptionColumn = new ColumnDefinition(1, guidedDecisionTable52.getDescriptionCol());
descriptionColumn.setHeader("Description");
columnDefinitionList.add(descriptionColumn);
int columnNumber = 2;
for (AttributeCol52 attributeCol52 : this.guidedDecisionTable52.getAttributeCols()) {
ColumnDefinition columnDefinition = new ColumnDefinition(columnNumber, attributeCol52);
columnDefinition.setHeader(attributeCol52.getAttribute());
columnDefinitionList.add(columnDefinition);
columnNumber++;
}
for (Pattern52 pattern52 : this.guidedDecisionTable52.getPatterns()) {
for (ConditionCol52 conditionCol52 : pattern52.getChildColumns()) {
ColumnDefinition columnDefinition = new ColumnDefinition(columnNumber, conditionCol52);
columnDefinitionList.add(columnDefinition);
columnNumber++;
}
}
for (ActionCol52 actionCol52 : this.guidedDecisionTable52.getActionCols()) {
if (actionCol52 instanceof ActionInsertFactCol52) {
ActionInsertFactCol52 actionInsertFactCol52 = (ActionInsertFactCol52) actionCol52;
ColumnDefinition columnDefinition = new ColumnDefinition(columnNumber, actionInsertFactCol52);
columnDefinitionList.add(columnDefinition);
columnNumber++;
}else if (actionCol52 instanceof ActionSetFieldCol52){
ActionSetFieldCol52 actionSetFieldCol52 = (ActionSetFieldCol52) actionCol52;
ColumnDefinition columnDefinition = new ColumnDefinition(columnNumber, actionSetFieldCol52);
columnDefinitionList.add(columnDefinition);
columnNumber++;
}
}
for (List<DTCellValue52> line : this.guidedDecisionTable52.getData()) {
try {
Row newRow = new Row(line, this);
//Row newRow = fillRow(line);
rows.add(newRow);
} catch (GuidedException e) {
GuidedException chtijbugDroolsRestException = new GuidedException(e);
e.setClassName("DecisionTable.Constructor");
e.setAttribute("Data");
e.setValue(line.toString());
throw chtijbugDroolsRestException;
}
}
}
public Row createEmptyRow(int rowNumber) throws GuidedException {
for (int j = rowNumber; j < this.rows.size(); j++) {
this.rows.get(j).updateRowNumber(j + 1);
}
Row newRow = new Row(this, rowNumber);
rows.add(newRow);
this.guidedDecisionTable52.getData().add(newRow.getCellValue52List());
return newRow;
}
private void removeRow(int rowNumber) throws GuidedException {
rows.remove(rowNumber);
this.guidedDecisionTable52.getData().remove(rowNumber);
for (int j = rowNumber; j < this.rows.size(); j++) {
this.rows.get(j).updateRowNumber(j);
}
}
public void clearAllData() {
this.guidedDecisionTable52.getData().clear();
this.getRows().clear();
}
public String getName() {
return name;
}
public GuidedDecisionTable52 getGuidedDecisionTable52() {
return guidedDecisionTable52;
}
public List<ColumnDefinition> getColumnDefinitionList() {
return columnDefinitionList;
}
public List<Row> getRows() {
return rows;
}
}

View file

@ -0,0 +1,54 @@
/*
* Copyright 2014 Pymma Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.chtijbug.drools.console.vaadinComponent.componentView.service.dtmodel;
public class GuidedException extends Exception {
private String className;
private String attribute;
private String value;
public GuidedException(Throwable throwable) {
super(throwable);
}
public GuidedException(String s) {
super(s);
}
public String getClassName() {
return className;
}
public void setClassName(String className) {
this.className = className;
}
public String getAttribute() {
return attribute;
}
public void setAttribute(String attribute) {
attribute = attribute;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

View file

@ -0,0 +1,85 @@
/*
* Copyright 2014 Pymma Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.chtijbug.drools.console.vaadinComponent.componentView.service.dtmodel;
import org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52;
import java.util.ArrayList;
import java.util.List;
public class Row {
private DecisionTable decisionTable;
private List<RowElement> rowElements = new ArrayList<RowElement>();
private List<DTCellValue52> cellValue52List;
protected Row(DecisionTable decisionTable, int rowNumber) throws GuidedException {
this.decisionTable = decisionTable;
this.cellValue52List = new ArrayList<DTCellValue52>();
for (ColumnDefinition col : this.decisionTable.getColumnDefinitionList()) {
RowElement newRowElement = new RowElement(col);
this.cellValue52List.add(newRowElement.getDtCellValue52());
if (col.getColumnNumber() == 0) {
try {
String newString = String.valueOf(rowNumber);
newRowElement.setValue(newString);
} catch (Exception e) {
GuidedException chtijbugDroolsRestException = new GuidedException(e);
chtijbugDroolsRestException.setClassName("Row");
chtijbugDroolsRestException.setValue(decisionTable.toString());
chtijbugDroolsRestException.setAttribute("protected Row(DecisionTable decisionTable,int rowNumber) throws ChtijbugDroolsRestException");
throw chtijbugDroolsRestException;
}
}
this.addRowElement(newRowElement);
}
}
protected Row(List<DTCellValue52> cellValue52List, DecisionTable decisionTable) throws GuidedException {
this.decisionTable = decisionTable;
this.cellValue52List = cellValue52List;
for (ColumnDefinition col : this.decisionTable.getColumnDefinitionList()) {
RowElement newRowElement = new RowElement(col, cellValue52List.get(col.getColumnNumber()));
this.addRowElement(newRowElement);
}
}
protected void updateRowNumber(int newRowNumber) throws GuidedException {
RowElement rowNumberElement = rowElements.get(0);
try {
rowNumberElement.setValue(String.valueOf(newRowNumber));
} catch (Exception e) {
GuidedException chtijbugDroolsRestException = new GuidedException(e);
chtijbugDroolsRestException.setAttribute("protected void updateRowNumber(int newRowNumber) throws ChtijbugDroolsRestExceptio");
chtijbugDroolsRestException.setClassName("Row");
throw chtijbugDroolsRestException;
}
}
public List<RowElement> getRowElements() {
return rowElements;
}
public void addRowElement(RowElement newRowElement) {
this.rowElements.add(newRowElement);
}
public List<DTCellValue52> getCellValue52List() {
return cellValue52List;
}
}

View file

@ -0,0 +1,144 @@
/*
* Copyright 2014 Pymma Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.chtijbug.drools.console.vaadinComponent.componentView.service.dtmodel;
import org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52;
import org.kie.soup.project.datamodel.oracle.DataType;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Created by IntelliJ IDEA.
* Date: 26/04/12
* Time: 14:47
* To change this template use File | Settings | File Templates.
*/
public class RowElement {
private ColumnDefinition columnDefinition;
private String value = "";
private DTCellValue52 dtCellValue52;
public RowElement(ColumnDefinition columnDefinition, DTCellValue52 dtCellValue52) throws GuidedException {
this.columnDefinition = columnDefinition;
this.dtCellValue52 = dtCellValue52;
this.value = ColumnDefinition.getValue(this.dtCellValue52);
}
public RowElement(ColumnDefinition columnDefinition) throws GuidedException {
this.columnDefinition = columnDefinition;
this.dtCellValue52 = new DTCellValue52();
if (this.columnDefinition.isHasDefaultValue()) {
this.value = this.columnDefinition.getDefaultValue();
if (this.columnDefinition.getColumnDefinition() == ColumnType.rowNumber) {
int rowNumber = new Integer(value).intValue();
this.dtCellValue52.setNumericValue(rowNumber + 1);
this.value = value;
} else if (this.columnDefinition.getColumnDefinition() == ColumnType.description) {
this.dtCellValue52.setStringValue(value);
} else if (this.columnDefinition.getColumnDefinition() == ColumnType.attribute) {
this.dtCellValue52.setStringValue(value);
try {
setValuedtCell(this.value);
} catch (Exception e) {
GuidedException chtijbugDroolsRestException = new GuidedException(e);
chtijbugDroolsRestException.setClassName("RowElement");
chtijbugDroolsRestException.setAttribute(this.columnDefinition.toString());
chtijbugDroolsRestException.setValue(this.value);
throw chtijbugDroolsRestException;
}
} else if (this.columnDefinition.getColumnDefinition() == ColumnType.condition) {
try {
setValuedtCell(this.value);
} catch (Exception e) {
GuidedException chtijbugDroolsRestException = new GuidedException(e);
chtijbugDroolsRestException.setClassName("RowElement");
chtijbugDroolsRestException.setAttribute(this.columnDefinition.toString());
chtijbugDroolsRestException.setValue(this.value);
throw chtijbugDroolsRestException;
}
} else if (this.columnDefinition.getColumnDefinition() == ColumnType.action) {
try {
setValuedtCell(this.value);
} catch (Exception e) {
GuidedException chtijbugDroolsRestException = new GuidedException(e);
chtijbugDroolsRestException.setClassName("RowElement");
chtijbugDroolsRestException.setAttribute(this.columnDefinition.toString());
chtijbugDroolsRestException.setValue(this.value);
throw chtijbugDroolsRestException;
}
}
}
}
public String getValue() {
return value;
}
public void setValue(String value) throws Exception {
this.value = value;
setValuedtCell(value);
}
public ColumnDefinition getColumnDefinition() {
return columnDefinition;
}
public DTCellValue52 getDtCellValue52() {
return dtCellValue52;
}
private void setValuedtCell(String aValue) throws Exception {
if (this.columnDefinition.getFieldType().toUpperCase().equals(DataType.TYPE_STRING.toString())) {
this.dtCellValue52.setStringValue(aValue);
} else if (this.columnDefinition.getFieldType().toUpperCase().equals(DataType.TYPE_NUMERIC_BIGDECIMAL.toString())) {
this.dtCellValue52.setNumericValue(new BigDecimal(aValue));
} else if (this.columnDefinition.getFieldType().toUpperCase().equals(DataType.TYPE_NUMERIC_BIGINTEGER.toString())) {
this.dtCellValue52.setNumericValue(new BigInteger(aValue));
} else if (this.columnDefinition.getFieldType().toUpperCase().equals(DataType.TYPE_NUMERIC_BYTE.toString())) {
this.dtCellValue52.setNumericValue(new Byte(aValue));
} else if (this.columnDefinition.getFieldType().toUpperCase().equals(DataType.TYPE_NUMERIC_DOUBLE.toString())) {
this.dtCellValue52.setNumericValue(new Double(aValue));
} else if (this.columnDefinition.getFieldType().toUpperCase().equals("DOUBLE")) {
this.dtCellValue52.setNumericValue(new Double(aValue));
} else if (this.columnDefinition.getFieldType().toUpperCase().equals(DataType.TYPE_NUMERIC_FLOAT.toString())) {
this.dtCellValue52.setNumericValue(new Float(aValue));
} else if (this.columnDefinition.getFieldType().toUpperCase().equals(DataType.TYPE_NUMERIC_INTEGER.toString())) {
this.dtCellValue52.setNumericValue(new Integer(aValue));
} else if (this.columnDefinition.getFieldType().toUpperCase().equals(DataType.TYPE_NUMERIC_LONG.toString())) {
this.dtCellValue52.setNumericValue(new Long(aValue));
} else if (this.columnDefinition.getFieldType().toUpperCase().equals(DataType.TYPE_NUMERIC_SHORT.toString())) {
this.dtCellValue52.setNumericValue(new Short(aValue));
} else if (this.columnDefinition.getFieldType().toUpperCase().equals(DataType.TYPE_DATE.toString())) {
SimpleDateFormat sdf = new SimpleDateFormat();
Date newDate = sdf.parse(aValue);
this.dtCellValue52.setDateValue(newDate);
} else if (this.columnDefinition.getFieldType().toUpperCase().equals(DataType.TYPE_BOOLEAN.toString())) {
this.dtCellValue52.setBooleanValue(new Boolean(aValue));
} else if (this.columnDefinition.getFieldType().toUpperCase().equals(DataType.TYPE_NUMERIC.toString())) {
this.dtCellValue52.setNumericValue(new Double(aValue));
}
}
}

View file

@ -8,6 +8,6 @@ spring.data.elasticsearch.cluster-nodes=localhost:9300
spring.data.mongodb.database=businessProxyDB
spring.data.mongodb.host=localhost:27017
spring.data.mongodb.host=localhost:28017
spring.servlet.multipart.enabled=false