use of org.kie.workbench.common.dmn.client.editors.included.DMNIncludedModelActiveRecord in project kie-wb-common by kiegroup.
the class ImportFactoryTest method testMakeDMNImport.
@Test
public void testMakeDMNImport() {
final DMNIncludedModelActiveRecord record = new DMNIncludedModelActiveRecord(null);
final String expectedImportType = DMNImportTypes.DMN.getDefaultNamespace();
final String nameValue = "name";
final String path = "/src/main/kie/dmn";
final Name expectedName = new Name(nameValue);
final LocationURI expectedLocationURI = new LocationURI(path);
final String expectedNamespace = "://namespace";
final int expectedDrgElementsCount = 2;
final int expectedItemDefinitionsCount = 3;
record.setName(nameValue);
record.setPath(path);
record.setNamespace(expectedNamespace);
record.setImportType(DMNImportTypes.DMN.getDefaultNamespace());
record.setDrgElementsCount(expectedDrgElementsCount);
record.setDataTypesCount(expectedItemDefinitionsCount);
final Import actualImport = factory.makeImport(record);
assertTrue(actualImport instanceof ImportDMN);
final ImportDMN dmnImport = (ImportDMN) actualImport;
assertEquals(expectedImportType, actualImport.getImportType());
assertEquals(expectedName, actualImport.getName());
assertEquals(expectedLocationURI, actualImport.getLocationURI());
assertEquals(expectedNamespace, actualImport.getNamespace());
assertEquals(expectedImportType, actualImport.getImportType());
assertEquals(expectedDrgElementsCount, dmnImport.getDrgElementsCount());
assertEquals(expectedItemDefinitionsCount, dmnImport.getItemDefinitionsCount());
}
use of org.kie.workbench.common.dmn.client.editors.included.DMNIncludedModelActiveRecord in project kie-wb-common by kiegroup.
the class ImportFactoryTest method testName.
@Test
public void testName() {
final Import import1 = mock(Import.class);
final Import import2 = mock(Import.class);
final Import import3 = mock(Import.class);
final List<Import> imports = asList(import1, import2, import3);
final DMNIncludedModelActiveRecord record = new DMNIncludedModelActiveRecord(null);
when(import1.getName()).thenReturn(new Name("foo"));
when(import2.getName()).thenReturn(new Name("bar"));
when(import3.getName()).thenReturn(new Name("foo bar"));
when(modelsIndex.getIndexedImports()).thenReturn(imports);
record.setName("bla");
final Name name = factory.name(record);
final String expected = "bla";
final String actual = name.getValue();
assertEquals(expected, actual);
}
use of org.kie.workbench.common.dmn.client.editors.included.DMNIncludedModelActiveRecord in project kie-wb-common by kiegroup.
the class IncludedModelModal method createIncludedModel.
BaseIncludedModelActiveRecord createIncludedModel(final Map<String, String> metaData) {
final String importType = metaData.get(IMPORT_TYPE_METADATA);
if (Objects.equals(DMNImportTypes.DMN, determineImportType(importType))) {
final DMNIncludedModelActiveRecord dmnIncludedModel = new DMNIncludedModelActiveRecord(recordEngine);
dmnIncludedModel.setDrgElementsCount(Integer.valueOf(metaData.get(DRG_ELEMENT_COUNT_METADATA)));
dmnIncludedModel.setDataTypesCount(Integer.valueOf(metaData.get(ITEM_DEFINITION_COUNT_METADATA)));
return dmnIncludedModel;
} else if (Objects.equals(DMNImportTypes.PMML, determineImportType(importType))) {
final PMMLIncludedModelActiveRecord pmmlIncludedModel = new PMMLIncludedModelActiveRecord(recordEngine);
pmmlIncludedModel.setModelCount(Integer.valueOf(metaData.get(PMML_MODEL_COUNT_METADATA)));
return pmmlIncludedModel;
}
return new DefaultIncludedModelActiveRecord(recordEngine);
}
use of org.kie.workbench.common.dmn.client.editors.included.DMNIncludedModelActiveRecord 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;
}
use of org.kie.workbench.common.dmn.client.editors.included.DMNIncludedModelActiveRecord 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;
}
Aggregations