Search in sources :

Example 1 with EventBus

use of com.google.gwt.event.shared.EventBus in project activityinfo by bedatadriven.

the class OfflineStore method getCachedMetadata.

/**
 * Try to load a cached FormSchema from the offline store.
 */
public Observable<FormMetadata> getCachedMetadata(ResourceId formId) {
    Observable<FormClass> schema = new ObservableTask<>(new SchemaQuery(database, formId), new FormChangeWatcher(eventBus, change -> change.isFormChanged(formId)));
    Observable<FormMetadataObject> metadata = new ObservableTask<>(new MetadataQuery(database, formId), new FormChangeWatcher(eventBus, change -> change.isFormChanged(formId)));
    return Observable.transform(schema, metadata, (s, m) -> FormMetadata.of(m.getVersion(), s, m.getPermissions()));
}
Also used : ObservableTask(org.activityinfo.ui.client.store.tasks.ObservableTask) FormTreeLoader(org.activityinfo.ui.client.store.FormTreeLoader) java.util(java.util) Json(org.activityinfo.json.Json) ObservableTree(org.activityinfo.observable.ObservableTree) Function2(org.activityinfo.promise.Function2) IDBTransaction(org.activityinfo.indexedb.IDBTransaction) Promise(org.activityinfo.promise.Promise) org.activityinfo.model.form(org.activityinfo.model.form) FormChange(org.activityinfo.ui.client.store.FormChange) Level(java.util.logging.Level) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) HttpStore(org.activityinfo.ui.client.store.http.HttpStore) OfflineDatabase(org.activityinfo.indexedb.OfflineDatabase) ResourceId(org.activityinfo.model.resource.ResourceId) RecordRef(org.activityinfo.model.type.RecordRef) JsonValue(org.activityinfo.json.JsonValue) RecordUpdate(org.activityinfo.model.resource.RecordUpdate) FormChangeWatcher(org.activityinfo.ui.client.store.http.FormChangeWatcher) Function(com.google.common.base.Function) ImmutableSet(com.google.common.collect.ImmutableSet) FormChangeEvent(org.activityinfo.ui.client.store.FormChangeEvent) EventBus(com.google.gwt.event.shared.EventBus) IDBFactory(org.activityinfo.indexedb.IDBFactory) StatefulValue(org.activityinfo.observable.StatefulValue) Logger(java.util.logging.Logger) ObservableTask(org.activityinfo.ui.client.store.tasks.ObservableTask) ColumnSet(org.activityinfo.model.query.ColumnSet) QueryModel(org.activityinfo.model.query.QueryModel) SimpleEventBus(com.google.gwt.event.shared.SimpleEventBus) RecordTransaction(org.activityinfo.model.resource.RecordTransaction) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Observable(org.activityinfo.observable.Observable) Maybe(org.activityinfo.promise.Maybe) FormTree(org.activityinfo.model.formTree.FormTree) FormChangeWatcher(org.activityinfo.ui.client.store.http.FormChangeWatcher)

Example 2 with EventBus

use of com.google.gwt.event.shared.EventBus in project drools-wb by kiegroup.

the class BaseSynchronizerTest method setup.

@Before
public void setup() {
    // Setup model related classes
    model = new GuidedDecisionTable52();
    uiModel = new GuidedDecisionTableUiModel(modelSynchronizer);
    incrementalDataModelServiceCaller = new CallerMock<>(incrementalDataModelService);
    final BRLRuleModel rm = new BRLRuleModel(model);
    final CellUtilities cellUtilities = new CellUtilities();
    final ColumnUtilities columnUtilities = new ColumnUtilities(model, oracle);
    final DependentEnumsUtilities enumsUtilities = new DependentEnumsUtilities(model, oracle);
    final GridWidgetCellFactory gridWidgetCellFactory = new GridWidgetCellFactoryImpl();
    // Setup mocks
    final GuidedDecisionTableModellerView.Presenter modellerPresenter = mock(GuidedDecisionTableModellerView.Presenter.class);
    final GuidedDecisionTableModellerView modellerView = mock(GuidedDecisionTableModellerView.class);
    final GridLayer gridLayer = mock(GridLayer.class);
    final AbsolutePanel domElementContainer = mock(AbsolutePanel.class);
    final GuidedDecisionTableView.Presenter dtablePresenter = mock(GuidedDecisionTableView.Presenter.class);
    final EventBus eventBus = mock(EventBus.class);
    when(dtablePresenter.getModellerPresenter()).thenReturn(modellerPresenter);
    when(modellerPresenter.getView()).thenReturn(modellerView);
    when(modellerView.getGridLayerView()).thenReturn(gridLayer);
    when(gridLayer.getDomElementContainer()).thenReturn(domElementContainer);
    when(domElementContainer.iterator()).thenReturn(mock(Iterator.class));
    // Setup column converters
    final List<BaseColumnConverter> converters = getConverters();
    gridWidgetColumnFactory.setConverters(converters);
    gridWidgetColumnFactory.initialise(model, oracle, columnUtilities, dtablePresenter);
    // Setup synchronizers
    final List<Synchronizer<? extends MetaData, ? extends MetaData, ? extends MetaData, ? extends MetaData, ? extends MetaData>> synchronizers = getSynchronizers();
    modelSynchronizer.setSynchronizers(synchronizers);
    modelSynchronizer.initialise(model, uiModel, cellUtilities, columnUtilities, enumsUtilities, gridWidgetCellFactory, gridWidgetColumnFactory, view, rm, eventBus, editable);
    // Dummy columns for Row number, rule name and Description
    uiModel.appendColumn(gridWidgetColumnFactory.convertColumn(new RowNumberCol52(), readOnly, view));
    uiModel.appendColumn(gridWidgetColumnFactory.convertColumn(new RuleNameColumn(), readOnly, view));
    uiModel.appendColumn(gridWidgetColumnFactory.convertColumn(new DescriptionCol52(), readOnly, view));
    ApplicationPreferences.setUp(new HashMap<String, String>() {

        {
            put(ApplicationPreferences.DATE_FORMAT, "dd-MM-yyyy");
        }
    });
}
Also used : ColumnUtilities(org.drools.workbench.screens.guided.dtable.client.widget.table.utilities.ColumnUtilities) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) GuidedDecisionTableModellerView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableModellerView) AbsolutePanel(com.google.gwt.user.client.ui.AbsolutePanel) EventBus(com.google.gwt.event.shared.EventBus) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) GridWidgetCellFactoryImpl(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.cell.impl.GridWidgetCellFactoryImpl) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) MetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.Synchronizer.MetaData) GuidedDecisionTableUiModel(org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiModel) Iterator(java.util.Iterator) BaseColumnConverter(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.BaseColumnConverter) Synchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.Synchronizer) BRLRuleModel(org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel) DependentEnumsUtilities(org.drools.workbench.screens.guided.dtable.client.widget.table.utilities.DependentEnumsUtilities) CellUtilities(org.drools.workbench.screens.guided.dtable.client.widget.table.utilities.CellUtilities) GridLayer(org.uberfire.ext.wires.core.grids.client.widget.layer.GridLayer) GridWidgetCellFactory(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.cell.GridWidgetCellFactory) RuleNameColumn(org.drools.workbench.models.guided.dtable.shared.model.RuleNameColumn) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) Before(org.junit.Before)

Example 3 with EventBus

use of com.google.gwt.event.shared.EventBus in project drools-wb by kiegroup.

the class AbstractScenarioSimulationProducerTest method getEventBus.

@Test
public void getEventBus() {
    EventBus retrieved = abstractScenarioSimulationProducer.getEventBus();
    assertNotNull(retrieved);
    assertEquals(retrieved, eventBusMock);
    verify(eventBusProducerMock, times(1)).getEventBus();
}
Also used : EventBus(com.google.gwt.event.shared.EventBus) Test(org.junit.Test)

Example 4 with EventBus

use of com.google.gwt.event.shared.EventBus in project drools-wb by kiegroup.

the class EventBusProducerTest method getEventBus.

@Test
public void getEventBus() {
    final EventBus retrieved = eventBusProducer.getEventBus();
    assertNotNull(retrieved);
}
Also used : EventBus(com.google.gwt.event.shared.EventBus) Test(org.junit.Test)

Example 5 with EventBus

use of com.google.gwt.event.shared.EventBus in project drools-wb by kiegroup.

the class ActionValueEditorTest method testGetDropDownData.

@Test
public void testGetDropDownData() throws Exception {
    final AsyncPackageDataModelOracle oracle = mock(AsyncPackageDataModelOracle.class);
    final String factType = "Car";
    final String factField = "color";
    final ActionFieldValue value = new ActionFieldValue() {

        {
            setField(factField);
        }
    };
    final ActionFieldValue[] values = new ActionFieldValue[0];
    final RuleModeller modeller = mock(RuleModeller.class);
    doReturn(oracle).when(modeller).getDataModelOracle();
    final EventBus eventBus = mock(EventBus.class);
    final String variableType = DataType.TYPE_STRING;
    final boolean readOnly = false;
    actionValueEditor = new ActionValueEditor(factType, value, values, modeller, eventBus, variableType, readOnly);
    // reset oracle due to calls in ActionValueEditor constructor
    reset(oracle);
    actionValueEditor.getDropDownData();
    final Map<String, String> fieldValues = new HashMap<>();
    verify(oracle).getEnums(eq(factType), eq(factField), eq(fieldValues));
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) ActionFieldValue(org.drools.workbench.models.datamodel.rule.ActionFieldValue) HashMap(java.util.HashMap) EventBus(com.google.gwt.event.shared.EventBus) Test(org.junit.Test)

Aggregations

EventBus (com.google.gwt.event.shared.EventBus)6 Test (org.junit.Test)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Function (com.google.common.base.Function)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 SimpleEventBus (com.google.gwt.event.shared.SimpleEventBus)1 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 AbsolutePanel (com.google.gwt.user.client.ui.AbsolutePanel)1 java.util (java.util)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Level (java.util.logging.Level)1 Logger (java.util.logging.Logger)1 Collectors (java.util.stream.Collectors)1 IDBFactory (org.activityinfo.indexedb.IDBFactory)1 IDBTransaction (org.activityinfo.indexedb.IDBTransaction)1 OfflineDatabase (org.activityinfo.indexedb.OfflineDatabase)1