@Override public T getObject(MethodContext methodContext) { T fieldVal = null; if (!mapAcsr.isEmpty()) { Map<String, ? extends Object> fromMap = mapAcsr.get(methodContext); if (fromMap == null) { Debug.logWarning( "Map not found with name " + mapAcsr + ", not getting Object value, returning null.", module); return null; } fieldVal = fieldAcsr.get(fromMap, methodContext); } else { // no map name, try the env fieldVal = fieldAcsr.get(methodContext); } if (fieldVal == null) { if (Debug.infoOn()) Debug.logInfo( "Field value not found with name " + fieldAcsr + " in Map with name " + mapAcsr + ", not getting Object value, returning null.", module); return null; } return fieldVal; }
@Override public boolean exec(MethodContext methodContext) { Object fieldVal = null; if (!mapAcsr.isEmpty()) { Map<String, ? extends Object> fromMap = mapAcsr.get(methodContext); if (fromMap == null) { if (Debug.infoOn()) Debug.logInfo( "Map not found with name " + mapAcsr + ", not copying from this map", module); return true; } fieldVal = fieldAcsr.get(fromMap, methodContext); } else { // no map name, try the env fieldVal = fieldAcsr.get(methodContext); } if (fieldVal == null) { if (Debug.verboseOn()) Debug.logVerbose( "Field value not found with name " + fieldAcsr + " in Map with name " + mapAcsr + ", not copying field", module); return true; } // note that going to an env field will only work if it came from an env // field because if not specified the to-map-name will be set to the map-name // to go from a map field to an env field, use the field-to-env operation Map<String, Object> toMap = null; if (!toMapAcsr.isEmpty()) { toMap = toMapAcsr.get(methodContext); if (toMap == null) { if (Debug.verboseOn()) Debug.logVerbose("Map not found with name " + toMapAcsr + ", creating new map", module); toMap = FastMap.newInstance(); toMapAcsr.put(methodContext, toMap); } toFieldAcsr.put(toMap, fieldVal, methodContext); } else { // no to-map, so put in env toFieldAcsr.put(methodContext, fieldVal); } return true; }
public FieldToField(Element element, SimpleMethod simpleMethod) { super(element, simpleMethod); mapAcsr = new ContextAccessor<Map<String, Object>>(element.getAttribute("map-name")); fieldAcsr = new ContextAccessor<Object>(element.getAttribute("field-name")); toMapAcsr = new ContextAccessor<Map<String, Object>>(element.getAttribute("to-map-name")); toFieldAcsr = new ContextAccessor<Object>(element.getAttribute("to-field-name")); // set toMapAcsr and toFieldAcsr to their defualt values of mapAcsr and fieldAcsr if empty if (toMapAcsr.isEmpty()) { toMapAcsr = mapAcsr; } if (toFieldAcsr.isEmpty()) { toFieldAcsr = fieldAcsr; } }