private static bool seek(IDataCursor ic, int position) { int curPos = 0; if (ic.first()) { while (curPos < position) { if (!ic.next()) { return(false); } curPos++; } return(true); } return(false); }
private static bool seek(IDataCursor ic, int position) { int curPos = 0; if (ic.first()) { while (curPos < position) { if (!ic.next()) { return false; } curPos++; } return true; } return false; }
public static object get(IData parent, WmPathItem pathItem, bool bestEffort, IData origPipe) { if ((parent == null) || (pathItem == null)) { return(null); } Object value = null; if (pathItem.pathType == 0) { IDataCursor cursor = parent.getCursor(); String name = pathItem.name; if (cursor.first(name)) { value = cursor.getValue(); } cursor.destroy(); } else if (pathItem.pathType == 1) { if (pathItem.position < 0) { return(null); } IDataCursor cursor = parent.getCursor(); if (seek(cursor, pathItem.position)) { value = cursor.getValue(); } cursor.destroy(); } else if (pathItem.pathType == 2) { if (pathItem.position < 0) { return(null); } IDataCursor cursor = parent.getCursor(); String name = pathItem.name; int position = pathItem.position; bool find = true; for (int i = 0; i <= position; i++) { if (!cursor.next(name)) { find = false; break; } } if (find) { value = cursor.getValue(); } cursor.destroy(); } else if (pathItem.pathType == 3) { return(null); } if ((!bestEffort) && (!dataCheck(value, pathItem))) { value = null; } if ((value is WmIDataList)) { value = ((WmIDataList)value).getItems(); } if (pathItem.arrayIndex == -1) { return(value); } return(getByArrayIndex(value, pathItem, origPipe)); }
/*protected bool validateMessage(FlowState state, IData pipeline, bool inOpt) * { * NSService svc = getService(state.getNamespace(), NSName.create(getNSName())); * * int vo = inOpt ? svc.getInputValidatorOptions() : svc.getOutputValidatorOptions(); * if (vo == 2) * { * IData val = null; * * NSRecord nsr = inOpt ? svc.getSignature().getInput() : svc.getSignature().getOutput(); * * ValidatorOptions vtorOpts = Validator.getDefaultOptions(); * * Validator vtor = Validator.create(pipeline, nsr, vtorOpts); * boolean valid = false; * Exception ex = null; * try * { * val = vtor.validate(); * IDataCursor ic = val.getCursor(); * if (ic.first("isValid")) * { * valid = IDataUtil.getBoolean(ic); * } * ic.destroy(); * } * catch (Exception e) * { * ex = e; * } * if ((!valid) || (ex != null)) * { * Object[] subs = { svc.getNSName().getFullName(), FlowInvoke.getValidationMsgs(val) }; * if (ex == null) * { * ex = new FlowException(FlowExceptionBundle.class, inOpt? FlowExceptionBundle.FAILED_INPUT_VALIDATION : FlowExceptionBundle.FAILED_OUTPUT_VALIDATION, "", subs); * } * handleError(state, ex); * } * return valid; * } * return true; * }*/ public override void invoke(FlowState flowState) { bool isRoot = FlowState.isRoot(this); bool disabled = false; FlowElement last = flowState.last; if ((last != null) && (!last.enabled)) { disabled = true; } if (flowState.shouldExit(this) || (flowState.error == null && exitOn == SUCCESS && !start && !map && !disabled) || (flowState.error != null && exitOn == FAILURE)) { flowState.done = true; flowState.willExit(); return; } if (flowState.error != null) { FlowExceptionHandler fex = flowState.flowExHandler; if (fex != null) { fex.resetException(); } flowState.error = null; IData pipe = flowState.pipeline; IDataCursor cursor = pipe.getCursor(); while (cursor.first() && cursor.delete()) { } cursor.destroy(); IDataUtil.append(save_pipeline, pipe); } else { save_pipeline = IDataUtil.clone(flowState.pipeline); } if (flowState.pushNextNode() == null) { flowState.done = true; if (isRoot && flowState.incremental) { if (flowState.shouldExit(this) || (flowState.error == null && exitOn == SUCCESS && !start && !map && !disabled) || (flowState.error != null && exitOn == FAILURE)) { flowState.done = true; flowState.willExit(); } } } else { map = flowState.current().type.Equals(TYPE_MAP); } if (start) { start = false; } }