Search in sources :

Example 6 with PMMLIncludedModelActiveRecord

use of org.kie.workbench.common.dmn.client.editors.included.PMMLIncludedModelActiveRecord in project kie-wb-common by kiegroup.

the class IncludedModelsFactory method makeIncludedModel.

private BaseIncludedModelActiveRecord makeIncludedModel(final Import anImport) {
    BaseIncludedModelActiveRecord includedModel;
    if (anImport instanceof ImportDMN) {
        final DMNIncludedModelActiveRecord dmnIncludedModel = new DMNIncludedModelActiveRecord(getRecordEngine());
        dmnIncludedModel.setDataTypesCount(getDataTypesCount((ImportDMN) anImport));
        dmnIncludedModel.setDrgElementsCount(getDrgElementsCount((ImportDMN) anImport));
        includedModel = dmnIncludedModel;
    } else if (anImport instanceof ImportPMML) {
        final PMMLIncludedModelActiveRecord pmmlIncludedModel = new PMMLIncludedModelActiveRecord(getRecordEngine());
        pmmlIncludedModel.setModelCount(getPMMLModelCount((ImportPMML) anImport));
        includedModel = pmmlIncludedModel;
    } else {
        includedModel = new DefaultIncludedModelActiveRecord(getRecordEngine());
    }
    includedModel.setUuid(uuidWrapper());
    includedModel.setName(getName(anImport));
    includedModel.setNamespace(getNamespace(anImport));
    includedModel.setImportType(getImportType(anImport));
    includedModel.setPath(getPath(anImport));
    getIncludedModelsIndex().index(includedModel, anImport);
    return includedModel;
}
Also used : DefaultIncludedModelActiveRecord(org.kie.workbench.common.dmn.client.editors.included.DefaultIncludedModelActiveRecord) ImportDMN(org.kie.workbench.common.dmn.api.definition.model.ImportDMN) PMMLIncludedModelActiveRecord(org.kie.workbench.common.dmn.client.editors.included.PMMLIncludedModelActiveRecord) BaseIncludedModelActiveRecord(org.kie.workbench.common.dmn.client.editors.included.BaseIncludedModelActiveRecord) DMNIncludedModelActiveRecord(org.kie.workbench.common.dmn.client.editors.included.DMNIncludedModelActiveRecord) ImportPMML(org.kie.workbench.common.dmn.api.definition.model.ImportPMML)

Example 7 with PMMLIncludedModelActiveRecord

use of org.kie.workbench.common.dmn.client.editors.included.PMMLIncludedModelActiveRecord in project kie-wb-common by kiegroup.

the class ImportFactory method makeImport.

public Import makeImport(final BaseIncludedModelActiveRecord record) {
    Import anImport;
    if (record instanceof DMNIncludedModelActiveRecord) {
        final ImportDMN dmn = new ImportDMN();
        final DMNIncludedModelActiveRecord dmnRecord = (DMNIncludedModelActiveRecord) record;
        dmn.setName(name(record));
        dmn.setNamespace(record.getNamespace());
        dmn.setLocationURI(location(record));
        dmn.setImportType(record.getImportType());
        dmn.setDrgElementsCount(dmnRecord.getDrgElementsCount());
        dmn.setItemDefinitionsCount(dmnRecord.getDataTypesCount());
        anImport = dmn;
    } else if (record instanceof PMMLIncludedModelActiveRecord) {
        final ImportPMML pmml = new ImportPMML();
        final PMMLIncludedModelActiveRecord pmmlRecord = (PMMLIncludedModelActiveRecord) record;
        pmml.setName(name(record));
        pmml.setNamespace(name(record).getValue());
        pmml.setLocationURI(location(record));
        pmml.setImportType(record.getImportType());
        pmml.setModelCount(pmmlRecord.getModelCount());
        anImport = pmml;
    } else {
        anImport = new Import();
    }
    anImport.setLocationURI(location(record));
    anImport.setImportType(record.getImportType());
    return anImport;
}
Also used : Import(org.kie.workbench.common.dmn.api.definition.model.Import) ImportDMN(org.kie.workbench.common.dmn.api.definition.model.ImportDMN) PMMLIncludedModelActiveRecord(org.kie.workbench.common.dmn.client.editors.included.PMMLIncludedModelActiveRecord) DMNIncludedModelActiveRecord(org.kie.workbench.common.dmn.client.editors.included.DMNIncludedModelActiveRecord) ImportPMML(org.kie.workbench.common.dmn.api.definition.model.ImportPMML)

Example 8 with PMMLIncludedModelActiveRecord

use of org.kie.workbench.common.dmn.client.editors.included.PMMLIncludedModelActiveRecord in project kie-wb-common by kiegroup.

the class DMNCardsGridComponentTest method testRefresh.

@Test
public void testRefresh() {
    final DefaultIncludedModelActiveRecord includedModel1 = mock(DefaultIncludedModelActiveRecord.class);
    final DMNIncludedModelActiveRecord includedModel2 = mock(DMNIncludedModelActiveRecord.class);
    final PMMLIncludedModelActiveRecord includedModel3 = mock(PMMLIncludedModelActiveRecord.class);
    final DefaultCardComponent card1 = mock(DefaultCardComponent.class);
    final DMNCardComponent card2 = mock(DMNCardComponent.class);
    final PMMLCardComponent card3 = mock(PMMLCardComponent.class);
    final List<BaseIncludedModelActiveRecord> includedModels = asList(includedModel1, includedModel2, includedModel3);
    when(pageState.generateIncludedModels()).thenReturn(includedModels);
    when(defaultCardComponent.get()).thenReturn(card1);
    when(dmnCardComponent.get()).thenReturn(card2);
    when(pmmlCardComponent.get()).thenReturn(card3);
    grid.refresh();
    verify(card1).setup(grid, includedModel1);
    verify(card2).setup(grid, includedModel2);
    verify(card3).setup(grid, includedModel3);
    verify(cardsGridComponent).setupCards(asList(card1, card2, card3));
}
Also used : DefaultIncludedModelActiveRecord(org.kie.workbench.common.dmn.client.editors.included.DefaultIncludedModelActiveRecord) PMMLIncludedModelActiveRecord(org.kie.workbench.common.dmn.client.editors.included.PMMLIncludedModelActiveRecord) BaseIncludedModelActiveRecord(org.kie.workbench.common.dmn.client.editors.included.BaseIncludedModelActiveRecord) DMNIncludedModelActiveRecord(org.kie.workbench.common.dmn.client.editors.included.DMNIncludedModelActiveRecord) Test(org.junit.Test)

Aggregations

PMMLIncludedModelActiveRecord (org.kie.workbench.common.dmn.client.editors.included.PMMLIncludedModelActiveRecord)8 Test (org.junit.Test)5 ImportPMML (org.kie.workbench.common.dmn.api.definition.model.ImportPMML)4 BaseIncludedModelActiveRecord (org.kie.workbench.common.dmn.client.editors.included.BaseIncludedModelActiveRecord)4 DMNIncludedModelActiveRecord (org.kie.workbench.common.dmn.client.editors.included.DMNIncludedModelActiveRecord)4 Import (org.kie.workbench.common.dmn.api.definition.model.Import)3 DefaultIncludedModelActiveRecord (org.kie.workbench.common.dmn.client.editors.included.DefaultIncludedModelActiveRecord)3 ImportDMN (org.kie.workbench.common.dmn.api.definition.model.ImportDMN)2 LocationURI (org.kie.workbench.common.dmn.api.property.dmn.LocationURI)2 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)2 Maps (org.kie.soup.commons.util.Maps)1 RefreshDecisionComponents (org.kie.workbench.common.dmn.client.docks.navigator.events.RefreshDecisionComponents)1 KieAssetsDropdownItem (org.kie.workbench.common.widgets.client.assets.dropdown.KieAssetsDropdownItem)1 Mockito.doAnswer (org.mockito.Mockito.doAnswer)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Answer (org.mockito.stubbing.Answer)1