Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTree.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTree.java?rev=1812918&r1=1812917&r2=1812918&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTree.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTree.java Sun Oct 22 13:58:51 2017 @@ -84,9 +84,9 @@ public class ModelTree extends ModelWidg private final String defaultRenderStyle; private final FlexibleStringExpander defaultWrapStyleExdr; private final FlexibleStringExpander expandCollapseRequestExdr; - private final boolean forceChildCheck; + protected final boolean forceChildCheck; private final String location; - private final Map<String, ModelNode> nodeMap; + protected final Map<String, ModelNode> nodeMap; private final int openDepth; private final int postTrailOpenDepth; private final String rootNodeName; @@ -134,7 +134,7 @@ public class ModelTree extends ModelWidg if (nodeElements.size() == 0) { throw new IllegalArgumentException("No node elements found for the tree definition with name: " + getName()); } - Map<String, ModelNode> nodeMap = new HashMap<String, ModelNode>(); + Map<String, ModelNode> nodeMap = new HashMap<>(); for (Element nodeElementEntry : UtilXml.childElementList(treeElement, "node")) { ModelNode node = new ModelNode(nodeElementEntry, this); String nodeName = node.getName(); @@ -171,7 +171,7 @@ public class ModelTree extends ModelWidg if (UtilValidate.isEmpty(expColReq)) { HttpServletRequest request = (HttpServletRequest) context.get("request"); String s1 = request.getRequestURI(); - int pos = s1.lastIndexOf("/"); + int pos = s1.lastIndexOf('/'); if (pos >= 0) expColReq = s1.substring(pos + 1); else @@ -180,11 +180,11 @@ public class ModelTree extends ModelWidg //append also the request parameters Map<String, Object> paramMap = UtilGenerics.checkMap(context.get("requestParameters")); if (UtilValidate.isNotEmpty(paramMap)) { - Map<String, Object> requestParameters = new HashMap<String, Object>(paramMap); + Map<String, Object> requestParameters = new HashMap<>(paramMap); requestParameters.remove(this.getTrailName(context)); if (UtilValidate.isNotEmpty(requestParameters)) { String queryString = UtilHttp.urlEncodeArgs(requestParameters, false); - if (expColReq.indexOf("?") < 0) { + if (expColReq.indexOf('?') < 0) { expColReq += "?"; } else { expColReq += "&"; @@ -244,7 +244,7 @@ public class ModelTree extends ModelWidg context.put("rootEntityId", trail.get(0)); context.put(getDefaultPkName(context), trail.get(0)); } else { - trail = new LinkedList<String>(); + trail = new LinkedList<>(); } context.put("targetNodeTrail", trail); context.put("currentNodeTrail", new LinkedList()); @@ -319,7 +319,7 @@ public class ModelTree extends ModelWidg this.entryName = nodeElement.getAttribute("entry-name"); this.entityName = nodeElement.getAttribute("entity-name"); this.pkName = nodeElement.getAttribute("join-field-name"); - ArrayList<ModelAction> actions = new ArrayList<ModelAction>(); + ArrayList<ModelAction> actions = new ArrayList<>(); // FIXME: Validate child elements, should be only one of actions, entity-one, service, script. Element actionsElement = UtilXml.firstChildElement(nodeElement, "actions"); if (actionsElement != null) { @@ -369,7 +369,7 @@ public class ModelTree extends ModelWidg } List<? extends Element> nodeElements = UtilXml.childElementList(nodeElement, "sub-node"); if (!nodeElements.isEmpty()) { - List<ModelSubNode> subNodeList = new ArrayList<ModelSubNode>(); + List<ModelSubNode> subNodeList = new ArrayList<>(); for (Element subNodeElementEntry : nodeElements) { ModelSubNode subNode = new ModelSubNode(subNodeElementEntry, this); subNodeList.add(subNode); @@ -386,7 +386,7 @@ public class ModelTree extends ModelWidg } private List<Object[]> getChildren(Map<String, Object> context) { - List<Object[]> subNodeValues = new ArrayList<Object[]>(); + List<Object[]> subNodeValues = new ArrayList<>(); for (ModelSubNode subNode : subNodeList) { String nodeName = subNode.getNodeName(context); ModelNode node = modelTree.nodeMap.get(nodeName); @@ -420,9 +420,8 @@ public class ModelTree extends ModelWidg public String getEntityName() { if (!this.entityName.isEmpty()) { return this.entityName; - } else { - return this.modelTree.getDefaultEntityName(); } + return this.modelTree.getDefaultEntityName(); } public String getEntryName() { @@ -440,9 +439,8 @@ public class ModelTree extends ModelWidg public String getPkName(Map<String, Object> context) { if (UtilValidate.isNotEmpty(this.pkName)) { return this.pkName; - } else { - return this.modelTree.getDefaultPkName(context); } + return this.modelTree.getDefaultPkName(context); } public String getRenderStyle() { @@ -525,9 +523,7 @@ public class ModelTree extends ModelWidg } } else if (nodeCount == null) { getChildren(context); - if (subNodeValues != null) { - nodeCount = Long.valueOf(subNodeValues.size()); - } + nodeCount = Long.valueOf(subNodeValues.size()); } if (nodeCount != null && nodeCount.intValue() > 0) { hasChildren = true; @@ -883,7 +879,7 @@ public class ModelTree extends ModelWidg this.nameExdr = FlexibleStringExpander.getInstance(linkElement.getAttribute("name")); List<? extends Element> parameterElementList = UtilXml.childElementList(linkElement, "parameter"); if (!parameterElementList.isEmpty()) { - List<Parameter> parameterList = new ArrayList<Parameter>(parameterElementList.size()); + List<Parameter> parameterList = new ArrayList<>(parameterElementList.size()); for (Element parameterElement : parameterElementList) { parameterList.add(new Parameter(parameterElement)); } @@ -945,7 +941,7 @@ public class ModelTree extends ModelWidg } public Map<String, String> getParameterMap(Map<String, Object> context) { - Map<String, String> fullParameterMap = new HashMap<String, String>(); + Map<String, String> fullParameterMap = new HashMap<>(); /* leaving this here... may want to add it at some point like the hyperlink element: Map<String, String> addlParamMap = this.parametersMapAcsr.get(context); if (addlParamMap != null) { @@ -975,9 +971,8 @@ public class ModelTree extends ModelWidg if (simpleEncoder != null) { return this.targetExdr.expandString(UtilCodec.HtmlEncodingMapWrapper.getHtmlEncodingMapWrapper(context, simpleEncoder)); - } else { - return this.targetExdr.expandString(context); } + return this.targetExdr.expandString(context); } public String getTargetWindow(Map<String, Object> context) { @@ -1071,7 +1066,7 @@ public class ModelTree extends ModelWidg super(subNodeElement); this.rootNode = modelNode; this.nodeNameExdr = FlexibleStringExpander.getInstance(subNodeElement.getAttribute("node-name")); - ArrayList<ModelAction> actions = new ArrayList<ModelAction>(); + ArrayList<ModelAction> actions = new ArrayList<>(); // FIXME: Validate child elements, should be only one of actions, entity-and, entity-condition, service, script. Element actionsElement = UtilXml.firstChildElement(subNodeElement, "actions"); if (actionsElement != null) { Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTreeAction.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTreeAction.java?rev=1812918&r1=1812917&r2=1812918&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTreeAction.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTreeAction.java Sun Oct 22 13:58:51 2017 @@ -72,7 +72,7 @@ public abstract class ModelTreeAction ex public static List<ModelAction> readNodeActions(ModelNode modelNode, Element actionsElement) { List<? extends Element> actionElementList = UtilXml.childElementList(actionsElement); - List<ModelAction> actions = new ArrayList<ModelAction>(actionElementList.size()); + List<ModelAction> actions = new ArrayList<>(actionElementList.size()); for (Element actionElement : actionElementList) { if ("service".equals(actionElement.getNodeName())) { actions.add(new Service(modelNode, actionElement)); @@ -87,7 +87,7 @@ public abstract class ModelTreeAction ex public static List<ModelAction> readSubNodeActions(ModelNode.ModelSubNode modelSubNode, Element actionsElement) { List<? extends Element> actionElementList = UtilXml.childElementList(actionsElement); - List<ModelAction> actions = new ArrayList<ModelAction>(actionElementList.size()); + List<ModelAction> actions = new ArrayList<>(actionElementList.size()); for (Element actionElement : actionElementList) { if ("service".equals(actionElement.getNodeName())) { actions.add(new Service(modelSubNode, actionElement)); @@ -289,7 +289,7 @@ public abstract class ModelTreeAction ex public void runAction(Map<String, Object> context) { context.put("_LIST_ITERATOR_", null); if (location.endsWith(".xml")) { - Map<String, Object> localContext = new HashMap<String, Object>(); + Map<String, Object> localContext = new HashMap<>(); localContext.putAll(context); DispatchContext ctx = WidgetWorker.getDispatcher(context).getDispatchContext(); MethodContext methodContext = new MethodContext(ctx, localContext, null); @@ -400,7 +400,7 @@ public abstract class ModelTreeAction ex serviceContext = WidgetWorker.getDispatcher(context).getDispatchContext() .makeValidContext(serviceNameExpanded, ModelService.IN_PARAM, context); } else { - serviceContext = new HashMap<String, Object>(); + serviceContext = new HashMap<>(); } if (this.fieldMap != null) { EntityFinderUtil.expandFieldMapToContext(this.fieldMap, context, serviceContext); Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelWidgetCondition.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelWidgetCondition.java?rev=1812918&r1=1812917&r2=1812918&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelWidgetCondition.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelWidgetCondition.java Sun Oct 22 13:58:51 2017 @@ -94,7 +94,7 @@ public abstract class ModelWidgetConditi public static List<Condition> readSubConditions(ConditionFactory factory, ModelWidget modelWidget, Element conditionElement) { List<? extends Element> subElementList = UtilXml.childElementList(conditionElement); - List<Condition> condList = new ArrayList<Condition>(subElementList.size()); + List<Condition> condList = new ArrayList<>(subElementList.size()); for (Element subElement : subElementList) { condList.add(factory.newInstance(modelWidget, subElement)); } @@ -227,7 +227,7 @@ public abstract class ModelWidgetConditi if (fieldVal == null) { fieldVal = ""; } - List<Object> messages = new LinkedList<Object>(); + List<Object> messages = new LinkedList<>(); 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 [" @@ -280,7 +280,7 @@ public abstract class ModelWidgetConditi if (fieldVal == null) { fieldVal = ""; } - List<Object> messages = new LinkedList<Object>(); + List<Object> messages = new LinkedList<>(); Boolean resultBool = BaseCompare.doRealCompare(fieldVal, toFieldVal, operator, type, format, messages, null, null, false); if (messages.size() > 0) { @@ -479,29 +479,28 @@ public abstract class ModelWidgetConditi Debug.logError(e, module); return false; } - if (permService != null) { - // build the context - Map<String, Object> svcCtx = permService.makeValid(serviceContext, ModelService.IN_PARAM); - svcCtx.put("resourceDescription", resource); - if (UtilValidate.isNotEmpty(mainAction)) { - svcCtx.put("mainAction", mainAction); - } - // invoke the service - Map<String, Object> resp; - try { - resp = dispatcher.runSync(permService.name, svcCtx, 300, true); - } catch (GenericServiceException e) { - Debug.logError(e, module); - return false; - } - if (ServiceUtil.isError(resp) || ServiceUtil.isFailure(resp)) { - Debug.logError(ServiceUtil.getErrorMessage(resp), module); - return false; - } - Boolean hasPermission = (Boolean) resp.get("hasPermission"); - if (hasPermission != null) { - return hasPermission.booleanValue(); - } + // build the context + Map<String, Object> svcCtx = permService.makeValid(serviceContext, ModelService.IN_PARAM); + svcCtx.put("resourceDescription", resource); + if (UtilValidate.isNotEmpty(mainAction)) { + svcCtx.put("mainAction", mainAction); + } + // invoke the service + Map<String, Object> resp; + try { + resp = dispatcher.runSync(permService.name, svcCtx, 300, true); + } + catch (GenericServiceException e) { + Debug.logError(e, module); + return false; + } + if (ServiceUtil.isError(resp) || ServiceUtil.isFailure(resp)) { + Debug.logError(ServiceUtil.getErrorMessage(resp), module); + return false; + } + Boolean hasPermission = (Boolean) resp.get("hasPermission"); + if (hasPermission != null) { + return hasPermission.booleanValue(); } } return false; @@ -639,9 +638,8 @@ public abstract class ModelWidgetConditi if (foundOneTrue) { // now found two true, so return false return false; - } else { - foundOneTrue = true; } + foundOneTrue = true; } } return foundOneTrue; |
Free forum by Nabble | Edit this page |