Author: jleroux
Date: Wed Mar 29 15:25:39 2017 New Revision: 1789381 URL: http://svn.apache.org/viewvc?rev=1789381&view=rev Log: Fixes r1788869 where I did not what I intented to do. I wrote then <<No functional changes. Fixes some unchecked casts by using UtilMisc.toMap Adds some @SuppressWarnings("unchecked") Adds few @SuppressWarnings("unused") Cleans imports Completes and fixes Javadoc in BirtUtil class>> Er, of course you can't fix unchecked casts by using UtilMisc.toMap, I intended to use UtilGenerics.checkMap and got mislead by Eclipse which also hides unchecked casts warnings when you use UtilMisc.toMap Then all derailed and I put some @SuppressWarnings("unchecked") to hide warning on List unchecked casts :/ The rest was correct but a private GenericValue userLogin; in ReportDesignGenerator which is really useless There are still no functional changes but some amended comments (French) and added TODO I note that the translated TODO needs a re-visit, smell like factoring is needed Modified: ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/flexible/BirtMasterReportServices.java ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/flexible/BirtServices.java ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/flexible/BirtUtil.java ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/flexible/ReportDesignGenerator.java Modified: ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/flexible/BirtMasterReportServices.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/flexible/BirtMasterReportServices.java?rev=1789381&r1=1789380&r2=1789381&view=diff ============================================================================== --- ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/flexible/BirtMasterReportServices.java (original) +++ ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/flexible/BirtMasterReportServices.java Wed Mar 29 15:25:39 2017 @@ -11,6 +11,7 @@ import java.util.Map; import java.util.Set; import org.apache.ofbiz.base.util.UtilDateTime; +import org.apache.ofbiz.base.util.UtilGenerics; import org.apache.ofbiz.base.util.UtilMisc; import org.apache.ofbiz.base.util.UtilProperties; import org.apache.ofbiz.base.util.UtilValidate; @@ -33,7 +34,7 @@ public class BirtMasterReportServices { public static final String resource = "BirtUiLabels"; public static final String resource_error = "BirtErrorUiLabels"; - // The following methods are flexible service as example for reporting + // The following methods are flexible report services as examples for reporting public static Map<String, Object> workEffortPerPersonPrepareDate(DispatchContext dctx, Map<String, Object> context) { Map<String, String> dataMap = UtilMisc.toMap("lastName", "name", "firstName", "name", "hours", "floating-point", "fromDate", "date-time", "thruDate", "date-time"); LinkedHashMap<String, String> filterMap = new LinkedHashMap<String, String>(); @@ -58,7 +59,7 @@ public class BirtMasterReportServices { public static Map<String, Object> workEffortPerPerson(DispatchContext dctx, Map<String, Object> context) { Delegator delegator = (Delegator) dctx.getDelegator(); IReportContext reportContext = (IReportContext) context.get("reportContext"); - Map<String, Object> parameters = UtilMisc.<String, Object>toMap(reportContext.getParameterValue("parameters")); + Map<String, Object> parameters = UtilGenerics.checkMap(reportContext.getParameterValue("parameters")); List<GenericValue> listWorkEffortTime = null; if (UtilValidate.isEmpty(parameters.get("firstName")) && UtilValidate.isEmpty(parameters.get("lastName"))) { @@ -147,7 +148,7 @@ public class BirtMasterReportServices { Delegator delegator = (Delegator) dctx.getDelegator(); Locale locale = (Locale) context.get("locale"); IReportContext reportContext = (IReportContext) context.get("reportContext"); - Map<String, Object> parameters = UtilMisc.<String, Object>toMap(reportContext.getParameterValue("parameters")); + Map<String, Object> parameters = UtilGenerics.checkMap(reportContext.getParameterValue("parameters")); List<GenericValue> listTurnOver = null; List<Map<String, Object>> listInvoiceEditable = new ArrayList<Map<String, Object>>(); @@ -178,7 +179,7 @@ public class BirtMasterReportServices { String productCategoryId = (String) parameters.get("productCategoryId"); productCategoryList.add(productCategoryId); } else if (parameters.get("productStoreId") instanceof String) { - productCategoryList = (List<String>) parameters.get("productCategoryId"); + productCategoryList = UtilGenerics.checkList(parameters.get("productCategoryId")); } // getting productIds in these categories EntityExpr conditionProductCategory = EntityCondition.makeCondition("primaryProductCategoryId", EntityOperator.IN, productCategoryList); @@ -202,7 +203,7 @@ public class BirtMasterReportServices { String productStoreId = (String) parameters.get("productStoreId"); productStoreList.add(productStoreId); } else if (parameters.get("productStoreId") instanceof List) { - productStoreList = (List<String>) parameters.get("productStoreId"); + productStoreList = UtilGenerics.checkList(parameters.get("productStoreId")); } // getting list of invoice Ids linked to these productStore EntityExpr conditionProductStoreId = EntityCondition.makeCondition("productStoreId", EntityOperator.IN, productStoreList); @@ -260,7 +261,7 @@ public class BirtMasterReportServices { // adding missing fields for (GenericValue invoice : listTurnOver) { - Map<String, Object> invoiceEditableTemp = UtilMisc.<String, Object>toMap(invoice.clone()); + Map<String, Object> invoiceEditableTemp = UtilGenerics.checkMap(invoice.clone()); invoiceEditableTemp.remove("GenericEntity"); Map<String, Object> invoiceEditable = new HashMap<String, Object>(); invoiceEditable.putAll(invoiceEditableTemp); Modified: ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/flexible/BirtServices.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/flexible/BirtServices.java?rev=1789381&r1=1789380&r2=1789381&view=diff ============================================================================== --- ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/flexible/BirtServices.java (original) +++ ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/flexible/BirtServices.java Wed Mar 29 15:25:39 2017 @@ -38,6 +38,7 @@ import javax.xml.parsers.ParserConfigura import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.base.util.GeneralException; import org.apache.ofbiz.base.util.StringUtil; +import org.apache.ofbiz.base.util.UtilGenerics; import org.apache.ofbiz.base.util.UtilMisc; import org.apache.ofbiz.base.util.UtilProperties; import org.apache.ofbiz.base.util.UtilValidate; @@ -163,7 +164,7 @@ public class BirtServices { Locale locale = (Locale) context.get("locale"); GenericValue userLogin = (GenericValue) context.get("userLogin"); String entityViewName = (String) reportContext.getParameterValue("modelElementName"); - Map<String, Object> inputFields = UtilMisc.<String, Object>toMap(reportContext.getParameterValue("parameters")); + Map<String, Object> inputFields = UtilGenerics.checkMap(reportContext.getParameterValue("parameters")); Map<String, Object> resultPerformFind = new HashMap<String, Object>(); Map<String, Object> resultToBirt = null; List<GenericValue> list = null; @@ -337,18 +338,18 @@ public class BirtServices { if (ServiceUtil.isError(resultMapsForGeneration)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(resultMapsForGeneration)); } - Map<String, String> dataMap = UtilMisc.<String, String>toMap(resultMapsForGeneration.get("dataMap")); + Map<String, String> dataMap = UtilGenerics.checkMap(resultMapsForGeneration.get("dataMap")); Map<String, String> fieldDisplayLabels = null; if (UtilValidate.isNotEmpty(resultMapsForGeneration.get("fieldDisplayLabels"))) { - fieldDisplayLabels = UtilMisc.<String, String>toMap(resultMapsForGeneration.get("fieldDisplayLabels")); + fieldDisplayLabels = UtilGenerics.checkMap(resultMapsForGeneration.get("fieldDisplayLabels")); } Map<String, String> filterMap = null; if (UtilValidate.isNotEmpty(resultMapsForGeneration.get("filterMap"))) { - filterMap = UtilMisc.<String, String>toMap(resultMapsForGeneration.get("filterMap")); + filterMap = UtilGenerics.checkMap(resultMapsForGeneration.get("filterMap")); } Map<String, String> filterDisplayLabels = null; if (UtilValidate.isNotEmpty(resultMapsForGeneration.get("filterDisplayLabels"))) { - filterDisplayLabels = UtilMisc.<String, String>toMap(resultMapsForGeneration.get("filterDisplayLabels")); + filterDisplayLabels = UtilGenerics.checkMap(resultMapsForGeneration.get("filterDisplayLabels")); } contentId = BirtWorker.recordReportContent(delegator, dispatcher, context); // callPerformFindFromBirt is the customMethod for Entity workflow @@ -418,10 +419,10 @@ public class BirtServices { contentId = BirtWorker.recordReportContent(delegator, dispatcher, context); String rptDesignFileName = BirtUtil.resolveRptDesignFilePathFromContent(delegator, contentId); Map<String, Object> resultService = dispatcher.runSync(serviceName, UtilMisc.toMap("locale", locale, "userLogin", userLogin)); - Map<String, String> dataMap = UtilMisc.<String, String>toMap(resultService.get("dataMap")); - Map<String, String> filterMap = UtilMisc.<String, String>toMap(resultService.get("filterMap")); - Map<String, String> fieldDisplayLabels = UtilMisc.<String, String>toMap(resultService.get("fieldDisplayLabels")); - Map<String, String> filterDisplayLabels = UtilMisc.<String, String>toMap(resultService.get("filterDisplayLabels")); + Map<String, String> dataMap = UtilGenerics.checkMap(resultService.get("dataMap")); + Map<String, String> filterMap = UtilGenerics.checkMap(resultService.get("filterMap")); + Map<String, String> fieldDisplayLabels = UtilGenerics.checkMap(resultService.get("fieldDisplayLabels")); + Map<String, String> filterDisplayLabels = UtilGenerics.checkMap(resultService.get("filterDisplayLabels")); Map<String, Object> resultGeneration = dispatcher.runSync("createFlexibleReport", UtilMisc.toMap( "locale", locale, "dataMap", dataMap, @@ -760,7 +761,7 @@ public class BirtServices { } } - // adding simple master page => tous ces casts et autres instanceof... c'est laid, mais c'est tellement galère que quand je trouve une solution qui marche... :s + // adding simple master page => All these casts and other occurrences ... It's ugly, but it's so hard that when I find a solution that works ... @SuppressWarnings("unchecked") List<DesignElementHandle> listMasterPages = designFromUser.getMasterPages().getContents(); for (DesignElementHandle masterPage : listMasterPages) { Modified: ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/flexible/BirtUtil.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/flexible/BirtUtil.java?rev=1789381&r1=1789380&r2=1789381&view=diff ============================================================================== --- ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/flexible/BirtUtil.java (original) +++ ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/flexible/BirtUtil.java Wed Mar 29 15:25:39 2017 @@ -42,8 +42,7 @@ public final class BirtUtil { public final static String module = BirtUtil.class.getName(); - @SuppressWarnings("unused") - private final static HTMLServerImageHandler imageHandler = new HTMLServerImageHandler(); + private final static HTMLServerImageHandler imageHandler = new HTMLServerImageHandler(); // TODO not used yet or to remove private final static Map<String, String> entityFieldTypeBirtTypeMap = MapUtils.unmodifiableMap(UtilMisc.toMap( "id", DesignChoiceConstants.COLUMN_DATA_TYPE_STRING, "url", DesignChoiceConstants.COLUMN_DATA_TYPE_STRING, Modified: ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/flexible/ReportDesignGenerator.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/flexible/ReportDesignGenerator.java?rev=1789381&r1=1789380&r2=1789381&view=diff ============================================================================== --- ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/flexible/ReportDesignGenerator.java (original) +++ ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/flexible/ReportDesignGenerator.java Wed Mar 29 15:25:39 2017 @@ -7,9 +7,9 @@ import java.util.Map; import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.base.util.GeneralException; +import org.apache.ofbiz.base.util.UtilGenerics; import org.apache.ofbiz.base.util.UtilProperties; import org.apache.ofbiz.base.util.UtilValidate; -import org.apache.ofbiz.entity.GenericValue; import org.apache.ofbiz.service.DispatchContext; import org.apache.ofbiz.service.GenericServiceException; import org.eclipse.birt.core.framework.Platform; @@ -62,22 +62,18 @@ public class ReportDesignGenerator { private Map<String, String> filterDisplayLabels; private String rptDesignName; private boolean generateFilters = false; - @SuppressWarnings("unused") - private GenericValue userLogin; public static final String resource_error = "BirtErrorUiLabels"; - @SuppressWarnings("unchecked") public ReportDesignGenerator(Map<String, Object> context, DispatchContext dctx) throws GeneralException, SemanticException { locale = (Locale) context.get("locale"); - dataMap = (Map<String, String>) context.get("dataMap"); + dataMap = UtilGenerics.checkMap(context.get("dataMap")); filterMap = (LinkedHashMap<String, String>) context.get("filterMap"); serviceName = (String) context.get("serviceName"); - fieldDisplayLabels = (Map<String, String>) context.get("fieldDisplayLabels"); + fieldDisplayLabels = UtilGenerics.checkMap(context.get("fieldDisplayLabels")); filterDisplayLabels = (LinkedHashMap<String, String>) context.get("filterDisplayLabels"); rptDesignName = (String) context.get("rptDesignName"); String writeFilters = (String) context.get("writeFilters"); - userLogin = (GenericValue) context.get("userLogin"); if (UtilValidate.isEmpty(dataMap)) { throw new GeneralException("Report design generator failed. Entry data map not found."); } |
Free forum by Nabble | Edit this page |