use of org.kie.workbench.common.dmn.api.property.dmn.DMNExternalLink in project kie-wb-common by kiegroup.
the class DocumentationLinksWidget method refresh.
void refresh() {
final List<DMNExternalLink> all = getValue().getLinks();
RemoveHelper.removeChildren(linksContainer);
for (final DMNExternalLink link : all) {
final DocumentationLinkItem listItem = listItems.get();
listItem.init(link);
listItem.setOnDeleted(this::onExternalLinkDeleted);
linksContainer.appendChild(listItem.getElement());
}
refreshContainersVisibility();
}
use of org.kie.workbench.common.dmn.api.property.dmn.DMNExternalLink in project kie-wb-common by kiegroup.
the class DMNExternalLinksToExtensionElements method loadExternalLinksFromExtensionElements.
static void loadExternalLinksFromExtensionElements(final org.kie.dmn.model.api.DRGElement source, final org.kie.workbench.common.dmn.api.definition.model.DRGElement target) {
if (!Objects.isNull(source.getExtensionElements())) {
for (final Object obj : source.getExtensionElements().getAny()) {
if (obj instanceof ExternalLink) {
final ExternalLink el = (ExternalLink) obj;
final DMNExternalLink external = new DMNExternalLink();
external.setDescription(el.getName());
external.setUrl(el.getUrl());
target.getLinksHolder().getValue().addLink(external);
}
}
}
}
use of org.kie.workbench.common.dmn.api.property.dmn.DMNExternalLink in project kie-wb-common by kiegroup.
the class DocumentationLinkItemTest method testOnDeleteLinkClick.
@Test
public void testOnDeleteLinkClick() {
final Consumer<DMNExternalLink> onDelete = mock(Consumer.class);
documentationLinkItem.setOnDeleted(onDelete);
final DMNExternalLink externalLink = mock(DMNExternalLink.class);
documentationLinkItem.init(externalLink);
documentationLinkItem.onDeleteLinkClick(null);
verify(onDelete).accept(externalLink);
}
use of org.kie.workbench.common.dmn.api.property.dmn.DMNExternalLink in project kie-wb-common by kiegroup.
the class DocumentationLinkItemTest method testInit.
@Test
public void testInit() {
final String url = "http://www.kiegroup.org";
final String description = "My nice description.";
final DMNExternalLink externalLink = new DMNExternalLink();
externalLink.setDescription(description);
externalLink.setUrl(url);
documentationLinkItem.init(externalLink);
assertEquals(description, link.textContent);
assertEquals(url, link.href);
}
use of org.kie.workbench.common.dmn.api.property.dmn.DMNExternalLink in project kie-wb-common by kiegroup.
the class DMNDocumentationDRDsFactoryTest method testCreate.
@Test
public void testCreate() {
final String nodeUUID1 = "1111-1111-1111-1111";
final String nodeUUID2 = "2222-2222-2222-2222";
final Node<View, Edge> node1 = new NodeImpl<>(nodeUUID1);
final Node<View, Edge> node2 = new NodeImpl<>(nodeUUID2);
final View view1 = mock(View.class);
final View view2 = mock(View.class);
final HasExpression hasExpression1 = mock(HasExpression.class);
final List<Node<View, Edge>> nodes = asList(node1, node2);
final Decision drgElement1 = new Decision();
final InputData drgElement2 = new InputData();
final String name1 = "Decision-1";
final String name2 = "Input-data-2";
final String description1 = "Description...";
final InformationItemPrimary variable1 = new InformationItemPrimary();
final QName typeRef1 = BOOLEAN.asQName();
final String image1 = "<image1>";
final DMNExternalLink externalLink = new DMNExternalLink();
final DocumentationLinksHolder linksHolder = new DocumentationLinksHolder();
linksHolder.getValue().addLink(externalLink);
drgElement2.setLinksHolder(linksHolder);
node1.setContent(view1);
node2.setContent(view2);
when(view1.getDefinition()).thenReturn(drgElement1);
when(view2.getDefinition()).thenReturn(drgElement2);
when(expressionHelper.getOptionalHasExpression(node1)).thenReturn(Optional.ofNullable(hasExpression1));
when(expressionHelper.getOptionalHasExpression(node2)).thenReturn(Optional.empty());
when(expressionContainerGrid.getNodeUUID()).thenReturn(Optional.of(nodeUUID2));
when(graph.nodes()).thenReturn(nodes);
doReturn(image1).when(factory).getNodeImage(diagram, node1);
doNothing().when(factory).setExpressionContainerGrid(any(), any());
variable1.setTypeRef(typeRef1);
drgElement1.setVariable(variable1);
drgElement1.setDescription(new Description(description1));
drgElement1.setName(new Name(name1));
drgElement2.setName(new Name(name2));
final List<DMNDocumentationDRD> drds = factory.create(diagram);
final DMNDocumentationDRD documentationDRD1 = drds.get(0);
final DMNDocumentationDRD documentationDRD2 = drds.get(1);
assertEquals(2, drds.size());
assertEquals(name1, documentationDRD1.getDrdName());
assertEquals(BOOLEAN.getName(), documentationDRD1.getDrdType());
assertEquals(description1, documentationDRD1.getDrdDescription());
assertEquals(image1, documentationDRD1.getDrdBoxedExpressionImage());
assertEquals(NONE, documentationDRD2.getDrdDescription());
assertEquals(UNDEFINED.getName(), documentationDRD2.getDrdType());
assertEquals(name2, documentationDRD2.getDrdName());
assertEquals(NONE, documentationDRD2.getDrdBoxedExpressionImage());
assertFalse(documentationDRD1.getHasExternalLinks());
assertTrue(documentationDRD2.getHasExternalLinks());
verify(factory).setExpressionContainerGrid(diagram, nodeUUID2);
}
Aggregations