You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2014/11/03 07:54:24 UTC
svn commit: r1636282 [18/20] - in
/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23: ./
applications/content/config/ applications/content/data/
applications/humanres/src/org/ofbiz/humanres/
applications/humanres/webapp/humanres/WEB-INF/ applica...
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java Mon Nov 3 06:54:16 2014
@@ -20,8 +20,11 @@ package org.ofbiz.widget.tree;
import java.io.IOException;
import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
@@ -29,9 +32,6 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.xml.parsers.ParserConfigurationException;
-import javolution.util.FastList;
-import javolution.util.FastMap;
-
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.GeneralException;
import org.ofbiz.base.util.StringUtil;
@@ -43,11 +43,6 @@ import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.UtilXml;
import org.ofbiz.base.util.collections.MapStack;
import org.ofbiz.base.util.string.FlexibleStringExpander;
-import org.ofbiz.widget.WidgetWorker;
-import org.ofbiz.widget.screen.ModelScreen;
-import org.ofbiz.widget.screen.ScreenFactory;
-import org.ofbiz.widget.screen.ScreenStringRenderer;
-import org.ofbiz.widget.screen.ScreenRenderException;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
@@ -56,6 +51,13 @@ import org.ofbiz.entity.model.ModelField
import org.ofbiz.entity.util.EntityListIterator;
import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.widget.ModelWidget;
+import org.ofbiz.widget.ModelWidgetAction;
+import org.ofbiz.widget.ModelWidgetVisitor;
+import org.ofbiz.widget.WidgetWorker;
+import org.ofbiz.widget.screen.ModelScreen;
+import org.ofbiz.widget.screen.ScreenFactory;
+import org.ofbiz.widget.screen.ScreenRenderException;
+import org.ofbiz.widget.screen.ScreenStringRenderer;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
@@ -67,28 +69,25 @@ public class ModelTree extends ModelWidg
public static final String module = ModelTree.class.getName();
- protected String treeLocation;
- protected String rootNodeName;
+ protected String defaultEntityName;
+ protected String defaultPkName;
protected String defaultRenderStyle;
protected FlexibleStringExpander defaultWrapStyleExdr;
- protected List<ModelNode> nodeList = FastList.newInstance();
- protected Map<String, ModelNode> nodeMap = FastMap.newInstance();
protected Delegator delegator;
protected LocalDispatcher dispatcher;
protected FlexibleStringExpander expandCollapseRequestExdr;
- protected FlexibleStringExpander trailNameExdr;
+ protected boolean forceChildCheck;
+ protected List<ModelNode> nodeList = new ArrayList<ModelNode>();
+ protected Map<String, ModelNode> nodeMap = new HashMap<String, ModelNode>();
protected int openDepth;
protected int postTrailOpenDepth;
- protected String defaultEntityName;
- protected String defaultPkName;
- protected boolean forceChildCheck;
+ protected String rootNodeName;
+ protected FlexibleStringExpander trailNameExdr;
+ protected String treeLocation;
// ===== CONSTRUCTORS =====
/** Default Constructor */
- /** XML Constructor */
- public ModelTree() {}
-
public ModelTree(Element treeElement, Delegator delegator, LocalDispatcher dispatcher) {
super(treeElement);
this.rootNodeName = treeElement.getAttribute("root-node-name");
@@ -126,9 +125,8 @@ public class ModelTree extends ModelWidg
}
if (nodeList.size() == 0) {
- throw new IllegalArgumentException("No node elements found for the tree definition with name: " + this.name);
+ throw new IllegalArgumentException("No node elements found for the tree definition with name: " + getName());
}
-
}
public void setDefaultEntityName(String name) {
@@ -205,7 +203,7 @@ public class ModelTree extends ModelWidg
@Override
public String getBoundaryCommentName() {
- return treeLocation + "#" + name;
+ return treeLocation + "#" + getName();
}
public void setTreeLocation(String treeLocation) {
@@ -227,6 +225,7 @@ public class ModelTree extends ModelWidg
* different tree elements; implementing your own makes it possible to
* use the same tree definitions for many types of tree UIs
*/
+ @SuppressWarnings("rawtypes")
public void renderTreeString(StringBuffer buf, Map<String, Object> context, TreeStringRenderer treeStringRenderer) throws GeneralException {
Map<String, Object> parameters = UtilGenerics.checkMap(context.get("parameters"));
@@ -246,16 +245,16 @@ public class ModelTree extends ModelWidg
context.put("rootEntityId", trail.get(0));
context.put(defaultPkName, trail.get(0));
} else {
- trail = FastList.newInstance();
+ trail = new LinkedList<String>();
}
context.put("targetNodeTrail", trail);
- context.put("currentNodeTrail", FastList.newInstance());
+ context.put("currentNodeTrail", new LinkedList());
StringWriter writer = new StringWriter();
try {
node.renderNodeString(writer, context, treeStringRenderer, 0);
buf.append(writer.toString());
} catch (IOException e2) {
- String errMsg = "Error rendering included label with name [" + name + "] : " + e2.toString();
+ String errMsg = "Error rendering included label with name [" + getName() + "] : " + e2.toString();
Debug.logError(e2, errMsg, module);
throw new RuntimeException(errMsg);
}
@@ -274,31 +273,29 @@ public class ModelTree extends ModelWidg
}
- public static class ModelNode {
+ public static class ModelNode extends ModelWidget {
- protected FlexibleStringExpander screenNameExdr;
- protected FlexibleStringExpander screenLocationExdr;
- protected String shareScope;
+ private final List<ModelWidgetAction> actions;
+ protected ModelTreeCondition condition;
+ protected String entityName;
+ protected String entryName;
+ protected String expandCollapseStyle;
+ protected Image image;
protected Label label;
protected Link link;
- protected Image image;
- protected List<ModelSubNode> subNodeList = FastList.newInstance();
- protected List<ModelTreeAction> actions = FastList.newInstance();
- protected String name;
protected ModelTree modelTree;
+ protected String name;
+ protected String pkName;
+ protected String renderStyle;
+ protected FlexibleStringExpander screenLocationExdr;
+ protected FlexibleStringExpander screenNameExdr;
+ protected String shareScope;
+ protected List<ModelSubNode> subNodeList = new ArrayList<ModelSubNode>();
protected List<Object []> subNodeValues;
- protected String expandCollapseStyle;
protected FlexibleStringExpander wrapStyleExdr;
- protected ModelTreeCondition condition;
- protected String renderStyle;
- protected String entryName;
- protected String entityName;
- protected String pkName;
-
- public ModelNode() {}
public ModelNode(Element nodeElement, ModelTree modelTree) {
-
+ super(nodeElement);
this.modelTree = modelTree;
this.name = nodeElement.getAttribute("name");
this.expandCollapseStyle = nodeElement.getAttribute("expand-collapse-style");
@@ -308,21 +305,25 @@ public class ModelTree extends ModelWidg
setEntityName(nodeElement.getAttribute("entity-name"));
if (this.pkName == null || nodeElement.hasAttribute("join-field-name"))
this.pkName = nodeElement.getAttribute("join-field-name");
-
+ ArrayList<ModelWidgetAction> actions = new ArrayList<ModelWidgetAction>();
+ Element actionsElement = UtilXml.firstChildElement(nodeElement, "actions");
+ if (actionsElement != null) {
+ actions.addAll(ModelTreeAction.readNodeActions(this, actionsElement));
+ }
Element actionElement = UtilXml.firstChildElement(nodeElement, "entity-one");
if (actionElement != null) {
- actions.add(new ModelTreeAction.EntityOne(this, actionElement));
+ actions.add(new ModelWidgetAction.EntityOne(this, actionElement));
}
-
actionElement = UtilXml.firstChildElement(nodeElement, "service");
if (actionElement != null) {
actions.add(new ModelTreeAction.Service(this, actionElement));
}
-
actionElement = UtilXml.firstChildElement(nodeElement, "script");
if (actionElement != null) {
actions.add(new ModelTreeAction.Script(this, actionElement));
}
+ actions.trimToSize();
+ this.actions = Collections.unmodifiableList(actions);
Element screenElement = UtilXml.firstChildElement(nodeElement, "include-screen");
if (screenElement != null) {
@@ -545,13 +546,13 @@ public class ModelTree extends ModelWidg
}
public void getChildren(Map<String, Object> context) {
- this.subNodeValues = FastList.newInstance();
+ this.subNodeValues = new ArrayList<Object []>();
for (ModelSubNode subNode: subNodeList) {
String nodeName = subNode.getNodeName(context);
ModelNode node = modelTree.nodeMap.get(nodeName);
- List<ModelTreeAction> subNodeActions = subNode.getActions();
+ List<ModelWidgetAction> subNodeActions = subNode.getActions();
//if (Debug.infoOn()) Debug.logInfo(" context.currentValue:" + context.get("currentValue"), module);
- ModelTreeAction.runSubActions(subNodeActions, context);
+ ModelWidgetAction.runSubActions(subNodeActions, context);
// List dataFound = (List)context.get("dataFound");
Iterator<? extends Map<String, ? extends Object>> dataIter = subNode.getListIterator();
if (dataIter instanceof EntityListIterator) {
@@ -695,40 +696,40 @@ public class ModelTree extends ModelWidg
this.pkName = pkName;
}
- public static class ModelSubNode {
+ public static class ModelSubNode extends ModelWidget {
+ private final List<ModelWidgetAction> actions;
protected ModelNode rootNode;
protected FlexibleStringExpander nodeNameExdr;
- protected List<ModelTreeAction> actions = FastList.newInstance();
protected ListIterator<? extends Map<String, ? extends Object>> listIterator;
- public ModelSubNode() {}
-
- public ModelSubNode(Element nodeElement, ModelNode modelNode) {
-
+ public ModelSubNode(Element subNodeElement, ModelNode modelNode) {
+ super(subNodeElement);
this.rootNode = modelNode;
- this.nodeNameExdr = FlexibleStringExpander.getInstance(nodeElement.getAttribute("node-name"));
-
- Element actionElement = UtilXml.firstChildElement(nodeElement, "entity-and");
+ this.nodeNameExdr = FlexibleStringExpander.getInstance(subNodeElement.getAttribute("node-name"));
+ ArrayList<ModelWidgetAction> actions = new ArrayList<ModelWidgetAction>();
+ Element actionsElement = UtilXml.firstChildElement(subNodeElement, "actions");
+ if (actionsElement != null) {
+ actions.addAll(ModelTreeAction.readNodeActions(this, actionsElement));
+ }
+ Element actionElement = UtilXml.firstChildElement(subNodeElement, "entity-and");
if (actionElement != null) {
actions.add(new ModelTreeAction.EntityAnd(this, actionElement));
}
-
- actionElement = UtilXml.firstChildElement(nodeElement, "service");
+ actionElement = UtilXml.firstChildElement(subNodeElement, "service");
if (actionElement != null) {
actions.add(new ModelTreeAction.Service(this, actionElement));
}
-
- actionElement = UtilXml.firstChildElement(nodeElement, "entity-condition");
+ actionElement = UtilXml.firstChildElement(subNodeElement, "entity-condition");
if (actionElement != null) {
actions.add(new ModelTreeAction.EntityCondition(this, actionElement));
}
-
- actionElement = UtilXml.firstChildElement(nodeElement, "script");
+ actionElement = UtilXml.firstChildElement(subNodeElement, "script");
if (actionElement != null) {
actions.add(new ModelTreeAction.Script(this, actionElement));
}
-
+ actions.trimToSize();
+ this.actions = Collections.unmodifiableList(actions);
}
public ModelTree.ModelNode getNode() {
@@ -739,7 +740,7 @@ public class ModelTree extends ModelWidg
return this.nodeNameExdr.expandString(context);
}
- public List<ModelTreeAction> getActions() {
+ public List<ModelWidgetAction> getActions() {
return actions;
}
@@ -750,6 +751,11 @@ public class ModelTree extends ModelWidg
public ListIterator<? extends Map<String, ? extends Object>> getListIterator() {
return listIterator;
}
+
+ @Override
+ public void accept(ModelWidgetVisitor visitor) {
+ visitor.visit(this);
+ }
}
public static class Label {
@@ -813,7 +819,7 @@ public class ModelTree extends ModelWidg
protected boolean secure = false;
protected boolean encode = false;
protected String linkType;
- protected List<WidgetWorker.Parameter> parameterList = FastList.newInstance();
+ protected List<WidgetWorker.Parameter> parameterList = new ArrayList<WidgetWorker.Parameter>();
public Link() {
setText(null);
@@ -936,7 +942,7 @@ public class ModelTree extends ModelWidg
}
public Map<String, String> getParameterMap(Map<String, Object> context) {
- Map<String, String> fullParameterMap = FastMap.newInstance();
+ Map<String, String> fullParameterMap = new HashMap<String, String>();
/* leaving this here... may want to add it at some point like the hyperlink element:
Map<String, String> addlParamMap = this.parametersMapAcsr.get(context);
@@ -1108,7 +1114,15 @@ public class ModelTree extends ModelWidg
}
}
}
- }
-}
+ @Override
+ public void accept(ModelWidgetVisitor visitor) {
+ visitor.visit(this);
+ }
+ }
+ @Override
+ public void accept(ModelWidgetVisitor visitor) {
+ visitor.visit(this);
+ }
+}
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java Mon Nov 3 06:54:16 2014
@@ -18,20 +18,16 @@
*******************************************************************************/
package org.ofbiz.widget.tree;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.ListIterator;
-import java.util.Locale;
import java.util.Map;
-import java.util.TimeZone;
import java.util.regex.PatternSyntaxException;
-import javolution.util.FastList;
-import javolution.util.FastMap;
-
-import org.ofbiz.base.util.BshUtil;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.GeneralException;
-import org.ofbiz.base.util.ObjectType;
+import org.ofbiz.base.util.ScriptUtil;
import org.ofbiz.base.util.UtilFormatOut;
import org.ofbiz.base.util.UtilGenerics;
import org.ofbiz.base.util.UtilValidate;
@@ -41,176 +37,104 @@ import org.ofbiz.base.util.string.Flexib
import org.ofbiz.entity.finder.ByAndFinder;
import org.ofbiz.entity.finder.ByConditionFinder;
import org.ofbiz.entity.finder.EntityFinderUtil;
-import org.ofbiz.entity.finder.PrimaryKeyFinder;
import org.ofbiz.entity.util.EntityListIterator;
+import org.ofbiz.minilang.MiniLangException;
+import org.ofbiz.minilang.SimpleMethod;
+import org.ofbiz.minilang.method.MethodContext;
+import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.GenericServiceException;
import org.ofbiz.service.ModelService;
+import org.ofbiz.widget.ModelActionVisitor;
+import org.ofbiz.widget.ModelWidget;
+import org.ofbiz.widget.ModelWidgetAction;
+import org.ofbiz.widget.WidgetWorker;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
* Widget Library - Tree model class
*/
-public abstract class ModelTreeAction {
+@SuppressWarnings("serial")
+public abstract class ModelTreeAction extends ModelWidgetAction {
+
public static final String module = ModelTreeAction.class.getName();
protected ModelTree modelTree;
- protected ModelTree.ModelNode modelNode;
protected ModelTree.ModelNode.ModelSubNode modelSubNode;
public ModelTreeAction(ModelTree.ModelNode modelNode, Element actionElement) {
if (Debug.verboseOn()) Debug.logVerbose("Reading Tree action with name: " + actionElement.getNodeName(), module);
- this.modelNode = modelNode;
this.modelTree = modelNode.getModelTree();
}
public ModelTreeAction(ModelTree.ModelNode.ModelSubNode modelSubNode, Element actionElement) {
if (Debug.verboseOn()) Debug.logVerbose("Reading Tree action with name: " + actionElement.getNodeName(), module);
this.modelSubNode = modelSubNode;
- this.modelNode = this.modelSubNode.getNode();
- this.modelTree = this.modelNode.getModelTree();
+ this.modelTree = modelSubNode.getNode().getModelTree();
}
- public abstract void runAction(Map<String, Object> context);
-
-/*
- public static List readSubActions(ModelTree.ModelNode modelNode, Element parentElement) {
- List actions = new LinkedList();
-
- List actionElementList = UtilXml.childElementList(parentElement);
- Iterator actionElementIter = actionElementList.iterator();
- while (actionElementIter.hasNext()) {
- Element actionElement = (Element) actionElementIter.next();
- if ("set".equals(actionElement.getNodeName())) {
- actions.add(new SetField(modelTree, actionElement));
- } else if ("script".equals(actionElement.getNodeName())) {
- actions.add(new Script(modelTree, actionElement));
- } else if ("service".equals(actionElement.getNodeName())) {
- actions.add(new Service(modelTree, actionElement));
- } else if ("entity-one".equals(actionElement.getNodeName())) {
- actions.add(new EntityOne(modelTree, actionElement));
- } else if ("entity-and".equals(actionElement.getNodeName())) {
- actions.add(new EntityAnd(modelTree, actionElement));
- } else if ("entity-condition".equals(actionElement.getNodeName())) {
- actions.add(new EntityCondition(modelTree, actionElement));
- } else {
- throw new IllegalArgumentException("Action element not supported with name: " + actionElement.getNodeName());
- }
+ public static List<ModelWidgetAction> readNodeActions(ModelWidget modelNode, Element actionsElement) {
+ List<? extends Element> actionElementList = UtilXml.childElementList(actionsElement);
+ List<ModelWidgetAction> actions = new ArrayList<ModelWidgetAction>(actionElementList.size());
+ for (Element actionElement : actionElementList) {
+ // TODO: Check for tree-specific actions
+ actions.add(ModelWidgetAction.toModelWidgetAction(modelNode, actionElement));
}
-
return actions;
}
- */
-
- public static void runSubActions(List<? extends ModelTreeAction> actions, Map<String, Object> context) {
- for (ModelTreeAction action: actions) {
- if (Debug.verboseOn()) Debug.logVerbose("Running tree action " + action.getClass().getName(), module);
- action.runAction(context);
- }
- }
-
- public static class SetField extends ModelTreeAction {
- protected FlexibleMapAccessor<Object> field;
- protected FlexibleMapAccessor<Object> fromField;
- protected FlexibleStringExpander valueExdr;
- protected FlexibleStringExpander globalExdr;
- protected String type;
-
- public SetField(ModelTree.ModelNode modelNode, Element setElement) {
- super (modelNode, setElement);
- this.field = FlexibleMapAccessor.getInstance(setElement.getAttribute("field"));
- this.fromField = FlexibleMapAccessor.getInstance(setElement.getAttribute("from-field"));
- this.valueExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("value"));
- this.globalExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("global"));
- this.type = setElement.getAttribute("type");
- if (!this.fromField.isEmpty() && !this.valueExdr.isEmpty()) {
- throw new IllegalArgumentException("Cannot specify a from-field [" + setElement.getAttribute("from-field") + "] and a value [" + setElement.getAttribute("value") + "] on the set action in a tree widget");
- }
- }
-
- @Override
- public void runAction(Map<String, Object> context) {
- String globalStr = this.globalExdr.expandString(context);
- // default to false
- boolean global = "true".equals(globalStr);
-
- Object newValue = null;
- if (!this.fromField.isEmpty()) {
- newValue = this.fromField.get(context);
- } else if (!this.valueExdr.isEmpty()) {
- newValue = this.valueExdr.expandString(context);
- }
- if (UtilValidate.isNotEmpty(this.type)) {
- if ("NewMap".equals(this.type)) {
- newValue = FastMap.newInstance();
- } else if ("NewList".equals(this.type)) {
- newValue = FastList.newInstance();
- } else {
- try {
- newValue = ObjectType.simpleTypeConvert(newValue, this.type, null, (TimeZone) context.get("timeZone"), (Locale) context.get("locale"), true);
- } catch (GeneralException e) {
- String errMsg = "Could not convert field value for the field: [" + this.field.getOriginalName() + "] to the [" + this.type + "] type for the value [" + newValue + "]: " + e.toString();
- Debug.logError(e, errMsg, module);
- throw new IllegalArgumentException(errMsg);
- }
- }
- }
- this.field.put(context, newValue);
-
- if (global) {
- Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext"));
- if (globalCtx != null) {
- this.field.put(globalCtx, newValue);
- }
- }
-
- // this is a hack for backward compatibility with the JPublish page object
- Map<String, Object> page = UtilGenerics.checkMap(context.get("page"));
- if (page != null) {
- this.field.put(page, newValue);
- }
- }
- }
public static class Script extends ModelTreeAction {
protected String location;
+ protected String method;
public Script(ModelTree.ModelNode modelNode, Element scriptElement) {
super (modelNode, scriptElement);
- this.location = scriptElement.getAttribute("location");
+ String scriptLocation = scriptElement.getAttribute("location");
+ this.location = WidgetWorker.getScriptLocation(scriptLocation);
+ this.method = WidgetWorker.getScriptMethodName(scriptLocation);
}
public Script(ModelTree.ModelNode.ModelSubNode modelSubNode, Element scriptElement) {
super (modelSubNode, scriptElement);
- this.location = scriptElement.getAttribute("location");
+ String scriptLocation = scriptElement.getAttribute("location");
+ this.location = WidgetWorker.getScriptLocation(scriptLocation);
+ this.method = WidgetWorker.getScriptMethodName(scriptLocation);
}
@Override
public void runAction(Map<String, Object> context) {
- if (location.endsWith(".bsh")) {
+ context.put("_LIST_ITERATOR_", null);
+ if (location.endsWith(".xml")) {
+ Map<String, Object> localContext = new HashMap<String, Object>();
+ localContext.putAll(context);
+ DispatchContext ctx = WidgetWorker.getDispatcher(context).getDispatchContext();
+ MethodContext methodContext = new MethodContext(ctx, localContext, null);
try {
- context.put("_LIST_ITERATOR_", null);
- BshUtil.runBshAtLocation(location, context);
- Object obj = context.get("_LIST_ITERATOR_");
- if (this.modelSubNode != null) {
- if (obj != null && (obj instanceof EntityListIterator || obj instanceof ListIterator<?>)) {
- ListIterator<? extends Map<String, ? extends Object>> listIt = UtilGenerics.cast(obj);
- this.modelSubNode.setListIterator(listIt);
- } else {
- if (obj instanceof List<?>) {
- List<? extends Map<String, ? extends Object>> list = UtilGenerics.checkList(obj);
- this.modelSubNode.setListIterator(list.listIterator());
- }
- }
- }
- } catch (GeneralException e) {
- String errMsg = "Error running BSH script at location [" + location + "]: " + e.toString();
- Debug.logError(e, errMsg, module);
- throw new IllegalArgumentException(errMsg);
+ SimpleMethod.runSimpleMethod(location, method, methodContext);
+ context.putAll(methodContext.getResults());
+ } catch (MiniLangException e) {
+ throw new RuntimeException("Error running simple method at location [" + location + "]", e);
}
} else {
- throw new IllegalArgumentException("For tree script actions the script type is not yet support for location:" + location);
+ ScriptUtil.executeScript(this.location, this.method, context);
}
+ Object obj = context.get("_LIST_ITERATOR_");
+ if (this.modelSubNode != null) {
+ if (obj != null && (obj instanceof EntityListIterator || obj instanceof ListIterator<?>)) {
+ ListIterator<? extends Map<String, ? extends Object>> listIt = UtilGenerics.cast(obj);
+ this.modelSubNode.setListIterator(listIt);
+ } else {
+ if (obj instanceof List<?>) {
+ List<? extends Map<String, ? extends Object>> list = UtilGenerics.checkList(obj);
+ this.modelSubNode.setListIterator(list.listIterator());
+ }
+ }
+ }
+ }
+
+ @Override
+ public void accept(ModelActionVisitor visitor) {
+ visitor.visit(this);
}
}
@@ -264,7 +188,7 @@ public abstract class ModelTreeAction {
if (autoFieldMapBool) {
serviceContext = this.modelTree.getDispatcher().getDispatchContext().makeValidContext(serviceNameExpanded, ModelService.IN_PARAM, context);
} else {
- serviceContext = FastMap.newInstance();
+ serviceContext = new HashMap<String, Object>();
}
if (this.fieldMap != null) {
@@ -323,31 +247,10 @@ public abstract class ModelTreeAction {
throw new IllegalArgumentException(errMsg);
}
}
- }
-
- public static class EntityOne extends ModelTreeAction {
- protected PrimaryKeyFinder finder;
- String valueName;
-
- public EntityOne(ModelTree.ModelNode modelNode, Element entityOneElement) {
- super (modelNode, entityOneElement);
-
- this.valueName = UtilFormatOut.checkEmpty(entityOneElement.getAttribute("value"), entityOneElement.getAttribute("value-name"));
- if (UtilValidate.isEmpty(this.valueName)) this.valueName = null;
- entityOneElement.setAttribute("value", this.valueName);
-
- finder = new PrimaryKeyFinder(entityOneElement);
- }
@Override
- public void runAction(Map<String, Object> context) {
- try {
- finder.runFind(context, this.modelTree.getDelegator());
- } catch (GeneralException e) {
- String errMsg = "Error doing entity query by condition: " + e.toString();
- Debug.logError(e, errMsg, module);
- throw new IllegalArgumentException(errMsg);
- }
+ public void accept(ModelActionVisitor visitor) {
+ visitor.visit(this);
}
}
@@ -389,6 +292,11 @@ public abstract class ModelTreeAction {
throw new IllegalArgumentException(errMsg);
}
}
+
+ @Override
+ public void accept(ModelActionVisitor visitor) {
+ visitor.visit(this);
+ }
}
public static class EntityCondition extends ModelTreeAction {
@@ -429,5 +337,10 @@ public abstract class ModelTreeAction {
throw new IllegalArgumentException(errMsg);
}
}
+
+ @Override
+ public void accept(ModelActionVisitor visitor) {
+ visitor.visit(this);
+ }
}
}
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java Mon Nov 3 06:54:16 2014
@@ -19,13 +19,13 @@
package org.ofbiz.widget.tree;
import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
-import javolution.util.FastList;
-
import org.apache.oro.text.regex.MalformedPatternException;
import org.apache.oro.text.regex.Pattern;
import org.apache.oro.text.regex.PatternMatcher;
@@ -77,7 +77,7 @@ public class ModelTreeCondition {
}
public static List<TreeCondition> readSubConditions(ModelTree modelTree, Element conditionElement) {
- List<TreeCondition> condList = FastList.newInstance();
+ List<TreeCondition> condList = new ArrayList<TreeCondition>();
for (Element subElement: UtilXml.childElementList(conditionElement)) {
condList.add(readCondition(modelTree, subElement));
}
@@ -323,7 +323,7 @@ public class ModelTreeCondition {
fieldVal = "";
}
- List<Object> messages = FastList.newInstance();
+ List<Object> messages = new LinkedList<Object>();
Boolean resultBool = BaseCompare.doRealCompare(fieldVal, value, operator, type, format, messages, null, null, true);
if (messages.size() > 0) {
messages.add(0, "Error with comparison in if-compare between field [" + fieldAcsr.toString() + "] with value [" + fieldVal + "] and value [" + value + "] with operator [" + operator + "] and type [" + type + "]: ");
@@ -374,7 +374,7 @@ public class ModelTreeCondition {
fieldVal = "";
}
- List<Object> messages = FastList.newInstance();
+ List<Object> messages = new LinkedList<Object>();
Boolean resultBool = BaseCompare.doRealCompare(fieldVal, toFieldVal, operator, type, format, messages, null, null, false);
if (messages.size() > 0) {
messages.add(0, "Error with comparison in if-compare-field between field [" + fieldAcsr.toString() + "] with value [" + fieldVal + "] and to-field [" + toFieldVal.toString() + "] with value [" + toFieldVal + "] with operator [" + operator + "] and type [" + type + "]: ");
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/macros.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/macros.xml?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/macros.xml (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/macros.xml Mon Nov 3 06:54:16 2014
@@ -186,32 +186,6 @@ under the License.
<pathelement location="${ofbiz.home.dir}/framework/base/lib/ant/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
- <macrodef name="ofbiz-javacc">
- <attribute name="dir"/>
- <attribute name="file"/>
- <attribute name="prefix" default=""/>
- <sequential>
- <if>
- <not>
- <uptodate
- srcfile="@{prefix}src/@{dir}/@{file}.jj"
- targetfile="@{prefix}build/gen-src/javacc/@{dir}/@{file}.java"/>
- </not>
- <then>
- <delete dir="@{prefix}build/gen-src/javacc/@{dir}"/>
- <mkdir dir="@{prefix}build/gen-src/javacc/@{dir}"/>
- <javacc target="@{prefix}src/@{dir}/@{file}.jj"
- javacchome="${ofbiz.home.dir}/lib/build/javacc"
- outputdirectory="@{prefix}build/gen-src/javacc/@{dir}"/>
- <replace token="public class"
- value='@SuppressWarnings("all") public class'
- dir="@{prefix}build/gen-src/javacc/@{dir}"
- includes="*.java" />
- <delete dir="@{prefix}build/classes/@{dir}"/>
- </then>
- </if>
- </sequential>
- </macrodef>
<presetdef name="externalsubant">
<subant inheritall="false">
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/cmssite/data/CmsSiteDemoData.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/cmssite/data/CmsSiteDemoData.xml?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/cmssite/data/CmsSiteDemoData.xml (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/cmssite/data/CmsSiteDemoData.xml Mon Nov 3 06:54:16 2014
@@ -101,7 +101,7 @@ under the License.
<Content contentId="CMSS_DEMO_HOME" contentTypeId="DOCUMENT" decoratorContentId="CMSS_DEC"
contentName="CMS Site Demo Home Page" dataResourceId="CMSS_DEMO_HOME"/>
<ContentPurpose contentId="CMSS_DEMO_HOME" contentPurposeTypeId="SECTION"/>
- <ContentAssoc contentId="CMSS_PPOINT" contentIdTo="CMSS_DEMO_HOME" contentAssocTypeId="SUB_CONTENT" fromDate="2001-01-01 00:00:00" mapKey="demoHome"/>
+ <ContentAssoc contentId="CMSS_PPOINT" contentIdTo="CMSS_DEMO_HOME" contentAssocTypeId="PUBLISH_LINK" fromDate="2001-01-01 00:00:00" mapKey="demoHome"/>
<WebSiteContent webSiteId="CmsSite" contentId="CMSS_DEMO_HOME" webSiteContentTypeId="DEFAULT_PAGE" fromDate="2001-01-01 00:00:00"/>
<!-- yet another demo page -->
@@ -114,7 +114,7 @@ under the License.
</ElectronicText>
<Content contentId="CMSS_DEMO_PAGE1" contentTypeId="DOCUMENT" decoratorContentId="CMSS_DEC" contentName="CMS Site Demo Page 1" dataResourceId="CMSS_DEMO_PAGE1"/>
<ContentPurpose contentId="CMSS_DEMO_PAGE1" contentPurposeTypeId="SECTION"/>
- <ContentAssoc contentId="CMSS_PPOINT" contentIdTo="CMSS_DEMO_PAGE1" contentAssocTypeId="SUB_CONTENT" fromDate="2001-01-01 00:00:00" mapKey="demoPage1"/>
+ <ContentAssoc contentId="CMSS_PPOINT" contentIdTo="CMSS_DEMO_PAGE1" contentAssocTypeId="PUBLISH_LINK" fromDate="2001-01-01 00:00:00" mapKey="demoPage1"/>
<DataResource dataResourceId="CMSS_DEMO_PAGE1_1" dataResourceTypeId="SHORT_TEXT" objectInfo="Sub-content 1"/>
<Content contentId="CMSS_DEMO_PAGE1_1" contentTypeId="DOCUMENT" contentName="CMS Site Demo Page 1_1" dataResourceId="CMSS_DEMO_PAGE1_1"/>
<ContentPurpose contentId="CMSS_DEMO_PAGE1_1" contentPurposeTypeId="SECTION"/>
@@ -130,16 +130,16 @@ under the License.
<DataResource dataResourceId="CMSS_DEMO_SCREEN" dataResourceTypeId="URL_RESOURCE" dataTemplateTypeId="SCREEN_COMBINED" objectInfo="component://cmssite/widget/CmssiteScreens.xml#testScreen"/>
<Content contentId="CMSS_DEMO_SCREEN" contentTypeId="DOCUMENT" contentName="CMS Site Demo screen/decorator example" dataResourceId="CMSS_DEMO_SCREEN"/>
- <ContentAssoc contentId="CMSS_PPOINT" contentIdTo="CMSS_DEMO_SCREEN" contentAssocTypeId="SUB_CONTENT" fromDate="2001-01-01 00:00:00"/>
+ <ContentAssoc contentId="CMSS_PPOINT" contentIdTo="CMSS_DEMO_SCREEN" contentAssocTypeId="PUBLISH_LINK" fromDate="2001-01-01 00:00:00"/>
<DataResource dataResourceId="CMSS_DEMO_BLOG" dataResourceTypeId="URL_RESOURCE" dataTemplateTypeId="SCREEN_COMBINED" objectInfo="component://cmssite/widget/CmssiteScreens.xml#blogScreen"/>
<Content contentId="CMSS_DEMO_BLOG" contentTypeId="DOCUMENT" contentName="CMS Site Demo blog screen example" dataResourceId="CMSS_DEMO_BLOG"/>
- <ContentAssoc contentId="CMSS_PPOINT" contentIdTo="CMSS_DEMO_BLOG" contentAssocTypeId="SUB_CONTENT" fromDate="2001-01-01 00:00:00"/>
+ <ContentAssoc contentId="CMSS_PPOINT" contentIdTo="CMSS_DEMO_BLOG" contentAssocTypeId="PUBLISH_LINK" fromDate="2001-01-01 00:00:00"/>
<DataResource dataResourceId="CMSS_DEMO_TPL_DATA" localeString="en" dataResourceTypeId="ELECTRONIC_TEXT" dataTemplateTypeId="NONE" statusId="CTNT_IN_PROGRESS" dataResourceName="data xml file" mimeTypeId="text/xml" isPublic="Y"/>
<DataResource dataResourceId="CMSS_DEMO_TPL_TEMPL" dataResourceTypeId="ELECTRONIC_TEXT" dataTemplateTypeId="FTL" statusId="CTNT_IN_PROGRESS" dataResourceName="demo xml templ" mimeTypeId="text/html" isPublic="Y" />
<Content contentId="CMSS_DEMO_TPL_DATA" contentTypeId="DOCUMENT" templateDataResourceId="CMSS_DEMO_TPL_TEMPL" dataResourceId="CMSS_DEMO_TPL_DATA" statusId="CTNT_IN_PROGRESS" contentName="Demo xml data + ftl template file" mimeTypeId="text/html"/>
- <ContentAssoc contentId="CMSS_PPOINT" contentIdTo="CMSS_DEMO_TPL_DATA" contentAssocTypeId="SUB_CONTENT" fromDate="2001-01-01 00:00:00"/>
+ <ContentAssoc contentId="CMSS_PPOINT" contentIdTo="CMSS_DEMO_TPL_DATA" contentAssocTypeId="PUBLISH_LINK" fromDate="2001-01-01 00:00:00"/>
<ElectronicText dataResourceId="CMSS_DEMO_TPL_DATA">
<textData><![CDATA[
<root>
@@ -194,7 +194,7 @@ under the License.
<DataResource dataResourceId="OFBIZ_HOME" dataResourceTypeId="URL_RESOURCE" dataTemplateTypeId="SCREEN_COMBINED"
objectInfo="component://cmssite/widget/OfbizsiteScreens.xml#main"/>
<Content contentId="OFBIZ_HOME" contentTypeId="DOCUMENT" contentName="OFBiz Site Home Page" dataResourceId="OFBIZ_HOME"/>
- <ContentAssoc contentId="OFBIZ_PPOINT" contentIdTo="OFBIZ_HOME" contentAssocTypeId="SUB_CONTENT" fromDate="2001-01-01 00:00:00" mapKey="demoHome"/>
+ <ContentAssoc contentId="OFBIZ_PPOINT" contentIdTo="OFBIZ_HOME" contentAssocTypeId="PUBLISH_LINK" fromDate="2001-01-01 00:00:00" mapKey="demoHome"/>
<WebSiteContent webSiteId="OfbizSite" contentId="OFBIZ_HOME" webSiteContentTypeId="DEFAULT_PAGE" fromDate="2001-01-01 00:00:00"/>
<!-- documents website -->
@@ -219,8 +219,8 @@ under the License.
<ContentAssoc contentId="DOCUMENTS" contentIdTo="APACHE_OFBIZ_U_HTML" contentAssocTypeId="SUB_CONTENT" fromDate="2006-01-12 01:01:01" sequenceNum=""/>
- <ContentAssoc contentId="CMSS_PPOINT" contentIdTo="PUBLIC_DOCS" contentAssocTypeId="SUB_CONTENT" fromDate="2001-01-01 00:00:00"/>
- <ContentAssoc contentId="CMSS_PPOINT" contentIdTo="APACHE_OFBIZ_HTML" contentAssocTypeId="SUB_CONTENT" fromDate="2001-01-01 00:00:00" mapKey="documents"/>
- <ContentAssoc contentId="CMSS_PPOINT" contentIdTo="APACHE_OFBIZ_PDF" contentAssocTypeId="SUB_CONTENT" fromDate="2001-01-01 00:00:00" mapKey="documents"/>
+ <ContentAssoc contentId="CMSS_PPOINT" contentIdTo="PUBLIC_DOCS" contentAssocTypeId="PUBLISH_LINK" fromDate="2001-01-01 00:00:00"/>
+ <ContentAssoc contentId="CMSS_PPOINT" contentIdTo="APACHE_OFBIZ_HTML" contentAssocTypeId="PUBLISH_LINK" fromDate="2001-01-01 00:00:00" mapKey="documents"/>
+ <ContentAssoc contentId="CMSS_PPOINT" contentIdTo="APACHE_OFBIZ_PDF" contentAssocTypeId="PUBLISH_LINK" fromDate="2001-01-01 00:00:00" mapKey="documents"/>
</entity-engine-xml>
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/cmssite/template/cms/MainDecorator.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/cmssite/template/cms/MainDecorator.ftl?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/cmssite/template/cms/MainDecorator.ftl (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/cmssite/template/cms/MainDecorator.ftl Mon Nov 3 06:54:16 2014
@@ -16,10 +16,11 @@ KIND, either express or implied. See th
specific language governing permissions and limitations
under the License.
-->
-
+<#if decoratedContent??>
${(decoratedContent.subcontent.htmlHead)?default((thisContent.subcontent.htmlHead)!)}
${(decoratedContent.subcontent.header)?default((thisContent.subcontent.header)!)}
${decoratedContent}
${(decoratedContent.subcontent.footer)?default((thisContent.subcontent.footer)!)}
+</#if>
\ No newline at end of file
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebay/src/org/ofbiz/ebay/EbayHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebay/src/org/ofbiz/ebay/EbayHelper.java?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebay/src/org/ofbiz/ebay/EbayHelper.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebay/src/org/ofbiz/ebay/EbayHelper.java Mon Nov 3 06:54:16 2014
@@ -47,6 +47,7 @@ import org.ofbiz.base.util.UtilXml;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.entity.util.EntityUtil;
import org.ofbiz.order.shoppingcart.ShoppingCart;
import org.ofbiz.party.contact.ContactHelper;
@@ -69,7 +70,7 @@ public class EbayHelper {
if (UtilValidate.isNotEmpty(productStoreId)) {
GenericValue eBayConfig = null;
try {
- eBayConfig = delegator.findOne("EbayConfig", false, UtilMisc.toMap("productStoreId", productStoreId));
+ eBayConfig = EntityQuery.use(delegator).from("EbayConfig").where(UtilMisc.toMap("productStoreId", productStoreId)).queryOne();
} catch (GenericEntityException e) {
String errMsg = UtilProperties.getMessage(resource, "buildEbayConfig.unableToFindEbayConfig" + e.getMessage(), locale);
return ServiceUtil.returnError(errMsg);
@@ -171,7 +172,7 @@ public class EbayHelper {
String partyId = "_NA_";
String shipmentMethodTypeId = "NO_SHIPPING";
try {
- GenericValue ebayShippingMethod = delegator.findOne("EbayShippingMethod", UtilMisc.toMap("shipmentMethodName", shippingService, "productStoreId", productStoreId), false);
+ GenericValue ebayShippingMethod = EntityQuery.use(delegator).from("EbayShippingMethod").where("shipmentMethodName", shippingService, "productStoreId", productStoreId).queryOne();
if (UtilValidate.isNotEmpty(ebayShippingMethod)) {
partyId = ebayShippingMethod.getString("carrierPartyId");
shipmentMethodTypeId = ebayShippingMethod.getString("shipmentMethodTypeId");
@@ -516,7 +517,7 @@ public class EbayHelper {
GenericValue postalAddress;
try {
// get the postal address for this contact mech
- postalAddress = delegator.findOne("PostalAddress", UtilMisc.toMap("contactMechId", contactMechId), false);
+ postalAddress = EntityQuery.use(delegator).from("PostalAddress").where("contactMechId", contactMechId).queryOne();
// match values to compare by modifying them the same way they
// were when they were created
@@ -622,7 +623,7 @@ public class EbayHelper {
titleFirstWord = title.substring(0, title.indexOf(' '));
}
if (UtilValidate.isNotEmpty(titleFirstWord)) {
- GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", titleFirstWord), false);
+ GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", titleFirstWord).queryOne();
if (UtilValidate.isNotEmpty(product)) {
productId = product.getString("productId");
}
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java Mon Nov 3 06:54:16 2014
@@ -43,6 +43,7 @@ import org.ofbiz.entity.GenericEntityExc
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.condition.EntityCondition;
import org.ofbiz.entity.condition.EntityComparisonOperator;
+import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.entity.util.EntityUtil;
import org.ofbiz.order.order.OrderChangeHelper;
import org.ofbiz.order.shoppingcart.CheckOutHelper;
@@ -992,7 +993,7 @@ public class EbayOrderServices {
if (productStoreId == null) {
return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "ordersImportFromEbay.productStoreIdIsMandatory", locale));
} else {
- GenericValue productStore = delegator.findOne("ProductStore", UtilMisc.toMap("productStoreId", productStoreId), false);
+ GenericValue productStore = EntityQuery.use(delegator).from("ProductStore").where("productStoreId", productStoreId).queryOne();
if (productStore != null) {
defaultCurrencyUomId = productStore.getString("defaultCurrencyUomId");
payToPartyId = productStore.getString("payToPartyId");
@@ -1150,7 +1151,7 @@ public class EbayOrderServices {
// if we get a party, check its contact information.
if (UtilValidate.isNotEmpty(partyId)) {
Debug.logInfo("Found existing party associated to the eBay buyer: " + partyId, module);
- GenericValue party = delegator.findOne("Party", UtilMisc.toMap("partyId", partyId), false);
+ GenericValue party = EntityQuery.use(delegator).from("Party").where("partyId", partyId).queryOne();
contactMechId = EbayHelper.setShippingAddressContactMech(dispatcher, delegator, party, userLogin, shippingAddressCtx);
String emailBuyer = (String) context.get("emailBuyer");
@@ -1261,7 +1262,7 @@ public class EbayOrderServices {
private static void addItem(ShoppingCart cart, Map<String, Object> orderItem, LocalDispatcher dispatcher, Delegator delegator, int groupIdx) throws GeneralException {
String productId = (String) orderItem.get("productId");
- GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), false);
+ GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne();
if (UtilValidate.isEmpty(product)) {
String productMissingMsg = "The product having ID (" + productId + ") is misssing in the system.";
orderImportFailureMessageList.add(productMissingMsg);
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java Mon Nov 3 06:54:16 2014
@@ -39,6 +39,7 @@ import org.ofbiz.base.util.UtilXml;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.entity.util.EntityUtil;
import org.ofbiz.entity.condition.EntityCondition;
import org.ofbiz.entity.condition.EntityComparisonOperator;
@@ -141,7 +142,7 @@ public class ImportOrdersFromEbay {
if (UtilValidate.isNotEmpty(orderId)) {
// Get the order header and verify if this order has been imported
// from eBay (i.e. sales channel = EBAY_CHANNEL and externalId is set)
- orderHeader = delegator.findOne("OrderHeader", UtilMisc.toMap("orderId", orderId), false);
+ orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne();
if (orderHeader == null) {
Debug.logError("Cannot find order with orderId [" + orderId + "]", module);
return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "ordersImportFromEbay.errorRetrievingOrderFromOrderId", locale));
@@ -600,7 +601,7 @@ public class ImportOrdersFromEbay {
if (productStoreId == null) {
return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "ordersImportFromEbay.productStoreIdIsMandatory", locale));
} else {
- GenericValue productStore = delegator.findOne("ProductStore", UtilMisc.toMap("productStoreId", productStoreId), false);
+ GenericValue productStore = EntityQuery.use(delegator).from("ProductStore").where("productStoreId", productStoreId).queryOne();
if (productStore != null) {
defaultCurrencyUomId = productStore.getString("defaultCurrencyUomId");
payToPartyId = productStore.getString("payToPartyId");
@@ -658,7 +659,7 @@ public class ImportOrdersFromEbay {
if (UtilValidate.isEmpty(productId)) {
return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "ordersImportFromEbay.productIdNotAvailable", locale));
} else {
- GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), false);
+ GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne();
if (UtilValidate.isEmpty(product)) {
return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "ordersImportFromEbay.productIdDoesNotExist", locale));
}
@@ -735,7 +736,7 @@ public class ImportOrdersFromEbay {
if (UtilValidate.isNotEmpty(partyAttribute)) {
partyId = (String) partyAttribute.get("partyId");
Debug.logInfo("Found existing party associated to the eBay buyer: " + partyId, module);
- GenericValue party = delegator.findOne("Party", UtilMisc.toMap("partyId", partyId), false);
+ GenericValue party = EntityQuery.use(delegator).from("Party").where("partyId", partyId).queryOne();
contactMechId = EbayHelper.setShippingAddressContactMech(dispatcher, delegator, party, userLogin, parameters);
String emailBuyer = (String) parameters.get("emailBuyer");
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayBestOfferAutoPref.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayBestOfferAutoPref.java?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayBestOfferAutoPref.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayBestOfferAutoPref.java Mon Nov 3 06:54:16 2014
@@ -28,6 +28,7 @@ import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.GenericServiceException;
import org.ofbiz.service.LocalDispatcher;
@@ -90,7 +91,7 @@ public class EbayBestOfferAutoPref {
Map<String, Object> ebayCondition11 = UtilMisc.<String, Object>toMap("userLogin", userLogin);
ebayCondition11.put("acceptanceCondition", condition11);
- GenericValue productStorePref = delegator.findOne("EbayProductStorePref", UtilMisc.toMap("productStoreId", productStoreId, "autoPrefEnumId", "EBAY_AUTO_BEST_OFFER"), false);
+ GenericValue productStorePref = EntityQuery.use(delegator).from("EbayProductStorePref").where("productStoreId", productStoreId, "autoPrefEnumId", "EBAY_AUTO_BEST_OFFER").queryOne();
if (UtilValidate.isEmpty(productStorePref)) {
String prefCondId1 = delegator.getNextSeqId("EbayProductStorePrefCond");
String parentPrefCondId = prefCondId1;
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayEvents.java?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayEvents.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayEvents.java Mon Nov 3 06:54:16 2014
@@ -42,6 +42,7 @@ import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.entity.util.EntityUtil;
import org.ofbiz.service.GenericServiceException;
import org.ofbiz.service.LocalDispatcher;
@@ -196,7 +197,7 @@ public class EbayEvents {
for (String productId : productIds) {
AddItemCall addItemCall = new AddItemCall(apiContext);
ItemType item = new ItemType();
- GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), false);
+ GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne();
item.setTitle(product.getString("internalName"));
item.setCurrency(CurrencyCodeType.USD);
String productDescription = "";
@@ -544,7 +545,7 @@ public class EbayEvents {
EbayStoreSiteFacade sf = null;
// find is exiting product and set category into item in additem call
try {
- if (UtilValidate.isNotEmpty(delegator.findOne("Product", UtilMisc.toMap("productId", productId), false))) {
+ if (UtilValidate.isNotEmpty(EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne())) {
ApiContext apiContext = getApiContext(request);
Map<String,Object> addItemObject = getAddItemListingObject(request, apiContext);
List<Map<String,Object>> addItemlist = UtilGenerics.checkList(addItemObject.get("itemListing"));
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayFeedback.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayFeedback.java?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayFeedback.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayFeedback.java Mon Nov 3 06:54:16 2014
@@ -23,6 +23,7 @@ import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityQuery;
import java.util.*;
@@ -80,7 +81,7 @@ public class EbayFeedback {
FeedbackDetailType[] feedback = feedbackCall.getFeedback();
if (feedback != null) {
String partyId = null;
- GenericValue userLoginEx = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", userID), false);
+ GenericValue userLoginEx = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", userID).queryOne();
if (userLoginEx == null) {
//Party
GenericValue party = delegator.makeValue("Party");
@@ -109,7 +110,7 @@ public class EbayFeedback {
//convert to ofbiz
String contentId = feedback[i].getFeedbackID();
Date eBayDateTime = feedback[i].getCommentTime().getTime();
- GenericValue contentCheck = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false);
+ GenericValue contentCheck = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
if (contentCheck != null) {
continue;
}
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStore.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStore.java?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStore.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStore.java Mon Nov 3 06:54:16 2014
@@ -55,6 +55,7 @@ import org.ofbiz.ebay.ProductsExportToEb
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.entity.util.EntityUtil;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.GenericServiceException;
@@ -281,7 +282,7 @@ public class EbayStore {
if (ebayParentCategoryId != null) {
List<GenericValue> productCategoryRollupList = delegator.findByAnd("ProductCategoryRollup", UtilMisc.toMap("parentProductCategoryId", productCategory.getString("productCategoryId")), UtilMisc.toList("sequenceNum ASC"), false);
for (GenericValue productCategoryRollup : productCategoryRollupList) {
- productCategory = delegator.findOne("ProductCategory", UtilMisc.toMap("productCategoryId", productCategoryRollup.getString("productCategoryId")), false);
+ productCategory = EntityQuery.use(delegator).from("ProductCategory").where("productCategoryId", productCategoryRollup.getString("productCategoryId")).queryOne();
StoreCustomCategoryType childCategoryType = new StoreCustomCategoryType();
String ebayChildCategoryId = EbayStoreHelper.retriveEbayCategoryIdByPartyId(delegator, productCategory.getString("productCategoryId"), context.get("partyId").toString());
if (ebayChildCategoryId == null) {
@@ -324,7 +325,7 @@ public class EbayStore {
if (ebayParentCategoryId != null) {
List<GenericValue> productChildCategoryRollupList = delegator.findByAnd("ProductCategoryRollup", UtilMisc.toMap("parentProductCategoryId",productParentCategoryRollup.getString("productCategoryId")),UtilMisc.toList("sequenceNum ASC"), false);
for (GenericValue productChildCategoryRollup : productChildCategoryRollupList) {
- productCategory = delegator.findOne("ProductCategory", UtilMisc.toMap("productCategoryId", productChildCategoryRollup.getString("productCategoryId")), false);
+ productCategory = EntityQuery.use(delegator).from("ProductCategory").where("productCategoryId", productChildCategoryRollup.getString("productCategoryId")).queryOne();
StoreCustomCategoryType childCategoryType = new StoreCustomCategoryType();
String ebayChildCategoryId = EbayStoreHelper.retriveEbayCategoryIdByPartyId(delegator,productCategory.getString("productCategoryId"),context.get("partyId").toString());
if (ebayChildCategoryId == null) {
@@ -523,7 +524,7 @@ public class EbayStore {
//UtilXml.addChildElementValue(StoreCategoriesElem, "Country", (String)context.get("country"), storeDocument);
GenericValue category = null;
if (UtilValidate.isNotEmpty(context.get("prodCatalogId"))) {
- category = delegator.findOne("ProductCategory", UtilMisc.toMap("productCategoryId", productCategoryId), true);
+ category = EntityQuery.use(delegator).from("ProductCategory").where("productCategoryId", productCategoryId).cache().queryOne();
}
String categoryName = category.getString("productCategoryId").toString();
if (category.getString("categoryName").toString() != null) {
@@ -1545,7 +1546,7 @@ public class EbayStore {
Map<String, Object> eBayConfigResult = EbayHelper.buildEbayConfig(context, delegator);
Map<String, Object> response = null;
try {
- GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", context.get("productId").toString()), false);
+ GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", context.get("productId").toString()).queryOne();
int intAtp = 1;
String facilityId = "";
if (UtilValidate.isNotEmpty(context.get("requireEbayInventory")) && "on".equals(context.get("requireEbayInventory").toString())) {
@@ -2464,7 +2465,7 @@ public class EbayStore {
public static boolean checkExistProduct(Delegator delegator, String productId) {
boolean checkResult = false;
try {
- GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), false);
+ GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne();
if(UtilValidate.isNotEmpty(product)) {
checkResult = true;
}
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java Mon Nov 3 06:54:16 2014
@@ -51,6 +51,7 @@ import org.ofbiz.entity.GenericEntityExc
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.condition.EntityCondition;
import org.ofbiz.entity.condition.EntityOperator;
+import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.GenericServiceException;
import org.ofbiz.service.LocalDispatcher;
@@ -142,7 +143,7 @@ public class EbayStoreAutoPreferences {
try {
ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
- ebayProductStorePref = delegator.findOne("EbayProductStorePref", UtilMisc.toMap("productStoreId", productStoreId, "autoPrefEnumId", "EBAY_AUTO_PIT_FB"), false);
+ ebayProductStorePref = EntityQuery.use(delegator).from("EbayProductStorePref").where("productStoreId", productStoreId, "autoPrefEnumId", "EBAY_AUTO_PIT_FB").queryOne();
if (UtilValidate.isNotEmpty(ebayProductStorePref) && UtilValidate.isNotEmpty(ebayProductStorePref.getString("autoPrefJobId"))) {
isAutoPositiveFeedback = ebayProductStorePref.getString("enabled");
// if isAutoPositiveFeedback is N that means not start this job run service
@@ -242,7 +243,7 @@ public class EbayStoreAutoPreferences {
GenericValue ebayProductStorePref = null;
String comments = null;
String autoPrefJobId = null;
- GenericValue userLogin = delegator.findOne("UserLogin", false, "userLoginId", "system");
+ GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne();
if ("Y".equals(isAutoPositiveFeedback)) {
if ("PAYMENT_RECEIVED".equals(feedbackEventCode)) {
condition = AutomatedLeaveFeedbackEventCodeType.PAYMENT_RECEIVED.toString();
@@ -267,7 +268,7 @@ public class EbayStoreAutoPreferences {
}
Map<String, Object> context = UtilMisc.<String, Object>toMap("userLogin", userLogin, "serviceName", "autoPrefLeaveFeedbackOption");
- ebayProductStorePref = delegator.findOne("EbayProductStorePref", UtilMisc.toMap("productStoreId", productStoreId, "autoPrefEnumId", "EBAY_AUTO_PIT_FB"), false);
+ ebayProductStorePref = EntityQuery.use(delegator).from("EbayProductStorePref").where("productStoreId", productStoreId, "autoPrefEnumId", "EBAY_AUTO_PIT_FB").queryOne();
context.put("productStoreId", productStoreId);
context.put("autoPrefEnumId", "EBAY_AUTO_PIT_FB");
if (UtilValidate.isNotEmpty(ebayProductStorePref) && UtilValidate.isNotEmpty(ebayProductStorePref.getString("autoPrefJobId"))) {
@@ -301,7 +302,7 @@ public class EbayStoreAutoPreferences {
Delegator delegator = dctx.getDelegator();
LocalDispatcher dispatcher = dctx.getDispatcher();
Locale locale = (Locale) context.get("locale");
- GenericValue userLogin = delegator.findOne("UserLogin", false, "userLoginId", "system");
+ GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne();
if (UtilValidate.isEmpty(context.get("productStoreId")) && UtilValidate.isEmpty(context.get("jobId"))) {
return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "EbayStoreRequiredProductStoreId", locale));
}
@@ -315,7 +316,7 @@ public class EbayStoreAutoPreferences {
try {
ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
- ebayProductStorePref = delegator.findOne("EbayProductStorePref", UtilMisc.toMap("productStoreId", productStoreId, "autoPrefEnumId", "EBAY_AUTO_FB_RMD"), false);
+ ebayProductStorePref = EntityQuery.use(delegator).from("EbayProductStorePref").where("productStoreId", productStoreId, "autoPrefEnumId", "EBAY_AUTO_FB_RMD").queryOne();
if (UtilValidate.isNotEmpty(ebayProductStorePref) && UtilValidate.isNotEmpty(ebayProductStorePref.getString("autoPrefJobId"))) {
isAutoFeedbackReminder = ebayProductStorePref.getString("enabled");
// if isAutoPositiveFeedback is N that means not start this job run service
@@ -353,7 +354,7 @@ public class EbayStoreAutoPreferences {
for (SellingManagerSoldOrderType item : items) {
// call send
Map<String, Object> sendMap = FastMap.newInstance();
- GenericValue productStoreEmail = delegator.findOne("ProductStoreEmailSetting", UtilMisc.toMap("productStoreId", productStoreId, "emailType", "EBAY_FEEBACK_REMIN"), false);
+ GenericValue productStoreEmail = EntityQuery.use(delegator).from("ProductStoreEmailSetting").where("productStoreId", productStoreId, "emailType", "EBAY_FEEBACK_REMIN").queryOne();
String bodyScreenLocation = productStoreEmail.getString("bodyScreenLocation");
sendMap.put("bodyScreenUri", bodyScreenLocation);
String subjectString = productStoreEmail.getString("subject");
@@ -392,7 +393,7 @@ public class EbayStoreAutoPreferences {
Locale locale = (Locale) context.get("locale");
String jobId = (String) context.get("jobId");
try {
- GenericValue userLogin = delegator.findOne("UserLogin", false, "userLoginId", "system");
+ GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne();
Map<String, Object> serviceMap = FastMap.newInstance();
serviceMap.put("userLogin", userLogin);
//ProductStore
@@ -410,7 +411,7 @@ public class EbayStoreAutoPreferences {
serviceMap.put("productStoreId", productStoreId);
Map<String, Object> eBayUserLogin = dispatcher.runSync("getEbayStoreUser", serviceMap);
String eBayUserLoginId = (String) eBayUserLogin.get("userLoginId");
- GenericValue party = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", eBayUserLoginId), false);
+ GenericValue party = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", eBayUserLoginId).queryOne();
String partyId = party.getString("partyId");
//save sold items to OFbBiz product entity
Map<String, Object> resultService = dispatcher.runSync("getEbaySoldItems", serviceMap);
@@ -419,7 +420,7 @@ public class EbayStoreAutoPreferences {
for (int itemCount = 0; itemCount < soldItems.size(); itemCount++) {
Map<String, Object> soldItemMap = soldItems.get(itemCount);
if (UtilValidate.isNotEmpty(soldItemMap.get("itemId"))) {
- GenericValue productCheck = delegator.findOne("Product", UtilMisc.toMap("productId", soldItemMap.get("itemId")), false);
+ GenericValue productCheck = EntityQuery.use(delegator).from("Product").where("productId", soldItemMap.get("itemId")).queryOne();
if (productCheck == null) {
Map<String, Object> inMap = FastMap.newInstance();
inMap.put("productId", soldItemMap.get("itemId"));
@@ -487,7 +488,7 @@ public class EbayStoreAutoPreferences {
itemToBeRelisted.setItemID(product.getString("productId"));
relistItemCall.setItemToBeRelisted(itemToBeRelisted);
relistItemCall.relistItem();
- GenericValue productStore = delegator.findOne("Product", UtilMisc.toMap("productId", product.getString("productId")), false);
+ GenericValue productStore = EntityQuery.use(delegator).from("Product").where("productId", product.getString("productId")).queryOne();
productStore.set("isVirtual", "Y");
productStore.store();
Debug.logInfo("Relisted Item - " + product.getString("productId"), module);
@@ -507,7 +508,7 @@ public class EbayStoreAutoPreferences {
Locale locale = (Locale) context.get("locale");
String jobId = (String) context.get("jobId");
try {
- GenericValue userLogin = delegator.findOne("UserLogin", false, "userLoginId", "system");
+ GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne();
List<GenericValue> productStores = delegator.findByAnd("EbayProductStorePref", UtilMisc.toMap("autoPrefJobId", jobId), null, false);
if (productStores.size() != 0) {
// get automatic setting
@@ -578,7 +579,7 @@ public class EbayStoreAutoPreferences {
Locale locale = (Locale) context.get("locale");
String jobId = (String) context.get("jobId");
try {
- GenericValue userLogin = delegator.findOne("UserLogin", false, "userLoginId", "system");
+ GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne();
List<GenericValue> productStores = delegator.findByAnd("EbayProductStorePref", UtilMisc.toMap("autoPrefJobId", jobId), null, false);
if (productStores.size() != 0) {
// get automatic setting
@@ -648,7 +649,7 @@ public class EbayStoreAutoPreferences {
Delegator delegator = dctx.getDelegator();
LocalDispatcher dispatcher = dctx.getDispatcher();
Locale locale = (Locale) context.get("locale");
- GenericValue userLogin = delegator.findOne("UserLogin", false, "userLoginId", "system");
+ GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne();
if (UtilValidate.isEmpty(context.get("productStoreId")) && UtilValidate.isEmpty(context.get("jobId"))) {
return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "EbayStoreRequiredProductStoreId", locale));
@@ -662,7 +663,7 @@ public class EbayStoreAutoPreferences {
try {
ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
- ebayProductStorePref = delegator.findOne("EbayProductStorePref", UtilMisc.toMap("productStoreId", productStoreId, "autoPrefEnumId", "EBAY_AUTO_FB_RMD"), false);
+ ebayProductStorePref = EntityQuery.use(delegator).from("EbayProductStorePref").where("productStoreId", productStoreId, "autoPrefEnumId", "EBAY_AUTO_FB_RMD").queryOne();
if (UtilValidate.isNotEmpty(ebayProductStorePref) && UtilValidate.isNotEmpty(ebayProductStorePref.getString("autoPrefJobId"))) {
isAutoSendEmail = ebayProductStorePref.getString("enabled");
// if isAutoPositiveFeedback is N that means not start this job run service
@@ -687,7 +688,7 @@ public class EbayStoreAutoPreferences {
for (SellingManagerSoldOrderType item : items) {
// call send
Map<String, Object> sendMap = FastMap.newInstance();
- GenericValue productStoreEmail = delegator.findOne("ProductStoreEmailSetting", UtilMisc.toMap("productStoreId", productStoreId, "emailType", "EBAY_PAY_RECIEVED"), false);
+ GenericValue productStoreEmail = EntityQuery.use(delegator).from("ProductStoreEmailSetting").where("productStoreId", productStoreId, "emailType", "EBAY_PAY_RECIEVED").queryOne();
String bodyScreenLocation = productStoreEmail.getString("bodyScreenLocation");
sendMap.put("bodyScreenUri", bodyScreenLocation);
String subjectString = productStoreEmail.getString("subject");
@@ -728,13 +729,13 @@ public class EbayStoreAutoPreferences {
Locale locale = (Locale) context.get("locale");
String productStoreId = (String) context.get("productStoreId");
try {
- GenericValue userLogin = delegator.findOne("UserLogin", false, "userLoginId", "system");
+ GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne();
ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
GetSellingManagerSoldListingsCall sellingManagerSoldListings = new GetSellingManagerSoldListingsCall(apiContext);
SellingManagerSoldOrderType[] sellingManagerSoldOrders = sellingManagerSoldListings.getSellingManagerSoldListings();
if (sellingManagerSoldOrders != null) {
int soldOrderLength = sellingManagerSoldOrders.length;
- GenericValue ebayPref = delegator.findOne("EbayProductStorePref", UtilMisc.toMap("productStoreId", productStoreId, "autoPrefEnumId", "ENA_COMB_ORD"), false);
+ GenericValue ebayPref = EntityQuery.use(delegator).from("EbayProductStorePref").where("productStoreId", productStoreId, "autoPrefEnumId", "ENA_COMB_ORD").queryOne();
if (UtilValidate.isNotEmpty(ebayPref)) {
Timestamp beginDate = UtilDateTime.toTimestamp("01/01/2001 00:00:00");
@@ -914,7 +915,7 @@ public class EbayStoreAutoPreferences {
Locale locale = (Locale) context.get("locale");
String productStoreId = (String) context.get("productStoreId");
try {
- GenericValue userLogin = delegator.findOne("UserLogin", false, "userLoginId", "system");
+ GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne();
Map<String, Object> resultSold = dispatcher.runSync("getEbaySoldItems", UtilMisc.toMap("productStoreId", productStoreId, "userLogin", userLogin));
List<Map<String, Object>> soldItems = UtilGenerics.checkList(resultSold.get("soldItems"));
if (soldItems.size() != 0) {
@@ -941,7 +942,7 @@ public class EbayStoreAutoPreferences {
String buyerUserId = bidder.get("userId").toString();
Map<String, Object> sendMap = FastMap.newInstance();
- GenericValue productStoreEmail = delegator.findOne("ProductStoreEmailSetting", UtilMisc.toMap("productStoreId", productStoreId, "emailType", "EBAY_WIN_BUYER_NOTI"), false);
+ GenericValue productStoreEmail = EntityQuery.use(delegator).from("ProductStoreEmailSetting").where("productStoreId", productStoreId, "emailType", "EBAY_WIN_BUYER_NOTI").queryOne();
String bodyScreenLocation = productStoreEmail.getString("bodyScreenLocation");
sendMap.put("bodyScreenUri", bodyScreenLocation);
String subjectString = productStoreEmail.getString("subject");
@@ -984,7 +985,7 @@ public class EbayStoreAutoPreferences {
String productStoreId = (String) context.get("productStoreId");
try {
- GenericValue userLogin = delegator.findOne("UserLogin", false, "userLoginId", "system");
+ GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne();
context.put("userLogin", userLogin);
Map<String, Object> resultSold = dispatcher.runSync("getEbaySoldItems", context);
List<Map<String, Object>> soldItems = UtilGenerics.checkList(resultSold.get("soldItems"));
@@ -1001,7 +1002,7 @@ public class EbayStoreAutoPreferences {
String buyerEmail = item.get("buyerEmail").toString();
Map<String, Object> sendMap = FastMap.newInstance();
- GenericValue productStoreEmail = delegator.findOne("ProductStoreEmailSetting", UtilMisc.toMap("productStoreId", productStoreId, "emailType", "EBAY_ITEM_DISPATCH"), false);
+ GenericValue productStoreEmail = EntityQuery.use(delegator).from("ProductStoreEmailSetting").where("productStoreId", productStoreId, "emailType", "EBAY_ITEM_DISPATCH").queryOne();
String bodyScreenLocation = productStoreEmail.getString("bodyScreenLocation");
sendMap.put("bodyScreenUri", bodyScreenLocation);
String subjectString = productStoreEmail.getString("subject");
@@ -1103,7 +1104,7 @@ public class EbayStoreAutoPreferences {
Delegator delegator = dctx.getDelegator();
Locale locale = (Locale) context.get("locale");
try {
- GenericValue userLogin = delegator.findOne("UserLogin", false, "userLoginId", "system");
+ GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne();
EntityCondition expression1 = EntityCondition.makeCondition("autoRelisting", EntityOperator.EQUALS, "Y");
EntityCondition expression2 = EntityCondition.makeCondition("endDateTime", EntityOperator.LESS_THAN, UtilDateTime.nowTimestamp());
EntityCondition expression3 = EntityCondition.makeCondition("itemId", EntityOperator.NOT_EQUAL, null);
@@ -1147,7 +1148,7 @@ public class EbayStoreAutoPreferences {
Locale locale = (Locale) context.get("locale");
try {
String productStoreId = (String) context.get("productStoreId");
- GenericValue ebayProductStorePref = delegator.findOne("EbayProductStorePref", UtilMisc.toMap("productStoreId", productStoreId, "autoPrefEnumId", "EBAY_AUTO_BEST_OFFER"), false);
+ GenericValue ebayProductStorePref = EntityQuery.use(delegator).from("EbayProductStorePref").where("productStoreId", productStoreId, "autoPrefEnumId", "EBAY_AUTO_BEST_OFFER").queryOne();
String parentPrefCondId = ebayProductStorePref.getString("parentPrefCondId");
List<GenericValue> ebayProductStorePrefCond = delegator.findByAnd("EbayProductStorePrefCond", UtilMisc.toMap("parentPrefCondId", parentPrefCondId), null, false);
//Parameters
@@ -1294,7 +1295,7 @@ public class EbayStoreAutoPreferences {
String buyerMessage = bestOfferType.getBuyerMessage();
if (ignoreOfferMessage.equals("Y") && UtilValidate.isNotEmpty(buyerMessage)) {
- GenericValue userOfferCheck = delegator.findOne("EbayUserBestOffer", UtilMisc.toMap("itemId", itemID, "userId", buyerUserID), false);
+ GenericValue userOfferCheck = EntityQuery.use(delegator).from("EbayUserBestOffer").where("itemId", itemID, "userId", buyerUserID).queryOne();
if (UtilValidate.isEmpty(userOfferCheck)) {
GenericValue ebayUserBestOffer = delegator.makeValue("EbayUserBestOffer");
ebayUserBestOffer.put("productStoreId", productStoreId);
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreCustomerService.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreCustomerService.java?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreCustomerService.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreCustomerService.java Mon Nov 3 06:54:16 2014
@@ -28,6 +28,7 @@ import org.ofbiz.base.util.UtilPropertie
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.ServiceUtil;
@@ -130,7 +131,7 @@ public class EbayStoreCustomerService {
} else {
return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "EbayStoreRequiredContactStatusSetting", locale));
}
- GenericValue ebayUserBestOffer = delegator.findOne("EbayUserBestOffer", UtilMisc.toMap("userId", userId, "itemId", itemId), false);
+ GenericValue ebayUserBestOffer = EntityQuery.use(delegator).from("EbayUserBestOffer").where("userId", userId, "itemId", itemId).queryOne();
ebayUserBestOffer.set("contactStatus", contactStatus);
ebayUserBestOffer.store();
@@ -159,7 +160,7 @@ public class EbayStoreCustomerService {
String itemId = (String) context.get("itemId");
String userId = (String) context.get("userId");
try {
- GenericValue ebayUserBestOffer = delegator.findOne("EbayUserBestOffer", UtilMisc.toMap("itemId", itemId, "userId", userId), false);
+ GenericValue ebayUserBestOffer = EntityQuery.use(delegator).from("EbayUserBestOffer").where("itemId", itemId, "userId", userId).queryOne();
ebayUserBestOffer.remove();
result.put("productStoreId", productStoreId);
} catch (Exception e) {