Package org.drools.ide.common.client.modeldriven.scorecards

Examples of org.drools.ide.common.client.modeldriven.scorecards.ScorecardModel


        return xt.toXML(model);
    }

    public ScorecardModel unmarshall(String xml) {
        if (xml == null || xml.trim().length() == 0) {
            return new ScorecardModel();
        }
        return (ScorecardModel) xt.fromXML(xml);
    }
View Full Code Here


public class ScorecardsContentHandler extends ContentHandler
        implements
        IRuleAsset, IHasCustomValidator {

    public void retrieveAssetContent(Asset asset, AssetItem item) throws SerializationException {
        ScorecardModel model = ScorecardsXMLPersistence.getInstance().unmarshall(item.getContent());
        asset.setContent(model);
    }
View Full Code Here

        ScorecardModel model = ScorecardsXMLPersistence.getInstance().unmarshall(item.getContent());
        asset.setContent(model);
    }

    public void storeAssetContent(Asset asset, AssetItem repoAsset) throws SerializationException {
        ScorecardModel model = (ScorecardModel) asset.getContent();
        repoAsset.updateContent(ScorecardsXMLPersistence.getInstance().marshal(model));
    }
View Full Code Here

        ScorecardModel model = (ScorecardModel) asset.getContent();
        repoAsset.updateContent(ScorecardsXMLPersistence.getInstance().marshal(model));
    }

    public void assembleDRL(BRMSPackageBuilder builder, AssetItem assetItem, StringBuilder stringBuilder) {
        ScorecardModel model = ScorecardsXMLPersistence.getInstance().unmarshall(assetItem.getContent());
        BuilderResult validationResult = validateScorecard(model);
        if ( !validationResult.hasLines() ) {
            String drl = getDrlFromScorecardModel(model);
            stringBuilder.append(drl);
        }
View Full Code Here

        }
    }

    public void assembleDRL(BRMSPackageBuilder builder, Asset asset, StringBuilder stringBuilder) {
        //called by View Source
        ScorecardModel model = (ScorecardModel) asset.getContent();
        BuilderResult validationResult = validateScorecard(model);
        if ( validationResult.hasLines() ) {
            if (StringUtils.isBlank(model.getName())) {
                stringBuilder.append("//Guided Scorecard has errors, Click on Source->Validate to view exact errors!");
            } else {
                stringBuilder.append("//Guided Scorecard ('"+model.getName()+"') has errors, Click on Source->Validate to view exact errors!");
            }
            return;
        }
        String drl = getDrlFromScorecardModel(model);
        stringBuilder.append(drl);
View Full Code Here

        String drl = getDrlFromScorecardModel(model);
        stringBuilder.append(drl);
    }

    public String getRawDRL(AssetItem assetItem) {
        ScorecardModel model = ScorecardsXMLPersistence.getInstance().unmarshall(assetItem.getContent());
        BuilderResult validationResult = validateScorecard(model);
        if ( !validationResult.hasLines() ) {
            return getDrlFromScorecardModel(model);
        } else {
            return "";
View Full Code Here

        return modelName;
    }

    public BuilderResult validateAsset(AssetItem assetItem) {
        System.out.println(">>> validateAsset() method.");
        ScorecardModel model = ScorecardsXMLPersistence.getInstance().unmarshall(assetItem.getContent());
        BuilderResult builderResult = validateScorecard(model);
        return builderResult;
    }
View Full Code Here

    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());
            }
View Full Code Here

        try {
            this.asset = asset;
            this.clientFactory = clientFactory;
            this.globalEventBus = globalEventBus;
            layout = new VerticalPanel();
            ScorecardModel scorecardModel = (ScorecardModel) asset.getContent();

            DecoratedDisclosurePanel disclosurePanel = new DecoratedDisclosurePanel("Scorecard " + " ( " + asset.getName() + " )");
            disclosurePanel.setWidth("100%");
            disclosurePanel.setTitle(Constants.INSTANCE.Scorecard());
            disclosurePanel.setOpen(true);

            DecoratedDisclosurePanel configPanel = new DecoratedDisclosurePanel("Setup Parameters");
            configPanel.setWidth("95%");
            configPanel.setOpen(true);
            configPanel.add(getScorecardProperties());
            VerticalPanel config = new VerticalPanel();

            DecoratedDisclosurePanel characteristicsPanel = new DecoratedDisclosurePanel("Characteristics");
            characteristicsPanel.setOpen(scorecardModel.getCharacteristics().size() > 0);
            characteristicsPanel.setWidth("95%");
            characteristicsPanel.add(getCharacteristics());

            config.setWidth("100%");
            config.add(configPanel);
            config.add(characteristicsPanel);

            disclosurePanel.add(config);
            layout.add(disclosurePanel);
            dtableContainer.setPixelSize(1000, 200);
            layout.add(dtableContainer);

            for (Characteristic characteristic : scorecardModel.getCharacteristics()) {
                DirtyableFlexTable flexTable = addCharacteristic(characteristic);
                for (Attribute attribute : characteristic.getAttributes()) {
                    addAttribute(flexTable, attribute);
                }
            }
View Full Code Here

        if (sce == null) {
            sce = SuggestionCompletionCache.getInstance().getEngineFromCache(asset.getMetaData().getModuleName());
            sceModelFields = sce.getModelFields();
        }

        final ScorecardModel scorecardModel = (ScorecardModel) asset.getContent();

        scorecardPropertiesGrid = new Grid(4, 4);
        scorecardPropertiesGrid.setCellSpacing(5);
        scorecardPropertiesGrid.setCellPadding(5);

        tbInitialScore = TextBoxFactory.getTextBox(SuggestionCompletionEngine.TYPE_NUMERIC_DOUBLE);
        tbInitialScore.setText(Double.toString(scorecardModel.getInitialScore()));

        String factName = scorecardModel.getFactName();
        if (factName.lastIndexOf(".") > -1){
            // if fact is a fully qualified className, strip off the packageName
            factName = factName.substring(factName.lastIndexOf(".")+1);
        }
        final EnumDropDown dropDownFields = new EnumDropDown("",
                new DropDownValueChanged() {
                    public void valueChanged(String newText,
                                             String newValue) {
                        //do nothing
                    }
                }, DropDownData.create(new String[]{}));

        EnumDropDown dropDownFacts = new EnumDropDown(factName,
                new DropDownValueChanged() {
                    public void valueChanged(String newText, String newValue) {
                        String selectedField = scorecardModel.getFieldName();
                        selectedField = selectedField+" : double";
                        dropDownFields.setDropDownData(selectedField, DropDownData.create(getEligibleFields(newValue, typesForScore)));
                    }
                }, DropDownData.create(sce.getFactTypes()));

        ddReasonCodeField = new EnumDropDown("",
                new DropDownValueChanged() {
                    public void valueChanged(String newText,
                                             String newValue) {
                        //do nothing
                    }
                }, DropDownData.create(new String[]{}));

        String rcField = scorecardModel.getReasonCodeField() +" : List";
        ddReasonCodeField.setDropDownData(rcField,DropDownData.create(getEligibleFields(factName,typesForRC)));

        boolean useReasonCodes = scorecardModel.isUseReasonCodes();
        String reasonCodesAlgo = scorecardModel.getReasonCodesAlgorithm();
        if (reasonCodesAlgo == null || reasonCodesAlgo.trim().length() == 0) {
            reasonCodesAlgo = "none";
        }

        ddUseReasonCode = booleanEditor(Boolean.toString(useReasonCodes));
        ddReasonCodeAlgo = dropDownEditor(DropDownData.create(REASON_CODE_ALGORITHMS), reasonCodesAlgo);
        tbBaselineScore = TextBoxFactory.getTextBox(SuggestionCompletionEngine.TYPE_NUMERIC_DOUBLE);

        scorecardPropertiesGrid.setText(0, 0, "Facts");
        scorecardPropertiesGrid.setText(0, 1, "Resultant Score Field");
        scorecardPropertiesGrid.setText(0, 2, "Initial Score");

        scorecardPropertiesGrid.setWidget(1, 0, dropDownFacts);
        scorecardPropertiesGrid.setWidget(1, 1, dropDownFields);
        scorecardPropertiesGrid.setWidget(1, 2, tbInitialScore);

        scorecardPropertiesGrid.setText(2, 0, "Use Reason Codes");
        scorecardPropertiesGrid.setText(2, 1, "Resultant Reason Codes Field");
        scorecardPropertiesGrid.setText(2, 2, "Reason Codes Algorithm");
        scorecardPropertiesGrid.setText(2, 3, "Baseline Score");

        scorecardPropertiesGrid.setWidget(3, 0, ddUseReasonCode);
        scorecardPropertiesGrid.setWidget(3, 1, ddReasonCodeField);
        scorecardPropertiesGrid.setWidget(3, 2, ddReasonCodeAlgo);
        scorecardPropertiesGrid.setWidget(3, 3, tbBaselineScore);

        /* TODO : Remove this explicitly Disabled Reasoncode support field*/
        ddUseReasonCode.setEnabled(false);

        tbBaselineScore.setText(Double.toString(scorecardModel.getBaselineScore()));

        scorecardPropertiesGrid.getCellFormatter().setWidth(0, 0, "200px");
        scorecardPropertiesGrid.getCellFormatter().setWidth(0, 1, "250px");
        scorecardPropertiesGrid.getCellFormatter().setWidth(0, 2, "200px");
        scorecardPropertiesGrid.getCellFormatter().setWidth(0, 3, "200px");

        int index = Arrays.asList(sce.getFactTypes()).indexOf(factName);
        dropDownFacts.setSelectedIndex(index);
        dropDownFields.setDropDownData(scorecardModel.getFieldName()+" : double", DropDownData.create(getEligibleFields(factName, typesForScore)));

        return scorecardPropertiesGrid;
    }
View Full Code Here

TOP

Related Classes of org.drools.ide.common.client.modeldriven.scorecards.ScorecardModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.