1 24 package org.ofbiz.minilang.method.entityops; 25 26 import org.ofbiz.base.util.Debug; 27 import org.ofbiz.entity.GenericValue; 28 import org.ofbiz.minilang.SimpleMethod; 29 import org.ofbiz.minilang.method.ContextAccessor; 30 import org.ofbiz.minilang.method.MethodContext; 31 import org.ofbiz.minilang.method.MethodOperation; 32 import org.w3c.dom.Element ; 33 34 41 public class CloneValue extends MethodOperation { 42 43 public static final String module = CloneValue.class.getName(); 44 45 ContextAccessor valueAcsr; 46 ContextAccessor newValueAcsr; 47 48 public CloneValue(Element element, SimpleMethod simpleMethod) { 49 super(element, simpleMethod); 50 valueAcsr = new ContextAccessor(element.getAttribute("value-name")); 51 newValueAcsr = new ContextAccessor(element.getAttribute("new-value-name")); 52 } 53 54 public boolean exec(MethodContext methodContext) { 55 GenericValue value = (GenericValue) valueAcsr.get(methodContext); 56 if (value == null) { 57 Debug.logWarning("In clone-value a value was not found with the specified valueAcsr: " + valueAcsr + ", not copying", module); 58 return true; 59 } 60 61 newValueAcsr.put(methodContext, GenericValue.create(value)); 62 return true; 63 } 64 65 public String rawString() { 66 return "<clone-value/>"; 68 } 69 public String expandedString(MethodContext methodContext) { 70 return this.rawString(); 72 } 73 } 74 | Popular Tags |