1 24 package org.ofbiz.minilang.method.entityops; 25 26 import java.util.Map ; 27 28 import org.ofbiz.base.util.Debug; 29 import org.ofbiz.entity.GenericEntityException; 30 import org.ofbiz.minilang.SimpleMethod; 31 import org.ofbiz.minilang.method.ContextAccessor; 32 import org.ofbiz.minilang.method.MethodContext; 33 import org.ofbiz.minilang.method.MethodOperation; 34 import org.w3c.dom.Element ; 35 36 43 public class RemoveByAnd extends MethodOperation { 44 45 public static final String module = RemoveByAnd.class.getName(); 46 47 String entityName; 48 ContextAccessor mapAcsr; 49 String doCacheClearStr; 50 51 public RemoveByAnd(Element element, SimpleMethod simpleMethod) { 52 super(element, simpleMethod); 53 entityName = element.getAttribute("entity-name"); 54 mapAcsr = new ContextAccessor(element.getAttribute("map-name")); 55 doCacheClearStr = element.getAttribute("do-cache-clear"); 56 } 57 58 public boolean exec(MethodContext methodContext) { 59 boolean doCacheClear = !"false".equals(doCacheClearStr); 60 String entityName = methodContext.expandString(this.entityName); 61 62 try { 63 methodContext.getDelegator().removeByAnd(entityName, (Map ) mapAcsr.get(methodContext), doCacheClear); 64 } catch (GenericEntityException e) { 65 Debug.logError(e, module); 66 String errMsg = "ERROR: Could not complete the " + simpleMethod.getShortDescription() + " process [problem removing the " + entityName + " entity by and: " + e.getMessage() + "]"; 67 68 if (methodContext.getMethodType() == MethodContext.EVENT) { 69 methodContext.putEnv(simpleMethod.getEventErrorMessageName(), errMsg); 70 methodContext.putEnv(simpleMethod.getEventResponseCodeName(), simpleMethod.getDefaultErrorCode()); 71 } else if (methodContext.getMethodType() == MethodContext.SERVICE) { 72 methodContext.putEnv(simpleMethod.getServiceErrorMessageName(), errMsg); 73 methodContext.putEnv(simpleMethod.getServiceResponseMessageName(), simpleMethod.getDefaultErrorCode()); 74 } 75 return false; 76 } 77 return true; 78 } 79 80 public String rawString() { 81 return "<remove-by-and/>"; 83 } 84 public String expandedString(MethodContext methodContext) { 85 return this.rawString(); 87 } 88 } 89 | Popular Tags |