@Test public void testDestroyDecisionWithTopLevelFunction() { final List<Decision> decisions = setupDecisionWithTopLevelFunction(); handler.destroy(DOCUMENT_NAME_ORIGINAL); assertTopLevelLiteralExpression(decisions.get(0)); assertTopLevelFunctionDefinition(decisions.get(1), "", ""); assertTopLevelFunctionDefinition(decisions.get(2), UNAFFECTED_DOCUMENT, UNAFFECTED_MODEL); verify(expressionGrid1).initialiseUiCells(); verify(expressionGrid2).initialiseUiCells(); verify(expressionGrid3).initialiseUiCells(); }
@Override public void destroy(final String oldModelName) { final List<Decision> decisions = getDecisions(); final List<BusinessKnowledgeModel> businessKnowledgeModels = getBusinessKnowledgeModels(); final List<FunctionDefinition> functions = getPMMLFunctionDefinitions(decisions, businessKnowledgeModels); final Map<FunctionDefinition, Context> contexts = getPMMLContexts(functions); final String quotedOldModelName = StringUtils.createQuotedString(oldModelName); for (final Map.Entry<FunctionDefinition, Context> entry : contexts.entrySet()) { final Context context = entry.getValue(); for (final ContextEntry contextEntry : context.getContextEntry()) { if (Objects.equals(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT, contextEntry.getVariable().getName().getValue())) { final Expression expression = contextEntry.getExpression(); if (expression instanceof IsLiteralExpression) { final IsLiteralExpression ile = (IsLiteralExpression) expression; if (Objects.nonNull(ile.getText())) { final Text text = ile.getText(); if (Objects.equals(quotedOldModelName, text.getValue())) { clearContextValues(context); entry.getKey().getFormalParameter().clear(); } } } } } } refreshCachedExpressionGrids(decisions, businessKnowledgeModels); }
PMMLIncludedModelHandler implements DRGElementHandler { @Override public void destroy(final String oldModelName) { final List<Decision> decisions = getDecisions(); final List<BusinessKnowledgeModel> businessKnowledgeModels = getBusinessKnowledgeModels(); final List<FunctionDefinition> functions = getPMMLFunctionDefinitions(decisions, businessKnowledgeModels); final Map<FunctionDefinition, Context> contexts = getPMMLContexts(functions); final String quotedOldModelName = StringUtils.createQuotedString(oldModelName); for (final Map.Entry<FunctionDefinition, Context> entry : contexts.entrySet()) { final Context context = entry.getValue(); for (final ContextEntry contextEntry : context.getContextEntry()) { if (Objects.equals(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT, contextEntry.getVariable().getName().getValue())) { final Expression expression = contextEntry.getExpression(); if (expression instanceof IsLiteralExpression) { final IsLiteralExpression ile = (IsLiteralExpression) expression; if (Objects.nonNull(ile.getText())) { final Text text = ile.getText(); if (Objects.equals(quotedOldModelName, text.getValue())) { clearContextValues(context); entry.getKey().getFormalParameter().clear(); } } } } } } refreshCachedExpressionGrids(decisions, businessKnowledgeModels); } }
PMMLIncludedModelHandler implements DRGElementHandler { @Override public void destroy(final String oldModelName) { final List<Decision> decisions = getDecisions(); final List<BusinessKnowledgeModel> businessKnowledgeModels = getBusinessKnowledgeModels(); final List<FunctionDefinition> functions = getPMMLFunctionDefinitions(decisions, businessKnowledgeModels); final Map<FunctionDefinition, Context> contexts = getPMMLContexts(functions); final String quotedOldModelName = StringUtils.createQuotedString(oldModelName); for (final Map.Entry<FunctionDefinition, Context> entry : contexts.entrySet()) { final Context context = entry.getValue(); for (final ContextEntry contextEntry : context.getContextEntry()) { if (Objects.equals(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT, contextEntry.getVariable().getName().getValue())) { final Expression expression = contextEntry.getExpression(); if (expression instanceof IsLiteralExpression) { final IsLiteralExpression ile = (IsLiteralExpression) expression; if (Objects.nonNull(ile.getText())) { final Text text = ile.getText(); if (Objects.equals(quotedOldModelName, text.getValue())) { clearContextValues(context); entry.getKey().getFormalParameter().clear(); } } } } } } refreshCachedExpressionGrids(decisions, businessKnowledgeModels); } @Inject  PMMLIncludedModelHandler(final DMNGraphUtils dmnGraphUtils,
                                    final SessionManager sessionManager); }
PMMLIncludedModelHandler implements DRGElementHandler { @Override public void destroy(final String oldModelName) { final List<Decision> decisions = getDecisions(); final List<BusinessKnowledgeModel> businessKnowledgeModels = getBusinessKnowledgeModels(); final List<FunctionDefinition> functions = getPMMLFunctionDefinitions(decisions, businessKnowledgeModels); final Map<FunctionDefinition, Context> contexts = getPMMLContexts(functions); final String quotedOldModelName = StringUtils.createQuotedString(oldModelName); for (final Map.Entry<FunctionDefinition, Context> entry : contexts.entrySet()) { final Context context = entry.getValue(); for (final ContextEntry contextEntry : context.getContextEntry()) { if (Objects.equals(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT, contextEntry.getVariable().getName().getValue())) { final Expression expression = contextEntry.getExpression(); if (expression instanceof IsLiteralExpression) { final IsLiteralExpression ile = (IsLiteralExpression) expression; if (Objects.nonNull(ile.getText())) { final Text text = ile.getText(); if (Objects.equals(quotedOldModelName, text.getValue())) { clearContextValues(context); entry.getKey().getFormalParameter().clear(); } } } } } } 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 destroy(final String oldModelName) { final List<Decision> decisions = getDecisions(); final List<BusinessKnowledgeModel> businessKnowledgeModels = getBusinessKnowledgeModels(); final List<FunctionDefinition> functions = getPMMLFunctionDefinitions(decisions, businessKnowledgeModels); final Map<FunctionDefinition, Context> contexts = getPMMLContexts(functions); final String quotedOldModelName = StringUtils.createQuotedString(oldModelName); for (final Map.Entry<FunctionDefinition, Context> entry : contexts.entrySet()) { final Context context = entry.getValue(); for (final ContextEntry contextEntry : context.getContextEntry()) { if (Objects.equals(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT, contextEntry.getVariable().getName().getValue())) { final Expression expression = contextEntry.getExpression(); if (expression instanceof IsLiteralExpression) { final IsLiteralExpression ile = (IsLiteralExpression) expression; if (Objects.nonNull(ile.getText())) { final Text text = ile.getText(); if (Objects.equals(quotedOldModelName, text.getValue())) { clearContextValues(context); entry.getKey().getFormalParameter().clear(); } } } } } } 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);  }