private void setNotFoundParam(Map<String, Object> params, String pType, Parameter pm) { // handle default values List<List<String>> atns = fn.getAnnotations().get(pType); if (atns != null) { String pName = pm.getName(); String xpName = "{$" + pm.getName() + "}"; for (List<String> values: atns) { if (values.size() > 2) { if (pName.equals(values.get(0)) || xpName.equals(values.get(1))) { params.put(pm.getName(), getAtomicValue(pm.getType(), values.get(2))); return; } } } } if (pm.getCardinality().isOptional()) { // pass empty value.. params.put(pm.getName(), null); } }
protected Parameter buildParam(String type, String value) { return new Parameter(value, type, Cardinality.one); }
@Override public String toString() { return "Parameter [name=" + name + ", type=" + getType() + ", cardinality=" + getCardinality() + "]"; }
XName name = new XName(e.getKey()); XdmValue value; switch (e.getValue().getType()) { case "boolean": { value = ValueFactory.newXSBoolean(new Boolean(e.getValue().getName())); break; case "long": case "short": { value = ValueFactory.newXSInteger(new Integer(e.getValue().getName())); break; value = ValueFactory.newValue(ValueType.XS_DOUBLE, new Double(e.getValue().getName())); break; value = ValueFactory.newValue(ValueType.XS_FLOAT, new Float(e.getValue().getName())); break; value = ValueFactory.newXSString(e.getValue().getName());
private Class[] buildParams() throws ClassNotFoundException { Class[] result = new Class[xdf.getParameters().size()]; int idx = 0; for (Parameter xp: xdf.getParameters()) { result[idx] = ReflectUtils.type2Class(xp.getType()); idx++; } return result; }
@Override protected int execCommand(String command, Map<String, Parameter> params) throws RequestException { if ("insertDocument".equals(command)) { ContentCreateOptions options = ContentCreateOptions.newXmlInstance(); //options.setNamespace("MyNameSpace"); String collect = params.get("collect").getName(); if (collect != null) { options.setCollections(new String[] {collect}); } String prefix = params.get("prefix").getName(); if (prefix == null) { prefix = "doc"; } String uri = prefix + cnt.getAndIncrement() + ".xml"; String doc = params.get("doc").getName(); Content content = ContentFactory.newContent(uri, doc, options); ContentSource xcs = getContentSource(); Session xss = xcs.newSession(); xss.insertContent(content); xss.close(); return 1; } return 0; }
private void bindParams(Map<String, Parameter> params, XQDynamicContext xqe) throws XQException { for (Map.Entry<String, Parameter> e: params.entrySet()) { Parameter param = e.getValue(); //if ("properties".equals(param.getType())) { // create and bind sequence with properties // Properties props; // try { // props = propsFromString(param.getName()); // } catch (IOException ex) { // logger.warn("bindParams.error; " + ex, ex); // continue; // } //XQItemType type = getConnection().createAtomicType(baseType, typeName, null); //XQSequence seq = getConnection().createSequence((java.util.Iterator) null); //xqe.bindSequence(new QName(e.getKey()), seq); // XQSequenceType type = getConnection().createSequenceType(getConnection().createItemType(), XQSequenceType.OCC_ZERO_OR_MORE); //getConnection().createSequenceType( // getConnection().createAtomicType(XQItemType.XQBASETYPE_STRING), XQSequenceType.OCC_ZERO_OR_MORE), XQSequenceType.OCC_ZERO_OR_MORE); //xqe.bindObject(new QName(e.getKey()), props, type); //} else { QName typeName = new QName(xs_ns, param.getType(), xs_prefix); int baseType = getBaseTypeForTypeName(typeName); XQItemType type = getConnection().createAtomicType(baseType, typeName, null); //xqe.bindAtomicValue(new QName(e.getKey()), param.getName(), type); xqe.bindObject(new QName(e.getKey()), getAtomicValue(baseType, param.getName()), type); //} } }
private Object extractBodyValue(ContainerRequestContext context, Parameter pm, String content) { //throws IOException { logger.trace("extractBodyValue.enter; got param: {}; content: {}; mediaType: {}", pm, content, context.getMediaType()); if (isBaseType(pm.getType())) { if (pm.getCardinality().isMultiple()) { List<String> values = new ArrayList<>(1); values.add(content); return getSequenceValue(pm.getType(), values); } else { return getAtomicValue(pm.getType(), content); } } else if (pm.getType().startsWith("map(")) { if (isSubtypeOf(context, "json")) { return mapFromJSON(content); } if (isSubtypeOf(context, "xml")) { return mapFromXML(content); } } else if (pm.getType().startsWith("document-node(")) { try { return textToDocument(content); } catch (IOException ex) { logger.error("", ex); return null; } } else if (pm.getType().startsWith("item(")) { return content; } return content; }
@Override public void write(ObjectDataOutput out, Parameter xParam) throws IOException { out.writeUTF(xParam.getName()); out.writeUTF(xParam.getType()); out.writeInt(xParam.getCardinality().ordinal()); }
String pName = param.getName(); io.swagger.models.parameters.Parameter pm = null; if (RestRequestProcessor.isPathParameter(rm.fn, pName)) { pm = new PathParameter().type(param.getType()).required(true); } else { String aType = RestRequestProcessor.getParamAnnotationType(rm.fn, pName); switch (aType) { case apn_cookie: { pm = new CookieParameter().type(param.getType()); break; pm = new FormParameter().type(param.getType()); break; pm = new HeaderParameter().type(param.getType()); break; "Please add custom client code to pass the parameter properly.").items(new MapProperty(new StringProperty())).type(param.getType()); pm = new QueryParameter().type(param.getType()); break;
clsa.add(ReflectUtils.type2Class(type)); Parameter xdp = new Parameter(name, type, Cardinality.one); xdf.getParameters().add(xdp);
/** * * @return the complete function signature */ public String getSignature() { StringBuilder buff = new StringBuilder(); if (className != null) { buff.append(className).append("."); } else if (prefix != null) { buff.append(prefix).append(":"); } buff.append(method).append("("); int idx = 0; for (Parameter xp: parameters) { if (idx > 0) { buff.append(", "); } buff.append(xp.getName()).append(" ").append(xp.getType()).append(xp.getCardinality().shortPresentation()); idx++; } buff.append("): ").append(result.getType()).append(result.getCardinality().shortPresentation()); //.append(";"); return buff.toString(); }
@Override public Parameter read(ObjectDataInput in) throws IOException { Parameter xParam = new Parameter( in.readUTF(), in.readUTF(), Cardinality.values()[in.readInt()]); return xParam; }
if (isPathParameter(fn, pm.getName())) { List<String> vals = context.getUriInfo().getPathParameters().get(pm.getName()); if (vals != null) { params.put(pm.getName(), getAtomicValue(pm.getType(), vals.get(0))); String aType = getParamAnnotationType(fn, pm.getName()); logger.trace("getParameters; param annotation: {}", aType); if (aType == null) { params.put(pm.getName(), extractBodyValue(context, pm, body)); switch (aType) { case apn_cookie: { Cookie val = context.getCookies().get(pm.getType()); if (val != null) { params.put(pm.getName(), getAtomicValue(pm.getType(), val.getValue())); found = true; String val = getParamValue(body, "&", pm.getName()); if (val != null) { params.put(pm.getName(), getAtomicValue(pm.getType(), val)); found = true; String val = context.getHeaderString(pm.getName()); //atns.get(0)); !!! if (val != null) { params.put(pm.getName(), getAtomicValue(pm.getType(), val)); found = true; String val = getParamValue(context.getUriInfo().getPath(), "&", pm.getName());
Function result = new Function(null, fn.getFunctionName().getLocalPart(), type, null, fn.getFunctionName().getPrefix()); for (UserFunctionParameter ufp: fn.getParameterDefinitions()) { Parameter param = new Parameter(ufp.getVariableQName().getLocalPart(), getTypeName(ufp.getRequiredType().getPrimaryType()), getCardinality(ufp.getRequiredType().getCardinality())); result.getParameters().add(param);