diff --git a/modules/xmcp/guihttp/filterimpl/H5XdevFilter/src/com/gip/xyna/xact/filter/session/workflowissues/ModelledExpressionManagement.java b/modules/xmcp/guihttp/filterimpl/H5XdevFilter/src/com/gip/xyna/xact/filter/session/workflowissues/ModelledExpressionManagement.java index 920de4a93..fd417ceca 100644 --- a/modules/xmcp/guihttp/filterimpl/H5XdevFilter/src/com/gip/xyna/xact/filter/session/workflowissues/ModelledExpressionManagement.java +++ b/modules/xmcp/guihttp/filterimpl/H5XdevFilter/src/com/gip/xyna/xact/filter/session/workflowissues/ModelledExpressionManagement.java @@ -20,6 +20,7 @@ +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -61,7 +62,8 @@ import com.gip.xyna.xprc.xfractwfe.formula.Variable; import com.gip.xyna.xprc.xfractwfe.formula.VariableAccessPart; import com.gip.xyna.xprc.xfractwfe.formula.VariableInstanceFunctionIncovation; -import com.gip.xyna.xprc.xfractwfe.generation.DomOrExceptionGenerationBase; +import com.gip.xyna.xprc.xfractwfe.generation.DomOrExceptionGenerationBase; +import com.gip.xyna.xprc.xfractwfe.generation.GenerationBase; import com.gip.xyna.xprc.xfractwfe.generation.ModelledExpression; import com.gip.xyna.xprc.xfractwfe.generation.ModelledExpression.EmptyVisitor; import com.gip.xyna.xprc.xfractwfe.generation.Operation; @@ -513,11 +515,11 @@ private TypeInfo determineFunctionExpressionResultType(FunctionExpression fe) { private TypeInfo determineTypeOfFollowAbleVariable(Variable var) { TypeInfo ti; try { - ti = var.getFollowedVariable().getTypeInfo(true); + ti = var.getFollowedVariable().getTypeInfo(true); + boolean isList = var.getFollowedVariable().getTypeInfo(false).isList(); if (ti.isBaseType()) { - return ti; + return new TypeInfo(ti.getBaseType(), isList); } else if (ti.isModelledType()) { - boolean isList = var.getFollowedVariable().getTypeInfo(false).isList(); if(isList && var.lastPartOfVariableHasListAccess()) { isList = false; } @@ -656,13 +658,34 @@ private List getOperationInputs(Step step, Variable var, String opera } DOM dom = (DOM)doe; - try { - result = dom.getOperationByName(operationName).getInputVars(); + try { + if (GenerationBase.isReservedServerObjectByFqClassName(dom.getFqClassName())) { + result = getInputOfReservedOperation(dom, GenerationBase.getReservedClass(dom.getOriginalFqName()), operationName); + } else { + result = dom.getOperationByName(operationName).getInputVars(); + } } catch (XPRC_OperationUnknownException e) { throw new InvalidFunctionException(); } return result; + } + + private List getInputOfReservedOperation(DOM dom, Class clazz, String operationName) throws XPRC_OperationUnknownException { + Method[] methods = clazz.getMethods(); + for (int i = 0; i < methods.length; i++) { + Method method = methods[i]; + if (method.getName().equals(operationName)) { + List result = new ArrayList(); + Class[] inputs = method.getParameterTypes(); + for (Class input : inputs) { + AVariable var = TypeToAVariableConverter.convert(dom, input); + result.add(var); + } + return result; + } + } + throw new XPRC_OperationUnknownException(operationName); } @Override diff --git a/modules/xmcp/guihttp/filterimpl/H5XdevFilter/src/com/gip/xyna/xact/filter/session/workflowissues/TypeToAVariableConverter.java b/modules/xmcp/guihttp/filterimpl/H5XdevFilter/src/com/gip/xyna/xact/filter/session/workflowissues/TypeToAVariableConverter.java new file mode 100644 index 000000000..f98e5141a --- /dev/null +++ b/modules/xmcp/guihttp/filterimpl/H5XdevFilter/src/com/gip/xyna/xact/filter/session/workflowissues/TypeToAVariableConverter.java @@ -0,0 +1,66 @@ +/* + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Copyright 2024 Xyna GmbH, Germany + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + */ +package com.gip.xyna.xact.filter.session.workflowissues; + + + +import com.gip.xyna.xprc.exceptions.XPRC_InvalidPackageNameException; +import com.gip.xyna.xprc.xfractwfe.generation.AVariable; +import com.gip.xyna.xprc.xfractwfe.generation.AVariable.PrimitiveType; +import com.gip.xyna.xprc.xfractwfe.generation.DOM; +import com.gip.xyna.xprc.xfractwfe.generation.DatatypeVariable; +import com.gip.xyna.xprc.xfractwfe.generation.GenerationBase; + + + +public class TypeToAVariableConverter { + + + public static AVariable convert(DOM dom, Class clazz) { + AVariable result; + + PrimitiveType primitiveType = AVariable.PrimitiveType.createOrNull(clazz.getCanonicalName()); + if (primitiveType != null) { + result = createPrimitiveTypeAVariable(dom, primitiveType); + } else { + result = createModelledTypeAvariable(dom, clazz); + } + + return result; + } + + + private static AVariable createPrimitiveTypeAVariable(DOM dom, PrimitiveType type) { + DatatypeVariable result = new DatatypeVariable(dom); + result.create(type); + return result; + } + + + private static AVariable createModelledTypeAvariable(DOM dom, Class clazz) { + DatatypeVariable result = new DatatypeVariable(dom); + try { + boolean isReserved = GenerationBase.isReservedServerObjectByFqClassName(clazz.getCanonicalName()); + String fqOriginalName = isReserved ? GenerationBase.getXmlNameForReservedClass(clazz) : clazz.getCanonicalName(); + result.create(fqOriginalName); + } catch (XPRC_InvalidPackageNameException e) { + throw new RuntimeException(e); + } + return result; + } +}