use of org.kie.workbench.common.dmn.api.property.dmn.Id in project kie-wb-common by kiegroup.
the class DRGElementTest method testGetContentDefinitionId.
@Test
public void testGetContentDefinitionId() {
final String contentDefinitionId = "the id";
final Id id = mock(Id.class);
when(drgElement.getId()).thenReturn(id);
when(id.getValue()).thenReturn(contentDefinitionId);
final String currentId = drgElement.getContentDefinitionId();
assertEquals(contentDefinitionId, currentId);
}
use of org.kie.workbench.common.dmn.api.property.dmn.Id in project kie-wb-common by kiegroup.
the class FunctionDefinitionTest method testCopy.
@Test
public void testCopy() {
final FunctionDefinition source = new FunctionDefinition();
source.setId(new Id(FUNCTION_ID));
source.setDescription(new Description(DESCRIPTION));
source.setTypeRef(BuiltInType.BOOLEAN.asQName());
source.setKind(Kind.JAVA);
final FunctionDefinition target = source.copy();
assertNotNull(target);
assertNotEquals(FUNCTION_ID, target.getId().getValue());
assertEquals(DESCRIPTION, target.getDescription().getValue());
assertEquals(BuiltInType.BOOLEAN.asQName(), target.getTypeRef());
assertEquals(Kind.JAVA, target.getKind());
}
use of org.kie.workbench.common.dmn.api.property.dmn.Id in project kie-wb-common by kiegroup.
the class ImportTest method setup.
@Before
public void setup() {
import1 = new Import();
import2 = new Import();
import1.setId(new Id("123"));
import2.setId(new Id("123"));
}
use of org.kie.workbench.common.dmn.api.property.dmn.Id in project kie-wb-common by kiegroup.
the class BindingTest method testCopy.
@Test
public void testCopy() {
final Binding source = new Binding();
final InformationItem informationItem = new InformationItem(new Id(ITEM_ID), new Description(DESCRIPTION), new Name(INFORMATION_ITEM_NAME), BuiltInType.BOOLEAN.asQName());
source.setParameter(informationItem);
final Binding target = source.copy();
assertNotNull(target);
assertNull(target.getExpression());
assertNotNull(target.getParameter());
assertNotEquals(ITEM_ID, target.getParameter().getId().getValue());
assertEquals(DESCRIPTION, target.getParameter().getDescription().getValue());
assertEquals(INFORMATION_ITEM_NAME, target.getParameter().getName().getValue());
assertEquals(BuiltInType.BOOLEAN.asQName(), target.getParameter().getTypeRef());
}
use of org.kie.workbench.common.dmn.api.property.dmn.Id in project kie-wb-common by kiegroup.
the class LiteralExpressionPMMLDocumentModelEditorDefinition method getEditor.
@Override
public Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> getEditor(final GridCellTuple parent, final Optional<String> nodeUUID, final HasExpression hasExpression, final Optional<HasName> hasName, final boolean isOnlyVisualChangeAllowed, final int nesting) {
return Optional.of(new LiteralExpressionPMMLGrid(parent, nodeUUID, hasExpression, hasName, getGridPanel(), getGridLayer(), makeGridData(() -> Optional.ofNullable((LiteralExpressionPMMLDocumentModel) hasExpression.getExpression())), definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, editorSelectedEvent, refreshFormPropertiesEvent, domainObjectSelectionEvent, getCellEditorControls(), listSelector, translationService, isOnlyVisualChangeAllowed, nesting, headerEditor, readOnlyProvider) {
@Override
protected String getPlaceHolder() {
return translationService.getTranslation(DMNEditorConstants.LiteralExpressionPMMLDocumentModelEditorDefinition_Placeholder);
}
@Override
protected void loadValues(final Consumer<List<String>> consumer) {
final String pmmlDocumentName = getExpressionPMMLValue(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT);
consumer.accept(pmmlDocumentMetadataProvider.getPMMLDocumentModels(pmmlDocumentName));
}
@Override
public Function<GridCellValueTuple, Command> newCellHasValueCommand() {
return (gridCellValueTuple) -> {
final CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation> builder = new CompositeCommand.Builder<>();
// Command to set the PMMLDocumentModel value
builder.addCommand(new SetCellValueCommand(gridCellValueTuple, () -> uiModelMapper, gridLayer::batch));
// Command to set PMMLDocumentModel parameters
getParentFunctionGrid().ifPresent(parentFunctionGrid -> {
final String pmmlDocumentName = getExpressionPMMLValue(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT);
final String pmmlDocumentModelName = StringUtils.createUnquotedString((String) gridCellValueTuple.getValue().getValue());
final List<String> parameters = pmmlDocumentMetadataProvider.getPMMLDocumentModelParameterNames(pmmlDocumentName, pmmlDocumentModelName);
parentFunctionGrid.getExpression().get().ifPresent(function -> {
builder.addCommand(new SetParametersCommand(function, convertParametersToInformationItems(parameters), gridLayer::batch));
});
});
return builder.build();
};
}
private List<InformationItem> convertParametersToInformationItems(final List<String> parameters) {
final List<InformationItem> informationItems = new ArrayList<>();
parameters.forEach(parameter -> informationItems.add(new InformationItem(new Id(), new Description(), new Name(parameter), BuiltInType.ANY.asQName())));
return informationItems;
}
});
}
Aggregations