Search in sources :

Example 1 with DeprecatedOperation

use of org.apache.ofbiz.minilang.method.MethodOperation.DeprecatedOperation in project ofbiz-framework by apache.

the class SimpleMethod method readOperations.

public static List<MethodOperation> readOperations(Element simpleMethodElement, SimpleMethod simpleMethod) throws MiniLangException {
    Assert.notNull("simpleMethodElement", simpleMethodElement, "simpleMethod", simpleMethod);
    List<? extends Element> operationElements = UtilXml.childElementList(simpleMethodElement);
    ArrayList<MethodOperation> methodOperations = new ArrayList<MethodOperation>(operationElements.size());
    if (UtilValidate.isNotEmpty(operationElements)) {
        for (Element curOperElem : operationElements) {
            String nodeName = UtilXml.getNodeNameIgnorePrefix(curOperElem);
            MethodOperation methodOp = null;
            MethodOperation.Factory<MethodOperation> factory = methodOperationFactories.get(nodeName);
            if (factory != null) {
                methodOp = factory.createMethodOperation(curOperElem, simpleMethod);
            } else if ("else".equals(nodeName)) {
            // don't add anything, but don't complain either, this one is handled in the individual operations
            } else {
                MiniLangValidate.handleError("Invalid element found", simpleMethod, curOperElem);
            }
            if (methodOp == null) {
                continue;
            }
            methodOperations.add(methodOp);
            DeprecatedOperation depOp = methodOp.getClass().getAnnotation(DeprecatedOperation.class);
            if (depOp != null) {
                MiniLangValidate.handleError("The " + nodeName + " operation has been deprecated in favor of the " + depOp.value() + " operation", simpleMethod, curOperElem);
            }
        }
    }
    methodOperations.trimToSize();
    return methodOperations;
}
Also used : MethodOperation(org.apache.ofbiz.minilang.method.MethodOperation) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) DeprecatedOperation(org.apache.ofbiz.minilang.method.MethodOperation.DeprecatedOperation)

Aggregations

ArrayList (java.util.ArrayList)1 MethodOperation (org.apache.ofbiz.minilang.method.MethodOperation)1 DeprecatedOperation (org.apache.ofbiz.minilang.method.MethodOperation.DeprecatedOperation)1 Element (org.w3c.dom.Element)1