@Test public void testUpdateBusinessKnowledgeModelWithTopLevelFunction() { final List<BusinessKnowledgeModel> bkms = setupBusinessKnowledgeModelWithTopLevelFunction(); handler.update(DOCUMENT_NAME_ORIGINAL, DOCUMENT_NAME_UPDATED); assertTopLevelLiteralExpression(bkms.get(0)); assertPMMLContextDefinition(bkms.get(1).getEncapsulatedLogic(), DOCUMENT_NAME_UPDATED, MODEL_NAME); assertPMMLContextDefinition(bkms.get(2).getEncapsulatedLogic(), UNAFFECTED_DOCUMENT, UNAFFECTED_MODEL); verify(expressionGrid1).initialiseUiCells(); verify(expressionGrid2).initialiseUiCells(); verify(expressionGrid3).initialiseUiCells(); }
@Override public void update(final String oldModelName, final String newModelName) { final List<Decision> decisions = getDecisions(); final List<BusinessKnowledgeModel> businessKnowledgeModels = getBusinessKnowledgeModels(); final List<FunctionDefinition> functions = getPMMLFunctionDefinitions(decisions, businessKnowledgeModels); final Collection<Context> contexts = getPMMLContexts(functions).values(); final String quotedOldModelName = StringUtils.createQuotedString(oldModelName); final String quotedNewModelName = StringUtils.createQuotedString(newModelName); contexts.stream() .map(Context::getContextEntry) .flatMap(Collection::stream) .filter(ce -> Objects.equals(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT, ce.getVariable().getName().getValue())) .filter(ce -> ce.getExpression() instanceof IsLiteralExpression) .map(ce -> (IsLiteralExpression) ce.getExpression()) .filter(ile -> Objects.nonNull(ile.getText())) .map(IsLiteralExpression::getText) .filter(text -> Objects.equals(quotedOldModelName, text.getValue())) .forEach(text -> text.setValue(quotedNewModelName)); refreshCachedExpressionGrids(decisions, businessKnowledgeModels); }
PMMLIncludedModelHandler implements DRGElementHandler { @Override public void update(final String oldModelName, final String newModelName) { final List<Decision> decisions = getDecisions(); final List<BusinessKnowledgeModel> businessKnowledgeModels = getBusinessKnowledgeModels(); final List<FunctionDefinition> functions = getPMMLFunctionDefinitions(decisions, businessKnowledgeModels); final Collection<Context> contexts = getPMMLContexts(functions).values(); final String quotedOldModelName = StringUtils.createQuotedString(oldModelName); final String quotedNewModelName = StringUtils.createQuotedString(newModelName); contexts.stream() .map(Context::getContextEntry) .flatMap(Collection::stream) .filter(ce -> Objects.equals(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT, ce.getVariable().getName().getValue())) .filter(ce -> ce.getExpression() instanceof IsLiteralExpression) .map(ce -> (IsLiteralExpression) ce.getExpression()) .filter(ile -> Objects.nonNull(ile.getText())) .map(IsLiteralExpression::getText) .filter(text -> Objects.equals(quotedOldModelName, text.getValue())) .forEach(text -> text.setValue(quotedNewModelName)); refreshCachedExpressionGrids(decisions, businessKnowledgeModels); } }
PMMLIncludedModelHandler implements DRGElementHandler { @Override public void update(final String oldModelName, final String newModelName) { final List<Decision> decisions = getDecisions(); final List<BusinessKnowledgeModel> businessKnowledgeModels = getBusinessKnowledgeModels(); final List<FunctionDefinition> functions = getPMMLFunctionDefinitions(decisions, businessKnowledgeModels); final Collection<Context> contexts = getPMMLContexts(functions).values(); final String quotedOldModelName = StringUtils.createQuotedString(oldModelName); final String quotedNewModelName = StringUtils.createQuotedString(newModelName); contexts.stream() .map(Context::getContextEntry) .flatMap(Collection::stream) .filter(ce -> Objects.equals(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT, ce.getVariable().getName().getValue())) .filter(ce -> ce.getExpression() instanceof IsLiteralExpression) .map(ce -> (IsLiteralExpression) ce.getExpression()) .filter(ile -> Objects.nonNull(ile.getText())) .map(IsLiteralExpression::getText) .filter(text -> Objects.equals(quotedOldModelName, text.getValue())) .forEach(text -> text.setValue(quotedNewModelName)); refreshCachedExpressionGrids(decisions, businessKnowledgeModels); } @Inject  PMMLIncludedModelHandler(final DMNGraphUtils dmnGraphUtils,
                                    final SessionManager sessionManager); }
PMMLIncludedModelHandler implements DRGElementHandler { @Override public void update(final String oldModelName, final String newModelName) { final List<Decision> decisions = getDecisions(); final List<BusinessKnowledgeModel> businessKnowledgeModels = getBusinessKnowledgeModels(); final List<FunctionDefinition> functions = getPMMLFunctionDefinitions(decisions, businessKnowledgeModels); final Collection<Context> contexts = getPMMLContexts(functions).values(); final String quotedOldModelName = StringUtils.createQuotedString(oldModelName); final String quotedNewModelName = StringUtils.createQuotedString(newModelName); contexts.stream() .map(Context::getContextEntry) .flatMap(Collection::stream) .filter(ce -> Objects.equals(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT, ce.getVariable().getName().getValue())) .filter(ce -> ce.getExpression() instanceof IsLiteralExpression) .map(ce -> (IsLiteralExpression) ce.getExpression()) .filter(ile -> Objects.nonNull(ile.getText())) .map(IsLiteralExpression::getText) .filter(text -> Objects.equals(quotedOldModelName, text.getValue())) .forEach(text -> text.setValue(quotedNewModelName)); refreshCachedExpressionGrids(decisions, businessKnowledgeModels); } @Inject  PMMLIncludedModelHandler(final DMNGraphUtils dmnGraphUtils,
                                    final SessionManager sessionManager); @Override void update(final String oldModelName,
                       final String newModelName); @Override void destroy(final String oldModelName); }
PMMLIncludedModelHandler implements DRGElementHandler { @Override public void update(final String oldModelName, final String newModelName) { final List<Decision> decisions = getDecisions(); final List<BusinessKnowledgeModel> businessKnowledgeModels = getBusinessKnowledgeModels(); final List<FunctionDefinition> functions = getPMMLFunctionDefinitions(decisions, businessKnowledgeModels); final Collection<Context> contexts = getPMMLContexts(functions).values(); final String quotedOldModelName = StringUtils.createQuotedString(oldModelName); final String quotedNewModelName = StringUtils.createQuotedString(newModelName); contexts.stream() .map(Context::getContextEntry) .flatMap(Collection::stream) .filter(ce -> Objects.equals(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT, ce.getVariable().getName().getValue())) .filter(ce -> ce.getExpression() instanceof IsLiteralExpression) .map(ce -> (IsLiteralExpression) ce.getExpression()) .filter(ile -> Objects.nonNull(ile.getText())) .map(IsLiteralExpression::getText) .filter(text -> Objects.equals(quotedOldModelName, text.getValue())) .forEach(text -> text.setValue(quotedNewModelName)); refreshCachedExpressionGrids(decisions, businessKnowledgeModels); } @Inject  PMMLIncludedModelHandler(final DMNGraphUtils dmnGraphUtils,
                                    final SessionManager sessionManager); @Override void update(final String oldModelName,
                       final String newModelName); @Override void destroy(final String oldModelName);  }