Search in sources :

Example 41 with MetadataCol52

use of org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52 in project drools-wb by kiegroup.

the class GridWidgetColumnFactoryImplTest method columnResizingListenerSetup_MetadataColumn.

@Test
public void columnResizingListenerSetup_MetadataColumn() {
    final MetadataCol52 column = new MetadataCol52();
    column.setMetadata("metadata");
    final GridColumn<?> uiColumn = factory.convertColumn(column, access, gridWidget);
    assertTrue(uiColumn instanceof BaseUiColumn);
    assertEquals((int) uiColumn.getWidth(), column.getWidth());
    uiColumn.setWidth(200.0);
    assertEquals(200, column.getWidth());
}
Also used : MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) BaseUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BaseUiColumn) Test(org.junit.Test)

Example 42 with MetadataCol52

use of org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52 in project drools by kiegroup.

the class GuidedDTDRLPersistenceTest method testLimitedEntryMetadata.

@Test
public void testLimitedEntryMetadata() {
    GuidedDecisionTable52 dt = new GuidedDecisionTable52();
    dt.setTableFormat(GuidedDecisionTable52.TableFormat.LIMITED_ENTRY);
    dt.setTableName("limited-entry");
    MetadataCol52 md = new MetadataCol52();
    md.setMetadata("metadata");
    dt.getMetadataCols().add(md);
    dt.setData(DataUtilities.makeDataLists(new String[][] { new String[] { "1", "desc", "md1" }, new String[] { "2", "desc", "md2" } }));
    GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
    String drl = p.marshal(dt);
    assertTrue(drl.indexOf("@metadata(md1)") > -1);
    assertTrue(drl.indexOf("@metadata(md2)") > -1);
}
Also used : MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Test(org.junit.Test)

Example 43 with MetadataCol52

use of org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52 in project drools by kiegroup.

the class GuidedDTDRLPersistenceTest method testRHS.

@Test
public void testRHS() {
    GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
    String[] row = new String[] { "1", "desc", "a", "a condition", "actionsetfield1", "actionupdatefield2", "retract", "actioninsertfact1", "actioninsertfact2" };
    List<BaseColumn> allColumns = new ArrayList<BaseColumn>();
    allColumns.add(new RowNumberCol52());
    allColumns.add(new DescriptionCol52());
    allColumns.add(new MetadataCol52());
    allColumns.add(new ConditionCol52());
    List<ActionCol52> cols = new ArrayList<ActionCol52>();
    ActionSetFieldCol52 asf1 = new ActionSetFieldCol52();
    asf1.setBoundName("a");
    asf1.setFactField("field1");
    asf1.setType(DataType.TYPE_STRING);
    cols.add(asf1);
    ActionSetFieldCol52 asf2 = new ActionSetFieldCol52();
    asf2.setBoundName("a");
    asf2.setFactField("field2");
    asf2.setUpdate(true);
    asf2.setType(DataType.TYPE_NUMERIC_INTEGER);
    cols.add(asf2);
    ActionRetractFactCol52 ret = new ActionRetractFactCol52();
    cols.add(ret);
    ActionInsertFactCol52 ins1 = new ActionInsertFactCol52();
    ins1.setBoundName("ins");
    ins1.setFactType("Cheese");
    ins1.setFactField("price");
    ins1.setType(DataType.TYPE_NUMERIC_INTEGER);
    cols.add(ins1);
    ActionInsertFactCol52 ins2 = new ActionInsertFactCol52();
    ins2.setBoundName("ins");
    ins2.setFactType("Cheese");
    ins2.setFactField("type");
    ins2.setType(DataType.TYPE_NUMERIC_INTEGER);
    cols.add(ins2);
    RuleModel rm = new RuleModel();
    allColumns.addAll(cols);
    List<DTCellValue52> rowData = DataUtilities.makeDataRowList(row);
    TemplateDataProvider rowDataProvider = new GuidedDTTemplateDataProvider(allColumns, rowData);
    p.doActions(allColumns, cols, rowDataProvider, rowData, rm);
    assertEquals(4, rm.rhs.length);
    // examine the set field action that is produced
    ActionSetField a1 = (ActionSetField) rm.rhs[0];
    assertEquals("a", a1.getVariable());
    assertEquals(1, a1.getFieldValues().length);
    assertEquals("field1", a1.getFieldValues()[0].getField());
    assertEquals("actionsetfield1", a1.getFieldValues()[0].getValue());
    assertEquals(DataType.TYPE_STRING, a1.getFieldValues()[0].getType());
    ActionSetField a2 = (ActionSetField) rm.rhs[1];
    assertEquals("a", a2.getVariable());
    assertEquals(1, a2.getFieldValues().length);
    assertEquals("field2", a2.getFieldValues()[0].getField());
    assertEquals("actionupdatefield2", a2.getFieldValues()[0].getValue());
    assertEquals(DataType.TYPE_NUMERIC_INTEGER, a2.getFieldValues()[0].getType());
    // examine the retract
    ActionRetractFact a3 = (ActionRetractFact) rm.rhs[2];
    assertEquals("retract", a3.getVariableName());
    // examine the insert
    ActionInsertFact a4 = (ActionInsertFact) rm.rhs[3];
    assertEquals("Cheese", a4.getFactType());
    assertEquals(2, a4.getFieldValues().length);
    assertEquals("price", a4.getFieldValues()[0].getField());
    assertEquals("actioninsertfact1", a4.getFieldValues()[0].getValue());
    assertEquals(DataType.TYPE_NUMERIC_INTEGER, a4.getFieldValues()[0].getType());
    assertEquals("type", a4.getFieldValues()[1].getField());
    assertEquals("actioninsertfact2", a4.getFieldValues()[1].getValue());
    assertEquals(DataType.TYPE_NUMERIC_INTEGER, a4.getFieldValues()[1].getType());
}
Also used : ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) LimitedEntryActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52) ActionRetractFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) ArrayList(java.util.ArrayList) GuidedDTTemplateDataProvider(org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) LimitedEntryActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) ActionRetractFact(org.drools.workbench.models.datamodel.rule.ActionRetractFact) LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) ActionSetField(org.drools.workbench.models.datamodel.rule.ActionSetField) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) ActionInsertFact(org.drools.workbench.models.datamodel.rule.ActionInsertFact) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) GuidedDTTemplateDataProvider(org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider) TemplateDataProvider(org.drools.workbench.models.guided.dtable.backend.util.TemplateDataProvider) Test(org.junit.Test)

Example 44 with MetadataCol52

use of org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52 in project drools by kiegroup.

the class GuidedDecisionTableUpgradeHelper1 method makeNewColumn.

private MetadataCol52 makeNewColumn(MetadataCol c) {
    MetadataCol52 nc = new MetadataCol52();
    nc.setDefaultValue(new DTCellValue52(c.defaultValue));
    nc.setHideColumn(c.hideColumn);
    nc.setMetadata(c.attr);
    nc.setWidth(c.width);
    return nc;
}
Also used : MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)

Example 45 with MetadataCol52

use of org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52 in project drools by kiegroup.

the class GuidedDTDRLPersistenceTest method testMetaData.

@Test
public void testMetaData() {
    GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
    String[] row = new String[] { "1", "desc", "bar", "" };
    List<BaseColumn> allColumns = new ArrayList<BaseColumn>();
    allColumns.add(new RowNumberCol52());
    allColumns.add(new DescriptionCol52());
    List<MetadataCol52> metadataCols = new ArrayList<MetadataCol52>();
    RuleModel rm = new RuleModel();
    RuleMetadata[] orig = rm.metadataList;
    // RuleAttribute[] orig = rm.attributes;
    p.doMetadata(allColumns, metadataCols, DataUtilities.makeDataRowList(row), rm);
    assertSame(orig, rm.metadataList);
    MetadataCol52 col1 = new MetadataCol52();
    col1.setMetadata("foo");
    MetadataCol52 col2 = new MetadataCol52();
    col2.setMetadata("foo2");
    metadataCols.add(col1);
    metadataCols.add(col2);
    allColumns.addAll(metadataCols);
    p.doMetadata(allColumns, metadataCols, DataUtilities.makeDataRowList(row), rm);
    assertEquals(1, rm.metadataList.length);
    assertEquals("foo", rm.metadataList[0].getAttributeName());
    assertEquals("bar", rm.metadataList[0].getValue());
    row = new String[] { "1", "desc", "bar1", "bar2" };
    p.doMetadata(allColumns, metadataCols, DataUtilities.makeDataRowList(row), rm);
    assertEquals(2, rm.metadataList.length);
    assertEquals("foo", rm.metadataList[0].getAttributeName());
    assertEquals("bar1", rm.metadataList[0].getValue());
    assertEquals("foo2", rm.metadataList[1].getAttributeName());
    assertEquals("bar2", rm.metadataList[1].getValue());
}
Also used : ArrayList(java.util.ArrayList) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) RuleMetadata(org.drools.workbench.models.datamodel.rule.RuleMetadata) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) Test(org.junit.Test)

Aggregations

MetadataCol52 (org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52)67 Test (org.junit.Test)52 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)18 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)12 ArrayList (java.util.ArrayList)11 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)10 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)10 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)9 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)9 AttributeCol52 (org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52)8 DecisionTableSelectionsChangedEvent (org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectionsChangedEvent)8 DecisionTableSelectedEvent (org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent)7 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)6 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)6 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)5 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)5 GuidedDTTemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider)4 TemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.TemplateDataProvider)4 BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)4 CompositeColumn (org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn)4