private static void fillMap (final MapAttribute ma, final java.util.Map m) { java.util.Iterator it = m.keySet().iterator(); while (it.hasNext()) { Object k = it.next(); Object v = m.get(k); if (ma instanceof StringMapAttribute) ma.put(new StringAttribute(k.toString()), java2owfe(v)); else ma.put(java2owfe(k), java2owfe(v)); } }
/** * Turns a java List into an OpenWFE ListAttribute */ public static ListAttribute list2owfe (java.util.List l) { ListAttribute result = new ListAttribute(); java.util.Iterator it = l.iterator(); while (it.hasNext()) { result.add(java2owfe(it.next())); } return result; }
private static void resolveGet (final StringMapAttribute sma, final Object bean, final Method[] getAndSet) { try { final Object value = getAndSet[0].invoke(bean, new Object[] {}); final String attributeName = getAndSet[0].getName().substring(3); final Attribute aValue = java2owfe(value); if (aValue != null) sma.put(attributeName, aValue); } catch (final Throwable t) { log.warn ("resolveGet() failed to get value from "+ getAndSet[0].getName()+"()", t); } }
private static ListAttribute array2owfe (final Object array) { //log.debug("array2owfe()"); final ListAttribute result = new ListAttribute(Array.getLength(array)); //result.setArray(true); for (int i=0; i<Array.getLength(array); i++) result.add(java2owfe(Array.get(array, i))); return result; }
/** * Sets the field '__result__' in the workitem. */ public static void setResult (final InFlowWorkItem wi, final Object result) { wi.getAttributes().put(F_RESULT, AttributeUtils.java2owfe(result)); // the method java2owfe leaves the result untouched if // it's already an Attribute }
/** * Use work item if request scope. */ @Override public void setAttribute(String name, Object value, int scope) { if (scope == Context.LOCAL_SCOPE) { Attribute attr = AttributeUtils.java2owfe(value); try { if (this.workItem.containsAttribute(name)) { log.debug("Attribute {} already set in WorkItem, will overwrite it with value {}", name, attr.toString()); this.workItem.setAttribute(name, attr); } else { this.workItem.addAttribute(name, attr); } } catch (AttributeException e) { log.error("can't set value {}", name, e); } } else { super.setAttribute(name, value, scope); } }
ValueUtils.setResult(wi, AttributeUtils.java2owfe(o));
bean.setIntegers(new int[] { 3, 5, 8, 12 }); li.getAttributes().put("bean", AttributeUtils.java2owfe(bean));
value = AttributeUtils.java2owfe(value);