private TextBox tbInitialScore;
private Grid scorecardPropertiesGrid;
public void onSave(SaveCommand saveCommand) {
try {
ScorecardModel scorecardModel = (ScorecardModel) asset.getContent();
scorecardModel.setName(asset.getName());
scorecardModel.setPackageName(asset.getMetaData().getModuleName());
scorecardModel.setBaselineScore(Double.parseDouble(tbBaselineScore.getValue()));
scorecardModel.setInitialScore(Double.parseDouble(tbInitialScore.getValue()));
scorecardModel.setReasonCodesAlgorithm(ddReasonCodeAlgo.getValue(ddReasonCodeAlgo.getSelectedIndex()));
scorecardModel.setUseReasonCodes(ddUseReasonCode.getSelectedIndex() == 1);
EnumDropDown enumDropDown = (EnumDropDown) scorecardPropertiesGrid.getWidget(1, 0);
String factName = enumDropDown.getValue(enumDropDown.getSelectedIndex());
scorecardModel.setFactName(factName);
if (sce.getModelFields().get(factName) != null){
for (ModelField mf : sce.getModelFields().get(factName)) {
if (mf.getType().equals(factName)){
scorecardModel.setFactName(mf.getClassName());
break;
}
}
}
enumDropDown = (EnumDropDown) scorecardPropertiesGrid.getWidget(1, 1);
if (enumDropDown.getSelectedIndex() > -1) {
String fieldName = enumDropDown.getValue(enumDropDown.getSelectedIndex());
fieldName = fieldName.substring(0, fieldName.indexOf(":")).trim();
scorecardModel.setFieldName(fieldName);
} else {
scorecardModel.setFieldName("");
}
if (ddReasonCodeField.getSelectedIndex() > -1) {
String rcField = ddReasonCodeField.getValue(ddReasonCodeField.getSelectedIndex());
rcField = rcField.substring(0, rcField.indexOf(":")).trim();
scorecardModel.setReasonCodeField(rcField);
}
scorecardModel.getCharacteristics().clear();
for (DirtyableFlexTable flexTable : characteristicsTables) {
Characteristic characteristic = new Characteristic();
characteristic.setName(((TextBox) flexTable.getWidget(0, 1)).getValue());
enumDropDown = (EnumDropDown) flexTable.getWidget(2, 0);
String simpleFactName = enumDropDown.getValue(enumDropDown.getSelectedIndex());
if (sce.getModelFields().get(simpleFactName) != null){
for (ModelField mf : sce.getModelFields().get(simpleFactName)) {
////System.out.println(">>>> "+mf.getType()+" "+mf.getClassName()+" "+mf.getName());
if (mf.getType().equals(simpleFactName)){
characteristic.setFact(mf.getClassName());
break;
}
}
}
enumDropDown = (EnumDropDown) flexTable.getWidget(2, 1);
if (enumDropDown.getSelectedIndex() > -1) {
String fieldName = enumDropDown.getValue(enumDropDown.getSelectedIndex());
fieldName = fieldName.substring(0, fieldName.indexOf(":")).trim();
characteristic.setField(fieldName);
} else {
characteristic.setField("");
}
characteristic.setReasonCode(((TextBox) flexTable.getWidget(2, 3)).getValue());
String baselineScore = ((TextBox) flexTable.getWidget(2, 2)).getValue();
try {
characteristic.setBaselineScore(Double.parseDouble(baselineScore));
} catch (Exception e) {
characteristic.setBaselineScore(0.0d);
}
scorecardModel.getCharacteristics().add(characteristic);
characteristic.setDataType(getDataTypeForField(simpleFactName, characteristic.getField()));
System.out.println(">>>SetDataType -->"+simpleFactName+"<-->"+characteristic.getField()+"<-->"+characteristic.getDataType()+"<--");
characteristic.getAttributes().clear();
characteristic.getAttributes().addAll(characteristicsAttrMap.get(flexTable).getList());
}