Search in sources :

Example 1 with HasText

use of org.kie.workbench.common.dmn.api.definition.HasText in project kie-wb-common by kiegroup.

the class DMNDeepCloneProcess method clone.

/**
 * <p>It defines additive fields, specific to DMN domain, to be included in the target</p>
 * <p>Then, the "classic" clone operation, defined in {@link DeepCloneProcess} will be executed</p>
 * <p>Note that {@link DeepCloneProcess} is already taking care of aspects related to look&feel, such as background color, font, etc.</p>
 * <p>Every time we copy a node, in order to respect the name uniqueness logic, a new node will be created with a suffix {@code -X},
 * where {@code X} it is an incremental numeric value</p>
 *
 * @param source node to be cloned
 * @param target destination of the cloning operation
 * @return cloned instance, i.e. target element
 */
@Override
public <S, T> T clone(final S source, final T target) {
    super.clone(source, target);
    if (source instanceof DRGElement) {
        cloneDRGElementBasicInfo((DRGElement) source, (DRGElement) target);
    }
    if (source instanceof HasText) {
        cloneTextElementBasicInfo((HasText) source, (HasText) target);
    }
    if (source instanceof HasVariable) {
        final IsInformationItem sourceVariable = ((HasVariable) source).getVariable();
        final IsInformationItem targetVariable = ((HasVariable) target).getVariable();
        cloneTypeRefInfo(sourceVariable, targetVariable);
    }
    if (source instanceof Decision) {
        cloneDecision((Decision) source, (Decision) target);
    }
    if (source instanceof BusinessKnowledgeModel) {
        cloneBusinessKnowledgeModel((BusinessKnowledgeModel) source, (BusinessKnowledgeModel) target);
    }
    return target;
}
Also used : HasText(org.kie.workbench.common.dmn.api.definition.HasText) HasVariable(org.kie.workbench.common.dmn.api.definition.HasVariable) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) IsInformationItem(org.kie.workbench.common.dmn.api.definition.model.IsInformationItem) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement)

Example 2 with HasText

use of org.kie.workbench.common.dmn.api.definition.HasText in project kie-wb-common by kiegroup.

the class DMNDeepCloneProcess method cloneTextElementBasicInfo.

private void cloneTextElementBasicInfo(final HasText source, final HasText target) {
    final String uniqueNodeName = composeUniqueNodeName(source.getText().getValue());
    target.setText(new Text(uniqueNodeName));
}
Also used : HasText(org.kie.workbench.common.dmn.api.definition.HasText) Text(org.kie.workbench.common.dmn.api.property.dmn.Text)

Example 3 with HasText

use of org.kie.workbench.common.dmn.api.definition.HasText in project kie-wb-common by kiegroup.

the class DRDContextMenuService method cloneDefinition.

private HasContentDefinitionId cloneDefinition(final DMNDiagramElement dmnElement, final Object definition) {
    final HasContentDefinitionId originalDefinition = (HasContentDefinitionId) definition;
    final HasContentDefinitionId clonedDefinition = dmnDeepCloneProcess.clone(originalDefinition);
    clonedDefinition.setContentDefinitionId(originalDefinition.getContentDefinitionId());
    clonedDefinition.setDiagramId(dmnElement.getId().getValue());
    if (definition instanceof HasText && clonedDefinition instanceof HasText) {
        HasText hasText = (HasText) definition;
        ((HasText) clonedDefinition).setText(hasText.getText());
    }
    if (definition instanceof HasName && clonedDefinition instanceof HasName) {
        HasName hasName = (HasName) definition;
        ((HasName) clonedDefinition).setName(hasName.getValue());
    }
    return clonedDefinition;
}
Also used : HasContentDefinitionId(org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId) HasText(org.kie.workbench.common.dmn.api.definition.HasText) HasName(org.kie.workbench.common.dmn.api.definition.HasName)

Aggregations

HasText (org.kie.workbench.common.dmn.api.definition.HasText)3 HasName (org.kie.workbench.common.dmn.api.definition.HasName)1 HasVariable (org.kie.workbench.common.dmn.api.definition.HasVariable)1 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)1 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)1 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)1 IsInformationItem (org.kie.workbench.common.dmn.api.definition.model.IsInformationItem)1 Text (org.kie.workbench.common.dmn.api.property.dmn.Text)1 HasContentDefinitionId (org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId)1