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); } }
/** * * @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(); }
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());
@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); //} } }
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)); 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()); if (val != null) { params.put(pm.getName(), getAtomicValue(pm.getType(), val));
@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)) {