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;
}
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));
}
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;
}
Aggregations