diff --git a/assetmaint/groovyScripts/assetmaint/EditMaint.groovy b/assetmaint/groovyScripts/assetmaint/EditMaint.groovy index bf7dea1fd..0357494b6 100644 --- a/assetmaint/groovyScripts/assetmaint/EditMaint.groovy +++ b/assetmaint/groovyScripts/assetmaint/EditMaint.groovy @@ -21,13 +21,13 @@ // screen is called from one of the WorkEffort calendar screens. // The URL coming from WorkEffort does not contain the maintHistSeqId parameter, // so this script will look it up using the workEffortId parameter. -maintHistSeqId = parameters.maintHistSeqId; -workEffortId = parameters.workEffortId; +maintHistSeqId = parameters.maintHistSeqId +workEffortId = parameters.workEffortId if (!maintHistSeqId && workEffortId) { - fixedAssetMaint = from("FixedAssetMaint").where("scheduleWorkEffortId", workEffortId).queryFirst(); + fixedAssetMaint = from("FixedAssetMaint").where("scheduleWorkEffortId", workEffortId).queryFirst() if (fixedAssetMaint) { - parameters.fixedAssetId = fixedAssetMaint.fixedAssetId; - parameters.maintHistSeqId = fixedAssetMaint.maintHistSeqId; + parameters.fixedAssetId = fixedAssetMaint.fixedAssetId + parameters.maintHistSeqId = fixedAssetMaint.maintHistSeqId } } diff --git a/assetmaint/groovyScripts/assetmaint/PrintFixedAssetMaint.groovy b/assetmaint/groovyScripts/assetmaint/PrintFixedAssetMaint.groovy index 4904fa0ad..a637857d1 100644 --- a/assetmaint/groovyScripts/assetmaint/PrintFixedAssetMaint.groovy +++ b/assetmaint/groovyScripts/assetmaint/PrintFixedAssetMaint.groovy @@ -17,52 +17,52 @@ specific language governing permissions and limitations under the License. **/ -facility = fixedAsset.getRelatedOne("LocatedAtFacility", false); -context.locatedAtFacility = facility; +facility = fixedAsset.getRelatedOne("LocatedAtFacility", false) +context.locatedAtFacility = facility -fixedAssetIdents = from("FixedAssetIdent").where("fixedAssetId", fixedAssetId).queryList(); -fixedAssetIdentValue = ""; +fixedAssetIdents = from("FixedAssetIdent").where("fixedAssetId", fixedAssetId).queryList() +fixedAssetIdentValue = "" if (fixedAssetIdents) { fixedAssetIdents.each { ident -> - fixedAssetIdentValue = fixedAssetIdentValue + " " + ident.idValue; + fixedAssetIdentValue = fixedAssetIdentValue + " " + ident.idValue } } -context.fixedAssetIdentValue = fixedAssetIdentValue; +context.fixedAssetIdentValue = fixedAssetIdentValue -status = fixedAssetMaint.getRelatedOne("StatusItem", false); +status = fixedAssetMaint.getRelatedOne("StatusItem", false) if (status) { - context.statusItemDesc = status.description; + context.statusItemDesc = status.description } -//context.put("fixedAssetMaint",fixedAssetMaint); +//context.put("fixedAssetMaint",fixedAssetMaint) -intervalUom = fixedAssetMaint.getRelatedOne("IntervalUom", false); +intervalUom = fixedAssetMaint.getRelatedOne("IntervalUom", false) if (intervalUom) { - context.intervalUomDesc = intervalUom.description; + context.intervalUomDesc = intervalUom.description } -instanceOfProductId = fixedAsset.instanceOfProductId; -productMaintSeqId = fixedAssetMaint.productMaintSeqId; +instanceOfProductId = fixedAsset.instanceOfProductId +productMaintSeqId = fixedAssetMaint.productMaintSeqId if (productMaintSeqId) { - productMaint = from("ProductMaint").where("productId", instanceOfProductId, "productMaintSeqId", productMaintSeqId).queryOne(); - context.productMaintName = productMaint.maintName; + productMaint = from("ProductMaint").where("productId", instanceOfProductId, "productMaintSeqId", productMaintSeqId).queryOne() + context.productMaintName = productMaint.maintName } -productMaintTypeId = fixedAssetMaint.productMaintTypeId; +productMaintTypeId = fixedAssetMaint.productMaintTypeId if (productMaintTypeId) { - productMaintType = from("ProductMaintType").where("productMaintTypeId", productMaintTypeId).queryOne(); + productMaintType = from("ProductMaintType").where("productMaintTypeId", productMaintTypeId).queryOne() if (productMaintType) { - productMaintTypeDesc = productMaintType.description; - context.productMaintTypeDesc = productMaintTypeDesc; + productMaintTypeDesc = productMaintType.description + context.productMaintTypeDesc = productMaintTypeDesc } } -intervalMeterTypeId = fixedAssetMaint.intervalMeterTypeId; -productMeterTypeDesc = ""; +intervalMeterTypeId = fixedAssetMaint.intervalMeterTypeId +productMeterTypeDesc = "" if (intervalMeterTypeId) { - productMeterType = from("ProductMeterType").where("productMeterTypeId", intervalMeterTypeId).queryOne(); - productMeterTypeDesc = productMeterType.description; + productMeterType = from("ProductMeterType").where("productMeterTypeId", intervalMeterTypeId).queryOne() + productMeterTypeDesc = productMeterType.description } -context.productMeterTypeDesc = productMeterTypeDesc; +context.productMeterTypeDesc = productMeterTypeDesc -scheduleWorkEffort = fixedAssetMaint.getRelatedOne("ScheduleWorkEffort", false); -context.scheduleWorkEffort = scheduleWorkEffort; +scheduleWorkEffort = fixedAssetMaint.getRelatedOne("ScheduleWorkEffort", false) +context.scheduleWorkEffort = scheduleWorkEffort diff --git a/assetmaint/groovyScripts/workeffort/EditWorkEfforts.groovy b/assetmaint/groovyScripts/workeffort/EditWorkEfforts.groovy index 1e987ecbf..fa8cbfda3 100644 --- a/assetmaint/groovyScripts/workeffort/EditWorkEfforts.groovy +++ b/assetmaint/groovyScripts/workeffort/EditWorkEfforts.groovy @@ -17,61 +17,61 @@ under the License. */ -maintHistSeqId = context.maintHistSeqId; -fixedAssetId = context.fixedAssetId; -workEffortId = context.workEffortId; +maintHistSeqId = context.maintHistSeqId +fixedAssetId = context.fixedAssetId +workEffortId = context.workEffortId if (!maintHistSeqId) { - maintHistSeqId = parameters.maintHistSeqId; + maintHistSeqId = parameters.maintHistSeqId } if (!fixedAssetId) { - fixedAssetId = parameters.fixedAssetId; + fixedAssetId = parameters.fixedAssetId } if (!workEffortId) { - workEffortId = parameters.workEffortId; + workEffortId = parameters.workEffortId } -fixedAssetMaint = null; -workEffort = null; -fixedAsset = null; -rootWorkEffortId = null; +fixedAssetMaint = null +workEffort = null +fixedAsset = null +rootWorkEffortId = null if (workEffortId) { - workEffort = from("WorkEffort").where("workEffortId", workEffortId).queryOne(); + workEffort = from("WorkEffort").where("workEffortId", workEffortId).queryOne() if (workEffort) { if (!fixedAssetId) { - fixedAssetId = workEffort.fixedAssetId; + fixedAssetId = workEffort.fixedAssetId } // If this is a child workeffort, locate the "root" workeffort - parentWorkEffort = from("WorkEffortAssoc").where("workEffortIdTo", workEffortId).queryFirst(); + parentWorkEffort = from("WorkEffortAssoc").where("workEffortIdTo", workEffortId).queryFirst() while (parentWorkEffort) { - rootWorkEffortId = parentWorkEffort.workEffortIdFrom; - parentWorkEffort = from("WorkEffortAssoc").where("workEffortIdTo", rootWorkEffortId).queryFirst(); + rootWorkEffortId = parentWorkEffort.workEffortIdFrom + parentWorkEffort = from("WorkEffortAssoc").where("workEffortIdTo", rootWorkEffortId).queryFirst() } } } if (!rootWorkEffortId) { - rootWorkEffortId = workEffortId; + rootWorkEffortId = workEffortId } if (rootWorkEffortId) { - fixedAssetMaint = from("FixedAssetMaint").where("scheduleWorkEffortId", rootWorkEffortId).queryFirst(); + fixedAssetMaint = from("FixedAssetMaint").where("scheduleWorkEffortId", rootWorkEffortId).queryFirst() if (fixedAssetMaint) { - maintHistSeqId = fixedAssetMaint.maintHistSeqId; + maintHistSeqId = fixedAssetMaint.maintHistSeqId if (!fixedAssetId) { - fixedAssetId = fixedAssetMaint.fixedAssetId; + fixedAssetId = fixedAssetMaint.fixedAssetId } } } if (fixedAssetId) { - fixedAsset = from("FixedAsset").where("fixedAssetId", fixedAssetId).queryOne(); + fixedAsset = from("FixedAsset").where("fixedAssetId", fixedAssetId).queryOne() } -context.fixedAssetMaint = fixedAssetMaint; -context.workEffort = workEffort; -context.fixedAsset = fixedAsset; -context.maintHistSeqId = maintHistSeqId; -context.fixedAssetId = fixedAssetId; -context.workEffortId = workEffortId; +context.fixedAssetMaint = fixedAssetMaint +context.workEffort = workEffort +context.fixedAsset = fixedAsset +context.maintHistSeqId = maintHistSeqId +context.fixedAssetId = fixedAssetId +context.workEffortId = workEffortId diff --git a/bi/groovyScripts/GetStarSchemaFields.groovy b/bi/groovyScripts/GetStarSchemaFields.groovy index 75684a00c..20bcde08b 100644 --- a/bi/groovyScripts/GetStarSchemaFields.groovy +++ b/bi/groovyScripts/GetStarSchemaFields.groovy @@ -17,30 +17,30 @@ * under the License. */ -starSchemaName = parameters.starSchemaName; +starSchemaName = parameters.starSchemaName -starSchemaFields = []; +starSchemaFields = [] if (starSchemaName) { - reader = delegator.getModelReader(); - starSchema = reader.getModelEntity(starSchemaName); + reader = delegator.getModelReader() + starSchema = reader.getModelEntity(starSchemaName) if (starSchema) { - fieldsIt = starSchema.getAliasesIterator(); + fieldsIt = starSchema.getAliasesIterator() while (fieldsIt.hasNext()) { - field = fieldsIt.next(); - fieldMap = [:]; - fieldMap.name = field.getName(); - description = field.getDescription(); + field = fieldsIt.next() + fieldMap = [:] + fieldMap.name = field.getName() + description = field.getDescription() if (!description) { - aliasedEntity = starSchema.getAliasedEntity(field.getEntityAlias(), reader); + aliasedEntity = starSchema.getAliasedEntity(field.getEntityAlias(), reader) if (aliasedEntity) { - aliasedField = starSchema.getAliasedField(aliasedEntity, field.getField(), reader); - description = aliasedField.getDescription(); + aliasedField = starSchema.getAliasedField(aliasedEntity, field.getField(), reader) + description = aliasedField.getDescription() } } - fieldMap.description = description; - starSchemaFields.add(fieldMap); + fieldMap.description = description + starSchemaFields.add(fieldMap) } } } -context.starSchemaName = starSchemaName; -context.starSchemaFields = starSchemaFields; +context.starSchemaName = starSchemaName +context.starSchemaFields = starSchemaFields diff --git a/bi/groovyScripts/GetStarSchemas.groovy b/bi/groovyScripts/GetStarSchemas.groovy index 02cb13d2e..1de6845a6 100644 --- a/bi/groovyScripts/GetStarSchemas.groovy +++ b/bi/groovyScripts/GetStarSchemas.groovy @@ -17,24 +17,24 @@ * under the License. */ -reader = delegator.getModelReader(); -ec = reader.getEntityNames(); -entities = new TreeSet(ec); -entitiesIt = entities.iterator(); +reader = delegator.getModelReader() +ec = reader.getEntityNames() +entities = new TreeSet(ec) +entitiesIt = entities.iterator() -List starSchemas = []; +List starSchemas = [] while (entitiesIt.hasNext()) { - entity = reader.getModelEntity(entitiesIt.next()); - packageName = entity.getPackageName(); + entity = reader.getModelEntity(entitiesIt.next()) + packageName = entity.getPackageName() if (!packageName.contains("starschema")) { - continue; + continue } - entityMap = [:]; - entityMap.name = entity.getEntityName(); - entityMap.title = entity.getTitle(); + entityMap = [:] + entityMap.name = entity.getEntityName() + entityMap.title = entity.getTitle() - starSchemas.add(entityMap); + starSchemas.add(entityMap) } -context.starSchemas = starSchemas; +context.starSchemas = starSchemas diff --git a/bi/groovyScripts/RunStarSchemaQuery.groovy b/bi/groovyScripts/RunStarSchemaQuery.groovy index 5792e747a..42b3a42b2 100644 --- a/bi/groovyScripts/RunStarSchemaQuery.groovy +++ b/bi/groovyScripts/RunStarSchemaQuery.groovy @@ -17,17 +17,17 @@ * under the License. */ -import org.apache.ofbiz.base.util.UtilHttp; +import org.apache.ofbiz.base.util.UtilHttp -starSchemaName = parameters.starSchemaName; -selectedFieldList = UtilHttp.parseMultiFormData(parameters); +starSchemaName = parameters.starSchemaName +selectedFieldList = UtilHttp.parseMultiFormData(parameters) -columnNames = [] as Set; +columnNames = [] as Set selectedFieldList.each { selectedField -> - columnNames.add(selectedField.selectedFieldName); + columnNames.add(selectedField.selectedFieldName) } -context.columnNames = columnNames; -List records = []; -records = select(context.columnNames).from(starSchemaName).distinct(false).queryList(); +context.columnNames = columnNames +List records = [] +records = select(context.columnNames).from(starSchemaName).distinct(false).queryList() -context.records = records; +context.records = records diff --git a/birt/groovyScripts/accounting/AcctgTransEntriesSearchResultsParameters.groovy b/birt/groovyScripts/accounting/AcctgTransEntriesSearchResultsParameters.groovy index cf252f9eb..08e47a024 100644 --- a/birt/groovyScripts/accounting/AcctgTransEntriesSearchResultsParameters.groovy +++ b/birt/groovyScripts/accounting/AcctgTransEntriesSearchResultsParameters.groovy @@ -17,32 +17,32 @@ * under the License. */ -def module = "AcctgTransEntriesSearchResultsParameters.groovy"; +def module = "AcctgTransEntriesSearchResultsParameters.groovy" try { - def birtParameters = [:]; - birtParameters.organizationPartyId = parameters.organizationPartyId; - birtParameters.productId = parameters.productId; - birtParameters.isPosted = parameters.isPosted; - birtParameters.invoiceId = parameters.invoiceId; - birtParameters.acctgTransId = parameters.acctgTransId; - birtParameters.glFiscalTypeId = parameters.glFiscalTypeId; - birtParameters.glAccountId = parameters.glAccountId; - birtParameters.shipmentId = parameters.shipmentId; - birtParameters.acctgTransTypeId = parameters.acctgTransTypeId; - birtParameters.workEffortId = parameters.workEffortId; - birtParameters.glJournalId = parameters.glJournalId; - birtParameters.partyId = parameters.partyId; - birtParameters.paymentId = parameters.paymentId; + def birtParameters = [:] + birtParameters.organizationPartyId = parameters.organizationPartyId + birtParameters.productId = parameters.productId + birtParameters.isPosted = parameters.isPosted + birtParameters.invoiceId = parameters.invoiceId + birtParameters.acctgTransId = parameters.acctgTransId + birtParameters.glFiscalTypeId = parameters.glFiscalTypeId + birtParameters.glAccountId = parameters.glAccountId + birtParameters.shipmentId = parameters.shipmentId + birtParameters.acctgTransTypeId = parameters.acctgTransTypeId + birtParameters.workEffortId = parameters.workEffortId + birtParameters.glJournalId = parameters.glJournalId + birtParameters.partyId = parameters.partyId + birtParameters.paymentId = parameters.paymentId if (parameters.fromDate) { - birtParameters.fromDate = Timestamp.valueOf(parameters.fromDate); + birtParameters.fromDate = Timestamp.valueOf(parameters.fromDate) } if (parameters.thruDate) { - birtParameters.thruDate = Timestamp.valueOf(parameters.thruDate); + birtParameters.thruDate = Timestamp.valueOf(parameters.thruDate) } - birtParameters.userLoginId = userLogin.userLoginId; - request.setAttribute("birtParameters", birtParameters); + birtParameters.userLoginId = userLogin.userLoginId + request.setAttribute("birtParameters", birtParameters) } catch (e) { - Debug.logError(e, module); + Debug.logError(e, module) } return "success"; \ No newline at end of file diff --git a/birt/groovyScripts/accounting/BalanceSheetParameters.groovy b/birt/groovyScripts/accounting/BalanceSheetParameters.groovy index 2498dee38..6ff0ceb85 100644 --- a/birt/groovyScripts/accounting/BalanceSheetParameters.groovy +++ b/birt/groovyScripts/accounting/BalanceSheetParameters.groovy @@ -17,25 +17,25 @@ * under the License. */ -import java.sql.Timestamp; -import org.apache.ofbiz.base.util.Debug; +import java.sql.Timestamp +import org.apache.ofbiz.base.util.Debug -def module = "BalanceSheetParameters.groovy"; +def module = "BalanceSheetParameters.groovy" try { - def birtParameters = [:]; + def birtParameters = [:] if (parameters.fromDate) { - birtParameters.fromDate = Timestamp.valueOf(parameters.fromDate); + birtParameters.fromDate = Timestamp.valueOf(parameters.fromDate) } if (parameters.thruDate) { - birtParameters.thruDate = Timestamp.valueOf(parameters.thruDate); + birtParameters.thruDate = Timestamp.valueOf(parameters.thruDate) } - birtParameters.glFiscalTypeId = parameters.glFiscalTypeId; - birtParameters.organizationPartyId = parameters.organizationPartyId; - birtParameters.userLoginId = userLogin.userLoginId; - birtParameters.locale = locale; - request.setAttribute("birtParameters", birtParameters); + birtParameters.glFiscalTypeId = parameters.glFiscalTypeId + birtParameters.organizationPartyId = parameters.organizationPartyId + birtParameters.userLoginId = userLogin.userLoginId + birtParameters.locale = locale + request.setAttribute("birtParameters", birtParameters) } catch (e) { - Debug.logError(e, module); + Debug.logError(e, module) } return "success"; \ No newline at end of file diff --git a/birt/groovyScripts/accounting/IncomeStatementParameters.groovy b/birt/groovyScripts/accounting/IncomeStatementParameters.groovy index 0ac6bd4b4..ebf7836ab 100644 --- a/birt/groovyScripts/accounting/IncomeStatementParameters.groovy +++ b/birt/groovyScripts/accounting/IncomeStatementParameters.groovy @@ -17,24 +17,24 @@ * under the License. */ -import java.sql.Timestamp; -import org.apache.ofbiz.base.util.Debug; +import java.sql.Timestamp +import org.apache.ofbiz.base.util.Debug -def module = "IncomeStatementParameters.groovy"; +def module = "IncomeStatementParameters.groovy" try { - def birtParameters = [:]; + def birtParameters = [:] if (parameters.fromDate) { - birtParameters.fromDate = Timestamp.valueOf(parameters.fromDate); + birtParameters.fromDate = Timestamp.valueOf(parameters.fromDate) } if (parameters.thruDate) { - birtParameters.thruDate = Timestamp.valueOf(parameters.thruDate); + birtParameters.thruDate = Timestamp.valueOf(parameters.thruDate) } - birtParameters.glFiscalTypeId = parameters.glFiscalTypeId; - birtParameters.organizationPartyId = parameters.organizationPartyId; - birtParameters.userLoginId = userLogin.userLoginId; - request.setAttribute("birtParameters", birtParameters); + birtParameters.glFiscalTypeId = parameters.glFiscalTypeId + birtParameters.organizationPartyId = parameters.organizationPartyId + birtParameters.userLoginId = userLogin.userLoginId + request.setAttribute("birtParameters", birtParameters) } catch (e) { - Debug.logError(e, module); + Debug.logError(e, module) } return "success"; \ No newline at end of file diff --git a/birt/groovyScripts/accounting/InvoiceAcctgTransEntryParameters.groovy b/birt/groovyScripts/accounting/InvoiceAcctgTransEntryParameters.groovy index f32fc6ead..efe2074ed 100644 --- a/birt/groovyScripts/accounting/InvoiceAcctgTransEntryParameters.groovy +++ b/birt/groovyScripts/accounting/InvoiceAcctgTransEntryParameters.groovy @@ -17,14 +17,14 @@ * under the License. */ -def module = "InvoiceAcctgTransEntryParameters.groovy"; +def module = "InvoiceAcctgTransEntryParameters.groovy" try { - birtParameters = [:]; - birtParameters.invoiceId = parameters.invoiceId; - birtParameters.userLoginId = userLogin.userLoginId; - request.setAttribute("birtParameters", birtParameters); + birtParameters = [:] + birtParameters.invoiceId = parameters.invoiceId + birtParameters.userLoginId = userLogin.userLoginId + request.setAttribute("birtParameters", birtParameters) } catch (e) { - Debug.logError(e, module); + Debug.logError(e, module) } return "success"; \ No newline at end of file diff --git a/birt/groovyScripts/accounting/PaymentAcctgTransEntryParameters.groovy b/birt/groovyScripts/accounting/PaymentAcctgTransEntryParameters.groovy index 9b905d91a..244485aa5 100644 --- a/birt/groovyScripts/accounting/PaymentAcctgTransEntryParameters.groovy +++ b/birt/groovyScripts/accounting/PaymentAcctgTransEntryParameters.groovy @@ -17,14 +17,14 @@ * under the License. */ -def module = "PaymentAcctgTransEntryParameters.groovy"; +def module = "PaymentAcctgTransEntryParameters.groovy" try { - birtParameters = [:]; - birtParameters.paymentId = parameters.paymentId; - birtParameters.userLoginId = userLogin.userLoginId; - request.setAttribute("birtParameters", birtParameters); + birtParameters = [:] + birtParameters.paymentId = parameters.paymentId + birtParameters.userLoginId = userLogin.userLoginId + request.setAttribute("birtParameters", birtParameters) } catch (e) { - Debug.logError(e, module); + Debug.logError(e, module) } return "success"; \ No newline at end of file diff --git a/birt/groovyScripts/accounting/PaymentReport.groovy b/birt/groovyScripts/accounting/PaymentReport.groovy index 955e5de91..bba5ab7b2 100644 --- a/birt/groovyScripts/accounting/PaymentReport.groovy +++ b/birt/groovyScripts/accounting/PaymentReport.groovy @@ -17,23 +17,23 @@ * under the License. */ -birtParameters = [:]; -birtParameters.partyIdTo = request.getParameter("partyIdTo"); -birtParameters.paymentId = request.getParameter("paymentId"); -birtParameters.paymentTypeId = request.getParameter("paymentTypeId"); -birtParameters.paymentId_op = request.getParameter("paymentId_op"); -birtParameters.paymentRefNum_ic = request.getParameter("paymentRefNum_ic"); -birtParameters.noConditionFind = request.getParameter("noConditionFind"); -birtParameters.contentType = request.getParameter("contentType"); -birtParameters.partyIdFrom = request.getParameter("partyIdFrom"); -birtParameters.paymentRefNum_op = request.getParameter("paymentRefNum_op"); -birtParameters.amount = request.getParameter("amount"); -birtParameters.statusId = request.getParameter("statusId"); -birtParameters.paymentGatewayResponseId = request.getParameter("paymentGatewayResponseId"); -birtParameters.paymentId_ic = request.getParameter("paymentId_ic"); -birtParameters.paymentRefNum = request.getParameter("paymentRefNum"); -birtParameters.comments_ic = request.getParameter("comments_ic"); -birtParameters.comments_op = request.getParameter("comments_op"); -birtParameters.comments = request.getParameter("comments"); -request.setAttribute("birtParameters", birtParameters); -return "success"; +birtParameters = [:] +birtParameters.partyIdTo = request.getParameter("partyIdTo") +birtParameters.paymentId = request.getParameter("paymentId") +birtParameters.paymentTypeId = request.getParameter("paymentTypeId") +birtParameters.paymentId_op = request.getParameter("paymentId_op") +birtParameters.paymentRefNum_ic = request.getParameter("paymentRefNum_ic") +birtParameters.noConditionFind = request.getParameter("noConditionFind") +birtParameters.contentType = request.getParameter("contentType") +birtParameters.partyIdFrom = request.getParameter("partyIdFrom") +birtParameters.paymentRefNum_op = request.getParameter("paymentRefNum_op") +birtParameters.amount = request.getParameter("amount") +birtParameters.statusId = request.getParameter("statusId") +birtParameters.paymentGatewayResponseId = request.getParameter("paymentGatewayResponseId") +birtParameters.paymentId_ic = request.getParameter("paymentId_ic") +birtParameters.paymentRefNum = request.getParameter("paymentRefNum") +birtParameters.comments_ic = request.getParameter("comments_ic") +birtParameters.comments_op = request.getParameter("comments_op") +birtParameters.comments = request.getParameter("comments") +request.setAttribute("birtParameters", birtParameters) +return "success" diff --git a/birt/groovyScripts/accounting/TrialBalanceParameters.groovy b/birt/groovyScripts/accounting/TrialBalanceParameters.groovy index a3ce99d3a..0ab94e72a 100644 --- a/birt/groovyScripts/accounting/TrialBalanceParameters.groovy +++ b/birt/groovyScripts/accounting/TrialBalanceParameters.groovy @@ -17,15 +17,15 @@ * under the License. */ -def module = "TrialBalanceParameters.groovy"; +def module = "TrialBalanceParameters.groovy" try { - def birtParameters = [:]; - birtParameters.organizationPartyId = parameters.organizationPartyId; - birtParameters.customTimePeriodId = parameters.customTimePeriodId; - birtParameters.userLoginId = userLogin.userLoginId; - request.setAttribute("birtParameters", birtParameters); + def birtParameters = [:] + birtParameters.organizationPartyId = parameters.organizationPartyId + birtParameters.customTimePeriodId = parameters.customTimePeriodId + birtParameters.userLoginId = userLogin.userLoginId + request.setAttribute("birtParameters", birtParameters) } catch (e) { - Debug.logError(e, module); + Debug.logError(e, module) } return "success"; \ No newline at end of file diff --git a/birt/groovyScripts/facility/InventoryItemReport.groovy b/birt/groovyScripts/facility/InventoryItemReport.groovy index 5fba0c771..cb2152fc3 100644 --- a/birt/groovyScripts/facility/InventoryItemReport.groovy +++ b/birt/groovyScripts/facility/InventoryItemReport.groovy @@ -17,33 +17,33 @@ * under the License. */ - import org.apache.ofbiz.base.util.UtilDateTime; + import org.apache.ofbiz.base.util.UtilDateTime - birtParameters = [:]; + birtParameters = [:] /* - birtParameters.facilityId = request.getParameter("facilityId"); - birtParameters.productId = request.getParameter("productId"); - birtParameters.productTypeId = request.getParameter("productTypeId"); - birtParameters.searchInProductCategoryId = request.getParameter("searchInProductCategoryId"); - birtParameters.contentType = request.getParameter("contentType"); - birtParameters.productSupplierId = request.getParameter("productSupplierId"); - birtParameters.statusId = request.getParameter("statusId"); - birtParameters.productsSoldThruTimestamp = request.getParameter("productsSoldThruTimestamp"); - birtParameters.VIEW_SIZE = request.getParameter("VIEW_SIZE"); - birtParameters.monthsInPastLimit = request.getParameter("monthsInPastLimit"); - birtParameters.fromDateSellThrough = request.getParameter("fromDateSellThrough"); - birtParameters.thruDateSellThrough = request.getParameter("thruDateSellThrough"); + birtParameters.facilityId = request.getParameter("facilityId") + birtParameters.productId = request.getParameter("productId") + birtParameters.productTypeId = request.getParameter("productTypeId") + birtParameters.searchInProductCategoryId = request.getParameter("searchInProductCategoryId") + birtParameters.contentType = request.getParameter("contentType") + birtParameters.productSupplierId = request.getParameter("productSupplierId") + birtParameters.statusId = request.getParameter("statusId") + birtParameters.productsSoldThruTimestamp = request.getParameter("productsSoldThruTimestamp") + birtParameters.VIEW_SIZE = request.getParameter("VIEW_SIZE") + birtParameters.monthsInPastLimit = request.getParameter("monthsInPastLimit") + birtParameters.fromDateSellThrough = request.getParameter("fromDateSellThrough") + birtParameters.thruDateSellThrough = request.getParameter("thruDateSellThrough") */ - int lastIntMonth = Integer.parseInt(request.getParameter("lastIntMonth")); + int lastIntMonth = Integer.parseInt(request.getParameter("lastIntMonth")) if (lastIntMonth == 0 ){ - fromOrderDate = null; + fromOrderDate = null }else{ - fromDateTime = UtilDateTime.getDayStart(UtilDateTime.toTimestamp(UtilDateTime.nowTimestamp()), (lastIntMonth*(-30))); + fromDateTime = UtilDateTime.getDayStart(UtilDateTime.toTimestamp(UtilDateTime.nowTimestamp()), (lastIntMonth*(-30))) fromOrderDate = UtilDateTime.toDateString(fromDateTime,"MMMM dd, yyyy") } - birtParameters.facilityId = request.getParameter("facilityId"); - birtParameters.orderDateDateValue_fld0_op = fromOrderDate.toString(); - request.setAttribute("birtParameters", birtParameters); - return "success"; + birtParameters.facilityId = request.getParameter("facilityId") + birtParameters.orderDateDateValue_fld0_op = fromOrderDate.toString() + request.setAttribute("birtParameters", birtParameters) + return "success" diff --git a/birt/groovyScripts/order/CheckReportBy.groovy b/birt/groovyScripts/order/CheckReportBy.groovy index 5960f03a6..1b1a4b11b 100644 --- a/birt/groovyScripts/order/CheckReportBy.groovy +++ b/birt/groovyScripts/order/CheckReportBy.groovy @@ -17,51 +17,51 @@ * under the License. */ -import org.apache.ofbiz.base.util.UtilValidate; +import org.apache.ofbiz.base.util.UtilValidate -reportBy = parameters.reportBy; -exportType = parameters.exportType; +reportBy = parameters.reportBy +exportType = parameters.exportType if (UtilValidate.isEmpty(parameters.fromDate)) { - request.setAttribute("_ERROR_MESSAGE_", "Please select From Date."); - return "error"; + request.setAttribute("_ERROR_MESSAGE_", "Please select From Date.") + return "error" } if (exportType == "pdf") { if (reportBy == "day") { - return "dayPDF"; + return "dayPDF" } else if (reportBy == "week") { - return "weekPDF"; + return "weekPDF" } else if (reportBy == "month") { - return "monthPDF"; + return "monthPDF" } else { - request.setAttribute("_ERROR_MESSAGE_", "Please select Report By."); - return "error"; + request.setAttribute("_ERROR_MESSAGE_", "Please select Report By.") + return "error" } } if (exportType == "excel") { if (reportBy == "day") { - return "dayExcel"; + return "dayExcel" } else if (reportBy == "week") { - return "weekExcel"; + return "weekExcel" } else if (reportBy == "month") { - return "monthExcel"; + return "monthExcel" } else { - request.setAttribute("_ERROR_MESSAGE_", "Please select Report By."); - return "error"; + request.setAttribute("_ERROR_MESSAGE_", "Please select Report By.") + return "error" } } if (exportType == "html") { if (reportBy == "day") { - return "dayHTML"; + return "dayHTML" } else if (reportBy == "week") { - return "weekHTML"; + return "weekHTML" } else if (reportBy == "month") { - return "monthHTML"; + return "monthHTML" } else { - request.setAttribute("_ERROR_MESSAGE_", "Please select Report By."); - return "error"; + request.setAttribute("_ERROR_MESSAGE_", "Please select Report By.") + return "error" } } diff --git a/birt/groovyScripts/order/NetBeforeOverheadReport.groovy b/birt/groovyScripts/order/NetBeforeOverheadReport.groovy index bba72471a..e77c4edd2 100644 --- a/birt/groovyScripts/order/NetBeforeOverheadReport.groovy +++ b/birt/groovyScripts/order/NetBeforeOverheadReport.groovy @@ -16,41 +16,41 @@ * specific language governing permissions and limitations * under the License. */ -import org.apache.ofbiz.base.util.Debug; -import org.apache.ofbiz.base.util.UtilDatetime; -import java.sql.*; +import org.apache.ofbiz.base.util.Debug +import org.apache.ofbiz.base.util.UtilDatetime +import java.sql.* -productStoreId = parameters.productStoreId; -DateTime = UtilDateTime.nowTimestamp(); -String DateStr = DateTime; -DateDay = DateStr.substring(0,10); -DateMonth = DateStr.substring(5,7); -DateYear = DateStr.substring(0,4); +productStoreId = parameters.productStoreId +DateTime = UtilDateTime.nowTimestamp() +String DateStr = DateTime +DateDay = DateStr.substring(0,10) +DateMonth = DateStr.substring(5,7) +DateYear = DateStr.substring(0,4) if (DateMonth == "01"||DateMonth == "03"||DateMonth == "05"||DateMonth == "07"||DateMonth == "08"||DateMonth == "10"||DateMonth == "12") { - NunberDate = 31; + NunberDate = 31 } else if (DateMonth == "02") { - NunberDate = 29; + NunberDate = 29 } else { - NunberDate = 30; + NunberDate = 30 } -birtParameters = [:]; +birtParameters = [:] try { - birtParameters.productStoreId = productStoreId; - birtParameters.DateDay = DateDay; - birtParameters.DateMonth = DateMonth; - birtParameters.DateYear = DateYear; - birtParameters.NunberDate = NunberDate; + birtParameters.productStoreId = productStoreId + birtParameters.DateDay = DateDay + birtParameters.DateMonth = DateMonth + birtParameters.DateYear = DateYear + birtParameters.NunberDate = NunberDate } catch (e) { - Debug.logError(e, ""); + Debug.logError(e, "") } -request.setAttribute("birtParameters", birtParameters); +request.setAttribute("birtParameters", birtParameters) -return "success"; +return "success" diff --git a/birt/groovyScripts/order/OrderByChannel.groovy b/birt/groovyScripts/order/OrderByChannel.groovy index af459d266..8ab4f1729 100644 --- a/birt/groovyScripts/order/OrderByChannel.groovy +++ b/birt/groovyScripts/order/OrderByChannel.groovy @@ -17,12 +17,12 @@ * under the License. */ -birtParameters = [:]; +birtParameters = [:] if(request.getParameter("SalesChannel")){ - birtParameters.saleChannel = request.getParameter("SalesChannel"); + birtParameters.saleChannel = request.getParameter("SalesChannel") }else{ - birtParameters.saleChannel = "null"; + birtParameters.saleChannel = "null" } -request.setAttribute("birtParameters", birtParameters); +request.setAttribute("birtParameters", birtParameters) -return "success"; +return "success" diff --git a/birt/groovyScripts/order/ProductDemandReport.groovy b/birt/groovyScripts/order/ProductDemandReport.groovy index 7140eb1f3..aa2777332 100644 --- a/birt/groovyScripts/order/ProductDemandReport.groovy +++ b/birt/groovyScripts/order/ProductDemandReport.groovy @@ -16,26 +16,26 @@ * specific language governing permissions and limitations * under the License. */ -import org.apache.ofbiz.base.util.Debug; -import org.apache.ofbiz.base.util.UtilDateTime; -import java.sql.*; -import com.ibm.icu.util.Calendar; +import org.apache.ofbiz.base.util.Debug +import org.apache.ofbiz.base.util.UtilDateTime +import java.sql.* +import com.ibm.icu.util.Calendar -productStoreId = parameters.productStoreId; -Calendar cal = UtilDateTime.toCalendar(UtilDateTime.nowTimestamp()); -int Week = cal.get(Calendar.WEEK_OF_YEAR); -int Year = cal.get(Calendar.YEAR); +productStoreId = parameters.productStoreId +Calendar cal = UtilDateTime.toCalendar(UtilDateTime.nowTimestamp()) +int Week = cal.get(Calendar.WEEK_OF_YEAR) +int Year = cal.get(Calendar.YEAR) -birtParameters = [:]; +birtParameters = [:] try { - birtParameters.productStoreId = productStoreId; - birtParameters.Week = Week; - birtParameters.Year = Year; + birtParameters.productStoreId = productStoreId + birtParameters.Week = Week + birtParameters.Year = Year } catch (e) { - Debug.logError(e, ""); + Debug.logError(e, "") } -request.setAttribute("birtParameters", birtParameters); +request.setAttribute("birtParameters", birtParameters) -return "success"; +return "success" diff --git a/birt/groovyScripts/order/SalesReport.groovy b/birt/groovyScripts/order/SalesReport.groovy index 3f1ecf3b8..27bfe3c08 100644 --- a/birt/groovyScripts/order/SalesReport.groovy +++ b/birt/groovyScripts/order/SalesReport.groovy @@ -16,29 +16,29 @@ * specific language governing permissions and limitations * under the License. */ -import org.apache.ofbiz.base.util.Debug; -import java.sql.*; +import org.apache.ofbiz.base.util.Debug +import java.sql.* -fromDateStr = parameters.fromDate; -cal = Calendar.getInstance(); -cal.setTime(Date.valueOf(fromDateStr)); -int week = cal.get(Calendar.WEEK_OF_YEAR); -int month = cal.get(Calendar.MONTH) + 1; -int year = cal.get(Calendar.YEAR); +fromDateStr = parameters.fromDate +cal = Calendar.getInstance() +cal.setTime(Date.valueOf(fromDateStr)) +int week = cal.get(Calendar.WEEK_OF_YEAR) +int month = cal.get(Calendar.MONTH) + 1 +int year = cal.get(Calendar.YEAR) -birtParameters = [:]; +birtParameters = [:] try { - birtParameters.reportBy = parameters.reportBy; - birtParameters.fromDate = (Date.valueOf(fromDateStr))-2; - birtParameters.thruDate = Date.valueOf(fromDateStr); - birtParameters.lastDate = (Date.valueOf(fromDateStr))-7; - birtParameters.thruWeek = week; - birtParameters.thruMonth = month; - birtParameters.thisYear = year; + birtParameters.reportBy = parameters.reportBy + birtParameters.fromDate = (Date.valueOf(fromDateStr))-2 + birtParameters.thruDate = Date.valueOf(fromDateStr) + birtParameters.lastDate = (Date.valueOf(fromDateStr))-7 + birtParameters.thruWeek = week + birtParameters.thruMonth = month + birtParameters.thisYear = year } catch (e) { - Debug.logError(e, ""); + Debug.logError(e, "") } -request.setAttribute("birtParameters", birtParameters); +request.setAttribute("birtParameters", birtParameters) -return "success"; +return "success" diff --git a/ebay/groovyScripts/EbayAdvancedSearch.groovy b/ebay/groovyScripts/EbayAdvancedSearch.groovy index d404ed4aa..6994acd07 100644 --- a/ebay/groovyScripts/EbayAdvancedSearch.groovy +++ b/ebay/groovyScripts/EbayAdvancedSearch.groovy @@ -17,54 +17,54 @@ * under the License. */ -import org.apache.ofbiz.entity.util.EntityUtil; -import org.apache.ofbiz.product.catalog.CatalogWorker; -import org.apache.ofbiz.product.category.CategoryWorker; -import org.apache.ofbiz.product.store.ProductStoreWorker; +import org.apache.ofbiz.entity.util.EntityUtil +import org.apache.ofbiz.product.catalog.CatalogWorker +import org.apache.ofbiz.product.category.CategoryWorker +import org.apache.ofbiz.product.store.ProductStoreWorker -categoryIds = []; -prodCatalogList = []; -categoryList = []; +categoryIds = [] +prodCatalogList = [] +categoryList = [] if (parameters.productStoreId) { - productStoreId = parameters.productStoreId; + productStoreId = parameters.productStoreId } else { - productStoreId = ProductStoreWorker.getProductStoreId(request); + productStoreId = ProductStoreWorker.getProductStoreId(request) } -ebayConfigList = from("EbayConfig").queryList(); +ebayConfigList = from("EbayConfig").queryList() if (productStoreId) { - productStoreCatalogs = CatalogWorker.getStoreCatalogs(delegator, productStoreId); + productStoreCatalogs = CatalogWorker.getStoreCatalogs(delegator, productStoreId) if (productStoreCatalogs) { productStoreCatalogs.each { productStoreCatalog -> - prodCatalog = from("ProdCatalog").where("prodCatalogId", productStoreCatalog.prodCatalogId).cache(true).queryOne(); - prodCatalogList.add(prodCatalog); + prodCatalog = from("ProdCatalog").where("prodCatalogId", productStoreCatalog.prodCatalogId).cache(true).queryOne() + prodCatalogList.add(prodCatalog) } } } -currentCatalogId = null; +currentCatalogId = null if (parameters.SEARCH_CATALOG_ID) { - currentCatalogId = parameters.SEARCH_CATALOG_ID; + currentCatalogId = parameters.SEARCH_CATALOG_ID } else if (prodCatalogList) { - catalog = EntityUtil.getFirst(prodCatalogList); - currentCatalogId = catalog.prodCatalogId; + catalog = EntityUtil.getFirst(prodCatalogList) + currentCatalogId = catalog.prodCatalogId } -topCategory = CatalogWorker.getCatalogTopEbayCategoryId(request, currentCatalogId); +topCategory = CatalogWorker.getCatalogTopEbayCategoryId(request, currentCatalogId) if (!topCategory) { - topCategory = CatalogWorker.getCatalogTopCategoryId(request, currentCatalogId); + topCategory = CatalogWorker.getCatalogTopCategoryId(request, currentCatalogId) } if (topCategory) { - CategoryWorker.getRelatedCategories(request, "topLevelList", topCategory, true); + CategoryWorker.getRelatedCategories(request, "topLevelList", topCategory, true) if (request.getAttribute("topLevelList")) { - categoryList = request.getAttribute("topLevelList"); + categoryList = request.getAttribute("topLevelList") } else { - categoryIds.add(topCategory); + categoryIds.add(topCategory) } } if (categoryList) { - categoryIds = EntityUtil.getFieldListFromEntityList(categoryList, "productCategoryId", true); + categoryIds = EntityUtil.getFieldListFromEntityList(categoryList, "productCategoryId", true) } -context.ebayConfigList = ebayConfigList; -context.categoryIds = categoryIds; -context.productStoreId = productStoreId; -context.prodCatalogList = prodCatalogList; -context.searchCatalogId = currentCatalogId; +context.ebayConfigList = ebayConfigList +context.categoryIds = categoryIds +context.productStoreId = productStoreId +context.prodCatalogList = prodCatalogList +context.searchCatalogId = currentCatalogId diff --git a/ebay/groovyScripts/EbayOrders.groovy b/ebay/groovyScripts/EbayOrders.groovy index 4738c0950..078635dd5 100644 --- a/ebay/groovyScripts/EbayOrders.groovy +++ b/ebay/groovyScripts/EbayOrders.groovy @@ -18,5 +18,5 @@ */ if (parameters.orderList) { - session.setAttribute("orderList", parameters.orderList); + session.setAttribute("orderList", parameters.orderList) } diff --git a/ebay/groovyScripts/ProductsExportToEbay.groovy b/ebay/groovyScripts/ProductsExportToEbay.groovy index 5aa8c9359..8db413ff7 100644 --- a/ebay/groovyScripts/ProductsExportToEbay.groovy +++ b/ebay/groovyScripts/ProductsExportToEbay.groovy @@ -16,54 +16,54 @@ * specific language governing permissions and limitations * under the License. */ -import org.apache.ofbiz.entity.util.EntityUtil; +import org.apache.ofbiz.entity.util.EntityUtil -webSiteList = []; -webSite = null; +webSiteList = [] +webSite = null if (parameters.productStoreId) { - productStoreId = parameters.productStoreId; - webSiteList = from("WebSite").where("productStoreId", productStoreId).queryList(); + productStoreId = parameters.productStoreId + webSiteList = from("WebSite").where("productStoreId", productStoreId).queryList() if (parameters.webSiteId) { - webSite = from("WebSite").where("webSiteId", parameters.webSiteId).cache(true).queryOne(); - context.selectedWebSiteId = parameters.webSiteId; + webSite = from("WebSite").where("webSiteId", parameters.webSiteId).cache(true).queryOne() + context.selectedWebSiteId = parameters.webSiteId } else if (webSiteList) { - webSite = EntityUtil.getFirst(webSiteList); - context.selectedWebSiteId = webSite.webSiteId; + webSite = EntityUtil.getFirst(webSiteList) + context.selectedWebSiteId = webSite.webSiteId } - context.productStoreId = productStoreId; - context.webSiteList = webSiteList; - countryCode = null; + context.productStoreId = productStoreId + context.webSiteList = webSiteList + countryCode = null if (parameters.country) { - countryCode = parameters.country; + countryCode = parameters.country } else { - countryCode = "US"; + countryCode = "US" } - context.countryCode = countryCode; + context.countryCode = countryCode if (webSite) { - eBayConfig = from("EbayConfig").where("productStoreId", productStoreId).queryOne(); - context.customXml = eBayConfig.customXml; - context.webSiteUrl = webSite.getString("standardContentPrefix"); + eBayConfig = from("EbayConfig").where("productStoreId", productStoreId).queryOne() + context.customXml = eBayConfig.customXml + context.webSiteUrl = webSite.getString("standardContentPrefix") - categoryCode = parameters.categoryCode; - context.categoryCode = categoryCode; - userLogin = parameters.userLogin; + categoryCode = parameters.categoryCode + context.categoryCode = categoryCode + userLogin = parameters.userLogin if (productStoreId) { - results = runService('getEbayCategories', [categoryCode : categoryCode, userLogin : userLogin, productStoreId : productStoreId]); + results = runService('getEbayCategories', [categoryCode : categoryCode, userLogin : userLogin, productStoreId : productStoreId]) } if (results.categories) { - context.categories = results.categories; + context.categories = results.categories } if (categoryCode) { if (!"Y".equals(categoryCode.substring(0, 1)) && !"".equals(categoryCode)) { - context.hideExportOptions = "Y"; + context.hideExportOptions = "Y" } else { - context.hideExportOptions = "N"; + context.hideExportOptions = "N" } } else { - context.hideExportOptions = "N"; + context.hideExportOptions = "N" } } } diff --git a/ebay/groovyScripts/UpdatedEbayOrders.groovy b/ebay/groovyScripts/UpdatedEbayOrders.groovy index 26cde5005..15f8138f6 100644 --- a/ebay/groovyScripts/UpdatedEbayOrders.groovy +++ b/ebay/groovyScripts/UpdatedEbayOrders.groovy @@ -18,6 +18,6 @@ */ if (session.getAttribute("orderList")) { - session.removeAttribute("orderList"); - return "success"; + session.removeAttribute("orderList") + return "success" } diff --git a/ebaystore/groovyScripts/automationPreferences/GetDisputeInfo.groovy b/ebaystore/groovyScripts/automationPreferences/GetDisputeInfo.groovy index 179bbadc1..a74abc574 100644 --- a/ebaystore/groovyScripts/automationPreferences/GetDisputeInfo.groovy +++ b/ebaystore/groovyScripts/automationPreferences/GetDisputeInfo.groovy @@ -17,80 +17,80 @@ * under the License. */ -import com.ebay.soap.eBLBaseComponents.DisputeReasonCodeType; -import com.ebay.soap.eBLBaseComponents.DisputeExplanationCodeType; +import com.ebay.soap.eBLBaseComponents.DisputeReasonCodeType +import com.ebay.soap.eBLBaseComponents.DisputeExplanationCodeType public static String makeSpace(String text){ - String result = ""; + String result = "" for (int i=0; i - contents = from("Content").where("contentId", contentRole.getString("contentId"), "ownerContentId", emailType).queryList(); + contents = from("Content").where("contentId", contentRole.getString("contentId"), "ownerContentId", emailType).queryList() if (contents.size() != 0) { if (emailType.equals(contents.get(0).getString("ownerContentId"))) { - contentId = contents.get(0).getString("contentId"); + contentId = contents.get(0).getString("contentId") } } } } -context.contentId = contentId; +context.contentId = contentId diff --git a/ebaystore/groovyScripts/feedback/FeedbackList.groovy b/ebaystore/groovyScripts/feedback/FeedbackList.groovy index c72cb8726..91b46d8e5 100644 --- a/ebaystore/groovyScripts/feedback/FeedbackList.groovy +++ b/ebaystore/groovyScripts/feedback/FeedbackList.groovy @@ -17,64 +17,64 @@ * under the License. */ -import org.apache.ofbiz.base.util.UtilDateTime; -import org.apache.ofbiz.entity.condition.EntityCondition; -import org.apache.ofbiz.entity.condition.EntityOperator; -import java.sql.Timestamp; +import org.apache.ofbiz.base.util.UtilDateTime +import org.apache.ofbiz.entity.condition.EntityCondition +import org.apache.ofbiz.entity.condition.EntityOperator +import java.sql.Timestamp partyId = null -resultUser = runService('getEbayStoreUser', ["productStoreId": parameters.productStoreId, "userLogin": context.get("userLogin")]); -ownerUser = resultUser.get("userLoginId"); -userLogin = from("UserLogin").where("userLoginId", ownerUser).queryOne(); +resultUser = runService('getEbayStoreUser', ["productStoreId": parameters.productStoreId, "userLogin": context.get("userLogin")]) +ownerUser = resultUser.get("userLoginId") +userLogin = from("UserLogin").where("userLoginId", ownerUser).queryOne() if (userLogin) { - partyId = userLogin.get("partyId"); + partyId = userLogin.get("partyId") } -expr = []; -cond = null; +expr = [] +cond = null -contentId = request.getParameter("contentId"); -fromDate = request.getParameter("fromDate"); -thruDate = request.getParameter("thruDate"); +contentId = request.getParameter("contentId") +fromDate = request.getParameter("fromDate") +thruDate = request.getParameter("thruDate") if (contentId) { - expr.add(EntityCondition.makeCondition("contentId",EntityOperator.EQUALS, contentId)); + expr.add(EntityCondition.makeCondition("contentId",EntityOperator.EQUALS, contentId)) } if (fromDate && thruDate) { - exprSub = []; - condSub = null; - exprSub.add(EntityCondition.makeCondition("createdDate",EntityOperator.GREATER_THAN, UtilDateTime.getDayStart(Timestamp.valueOf(fromDate + " 00:00:00.000")))); - exprSub.add(EntityCondition.makeCondition("createdDate",EntityOperator.LESS_THAN, UtilDateTime.getDayEnd(Timestamp.valueOf(thruDate + " 23:59:59.999")))); - condSub = EntityCondition.makeCondition(exprSub, EntityOperator.AND); - expr.add(condSub); + exprSub = [] + condSub = null + exprSub.add(EntityCondition.makeCondition("createdDate",EntityOperator.GREATER_THAN, UtilDateTime.getDayStart(Timestamp.valueOf(fromDate + " 00:00:00.000")))) + exprSub.add(EntityCondition.makeCondition("createdDate",EntityOperator.LESS_THAN, UtilDateTime.getDayEnd(Timestamp.valueOf(thruDate + " 23:59:59.999")))) + condSub = EntityCondition.makeCondition(exprSub, EntityOperator.AND) + expr.add(condSub) } else if (fromDate && !thruDate) { - expr.add(EntityCondition.makeCondition("createdDate",EntityOperator.GREATER_THAN, UtilDateTime.getDayStart(Timestamp.valueOf(fromDate + " 00:00:00.000")))); + expr.add(EntityCondition.makeCondition("createdDate",EntityOperator.GREATER_THAN, UtilDateTime.getDayStart(Timestamp.valueOf(fromDate + " 00:00:00.000")))) } else if (!fromDate && thruDate) { - expr.add(EntityCondition.makeCondition("createdDate",EntityOperator.LESS_THAN, UtilDateTime.getDayEnd(Timestamp.valueOf(thruDate + " 23:59:59.999")))); + expr.add(EntityCondition.makeCondition("createdDate",EntityOperator.LESS_THAN, UtilDateTime.getDayEnd(Timestamp.valueOf(thruDate + " 23:59:59.999")))) } -contentRoles = from("ContentRole").where("roleTypeId","OWNER", "partyId", partyId).queryList(); -contentIds = []; +contentRoles = from("ContentRole").where("roleTypeId","OWNER", "partyId", partyId).queryList() +contentIds = [] contentRoles.each{ content -> - contentIds.add(content.getString("contentId")); + contentIds.add(content.getString("contentId")) } -expr.add(EntityCondition.makeCondition("contentId", EntityOperator.IN, contentIds)); -contents = from("Content").where(expr).queryList(); +expr.add(EntityCondition.makeCondition("contentId", EntityOperator.IN, contentIds)) +contents = from("Content").where(expr).queryList() -recentFeedbackList = []; -ownerUser = null; -commentator = null; +recentFeedbackList = [] +ownerUser = null +commentator = null contents.each{ content -> - commentatorContents = from("ContentRole").where("contentId",content.contentId, "roleTypeId","COMMENTATOR").queryList(); + commentatorContents = from("ContentRole").where("contentId",content.contentId, "roleTypeId","COMMENTATOR").queryList() if(commentatorContents){ - commentatorPartyId = commentatorContents.get(0).get("partyId"); - commentatorUsers = from("UserLogin").where("partyId", commentatorPartyId).queryList(); + commentatorPartyId = commentatorContents.get(0).get("partyId") + commentatorUsers = from("UserLogin").where("partyId", commentatorPartyId).queryList() if(commentatorUsers){ - commentator = commentatorUsers.get(0).get("userLoginId"); + commentator = commentatorUsers.get(0).get("userLoginId") } } entry = [contentId : content.contentId, dataResourceId : content.dataResourceId, createdDate : content.createdDate, ownerUser : ownerUser, - commentator : commentator]; - recentFeedbackList.add(entry); + commentator : commentator] + recentFeedbackList.add(entry) } -context.recentFeedbackList = recentFeedbackList; +context.recentFeedbackList = recentFeedbackList diff --git a/ebaystore/groovyScripts/store/CheckOrderStatus.groovy b/ebaystore/groovyScripts/store/CheckOrderStatus.groovy index 619730c11..56eec0439 100644 --- a/ebaystore/groovyScripts/store/CheckOrderStatus.groovy +++ b/ebaystore/groovyScripts/store/CheckOrderStatus.groovy @@ -16,14 +16,14 @@ * specific language governing permissions and limitations * under the License. */ -import org.apache.ofbiz.entity.util.EntityUtil; +import org.apache.ofbiz.entity.util.EntityUtil -context.importStatus = "NOT_IMPORT"; -orderHeaders = from("OrderHeader").where("externalId", externalId).queryList(); +context.importStatus = "NOT_IMPORT" +orderHeaders = from("OrderHeader").where("externalId", externalId).queryList() if (orderHeaders.size() > 0) { - orderHeader = EntityUtil.getFirst(orderHeaders); - context.orderId = orderHeader.get("orderId"); + orderHeader = EntityUtil.getFirst(orderHeaders) + context.orderId = orderHeader.get("orderId") if ("ORDER_APPROVED".equals(orderHeader.get("statusId").toString())) { - context.importStatus = "IMPORTED"; + context.importStatus = "IMPORTED" } } diff --git a/ebaystore/groovyScripts/store/OrderListParameters.groovy b/ebaystore/groovyScripts/store/OrderListParameters.groovy index c20fe4789..0b936de48 100644 --- a/ebaystore/groovyScripts/store/OrderListParameters.groovy +++ b/ebaystore/groovyScripts/store/OrderListParameters.groovy @@ -17,9 +17,9 @@ * under the License. */ - session.setAttribute("shippingAddressCtx", shippingAddressCtx); - session.setAttribute("shippingServiceSelectedCtx", shippingServiceSelectedCtx); - session.setAttribute("shippingDetailsCtx", shippingDetailsCtx); - session.setAttribute("checkoutStatusCtx", checkoutStatusCtx); - session.setAttribute("externalTransactionCtx", externalTransactionCtx); - session.setAttribute("orderItemList", orderItemList); + session.setAttribute("shippingAddressCtx", shippingAddressCtx) + session.setAttribute("shippingServiceSelectedCtx", shippingServiceSelectedCtx) + session.setAttribute("shippingDetailsCtx", shippingDetailsCtx) + session.setAttribute("checkoutStatusCtx", checkoutStatusCtx) + session.setAttribute("externalTransactionCtx", externalTransactionCtx) + session.setAttribute("orderItemList", orderItemList) diff --git a/ebaystore/groovyScripts/store/OrderListPrepare.groovy b/ebaystore/groovyScripts/store/OrderListPrepare.groovy index 6b28bbbb0..bf2aaee02 100644 --- a/ebaystore/groovyScripts/store/OrderListPrepare.groovy +++ b/ebaystore/groovyScripts/store/OrderListPrepare.groovy @@ -17,59 +17,59 @@ * under the License. */ -import org.apache.ofbiz.entity.util.EntityUtil; +import org.apache.ofbiz.entity.util.EntityUtil -orderLists = []; +orderLists = [] if (orderList) { for (orderCount = 0; orderCount < orderList.size(); orderCount++) { - orderItem = orderList[orderCount]; - orderId = null; - orderHeaders = from("OrderHeader").where("externalId", orderItem.("externalId")).queryList(); + orderItem = orderList[orderCount] + orderId = null + orderHeaders = from("OrderHeader").where("externalId", orderItem.("externalId")).queryList() if (orderHeaders.size() > 0) { - orderHeader = EntityUtil.getFirst(orderHeaders); - orderId = orderHeader.get("orderId").toString(); + orderHeader = EntityUtil.getFirst(orderHeaders) + orderId = orderHeader.get("orderId").toString() } - checkoutStatus = orderItem.get("checkoutStatusCtx"); - paymentMethodUsed = null; + checkoutStatus = orderItem.get("checkoutStatusCtx") + paymentMethodUsed = null if (checkoutStatus) { - paymentMethodUsed = checkoutStatus.get("paymentMethodUsed"); + paymentMethodUsed = checkoutStatus.get("paymentMethodUsed") } - //orderLists.add(orderMap); - items = orderItem.get("orderItemList"); + //orderLists.add(orderMap) + items = orderItem.get("orderItemList") for (itemCount = 0; itemCount < items.size(); itemCount++) { - item = items[itemCount]; - title = null; + item = items[itemCount] + title = null if (!(item.get("title"))) { - product = from("Product").where("productId", item.get("productId")).cache(true).queryOne(); - title = product.get("internalName"); + product = from("Product").where("productId", item.get("productId")).cache(true).queryOne() + title = product.get("internalName") } - orderMap = [:]; - orderMap.put("orderId", orderId); - orderMap.put("externalId", orderItem.get("externalId")); - orderMap.put("amountPaid", orderItem.get("amountPaid")); - orderMap.put("createdDate", orderItem.get("createdDate")); - orderMap.put("ebayUserIdBuyer", orderItem.get("ebayUserIdBuyer")); - orderMap.put("paymentMethodUsed", paymentMethodUsed); - orderMap.put("itemId", item.get("itemId")); - orderMap.put("quantity", item.get("quantity")); - orderMap.put("productId", item.get("productId")); - orderMap.put("transactionPrice", item.get("transactionPrice")); - orderMap.put("title", title); - orderMap.put("closedDate", item.get("closedDate")); + orderMap = [:] + orderMap.put("orderId", orderId) + orderMap.put("externalId", orderItem.get("externalId")) + orderMap.put("amountPaid", orderItem.get("amountPaid")) + orderMap.put("createdDate", orderItem.get("createdDate")) + orderMap.put("ebayUserIdBuyer", orderItem.get("ebayUserIdBuyer")) + orderMap.put("paymentMethodUsed", paymentMethodUsed) + orderMap.put("itemId", item.get("itemId")) + orderMap.put("quantity", item.get("quantity")) + orderMap.put("productId", item.get("productId")) + orderMap.put("transactionPrice", item.get("transactionPrice")) + orderMap.put("title", title) + orderMap.put("closedDate", item.get("closedDate")) - orderMap.put("shippingAddressCtx", orderItem.get("shippingAddressCtx")); - orderMap.put("shippingServiceSelectedCtx", orderItem.get("shippingServiceSelectedCtx")); - orderMap.put("shippingDetailsCtx", orderItem.get("shippingDetailsCtx")); - orderMap.put("checkoutStatusCtx", orderItem.get("checkoutStatusCtx")); - orderMap.put("externalTransactionCtx", orderItem.get("externalTransactionCtx")); - orderMap.put("orderItemList", orderItem.get("orderItemList")); - orderMap.put("paidTime", orderItem.get("paidTime")); - orderMap.put("shippedTime", orderItem.get("shippedTime")); - orderMap.put("paidTime", orderItem.get("paidTime")); - orderMap.put("emailBuyer", orderItem.get("emailBuyer")); + orderMap.put("shippingAddressCtx", orderItem.get("shippingAddressCtx")) + orderMap.put("shippingServiceSelectedCtx", orderItem.get("shippingServiceSelectedCtx")) + orderMap.put("shippingDetailsCtx", orderItem.get("shippingDetailsCtx")) + orderMap.put("checkoutStatusCtx", orderItem.get("checkoutStatusCtx")) + orderMap.put("externalTransactionCtx", orderItem.get("externalTransactionCtx")) + orderMap.put("orderItemList", orderItem.get("orderItemList")) + orderMap.put("paidTime", orderItem.get("paidTime")) + orderMap.put("shippedTime", orderItem.get("shippedTime")) + orderMap.put("paidTime", orderItem.get("paidTime")) + orderMap.put("emailBuyer", orderItem.get("emailBuyer")) - orderLists.add(orderMap); + orderLists.add(orderMap) } } } -context.orderLists = orderLists; +context.orderLists = orderLists diff --git a/ebaystore/groovyScripts/store/PrepareProductListing.groovy b/ebaystore/groovyScripts/store/PrepareProductListing.groovy index 17562e11a..c043733c6 100644 --- a/ebaystore/groovyScripts/store/PrepareProductListing.groovy +++ b/ebaystore/groovyScripts/store/PrepareProductListing.groovy @@ -17,166 +17,166 @@ * under the License. */ - import org.apache.ofbiz.product.product.ProductContentWrapper; - import org.apache.ofbiz.product.catalog.CatalogWorker; - import org.apache.ofbiz.ebaystore.EbayStoreHelper; - import com.ebay.sdk.ApiContext; - import com.ebay.sdk.call.AddItemCall; - import com.ebay.soap.eBLBaseComponents.BuyerPaymentMethodCodeType; - import com.ebay.soap.eBLBaseComponents.ItemSpecificsEnabledCodeType; - import com.ebay.soap.eBLBaseComponents.SiteCodeType; - import org.apache.ofbiz.ebaystore.EbayEvents; + import org.apache.ofbiz.product.product.ProductContentWrapper + import org.apache.ofbiz.product.catalog.CatalogWorker + import org.apache.ofbiz.ebaystore.EbayStoreHelper + import com.ebay.sdk.ApiContext + import com.ebay.sdk.call.AddItemCall + import com.ebay.soap.eBLBaseComponents.BuyerPaymentMethodCodeType + import com.ebay.soap.eBLBaseComponents.ItemSpecificsEnabledCodeType + import com.ebay.soap.eBLBaseComponents.SiteCodeType + import org.apache.ofbiz.ebaystore.EbayEvents //set the content path prefix - contentPathPrefix = CatalogWorker.getContentPathPrefix(request); - productStoreId = parameters.productStoreId; - search_CategoryId = parameters.search_CategoryId; + contentPathPrefix = CatalogWorker.getContentPathPrefix(request) + productStoreId = parameters.productStoreId + search_CategoryId = parameters.search_CategoryId //Get the addItemList and Prepare details - apiContext = EbayEvents.getApiContext(request); - addItemObj = EbayEvents.getAddItemListingObject(request, apiContext); - contents = []; + apiContext = EbayEvents.getApiContext(request) + addItemObj = EbayEvents.getAddItemListingObject(request, apiContext) + contents = [] if (addItemObj) { - site = (SiteCodeType)apiContext.getSite(); - isExportValid = "false"; - context.site = site; - context.siteCode = apiContext.getSite().value(); - context.siteCode_Ebay_Motors = SiteCodeType.E_BAY_MOTORS.value(); - addItems = addItemObj.itemListing; + site = (SiteCodeType)apiContext.getSite() + isExportValid = "false" + context.site = site + context.siteCode = apiContext.getSite().value() + context.siteCode_Ebay_Motors = SiteCodeType.E_BAY_MOTORS.value() + addItems = addItemObj.itemListing addItems.each{ addItemMap -> - addItem = addItemMap.addItemCall; - content = [:]; - item = addItem.getItem(); - productId = item.getSKU(); - product = from("Product").where("productId", productId).cache(true).queryOne(); - contentWrapper = new ProductContentWrapper(product, request); - content.productContentWrapper = contentWrapper; - content.product = product; - contents.add(content); + addItem = addItemMap.addItemCall + content = [:] + item = addItem.getItem() + productId = item.getSKU() + product = from("Product").where("productId", productId).cache(true).queryOne() + contentWrapper = new ProductContentWrapper(product, request) + content.productContentWrapper = contentWrapper + content.product = product + contents.add(content) if (addItemMap.isVerify == "Y") { - isExportValid = "true"; + isExportValid = "true" } else { - isExportValid = "false"; + isExportValid = "false" } } - context.isExportValid = isExportValid; + context.isExportValid = isExportValid - request.setAttribute("productStoreId", productStoreId); - categories = EbayEvents.getChildCategories(request); - context.categories = categories; - storeCategories = EbayEvents.getStoreChildCategories(request); - context.storeCategories = storeCategories; + request.setAttribute("productStoreId", productStoreId) + categories = EbayEvents.getChildCategories(request) + context.categories = categories + storeCategories = EbayEvents.getStoreChildCategories(request) + context.storeCategories = storeCategories // point product tab id - productId = null; + productId = null if (request.getAttribute("isProductId") || parameters.isProductId) { if (request.getAttribute("isProductId")) { - productId = request.getAttribute("isProductId"); + productId = request.getAttribute("isProductId") } else { - productId = parameters.isProductId; + productId = parameters.isProductId } - context.isProductId = productId; + context.isProductId = productId // get product default price form product price - productPrices = from("ProductPrice").where("productId", productId, "productPricePurposeId", "EBAY").queryList(); + productPrices = from("ProductPrice").where("productId", productId, "productPricePurposeId", "EBAY").queryList() if (productPrices) { - context.productPrices = productPrices; + context.productPrices = productPrices } //Is it reserve on eBayInventory - isReserve = EbayStoreHelper.isReserveInventory(delegator, productStoreId, productId); - context.isReserve = isReserve; + isReserve = EbayStoreHelper.isReserveInventory(delegator, productStoreId, productId) + context.isReserve = isReserve // get category detail - pkCateId = null; - stCate1ID = null; - stCate2ID = null; + pkCateId = null + stCate1ID = null + stCate2ID = null addItems.each{ addItemMap -> - addItem = addItemMap.addItemCall; - item = addItem.getItem(); + addItem = addItemMap.addItemCall + item = addItem.getItem() if (productId == item.getSKU()) { - primaryCate = item.getPrimaryCategory(); - storeFront = item.getStorefront(); + primaryCate = item.getPrimaryCategory() + storeFront = item.getStorefront() if (storeFront) { - stCate1ID = storeFront.getStoreCategoryID(); - stCate2ID = storeFront.getStoreCategory2ID(); - context.storeFront = storeFront; + stCate1ID = storeFront.getStoreCategoryID() + stCate2ID = storeFront.getStoreCategory2ID() + context.storeFront = storeFront } - if (primaryCate) pkCateId = primaryCate.getCategoryID(); + if (primaryCate) pkCateId = primaryCate.getCategoryID() } } - categorySpecificObject = EbayEvents.categorySpecifics(pkCateId, request); + categorySpecificObject = EbayEvents.categorySpecifics(pkCateId, request) if(categorySpecificObject) { - Map categorySpecificMap = categorySpecificObject.get("categorySpecifics"); - int checkNameSpecific = null; - int checkValueSpecific = null; - Iterator specificIterator = categorySpecificMap.keySet().iterator(); + Map categorySpecificMap = categorySpecificObject.get("categorySpecifics") + int checkNameSpecific = null + int checkValueSpecific = null + Iterator specificIterator = categorySpecificMap.keySet().iterator() while(specificIterator.hasNext()){ - String name = specificIterator.next(); - List valueList = categorySpecificMap.get(name); - checkValueSpecific = (valueList) ? 1 : 0 ; + String name = specificIterator.next() + List valueList = categorySpecificMap.get(name) + checkValueSpecific = (valueList) ? 1 : 0 } - checkNameSpecific = categorySpecificMap.size(); - String checkSpecific = ((checkNameSpecific > 0) && (checkValueSpecific == 1)) ? "true" : "false"; - context.checkSpecific = checkSpecific; - context.categorySpecifix = categorySpecificObject; + checkNameSpecific = categorySpecificMap.size() + String checkSpecific = ((checkNameSpecific > 0) && (checkValueSpecific == 1)) ? "true" : "false" + context.checkSpecific = checkSpecific + context.categorySpecifix = categorySpecificObject } - context.stCate1ID = stCate1ID; - context.stCate2ID = stCate2ID; + context.stCate1ID = stCate1ID + context.stCate2ID = stCate2ID if (pkCateId) { - refName = "itemCateFacade_" + pkCateId; + refName = "itemCateFacade_" + pkCateId if (addItemObj.get(refName)) { - cf = addItemObj.get(refName); + cf = addItemObj.get(refName) if (cf) { - listingTypes = []; - listingDurationReferenceMap = cf.getListingDurationReferenceMap(); - listingDurationMap = cf.getListingDurationMap(); + listingTypes = [] + listingDurationReferenceMap = cf.getListingDurationReferenceMap() + listingDurationMap = cf.getListingDurationMap() if (listingDurationReferenceMap && listingDurationMap) { - Iterator keys = listingDurationReferenceMap.keySet().iterator(); + Iterator keys = listingDurationReferenceMap.keySet().iterator() while (keys.hasNext()) { - listingTypeMap = [:]; - String key = keys.next(); - listingTypeMap.type = key; - listingTypeMap.durations = listingDurationMap.get(new Integer(listingDurationReferenceMap.get(key))); - listingTypes.add(listingTypeMap); + listingTypeMap = [:] + String key = keys.next() + listingTypeMap.type = key + listingTypeMap.durations = listingDurationMap.get(new Integer(listingDurationReferenceMap.get(key))) + listingTypes.add(listingTypeMap) } } - context.listingTypes = listingTypes; - buyerPaymentMethods = cf.getPaymentMethods(); + context.listingTypes = listingTypes + buyerPaymentMethods = cf.getPaymentMethods() if (buyerPaymentMethods) { - context.paymentMethods = buyerPaymentMethods; - context.buyerPayMethCode_PAY_PAL = BuyerPaymentMethodCodeType.PAY_PAL; + context.paymentMethods = buyerPaymentMethods + context.buyerPayMethCode_PAY_PAL = BuyerPaymentMethodCodeType.PAY_PAL } // load item specifices and custom if both item attributes and item specifics are supported, we only use item specifics if (cf.getItemSpecificEnabled()) { if (ItemSpecificsEnabledCodeType.ENABLED.equals(cf.getItemSpecificEnabled())) { } else if (cf.AttributesEnabled()) { //show attributes input page - String attributesHtml = attrMaster.renderHtml(cf.getJoinedAttrSets(), null); - context.AttributesHtml = attributesHtml; + String attributesHtml = attrMaster.renderHtml(cf.getJoinedAttrSets(), null) + context.AttributesHtml = attributesHtml } else {//show return policy input page - sf = EbayEvents.getSiteFacade(apiContext,request); - details = sf.getEBayDetailsMap().get(apiContext.getSite()); - returnPolicyEnabled = cf.getRetPolicyEnabled(); + sf = EbayEvents.getSiteFacade(apiContext,request) + details = sf.getEBayDetailsMap().get(apiContext.getSite()) + returnPolicyEnabled = cf.getRetPolicyEnabled() - context.EBayDetails = details; - context.ReturnPolicyEnabled = returnPolicyEnabled; + context.EBayDetails = details + context.ReturnPolicyEnabled = returnPolicyEnabled } } // load shipping services detail - eBayDetailsMap = sf.getEBayDetailsMap(); + eBayDetailsMap = sf.getEBayDetailsMap() if (eBayDetailsMap) { - eBayDetails = eBayDetailsMap.get(site); - shippingServiceDetails = eBayDetails.getShippingServiceDetails(); - shippingServiceDetails = EbayEvents.filterShippingService(shippingServiceDetails); - context.shippingServiceDetails = shippingServiceDetails; - shippingLocationDetails = eBayDetails.getShippingLocationDetails(); - context.shippingLocationDetails = shippingLocationDetails; + eBayDetails = eBayDetailsMap.get(site) + shippingServiceDetails = eBayDetails.getShippingServiceDetails() + shippingServiceDetails = EbayEvents.filterShippingService(shippingServiceDetails) + context.shippingServiceDetails = shippingServiceDetails + shippingLocationDetails = eBayDetails.getShippingLocationDetails() + context.shippingLocationDetails = shippingLocationDetails } // load AdItemTemplates if (cf.getAdItemTemplates()) { - context.adItemTemplates = cf.getAdItemTemplates(); + context.adItemTemplates = cf.getAdItemTemplates() } } } } } } - context.addItemObj = addItemObj; - context.contentList = contents; + context.addItemObj = addItemObj + context.contentList = contents diff --git a/ebaystore/groovyScripts/store/RetrieveStoreOptions.groovy b/ebaystore/groovyScripts/store/RetrieveStoreOptions.groovy index 7de8974e2..57d37cb7a 100644 --- a/ebaystore/groovyScripts/store/RetrieveStoreOptions.groovy +++ b/ebaystore/groovyScripts/store/RetrieveStoreOptions.groovy @@ -17,49 +17,49 @@ * under the License. */ -productStoreId = parameters.productStoreId; -storeThemeId = null; +productStoreId = parameters.productStoreId +storeThemeId = null if (parameters.ebayStore) { - ebayStore = parameters.get("ebayStore"); - storeThemeId = ebayStore.get("storeThemeId"); + ebayStore = parameters.get("ebayStore") + storeThemeId = ebayStore.get("storeThemeId") } if (productStoreId != null) { - flag = null; - storeBasicThemes = null; - resultsBasicThemes = runService('retrieveBasicThemeArray',["productStoreId":productStoreId, "userLogin": userLogin]); + flag = null + storeBasicThemes = null + resultsBasicThemes = runService('retrieveBasicThemeArray',["productStoreId":productStoreId, "userLogin": userLogin]) if(resultsBasicThemes){ - storeBasicThemes = resultsBasicThemes.get("storeThemeList"); + storeBasicThemes = resultsBasicThemes.get("storeThemeList") //check what kind of theme? - context.put("storeThemeOptList",storeBasicThemes); + context.put("storeThemeOptList",storeBasicThemes) if (storeThemeId != null && storeBasicThemes != null) { storeBasicThemes.each { storeTheme -> if (storeThemeId == storeTheme.storeThemeId) { - flag = "Basic"; + flag = "Basic" } } } } - storeAdvanceThemes = null; - storeAdvancedThemeColorOptList = null; - resultsAdvanceThemes = runService('retrieveAdvancedThemeArray',["productStoreId":productStoreId, "userLogin": userLogin]); + storeAdvanceThemes = null + storeAdvancedThemeColorOptList = null + resultsAdvanceThemes = runService('retrieveAdvancedThemeArray',["productStoreId":productStoreId, "userLogin": userLogin]) if (resultsAdvanceThemes) { - storeAdvanceThemes = resultsAdvanceThemes.get("storeThemeList"); - storeAdvancedThemeColorOptList = resultsAdvanceThemes.get("storeAdvancedThemeColorOptList"); - context.put("storeAdvanceThemeOptList",storeAdvanceThemes); - context.put("storeAdvancedThemeColorOptList",storeAdvancedThemeColorOptList); + storeAdvanceThemes = resultsAdvanceThemes.get("storeThemeList") + storeAdvancedThemeColorOptList = resultsAdvanceThemes.get("storeAdvancedThemeColorOptList") + context.put("storeAdvanceThemeOptList",storeAdvanceThemes) + context.put("storeAdvancedThemeColorOptList",storeAdvancedThemeColorOptList) if (storeThemeId != null && storeAdvanceThemes != null) { storeAdvanceThemes.each { storeAdvanceTheme -> if(storeThemeId == storeAdvanceTheme.storeThemeId){ - flag = "Advanced"; + flag = "Advanced" } } } } - resultsFontTheme = runService('retrieveStoreFontTheme',["productStoreId":productStoreId, "userLogin": userLogin]); + resultsFontTheme = runService('retrieveStoreFontTheme',["productStoreId":productStoreId, "userLogin": userLogin]) if (resultsFontTheme) { - storeFontTheme = resultsFontTheme.get("advanceFontTheme"); - context.put("storeFontTheme",storeFontTheme); + storeFontTheme = resultsFontTheme.get("advanceFontTheme") + context.put("storeFontTheme",storeFontTheme) } - context.put("themeType",flag); + context.put("themeType",flag) } diff --git a/ebaystore/groovyScripts/store/SoldAction.groovy b/ebaystore/groovyScripts/store/SoldAction.groovy index 5406482f9..942f37672 100644 --- a/ebaystore/groovyScripts/store/SoldAction.groovy +++ b/ebaystore/groovyScripts/store/SoldAction.groovy @@ -17,24 +17,24 @@ * under the License. */ -import org.apache.ofbiz.base.util.*; +import org.apache.ofbiz.base.util.* -actionList = []; -hasAction = false; +actionList = [] +hasAction = false //Unpaid Item Dispute if (unpaidItemStatus == null && paidTime == null && checkoutStatus != "CheckoutComplete") { - inMap = [:]; - inMap.put("action","openUnpaid"); - inMap.put("actionName","Open Unpaid"); - actionList.add(inMap); - hasAction = true; + inMap = [:] + inMap.put("action","openUnpaid") + inMap.put("actionName","Open Unpaid") + actionList.add(inMap) + hasAction = true } //Second Chance Offer -inMap = [:]; -inMap.put("action","makeSecondChanceOffer"); -inMap.put("actionName","Make Second Chance Offer"); -actionList.add(inMap); -hasAction = true; +inMap = [:] +inMap.put("action","makeSecondChanceOffer") +inMap.put("actionName","Make Second Chance Offer") +actionList.add(inMap) +hasAction = true -context.actionList = actionList; -context.hasAction = hasAction; +context.actionList = actionList +context.hasAction = hasAction diff --git a/ebaystore/groovyScripts/store/StoreAccount.groovy b/ebaystore/groovyScripts/store/StoreAccount.groovy index 40cea5604..30bbda80f 100644 --- a/ebaystore/groovyScripts/store/StoreAccount.groovy +++ b/ebaystore/groovyScripts/store/StoreAccount.groovy @@ -17,25 +17,25 @@ * under the License. */ -import org.apache.ofbiz.base.util.*; +import org.apache.ofbiz.base.util.* -results = []; -ebayAccountList = from("PartyRoleAndPartyDetail").where("roleTypeId", "EBAY_ACCOUNT").queryList(); -productStoreRoles = from("ProductStoreRole").where("roleTypeId", "EBAY_ACCOUNT").queryList(); +results = [] +ebayAccountList = from("PartyRoleAndPartyDetail").where("roleTypeId", "EBAY_ACCOUNT").queryList() +productStoreRoles = from("ProductStoreRole").where("roleTypeId", "EBAY_ACCOUNT").queryList() if (productStoreRoles != null && ebayAccountList != null) { ebayAccountList.each{ebayAccount-> - partyId = ebayAccount.partyId; + partyId = ebayAccount.partyId productStoreRoles.each{productStoreRole -> if(partyId.equals(productStoreRole.partyId)){ - storeMap = [:]; - storeMap.partyId = ebayAccount.partyId; - storeMap.firstName = ebayAccount.firstName; - storeMap.lastName = ebayAccount.lastName; - storeMap.productStoreId = productStoreRole.productStoreId; - results.add(storeMap); + storeMap = [:] + storeMap.partyId = ebayAccount.partyId + storeMap.firstName = ebayAccount.firstName + storeMap.lastName = ebayAccount.lastName + storeMap.productStoreId = productStoreRole.productStoreId + results.add(storeMap) } } } - context.put("stores",results); + context.put("stores",results) } diff --git a/ecommerce/groovyScripts/EcommerceSetup.groovy b/ecommerce/groovyScripts/EcommerceSetup.groovy index 78a2d98ef..7878d80a4 100644 --- a/ecommerce/groovyScripts/EcommerceSetup.groovy +++ b/ecommerce/groovyScripts/EcommerceSetup.groovy @@ -17,25 +17,25 @@ * under the License. */ -import java.util.*; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.product.catalog.CatalogWorker; -import org.apache.ofbiz.product.store.ProductStoreWorker; -import org.apache.ofbiz.common.CommonWorkers; -import org.apache.ofbiz.order.shoppingcart.*; -import org.apache.ofbiz.webapp.control.*; +import java.util.* +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.product.catalog.CatalogWorker +import org.apache.ofbiz.product.store.ProductStoreWorker +import org.apache.ofbiz.common.CommonWorkers +import org.apache.ofbiz.order.shoppingcart.* +import org.apache.ofbiz.webapp.control.* -productStore = ProductStoreWorker.getProductStore(request); +productStore = ProductStoreWorker.getProductStore(request) -prodCatalog = CatalogWorker.getProdCatalog(request); +prodCatalog = CatalogWorker.getProdCatalog(request) if (prodCatalog) { - catalogStyleSheet = prodCatalog.styleSheet; - if (catalogStyleSheet) globalContext.catalogStyleSheet = catalogStyleSheet; - catalogHeaderLogo = prodCatalog.headerLogo; - if (catalogHeaderLogo) globalContext.catalogHeaderLogo = catalogHeaderLogo; + catalogStyleSheet = prodCatalog.styleSheet + if (catalogStyleSheet) globalContext.catalogStyleSheet = catalogStyleSheet + catalogHeaderLogo = prodCatalog.headerLogo + if (catalogHeaderLogo) globalContext.catalogHeaderLogo = catalogHeaderLogo } -globalContext.productStore = productStore; -globalContext.checkLoginUrl = LoginWorker.makeLoginUrl(request, "checkLogin"); -globalContext.catalogQuickaddUse = CatalogWorker.getCatalogQuickaddUse(request); +globalContext.productStore = productStore +globalContext.checkLoginUrl = LoginWorker.makeLoginUrl(request, "checkLogin") +globalContext.catalogQuickaddUse = CatalogWorker.getCatalogQuickaddUse(request) diff --git a/ecommerce/groovyScripts/Login.groovy b/ecommerce/groovyScripts/Login.groovy index 4be040eb1..abe196468 100644 --- a/ecommerce/groovyScripts/Login.groovy +++ b/ecommerce/groovyScripts/Login.groovy @@ -17,18 +17,18 @@ * under the License. */ -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.common.CommonWorkers; -import org.apache.ofbiz.webapp.control.*; +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.common.CommonWorkers +import org.apache.ofbiz.webapp.control.* -context.autoUserLogin = session.getAttribute("autoUserLogin"); -context.autoLogoutUrl = LoginWorker.makeLoginUrl(request, "autoLogout"); +context.autoUserLogin = session.getAttribute("autoUserLogin") +context.autoLogoutUrl = LoginWorker.makeLoginUrl(request, "autoLogout") -previousParams = session.getAttribute("_PREVIOUS_PARAMS_"); +previousParams = session.getAttribute("_PREVIOUS_PARAMS_") if (previousParams) { - previousParams = UtilHttp.stripNamedParamsFromQueryString(previousParams, ["USERNAME", "PASSWORD"]); - previousParams = "?" + previousParams; + previousParams = UtilHttp.stripNamedParamsFromQueryString(previousParams, ["USERNAME", "PASSWORD"]) + previousParams = "?" + previousParams } else { - previousParams = ""; + previousParams = "" } -context.previousParams = previousParams; +context.previousParams = previousParams diff --git a/ecommerce/groovyScripts/Main.groovy b/ecommerce/groovyScripts/Main.groovy index b23461915..5a24d2803 100644 --- a/ecommerce/groovyScripts/Main.groovy +++ b/ecommerce/groovyScripts/Main.groovy @@ -17,13 +17,13 @@ * under the License. */ -import org.apache.ofbiz.product.catalog.*; +import org.apache.ofbiz.product.catalog.* -catalogId = CatalogWorker.getCurrentCatalogId(request); -promoCat = CatalogWorker.getCatalogPromotionsCategoryId(request, catalogId); -request.setAttribute("productCategoryId", promoCat); +catalogId = CatalogWorker.getCurrentCatalogId(request) +promoCat = CatalogWorker.getCatalogPromotionsCategoryId(request, catalogId) +request.setAttribute("productCategoryId", promoCat) -/* NOTE DEJ20070220 woah, this is doing weird stuff like always showing the last viewed category when going to the main page; +/* NOTE DEJ20070220 woah, this is doing weird stuff like always showing the last viewed category when going to the main page * It appears this was done for to make it go back to the desired category after logging in, but this is NOT the place to do that, * and IMO this is an unacceptable side-effect. * @@ -33,10 +33,10 @@ request.setAttribute("productCategoryId", promoCat); * * NOTE JLR 20070221 this should be done using the same method than in add to cart. I will do it like that and remove all this after. * -productCategoryId = session.getAttribute("productCategoryId"); +productCategoryId = session.getAttribute("productCategoryId") if (!productCategoryId) { - request.setAttribute("productCategoryId", promoCat); + request.setAttribute("productCategoryId", promoCat) } else { - request.setAttribute("productCategoryId", productCategoryId); + request.setAttribute("productCategoryId", productCategoryId) } */ diff --git a/ecommerce/groovyScripts/ProcessPaymentSettings.groovy b/ecommerce/groovyScripts/ProcessPaymentSettings.groovy index 059c68a0c..c0b1be3ce 100644 --- a/ecommerce/groovyScripts/ProcessPaymentSettings.groovy +++ b/ecommerce/groovyScripts/ProcessPaymentSettings.groovy @@ -17,68 +17,68 @@ * under the License. */ -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.ArrayList +import java.util.HashMap +import java.util.List +import java.util.Map -import org.apache.ofbiz.base.util.UtilHttp; -import org.apache.ofbiz.base.util.UtilMisc; -import org.apache.ofbiz.entity.Delegator; -import org.apache.ofbiz.entity.GenericValue; -import org.apache.ofbiz.order.shoppingcart.CheckOutHelper; -import org.apache.ofbiz.order.shoppingcart.ShoppingCart; -import org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents; -import org.apache.ofbiz.service.LocalDispatcher; -import org.apache.ofbiz.service.ModelService; -import org.apache.ofbiz.service.ServiceUtil; +import org.apache.ofbiz.base.util.UtilHttp +import org.apache.ofbiz.base.util.UtilMisc +import org.apache.ofbiz.entity.Delegator +import org.apache.ofbiz.entity.GenericValue +import org.apache.ofbiz.order.shoppingcart.CheckOutHelper +import org.apache.ofbiz.order.shoppingcart.ShoppingCart +import org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents +import org.apache.ofbiz.service.LocalDispatcher +import org.apache.ofbiz.service.ModelService +import org.apache.ofbiz.service.ServiceUtil -cart = ShoppingCartEvents.getCartObject(request); -dispatcher = request.getAttribute("dispatcher"); -delegator = request.getAttribute("delegator"); -checkOutHelper = new CheckOutHelper(dispatcher, delegator, cart); -paramMap = UtilHttp.getParameterMap(request); +cart = ShoppingCartEvents.getCartObject(request) +dispatcher = request.getAttribute("dispatcher") +delegator = request.getAttribute("delegator") +checkOutHelper = new CheckOutHelper(dispatcher, delegator, cart) +paramMap = UtilHttp.getParameterMap(request) -paymentMethodTypeId = paramMap.paymentMethodTypeId; -errorMessages = []; -errorMaps = [:]; +paymentMethodTypeId = paramMap.paymentMethodTypeId +errorMessages = [] +errorMaps = [:] if (paymentMethodTypeId) { - paymentMethodId = request.getAttribute("paymentMethodId"); + paymentMethodId = request.getAttribute("paymentMethodId") if ("EXT_OFFLINE".equals(paymentMethodTypeId)) { - paymentMethodId = "EXT_OFFLINE"; + paymentMethodId = "EXT_OFFLINE" } - singleUsePayment = paramMap.singleUsePayment; - appendPayment = paramMap.appendPayment; - isSingleUsePayment = "Y".equalsIgnoreCase(singleUsePayment) ?: false; - doAppendPayment = "Y".equalsIgnoreCase(appendPayment) ?: false; - callResult = checkOutHelper.finalizeOrderEntryPayment(paymentMethodId, null, isSingleUsePayment, doAppendPayment); - cpi = cart.getPaymentInfo(paymentMethodId, null, null, null, true); - cpi.securityCode = paramMap.cardSecurityCode; - ServiceUtil.addErrors(errorMessages, errorMaps, callResult); + singleUsePayment = paramMap.singleUsePayment + appendPayment = paramMap.appendPayment + isSingleUsePayment = "Y".equalsIgnoreCase(singleUsePayment) ?: false + doAppendPayment = "Y".equalsIgnoreCase(appendPayment) ?: false + callResult = checkOutHelper.finalizeOrderEntryPayment(paymentMethodId, null, isSingleUsePayment, doAppendPayment) + cpi = cart.getPaymentInfo(paymentMethodId, null, null, null, true) + cpi.securityCode = paramMap.cardSecurityCode + ServiceUtil.addErrors(errorMessages, errorMaps, callResult) } if (!errorMessages && !errorMaps) { - selPaymentMethods = null; - addGiftCard = paramMap.addGiftCard; + selPaymentMethods = null + addGiftCard = paramMap.addGiftCard if ("Y".equalsIgnoreCase(addGiftCard)) { - selPaymentMethods = [paymentMethodTypeId : null]; - callResult = checkOutHelper.checkGiftCard(paramMap, selPaymentMethods); - ServiceUtil.addErrors(errorMessages, errorMaps, callResult); + selPaymentMethods = [paymentMethodTypeId : null] + callResult = checkOutHelper.checkGiftCard(paramMap, selPaymentMethods) + ServiceUtil.addErrors(errorMessages, errorMaps, callResult) if (!errorMessages && !errorMaps) { - gcPaymentMethodId = callResult.paymentMethodId; - giftCardAmount = callResult.amount; - gcCallRes = checkOutHelper.finalizeOrderEntryPayment(gcPaymentMethodId, giftCardAmount, true, true); - ServiceUtil.addErrors(errorMessages, errorMaps, gcCallRes); + gcPaymentMethodId = callResult.paymentMethodId + giftCardAmount = callResult.amount + gcCallRes = checkOutHelper.finalizeOrderEntryPayment(gcPaymentMethodId, giftCardAmount, true, true) + ServiceUtil.addErrors(errorMessages, errorMaps, gcCallRes) } } } //See whether we need to return an error or not -callResult = ServiceUtil.returnSuccess(); +callResult = ServiceUtil.returnSuccess() if (errorMessages || errorMaps) { - request.setAttribute(ModelService.ERROR_MESSAGE_LIST, errorMessages); - request.setAttribute(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR); - return "error"; + request.setAttribute(ModelService.ERROR_MESSAGE_LIST, errorMessages) + request.setAttribute(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR) + return "error" } -return "success"; +return "success" diff --git a/ecommerce/groovyScripts/cart/ShowCart.groovy b/ecommerce/groovyScripts/cart/ShowCart.groovy index 1386af8eb..b999215df 100644 --- a/ecommerce/groovyScripts/cart/ShowCart.groovy +++ b/ecommerce/groovyScripts/cart/ShowCart.groovy @@ -17,62 +17,62 @@ * under the License. */ -import org.apache.ofbiz.base.util.UtilMisc; -import org.apache.ofbiz.product.catalog.CatalogWorker; -import org.apache.ofbiz.order.shoppingcart.product.ProductDisplayWorker; -import org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents; -import org.apache.ofbiz.product.store.ProductStoreWorker; -import org.apache.ofbiz.entity.condition.*; -import org.apache.ofbiz.entity.util.EntityUtil; +import org.apache.ofbiz.base.util.UtilMisc +import org.apache.ofbiz.product.catalog.CatalogWorker +import org.apache.ofbiz.order.shoppingcart.product.ProductDisplayWorker +import org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents +import org.apache.ofbiz.product.store.ProductStoreWorker +import org.apache.ofbiz.entity.condition.* +import org.apache.ofbiz.entity.util.EntityUtil // Get the Cart and Prepare Size -shoppingCart = ShoppingCartEvents.getCartObject(request); -context.shoppingCartSize = shoppingCart?.size() ?: 0; -context.shoppingCart = shoppingCart; +shoppingCart = ShoppingCartEvents.getCartObject(request) +context.shoppingCartSize = shoppingCart?.size() ?: 0 +context.shoppingCart = shoppingCart -context.productStore = ProductStoreWorker.getProductStore(request); +context.productStore = ProductStoreWorker.getProductStore(request) if (parameters.add_product_id) { // check if a parameter is passed - add_product_id = parameters.add_product_id; - product = from("Product").where("productId", add_product_id).cache(true).queryOne(); - context.product = product; + add_product_id = parameters.add_product_id + product = from("Product").where("productId", add_product_id).cache(true).queryOne() + context.product = product } // get all the possible gift wrap options -allgiftWraps = from("ProductFeature").where("productFeatureTypeId", "GIFT_WRAP").orderBy("defaultSequenceNum").queryList(); -context.allgiftWraps = allgiftWraps; +allgiftWraps = from("ProductFeature").where("productFeatureTypeId", "GIFT_WRAP").orderBy("defaultSequenceNum").queryList() +context.allgiftWraps = allgiftWraps // get the shopping lists for the logged in user if (userLogin) { allShoppingLists = from("ShoppingList").where(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, userLogin.partyId), - EntityCondition.makeCondition("listName", EntityOperator.NOT_EQUAL, "auto-save")).orderBy("listName").queryList(); - context.shoppingLists = allShoppingLists; + EntityCondition.makeCondition("listName", EntityOperator.NOT_EQUAL, "auto-save")).orderBy("listName").queryList() + context.shoppingLists = allShoppingLists } // Get Cart Associated Products Data -associatedProducts = ProductDisplayWorker.getRandomCartProductAssoc(request, true); -context.associatedProducts = associatedProducts; +associatedProducts = ProductDisplayWorker.getRandomCartProductAssoc(request, true) +context.associatedProducts = associatedProducts -context.contentPathPrefix = CatalogWorker.getContentPathPrefix(request); +context.contentPathPrefix = CatalogWorker.getContentPathPrefix(request) //Get Cart Items -shoppingCartItems = shoppingCart.items(); +shoppingCartItems = shoppingCart.items() if(shoppingCartItems) { shoppingCartItems.each { shoppingCartItem -> if (shoppingCartItem.getProductId()) { if (shoppingCartItem.getParentProductId()) { - parentProductId = shoppingCartItem.getParentProductId(); + parentProductId = shoppingCartItem.getParentProductId() } else { - parentProductId = shoppingCartItem.getProductId(); + parentProductId = shoppingCartItem.getProductId() } - context.parentProductId = parentProductId; + context.parentProductId = parentProductId } - productCategoryMembers = from("ProductCategoryMember").where("productId", parentProductId).queryList(); + productCategoryMembers = from("ProductCategoryMember").where("productId", parentProductId).queryList() if (productCategoryMembers) { - productCategoryMember = EntityUtil.getFirst(productCategoryMembers); - productCategory = productCategoryMember.getRelatedOne("ProductCategory", false); - context.productCategory = productCategory; + productCategoryMember = EntityUtil.getFirst(productCategoryMembers) + productCategory = productCategoryMember.getRelatedOne("ProductCategory", false) + context.productCategory = productCategory } } } diff --git a/ecommerce/groovyScripts/cart/ShowPromoText.groovy b/ecommerce/groovyScripts/cart/ShowPromoText.groovy index 56b845b0d..5bd32ab81 100644 --- a/ecommerce/groovyScripts/cart/ShowPromoText.groovy +++ b/ecommerce/groovyScripts/cart/ShowPromoText.groovy @@ -17,42 +17,42 @@ * under the License. */ -import org.apache.ofbiz.base.util.UtilMisc; -import org.apache.ofbiz.order.shoppingcart.product.ProductPromoWorker; +import org.apache.ofbiz.base.util.UtilMisc +import org.apache.ofbiz.order.shoppingcart.product.ProductPromoWorker -promoShowLimit = 3; +promoShowLimit = 3 //Get Promo Text Data -productPromosAll = ProductPromoWorker.getStoreProductPromos(delegator, dispatcher, request); +productPromosAll = ProductPromoWorker.getStoreProductPromos(delegator, dispatcher, request) //Make sure that at least one promo has non-empty promoText -showPromoText = false; -promoToShow = 0; -productPromosAllShowable = new ArrayList(productPromosAll.size()); +showPromoText = false +promoToShow = 0 +productPromosAllShowable = new ArrayList(productPromosAll.size()) productPromosAll.each { productPromo -> - promoText = productPromo.promoText; + promoText = productPromo.promoText if (promoText && !"N".equals(productPromo.showToCustomer)) { - showPromoText = true; - promoToShow++; - productPromosAllShowable.add(productPromo); + showPromoText = true + promoToShow++ + productPromosAllShowable.add(productPromo) } } // now slim it down to promoShowLimit -productPromosRandomTemp = new ArrayList(productPromosAllShowable); -productPromos = null; +productPromosRandomTemp = new ArrayList(productPromosAllShowable) +productPromos = null if (productPromosRandomTemp.size() > promoShowLimit) { - productPromos = new ArrayList(promoShowLimit); + productPromos = new ArrayList(promoShowLimit) for (i = 0; i < promoShowLimit; i++) { - randomIndex = Math.round(java.lang.Math.random() * (productPromosRandomTemp.size() - 1)) as int; - productPromos.add(productPromosRandomTemp.remove(randomIndex)); + randomIndex = Math.round(java.lang.Math.random() * (productPromosRandomTemp.size() - 1)) as int + productPromos.add(productPromosRandomTemp.remove(randomIndex)) } } else { - productPromos = productPromosRandomTemp; + productPromos = productPromosRandomTemp } -context.promoShowLimit = promoShowLimit; -context.productPromosAllShowable = productPromosAllShowable; -context.productPromos = productPromos; -context.showPromoText = showPromoText; -context.promoToShow = promoToShow; +context.promoShowLimit = promoShowLimit +context.productPromosAllShowable = productPromosAllShowable +context.productPromos = productPromos +context.showPromoText = showPromoText +context.promoToShow = promoToShow diff --git a/ecommerce/groovyScripts/catalog/AjaxBreadcrumbs.groovy b/ecommerce/groovyScripts/catalog/AjaxBreadcrumbs.groovy index d85b3e671..a0463ec57 100644 --- a/ecommerce/groovyScripts/catalog/AjaxBreadcrumbs.groovy +++ b/ecommerce/groovyScripts/catalog/AjaxBreadcrumbs.groovy @@ -16,34 +16,34 @@ * specific language governing permissions and limitations * under the License. */ -import org.apache.ofbiz.product.product.ProductContentWrapper; -import org.apache.ofbiz.product.category.*; -import org.apache.ofbiz.base.util.UtilValidate; +import org.apache.ofbiz.product.product.ProductContentWrapper +import org.apache.ofbiz.product.category.* +import org.apache.ofbiz.base.util.UtilValidate -parentCategoryStr = parameters.parentCategoryStr; +parentCategoryStr = parameters.parentCategoryStr if(!UtilValidate.isEmpty(parentCategoryStr)) { - pathList = parentCategoryStr.split('/'); - cateList = []; - pathTemp = ''; + pathList = parentCategoryStr.split('/') + cateList = [] + pathTemp = '' for(path in pathList) { - cateMap = [:]; - category = from("ProductCategory").where("productCategoryId", path).queryOne(); - categoryContentWrapper = new CategoryContentWrapper(category, request); + cateMap = [:] + category = from("ProductCategory").where("productCategoryId", path).queryOne() + categoryContentWrapper = new CategoryContentWrapper(category, request) - pathTemp = pathTemp + path; - cateMap.title = categoryContentWrapper.get("DESCRIPTION", "html"); - cateMap.productCategoryId = category.productCategoryId; - cateMap.parentCategory = pathTemp; + pathTemp = pathTemp + path + cateMap.title = categoryContentWrapper.get("DESCRIPTION", "html") + cateMap.productCategoryId = category.productCategoryId + cateMap.parentCategory = pathTemp - cateList.add(cateMap); + cateList.add(cateMap) - pathTemp = pathTemp + '/'; + pathTemp = pathTemp + '/' } - context.productCategoryTrail = cateList; + context.productCategoryTrail = cateList } -currentCategory = from("ProductCategory").where("productCategoryId", productCategoryId).queryOne(); -currentCategoryContentWrapper = new CategoryContentWrapper(currentCategory, request); -context.currentCategoryName = currentCategoryContentWrapper.get("CATEGORY_NAME", "html"); -context.currentCategoryDescription = currentCategoryContentWrapper.get("DESCRIPTION", "html"); -context.currentCategoryId = productCategoryId; +currentCategory = from("ProductCategory").where("productCategoryId", productCategoryId).queryOne() +currentCategoryContentWrapper = new CategoryContentWrapper(currentCategory, request) +context.currentCategoryName = currentCategoryContentWrapper.get("CATEGORY_NAME", "html") +context.currentCategoryDescription = currentCategoryContentWrapper.get("DESCRIPTION", "html") +context.currentCategoryId = productCategoryId diff --git a/ecommerce/groovyScripts/catalog/BestSellingCategory.groovy b/ecommerce/groovyScripts/catalog/BestSellingCategory.groovy index aea5d81a9..423a7233a 100644 --- a/ecommerce/groovyScripts/catalog/BestSellingCategory.groovy +++ b/ecommerce/groovyScripts/catalog/BestSellingCategory.groovy @@ -17,26 +17,26 @@ * under the License. */ -import org.apache.ofbiz.base.util.UtilValidate; -import org.apache.ofbiz.base.util.UtilMisc; -import org.apache.ofbiz.product.catalog.*; -import org.apache.ofbiz.product.category.*; +import org.apache.ofbiz.base.util.UtilValidate +import org.apache.ofbiz.base.util.UtilMisc +import org.apache.ofbiz.product.catalog.* +import org.apache.ofbiz.product.category.* -catalogId = CatalogWorker.getCurrentCatalogId(request); -bestSellerCates = []; +catalogId = CatalogWorker.getCurrentCatalogId(request) +bestSellerCates = [] if (UtilValidate.isNotEmpty(catalogId)) { - prodCatalogCategoryList = CatalogWorker.getProdCatalogCategories(request, catalogId, "PCCT_BEST_SELL"); + prodCatalogCategoryList = CatalogWorker.getProdCatalogCategories(request, catalogId, "PCCT_BEST_SELL") if (prodCatalogCategoryList.size() > 0) { for (int i = 0; i < prodCatalogCategoryList.size(); i++) { - prodCatalogCategory = prodCatalogCategoryList[i]; - productCategoryId = prodCatalogCategory.getString("productCategoryId"); - childCategoryList = CategoryWorker.getRelatedCategoriesRet(request, "childCategoryList", productCategoryId, true); + prodCatalogCategory = prodCatalogCategoryList[i] + productCategoryId = prodCatalogCategory.getString("productCategoryId") + childCategoryList = CategoryWorker.getRelatedCategoriesRet(request, "childCategoryList", productCategoryId, true) if (childCategoryList.size() > 0) { - bestSellerCates.add(childCategoryList); + bestSellerCates.add(childCategoryList) } } } } -context.productCategoryList = bestSellerCates; +context.productCategoryList = bestSellerCates diff --git a/ecommerce/groovyScripts/catalog/LayeredNavigation.groovy b/ecommerce/groovyScripts/catalog/LayeredNavigation.groovy index 9bf80fc42..d2776640a 100644 --- a/ecommerce/groovyScripts/catalog/LayeredNavigation.groovy +++ b/ecommerce/groovyScripts/catalog/LayeredNavigation.groovy @@ -17,122 +17,122 @@ * under the License. */ -import org.apache.ofbiz.base.util.UtilHttp; -import org.apache.ofbiz.entity.util.EntityUtil; -import org.apache.ofbiz.product.catalog.CatalogWorker; -import org.apache.ofbiz.product.category.CategoryContentWrapper; -import org.apache.ofbiz.product.category.CategoryWorker; -import org.apache.ofbiz.product.product.ProductSearch; -import org.apache.ofbiz.product.product.ProductSearchSession; +import org.apache.ofbiz.base.util.UtilHttp +import org.apache.ofbiz.entity.util.EntityUtil +import org.apache.ofbiz.product.catalog.CatalogWorker +import org.apache.ofbiz.product.category.CategoryContentWrapper +import org.apache.ofbiz.product.category.CategoryWorker +import org.apache.ofbiz.product.product.ProductSearch +import org.apache.ofbiz.product.product.ProductSearchSession -searchCategoryId = parameters.searchCategoryId; +searchCategoryId = parameters.searchCategoryId if (!searchCategoryId) { - searchCategoryId = context.productCategoryId; + searchCategoryId = context.productCategoryId } if (searchCategoryId) { - currentSearchCategory = from("ProductCategory").where("productCategoryId", searchCategoryId).queryOne(); - CategoryWorker.getRelatedCategories(request, "subCategoryList", searchCategoryId, false); - subCategoryList = request.getAttribute("subCategoryList"); - CategoryContentWrapper categoryContentWrapper = new CategoryContentWrapper(currentSearchCategory, request); - context.currentSearchCategory = currentSearchCategory; - context.categoryContentWrapper = categoryContentWrapper; + currentSearchCategory = from("ProductCategory").where("productCategoryId", searchCategoryId).queryOne() + CategoryWorker.getRelatedCategories(request, "subCategoryList", searchCategoryId, false) + subCategoryList = request.getAttribute("subCategoryList") + CategoryContentWrapper categoryContentWrapper = new CategoryContentWrapper(currentSearchCategory, request) + context.currentSearchCategory = currentSearchCategory + context.categoryContentWrapper = categoryContentWrapper } -productCategoryId = context.productCategoryId; +productCategoryId = context.productCategoryId if (productCategoryId) { - context.productCategory = from("ProductCategory").where("productCategoryId", productCategoryId).queryOne(); - parameters.SEARCH_CATEGORY_ID = productCategoryId; + context.productCategory = from("ProductCategory").where("productCategoryId", productCategoryId).queryOne() + parameters.SEARCH_CATEGORY_ID = productCategoryId } if (!parameters.clearSearch || !"N".equals(parameters.clearSearch)) { - ProductSearchSession.searchClear(session); + ProductSearchSession.searchClear(session) } -ProductSearchSession.processSearchParameters(parameters, request); -prodCatalogId = CatalogWorker.getCurrentCatalogId(request); -result = ProductSearchSession.getProductSearchResult(request, delegator, prodCatalogId); +ProductSearchSession.processSearchParameters(parameters, request) +prodCatalogId = CatalogWorker.getCurrentCatalogId(request) +result = ProductSearchSession.getProductSearchResult(request, delegator, prodCatalogId) -context.index = ProductSearchSession.getCategoryCostraintIndex(session); +context.index = ProductSearchSession.getCategoryCostraintIndex(session) -searchConstraintList = ProductSearchSession.getProductSearchOptions(session).getConstraintList(); +searchConstraintList = ProductSearchSession.getProductSearchOptions(session).getConstraintList() if (searchCategoryId) { - productCategoryRollups = from("ProductCategoryRollup").where("productCategoryId", searchCategoryId).filterByDate().queryList(); - previousCategoryId = null; + productCategoryRollups = from("ProductCategoryRollup").where("productCategoryId", searchCategoryId).filterByDate().queryList() + previousCategoryId = null if (productCategoryRollups) { for (categoryRollup in productCategoryRollups) { - categoryConstraint = new ProductSearch.CategoryConstraint(categoryRollup.parentProductCategoryId, true, false); + categoryConstraint = new ProductSearch.CategoryConstraint(categoryRollup.parentProductCategoryId, true, false) if (searchConstraintList.contains(categoryConstraint)) { - previousCategoryId = categoryRollup.parentProductCategoryId; - context.previousCategoryId = previousCategoryId; + previousCategoryId = categoryRollup.parentProductCategoryId + context.previousCategoryId = previousCategoryId } } } } -context.showSubCats = true; +context.showSubCats = true if (subCategoryList) { - thisSubCategoryList = []; + thisSubCategoryList = [] subCategoryList.each { subCategory -> - categoryCount = ProductSearchSession.getCountForProductCategory(subCategory.productCategoryId, session, delegator); + categoryCount = ProductSearchSession.getCountForProductCategory(subCategory.productCategoryId, session, delegator) if (categoryCount > 0) { - subCategoryContentWrapper = new CategoryContentWrapper(subCategory, request); - thisSubCategoryList.add([productCategoryId: subCategory.productCategoryId, categoryName: subCategory.categoryName, count: categoryCount, categoryContentWrapper: subCategoryContentWrapper]); + subCategoryContentWrapper = new CategoryContentWrapper(subCategory, request) + thisSubCategoryList.add([productCategoryId: subCategory.productCategoryId, categoryName: subCategory.categoryName, count: categoryCount, categoryContentWrapper: subCategoryContentWrapper]) } } if (thisSubCategoryList) { - context.subCategoryList = thisSubCategoryList; + context.subCategoryList = thisSubCategoryList } else { - context.showSubCats = false; + context.showSubCats = false } } else { - context.showSubCats = false; + context.showSubCats = false } -context.showColors = true; -colors = ProductSearchSession.listCountByFeatureForType("COLOR", session, delegator); -colorFeatureType = from("ProductFeatureType").where("productFeatureTypeId", "COLOR").queryOne(); +context.showColors = true +colors = ProductSearchSession.listCountByFeatureForType("COLOR", session, delegator) +colorFeatureType = from("ProductFeatureType").where("productFeatureTypeId", "COLOR").queryOne() if (colors) { colors.each { color -> - featureConstraint = new ProductSearch.FeatureConstraint(color.productFeatureId, false); + featureConstraint = new ProductSearch.FeatureConstraint(color.productFeatureId, false) if (searchConstraintList.contains(featureConstraint)) { - context.showColors=false; + context.showColors=false } } } else { - context.showColors = false; + context.showColors = false } if (context.showColors) { - context.colors = colors; - context.colorFeatureType = colorFeatureType; + context.colors = colors + context.colorFeatureType = colorFeatureType } -availablePriceRangeList = [[low: "0", high: "10"], [low: "10", high: "20"], [low: "20", high: "30"], [low: "30", high: "40"], [low: "40", high: "50"], [low: "50", high: "60"], [low: "60", high: "70"], [low: "70", high: "80"], [low: "80", high: "90"], [low: "90", high: "100"]]; -priceRangeList = []; -context.showPriceRange = true; +availablePriceRangeList = [[low: "0", high: "10"], [low: "10", high: "20"], [low: "20", high: "30"], [low: "30", high: "40"], [low: "40", high: "50"], [low: "50", high: "60"], [low: "60", high: "70"], [low: "70", high: "80"], [low: "80", high: "90"], [low: "90", high: "100"]] +priceRangeList = [] +context.showPriceRange = true availablePriceRangeList.each { priceRange -> - priceRangeConstraint = new ProductSearch.ListPriceRangeConstraint(new BigDecimal(priceRange.low), new BigDecimal(priceRange.high), UtilHttp.getCurrencyUom(request)); + priceRangeConstraint = new ProductSearch.ListPriceRangeConstraint(new BigDecimal(priceRange.low), new BigDecimal(priceRange.high), UtilHttp.getCurrencyUom(request)) if (searchConstraintList.contains(priceRangeConstraint)) { - context.showPriceRange = false; + context.showPriceRange = false } else { - priceRangeCount = ProductSearchSession.getCountForListPriceRange(new BigDecimal(priceRange.low), new BigDecimal(priceRange.high), session, delegator); + priceRangeCount = ProductSearchSession.getCountForListPriceRange(new BigDecimal(priceRange.low), new BigDecimal(priceRange.high), session, delegator) if (priceRangeCount != 0) { - priceRangeList.add([low: priceRange.low, high: priceRange.high, count: priceRangeCount]); + priceRangeList.add([low: priceRange.low, high: priceRange.high, count: priceRangeCount]) } } } if (!priceRangeList) { - context.showPriceRange = false; + context.showPriceRange = false } if (context.showPriceRange) { - context.priceRangeList = priceRangeList; + context.priceRangeList = priceRangeList } -context.productIds = result.productIds; -context.viewIndex = result.viewIndex; -context.viewSize = result.viewSize; -context.listSize = result.listSize; -context.lowIndex = result.lowIndex; -context.highIndex = result.highIndex; -context.paging = result.paging; -context.previousViewSize = result.previousViewSize; -context.searchConstraintStrings = result.searchConstraintStrings; +context.productIds = result.productIds +context.viewIndex = result.viewIndex +context.viewSize = result.viewSize +context.listSize = result.listSize +context.lowIndex = result.lowIndex +context.highIndex = result.highIndex +context.paging = result.paging +context.previousViewSize = result.previousViewSize +context.searchConstraintStrings = result.searchConstraintStrings diff --git a/ecommerce/groovyScripts/catalog/MiniProductSummary.groovy b/ecommerce/groovyScripts/catalog/MiniProductSummary.groovy index 491f348ca..193ba2cc4 100644 --- a/ecommerce/groovyScripts/catalog/MiniProductSummary.groovy +++ b/ecommerce/groovyScripts/catalog/MiniProductSummary.groovy @@ -17,29 +17,29 @@ * under the License. */ -import java.math.BigDecimal; -import java.util.Map; +import java.math.BigDecimal +import java.util.Map -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.service.*; -import org.apache.ofbiz.product.product.ProductContentWrapper; -import org.apache.ofbiz.product.config.ProductConfigWorker; -import org.apache.ofbiz.product.catalog.*; -import org.apache.ofbiz.product.store.*; -import org.apache.ofbiz.order.shoppingcart.*; -import org.apache.ofbiz.webapp.website.WebSiteWorker; +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.service.* +import org.apache.ofbiz.product.product.ProductContentWrapper +import org.apache.ofbiz.product.config.ProductConfigWorker +import org.apache.ofbiz.product.catalog.* +import org.apache.ofbiz.product.store.* +import org.apache.ofbiz.order.shoppingcart.* +import org.apache.ofbiz.webapp.website.WebSiteWorker -miniProduct = request.getAttribute("miniProduct"); -optProductId = request.getAttribute("optProductId"); -webSiteId = WebSiteWorker.getWebSiteId(request); -prodCatalogId = CatalogWorker.getCurrentCatalogId(request); -productStoreId = ProductStoreWorker.getProductStoreId(request); -cart = ShoppingCartEvents.getCartObject(request); -context.remove("totalPrice"); +miniProduct = request.getAttribute("miniProduct") +optProductId = request.getAttribute("optProductId") +webSiteId = WebSiteWorker.getWebSiteId(request) +prodCatalogId = CatalogWorker.getCurrentCatalogId(request) +productStoreId = ProductStoreWorker.getProductStoreId(request) +cart = ShoppingCartEvents.getCartObject(request) +context.remove("totalPrice") if (optProductId) { - miniProduct = from("Product").where("productId", optProductId).queryOne(); + miniProduct = from("Product").where("productId", optProductId).queryOne() } if (miniProduct && productStoreId && prodCatalogId ) { @@ -49,43 +49,43 @@ if (miniProduct && productStoreId && prodCatalogId ) { webSiteId : webSiteId, currencyUomId : cart.getCurrency(), autoUserLogin : autoUserLogin, - productStoreId : productStoreId]; - if (userLogin) priceParams.partyId = userLogin.partyId; - priceResult = runService('calculateProductPrice', priceParams); + productStoreId : productStoreId] + if (userLogin) priceParams.partyId = userLogin.partyId + priceResult = runService('calculateProductPrice', priceParams) // returns: isSale, price, orderItemPriceInfos - context.priceResult = priceResult; + context.priceResult = priceResult // Check if Price has to be displayed with tax if (productStore.get("showPricesWithVatTax").equals("Y")) { - Map priceMap = runServic('calcTaxForDisplay', ["basePrice": priceResult.get("price"), "locale": locale, "productId": optProductId, "productStoreId": productStoreId]); - context.price = priceMap.get("priceWithTax"); + Map priceMap = runServic('calcTaxForDisplay', ["basePrice": priceResult.get("price"), "locale": locale, "productId": optProductId, "productStoreId": productStoreId]) + context.price = priceMap.get("priceWithTax") } else { - context.price = priceResult.get("price"); + context.price = priceResult.get("price") } // get aggregated product totalPrice if ("AGGREGATED".equals(miniProduct.productTypeId) || "AGGREGATED_SERVICE".equals(miniProduct.productTypeId)) { - configWrapper = ProductConfigWorker.getProductConfigWrapper(optProductId, cart.getCurrency(), request); + configWrapper = ProductConfigWorker.getProductConfigWrapper(optProductId, cart.getCurrency(), request) if (configWrapper) { - configWrapper.setDefaultConfig(); + configWrapper.setDefaultConfig() // Check if Config Price has to be displayed with tax if (productStore.get("showPricesWithVatTax").equals("Y")) { - BigDecimal totalPriceNoTax = configWrapper.getTotalPrice(); - Map totalPriceMap = runService('calcTaxForDisplay', ["basePrice": totalPriceNoTax, "locale": locale, "productId": optProductId, "productStoreId": productStoreId]); - context.totalPrice = totalPriceMap.get("priceWithTax"); + BigDecimal totalPriceNoTax = configWrapper.getTotalPrice() + Map totalPriceMap = runService('calcTaxForDisplay', ["basePrice": totalPriceNoTax, "locale": locale, "productId": optProductId, "productStoreId": productStoreId]) + context.totalPrice = totalPriceMap.get("priceWithTax") } else { - context.totalPrice = configWrapper.getTotalPrice(); + context.totalPrice = configWrapper.getTotalPrice() } } } - context.miniProduct = miniProduct; - context.nowTimeLong = nowTimestamp.getTime(); + context.miniProduct = miniProduct + context.nowTimeLong = nowTimestamp.getTime() - context.miniProdFormName = request.getAttribute("miniProdFormName"); - context.miniProdQuantity = request.getAttribute("miniProdQuantity"); + context.miniProdFormName = request.getAttribute("miniProdFormName") + context.miniProdQuantity = request.getAttribute("miniProdQuantity") // make the miniProductContentWrapper - ProductContentWrapper miniProductContentWrapper = new ProductContentWrapper(miniProduct, request); - context.miniProductContentWrapper = miniProductContentWrapper; + ProductContentWrapper miniProductContentWrapper = new ProductContentWrapper(miniProduct, request) + context.miniProductContentWrapper = miniProductContentWrapper } diff --git a/ecommerce/groovyScripts/catalog/MiniReorderProds.groovy b/ecommerce/groovyScripts/catalog/MiniReorderProds.groovy index b00571ac3..4049b8246 100644 --- a/ecommerce/groovyScripts/catalog/MiniReorderProds.groovy +++ b/ecommerce/groovyScripts/catalog/MiniReorderProds.groovy @@ -17,8 +17,8 @@ * under the License. */ -import org.apache.ofbiz.order.shoppingcart.product.ProductDisplayWorker; +import org.apache.ofbiz.order.shoppingcart.product.ProductDisplayWorker -reorderProductResults = ProductDisplayWorker.getQuickReorderProducts(request); -context.reorderProducts = reorderProductResults.products; -context.reorderQuantities = reorderProductResults.quantities; +reorderProductResults = ProductDisplayWorker.getQuickReorderProducts(request) +context.reorderProducts = reorderProductResults.products +context.reorderQuantities = reorderProductResults.quantities diff --git a/ecommerce/groovyScripts/catalog/PopularTags.groovy b/ecommerce/groovyScripts/catalog/PopularTags.groovy index 1f02b9617..046bf6183 100644 --- a/ecommerce/groovyScripts/catalog/PopularTags.groovy +++ b/ecommerce/groovyScripts/catalog/PopularTags.groovy @@ -17,66 +17,66 @@ * under the License. */ -import java.util.List; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.entity.condition.*; -import org.apache.ofbiz.entity.util.*; -import org.apache.ofbiz.entity.util.EntityUtil; +import java.util.List +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.entity.condition.* +import org.apache.ofbiz.entity.util.* +import org.apache.ofbiz.entity.util.EntityUtil import org.apache.ofbiz.entity.transaction.* -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.base.util.string.*; -import org.apache.ofbiz.content.content.*; -import org.apache.commons.lang.StringEscapeUtils; -import org.apache.ofbiz.entity.util.EntityUtilProperties; +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.base.util.string.* +import org.apache.ofbiz.content.content.* +import org.apache.commons.lang.StringEscapeUtils +import org.apache.ofbiz.entity.util.EntityUtilProperties -int minFontSize = EntityUtilProperties.getPropertyAsInteger("ecommerce", "tagcloud.min.fontsize", 0).intValue(); -int maxFontSize = EntityUtilProperties.getPropertyAsInteger("ecommerce", "tagcloud.max.fontsize", 0).intValue(); -int limitTagCloud = EntityUtilProperties.getPropertyAsInteger("ecommerce", "tagcloud.limit", 0).intValue(); +int minFontSize = EntityUtilProperties.getPropertyAsInteger("ecommerce", "tagcloud.min.fontsize", 0).intValue() +int maxFontSize = EntityUtilProperties.getPropertyAsInteger("ecommerce", "tagcloud.max.fontsize", 0).intValue() +int limitTagCloud = EntityUtilProperties.getPropertyAsInteger("ecommerce", "tagcloud.limit", 0).intValue() -tagCloudList = [] as LinkedList; -tagList = [] as LinkedList; +tagCloudList = [] as LinkedList +tagList = [] as LinkedList productKeywords = select("keyword", "keywordTypeId", "statusId") .from("ProductKeyword") .where(keywordTypeId : "KWT_TAG", statusId : "KW_APPROVED") .orderBy("keyword") .distinct(true) - .queryList(); + .queryList() if (UtilValidate.isNotEmpty(productKeywords)) { productKeywords.each { productKeyword -> - productTags = from("ProductKeyword").where("keyword", productKeyword.keyword, "keywordTypeId", "KWT_TAG", "statusId", "KW_APPROVED").queryList(); - searchResult = [:]; - searchResult.tag = productKeyword.keyword; - searchResult.countTag = productTags.size(); - tagList.add(searchResult); + productTags = from("ProductKeyword").where("keyword", productKeyword.keyword, "keywordTypeId", "KWT_TAG", "statusId", "KW_APPROVED").queryList() + searchResult = [:] + searchResult.tag = productKeyword.keyword + searchResult.countTag = productTags.size() + tagList.add(searchResult) } } if (tagList) { - int tag = 0; - tagList.sort{ a,b -> b.countTag <=> a.countTag }; + int tag = 0 + tagList.sort{ a,b -> b.countTag <=> a.countTag } if (tagList.size() < limitTagCloud) { - limitTagCloud = tagList.size(); + limitTagCloud = tagList.size() } - int maxResult = tagList[0].countTag; - int minResult = tagList[limitTagCloud - 1].countTag; + int maxResult = tagList[0].countTag + int minResult = tagList[limitTagCloud - 1].countTag tagList.each { tagCloud -> if (tag < limitTagCloud) { - tagCloudOfbizInfo = [:]; - double weight = 0; + tagCloudOfbizInfo = [:] + double weight = 0 if ((maxResult - minResult) > 0) { - weight = (tagCloud.countTag - minResult) / (maxResult - minResult); + weight = (tagCloud.countTag - minResult) / (maxResult - minResult) } - double fontSize = minFontSize + ((maxFontSize - minFontSize) * weight); - tagCloudOfbizInfo.tag = tagCloud.tag; - tagCloudOfbizInfo.fontSize = fontSize; - tagCloudList.add(tagCloudOfbizInfo); - tag++; + double fontSize = minFontSize + ((maxFontSize - minFontSize) * weight) + tagCloudOfbizInfo.tag = tagCloud.tag + tagCloudOfbizInfo.fontSize = fontSize + tagCloudList.add(tagCloudOfbizInfo) + tag++ } } } tagCloudList = tagCloudList.sort{it.tag} -context.tagCloudList = tagCloudList; +context.tagCloudList = tagCloudList diff --git a/ecommerce/groovyScripts/catalog/ProductCategories.groovy b/ecommerce/groovyScripts/catalog/ProductCategories.groovy index 3dbaf3097..e2002c83d 100644 --- a/ecommerce/groovyScripts/catalog/ProductCategories.groovy +++ b/ecommerce/groovyScripts/catalog/ProductCategories.groovy @@ -21,74 +21,74 @@ * This script is also referenced by the ecommerce's screens and * should not contain order component's specific code. */ -import org.apache.ofbiz.entity.util.EntityUtil; +import org.apache.ofbiz.entity.util.EntityUtil -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.product.catalog.*; -import org.apache.ofbiz.product.category.*; -import org.apache.ofbiz.entity.*; +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.product.catalog.* +import org.apache.ofbiz.product.category.* +import org.apache.ofbiz.entity.* List fillTree(rootCat ,CatLvl, parentCategoryId) { if(rootCat) { rootCat.sort{ it.productCategoryId } - def listTree = []; + def listTree = [] for(root in rootCat) { - preCatChilds = from("ProductCategoryRollup").where("parentProductCategoryId", root.productCategoryId).queryList(); - catChilds = EntityUtil.getRelated("CurrentProductCategory",null,preCatChilds,false); - def childList = []; + preCatChilds = from("ProductCategoryRollup").where("parentProductCategoryId", root.productCategoryId).queryList() + catChilds = EntityUtil.getRelated("CurrentProductCategory",null,preCatChilds,false) + def childList = [] // CatLvl uses for identify the Category level for display different css class if(catChilds) { if(CatLvl==2) - childList = fillTree(catChilds,CatLvl+1, parentCategoryId.replaceAll("/", "")+'/'+root.productCategoryId); + childList = fillTree(catChilds,CatLvl+1, parentCategoryId.replaceAll("/", "")+'/'+root.productCategoryId) // replaceAll and '/' uses for fix bug in the breadcrum for href of category else if(CatLvl==1) - childList = fillTree(catChilds,CatLvl+1, parentCategoryId.replaceAll("/", "")+root.productCategoryId); + childList = fillTree(catChilds,CatLvl+1, parentCategoryId.replaceAll("/", "")+root.productCategoryId) else - childList = fillTree(catChilds,CatLvl+1, parentCategoryId+'/'+root.productCategoryId); + childList = fillTree(catChilds,CatLvl+1, parentCategoryId+'/'+root.productCategoryId) } - productsInCat = from("ProductCategoryAndMember").where("productCategoryId", root.productCategoryId).queryList(); + productsInCat = from("ProductCategoryAndMember").where("productCategoryId", root.productCategoryId).queryList() // Display the category if this category containing products or contain the category that's containing products if(productsInCat || childList) { - def rootMap = [:]; - category = from("ProductCategory").where("productCategoryId", root.productCategoryId).queryOne(); - categoryContentWrapper = new CategoryContentWrapper(category, request); - context.title = categoryContentWrapper.get("CATEGORY_NAME", "html"); - categoryDescription = categoryContentWrapper.get("DESCRIPTION", "html"); + def rootMap = [:] + category = from("ProductCategory").where("productCategoryId", root.productCategoryId).queryOne() + categoryContentWrapper = new CategoryContentWrapper(category, request) + context.title = categoryContentWrapper.get("CATEGORY_NAME", "html") + categoryDescription = categoryContentWrapper.get("DESCRIPTION", "html") if(categoryContentWrapper.get("CATEGORY_NAME", "html").toString()) - rootMap["categoryName"] = categoryContentWrapper.get("CATEGORY_NAME", "html"); + rootMap["categoryName"] = categoryContentWrapper.get("CATEGORY_NAME", "html") else - rootMap["categoryName"] = root.categoryName; + rootMap["categoryName"] = root.categoryName if(categoryContentWrapper.get("DESCRIPTION", "html").toString()) - rootMap["categoryDescription"] = categoryContentWrapper.get("DESCRIPTION", "html"); + rootMap["categoryDescription"] = categoryContentWrapper.get("DESCRIPTION", "html") else - rootMap["categoryDescription"] = root.description; + rootMap["categoryDescription"] = root.description - rootMap["productCategoryId"] = root.productCategoryId; - rootMap["parentCategoryId"] = parentCategoryId; - rootMap["child"] = childList; + rootMap["productCategoryId"] = root.productCategoryId + rootMap["parentCategoryId"] = parentCategoryId + rootMap["child"] = childList - listTree.add(rootMap); + listTree.add(rootMap) } } - return listTree; + return listTree } } -CategoryWorker.getRelatedCategories(request, "topLevelList", CatalogWorker.getCatalogTopCategoryId(request, CatalogWorker.getCurrentCatalogId(request)), true); -curCategoryId = parameters.category_id ?: parameters.CATEGORY_ID ?: ""; -request.setAttribute("curCategoryId", curCategoryId); -CategoryWorker.setTrail(request, curCategoryId); +CategoryWorker.getRelatedCategories(request, "topLevelList", CatalogWorker.getCatalogTopCategoryId(request, CatalogWorker.getCurrentCatalogId(request)), true) +curCategoryId = parameters.category_id ?: parameters.CATEGORY_ID ?: "" +request.setAttribute("curCategoryId", curCategoryId) +CategoryWorker.setTrail(request, curCategoryId) -categoryList = request.getAttribute("topLevelList"); +categoryList = request.getAttribute("topLevelList") if (categoryList) { - catContentWrappers = [:]; - CategoryWorker.getCategoryContentWrappers(catContentWrappers, categoryList, request); - context.catContentWrappers = catContentWrappers; - completedTree = fillTree(categoryList, 1, ""); - context.completedTree = completedTree; + catContentWrappers = [:] + CategoryWorker.getCategoryContentWrappers(catContentWrappers, categoryList, request) + context.catContentWrappers = catContentWrappers + completedTree = fillTree(categoryList, 1, "") + context.completedTree = completedTree } diff --git a/ecommerce/groovyScripts/content/AdvancedSearchPrep.groovy b/ecommerce/groovyScripts/content/AdvancedSearchPrep.groovy index 486c9c308..dc5a815d0 100644 --- a/ecommerce/groovyScripts/content/AdvancedSearchPrep.groovy +++ b/ecommerce/groovyScripts/content/AdvancedSearchPrep.groovy @@ -17,24 +17,24 @@ * under the License. */ -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.product.catalog.*; -import org.apache.ofbiz.product.feature.*; -import org.apache.ofbiz.product.product.*; +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.product.catalog.* +import org.apache.ofbiz.product.feature.* +import org.apache.ofbiz.product.product.* -productFeaturesByTypeMap = ParametricSearch.getAllFeaturesByType(delegator, 2000); -productFeatureTypeIdsOrdered = new ArrayList(new TreeSet(productFeaturesByTypeMap.keySet())); +productFeaturesByTypeMap = ParametricSearch.getAllFeaturesByType(delegator, 2000) +productFeatureTypeIdsOrdered = new ArrayList(new TreeSet(productFeaturesByTypeMap.keySet())) -searchOperator = parameters.SEARCH_OPERATOR; +searchOperator = parameters.SEARCH_OPERATOR if (!"AND".equals(searchOperator) && !"OR".equals(searchOperator)) { - searchOperator = "OR"; + searchOperator = "OR" } -searchConstraintStrings = ProductSearchSession.searchGetConstraintStrings(false, session, delegator); -searchSortOrderString = ProductSearchSession.searchGetSortOrderString(false, request); +searchConstraintStrings = ProductSearchSession.searchGetConstraintStrings(false, session, delegator) +searchSortOrderString = ProductSearchSession.searchGetSortOrderString(false, request) -context.productFeaturesByTypeMap = productFeaturesByTypeMap; -context.productFeatureTypeIdsOrdered = productFeatureTypeIdsOrdered; -context.searchOperator = searchOperator; -context.searchConstraintStrings = searchConstraintStrings; -context.searchSortOrderString = searchSortOrderString; +context.productFeaturesByTypeMap = productFeaturesByTypeMap +context.productFeatureTypeIdsOrdered = productFeatureTypeIdsOrdered +context.searchOperator = searchOperator +context.searchConstraintStrings = searchConstraintStrings +context.searchSortOrderString = searchSortOrderString diff --git a/ecommerce/groovyScripts/content/ContentPrep.groovy b/ecommerce/groovyScripts/content/ContentPrep.groovy index 76d74fe84..8db7488ae 100644 --- a/ecommerce/groovyScripts/content/ContentPrep.groovy +++ b/ecommerce/groovyScripts/content/ContentPrep.groovy @@ -17,4 +17,4 @@ * under the License. */ -context.contentId = parameters.cid ?: parameters.contentId; +context.contentId = parameters.cid ?: parameters.contentId diff --git a/ecommerce/groovyScripts/content/Mrv.groovy b/ecommerce/groovyScripts/content/Mrv.groovy index 408d4ab81..ba25fd1d6 100644 --- a/ecommerce/groovyScripts/content/Mrv.groovy +++ b/ecommerce/groovyScripts/content/Mrv.groovy @@ -17,54 +17,54 @@ * under the License. */ -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; +import java.util.ArrayList +import java.util.Collection +import java.util.HashMap +import java.util.Iterator +import java.util.LinkedList +import java.util.List +import java.util.Map +import java.util.Set +import java.util.TreeSet -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.security.*; -import org.apache.ofbiz.service.*; -import org.apache.ofbiz.entity.model.*; -import org.apache.ofbiz.base.util.collections.LifoSet; +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.security.* +import org.apache.ofbiz.service.* +import org.apache.ofbiz.entity.model.* +import org.apache.ofbiz.base.util.collections.LifoSet -import javax.servlet.*; -import javax.servlet.http.*; +import javax.servlet.* +import javax.servlet.http.* -entityName = "ContentDataResourceView"; -lookupCaches = session.getAttribute("lookupCaches"); +entityName = "ContentDataResourceView" +lookupCaches = session.getAttribute("lookupCaches") if (!lookupCaches) { - lookupCaches = [:]; - session.setAttribute("lookupCaches", lookupCaches); + lookupCaches = [:] + session.setAttribute("lookupCaches", lookupCaches) } -lifoSet = lookupCaches[entityName]; +lifoSet = lookupCaches[entityName] if (!lifoSet) { - lifoSet = new LifoSet(10); - lookupCaches.ContentAssocDataResourceViewFrom = lifoSet; + lifoSet = new LifoSet(10) + lookupCaches.ContentAssocDataResourceViewFrom = lifoSet } -sz = lifoSet.size(); -contentIdKey = null; -mrvList = []; +sz = lifoSet.size() +contentIdKey = null +mrvList = [] lifoSet.each { pk0 -> - pk = pk0.getPrimaryKey(); - gv = from(pk.getEntityName()).where(pk).cache(true).queryOne(); + pk = pk0.getPrimaryKey() + gv = from(pk.getEntityName()).where(pk).cache(true).queryOne() if (gv) { - arr = [gv.contentId, gv.contentName] as String[]; - mrvList.add(arr); + arr = [gv.contentId, gv.contentName] as String[] + mrvList.add(arr) } else { // should handle errors in some other way; this does not provide any tracing; impossible to locat // where the error actually occurred - //Debug.logError("findOne on " + pk + " returned null"); + //Debug.logError("findOne on " + pk + " returned null") } } -context.put("mrvList", mrvList); +context.put("mrvList", mrvList) diff --git a/ecommerce/groovyScripts/content/Search.groovy b/ecommerce/groovyScripts/content/Search.groovy index ae351c12d..c78c544bc 100644 --- a/ecommerce/groovyScripts/content/Search.groovy +++ b/ecommerce/groovyScripts/content/Search.groovy @@ -31,74 +31,74 @@ import org.apache.lucene.search.* import org.apache.lucene.index.DirectoryReader import org.apache.lucene.store.Directory -paramMap = UtilHttp.getParameterMap(request); -queryLine = paramMap.queryLine.toString(); -//Debug.logInfo("in search, queryLine:" + queryLine, ""); +paramMap = UtilHttp.getParameterMap(request) +queryLine = paramMap.queryLine.toString() +//Debug.logInfo("in search, queryLine:" + queryLine, "") -siteId = paramMap.siteId ?: "WebStoreCONTENT"; -//Debug.logInfo("in search, siteId:" + siteId, ""); -featureIdByType = ParametricSearch.makeFeatureIdByTypeMap(paramMap); -//Debug.logInfo("in search, featureIdByType:" + featureIdByType, ""); +siteId = paramMap.siteId ?: "WebStoreCONTENT" +//Debug.logInfo("in search, siteId:" + siteId, "") +featureIdByType = ParametricSearch.makeFeatureIdByTypeMap(paramMap) +//Debug.logInfo("in search, featureIdByType:" + featureIdByType, "") -combQuery = new BooleanQuery(); -Directory directory = FSDirectory.open(new File(SearchWorker.getIndexPath("content")).toPath()); -DirectoryReader reader = DirectoryReader.open(directory); -IndexSearcher searcher = null; -Analyzer analyzer = null; +combQuery = new BooleanQuery() +Directory directory = FSDirectory.open(new File(SearchWorker.getIndexPath("content")).toPath()) +DirectoryReader reader = DirectoryReader.open(directory) +IndexSearcher searcher = null +Analyzer analyzer = null try { - searcher = new IndexSearcher(reader); - analyzer = new StandardAnalyzer(); + searcher = new IndexSearcher(reader) + analyzer = new StandardAnalyzer() } catch (java.io.FileNotFoundException e) { - Debug.logError(e, "Search.groovy"); - request.setAttribute("errorMsgReq", "No index file exists."); + Debug.logError(e, "Search.groovy") + request.setAttribute("errorMsgReq", "No index file exists.") } -termQuery = new TermQuery(new Term("site", siteId.toString())); -combQuery.add(termQuery, BooleanClause.Occur.MUST); -//Debug.logInfo("in search, termQuery:" + termQuery.toString(), ""); +termQuery = new TermQuery(new Term("site", siteId.toString())) +combQuery.add(termQuery, BooleanClause.Occur.MUST) +//Debug.logInfo("in search, termQuery:" + termQuery.toString(), "") -//Debug.logInfo("in search, combQuery(1):" + combQuery, ""); +//Debug.logInfo("in search, combQuery(1):" + combQuery, "") if (queryLine && analyzer) { - Query query = null; - QueryParser parser = new QueryParser("content", analyzer); - query = parser.parse(queryLine); - combQuery.add(query, BooleanClause.Occur.MUST); + Query query = null + QueryParser parser = new QueryParser("content", analyzer) + query = parser.parse(queryLine) + combQuery.add(query, BooleanClause.Occur.MUST) } if (featureIdByType) { - featureQuery = new BooleanQuery(); - featuresRequired = BooleanClause.Occur.MUST; + featureQuery = new BooleanQuery() + featuresRequired = BooleanClause.Occur.MUST if ("any".equals(paramMap.anyOrAll)) { - featuresRequired = BooleanClause.Occur.SHOULD; + featuresRequired = BooleanClause.Occur.SHOULD } if (featureIdByType) { featureIdByType.each { key, value -> - termQuery = new TermQuery(new Term("feature", value)); - featureQuery.add(termQuery, featuresRequired); - //Debug.logInfo("in search searchFeature3, termQuery:" + termQuery.toString(), ""); + termQuery = new TermQuery(new Term("feature", value)) + featureQuery.add(termQuery, featuresRequired) + //Debug.logInfo("in search searchFeature3, termQuery:" + termQuery.toString(), "") } } - combQuery.add(featureQuery, featuresRequired); + combQuery.add(featureQuery, featuresRequired) } if (searcher) { - Debug.logInfo("in search searchFeature3, combQuery:" + combQuery.toString(), ""); - TopScoreDocCollector collector = TopScoreDocCollector.create(100); //defaulting to 100 results - searcher.search(combQuery, collector); - ScoreDoc[] hits = collector.topDocs().scoreDocs; - Debug.logInfo("in search, hits:" + collector.getTotalHits(), ""); + Debug.logInfo("in search searchFeature3, combQuery:" + combQuery.toString(), "") + TopScoreDocCollector collector = TopScoreDocCollector.create(100) //defaulting to 100 results + searcher.search(combQuery, collector) + ScoreDoc[] hits = collector.topDocs().scoreDocs + Debug.logInfo("in search, hits:" + collector.getTotalHits(), "") - contentList = [] as ArrayList; - hitSet = [:] as HashSet; + contentList = [] as ArrayList + hitSet = [:] as HashSet for (int start = 0; start < collector.getTotalHits(); start++) { Document doc = searcher.doc(hits[start].doc) - contentId = doc.get("contentId"); - content = from("Content").where("contentId", contentId).cache(true).queryOne(); + contentId = doc.get("contentId") + content = from("Content").where("contentId", contentId).cache(true).queryOne() if (!hitSet.contains(contentId)) { - contentList.add(content); - hitSet.add(contentId); + contentList.add(content) + hitSet.add(contentId) } } - context.queryResults = contentList; + context.queryResults = contentList } diff --git a/ecommerce/groovyScripts/customer/ChangePassword.groovy b/ecommerce/groovyScripts/customer/ChangePassword.groovy index 6785dcb1b..2e3490231 100644 --- a/ecommerce/groovyScripts/customer/ChangePassword.groovy +++ b/ecommerce/groovyScripts/customer/ChangePassword.groovy @@ -17,21 +17,21 @@ * under the License. */ -import java.util.HashMap; -import org.apache.ofbiz.base.util.UtilHttp; +import java.util.HashMap +import org.apache.ofbiz.base.util.UtilHttp -tryEntity = true; -errorMessage = parameters._ERROR_MESSAGE_; +tryEntity = true +errorMessage = parameters._ERROR_MESSAGE_ if (errorMessage) { - tryEntity = false; + tryEntity = false } -donePage = parameters.DONE_PAGE ?: "viewprofile"; +donePage = parameters.DONE_PAGE ?: "viewprofile" -userLoginData = userLogin; -if (!tryEntity) userLoginData = UtilHttp.getParameterMap(request); -if (!userLoginData) userLoginData = [:]; +userLoginData = userLogin +if (!tryEntity) userLoginData = UtilHttp.getParameterMap(request) +if (!userLoginData) userLoginData = [:] -context.donePage = donePage; -context.userLoginData = userLoginData; +context.donePage = donePage +context.userLoginData = userLoginData diff --git a/ecommerce/groovyScripts/customer/ContactList.groovy b/ecommerce/groovyScripts/customer/ContactList.groovy index 59d9f4e87..b4f36489f 100644 --- a/ecommerce/groovyScripts/customer/ContactList.groovy +++ b/ecommerce/groovyScripts/customer/ContactList.groovy @@ -17,44 +17,44 @@ * under the License. */ -import java.lang.*; -import java.util.*; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.entity.util.*; -import org.apache.ofbiz.entity.condition.*; -import org.apache.ofbiz.party.contact.ContactMechWorker; -import org.apache.ofbiz.product.store.ProductStoreWorker; -import org.apache.ofbiz.webapp.website.WebSiteWorker; -import org.apache.ofbiz.accounting.payment.PaymentWorker; +import java.lang.* +import java.util.* +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.entity.util.* +import org.apache.ofbiz.entity.condition.* +import org.apache.ofbiz.party.contact.ContactMechWorker +import org.apache.ofbiz.product.store.ProductStoreWorker +import org.apache.ofbiz.webapp.website.WebSiteWorker +import org.apache.ofbiz.accounting.payment.PaymentWorker -/*publicEmailContactLists = delegator.findByAnd("ContactList", [isPublic : "Y", contactMechTypeId : "EMAIL_ADDRESS"], ["contactListName"], false); +/*publicEmailContactLists = delegator.findByAnd("ContactList", [isPublic : "Y", contactMechTypeId : "EMAIL_ADDRESS"], ["contactListName"], false) context.publicEmailContactLists = publicEmailContactLists;*/ -webSiteId = WebSiteWorker.getWebSiteId(request); -exprList = []; -exprListThruDate = []; -exprList.add(EntityCondition.makeCondition("webSiteId", EntityOperator.EQUALS, webSiteId)); -exprListThruDate.add(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null)); -exprListThruDate.add(EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN_EQUAL_TO, UtilDateTime.nowTimestamp())); -orCond = EntityCondition.makeCondition(exprListThruDate, EntityOperator.OR); -exprList.add(orCond); -webSiteContactList = from("WebSiteContactList").where(exprList).queryList(); +webSiteId = WebSiteWorker.getWebSiteId(request) +exprList = [] +exprListThruDate = [] +exprList.add(EntityCondition.makeCondition("webSiteId", EntityOperator.EQUALS, webSiteId)) +exprListThruDate.add(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null)) +exprListThruDate.add(EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN_EQUAL_TO, UtilDateTime.nowTimestamp())) +orCond = EntityCondition.makeCondition(exprListThruDate, EntityOperator.OR) +exprList.add(orCond) +webSiteContactList = from("WebSiteContactList").where(exprList).queryList() -publicEmailContactLists = []; +publicEmailContactLists = [] webSiteContactList.each { webSiteContactList -> - contactList = webSiteContactList.getRelatedOne("ContactList", false); - contactListType = contactList.getRelatedOne("ContactListType", false); - temp = [:]; - temp.contactList = contactList; - temp.contactListType = contactListType; - publicEmailContactLists.add(temp); + contactList = webSiteContactList.getRelatedOne("ContactList", false) + contactListType = contactList.getRelatedOne("ContactListType", false) + temp = [:] + temp.contactList = contactList + temp.contactListType = contactListType + publicEmailContactLists.add(temp) } -context.publicEmailContactLists = publicEmailContactLists; +context.publicEmailContactLists = publicEmailContactLists if (userLogin) { - partyAndContactMechList = from("PartyAndContactMech").where("partyId", partyId, "contactMechTypeId", "EMAIL_ADDRESS").orderBy("-fromDate").filterByDate().queryList(); - context.partyAndContactMechList = partyAndContactMechList; + partyAndContactMechList = from("PartyAndContactMech").where("partyId", partyId, "contactMechTypeId", "EMAIL_ADDRESS").orderBy("-fromDate").filterByDate().queryList() + context.partyAndContactMechList = partyAndContactMechList } diff --git a/ecommerce/groovyScripts/customer/CustomerReviews.groovy b/ecommerce/groovyScripts/customer/CustomerReviews.groovy index 4fb8b9991..8afe0bd03 100644 --- a/ecommerce/groovyScripts/customer/CustomerReviews.groovy +++ b/ecommerce/groovyScripts/customer/CustomerReviews.groovy @@ -22,7 +22,7 @@ import org.apache.ofbiz.entity.condition.EntityCondition // get the product review(s) for the given user if (userLogin) { - reviews = from("ProductReview").where("userLoginId", userLogin.userLoginId).cache(true).queryList(); + reviews = from("ProductReview").where("userLoginId", userLogin.userLoginId).cache(true).queryList() - context.reviews = reviews; + context.reviews = reviews } diff --git a/ecommerce/groovyScripts/customer/CustomerSurvey.groovy b/ecommerce/groovyScripts/customer/CustomerSurvey.groovy index de122630b..ae3f56e11 100644 --- a/ecommerce/groovyScripts/customer/CustomerSurvey.groovy +++ b/ecommerce/groovyScripts/customer/CustomerSurvey.groovy @@ -17,30 +17,30 @@ * under the License. */ -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.Delegator; -import org.apache.ofbiz.entity.GenericValue; -import org.apache.ofbiz.product.store.ProductStoreSurveyWrapper; +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.Delegator +import org.apache.ofbiz.entity.GenericValue +import org.apache.ofbiz.product.store.ProductStoreSurveyWrapper -partyId = userLogin.partyId; -paramMap = UtilHttp.getParameterMap(request); +partyId = userLogin.partyId +paramMap = UtilHttp.getParameterMap(request) -productStoreSurveyId = parameters.productStoreSurveyId; +productStoreSurveyId = parameters.productStoreSurveyId -surveyAppl = from("ProductStoreSurveyAppl").where("productStoreSurveyId", productStoreSurveyId).queryOne(); +surveyAppl = from("ProductStoreSurveyAppl").where("productStoreSurveyId", productStoreSurveyId).queryOne() if (surveyAppl) { - survey = surveyAppl.getRelatedOne("Survey", false); - context.survey = survey; + survey = surveyAppl.getRelatedOne("Survey", false) + context.survey = survey if (!parameters._ERROR_MESSAGE_) { - paramMap = [productStoreSurveyId : productStoreSurveyId]; + paramMap = [productStoreSurveyId : productStoreSurveyId] } - wrapper = new ProductStoreSurveyWrapper(surveyAppl, partyId, paramMap); - context.surveyWrapper = wrapper; + wrapper = new ProductStoreSurveyWrapper(surveyAppl, partyId, paramMap) + context.surveyWrapper = wrapper - surveyResp = parameters.surveyResponseId; + surveyResp = parameters.surveyResponseId if (surveyResp) { - wrapper.setThisResponseId(surveyResp); - wrapper.callResult(true); + wrapper.setThisResponseId(surveyResp) + wrapper.callResult(true) } } diff --git a/ecommerce/groovyScripts/customer/EditBillingAddress.groovy b/ecommerce/groovyScripts/customer/EditBillingAddress.groovy index 5b24bae5f..1c4a1a970 100644 --- a/ecommerce/groovyScripts/customer/EditBillingAddress.groovy +++ b/ecommerce/groovyScripts/customer/EditBillingAddress.groovy @@ -17,67 +17,67 @@ * under the License. */ -import org.apache.ofbiz.entity.util.EntityUtil; -import org.apache.ofbiz.party.contact.ContactHelper; -import org.apache.ofbiz.entity.condition.EntityCondition; +import org.apache.ofbiz.entity.util.EntityUtil +import org.apache.ofbiz.party.contact.ContactHelper +import org.apache.ofbiz.entity.condition.EntityCondition if (userLogin) { - party = userLogin.getRelatedOne("Party", false); - contactMech = EntityUtil.getFirst(ContactHelper.getContactMech(party, "BILLING_LOCATION", "POSTAL_ADDRESS", false)); + party = userLogin.getRelatedOne("Party", false) + contactMech = EntityUtil.getFirst(ContactHelper.getContactMech(party, "BILLING_LOCATION", "POSTAL_ADDRESS", false)) if (contactMech) { - postalAddress = contactMech.getRelatedOne("PostalAddress", false); - billToContactMechId = postalAddress.contactMechId; - context.billToContactMechId = billToContactMechId; - context.billToName = postalAddress.toName; - context.billToAttnName = postalAddress.attnName; - context.billToAddress1 = postalAddress.address1; - context.billToAddress2 = postalAddress.address2; - context.billToCity = postalAddress.city; - context.billToPostalCode = postalAddress.postalCode; - context.billToStateProvinceGeoId = postalAddress.stateProvinceGeoId; - context.billToCountryGeoId = postalAddress.countryGeoId; - billToStateProvinceGeo = from("Geo").where("geoId", postalAddress.stateProvinceGeoId).queryOne(); + postalAddress = contactMech.getRelatedOne("PostalAddress", false) + billToContactMechId = postalAddress.contactMechId + context.billToContactMechId = billToContactMechId + context.billToName = postalAddress.toName + context.billToAttnName = postalAddress.attnName + context.billToAddress1 = postalAddress.address1 + context.billToAddress2 = postalAddress.address2 + context.billToCity = postalAddress.city + context.billToPostalCode = postalAddress.postalCode + context.billToStateProvinceGeoId = postalAddress.stateProvinceGeoId + context.billToCountryGeoId = postalAddress.countryGeoId + billToStateProvinceGeo = from("Geo").where("geoId", postalAddress.stateProvinceGeoId).queryOne() if (billToStateProvinceGeo) { - context.billToStateProvinceGeo = billToStateProvinceGeo.geoName; + context.billToStateProvinceGeo = billToStateProvinceGeo.geoName } - billToCountryProvinceGeo = from("Geo").where("geoId", postalAddress.countryGeoId).queryOne(); + billToCountryProvinceGeo = from("Geo").where("geoId", postalAddress.countryGeoId).queryOne() if (billToCountryProvinceGeo) { - context.billToCountryProvinceGeo = billToCountryProvinceGeo.geoName; + context.billToCountryProvinceGeo = billToCountryProvinceGeo.geoName } - creditCards = []; - paymentMethod = from("PaymentMethod").where("partyId", party.partyId, "paymentMethodTypeId", "CREDIT_CARD").orderBy("fromDate").filterByDate().queryFirst(); + creditCards = [] + paymentMethod = from("PaymentMethod").where("partyId", party.partyId, "paymentMethodTypeId", "CREDIT_CARD").orderBy("fromDate").filterByDate().queryFirst() if (paymentMethod) { - creditCard = paymentMethod.getRelatedOne("CreditCard", false); - context.paymentMethodTypeId = "CREDIT_CARD"; - context.cardNumber = creditCard.cardNumber; - context.cardType = creditCard.cardType; - context.paymentMethodId = creditCard.paymentMethodId; - context.firstNameOnCard = creditCard.firstNameOnCard; - context.lastNameOnCard = creditCard.lastNameOnCard; - context.expMonth = (creditCard.expireDate).substring(0, 2); - context.expYear = (creditCard.expireDate).substring(3); + creditCard = paymentMethod.getRelatedOne("CreditCard", false) + context.paymentMethodTypeId = "CREDIT_CARD" + context.cardNumber = creditCard.cardNumber + context.cardType = creditCard.cardType + context.paymentMethodId = creditCard.paymentMethodId + context.firstNameOnCard = creditCard.firstNameOnCard + context.lastNameOnCard = creditCard.lastNameOnCard + context.expMonth = (creditCard.expireDate).substring(0, 2) + context.expYear = (creditCard.expireDate).substring(3) } if (shipToContactMechId) { if (billToContactMechId && billToContactMechId.equals(shipToContactMechId)) { - context.useShippingAddressForBilling = "Y"; + context.useShippingAddressForBilling = "Y" } } } billToContactMechList = ContactHelper.getContactMech(party, "PHONE_BILLING", "TELECOM_NUMBER", false) if (billToContactMechList) { - billToTelecomNumber = (EntityUtil.getFirst(billToContactMechList)).getRelatedOne("TelecomNumber", false); - pcm = EntityUtil.getFirst(billToTelecomNumber.getRelated("PartyContactMech", null, null, false)); - context.billToTelecomNumber = billToTelecomNumber; - context.billToExtension = pcm.extension; + billToTelecomNumber = (EntityUtil.getFirst(billToContactMechList)).getRelatedOne("TelecomNumber", false) + pcm = EntityUtil.getFirst(billToTelecomNumber.getRelated("PartyContactMech", null, null, false)) + context.billToTelecomNumber = billToTelecomNumber + context.billToExtension = pcm.extension } billToFaxNumberList = ContactHelper.getContactMech(party, "FAX_BILLING", "TELECOM_NUMBER", false) if (billToFaxNumberList) { - billToFaxNumber = (EntityUtil.getFirst(billToFaxNumberList)).getRelatedOne("TelecomNumber", false); - faxPartyContactMech = EntityUtil.getFirst(billToFaxNumber.getRelated("PartyContactMech", null, null, false)); - context.billToFaxNumber = billToFaxNumber; - context.billToFaxExtension = faxPartyContactMech.extension; + billToFaxNumber = (EntityUtil.getFirst(billToFaxNumberList)).getRelatedOne("TelecomNumber", false) + faxPartyContactMech = EntityUtil.getFirst(billToFaxNumber.getRelated("PartyContactMech", null, null, false)) + context.billToFaxNumber = billToFaxNumber + context.billToFaxExtension = faxPartyContactMech.extension } } diff --git a/ecommerce/groovyScripts/customer/EditContactMech.groovy b/ecommerce/groovyScripts/customer/EditContactMech.groovy index 51c027185..e299e47f2 100644 --- a/ecommerce/groovyScripts/customer/EditContactMech.groovy +++ b/ecommerce/groovyScripts/customer/EditContactMech.groovy @@ -17,87 +17,87 @@ * under the License. */ -import java.util.HashMap; -import org.apache.ofbiz.party.contact.ContactMechWorker; -import org.apache.ofbiz.base.util.UtilHttp; -import org.apache.ofbiz.base.util.UtilMisc; +import java.util.HashMap +import org.apache.ofbiz.party.contact.ContactMechWorker +import org.apache.ofbiz.base.util.UtilHttp +import org.apache.ofbiz.base.util.UtilMisc /* puts the following in the context: "contactMech", "contactMechId", "partyContactMech", "partyContactMechPurposes", "contactMechTypeId", "contactMechType", "purposeTypes", "postalAddress", "telecomNumber", "requestName", "donePage", "tryEntity", "contactMechTypes" */ -target = [:]; -ContactMechWorker.getContactMechAndRelated(request, userLogin.partyId, target); -context.putAll(target); +target = [:] +ContactMechWorker.getContactMechAndRelated(request, userLogin.partyId, target) +context.putAll(target) if (!security.hasEntityPermission("PARTYMGR", "_VIEW", session) && !context.partyContactMech && context.contactMech) { - context.canNotView = true; + context.canNotView = true } else { - context.canNotView = false; + context.canNotView = false } -preContactMechTypeId = parameters.preContactMechTypeId; -if (preContactMechTypeId) context.preContactMechTypeId = preContactMechTypeId; +preContactMechTypeId = parameters.preContactMechTypeId +if (preContactMechTypeId) context.preContactMechTypeId = preContactMechTypeId -paymentMethodId = parameters.paymentMethodId; -if (paymentMethodId) context.paymentMethodId = paymentMethodId; +paymentMethodId = parameters.paymentMethodId +if (paymentMethodId) context.paymentMethodId = paymentMethodId -cmNewPurposeTypeId = parameters.contactMechPurposeTypeId; +cmNewPurposeTypeId = parameters.contactMechPurposeTypeId if (cmNewPurposeTypeId) { - contactMechPurposeType = from("ContactMechPurposeType").where("contactMechPurposeTypeId", cmNewPurposeTypeId).queryOne(); + contactMechPurposeType = from("ContactMechPurposeType").where("contactMechPurposeTypeId", cmNewPurposeTypeId).queryOne() if (contactMechPurposeType) { - context.contactMechPurposeType = contactMechPurposeType; + context.contactMechPurposeType = contactMechPurposeType } else { - cmNewPurposeTypeId = null; + cmNewPurposeTypeId = null } - context.cmNewPurposeTypeId = cmNewPurposeTypeId; + context.cmNewPurposeTypeId = cmNewPurposeTypeId } -tryEntity = context.tryEntity; +tryEntity = context.tryEntity -contactMechData = context.contactMech; -if (!tryEntity) contactMechData = parameters; -if (!contactMechData) contactMechData = [:]; -if (contactMechData) context.contactMechData = contactMechData; +contactMechData = context.contactMech +if (!tryEntity) contactMechData = parameters +if (!contactMechData) contactMechData = [:] +if (contactMechData) context.contactMechData = contactMechData -partyContactMechData = context.partyContactMech; -if (!tryEntity) partyContactMechData = parameters; -if (!partyContactMechData) partyContactMechData = [:]; -if (partyContactMechData) context.partyContactMechData = partyContactMechData; +partyContactMechData = context.partyContactMech +if (!tryEntity) partyContactMechData = parameters +if (!partyContactMechData) partyContactMechData = [:] +if (partyContactMechData) context.partyContactMechData = partyContactMechData -postalAddressData = context.postalAddress; -if (!tryEntity) postalAddressData = parameters; -if (!postalAddressData) postalAddressData = [:]; -if (postalAddressData) context.postalAddressData = postalAddressData; +postalAddressData = context.postalAddress +if (!tryEntity) postalAddressData = parameters +if (!postalAddressData) postalAddressData = [:] +if (postalAddressData) context.postalAddressData = postalAddressData -telecomNumberData = context.telecomNumber; -if (!tryEntity) telecomNumberData = parameters; -if (!telecomNumberData) telecomNumberData = [:]; -if (telecomNumberData) context.telecomNumberData = telecomNumberData; +telecomNumberData = context.telecomNumber +if (!tryEntity) telecomNumberData = parameters +if (!telecomNumberData) telecomNumberData = [:] +if (telecomNumberData) context.telecomNumberData = telecomNumberData // load the geo names for selected countries and states/regions if (parameters.countryGeoId) { - geoValue = from("Geo").where("geoId", parameters.countryGeoId).cache(true).queryOne(); + geoValue = from("Geo").where("geoId", parameters.countryGeoId).cache(true).queryOne() if (geoValue) { - context.selectedCountryName = geoValue.geoName; + context.selectedCountryName = geoValue.geoName } } else if (postalAddressData?.countryGeoId) { - geoValue = from("Geo").where("geoId", postalAddressData.countryGeoId).cache(true).queryOne(); + geoValue = from("Geo").where("geoId", postalAddressData.countryGeoId).cache(true).queryOne() if (geoValue) { - context.selectedCountryName = geoValue.geoName; + context.selectedCountryName = geoValue.geoName } } if (parameters.stateProvinceGeoId) { - geoValue = from("Geo").where("geoId", parameters.stateProvinceGeoId).cache(true).queryOne(); + geoValue = from("Geo").where("geoId", parameters.stateProvinceGeoId).cache(true).queryOne() if (geoValue) { - context.selectedStateName = geoValue.geoId; + context.selectedStateName = geoValue.geoId } } else if (postalAddressData?.stateProvinceGeoId) { - geoValue = from("Geo").where("geoId", postalAddressData.stateProvinceGeoId).cache(true).queryOne(); + geoValue = from("Geo").where("geoId", postalAddressData.stateProvinceGeoId).cache(true).queryOne() if (geoValue) { - context.selectedStateName = geoValue.geoId; + context.selectedStateName = geoValue.geoId } } diff --git a/ecommerce/groovyScripts/customer/EditEmailAndTelecomNumber.groovy b/ecommerce/groovyScripts/customer/EditEmailAndTelecomNumber.groovy index 1351b758a..1382733b8 100644 --- a/ecommerce/groovyScripts/customer/EditEmailAndTelecomNumber.groovy +++ b/ecommerce/groovyScripts/customer/EditEmailAndTelecomNumber.groovy @@ -17,28 +17,28 @@ * under the License. */ -import org.apache.ofbiz.entity.util.EntityUtil; -import org.apache.ofbiz.party.contact.ContactHelper; +import org.apache.ofbiz.entity.util.EntityUtil +import org.apache.ofbiz.party.contact.ContactHelper if (userLogin) { - party = userLogin.getRelatedOne("Party", false); + party = userLogin.getRelatedOne("Party", false) - contactMech = EntityUtil.getFirst(ContactHelper.getContactMech(party, "PRIMARY_EMAIL", "EMAIL_ADDRESS", false)); + contactMech = EntityUtil.getFirst(ContactHelper.getContactMech(party, "PRIMARY_EMAIL", "EMAIL_ADDRESS", false)) if (contactMech) { - context.emailContactMechId = contactMech.contactMechId; - context.emailAddress = contactMech.infoString; + context.emailContactMechId = contactMech.contactMechId + context.emailAddress = contactMech.infoString } - contactMech = EntityUtil.getFirst(ContactHelper.getContactMech(party, "PRIMARY_PHONE", "TELECOM_NUMBER", false)); + contactMech = EntityUtil.getFirst(ContactHelper.getContactMech(party, "PRIMARY_PHONE", "TELECOM_NUMBER", false)) if (contactMech) { - partyContactMech = from("PartyContactMech").where("partyId", party.partyId, "contactMechId", contactMech.contactMechId).filterByDate().queryFirst(); + partyContactMech = from("PartyContactMech").where("partyId", party.partyId, "contactMechId", contactMech.contactMechId).filterByDate().queryFirst() if (partyContactMech) { - telecomNumber = partyContactMech.getRelatedOne("TelecomNumber", false); - context.phoneContactMechId = telecomNumber.contactMechId; - context.countryCode = telecomNumber.countryCode; - context.areaCode = telecomNumber.areaCode; - context.contactNumber = telecomNumber.contactNumber; - context.extension = partyContactMech.extension; + telecomNumber = partyContactMech.getRelatedOne("TelecomNumber", false) + context.phoneContactMechId = telecomNumber.contactMechId + context.countryCode = telecomNumber.countryCode + context.areaCode = telecomNumber.areaCode + context.contactNumber = telecomNumber.contactNumber + context.extension = partyContactMech.extension } } } diff --git a/ecommerce/groovyScripts/customer/EditPaymentMethod.groovy b/ecommerce/groovyScripts/customer/EditPaymentMethod.groovy index c3cb31339..a00b91956 100644 --- a/ecommerce/groovyScripts/customer/EditPaymentMethod.groovy +++ b/ecommerce/groovyScripts/customer/EditPaymentMethod.groovy @@ -17,48 +17,48 @@ * under the License. */ -import java.util.HashMap; -import org.apache.ofbiz.base.util.UtilHttp; -import org.apache.ofbiz.accounting.payment.PaymentWorker; -import org.apache.ofbiz.party.contact.ContactMechWorker; +import java.util.HashMap +import org.apache.ofbiz.base.util.UtilHttp +import org.apache.ofbiz.accounting.payment.PaymentWorker +import org.apache.ofbiz.party.contact.ContactMechWorker -paymentResults = PaymentWorker.getPaymentMethodAndRelated(request, userLogin.partyId); +paymentResults = PaymentWorker.getPaymentMethodAndRelated(request, userLogin.partyId) //returns the following: "paymentMethod", "creditCard", "giftCard", "eftAccount", "paymentMethodId", "curContactMechId", "donePage", "tryEntity" -context.putAll(paymentResults); +context.putAll(paymentResults) -curPostalAddressResults = ContactMechWorker.getCurrentPostalAddress(request, userLogin.partyId, paymentResults.curContactMechId); +curPostalAddressResults = ContactMechWorker.getCurrentPostalAddress(request, userLogin.partyId, paymentResults.curContactMechId) //returns the following: "curPartyContactMech", "curContactMech", "curPostalAddress", "curPartyContactMechPurposes" -context.putAll(curPostalAddressResults); +context.putAll(curPostalAddressResults) -postalAddressInfos = ContactMechWorker.getPartyPostalAddresses(request, userLogin.partyId, paymentResults.curContactMechId); -context.put("postalAddressInfos", postalAddressInfos); +postalAddressInfos = ContactMechWorker.getPartyPostalAddresses(request, userLogin.partyId, paymentResults.curContactMechId) +context.put("postalAddressInfos", postalAddressInfos) //prepare "Data" maps for filling form input boxes -tryEntity = paymentResults.tryEntity; +tryEntity = paymentResults.tryEntity -creditCardData = paymentResults.creditCard; -if (!tryEntity) creditCardData = parameters; -if (!creditCardData) creditCardData = [:]; -if (creditCardData) context.creditCardData = creditCardData; +creditCardData = paymentResults.creditCard +if (!tryEntity) creditCardData = parameters +if (!creditCardData) creditCardData = [:] +if (creditCardData) context.creditCardData = creditCardData -giftCardData = paymentResults.giftCard; -if (!tryEntity) giftCardData = parameters; -if (!giftCardData) giftCardData = [:]; -if (giftCardData) context.giftCardData = giftCardData; +giftCardData = paymentResults.giftCard +if (!tryEntity) giftCardData = parameters +if (!giftCardData) giftCardData = [:] +if (giftCardData) context.giftCardData = giftCardData -eftAccountData = paymentResults.eftAccount; -if (!tryEntity) eftAccountData = parameters; -if (!eftAccountData) eftAccountData = [:]; -if (eftAccountData) context.eftAccountData = eftAccountData; +eftAccountData = paymentResults.eftAccount +if (!tryEntity) eftAccountData = parameters +if (!eftAccountData) eftAccountData = [:] +if (eftAccountData) context.eftAccountData = eftAccountData -paymentMethodData = paymentResults.paymentMethod; -if (!tryEntity) paymentMethodData = parameters; -if (!paymentMethodData) paymentMethodData = [:]; -if (paymentMethodData) context.paymentMethodData = paymentMethodData; +paymentMethodData = paymentResults.paymentMethod +if (!tryEntity) paymentMethodData = parameters +if (!paymentMethodData) paymentMethodData = [:] +if (paymentMethodData) context.paymentMethodData = paymentMethodData //prepare security flag if (!security.hasEntityPermission("PARTYMGR", "_VIEW", session) && (context.creditCard || context.giftCard || context.eftAccount) && context.paymentMethod && !userLogin.partyId.equals(context.paymentMethod.partyId)) { - context.canNotView = true; + context.canNotView = true } else { - context.canNotView = false; + context.canNotView = false } diff --git a/ecommerce/groovyScripts/customer/EditPerson.groovy b/ecommerce/groovyScripts/customer/EditPerson.groovy index 023ca10b7..7d2147d37 100644 --- a/ecommerce/groovyScripts/customer/EditPerson.groovy +++ b/ecommerce/groovyScripts/customer/EditPerson.groovy @@ -17,16 +17,16 @@ * under the License. */ -import java.util.HashMap; -import org.apache.ofbiz.base.util.UtilHttp; +import java.util.HashMap +import org.apache.ofbiz.base.util.UtilHttp -tryEntity = true; -errorMessage = parameters._ERROR_MESSAGE_; +tryEntity = true +errorMessage = parameters._ERROR_MESSAGE_ if (errorMessage) { - tryEntity = false; + tryEntity = false } -personData = person; -if (!tryEntity) personData = UtilHttp.getParameterMap(request); -if (!personData) personData = [:]; +personData = person +if (!tryEntity) personData = UtilHttp.getParameterMap(request) +if (!personData) personData = [:] -context.personData = personData; +context.personData = personData diff --git a/ecommerce/groovyScripts/customer/EditShippingAddress.groovy b/ecommerce/groovyScripts/customer/EditShippingAddress.groovy index 62b3af93b..55ed34fce 100644 --- a/ecommerce/groovyScripts/customer/EditShippingAddress.groovy +++ b/ecommerce/groovyScripts/customer/EditShippingAddress.groovy @@ -17,60 +17,60 @@ * under the License. */ -import org.apache.ofbiz.entity.util.EntityUtil; -import org.apache.ofbiz.party.contact.ContactHelper; +import org.apache.ofbiz.entity.util.EntityUtil +import org.apache.ofbiz.party.contact.ContactHelper if (userLogin) { - party = userLogin.getRelatedOne("Party", false); + party = userLogin.getRelatedOne("Party", false) context.partyId = party.partyId if ("PERSON".equals(party.partyTypeId)) { - person = from("Person").where("partyId", party.partyId).queryOne(); - context.firstName = person.firstName; - context.lastName = person.lastName; + person = from("Person").where("partyId", party.partyId).queryOne() + context.firstName = person.firstName + context.lastName = person.lastName } else { - group = from("PartyGroup").where("partyId", party.partyId).queryOne(); - context.firstName = group.groupName; - context.lastName = ""; + group = from("PartyGroup").where("partyId", party.partyId).queryOne() + context.firstName = group.groupName + context.lastName = "" } - contactMech = EntityUtil.getFirst(ContactHelper.getContactMech(party, "SHIPPING_LOCATION", "POSTAL_ADDRESS", false)); + contactMech = EntityUtil.getFirst(ContactHelper.getContactMech(party, "SHIPPING_LOCATION", "POSTAL_ADDRESS", false)) if (contactMech) { - postalAddress = contactMech.getRelatedOne("PostalAddress", false); - context.shipToContactMechId = postalAddress.contactMechId; + postalAddress = contactMech.getRelatedOne("PostalAddress", false) + context.shipToContactMechId = postalAddress.contactMechId - context.shipToName = postalAddress.toName; - context.shipToAttnName = postalAddress.attnName; - context.shipToAddress1 = postalAddress.address1; - context.shipToAddress2 = postalAddress.address2; - context.shipToCity = postalAddress.city; - context.shipToPostalCode = postalAddress.postalCode; - context.shipToStateProvinceGeoId = postalAddress.stateProvinceGeoId; - context.shipToCountryGeoId = postalAddress.countryGeoId; - shipToStateProvinceGeo = from("Geo").where("geoId", postalAddress.stateProvinceGeoId).queryOne(); + context.shipToName = postalAddress.toName + context.shipToAttnName = postalAddress.attnName + context.shipToAddress1 = postalAddress.address1 + context.shipToAddress2 = postalAddress.address2 + context.shipToCity = postalAddress.city + context.shipToPostalCode = postalAddress.postalCode + context.shipToStateProvinceGeoId = postalAddress.stateProvinceGeoId + context.shipToCountryGeoId = postalAddress.countryGeoId + shipToStateProvinceGeo = from("Geo").where("geoId", postalAddress.stateProvinceGeoId).queryOne() if (shipToStateProvinceGeo) { - context.shipToStateProvinceGeo = shipToStateProvinceGeo.geoName; + context.shipToStateProvinceGeo = shipToStateProvinceGeo.geoName } - shipToCountryProvinceGeo = from("Geo").where("geoId", postalAddress.countryGeoId).queryOne(); + shipToCountryProvinceGeo = from("Geo").where("geoId", postalAddress.countryGeoId).queryOne() if (shipToCountryProvinceGeo) { - context.shipToCountryProvinceGeo = shipToCountryProvinceGeo.geoName; + context.shipToCountryProvinceGeo = shipToCountryProvinceGeo.geoName } } else { - context.shipToContactMechId = null; + context.shipToContactMechId = null } shipToContactMechList = ContactHelper.getContactMech(party, "PHONE_SHIPPING", "TELECOM_NUMBER", false) if (shipToContactMechList) { - shipToTelecomNumber = (EntityUtil.getFirst(shipToContactMechList)).getRelatedOne("TelecomNumber", false); - pcm = EntityUtil.getFirst(shipToTelecomNumber.getRelated("PartyContactMech", null, null, false)); - context.shipToTelecomNumber = shipToTelecomNumber; - context.shipToExtension = pcm.extension; + shipToTelecomNumber = (EntityUtil.getFirst(shipToContactMechList)).getRelatedOne("TelecomNumber", false) + pcm = EntityUtil.getFirst(shipToTelecomNumber.getRelated("PartyContactMech", null, null, false)) + context.shipToTelecomNumber = shipToTelecomNumber + context.shipToExtension = pcm.extension } shipToFaxNumberList = ContactHelper.getContactMech(party, "FAX_SHIPPING", "TELECOM_NUMBER", false) if (shipToFaxNumberList) { - shipToFaxNumber = (EntityUtil.getFirst(shipToFaxNumberList)).getRelatedOne("TelecomNumber", false); - faxPartyContactMech = EntityUtil.getFirst(shipToFaxNumber.getRelated("PartyContactMech", null, null, false)); - context.shipToFaxNumber = shipToFaxNumber; - context.shipToFaxExtension = faxPartyContactMech.extension; + shipToFaxNumber = (EntityUtil.getFirst(shipToFaxNumberList)).getRelatedOne("TelecomNumber", false) + faxPartyContactMech = EntityUtil.getFirst(shipToFaxNumber.getRelated("PartyContactMech", null, null, false)) + context.shipToFaxNumber = shipToFaxNumber + context.shipToFaxExtension = faxPartyContactMech.extension } } diff --git a/ecommerce/groovyScripts/customer/GiftCardBalance.groovy b/ecommerce/groovyScripts/customer/GiftCardBalance.groovy index c52b59cf7..8051bf3aa 100644 --- a/ecommerce/groovyScripts/customer/GiftCardBalance.groovy +++ b/ecommerce/groovyScripts/customer/GiftCardBalance.groovy @@ -17,5 +17,5 @@ * under the License. */ - import org.apache.ofbiz.product.store.*; - context.paymentProperties = ProductStoreWorker.getProductStorePaymentProperties(request, "GIFT_CARD", null, true); + import org.apache.ofbiz.product.store.* + context.paymentProperties = ProductStoreWorker.getProductStorePaymentProperties(request, "GIFT_CARD", null, true) diff --git a/ecommerce/groovyScripts/customer/GiftCardLink.groovy b/ecommerce/groovyScripts/customer/GiftCardLink.groovy index d8818deb4..3dc41143f 100644 --- a/ecommerce/groovyScripts/customer/GiftCardLink.groovy +++ b/ecommerce/groovyScripts/customer/GiftCardLink.groovy @@ -17,17 +17,17 @@ * under the License. */ -import org.apache.ofbiz.product.store.*; +import org.apache.ofbiz.product.store.* -processResult = parameters.processResult; +processResult = parameters.processResult if (processResult != null) { if (!processResult) { - request.setAttribute("_ERROR_MESSAGE_", "
  • There was a problem linking your cards. Please check the numbers and try again.
  • "); - request.removeAttribute("_EVENT_MESSAGE_"); + request.setAttribute("_ERROR_MESSAGE_", "
  • There was a problem linking your cards. Please check the numbers and try again.
  • ") + request.removeAttribute("_EVENT_MESSAGE_") } else { - request.setAttribute("_EVENT_MESSAGE_", "
  • Thank-you. Your gift card account is now linked.
  • "); + request.setAttribute("_EVENT_MESSAGE_", "
  • Thank-you. Your gift card account is now linked.
  • ") } } -context.userLogin = userLogin; -context.paymentProperties = ProductStoreWorker.getProductStorePaymentProperties(request, "GIFT_CARD", null, true); +context.userLogin = userLogin +context.paymentProperties = ProductStoreWorker.getProductStorePaymentProperties(request, "GIFT_CARD", null, true) diff --git a/ecommerce/groovyScripts/customer/NewCustomer.groovy b/ecommerce/groovyScripts/customer/NewCustomer.groovy index a405b22e6..e765a3dc1 100644 --- a/ecommerce/groovyScripts/customer/NewCustomer.groovy +++ b/ecommerce/groovyScripts/customer/NewCustomer.groovy @@ -17,42 +17,42 @@ * under the License. */ -import org.apache.ofbiz.base.util.UtilProperties; -import org.apache.ofbiz.base.util.UtilMisc; -import org.apache.ofbiz.product.store.ProductStoreWorker; +import org.apache.ofbiz.base.util.UtilProperties +import org.apache.ofbiz.base.util.UtilMisc +import org.apache.ofbiz.product.store.ProductStoreWorker -productStore = ProductStoreWorker.getProductStore(request); -context.productStoreId = productStore.productStoreId; -context.productStore = productStore; +productStore = ProductStoreWorker.getProductStore(request) +context.productStoreId = productStore.productStoreId +context.productStore = productStore -context.createAllowPassword = "Y".equals(productStore.allowPassword); -context.getUsername = !"Y".equals(productStore.usePrimaryEmailUsername); +context.createAllowPassword = "Y".equals(productStore.allowPassword) +context.getUsername = !"Y".equals(productStore.usePrimaryEmailUsername) -previousParams = parameters._PREVIOUS_PARAMS_; +previousParams = parameters._PREVIOUS_PARAMS_ if (previousParams) { - previousParams = "?" + previousParams; + previousParams = "?" + previousParams } else { - previousParams = ""; + previousParams = "" } -context.previousParams = previousParams; +context.previousParams = previousParams //the parameters from janrain -userInfoMap = request.getAttribute("userInfoMap"); +userInfoMap = request.getAttribute("userInfoMap") if (!userInfoMap) { - userInfoMap = request.getSession().getAttribute("userInfoMap"); + userInfoMap = request.getSession().getAttribute("userInfoMap") } if (userInfoMap) { if (userInfoMap.givenName && userInfoMap.familyName) { - requestParameters.USER_FIRST_NAME = userInfoMap.givenName; - requestParameters.USER_LAST_NAME = userInfoMap.familyName; + requestParameters.USER_FIRST_NAME = userInfoMap.givenName + requestParameters.USER_LAST_NAME = userInfoMap.familyName } else if (userInfoMap.formatted) { - requestParameters.USER_FIRST_NAME = userInfoMap.formatted; + requestParameters.USER_FIRST_NAME = userInfoMap.formatted } - requestParameters.CUSTOMER_EMAIL = userInfoMap.email; - requestParameters.preferredUsername = userInfoMap.preferredUsername; - requestParameters.USERNAME = userInfoMap.preferredUsername; - request.getSession().setAttribute("userInfoMap", userInfoMap); + requestParameters.CUSTOMER_EMAIL = userInfoMap.email + requestParameters.preferredUsername = userInfoMap.preferredUsername + requestParameters.USERNAME = userInfoMap.preferredUsername + request.getSession().setAttribute("userInfoMap", userInfoMap) } donePage = "main;" + parameters.visit.sessionId -context.donePage = donePage; +context.donePage = donePage diff --git a/ecommerce/groovyScripts/customer/OnePageCheckoutOptions.groovy b/ecommerce/groovyScripts/customer/OnePageCheckoutOptions.groovy index bce1823e7..ad2f2ddcc 100644 --- a/ecommerce/groovyScripts/customer/OnePageCheckoutOptions.groovy +++ b/ecommerce/groovyScripts/customer/OnePageCheckoutOptions.groovy @@ -17,11 +17,11 @@ * under the License. */ - import org.apache.ofbiz.order.shoppingcart.shipping.*; + import org.apache.ofbiz.order.shoppingcart.shipping.* -shoppingCart = session.getAttribute("shoppingCart"); +shoppingCart = session.getAttribute("shoppingCart") // Reassign items requiring drop-shipping to new or existing drop-ship groups if (shoppingCart) { - shoppingCart.createDropShipGroups(dispatcher); + shoppingCart.createDropShipGroups(dispatcher) } diff --git a/ecommerce/groovyScripts/customer/ViewProfile.groovy b/ecommerce/groovyScripts/customer/ViewProfile.groovy index d15fdf693..ee02bec21 100644 --- a/ecommerce/groovyScripts/customer/ViewProfile.groovy +++ b/ecommerce/groovyScripts/customer/ViewProfile.groovy @@ -17,85 +17,85 @@ * under the License. */ -import java.lang.*; -import java.util.*; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.entity.util.*; -import org.apache.ofbiz.entity.condition.*; -import org.apache.ofbiz.party.contact.ContactMechWorker; -import org.apache.ofbiz.product.store.ProductStoreWorker; -import org.apache.ofbiz.accounting.payment.PaymentWorker; +import java.lang.* +import java.util.* +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.entity.util.* +import org.apache.ofbiz.entity.condition.* +import org.apache.ofbiz.party.contact.ContactMechWorker +import org.apache.ofbiz.product.store.ProductStoreWorker +import org.apache.ofbiz.accounting.payment.PaymentWorker -productStoreId = ProductStoreWorker.getProductStoreId(request); -context.productStoreId = productStoreId; +productStoreId = ProductStoreWorker.getProductStoreId(request) +context.productStoreId = productStoreId if (userLogin) { - profiledefs = from("PartyProfileDefault").where("partyId", partyId, "productStoreId", productStoreId).queryOne(); + profiledefs = from("PartyProfileDefault").where("partyId", partyId, "productStoreId", productStoreId).queryOne() - showOld = "true".equals(parameters.SHOW_OLD); + showOld = "true".equals(parameters.SHOW_OLD) - partyContactMechValueMaps = ContactMechWorker.getPartyContactMechValueMaps(delegator, userLogin.partyId, showOld); - paymentMethodValueMaps = PaymentWorker.getPartyPaymentMethodValueMaps(delegator, userLogin.partyId, showOld); + partyContactMechValueMaps = ContactMechWorker.getPartyContactMechValueMaps(delegator, userLogin.partyId, showOld) + paymentMethodValueMaps = PaymentWorker.getPartyPaymentMethodValueMaps(delegator, userLogin.partyId, showOld) - context.profiledefs = profiledefs; - context.showOld = showOld; - context.partyContactMechValueMaps = partyContactMechValueMaps; - context.paymentMethodValueMaps = paymentMethodValueMaps; + context.profiledefs = profiledefs + context.showOld = showOld + context.partyContactMechValueMaps = partyContactMechValueMaps + context.paymentMethodValueMaps = paymentMethodValueMaps // shipping methods - for default selection if (profiledefs?.defaultShipAddr) { - shipAddress = from("PostalAddress").where("contactMechId", profiledefs.defaultShipAddr).queryOne(); + shipAddress = from("PostalAddress").where("contactMechId", profiledefs.defaultShipAddr).queryOne() if (shipAddress) { - carrierShipMeths = ProductStoreWorker.getAvailableStoreShippingMethods(delegator, productStoreId, shipAddress, [1], null, 0, 1); - context.carrierShipMethods = carrierShipMeths; + carrierShipMeths = ProductStoreWorker.getAvailableStoreShippingMethods(delegator, productStoreId, shipAddress, [1], null, 0, 1) + context.carrierShipMethods = carrierShipMeths } } - profileSurveys = ProductStoreWorker.getProductSurveys(delegator, productStoreId, null, "CUSTOMER_PROFILE"); - context.surveys = profileSurveys; + profileSurveys = ProductStoreWorker.getProductSurveys(delegator, productStoreId, null, "CUSTOMER_PROFILE") + context.surveys = profileSurveys - exprs = [EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId)]; - exprs.add(EntityCondition.makeCondition("roleStatusId", EntityOperator.NOT_EQUAL, "COM_ROLE_READ")); - messages = from("CommunicationEventAndRole").where(exprs).orderBy("-entryDate").maxRows(5).queryList(); - context.messages = messages; - context.profileMessages = true; + exprs = [EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId)] + exprs.add(EntityCondition.makeCondition("roleStatusId", EntityOperator.NOT_EQUAL, "COM_ROLE_READ")) + messages = from("CommunicationEventAndRole").where(exprs).orderBy("-entryDate").maxRows(5).queryList() + context.messages = messages + context.profileMessages = true - partyContent = from("ContentRole").where("partyId", partyId, "roleTypeId", "OWNER").filterByDate().queryList(); - context.partyContent = partyContent; + partyContent = from("ContentRole").where("partyId", partyId, "roleTypeId", "OWNER").filterByDate().queryList() + context.partyContent = partyContent - mimeTypes = from("MimeType").orderBy("description", "mimeTypeId").queryList(); - context.mimeTypes = mimeTypes; + mimeTypes = from("MimeType").orderBy("description", "mimeTypeId").queryList() + context.mimeTypes = mimeTypes - partyContentTypes = from("PartyContentType").orderBy("description").queryList(); - context.partyContentTypes = partyContentTypes; + partyContentTypes = from("PartyContentType").orderBy("description").queryList() + context.partyContentTypes = partyContentTypes // call the getOrderedSummaryInformation service to get the sub-total of valid orders in last X months - monthsToInclude = 12; - result = runService('getOrderedSummaryInformation', [partyId : partyId, roleTypeId : "PLACING_CUSTOMER", orderTypeId : "SALES_ORDER", statusId : "ORDER_COMPLETED", monthsToInclude : monthsToInclude, userLogin : userLogin]); - context.monthsToInclude = monthsToInclude; - context.totalSubRemainingAmount = result.totalSubRemainingAmount; - context.totalOrders = result.totalOrders; + monthsToInclude = 12 + result = runService('getOrderedSummaryInformation', [partyId : partyId, roleTypeId : "PLACING_CUSTOMER", orderTypeId : "SALES_ORDER", statusId : "ORDER_COMPLETED", monthsToInclude : monthsToInclude, userLogin : userLogin]) + context.monthsToInclude = monthsToInclude + context.totalSubRemainingAmount = result.totalSubRemainingAmount + context.totalOrders = result.totalOrders - contactListPartyList = from("ContactListParty").where("partyId", partyId).orderBy("-fromDate").queryList(); - // show all, including history, ie don't filter: contactListPartyList = EntityUtil.filterByDate(contactListPartyList, true); - context.contactListPartyList = contactListPartyList; + contactListPartyList = from("ContactListParty").where("partyId", partyId).orderBy("-fromDate").queryList() + // show all, including history, ie don't filter: contactListPartyList = EntityUtil.filterByDate(contactListPartyList, true) + context.contactListPartyList = contactListPartyList - publicContactLists = from("ContactList").where("isPublic", "Y").orderBy("contactListName").queryList(); - context.publicContactLists = publicContactLists; + publicContactLists = from("ContactList").where("isPublic", "Y").orderBy("contactListName").queryList() + context.publicContactLists = publicContactLists - partyAndContactMechList = from("PartyAndContactMech").where("partyId", partyId).orderBy("-fromDate").filterByDate().queryList(); - context.partyAndContactMechList = partyAndContactMechList; + partyAndContactMechList = from("PartyAndContactMech").where("partyId", partyId).orderBy("-fromDate").filterByDate().queryList() + context.partyAndContactMechList = partyAndContactMechList // state/province & country's name if (partyContactMechValueMaps) { partyContactMechValueMaps.each { if (it.postalAddress) { - postalAddress = it.postalAddress; - countryGeo = postalAddress.getRelatedOne("CountryGeo", false); - if (countryGeo) it.countryGeoName = countryGeo.getString("geoName"); - stateProvinceGeo = postalAddress.getRelatedOne("StateProvinceGeo", false); - if (stateProvinceGeo) it.stateProvinceGeoName = stateProvinceGeo.getString("geoName"); + postalAddress = it.postalAddress + countryGeo = postalAddress.getRelatedOne("CountryGeo", false) + if (countryGeo) it.countryGeoName = countryGeo.getString("geoName") + stateProvinceGeo = postalAddress.getRelatedOne("StateProvinceGeo", false) + if (stateProvinceGeo) it.stateProvinceGeoName = stateProvinceGeo.getString("geoName") } } diff --git a/ecommerce/groovyScripts/forum/ContentAddPrep.groovy b/ecommerce/groovyScripts/forum/ContentAddPrep.groovy index b0f21b9d0..0930a5e21 100644 --- a/ecommerce/groovyScripts/forum/ContentAddPrep.groovy +++ b/ecommerce/groovyScripts/forum/ContentAddPrep.groovy @@ -17,77 +17,77 @@ * under the License. */ -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.security.*; -import org.apache.ofbiz.service.*; -import org.apache.ofbiz.entity.model.*; -import org.apache.ofbiz.securityext.login.*; -import org.apache.ofbiz.common.*; -import org.apache.ofbiz.entity.model.*; -import org.apache.ofbiz.content.ContentManagementWorker; -import org.apache.ofbiz.content.content.ContentWorker; +import java.util.ArrayList +import java.util.Collection +import java.util.HashMap +import java.util.Iterator +import java.util.LinkedList +import java.util.List +import java.util.Map +import java.util.Set +import java.util.TreeSet +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.security.* +import org.apache.ofbiz.service.* +import org.apache.ofbiz.entity.model.* +import org.apache.ofbiz.securityext.login.* +import org.apache.ofbiz.common.* +import org.apache.ofbiz.entity.model.* +import org.apache.ofbiz.content.ContentManagementWorker +import org.apache.ofbiz.content.content.ContentWorker -import freemarker.template.SimpleHash; -import freemarker.template.SimpleSequence; +import freemarker.template.SimpleHash +import freemarker.template.SimpleSequence -import javax.servlet.*; -import javax.servlet.http.*; +import javax.servlet.* +import javax.servlet.http.* -singleWrapper = context.singleWrapper; -singleWrapper.putInContext("contentPurposeTypeId", page.contentPurposeTypeId); -singleWrapper.putInContext("contentAssocTypeId", page.contentAssocTypeId); -rootPubPt = parameters.webSiteId; -paramMap = UtilHttp.getParameterMap(request); -contentIdTo = ContentManagementWorker.getFromSomewhere("forumId", paramMap, request, context); -context.contentIdTo = contentIdTo; -//Debug.logInfo("in contentaddprep, contentIdTo:" + contentIdTo,""); -//Debug.logInfo("in contentaddprep, paramMap:" + paramMap,""); -attrList = from("ContentAttribute").where("contentId", contentIdTo, "attrName", "publishOperation").cache(true).queryList(); -publishOperation = null; +singleWrapper = context.singleWrapper +singleWrapper.putInContext("contentPurposeTypeId", page.contentPurposeTypeId) +singleWrapper.putInContext("contentAssocTypeId", page.contentAssocTypeId) +rootPubPt = parameters.webSiteId +paramMap = UtilHttp.getParameterMap(request) +contentIdTo = ContentManagementWorker.getFromSomewhere("forumId", paramMap, request, context) +context.contentIdTo = contentIdTo +//Debug.logInfo("in contentaddprep, contentIdTo:" + contentIdTo,"") +//Debug.logInfo("in contentaddprep, paramMap:" + paramMap,"") +attrList = from("ContentAttribute").where("contentId", contentIdTo, "attrName", "publishOperation").cache(true).queryList() +publishOperation = null if (attrList) { - contentAttribute = attrList.get(0); - publishOperation = contentAttribute.attrValue; - //Debug.logInfo("in contentaddprep, publishOperation:" + publishOperation,""); + contentAttribute = attrList.get(0) + publishOperation = contentAttribute.attrValue + //Debug.logInfo("in contentaddprep, publishOperation:" + publishOperation,"") } -singleWrapper.putInContext("publishOperation", publishOperation); -singleWrapper.putInContext("contentIdTo", contentIdTo); -//singleWrapper.putInContext("ownerContentId", contentIdTo); -summaryDataResourceTypeId = page.summaryDataResourceTypeId; -singleWrapper.putInContext("summaryDataResourceTypeId", summaryDataResourceTypeId); -targetOperation = page.targetOperation ?: "CONTENT_CREATE"; +singleWrapper.putInContext("publishOperation", publishOperation) +singleWrapper.putInContext("contentIdTo", contentIdTo) +//singleWrapper.putInContext("ownerContentId", contentIdTo) +summaryDataResourceTypeId = page.summaryDataResourceTypeId +singleWrapper.putInContext("summaryDataResourceTypeId", summaryDataResourceTypeId) +targetOperation = page.targetOperation ?: "CONTENT_CREATE" -singleWrapper.putInContext("targetOperation", targetOperation); -singleWrapper.putInContext("contentTypeId", "DOCUMENT"); -contentPurpose = page.contentPurpose ?: "ARTICLE"; +singleWrapper.putInContext("targetOperation", targetOperation) +singleWrapper.putInContext("contentTypeId", "DOCUMENT") +contentPurpose = page.contentPurpose ?: "ARTICLE" -singleWrapper.putInContext("contentPurpose", contentPurpose); -singleWrapper.putInContext("forumId", contentIdTo); +singleWrapper.putInContext("contentPurpose", contentPurpose) +singleWrapper.putInContext("forumId", contentIdTo) -forumContent = from("Content").where("contentId", contentIdTo).cache(true).queryOne(); -statusId = "CTNT_PUBLISHED"; +forumContent = from("Content").where("contentId", contentIdTo).cache(true).queryOne() +statusId = "CTNT_PUBLISHED" if (forumContent) { - statusId = forumContent.statusId; + statusId = forumContent.statusId if (!statusId) { - statusId = page.statusId; + statusId = page.statusId } if (!statusId) { - statusId = "CTNT_PUBLISHED"; + statusId = "CTNT_PUBLISHED" } } -singleWrapper.putInContext("statusId", statusId); +singleWrapper.putInContext("statusId", statusId) -siteAncestorList = []; -siteAncestorList.add(contentIdTo); -context.siteAncestorList = siteAncestorList; -//Debug.logInfo("in viewprep, siteAncestorList:" + siteAncestorList,""); +siteAncestorList = [] +siteAncestorList.add(contentIdTo) +context.siteAncestorList = siteAncestorList +//Debug.logInfo("in viewprep, siteAncestorList:" + siteAncestorList,"") diff --git a/ecommerce/groovyScripts/forum/ContentPrep.groovy b/ecommerce/groovyScripts/forum/ContentPrep.groovy index d021fe041..ba3a608ed 100644 --- a/ecommerce/groovyScripts/forum/ContentPrep.groovy +++ b/ecommerce/groovyScripts/forum/ContentPrep.groovy @@ -17,113 +17,113 @@ * under the License. */ -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.base.util.template.FreeMarkerWorker; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.security.*; -import org.apache.ofbiz.service.*; -import org.apache.ofbiz.entity.model.*; -import org.apache.ofbiz.webapp.ftl.FreeMarkerViewHandler; -import org.apache.ofbiz.content.content.ContentWorker; -import org.apache.ofbiz.content.ContentManagementWorker; +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.base.util.template.FreeMarkerWorker +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.security.* +import org.apache.ofbiz.service.* +import org.apache.ofbiz.entity.model.* +import org.apache.ofbiz.webapp.ftl.FreeMarkerViewHandler +import org.apache.ofbiz.content.content.ContentWorker +import org.apache.ofbiz.content.ContentManagementWorker -import java.io.StringWriter; -import freemarker.template.SimpleHash; -import freemarker.template.WrappingTemplateModel; +import java.io.StringWriter +import freemarker.template.SimpleHash +import freemarker.template.WrappingTemplateModel -import javax.servlet.*; -import javax.servlet.http.*; +import javax.servlet.* +import javax.servlet.http.* // load edit or create Content form -rootPubPt = parameters.webSiteId; -//Debug.logInfo("in contentprep, security:" + security, ""); +rootPubPt = parameters.webSiteId +//Debug.logInfo("in contentprep, security:" + security, "") -singleWrapper = context.singleWrapper; +singleWrapper = context.singleWrapper -paramMap = UtilHttp.getParameterMap(request); -contentId = ""; -contentId = ContentManagementWorker.getFromSomewhere("masterContentId", paramMap, request, context); +paramMap = UtilHttp.getParameterMap(request) +contentId = "" +contentId = ContentManagementWorker.getFromSomewhere("masterContentId", paramMap, request, context) if (!contentId) - contentId = ContentManagementWorker.getFromSomewhere("contentIdTo", paramMap, request, context); + contentId = ContentManagementWorker.getFromSomewhere("contentIdTo", paramMap, request, context) if (!contentId) - contentId = ContentManagementWorker.getFromSomewhere("contentId", paramMap, request, context); + contentId = ContentManagementWorker.getFromSomewhere("contentId", paramMap, request, context) -//Debug.logInfo("in contentprep, contentId(1):" + contentId, ""); -currentValue = parameters.currentValue; -//Debug.logInfo("in contentprep, currentValue(0):" + currentValue, ""); +//Debug.logInfo("in contentprep, contentId(1):" + contentId, "") +currentValue = parameters.currentValue +//Debug.logInfo("in contentprep, currentValue(0):" + currentValue, "") if (!contentId && currentValue) { - contentId = currentValue.contentId; + contentId = currentValue.contentId } if (contentId && !currentValue) { - currentValue = from("Content").where("contentId", contentId).cache(true).queryOne(); + currentValue = from("Content").where("contentId", contentId).cache(true).queryOne() } -//Debug.logInfo("in contentprep, currentValue(1):" + currentValue, ""); -//Debug.logInfo("in contentprep, contentId(4):" + contentId, ""); +//Debug.logInfo("in contentprep, currentValue(1):" + currentValue, "") +//Debug.logInfo("in contentprep, contentId(4):" + contentId, "") if (currentValue) { - dataResourceId = currentValue.dataResourceId; - context.contentId = contentId; - context.contentName = currentValue.contentName; - context.description = currentValue.description; - context.statusId = currentValue.statusId; + dataResourceId = currentValue.dataResourceId + context.contentId = contentId + context.contentName = currentValue.contentName + context.description = currentValue.description + context.statusId = currentValue.statusId - mimeTypeId = currentValue.mimeTypeId; - rootDir = request.getSession().getServletContext().getRealPath("/"); - wrapper = FreeMarkerWorker.getDefaultOfbizWrapper(); - WrappingTemplateModel.setDefaultObjectWrapper(wrapper); - //templateRoot = new SimpleHash(wrapper); - templateRoot = [:]; - FreeMarkerViewHandler.prepOfbizRoot(templateRoot, request, response); + mimeTypeId = currentValue.mimeTypeId + rootDir = request.getSession().getServletContext().getRealPath("/") + wrapper = FreeMarkerWorker.getDefaultOfbizWrapper() + WrappingTemplateModel.setDefaultObjectWrapper(wrapper) + //templateRoot = new SimpleHash(wrapper) + templateRoot = [:] + FreeMarkerViewHandler.prepOfbizRoot(templateRoot, request, response) - ctx = [:]; - ctx.rootDir = rootDir; + ctx = [:] + ctx.rootDir = rootDir // webSiteId and https need to go here, too - templateRoot.context = ctx; - fromDate = nowTimestamp; - assocTypes = null; - //assocTypes = ["SUB_CONTENT"]; - subContentDataResourceView = ContentWorker.getSubContent(delegator, contentId, "ARTICLE", null, userLogin, assocTypes, fromDate); + templateRoot.context = ctx + fromDate = nowTimestamp + assocTypes = null + //assocTypes = ["SUB_CONTENT"] + subContentDataResourceView = ContentWorker.getSubContent(delegator, contentId, "ARTICLE", null, userLogin, assocTypes, fromDate) if (subContentDataResourceView) { - out = new StringWriter(); - ContentWorker.renderContentAsText(dispatcher, delegator, null, out, templateRoot, subContentDataResourceView, locale, mimeTypeId, true); - textData = out.toString(); - context.txtContentId = subContentDataResourceView.contentId; - context.txtDataResourceId = subContentDataResourceView.dataResourceId; - context.textData = textData; - //Debug.logInfo("textId:" + txtContentId, ""); - //Debug.logInfo("textData:" + textData, ""); + out = new StringWriter() + ContentWorker.renderContentAsText(dispatcher, delegator, null, out, templateRoot, subContentDataResourceView, locale, mimeTypeId, true) + textData = out.toString() + context.txtContentId = subContentDataResourceView.contentId + context.txtDataResourceId = subContentDataResourceView.dataResourceId + context.textData = textData + //Debug.logInfo("textId:" + txtContentId, "") + //Debug.logInfo("textData:" + textData, "") if (singleWrapper) { - //Debug.logInfo("textData:" + textData, ""); - singleWrapper.putInContext("textData", textData); + //Debug.logInfo("textData:" + textData, "") + singleWrapper.putInContext("textData", textData) } } - subContentDataResourceView = ContentWorker.getSubContent(dispatcher, delegator, contentId, "SUMMARY", null, userLogin, assocTypes, fromDate, true); + subContentDataResourceView = ContentWorker.getSubContent(dispatcher, delegator, contentId, "SUMMARY", null, userLogin, assocTypes, fromDate, true) if (subContentDataResourceView) { - out = new StringWriter(); - ContentWorker.renderContentAsText(delegator, null, out, templateRoot, subContentDataResourceView, locale, mimeTypeId); - summaryData = out.toString(); - context.sumContentId = subContentDataResourceView.contentId; - context.sumDataResourceId = subContentDataResourceView.dataResourceId; - context.summaryData = summaryData; - //Debug.logInfo("sumId:" + sumContentId, ""); - //Debug.logInfo("summaryData:" + summaryData, ""); + out = new StringWriter() + ContentWorker.renderContentAsText(delegator, null, out, templateRoot, subContentDataResourceView, locale, mimeTypeId) + summaryData = out.toString() + context.sumContentId = subContentDataResourceView.contentId + context.sumDataResourceId = subContentDataResourceView.dataResourceId + context.summaryData = summaryData + //Debug.logInfo("sumId:" + sumContentId, "") + //Debug.logInfo("summaryData:" + summaryData, "") if (singleWrapper) { - //Debug.logInfo("summaryData:" + summaryData, ""); - singleWrapper.putInContext("summaryData", summaryData); + //Debug.logInfo("summaryData:" + summaryData, "") + singleWrapper.putInContext("summaryData", summaryData) } } - subContentDataResourceView = ContentWorker.getSubContent(dispatcher, delegator, contentId, "IMAGE", null, userLogin, assocTypes, fromDate, true); + subContentDataResourceView = ContentWorker.getSubContent(dispatcher, delegator, contentId, "IMAGE", null, userLogin, assocTypes, fromDate, true) if (subContentDataResourceView) { - out = new StringWriter(); - ContentWorker.renderContentAsText(delegator, null, out, templateRoot, subContentDataResourceView, locale, mimeTypeId); - imageData = out.toString(); - context.imgContentId = subContentDataResourceView.contentId; - context.imgDataResourceId = subContentDataResourceView.dataResourceId; - context.imageData = imageData; + out = new StringWriter() + ContentWorker.renderContentAsText(delegator, null, out, templateRoot, subContentDataResourceView, locale, mimeTypeId) + imageData = out.toString() + context.imgContentId = subContentDataResourceView.contentId + context.imgDataResourceId = subContentDataResourceView.dataResourceId + context.imageData = imageData } } diff --git a/ecommerce/groovyScripts/forum/CurrentValPrep.groovy b/ecommerce/groovyScripts/forum/CurrentValPrep.groovy index 124f45578..bca27d61c 100644 --- a/ecommerce/groovyScripts/forum/CurrentValPrep.groovy +++ b/ecommerce/groovyScripts/forum/CurrentValPrep.groovy @@ -17,131 +17,131 @@ * under the License. */ -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.security.*; -import org.apache.ofbiz.service.*; -import org.apache.ofbiz.entity.model.*; -import org.apache.ofbiz.content.ContentManagementWorker; +import java.util.ArrayList +import java.util.Collection +import java.util.HashMap +import java.util.Iterator +import java.util.LinkedList +import java.util.List +import java.util.Map +import java.util.Set +import java.util.TreeSet +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.security.* +import org.apache.ofbiz.service.* +import org.apache.ofbiz.entity.model.* +import org.apache.ofbiz.content.ContentManagementWorker -import javax.servlet.*; -import javax.servlet.http.*; +import javax.servlet.* +import javax.servlet.http.* -currentEntityMap = session.getAttribute("currentEntityMap"); +currentEntityMap = session.getAttribute("currentEntityMap") if (!currentEntityMap) { - currentEntityMap = [:]; - session.setAttribute("currentEntityMap", currentEntityMap); + currentEntityMap = [:] + session.setAttribute("currentEntityMap", currentEntityMap) } -entityName = context.entityName; -currentEntityPropertyName = parameters.currentEntityPropertyName; +entityName = context.entityName +currentEntityPropertyName = parameters.currentEntityPropertyName if (!currentEntityPropertyName) { - currentEntityName = entityName; + currentEntityName = entityName } else { - currentEntityName = parameters[currentEntityPropertyName]; + currentEntityName = parameters[currentEntityPropertyName] } -//Debug.logInfo("in currentvalprep, currentEntityName:" + currentEntityName,""); -cachedPK = currentEntityMap[currentEntityName]; -//Debug.logInfo("in currentvalprep, cachedPK:" + cachedPK,""); +//Debug.logInfo("in currentvalprep, currentEntityName:" + currentEntityName,"") +cachedPK = currentEntityMap[currentEntityName] +//Debug.logInfo("in currentvalprep, cachedPK:" + cachedPK,"") // Build a key from param or attribute values. -paramMap = UtilHttp.getParameterMap(request); -//Debug.logInfo("paramMap:" + paramMap, null); -v = delegator.makeValue(currentEntityName); -passedPK = v.getPrimaryKey(); -keyColl = passedPK.getAllKeys(); -keyIt = keyColl.iterator(); +paramMap = UtilHttp.getParameterMap(request) +//Debug.logInfo("paramMap:" + paramMap, null) +v = delegator.makeValue(currentEntityName) +passedPK = v.getPrimaryKey() +keyColl = passedPK.getAllKeys() +keyIt = keyColl.iterator() while (keyIt.hasNext()) { - attrName = keyIt.next(); - attrVal = parameters[attrName]; - //Debug.logInfo("in currentvalprep, attrName:" + attrName,""); - //Debug.logInfo("in currentvalprep, attrVal:" + attrVal,""); + attrName = keyIt.next() + attrVal = parameters[attrName] + //Debug.logInfo("in currentvalprep, attrName:" + attrName,"") + //Debug.logInfo("in currentvalprep, attrVal:" + attrVal,"") if (attrVal) { - passedPK[attrName] = attrVal; + passedPK[attrName] = attrVal } } -//Debug.logInfo("in currentvalprep, passedPK:" + passedPK,""); +//Debug.logInfo("in currentvalprep, passedPK:" + passedPK,"") // messed up code to determine whether or not the cached or passed keys have missing fields, // in which case, the valid one is used to retrieve the current value -pksEqual = true; +pksEqual = true if (cachedPK) { - keyColl = cachedPK.getPrimaryKey().getAllKeys(); - keyIt = keyColl.iterator(); + keyColl = cachedPK.getPrimaryKey().getAllKeys() + keyIt = keyColl.iterator() while (keyIt.hasNext()) { - sCached = null; - sPassed = null; - oCached = null; - oCached = null; - ky = keyIt.next(); - oPassed = passedPK[ky]; + sCached = null + sPassed = null + oCached = null + oCached = null + ky = keyIt.next() + oPassed = passedPK[ky] if (oPassed) { - sPassed = oPassed; + sPassed = oPassed if (!sPassed) { - pksEqual = false; + pksEqual = false } else { - oCached = cachedPK[ky]; + oCached = cachedPK[ky] if (oCached) { - sCached = oCached; + sCached = oCached if (!sPassed) { - pksEqual = false; + pksEqual = false } else { if (!sPassed.equals(sCached)) { - //pksEqual = true; + //pksEqual = true } } } } } else { - pksEqual = false; + pksEqual = false } } } -currentPK = passedPK; +currentPK = passedPK if (!pksEqual) { - currentPK = cachedPK; + currentPK = cachedPK // all other condition result in currentPK = passedPK } -//Debug.logInfo("in currentvalprep, currentPK:" + currentPK,""); +//Debug.logInfo("in currentvalprep, currentPK:" + currentPK,"") -currentEntityMap[currentEntityName] = currentPK; -request.setAttribute("currentPK", currentPK); -context.currentPK = currentPK; -currentValue = from(currentPK.getPrimaryKey().getEntityName()).where(currentPK.getPrimaryKey()).queryOne(); -context.currentValue = currentValue; -request.setAttribute("currentValue", currentValue); +currentEntityMap[currentEntityName] = currentPK +request.setAttribute("currentPK", currentPK) +context.currentPK = currentPK +currentValue = from(currentPK.getPrimaryKey().getEntityName()).where(currentPK.getPrimaryKey()).queryOne() +context.currentValue = currentValue +request.setAttribute("currentValue", currentValue) -// Debug.logInfo("===========in currentvalprep, currentValue:" + request.getAttribute("currentValue"),""); +// Debug.logInfo("===========in currentvalprep, currentValue:" + request.getAttribute("currentValue"),"") if (currentValue) { if (currentEntityName.indexOf("DataResource") >= 0) { - suffix = ""; - s = currentValue.dataResourceTypeId ?: currentValue.drDataResourceTypeId; - if (s) suffix = "_" + s; + suffix = "" + s = currentValue.dataResourceTypeId ?: currentValue.drDataResourceTypeId + if (s) suffix = "_" + s if ("_ELECTRONIC_TEXT".equals(suffix)) { - s = currentValue.mimeTypeId ?: currentValue.drMimeTypeId; - if (s) suffix += "_" + s; + s = currentValue.mimeTypeId ?: currentValue.drMimeTypeId + if (s) suffix += "_" + s } - //Debug.logInfo("in currentvalprep, suffix:" + suffix,""); + //Debug.logInfo("in currentvalprep, suffix:" + suffix,"") // if (suffix) { -// ContentManagementWorker.mruAdd(session, currentPK, suffix); +// ContentManagementWorker.mruAdd(session, currentPK, suffix) // } else { - ContentManagementWorker.mruAdd(session, currentPK); + ContentManagementWorker.mruAdd(session, currentPK) // } } else { - ContentManagementWorker.mruAdd(session, currentPK); + ContentManagementWorker.mruAdd(session, currentPK) } } -//Debug.logInfo("in currentvalprep, contentId:" + request.getAttribute("contentId"),""); +//Debug.logInfo("in currentvalprep, contentId:" + request.getAttribute("contentId"),"") diff --git a/ecommerce/groovyScripts/forum/EditAddPrep.groovy b/ecommerce/groovyScripts/forum/EditAddPrep.groovy index 9bf279443..6797d9b21 100644 --- a/ecommerce/groovyScripts/forum/EditAddPrep.groovy +++ b/ecommerce/groovyScripts/forum/EditAddPrep.groovy @@ -17,72 +17,72 @@ * under the License. */ -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.security.*; -import org.apache.ofbiz.service.*; -import org.apache.ofbiz.entity.model.*; -import org.apache.ofbiz.securityext.login.*; -import org.apache.ofbiz.common.*; -import org.apache.ofbiz.entity.model.*; -import org.apache.ofbiz.content.ContentManagementWorker; -import org.apache.ofbiz.content.content.ContentWorker; +import java.util.ArrayList +import java.util.Collection +import java.util.HashMap +import java.util.Iterator +import java.util.LinkedList +import java.util.List +import java.util.Map +import java.util.Set +import java.util.TreeSet +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.security.* +import org.apache.ofbiz.service.* +import org.apache.ofbiz.entity.model.* +import org.apache.ofbiz.securityext.login.* +import org.apache.ofbiz.common.* +import org.apache.ofbiz.entity.model.* +import org.apache.ofbiz.content.ContentManagementWorker +import org.apache.ofbiz.content.content.ContentWorker -import freemarker.template.SimpleHash; -import freemarker.template.SimpleSequence; +import freemarker.template.SimpleHash +import freemarker.template.SimpleSequence -import javax.servlet.*; -import javax.servlet.http.*; +import javax.servlet.* +import javax.servlet.http.* -singleWrapper = context.singleWrapper; -contentIdTo = parameters.contentIdTo; -singleWrapper.putInContext("contentIdTo", contentIdTo); -mapKey = parameters.mapKey; -singleWrapper.putInContext("mapKey", mapKey); +singleWrapper = context.singleWrapper +contentIdTo = parameters.contentIdTo +singleWrapper.putInContext("contentIdTo", contentIdTo) +mapKey = parameters.mapKey +singleWrapper.putInContext("mapKey", mapKey) if ("SUMMARY".equals(mapKey)) { - singleWrapper.putInContext("textSource", "summaryData"); + singleWrapper.putInContext("textSource", "summaryData") } else { - singleWrapper.putInContext("textSource", "textData"); + singleWrapper.putInContext("textSource", "textData") } -singleWrapper.putInContext("dataResourceTypeId", "ELECTRONIC_TEXT"); -singleWrapper.putInContext("contentAssocTypeId", "SUB_CONTENT"); -//Debug.logInfo("in editaddprep, contentIdTo:" + contentIdTo,""); -//Debug.logInfo("in editaddprep, mapKey:" + mapKey,""); -//currentValue = request.getAttribute("currentValue"); -//currentValue = request.getAttribute("currentValue"); +singleWrapper.putInContext("dataResourceTypeId", "ELECTRONIC_TEXT") +singleWrapper.putInContext("contentAssocTypeId", "SUB_CONTENT") +//Debug.logInfo("in editaddprep, contentIdTo:" + contentIdTo,"") +//Debug.logInfo("in editaddprep, mapKey:" + mapKey,"") +//currentValue = request.getAttribute("currentValue") +//currentValue = request.getAttribute("currentValue") -currentValue = ContentWorker.getSubContentCache(delegator, contentIdTo, mapKey, null, userLogin, null, null, false, null); -//Debug.logInfo("in editaddprep, currentValue:" + currentValue,""); +currentValue = ContentWorker.getSubContentCache(delegator, contentIdTo, mapKey, null, userLogin, null, null, false, null) +//Debug.logInfo("in editaddprep, currentValue:" + currentValue,"") if (!currentValue) { - parentValue = from("Content").where("contentId", contentIdTo).cache(true).queryOne(); - currentValue = delegator.makeValue("Content"); - subject = parentValue.contentName; + parentValue = from("Content").where("contentId", contentIdTo).cache(true).queryOne() + currentValue = delegator.makeValue("Content") + subject = parentValue.contentName if ("SUMMARY".equals(mapKey)) { - subject = "Short " + subject; + subject = "Short " + subject } - currentValue.contentName = subject; - currentValue.description = subject; - singleWrapper.putInContext("contentTypeId", "DOCUMENT"); + currentValue.contentName = subject + currentValue.description = subject + singleWrapper.putInContext("contentTypeId", "DOCUMENT") } else { - singleWrapper.putInContext("contentTypeId", null); - //Debug.logInfo("in editaddprep, currentValue:" + currentValue,""); + singleWrapper.putInContext("contentTypeId", null) + //Debug.logInfo("in editaddprep, currentValue:" + currentValue,"") } -singleWrapper.putInContext("currentValue", currentValue); -context.currentValue = currentValue; -request.setAttribute("currentValue", currentValue); -persistAction = parameters.persistAction ?: "persistContent"; +singleWrapper.putInContext("currentValue", currentValue) +context.currentValue = currentValue +request.setAttribute("currentValue", currentValue) +persistAction = parameters.persistAction ?: "persistContent" -singleWrapper.putInContext("persistAction", persistAction); -//Debug.logInfo("in editaddprep, currentValue:" + currentValue,""); +singleWrapper.putInContext("persistAction", persistAction) +//Debug.logInfo("in editaddprep, currentValue:" + currentValue,"") diff --git a/ecommerce/groovyScripts/forum/HtmlAreaPrep.groovy b/ecommerce/groovyScripts/forum/HtmlAreaPrep.groovy index 6e3728589..4be9ac6d2 100644 --- a/ecommerce/groovyScripts/forum/HtmlAreaPrep.groovy +++ b/ecommerce/groovyScripts/forum/HtmlAreaPrep.groovy @@ -17,25 +17,25 @@ * under the License. */ -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.security.*; -import org.apache.ofbiz.service.*; -import org.apache.ofbiz.entity.model.*; -import org.apache.ofbiz.content.data.DataResourceWorker; -import org.apache.ofbiz.webapp.ftl.FreeMarkerViewHandler; +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.security.* +import org.apache.ofbiz.service.* +import org.apache.ofbiz.entity.model.* +import org.apache.ofbiz.content.data.DataResourceWorker +import org.apache.ofbiz.webapp.ftl.FreeMarkerViewHandler -import java.io.StringWriter; -import freemarker.ext.beans.BeansWrapper; -import freemarker.template.SimpleHash; -import freemarker.template.WrappingTemplateModel; +import java.io.StringWriter +import freemarker.ext.beans.BeansWrapper +import freemarker.template.SimpleHash +import freemarker.template.WrappingTemplateModel -import javax.servlet.*; -import javax.servlet.http.*; +import javax.servlet.* +import javax.servlet.http.* -contentIdTo = parameters.contentIdTo; +contentIdTo = parameters.contentIdTo if (!contentIdTo || !contentIdTo.equals("TEMPLATE_MASTER")) { - context.dynamicPrimaryHTMLField = "textData"; + context.dynamicPrimaryHTMLField = "textData" } diff --git a/ecommerce/groovyScripts/forum/NodeTrailPrep.groovy b/ecommerce/groovyScripts/forum/NodeTrailPrep.groovy index becd74f39..389cb4976 100644 --- a/ecommerce/groovyScripts/forum/NodeTrailPrep.groovy +++ b/ecommerce/groovyScripts/forum/NodeTrailPrep.groovy @@ -17,64 +17,64 @@ * under the License. */ -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; +import java.util.ArrayList +import java.util.Collection +import java.util.HashMap +import java.util.Iterator +import java.util.LinkedList +import java.util.List +import java.util.Map +import java.util.Set +import java.util.TreeSet -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.security.*; -import org.apache.ofbiz.service.*; -import org.apache.ofbiz.entity.model.*; -import org.apache.ofbiz.securityext.login.*; -import org.apache.ofbiz.common.*; -import org.apache.ofbiz.entity.model.*; -import org.apache.ofbiz.content.content.ContentWorker; -import org.apache.ofbiz.content.ContentManagementWorker; +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.security.* +import org.apache.ofbiz.service.* +import org.apache.ofbiz.entity.model.* +import org.apache.ofbiz.securityext.login.* +import org.apache.ofbiz.common.* +import org.apache.ofbiz.entity.model.* +import org.apache.ofbiz.content.content.ContentWorker +import org.apache.ofbiz.content.ContentManagementWorker -import javax.servlet.*; -import javax.servlet.http.*; +import javax.servlet.* +import javax.servlet.http.* -nodeTrailCsv = ContentManagementWorker.getFromSomewhere("nodeTrailCsv", parameters, request, context); -passedParams = null; +nodeTrailCsv = ContentManagementWorker.getFromSomewhere("nodeTrailCsv", parameters, request, context) +passedParams = null if (!nodeTrailCsv) { // this only happens in UploadContentAndImage - passedParams = request.getAttribute("passedParams"); + passedParams = request.getAttribute("passedParams") if (passedParams) { - nodeTrailCsv = passedParams.nodeTrailCsv; + nodeTrailCsv = passedParams.nodeTrailCsv } } if (nodeTrailCsv) { - nodeTrail = ContentWorker.csvToTrail(nodeTrailCsv, delegator); - context.globalNodeTrail = nodeTrail; - singleWrapper = context.singleWrapper; + nodeTrail = ContentWorker.csvToTrail(nodeTrailCsv, delegator) + context.globalNodeTrail = nodeTrail + singleWrapper = context.singleWrapper if (singleWrapper) { - singleWrapper.putInContext("nodeTrailCsv",nodeTrailCsv); + singleWrapper.putInContext("nodeTrailCsv",nodeTrailCsv) // there might be another way to do this, but if the widget form def already has a default-map // (such as "currentValue"), then I don't know how to reference another map (defined in the // field def via "map-name", except to do this. // What I want to do is specify 'map-name=""' and have it use the context main - Map dummy = singleWrapper.getFromContext("dummy"); + Map dummy = singleWrapper.getFromContext("dummy") if (!dummy) { - dummy = [:]; + dummy = [:] } - dummy.nodeTrailCsv = nodeTrailCsv; - //Debug.logInfo("in nodetrailprep, dummy:" + dummy,""); - singleWrapper.putInContext("dummy",dummy); + dummy.nodeTrailCsv = nodeTrailCsv + //Debug.logInfo("in nodetrailprep, dummy:" + dummy,"") + singleWrapper.putInContext("dummy",dummy) } - context.nodeTrailCsv = nodeTrailCsv; + context.nodeTrailCsv = nodeTrailCsv - //Debug.logInfo("in nodetrailprep, nodeTrailCsv:" + nodeTrailCsv,""); - trailContentList = ContentWorker.csvToContentList(nodeTrailCsv, delegator); - //Debug.logInfo("in nodetrailprep, trailContentList:" + trailContentList,""); - context.ancestorList = trailContentList; - //Debug.logInfo("in vewprep, siteAncestorList:" + siteAncestorList,""); + //Debug.logInfo("in nodetrailprep, nodeTrailCsv:" + nodeTrailCsv,"") + trailContentList = ContentWorker.csvToContentList(nodeTrailCsv, delegator) + //Debug.logInfo("in nodetrailprep, trailContentList:" + trailContentList,"") + context.ancestorList = trailContentList + //Debug.logInfo("in vewprep, siteAncestorList:" + siteAncestorList,"") } diff --git a/ecommerce/groovyScripts/forum/OwnerContentPrep.groovy b/ecommerce/groovyScripts/forum/OwnerContentPrep.groovy index d9b491604..81e2b4cd1 100644 --- a/ecommerce/groovyScripts/forum/OwnerContentPrep.groovy +++ b/ecommerce/groovyScripts/forum/OwnerContentPrep.groovy @@ -17,62 +17,62 @@ * under the License. */ -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.security.*; -import org.apache.ofbiz.service.*; -import org.apache.ofbiz.entity.model.*; -import org.apache.ofbiz.content.data.DataResourceWorker; -import org.apache.ofbiz.webapp.ftl.FreeMarkerViewHandler; -import org.apache.ofbiz.content.content.ContentWorker; -import org.apache.ofbiz.content.ContentManagementWorker; +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.security.* +import org.apache.ofbiz.service.* +import org.apache.ofbiz.entity.model.* +import org.apache.ofbiz.content.data.DataResourceWorker +import org.apache.ofbiz.webapp.ftl.FreeMarkerViewHandler +import org.apache.ofbiz.content.content.ContentWorker +import org.apache.ofbiz.content.ContentManagementWorker -import java.io.StringWriter; -import freemarker.ext.beans.BeansWrapper; -import freemarker.template.SimpleHash; -import freemarker.template.WrappingTemplateModel; +import java.io.StringWriter +import freemarker.ext.beans.BeansWrapper +import freemarker.template.SimpleHash +import freemarker.template.WrappingTemplateModel -import javax.servlet.*; -import javax.servlet.http.*; +import javax.servlet.* +import javax.servlet.http.* // load edit or create Content form -//Debug.logInfo("in ownerprep, security:" + security, ""); +//Debug.logInfo("in ownerprep, security:" + security, "") -rootPubPt = parameters.webSiteId; -//Debug.logInfo("in ownerprep, rootPubPt:" + rootPubPt, ""); -entityAction = page.entityOperation; -permittedOperations = page.permittedOperations; +rootPubPt = parameters.webSiteId +//Debug.logInfo("in ownerprep, rootPubPt:" + rootPubPt, "") +entityAction = page.entityOperation +permittedOperations = page.permittedOperations -allDepartmentContentList = ContentManagementWorker.getAllDepartmentContent(delegator, rootPubPt); -//Debug.logInfo("in ownercontentprep, allDepartmentContentList:" + allDepartmentContentList, ""); -departmentPointList = ContentManagementWorker.getPermittedDepartmentPoints( delegator, allDepartmentContentList, userLogin, security, entityAction, "CONTENT_CREATE", null ); -//Debug.logInfo("in ownercontentprep, departmentPointList:" + departmentPointList, ""); -departmentPointMap = [:]; -departmentPointMapAll = [:]; -ownerContentList = []; +allDepartmentContentList = ContentManagementWorker.getAllDepartmentContent(delegator, rootPubPt) +//Debug.logInfo("in ownercontentprep, allDepartmentContentList:" + allDepartmentContentList, "") +departmentPointList = ContentManagementWorker.getPermittedDepartmentPoints( delegator, allDepartmentContentList, userLogin, security, entityAction, "CONTENT_CREATE", null ) +//Debug.logInfo("in ownercontentprep, departmentPointList:" + departmentPointList, "") +departmentPointMap = [:] +departmentPointMapAll = [:] +ownerContentList = [] departmentPointList.each { arr -> - contentId = arr[0]; - description = arr[1]; - subPointList = []; - lineMap = [:]; - lineMap.contentId = contentId; - lineMap.description = description.toUpperCase(); - ownerContentList.add(lineMap); - subDepartmentContentList = ContentManagementWorker.getAllDepartmentContent(delegator, contentId); + contentId = arr[0] + description = arr[1] + subPointList = [] + lineMap = [:] + lineMap.contentId = contentId + lineMap.description = description.toUpperCase() + ownerContentList.add(lineMap) + subDepartmentContentList = ContentManagementWorker.getAllDepartmentContent(delegator, contentId) subDepartmentContentList.each { departmentPoint2 -> - contentId2 = departmentPoint2.contentId; - description2 = departmentPoint2.templateTitle; - lineMap2 = [:]; - lineMap2.contentId = contentId2; - lineMap2.description = "   -" + description2; - ownerContentList.add(lineMap2); + contentId2 = departmentPoint2.contentId + description2 = departmentPoint2.templateTitle + lineMap2 = [:] + lineMap2.contentId = contentId2 + lineMap2.description = "   -" + description2 + ownerContentList.add(lineMap2) } } -//Debug.logInfo("in ownercontentprep, ownerContentList:" + ownerContentList, ""); +//Debug.logInfo("in ownercontentprep, ownerContentList:" + ownerContentList, "") -pubPt = context.pubPt; -//Debug.logInfo("in ownercontentprep, pubPt:" + pubPt, ""); -singleWrapper = context.singleWrapper; -singleWrapper.putInContext("ownerContentList", ownerContentList); -singleWrapper.putInContext("pubPt", pubPt); +pubPt = context.pubPt +//Debug.logInfo("in ownercontentprep, pubPt:" + pubPt, "") +singleWrapper = context.singleWrapper +singleWrapper.putInContext("ownerContentList", ownerContentList) +singleWrapper.putInContext("pubPt", pubPt) diff --git a/ecommerce/groovyScripts/forum/PermPrep.groovy b/ecommerce/groovyScripts/forum/PermPrep.groovy index 9f6013ccc..3b2cf4207 100644 --- a/ecommerce/groovyScripts/forum/PermPrep.groovy +++ b/ecommerce/groovyScripts/forum/PermPrep.groovy @@ -17,149 +17,149 @@ * under the License. */ -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; +import java.util.ArrayList +import java.util.Collection +import java.util.HashMap +import java.util.Iterator +import java.util.LinkedList +import java.util.List +import java.util.Map +import java.util.Set +import java.util.TreeSet -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.security.*; -import org.apache.ofbiz.service.*; -import org.apache.ofbiz.entity.model.*; -import org.apache.ofbiz.content.content.PermissionRecorder; -import org.apache.ofbiz.content.ContentManagementWorker; +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.security.* +import org.apache.ofbiz.service.* +import org.apache.ofbiz.entity.model.* +import org.apache.ofbiz.content.content.PermissionRecorder +import org.apache.ofbiz.content.ContentManagementWorker -import javax.servlet.*; -import javax.servlet.http.*; +import javax.servlet.* +import javax.servlet.http.* -paramMap = UtilHttp.getParameterMap(request); -//Debug.logInfo("in permprep, userLogin(0):" + userLogin, null); +paramMap = UtilHttp.getParameterMap(request) +//Debug.logInfo("in permprep, userLogin(0):" + userLogin, null) // Get permission from pagedef config file -permission = context.permission; -permissionType = context.permissionType ?: "simple"; +permission = context.permission +permissionType = context.permissionType ?: "simple" -entityName = context.entityName; -entityOperation = context.entityOperation; -targetOperation = context.targetOperation; -//Debug.logInfo("in permprep, targetOperation(0):" + targetOperation, null); +entityName = context.entityName +entityOperation = context.entityOperation +targetOperation = context.targetOperation +//Debug.logInfo("in permprep, targetOperation(0):" + targetOperation, null) -mode = paramMap.mode; -//Debug.logInfo("in permprep, contentId(0):" + request.getAttribute("contentId"),""); -currentValue = request.getAttribute("currentValue"); -//Debug.logInfo("in permprep, paramMap(1):" + paramMap, null); -//Debug.logInfo("in permprep, currentValue(1):" + currentValue, null); +mode = paramMap.mode +//Debug.logInfo("in permprep, contentId(0):" + request.getAttribute("contentId"),"") +currentValue = request.getAttribute("currentValue") +//Debug.logInfo("in permprep, paramMap(1):" + paramMap, null) +//Debug.logInfo("in permprep, currentValue(1):" + currentValue, null) if ("add".equals(mode)) { - entityOperation = context.addEntityOperation ?: context.entityOperation ?: "_CREATE"; - targetOperation = context.addTargetOperation ?: context.get("targetOperation") ?: "CONTENT_CREATE"; - //org.apache.ofbiz.base.util.Debug.logInfo("in permprep, targetOperation:" + targetOperation, null); + entityOperation = context.addEntityOperation ?: context.entityOperation ?: "_CREATE" + targetOperation = context.addTargetOperation ?: context.get("targetOperation") ?: "CONTENT_CREATE" + //org.apache.ofbiz.base.util.Debug.logInfo("in permprep, targetOperation:" + targetOperation, null) } else { if (!entityOperation) { - entityOperation = "_UPDATE"; + entityOperation = "_UPDATE" } if (!targetOperation) { - targetOperation = "CONTENT_UPDATE"; + targetOperation = "CONTENT_UPDATE" } } if (permissionType.equals("complex")) { - mapIn = [:]; - mapIn.userLogin = userLogin; - targetOperationList = StringUtil.split(targetOperation, "|"); - mapIn.targetOperationList = targetOperationList; - thisContentId = null; + mapIn = [:] + mapIn.userLogin = userLogin + targetOperationList = StringUtil.split(targetOperation, "|") + mapIn.targetOperationList = targetOperationList + thisContentId = null - //Debug.logInfo("in permprep, userLogin(1):" + userLogin, null); + //Debug.logInfo("in permprep, userLogin(1):" + userLogin, null) //if (userLogin != null) { - //Debug.logInfo("in permprep, userLoginId(1):" + userLogin.get("userLoginId"), null); + //Debug.logInfo("in permprep, userLoginId(1):" + userLogin.get("userLoginId"), null) //} if (!currentValue || !"Content".equals(entityName)) { - permissionIdName = context.permissionIdName; - //org.apache.ofbiz.base.util.Debug.logInfo("in permprep, permissionIdName(1):" + permissionIdName, null); + permissionIdName = context.permissionIdName + //org.apache.ofbiz.base.util.Debug.logInfo("in permprep, permissionIdName(1):" + permissionIdName, null) if (!permissionIdName) { - thisContentId = ContentManagementWorker.getFromSomewhere(permissionIdName, paramMap, request, context); + thisContentId = ContentManagementWorker.getFromSomewhere(permissionIdName, paramMap, request, context) } else if (!thisContentId) { - thisContentId = ContentManagementWorker.getFromSomewhere("subContentId", paramMap, request, context); + thisContentId = ContentManagementWorker.getFromSomewhere("subContentId", paramMap, request, context) } else if (!thisContentId) { - thisContentId = ContentManagementWorker.getFromSomewhere("contentIdTo", paramMap, request, context); + thisContentId = ContentManagementWorker.getFromSomewhere("contentIdTo", paramMap, request, context) } else if (!thisContentId) { - thisContentId = ContentManagementWorker.getFromSomewhere("contentId", paramMap, request, context); + thisContentId = ContentManagementWorker.getFromSomewhere("contentId", paramMap, request, context) } - //org.apache.ofbiz.base.util.Debug.logInfo("in permprep, thisContentId(2):" + thisContentId, null); + //org.apache.ofbiz.base.util.Debug.logInfo("in permprep, thisContentId(2):" + thisContentId, null) } else { - thisContentId = currentValue.contentId; + thisContentId = currentValue.contentId } - //org.apache.ofbiz.base.util.Debug.logInfo("in permprep, thisContentId(3):" + thisContentId, null); + //org.apache.ofbiz.base.util.Debug.logInfo("in permprep, thisContentId(3):" + thisContentId, null) if (!currentValue || !"Content".equals(entityName)) { if (thisContentId) { - currentValue = from("Content").where("contentId", thisContentId).queryOne(); + currentValue = from("Content").where("contentId", thisContentId).queryOne() } } if ("add".equals(mode)) { - addEntityOperation = context.addEntityOperation; + addEntityOperation = context.addEntityOperation if (addEntityOperation) { - entityOperation = addEntityOperation; + entityOperation = addEntityOperation } } else { - editEntityOperation = context.editEntityOperation; + editEntityOperation = context.editEntityOperation if (editEntityOperation) { - entityOperation = editEntityOperation; + entityOperation = editEntityOperation } } - //org.apache.ofbiz.base.util.Debug.logInfo("in permprep, currentValue(2):" + currentValue, null); + //org.apache.ofbiz.base.util.Debug.logInfo("in permprep, currentValue(2):" + currentValue, null) if ("Content".equals(currentValue?.getEntityName())) { - mapIn.currentContent = currentValue; + mapIn.currentContent = currentValue } - mapIn.entityOperation = entityOperation; + mapIn.entityOperation = entityOperation - contentPurposeTypeId = context.contentPurposeTypeId; + contentPurposeTypeId = context.contentPurposeTypeId if (contentPurposeTypeId) { - mapIncontentPurposeList = StringUtil.split(contentPurposeTypeId, "|"); + mapIncontentPurposeList = StringUtil.split(contentPurposeTypeId, "|") } - //org.apache.ofbiz.base.util.Debug.logInfo("in permprep, mapIn:" + mapIn, null); - result = runService('checkContentPermission', mapIn); - permissionStatus = result.permissionStatus; - //org.apache.ofbiz.base.util.Debug.logInfo("in permprep, permissionStatus:" + permissionStatus, null); + //org.apache.ofbiz.base.util.Debug.logInfo("in permprep, mapIn:" + mapIn, null) + result = runService('checkContentPermission', mapIn) + permissionStatus = result.permissionStatus + //org.apache.ofbiz.base.util.Debug.logInfo("in permprep, permissionStatus:" + permissionStatus, null) if ("granted".equals(permissionStatus)) { - context.hasPermission = true; - request.setAttribute("hasPermission", true); - request.setAttribute("permissionStatus", "granted"); + context.hasPermission = true + request.setAttribute("hasPermission", true) + request.setAttribute("permissionStatus", "granted") } else { - context.hasPermission = false; - request.setAttribute("hasPermission", false); - request.setAttribute("permissionStatus", ""); - errorMessage = "Permission to display:" + page.getPageName() + " is denied."; - recorder = result.permissionRecorder; - //Debug.logInfo("recorder(0):" + recorder, ""); + context.hasPermission = false + request.setAttribute("hasPermission", false) + request.setAttribute("permissionStatus", "") + errorMessage = "Permission to display:" + page.getPageName() + " is denied." + recorder = result.permissionRecorder + //Debug.logInfo("recorder(0):" + recorder, "") if (recorder) { - permissionMessage = recorder.toHtml(); - //Debug.logInfo("permissionMessage(0):" + permissionMessage, ""); - errorMessage += " \n " + permissionMessage; + permissionMessage = recorder.toHtml() + //Debug.logInfo("permissionMessage(0):" + permissionMessage, "") + errorMessage += " \n " + permissionMessage } - request.setAttribute("errorMsgReq", errorMessage); + request.setAttribute("errorMsgReq", errorMessage) } - //Debug.logInfo("in permprep, contentId(1):" + request.getAttribute("contentId"),""); + //Debug.logInfo("in permprep, contentId(1):" + request.getAttribute("contentId"),"") } else { - //org.apache.ofbiz.base.util.Debug.logInfo("permission:" + permission , null); - //org.apache.ofbiz.base.util.Debug.logInfo("entityOperation:" + entityOperation , null); + //org.apache.ofbiz.base.util.Debug.logInfo("permission:" + permission , null) + //org.apache.ofbiz.base.util.Debug.logInfo("entityOperation:" + entityOperation , null) if (security.hasEntityPermission(permission, entityOperation, session)) { - //org.apache.ofbiz.base.util.Debug.logInfo("hasEntityPermission is true:" , null); - context.hasPermission = true; - request.setAttribute("hasPermission", true); - request.setAttribute("permissionStatus", "granted"); + //org.apache.ofbiz.base.util.Debug.logInfo("hasEntityPermission is true:" , null) + context.hasPermission = true + request.setAttribute("hasPermission", true) + request.setAttribute("permissionStatus", "granted") } else { - //org.apache.ofbiz.base.util.Debug.logInfo("hasEntityPermission is false:" , null); - context.hasPermission = false; - request.setAttribute("hasPermission", false); - request.setAttribute("permissionStatus", ""); + //org.apache.ofbiz.base.util.Debug.logInfo("hasEntityPermission is false:" , null) + context.hasPermission = false + request.setAttribute("hasPermission", false) + request.setAttribute("permissionStatus", "") } } diff --git a/ecommerce/groovyScripts/forum/PubInit.groovy b/ecommerce/groovyScripts/forum/PubInit.groovy index 0a2ebf132..001eded07 100644 --- a/ecommerce/groovyScripts/forum/PubInit.groovy +++ b/ecommerce/groovyScripts/forum/PubInit.groovy @@ -17,40 +17,40 @@ * under the License. */ -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.security.*; -import org.apache.ofbiz.service.*; -import org.apache.ofbiz.entity.model.*; -import org.apache.ofbiz.webapp.website.WebSiteWorker; -import org.apache.ofbiz.securityext.login.*; -import org.apache.ofbiz.common.*; -import org.apache.ofbiz.entity.model.*; -import org.apache.ofbiz.content.ContentManagementWorker; +import java.util.ArrayList +import java.util.Collection +import java.util.HashMap +import java.util.Iterator +import java.util.LinkedList +import java.util.List +import java.util.Map +import java.util.Set +import java.util.TreeSet +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.security.* +import org.apache.ofbiz.service.* +import org.apache.ofbiz.entity.model.* +import org.apache.ofbiz.webapp.website.WebSiteWorker +import org.apache.ofbiz.securityext.login.* +import org.apache.ofbiz.common.* +import org.apache.ofbiz.entity.model.* +import org.apache.ofbiz.content.ContentManagementWorker -import javax.servlet.*; -import javax.servlet.http.*; +import javax.servlet.* +import javax.servlet.http.* -paramMap = UtilHttp.getParameterMap(request); -forumId = null; -servletContext = session.getServletContext(); -rootForumId = WebSiteWorker.getWebSiteId(request); -context.rootPubId = rootForumId; -session.setAttribute("rootPubId", rootForumId); -request.setAttribute("rootPubId", rootForumId); -forumId = ContentManagementWorker.getFromSomewhere("forumId", paramMap, request, context); +paramMap = UtilHttp.getParameterMap(request) +forumId = null +servletContext = session.getServletContext() +rootForumId = WebSiteWorker.getWebSiteId(request) +context.rootPubId = rootForumId +session.setAttribute("rootPubId", rootForumId) +request.setAttribute("rootPubId", rootForumId) +forumId = ContentManagementWorker.getFromSomewhere("forumId", paramMap, request, context) if (forumId) { - forumId = rootForumId; + forumId = rootForumId } -context.forumId = forumId; -session.setAttribute("forumId", forumId); -request.setAttribute("forumId", forumId); +context.forumId = forumId +session.setAttribute("forumId", forumId) +request.setAttribute("forumId", forumId) diff --git a/ecommerce/groovyScripts/forum/RespondPermAndPrep.groovy b/ecommerce/groovyScripts/forum/RespondPermAndPrep.groovy index 1906be3c8..ad58bc40c 100644 --- a/ecommerce/groovyScripts/forum/RespondPermAndPrep.groovy +++ b/ecommerce/groovyScripts/forum/RespondPermAndPrep.groovy @@ -17,139 +17,139 @@ * under the License. */ -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; +import java.util.ArrayList +import java.util.Collection +import java.util.HashMap +import java.util.Iterator +import java.util.LinkedList +import java.util.List +import java.util.Map +import java.util.Set +import java.util.TreeSet -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.security.*; -import org.apache.ofbiz.service.*; -import org.apache.ofbiz.entity.model.*; -import org.apache.ofbiz.content.content.PermissionRecorder; +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.security.* +import org.apache.ofbiz.service.* +import org.apache.ofbiz.entity.model.* +import org.apache.ofbiz.content.content.PermissionRecorder -import javax.servlet.*; -import javax.servlet.http.*; +import javax.servlet.* +import javax.servlet.http.* -paramMap = UtilHttp.getParameterMap(request); +paramMap = UtilHttp.getParameterMap(request) -contentIdTo = paramMap.contentIdTo; +contentIdTo = paramMap.contentIdTo if (!contentIdTo) { - request.setAttribute("errorMsgReq", "contentIdTo is empty"); - return; + request.setAttribute("errorMsgReq", "contentIdTo is empty") + return } /* -pubPt = paramMap.pubPt ?: context.pubPt; +pubPt = paramMap.pubPt ?: context.pubPt if (!pubPt) { - request.setAttribute("errorMsgReq", "pubPt is empty"); - return; + request.setAttribute("errorMsgReq", "pubPt is empty") + return } */ -contentToValue = from("Content").where("contentId", contentIdTo).queryOne(); -contentToPurposeList = contentToValue.getRelated("ContentPurpose", null, null, true); -currentValue = delegator.makeValue("Content", [contentTypeId : "DOCUMENT", statusId : "CTNT_PUBLISHED", privilegeEnumId : "_00_"]); +contentToValue = from("Content").where("contentId", contentIdTo).queryOne() +contentToPurposeList = contentToValue.getRelated("ContentPurpose", null, null, true) +currentValue = delegator.makeValue("Content", [contentTypeId : "DOCUMENT", statusId : "CTNT_PUBLISHED", privilegeEnumId : "_00_"]) if (contentToPurposeList.contains("RESPONSE")) { - ownerContentId = contentToValue.ownerContentId; - currentValue.ownerContentId = ownerContentId; + ownerContentId = contentToValue.ownerContentId + currentValue.ownerContentId = ownerContentId } else { - contentId = contentToValue.contentId; - currentValueownerContentId = contentId; + contentId = contentToValue.contentId + currentValueownerContentId = contentId } -mapIn = [:]; -mapIn.userLogin = userLogin; -targetOperationList = StringUtil.split(context.targetOperation, "|"); -mapIn.targetOperationList = targetOperationList; +mapIn = [:] +mapIn.userLogin = userLogin +targetOperationList = StringUtil.split(context.targetOperation, "|") +mapIn.targetOperationList = targetOperationList if (currentValue) { - mapIn.currentContent = currentValue; + mapIn.currentContent = currentValue } -mapIn.entityOperation = "_CREATE"; -mapIn.contentPurposeList = ["RESPONSE"]; +mapIn.entityOperation = "_CREATE" +mapIn.contentPurposeList = ["RESPONSE"] -//org.apache.ofbiz.base.util.Debug.logInfo("in permprep, mapIn:" + mapIn, null); -result = runService('checkContentPermission', mapIn); -permissionStatus = result.permissionStatus; -//org.apache.ofbiz.base.util.Debug.logInfo("permissionStatus:" + permissionStatus, null); +//org.apache.ofbiz.base.util.Debug.logInfo("in permprep, mapIn:" + mapIn, null) +result = runService('checkContentPermission', mapIn) +permissionStatus = result.permissionStatus +//org.apache.ofbiz.base.util.Debug.logInfo("permissionStatus:" + permissionStatus, null) if (!"granted".equals(permissionStatus)) { - request.setAttribute("errorMsgReq", "Permission to add response is denied (1)"); - errorMessage = "Permission to add response is denied (2)"; - recorder = result.permissionRecorder; - //Debug.logInfo("recorder(0):" + recorder, ""); + request.setAttribute("errorMsgReq", "Permission to add response is denied (1)") + errorMessage = "Permission to add response is denied (2)" + recorder = result.permissionRecorder + //Debug.logInfo("recorder(0):" + recorder, "") if (recorder) { - permissionMessage = recorder.toHtml(); - //Debug.logInfo("permissionMessage(0):" + permissionMessage, ""); - errorMessage += " \n " + permissionMessage; + permissionMessage = recorder.toHtml() + //Debug.logInfo("permissionMessage(0):" + permissionMessage, "") + errorMessage += " \n " + permissionMessage } - request.setAttribute("permissionErrorMsg", errorMessage); - context.permissionErrorMsg = errorMessage; - context.hasPermission = false; - request.setAttribute("hasPermission", false); - request.setAttribute("permissionStatus", ""); - return; + request.setAttribute("permissionErrorMsg", errorMessage) + context.permissionErrorMsg = errorMessage + context.hasPermission = false + request.setAttribute("hasPermission", false) + request.setAttribute("permissionStatus", "") + return } else { - context.hasPermission = true; - request.setAttribute("hasPermission", true); - request.setAttribute("permissionStatus", "granted"); + context.hasPermission = true + request.setAttribute("hasPermission", true) + request.setAttribute("permissionStatus", "granted") } /* -pubContentValue = delegator.findOne("Content", [contentId : pubPt], false); +pubContentValue = delegator.findOne("Content", [contentId : pubPt], false) if (pubContentValue) { - mapIn.currentContent = pubContentValue; - mapIn.statusId = "CTNT_PUBLISHED"; + mapIn.currentContent = pubContentValue + mapIn.statusId = "CTNT_PUBLISHED" } -//org.apache.ofbiz.base.util.Debug.logInfo("in permprep(2), mapIn:" + mapIn, null); -result = dispatcher.runSync("checkContentPermission", mapIn); -permissionStatus = result.permissionStatus; -//org.apache.ofbiz.base.util.Debug.logInfo("permissionStatus(2):" + permissionStatus, null); +//org.apache.ofbiz.base.util.Debug.logInfo("in permprep(2), mapIn:" + mapIn, null) +result = dispatcher.runSync("checkContentPermission", mapIn) +permissionStatus = result.permissionStatus +//org.apache.ofbiz.base.util.Debug.logInfo("permissionStatus(2):" + permissionStatus, null) if (!"granted".equals(permissionStatus)) { - request.setAttribute("errorMsgReq", "Permission to add response is denied (2)"); - errorMessage = "Permission to add response is denied (2)"; - recorder = result.permissionRecorder; - //Debug.logInfo("recorder(0):" + recorder, ""); + request.setAttribute("errorMsgReq", "Permission to add response is denied (2)") + errorMessage = "Permission to add response is denied (2)" + recorder = result.permissionRecorder + //Debug.logInfo("recorder(0):" + recorder, "") if (recorder) { - permissionMessage = recorder.toHtml(); - //Debug.logInfo("permissionMessage(0):" + permissionMessage, ""); - errorMessage += " \n " + permissionMessage; + permissionMessage = recorder.toHtml() + //Debug.logInfo("permissionMessage(0):" + permissionMessage, "") + errorMessage += " \n " + permissionMessage } - request.setAttribute("permissionErrorMsg", errorMessage); - context.permissionErrorMsg = errorMessage; - context.hasPermission = false; - request.setAttribute("hasPermission", false); - request.setAttribute("permissionStatus", ""); - return; + request.setAttribute("permissionErrorMsg", errorMessage) + context.permissionErrorMsg = errorMessage + context.hasPermission = false + request.setAttribute("hasPermission", false) + request.setAttribute("permissionStatus", "") + return } else { - context.hasPermission = true; - request.setAttribute("hasPermission", true); - request.setAttribute("permissionStatus", "granted"); + context.hasPermission = true + request.setAttribute("hasPermission", true) + request.setAttribute("permissionStatus", "granted") } */ -request.setAttribute("currentValue", currentValue); -singleWrapper = context.singleWrapper; -singleWrapper.putInContext("contentPurposeTypeId", context.contentPurposeTypeId); -singleWrapper.putInContext("targetOperation", context.targetOperation); -singleWrapper.putInContext("targetOperationString", context.targetOperation); -singleWrapper.putInContext("currentValue", currentValue); +request.setAttribute("currentValue", currentValue) +singleWrapper = context.singleWrapper +singleWrapper.putInContext("contentPurposeTypeId", context.contentPurposeTypeId) +singleWrapper.putInContext("targetOperation", context.targetOperation) +singleWrapper.putInContext("targetOperationString", context.targetOperation) +singleWrapper.putInContext("currentValue", currentValue) -trailList = context.trailList; -replyName = null; +trailList = context.trailList +replyName = null if (trailList) { - idNamePair = trailList[trailList.size() -1]; - replyName = idNamePair[1]; + idNamePair = trailList[trailList.size() -1] + replyName = idNamePair[1] if (!replyName.contains("RE:")) { - replyName = "RE:" + replyName; + replyName = "RE:" + replyName } } -singleWrapper.putInContext("replyName", [contentName : replyName, description : replyName]); +singleWrapper.putInContext("replyName", [contentName : replyName, description : replyName]) diff --git a/ecommerce/groovyScripts/forum/ResponsePrep.groovy b/ecommerce/groovyScripts/forum/ResponsePrep.groovy index 8935247d8..945dee348 100644 --- a/ecommerce/groovyScripts/forum/ResponsePrep.groovy +++ b/ecommerce/groovyScripts/forum/ResponsePrep.groovy @@ -17,59 +17,59 @@ * under the License. */ -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; +import java.util.ArrayList +import java.util.Collection +import java.util.HashMap +import java.util.Iterator +import java.util.LinkedList +import java.util.List +import java.util.Map +import java.util.Set +import java.util.TreeSet -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.security.*; -import org.apache.ofbiz.service.*; -import org.apache.ofbiz.entity.model.*; -import org.apache.ofbiz.securityext.login.*; -import org.apache.ofbiz.common.*; -import org.apache.ofbiz.content.content.ContentWorker; +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.security.* +import org.apache.ofbiz.service.* +import org.apache.ofbiz.entity.model.* +import org.apache.ofbiz.securityext.login.* +import org.apache.ofbiz.common.* +import org.apache.ofbiz.content.content.ContentWorker -import javax.servlet.*; -import javax.servlet.http.*; +import javax.servlet.* +import javax.servlet.http.* -paramMap = UtilHttp.getParameterMap(request); +paramMap = UtilHttp.getParameterMap(request) -contentIdTo = paramMap.contentIdTo; -nodeTrailCsv = paramMap.nodeTrailCsv; -//Debug.logInfo("in viewprep, nodeTrailCsv:" + nodeTrailCsv,""); -context.nodeTrailCsv = nodeTrailCsv; -contentId = paramMap.contentIdTo; -context.subContentId = contentId; -context.contentIdTo = contentId; +contentIdTo = paramMap.contentIdTo +nodeTrailCsv = paramMap.nodeTrailCsv +//Debug.logInfo("in viewprep, nodeTrailCsv:" + nodeTrailCsv,"") +context.nodeTrailCsv = nodeTrailCsv +contentId = paramMap.contentIdTo +context.subContentId = contentId +context.contentIdTo = contentId -trail = StringUtil.split(nodeTrailCsv, ","); -siteAncestorList = []; -idList = []; +trail = StringUtil.split(nodeTrailCsv, ",") +siteAncestorList = [] +idList = [] if (trail) { - pubPt = trail[0]; - ContentWorker.getContentAncestry(delegator, pubPt, "SUBSITE", "To", idList); - idList.add(pubPt); + pubPt = trail[0] + ContentWorker.getContentAncestry(delegator, pubPt, "SUBSITE", "To", idList) + idList.add(pubPt) } // start at 1 to skip webSiteId idList.each { id -> - webSitePublishPoint = from("WebSitePublishPoint").where("contentId", id).cache(true).queryOne(); - siteAncestorList.add(webSitePublishPoint); + webSitePublishPoint = from("WebSitePublishPoint").where("contentId", id).cache(true).queryOne() + siteAncestorList.add(webSitePublishPoint) } -context.siteAncestorList = siteAncestorList; -//Debug.logInfo("in viewprep, siteAncestorList:" + siteAncestorList,""); +context.siteAncestorList = siteAncestorList +//Debug.logInfo("in viewprep, siteAncestorList:" + siteAncestorList,"") -singleWrapper = context.singleWrapper; -// singleWrapper.putInContext("pageName", page.getPageName()); -singleWrapper.putInContext("contentIdTo", contentIdTo); -singleWrapper.putInContext("summaryDataResourceTypeId", null); -singleWrapper.putInContext("mapKey", null); -singleWrapper.putInContext("nodeTrailCsv", nodeTrailCsv); +singleWrapper = context.singleWrapper +// singleWrapper.putInContext("pageName", page.getPageName()) +singleWrapper.putInContext("contentIdTo", contentIdTo) +singleWrapper.putInContext("summaryDataResourceTypeId", null) +singleWrapper.putInContext("mapKey", null) +singleWrapper.putInContext("nodeTrailCsv", nodeTrailCsv) diff --git a/ecommerce/groovyScripts/forum/ViewPrep.groovy b/ecommerce/groovyScripts/forum/ViewPrep.groovy index 453098e07..e5ee12f22 100644 --- a/ecommerce/groovyScripts/forum/ViewPrep.groovy +++ b/ecommerce/groovyScripts/forum/ViewPrep.groovy @@ -17,55 +17,55 @@ * under the License. */ -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; +import java.util.ArrayList +import java.util.Collection +import java.util.HashMap +import java.util.Iterator +import java.util.LinkedList +import java.util.List +import java.util.Map +import java.util.Set +import java.util.TreeSet -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.security.*; -import org.apache.ofbiz.service.*; -import org.apache.ofbiz.entity.model.*; -import org.apache.ofbiz.securityext.login.*; -import org.apache.ofbiz.common.*; -import org.apache.ofbiz.content.content.ContentWorker; -import org.apache.ofbiz.content.ContentManagementWorker; +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.security.* +import org.apache.ofbiz.service.* +import org.apache.ofbiz.entity.model.* +import org.apache.ofbiz.securityext.login.* +import org.apache.ofbiz.common.* +import org.apache.ofbiz.content.content.ContentWorker +import org.apache.ofbiz.content.ContentManagementWorker -import javax.servlet.*; -import javax.servlet.http.*; +import javax.servlet.* +import javax.servlet.http.* -paramMap = UtilHttp.getParameterMap(request); +paramMap = UtilHttp.getParameterMap(request) // Strip old VIEW_INDEX from query string if present //since we are adding them again. -temp = request.getQueryString(); -queryString = UtilHttp.stripViewParamsFromQueryString(temp); -//Debug.logInfo("in viewprep, queryString(1):" + queryString,""); -context.queryString = queryString; -//Debug.logInfo("in viewprep, queryString(2):" + queryString,""); +temp = request.getQueryString() +queryString = UtilHttp.stripViewParamsFromQueryString(temp) +//Debug.logInfo("in viewprep, queryString(1):" + queryString,"") +context.queryString = queryString +//Debug.logInfo("in viewprep, queryString(2):" + queryString,"") -requestURL = request.getRequestURL(); -//Debug.logInfo("in viewprep, requestURL(3):" + requestURL,""); -context.requestURL = requestURL; -viewSize = paramMap.VIEW_SIZE; -context.viewSize = viewSize; -//Debug.logInfo("in viewprep, viewSize(3):" + viewSize,""); -viewIndex = paramMap.VIEW_INDEX; -context.viewIndex = viewIndex; -//Debug.logInfo("in viewprep, viewIndex(3):" + viewIndex,""); +requestURL = request.getRequestURL() +//Debug.logInfo("in viewprep, requestURL(3):" + requestURL,"") +context.requestURL = requestURL +viewSize = paramMap.VIEW_SIZE +context.viewSize = viewSize +//Debug.logInfo("in viewprep, viewSize(3):" + viewSize,"") +viewIndex = paramMap.VIEW_INDEX +context.viewIndex = viewIndex +//Debug.logInfo("in viewprep, viewIndex(3):" + viewIndex,"") -nodeTrailCsv = ContentManagementWorker.getFromSomewhere("nodeTrailCsv", paramMap, request, context); -context.nodeTrailCsv = nodeTrailCsv; -contentId = ContentManagementWorker.getFromSomewhere("contentId", paramMap, request, context); -//Debug.logInfo("in viewprep, contentId(3):" + contentId,""); -context.subContentId = contentId; -context.contentIdTo = contentId; -forumId = ContentManagementWorker.getFromSomewhere("forumId", paramMap, request, context); -//forumContent = delegator.findOne("Content", [contentId : forumId], true); -//context.forumContent = forumContent; +nodeTrailCsv = ContentManagementWorker.getFromSomewhere("nodeTrailCsv", paramMap, request, context) +context.nodeTrailCsv = nodeTrailCsv +contentId = ContentManagementWorker.getFromSomewhere("contentId", paramMap, request, context) +//Debug.logInfo("in viewprep, contentId(3):" + contentId,"") +context.subContentId = contentId +context.contentIdTo = contentId +forumId = ContentManagementWorker.getFromSomewhere("forumId", paramMap, request, context) +//forumContent = delegator.findOne("Content", [contentId : forumId], true) +//context.forumContent = forumContent diff --git a/ecommerce/groovyScripts/includes/MruAdd.groovy b/ecommerce/groovyScripts/includes/MruAdd.groovy index 0b2966d9f..e887ac001 100644 --- a/ecommerce/groovyScripts/includes/MruAdd.groovy +++ b/ecommerce/groovyScripts/includes/MruAdd.groovy @@ -17,55 +17,55 @@ * under the License. */ -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; +import java.util.ArrayList +import java.util.Collection +import java.util.HashMap +import java.util.Iterator +import java.util.LinkedList +import java.util.List +import java.util.Map +import java.util.Set +import java.util.TreeSet -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.security.*; -import org.apache.ofbiz.service.*; -import org.apache.ofbiz.entity.model.*; -import org.apache.ofbiz.content.ContentManagementWorker; -import org.apache.ofbiz.content.content.ContentWorker; -import org.apache.ofbiz.base.util.collections.LifoSet; +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.security.* +import org.apache.ofbiz.service.* +import org.apache.ofbiz.entity.model.* +import org.apache.ofbiz.content.ContentManagementWorker +import org.apache.ofbiz.content.content.ContentWorker +import org.apache.ofbiz.base.util.collections.LifoSet -import javax.servlet.*; -import javax.servlet.http.*; +import javax.servlet.* +import javax.servlet.http.* -lookupCaches = session.getAttribute("lookupCaches"); -//org.apache.ofbiz.base.util.Debug.logInfo("entityName:" + entityName, ""); -//org.apache.ofbiz.base.util.Debug.logInfo("in MruAdd.groovy, lookupCaches:" + lookupCaches, ""); +lookupCaches = session.getAttribute("lookupCaches") +//org.apache.ofbiz.base.util.Debug.logInfo("entityName:" + entityName, "") +//org.apache.ofbiz.base.util.Debug.logInfo("in MruAdd.groovy, lookupCaches:" + lookupCaches, "") if (!lookupCaches) { - lookupCaches = [:]; - session.setAttribute("lookupCaches", lookupCaches); + lookupCaches = [:] + session.setAttribute("lookupCaches", lookupCaches) } -cacheEntityName = entityName; -//Debug.logInfo("cacheEntityName:" + cacheEntityName, ""); -lifoSet = lookupCaches[cacheEntityName]; -//org.apache.ofbiz.base.util.Debug.logInfo("lifoSet:" + lifoSet, ""); +cacheEntityName = entityName +//Debug.logInfo("cacheEntityName:" + cacheEntityName, "") +lifoSet = lookupCaches[cacheEntityName] +//org.apache.ofbiz.base.util.Debug.logInfo("lifoSet:" + lifoSet, "") if (!lifoSet) { - lifoSet = new LifoSet(10); - lookupCaches[cacheEntityName] = lifoSet; + lifoSet = new LifoSet(10) + lookupCaches[cacheEntityName] = lifoSet } -paramMap = UtilHttp.getParameterMap(request); -contentId = paramMap.contentId; -contentAssocDataResourceViewFrom = ContentWorker.getSubContentCache(delegator, null, null, contentId, null, null, null, null, null); -//Debug.logInfo("in mruadd, contentAssocDataResourceViewFrom :" + contentAssocDataResourceViewFrom , ""); +paramMap = UtilHttp.getParameterMap(request) +contentId = paramMap.contentId +contentAssocDataResourceViewFrom = ContentWorker.getSubContentCache(delegator, null, null, contentId, null, null, null, null, null) +//Debug.logInfo("in mruadd, contentAssocDataResourceViewFrom :" + contentAssocDataResourceViewFrom , "") if (contentAssocDataResourceViewFrom) { - lookupCaches = session.getAttribute("lookupCaches"); - viewPK = contentAssocDataResourceViewFrom.getPrimaryKey(); - //Debug.logInfo("in mruadd, viewPK :" + viewPK , ""); + lookupCaches = session.getAttribute("lookupCaches") + viewPK = contentAssocDataResourceViewFrom.getPrimaryKey() + //Debug.logInfo("in mruadd, viewPK :" + viewPK , "") if (viewPK) { - ContentManagementWorker.mruAdd(session, viewPK); + ContentManagementWorker.mruAdd(session, viewPK) } } diff --git a/ecommerce/groovyScripts/order/AnonymousCheckoutLinks.groovy b/ecommerce/groovyScripts/order/AnonymousCheckoutLinks.groovy index 1d7175ab1..74c84aa65 100644 --- a/ecommerce/groovyScripts/order/AnonymousCheckoutLinks.groovy +++ b/ecommerce/groovyScripts/order/AnonymousCheckoutLinks.groovy @@ -17,30 +17,30 @@ * under the License. */ -import org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents; +import org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents -shoppingCart = ShoppingCartEvents.getCartObject(request); +shoppingCart = ShoppingCartEvents.getCartObject(request) if (userLogin) { - context.enableShippingAddress = true; + context.enableShippingAddress = true } -shippingContactMechId = shoppingCart.getShippingContactMechId(); +shippingContactMechId = shoppingCart.getShippingContactMechId() if (shippingContactMechId) { - context.enableShipmentMethod = true; + context.enableShipmentMethod = true } -shipmentMethodTypeId = shoppingCart.getShipmentMethodTypeId(); +shipmentMethodTypeId = shoppingCart.getShipmentMethodTypeId() if (shipmentMethodTypeId) { - context.enablePaymentOptions = true; + context.enablePaymentOptions = true } -paymentMethodIds = shoppingCart.getPaymentMethodIds(); -paymentMethodTypeId = parameters.paymentMethodTypeId; +paymentMethodIds = shoppingCart.getPaymentMethodIds() +paymentMethodTypeId = parameters.paymentMethodTypeId if (paymentMethodIds || paymentMethodTypeId) { - context.enablePaymentInformation = true; + context.enablePaymentInformation = true } if (paymentMethodIds) { - context.enableReviewOrder = true; + context.enableReviewOrder = true } diff --git a/ecommerce/groovyScripts/order/AnonymousTrail.groovy b/ecommerce/groovyScripts/order/AnonymousTrail.groovy index 919f1c45c..977cb6593 100644 --- a/ecommerce/groovyScripts/order/AnonymousTrail.groovy +++ b/ecommerce/groovyScripts/order/AnonymousTrail.groovy @@ -17,26 +17,26 @@ * under the License. */ -import org.apache.ofbiz.order.shoppingcart.*; +import org.apache.ofbiz.order.shoppingcart.* -cart = session.getAttribute("shoppingCart"); +cart = session.getAttribute("shoppingCart") -trailClassMap = [:]; +trailClassMap = [:] if (cart.getShippingContactMechId()) { - context.shipAddr = "Y"; - trailClassMap.shipAddr = "submenutextright"; + context.shipAddr = "Y" + trailClassMap.shipAddr = "submenutextright" } if (cart.getShipmentMethodTypeId()) { - context.shipOptions = "Y"; - trailClassMap.shipAddr = "submenutext"; - trailClassMap.shipOptions = "submenutextright"; + context.shipOptions = "Y" + trailClassMap.shipAddr = "submenutext" + trailClassMap.shipOptions = "submenutextright" } if (parameters.paymentMethodType || cart.getPaymentMethodIds() || cart.getPaymentMethodTypeIds()) { - context.billing = "Y"; - trailClassMap.shipOptions = "submenutext"; - trailClassMap.paymentType = "submenutextright"; + context.billing = "Y" + trailClassMap.shipOptions = "submenutext" + trailClassMap.paymentType = "submenutextright" } -context.trailClass = trailClassMap; +context.trailClass = trailClassMap diff --git a/ecommerce/groovyScripts/order/BillSettings.groovy b/ecommerce/groovyScripts/order/BillSettings.groovy index e3602d5e4..57fa17a8c 100644 --- a/ecommerce/groovyScripts/order/BillSettings.groovy +++ b/ecommerce/groovyScripts/order/BillSettings.groovy @@ -17,92 +17,92 @@ * under the License. */ -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.entity.util.*; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.accounting.payment.*; -import org.apache.ofbiz.order.shoppingcart.*; -import org.apache.ofbiz.party.contact.*; +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.entity.util.* +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.accounting.payment.* +import org.apache.ofbiz.order.shoppingcart.* +import org.apache.ofbiz.party.contact.* -cart = session.getAttribute("shoppingCart"); -currencyUomId = cart.getCurrency(); -payType = parameters.paymentMethodType; +cart = session.getAttribute("shoppingCart") +currencyUomId = cart.getCurrency() +payType = parameters.paymentMethodType if (!payType && parameters.useGc) { - payType = "GC"; + payType = "GC" } -context.cart = cart; -context.paymentMethodType = payType; +context.cart = cart +context.paymentMethodType = payType -partyId = cart.getPartyId() ?: userLogin.partyId; -context.partyId = partyId; +partyId = cart.getPartyId() ?: userLogin.partyId +context.partyId = partyId // nuke the event messages -request.removeAttribute("_EVENT_MESSAGE_"); +request.removeAttribute("_EVENT_MESSAGE_") if (partyId && !partyId.equals("_NA_")) { - party = from("Party").where("partyId", partyId).queryOne(); - person = party.getRelatedOne("Person", false); - context.party = party; - context.person = person; + party = from("Party").where("partyId", partyId).queryOne() + person = party.getRelatedOne("Person", false) + context.party = party + context.person = person if (party) { - context.paymentMethodList = EntityUtil.filterByDate(party.getRelated("PaymentMethod", null, null, false)); + context.paymentMethodList = EntityUtil.filterByDate(party.getRelated("PaymentMethod", null, null, false)) - billingAccountList = BillingAccountWorker.makePartyBillingAccountList(userLogin, currencyUomId, partyId, delegator, dispatcher); + billingAccountList = BillingAccountWorker.makePartyBillingAccountList(userLogin, currencyUomId, partyId, delegator, dispatcher) if (billingAccountList) { - context.selectedBillingAccountId = cart.getBillingAccountId(); - context.billingAccountList = billingAccountList; + context.selectedBillingAccountId = cart.getBillingAccountId() + context.billingAccountList = billingAccountList } } } if (parameters.useShipAddr && cart.getShippingContactMechId()) { - shippingContactMech = cart.getShippingContactMechId(); - postalAddress = from("PostalAddress").where("contactMechId", shippingContactMech).queryOne(); - context.useEntityFields = "Y"; - context.postalFields = postalAddress; + shippingContactMech = cart.getShippingContactMechId() + postalAddress = from("PostalAddress").where("contactMechId", shippingContactMech).queryOne() + context.useEntityFields = "Y" + context.postalFields = postalAddress if (postalAddress && partyId) { - partyContactMech = from("PartyContactMech").where("partyId", partyId, "contactMechId", postalAddress.contactMechId).orderBy("-fromDate").filterByDate().queryFirst(); - context.partyContactMech = partyContactMech; + partyContactMech = from("PartyContactMech").where("partyId", partyId, "contactMechId", postalAddress.contactMechId).orderBy("-fromDate").filterByDate().queryFirst() + context.partyContactMech = partyContactMech } } else { - context.postalFields = UtilHttp.getParameterMap(request); + context.postalFields = UtilHttp.getParameterMap(request) } if (cart && !parameters.singleUsePayment) { if (cart.getPaymentMethodIds() ) { - checkOutPaymentId = cart.getPaymentMethodIds()[0]; - context.checkOutPaymentId = checkOutPaymentId; - paymentMethod = from("PaymentMethod").where("paymentMethodId", checkOutPaymentId).queryOne(); - account = null; + checkOutPaymentId = cart.getPaymentMethodIds()[0] + context.checkOutPaymentId = checkOutPaymentId + paymentMethod = from("PaymentMethod").where("paymentMethodId", checkOutPaymentId).queryOne() + account = null if ("CREDIT_CARD".equals(paymentMethod.paymentMethodTypeId)) { - account = paymentMethod.getRelatedOne("CreditCard", false); - context.creditCard = account; - context.paymentMethodType = "CC"; + account = paymentMethod.getRelatedOne("CreditCard", false) + context.creditCard = account + context.paymentMethodType = "CC" } else if ("EFT_ACCOUNT".equals(paymentMethod.paymentMethodTypeId)) { - account = paymentMethod.getRelatedOne("EftAccount", false); - context.eftAccount = account; - context.paymentMethodType = "EFT"; + account = paymentMethod.getRelatedOne("EftAccount", false) + context.eftAccount = account + context.paymentMethodType = "EFT" } else if ("GIFT_CARD".equals(paymentMethod.paymentMethodTypeId)) { - account = paymentMethod.getRelatedOne("GiftCard", false); - context.giftCard = account; - context.paymentMethodType = "GC"; + account = paymentMethod.getRelatedOne("GiftCard", false) + context.giftCard = account + context.paymentMethodType = "GC" } else { - context.paymentMethodType = "offline"; + context.paymentMethodType = "offline" } if (account && parameters.useShipAddr) { - address = account.getRelatedOne("PostalAddress", false); - context.postalAddress = address; - context.postalFields = address; + address = account.getRelatedOne("PostalAddress", false) + context.postalAddress = address + context.postalFields = address } } else if (cart.getPaymentMethodTypeIds()) { - checkOutPaymentId = cart.getPaymentMethodTypeIds()[0]; - context.checkOutPaymentId = checkOutPaymentId; + checkOutPaymentId = cart.getPaymentMethodTypeIds()[0] + context.checkOutPaymentId = checkOutPaymentId } } -requestPaymentMethodType = parameters.paymentMethodType; +requestPaymentMethodType = parameters.paymentMethodType if (requestPaymentMethodType) { - context.paymentMethodType = requestPaymentMethodType; + context.paymentMethodType = requestPaymentMethodType } diff --git a/ecommerce/groovyScripts/order/CheckoutReview.groovy b/ecommerce/groovyScripts/order/CheckoutReview.groovy index 25018057f..25b30ece8 100644 --- a/ecommerce/groovyScripts/order/CheckoutReview.groovy +++ b/ecommerce/groovyScripts/order/CheckoutReview.groovy @@ -17,94 +17,94 @@ * under the License. */ -import java.lang.*; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.accounting.payment.*; -import org.apache.ofbiz.order.order.*; -import org.apache.ofbiz.party.contact.*; -import org.apache.ofbiz.product.catalog.*; -import org.apache.ofbiz.product.store.*; -import org.apache.ofbiz.webapp.website.WebSiteWorker; +import java.lang.* +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.accounting.payment.* +import org.apache.ofbiz.order.order.* +import org.apache.ofbiz.party.contact.* +import org.apache.ofbiz.product.catalog.* +import org.apache.ofbiz.product.store.* +import org.apache.ofbiz.webapp.website.WebSiteWorker -cart = session.getAttribute("shoppingCart"); -context.cart = cart; +cart = session.getAttribute("shoppingCart") +context.cart = cart -orderItems = cart.makeOrderItems(); -context.orderItems = orderItems; +orderItems = cart.makeOrderItems() +context.orderItems = orderItems -orderAdjustments = cart.makeAllAdjustments(); +orderAdjustments = cart.makeAllAdjustments() -orderItemShipGroupInfo = cart.makeAllShipGroupInfos(); +orderItemShipGroupInfo = cart.makeAllShipGroupInfos() if (orderItemShipGroupInfo) { orderItemShipGroupInfo.each { valueObj -> if ("OrderAdjustment".equals(valueObj.getEntityName())) { // shipping / tax adjustment(s) - orderAdjustments.add(valueObj); + orderAdjustments.add(valueObj) } } } -context.orderAdjustments = orderAdjustments; +context.orderAdjustments = orderAdjustments -workEfforts = cart.makeWorkEfforts(); // if required make workefforts for rental fixed assets too. -context.workEfforts = workEfforts; +workEfforts = cart.makeWorkEfforts() // if required make workefforts for rental fixed assets too. +context.workEfforts = workEfforts -orderHeaderAdjustments = OrderReadHelper.getOrderHeaderAdjustments(orderAdjustments, null); -context.orderHeaderAdjustments = orderHeaderAdjustments; -context.orderItemShipGroups = cart.getShipGroups(); -context.headerAdjustmentsToShow = OrderReadHelper.filterOrderAdjustments(orderHeaderAdjustments, true, false, false, false, false); +orderHeaderAdjustments = OrderReadHelper.getOrderHeaderAdjustments(orderAdjustments, null) +context.orderHeaderAdjustments = orderHeaderAdjustments +context.orderItemShipGroups = cart.getShipGroups() +context.headerAdjustmentsToShow = OrderReadHelper.filterOrderAdjustments(orderHeaderAdjustments, true, false, false, false, false) -orderSubTotal = OrderReadHelper.getOrderItemsSubTotal(orderItems, orderAdjustments, workEfforts); -context.orderSubTotal = orderSubTotal; -context.placingCustomerPerson = userLogin?.getRelatedOne("Person", false); -context.paymentMethods = cart.getPaymentMethods(); +orderSubTotal = OrderReadHelper.getOrderItemsSubTotal(orderItems, orderAdjustments, workEfforts) +context.orderSubTotal = orderSubTotal +context.placingCustomerPerson = userLogin?.getRelatedOne("Person", false) +context.paymentMethods = cart.getPaymentMethods() -paymentMethodTypeIds = cart.getPaymentMethodTypeIds(); -paymentMethodType = null; -paymentMethodTypeId = null; +paymentMethodTypeIds = cart.getPaymentMethodTypeIds() +paymentMethodType = null +paymentMethodTypeId = null if (paymentMethodTypeIds) { - paymentMethodTypeId = paymentMethodTypeIds[0]; - paymentMethodType = from("PaymentMethodType").where("paymentMethodTypeId", paymentMethodTypeId).queryOne(); - context.paymentMethodType = paymentMethodType; + paymentMethodTypeId = paymentMethodTypeIds[0] + paymentMethodType = from("PaymentMethodType").where("paymentMethodTypeId", paymentMethodTypeId).queryOne() + context.paymentMethodType = paymentMethodType } -webSiteId = WebSiteWorker.getWebSiteId(request); +webSiteId = WebSiteWorker.getWebSiteId(request) -productStore = ProductStoreWorker.getProductStore(request); -context.productStore = productStore; +productStore = ProductStoreWorker.getProductStore(request) +context.productStore = productStore -isDemoStore = !"N".equals(productStore.isDemoStore); -context.isDemoStore = isDemoStore; +isDemoStore = !"N".equals(productStore.isDemoStore) +context.isDemoStore = isDemoStore -payToPartyId = productStore.payToPartyId; -paymentAddress = PaymentWorker.getPaymentAddress(delegator, payToPartyId); -if (paymentAddress) context.paymentAddress = paymentAddress; +payToPartyId = productStore.payToPartyId +paymentAddress = PaymentWorker.getPaymentAddress(delegator, payToPartyId) +if (paymentAddress) context.paymentAddress = paymentAddress // TODO: FIXME! /* -billingAccount = cart.getBillingAccountId() ? delegator.findOne("BillingAccount", [billingAccountId : cart.getBillingAccountId()], false) : null; +billingAccount = cart.getBillingAccountId() ? delegator.findOne("BillingAccount", [billingAccountId : cart.getBillingAccountId()], false) : null if (billingAccount) - context.billingAccount = billingAccount; + context.billingAccount = billingAccount */ -context.customerPoNumber = cart.getPoNumber(); -context.carrierPartyId = cart.getCarrierPartyId(); -context.shipmentMethodTypeId = cart.getShipmentMethodTypeId(); -context.shippingInstructions = cart.getShippingInstructions(); -context.maySplit = cart.getMaySplit(); -context.giftMessage = cart.getGiftMessage(); -context.isGift = cart.getIsGift(); -context.currencyUomId = cart.getCurrency(); +context.customerPoNumber = cart.getPoNumber() +context.carrierPartyId = cart.getCarrierPartyId() +context.shipmentMethodTypeId = cart.getShipmentMethodTypeId() +context.shippingInstructions = cart.getShippingInstructions() +context.maySplit = cart.getMaySplit() +context.giftMessage = cart.getGiftMessage() +context.isGift = cart.getIsGift() +context.currencyUomId = cart.getCurrency() -shipmentMethodType = from("ShipmentMethodType").where("shipmentMethodTypeId", cart.getShipmentMethodTypeId()).queryOne(); -if (shipmentMethodType) context.shipMethDescription = shipmentMethodType.description; +shipmentMethodType = from("ShipmentMethodType").where("shipmentMethodTypeId", cart.getShipmentMethodTypeId()).queryOne() +if (shipmentMethodType) context.shipMethDescription = shipmentMethodType.description -orh = new OrderReadHelper(orderAdjustments, orderItems); -context.localOrderReadHelper = orh; -context.orderShippingTotal = cart.getTotalShipping(); -context.orderTaxTotal = cart.getTotalSalesTax(); -context.orderGrandTotal = cart.getGrandTotal(); +orh = new OrderReadHelper(orderAdjustments, orderItems) +context.localOrderReadHelper = orh +context.orderShippingTotal = cart.getTotalShipping() +context.orderTaxTotal = cart.getTotalSalesTax() +context.orderGrandTotal = cart.getGrandTotal() // nuke the event messages -request.removeAttribute("_EVENT_MESSAGE_"); +request.removeAttribute("_EVENT_MESSAGE_") diff --git a/ecommerce/groovyScripts/order/CheckoutShippingOptions.groovy b/ecommerce/groovyScripts/order/CheckoutShippingOptions.groovy index d65089d80..68d9a65c6 100644 --- a/ecommerce/groovyScripts/order/CheckoutShippingOptions.groovy +++ b/ecommerce/groovyScripts/order/CheckoutShippingOptions.groovy @@ -17,29 +17,29 @@ * under the License. */ -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.entity.util.*; -import org.apache.ofbiz.party.contact.*; -import org.apache.ofbiz.product.store.*; -import org.apache.ofbiz.order.shoppingcart.shipping.*; +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.entity.util.* +import org.apache.ofbiz.party.contact.* +import org.apache.ofbiz.product.store.* +import org.apache.ofbiz.order.shoppingcart.shipping.* -cart = session.getAttribute("shoppingCart"); -party = userLogin.getRelatedOne("Party", false); -productStore = ProductStoreWorker.getProductStore(request); +cart = session.getAttribute("shoppingCart") +party = userLogin.getRelatedOne("Party", false) +productStore = ProductStoreWorker.getProductStore(request) if (cart) { - shippingEstWpr = new ShippingEstimateWrapper(dispatcher, cart, 0); - context.shippingEstWpr = shippingEstWpr; - context.carrierShipmentMethodList = shippingEstWpr.getShippingMethods(); + shippingEstWpr = new ShippingEstimateWrapper(dispatcher, cart, 0) + context.shippingEstWpr = shippingEstWpr + context.carrierShipmentMethodList = shippingEstWpr.getShippingMethods() } -context.shoppingCart = cart; -context.userLogin = userLogin; -context.productStoreId = productStore.productStoreId; -context.productStore = productStore; -context.emailList = ContactHelper.getContactMechByType(party, "EMAIL_ADDRESS", false); +context.shoppingCart = cart +context.userLogin = userLogin +context.productStoreId = productStore.productStoreId +context.productStore = productStore +context.emailList = ContactHelper.getContactMechByType(party, "EMAIL_ADDRESS", false) if (cart.getShipmentMethodTypeId() && cart.getCarrierPartyId()) { - context.chosenShippingMethod = cart.getShipmentMethodTypeId() + '@' + cart.getCarrierPartyId(); + context.chosenShippingMethod = cart.getShipmentMethodTypeId() + '@' + cart.getCarrierPartyId() } diff --git a/ecommerce/groovyScripts/order/CustSettings.groovy b/ecommerce/groovyScripts/order/CustSettings.groovy index 23e64fa21..6edaa63b8 100644 --- a/ecommerce/groovyScripts/order/CustSettings.groovy +++ b/ecommerce/groovyScripts/order/CustSettings.groovy @@ -17,83 +17,83 @@ * under the License. */ -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.util.EntityUtil; +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.util.EntityUtil -partyId = null; +partyId = null if (userLogin) { - partyId = userLogin.partyId; + partyId = userLogin.partyId } if (!partyId && parameters.partyId) { - partyId = parameters.partyId; + partyId = parameters.partyId } if (partyId) { - parameters.partyId = partyId; + parameters.partyId = partyId // NOTE: if there was an error, then don't look up and fill in all of this data, just use the values from the previous request (which will be in the parameters Map automagically) if (!request.getAttribute("_ERROR_MESSAGE_") && !request.getAttribute("_ERROR_MESSAGE_LIST_")) { - person = from("Person").where("partyId", partyId).queryOne(); + person = from("Person").where("partyId", partyId).queryOne() if (person) { - context.callSubmitForm = true; + context.callSubmitForm = true // should never be null for the anonymous checkout, but just in case - parameters.personalTitle = person.personalTitle; - parameters.firstName = person.firstName; - parameters.middleName = person.middleName; - parameters.lastName = person.lastName; - parameters.suffix = person.suffix; + parameters.personalTitle = person.personalTitle + parameters.firstName = person.firstName + parameters.middleName = person.middleName + parameters.lastName = person.lastName + parameters.suffix = person.suffix //Parameters not in use, Do we really need these here or should be removed. - parameters.residenceStatusEnumId = person.residenceStatusEnumId; - parameters.maritalStatus = person.maritalStatus; - parameters.employmentStatusEnumId = person.employmentStatusEnumId; - parameters.occupation = person.occupation; - parameters.yearsWithEmployer = person.yearsWithEmployer; - parameters.monthsWithEmployer = person.monthsWithEmployer; - parameters.existingCustomer = person.existingCustomer; + parameters.residenceStatusEnumId = person.residenceStatusEnumId + parameters.maritalStatus = person.maritalStatus + parameters.employmentStatusEnumId = person.employmentStatusEnumId + parameters.occupation = person.occupation + parameters.yearsWithEmployer = person.yearsWithEmployer + parameters.monthsWithEmployer = person.monthsWithEmployer + parameters.existingCustomer = person.existingCustomer // birthDate -> birthDateDay, birthDateMonth, birthDateYear - birthDate = person.birthDate; + birthDate = person.birthDate if (birthDate) { // will be in the format "yyyy-mm-dd", like "2006-10-21" - birthDateString = birthDate.toString(); - parameters.birthDateDay = birthDateString.substring(8); - parameters.birthDateMonth = birthDateString.substring(5, 7); - parameters.birthDateYear = birthDateString.substring(0, 4); + birthDateString = birthDate.toString() + parameters.birthDateDay = birthDateString.substring(8) + parameters.birthDateMonth = birthDateString.substring(5, 7) + parameters.birthDateYear = birthDateString.substring(0, 4) // and finally, the whole thing, just in case we want it that way - parameters.birthDate = birthDateString; + parameters.birthDate = birthDateString } } // get the Email Address - emailPartyContactDetail = from("PartyContactDetailByPurpose").where("partyId", partyId, "contactMechPurposeTypeId", "PRIMARY_EMAIL").filterByDate().queryFirst(); + emailPartyContactDetail = from("PartyContactDetailByPurpose").where("partyId", partyId, "contactMechPurposeTypeId", "PRIMARY_EMAIL").filterByDate().queryFirst() if (emailPartyContactDetail) { - parameters.emailContactMechId = emailPartyContactDetail.contactMechId; - parameters.emailAddress = emailPartyContactDetail.infoString; - parameters.emailSol = emailPartyContactDetail.allowSolicitation; + parameters.emailContactMechId = emailPartyContactDetail.contactMechId + parameters.emailAddress = emailPartyContactDetail.infoString + parameters.emailSol = emailPartyContactDetail.allowSolicitation } // get the Phone Numbers - homePhonePartyContactDetail = from("PartyContactDetailByPurpose").where("partyId", partyId, "contactMechPurposeTypeId", "PHONE_HOME").filterByDate().queryFirst(); + homePhonePartyContactDetail = from("PartyContactDetailByPurpose").where("partyId", partyId, "contactMechPurposeTypeId", "PHONE_HOME").filterByDate().queryFirst() if (homePhonePartyContactDetail) { - parameters.homePhoneContactMechId = homePhonePartyContactDetail.contactMechId; - parameters.homeCountryCode = homePhonePartyContactDetail.countryCode; - parameters.homeAreaCode = homePhonePartyContactDetail.areaCode; - parameters.homeContactNumber = homePhonePartyContactDetail.contactNumber; - parameters.homeExt = homePhonePartyContactDetail.extension; - parameters.homeSol = homePhonePartyContactDetail.allowSolicitation; + parameters.homePhoneContactMechId = homePhonePartyContactDetail.contactMechId + parameters.homeCountryCode = homePhonePartyContactDetail.countryCode + parameters.homeAreaCode = homePhonePartyContactDetail.areaCode + parameters.homeContactNumber = homePhonePartyContactDetail.contactNumber + parameters.homeExt = homePhonePartyContactDetail.extension + parameters.homeSol = homePhonePartyContactDetail.allowSolicitation } - workPhonePartyContactDetail = from("PartyContactDetailByPurpose").where("partyId", partyId, "contactMechPurposeTypeId", "PHONE_WORK").filterByDate().queryFirst(); + workPhonePartyContactDetail = from("PartyContactDetailByPurpose").where("partyId", partyId, "contactMechPurposeTypeId", "PHONE_WORK").filterByDate().queryFirst() if (workPhonePartyContactDetail) { - parameters.workPhoneContactMechId = workPhonePartyContactDetail.contactMechId; - parameters.workCountryCode = workPhonePartyContactDetail.countryCode; - parameters.workAreaCode = workPhonePartyContactDetail.areaCode; - parameters.workContactNumber = workPhonePartyContactDetail.contactNumber; - parameters.workExt = workPhonePartyContactDetail.extension; - parameters.workSol = workPhonePartyContactDetail.allowSolicitation; + parameters.workPhoneContactMechId = workPhonePartyContactDetail.contactMechId + parameters.workCountryCode = workPhonePartyContactDetail.countryCode + parameters.workAreaCode = workPhonePartyContactDetail.areaCode + parameters.workContactNumber = workPhonePartyContactDetail.contactNumber + parameters.workExt = workPhonePartyContactDetail.extension + parameters.workSol = workPhonePartyContactDetail.allowSolicitation } } } diff --git a/ecommerce/groovyScripts/order/OptionSettings.groovy b/ecommerce/groovyScripts/order/OptionSettings.groovy index 02828ce1e..9fe996df8 100644 --- a/ecommerce/groovyScripts/order/OptionSettings.groovy +++ b/ecommerce/groovyScripts/order/OptionSettings.groovy @@ -17,40 +17,40 @@ * under the License. */ -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.order.shoppingcart.*; -import org.apache.ofbiz.order.shoppingcart.shipping.*; -import org.apache.ofbiz.party.contact.*; -import org.apache.ofbiz.product.store.*; +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.order.shoppingcart.* +import org.apache.ofbiz.order.shoppingcart.shipping.* +import org.apache.ofbiz.party.contact.* +import org.apache.ofbiz.product.store.* -shoppingCart = session.getAttribute("shoppingCart"); -context.shoppingCart = shoppingCart; -productStore = ProductStoreWorker.getProductStore(request); +shoppingCart = session.getAttribute("shoppingCart") +context.shoppingCart = shoppingCart +productStore = ProductStoreWorker.getProductStore(request) if (shoppingCart) { - shippingEstWpr = new ShippingEstimateWrapper(dispatcher, shoppingCart, 0); - context.shippingEstWpr = shippingEstWpr; - context.carrierShipmentMethodList = shippingEstWpr.getShippingMethods(); + shippingEstWpr = new ShippingEstimateWrapper(dispatcher, shoppingCart, 0) + context.shippingEstWpr = shippingEstWpr + context.carrierShipmentMethodList = shippingEstWpr.getShippingMethods() } // nuke the event messages -request.removeAttribute("_EVENT_MESSAGE_"); +request.removeAttribute("_EVENT_MESSAGE_") -party = null; -partyId = session.getAttribute("orderPartyId"); +party = null +partyId = session.getAttribute("orderPartyId") if (partyId) { - party = from("Party").where("partyId", partyId).queryOne(); - context.party = party; + party = from("Party").where("partyId", partyId).queryOne() + context.party = party } -context.emailList = ContactHelper.getContactMechByType(party, "EMAIL_ADDRESS", false); +context.emailList = ContactHelper.getContactMechByType(party, "EMAIL_ADDRESS", false) if (shoppingCart && shoppingCart.getShipmentMethodTypeId() && shoppingCart.getCarrierPartyId()) { - context.chosenShippingMethod = shoppingCart.getShipmentMethodTypeId() + '@' + shoppingCart.getCarrierPartyId(); - context.callSubmitForm = true; + context.chosenShippingMethod = shoppingCart.getShipmentMethodTypeId() + '@' + shoppingCart.getCarrierPartyId() + context.callSubmitForm = true } -context.productStoreId = productStore.productStoreId; -context.productStore = productStore; +context.productStoreId = productStore.productStoreId +context.productStore = productStore diff --git a/ecommerce/groovyScripts/order/OrderHistory.groovy b/ecommerce/groovyScripts/order/OrderHistory.groovy index d091bf9df..0d08daac0 100644 --- a/ecommerce/groovyScripts/order/OrderHistory.groovy +++ b/ecommerce/groovyScripts/order/OrderHistory.groovy @@ -17,27 +17,27 @@ * under the License. */ -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.entity.util.*; -import org.apache.ofbiz.entity.condition.*; +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.entity.util.* +import org.apache.ofbiz.entity.condition.* -partyRole = from("PartyRole").where("partyId", userLogin.partyId, "roleTypeId", "SUPPLIER").queryOne(); +partyRole = from("PartyRole").where("partyId", userLogin.partyId, "roleTypeId", "SUPPLIER").queryOne() if (partyRole) { if ("SUPPLIER".equals(partyRole.roleTypeId)) { /** drop shipper or supplier **/ - porderRoleCollection = from("OrderRole").where("partyId", userLogin.partyId, "roleTypeId", "SUPPLIER_AGENT").queryList(); + porderRoleCollection = from("OrderRole").where("partyId", userLogin.partyId, "roleTypeId", "SUPPLIER_AGENT").queryList() porderHeaderList = EntityUtil.orderBy(EntityUtil.filterByAnd(EntityUtil.getRelated("OrderHeader", null, porderRoleCollection, false), [EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "ORDER_REJECTED"), EntityCondition.makeCondition("orderTypeId", EntityOperator.EQUALS, "PURCHASE_ORDER")]), - ["orderDate DESC"]); - context.porderHeaderList = porderHeaderList; + ["orderDate DESC"]) + context.porderHeaderList = porderHeaderList } } -orderRoleCollection = from("OrderRole").where("partyId", userLogin.partyId, "roleTypeId", "PLACING_CUSTOMER").queryList(); +orderRoleCollection = from("OrderRole").where("partyId", userLogin.partyId, "roleTypeId", "PLACING_CUSTOMER").queryList() orderHeaderList = EntityUtil.orderBy(EntityUtil.filterByAnd(EntityUtil.getRelated("OrderHeader", null, orderRoleCollection, false), - [EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "ORDER_REJECTED")]), ["orderDate DESC"]); -context.orderHeaderList = orderHeaderList; + [EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "ORDER_REJECTED")]), ["orderDate DESC"]) +context.orderHeaderList = orderHeaderList -downloadOrderRoleAndProductContentInfoList = from("OrderRoleAndProductContentInfo").where("partyId", userLogin.partyId, "roleTypeId", "PLACING_CUSTOMER", "productContentTypeId", "DIGITAL_DOWNLOAD", "statusId", "ITEM_COMPLETED").queryList(); -context.downloadOrderRoleAndProductContentInfoList = downloadOrderRoleAndProductContentInfoList; +downloadOrderRoleAndProductContentInfoList = from("OrderRoleAndProductContentInfo").where("partyId", userLogin.partyId, "roleTypeId", "PLACING_CUSTOMER", "productContentTypeId", "DIGITAL_DOWNLOAD", "statusId", "ITEM_COMPLETED").queryList() +context.downloadOrderRoleAndProductContentInfoList = downloadOrderRoleAndProductContentInfoList diff --git a/ecommerce/groovyScripts/order/OrderStatus.groovy b/ecommerce/groovyScripts/order/OrderStatus.groovy index af5ce01c4..f6c183013 100644 --- a/ecommerce/groovyScripts/order/OrderStatus.groovy +++ b/ecommerce/groovyScripts/order/OrderStatus.groovy @@ -17,140 +17,140 @@ * under the License. */ -import java.math.BigDecimal; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.entity.condition.*; -import org.apache.ofbiz.entity.util.*; -import org.apache.ofbiz.accounting.payment.*; -import org.apache.ofbiz.order.order.*; -import org.apache.ofbiz.party.contact.*; -import org.apache.ofbiz.product.catalog.*; -import org.apache.ofbiz.product.store.*; +import java.math.BigDecimal +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.entity.condition.* +import org.apache.ofbiz.entity.util.* +import org.apache.ofbiz.accounting.payment.* +import org.apache.ofbiz.order.order.* +import org.apache.ofbiz.party.contact.* +import org.apache.ofbiz.product.catalog.* +import org.apache.ofbiz.product.store.* -orderId = parameters.orderId; -orderHeader = null; +orderId = parameters.orderId +orderHeader = null // we have a special case here where for an anonymous order the user will already be logged out, but the userLogin will be in the request so we can still do a security check here if (!userLogin) { - userLogin = parameters.temporaryAnonymousUserLogin; + userLogin = parameters.temporaryAnonymousUserLogin // This is another special case, when Order is placed by anonymous user from ecommerce and then Order is completed by admin(or any user) from Order Manager // then userLogin is not found when Order Complete Mail is send to user. if (!userLogin) { if (orderId) { - orderHeader = from("OrderHeader").where("orderId", orderId).queryOne(); - orderStatuses = orderHeader.getRelated("OrderStatus", null, null, false); - filteredOrderStatusList = []; - extOfflineModeExists = false; + orderHeader = from("OrderHeader").where("orderId", orderId).queryOne() + orderStatuses = orderHeader.getRelated("OrderStatus", null, null, false) + filteredOrderStatusList = [] + extOfflineModeExists = false // Handled the case of OFFLINE payment method. In case of OFFLINE payment "ORDER_CREATED" status must be checked. - orderPaymentPreferences = orderHeader.getRelated("OrderPaymentPreference", null, UtilMisc.toList("orderPaymentPreferenceId"), false); - filteredOrderPaymentPreferences = EntityUtil.filterByCondition(orderPaymentPreferences, EntityCondition.makeCondition("paymentMethodTypeId", EntityOperator.IN, ["EXT_OFFLINE"])); + orderPaymentPreferences = orderHeader.getRelated("OrderPaymentPreference", null, UtilMisc.toList("orderPaymentPreferenceId"), false) + filteredOrderPaymentPreferences = EntityUtil.filterByCondition(orderPaymentPreferences, EntityCondition.makeCondition("paymentMethodTypeId", EntityOperator.IN, ["EXT_OFFLINE"])) if (filteredOrderPaymentPreferences) { - extOfflineModeExists = true; + extOfflineModeExists = true } if (extOfflineModeExists) { - filteredOrderStatusList = EntityUtil.filterByCondition(orderStatuses, EntityCondition.makeCondition("statusId", EntityOperator.IN, ["ORDER_COMPLETED", "ORDER_APPROVED", "ORDER_CREATED"])); + filteredOrderStatusList = EntityUtil.filterByCondition(orderStatuses, EntityCondition.makeCondition("statusId", EntityOperator.IN, ["ORDER_COMPLETED", "ORDER_APPROVED", "ORDER_CREATED"])) } else { - filteredOrderStatusList = EntityUtil.filterByCondition(orderStatuses, EntityCondition.makeCondition("statusId", EntityOperator.IN, ["ORDER_COMPLETED", "ORDER_APPROVED"])); + filteredOrderStatusList = EntityUtil.filterByCondition(orderStatuses, EntityCondition.makeCondition("statusId", EntityOperator.IN, ["ORDER_COMPLETED", "ORDER_APPROVED"])) } if (UtilValidate.isNotEmpty(filteredOrderStatusList)) { if (filteredOrderStatusList.size() < 2) { - statusUserLogin = EntityUtil.getFirst(filteredOrderStatusList).statusUserLogin; - userLogin = from("UserLogin").where("userLoginId", statusUserLogin).queryOne(); + statusUserLogin = EntityUtil.getFirst(filteredOrderStatusList).statusUserLogin + userLogin = from("UserLogin").where("userLoginId", statusUserLogin).queryOne() } else { filteredOrderStatusList.each { orderStatus -> if ("ORDER_COMPLETED".equals(orderStatus.statusId)) { - statusUserLogin = orderStatus.statusUserLogin; - userLogin = from("UserLogin").where("userLoginId", statusUserLogin).queryOne(); + statusUserLogin = orderStatus.statusUserLogin + userLogin = from("UserLogin").where("userLoginId", statusUserLogin).queryOne() } } } } } } - context.userLogin = userLogin; + context.userLogin = userLogin } -/* partyId = null; +/* partyId = null if (userLogin) partyId = userLogin.partyId; */ -partyId = context.partyId; +partyId = context.partyId if (userLogin) { if (!partyId) { - partyId = userLogin.partyId; + partyId = userLogin.partyId } } // can anybody view an anonymous order? this is set in the screen widget and should only be turned on by an email confirmation screen -allowAnonymousView = context.allowAnonymousView; +allowAnonymousView = context.allowAnonymousView -isDemoStore = true; +isDemoStore = true if (orderId) { - orderHeader = from("OrderHeader").where("orderId", orderId).queryOne(); + orderHeader = from("OrderHeader").where("orderId", orderId).queryOne() if ("PURCHASE_ORDER".equals(orderHeader?.orderTypeId)) { //drop shipper or supplier - roleTypeId = "SUPPLIER_AGENT"; + roleTypeId = "SUPPLIER_AGENT" } else { //customer - roleTypeId = "PLACING_CUSTOMER"; + roleTypeId = "PLACING_CUSTOMER" } - context.roleTypeId = roleTypeId; + context.roleTypeId = roleTypeId // check OrderRole to make sure the user can view this order. This check must be done for any order which is not anonymously placed and // any anonymous order when the allowAnonymousView security flag (see above) is not set to Y, to prevent peeking if (orderHeader && (!"anonymous".equals(orderHeader.createdBy) || ("anonymous".equals(orderHeader.createdBy) && !"Y".equals(allowAnonymousView)))) { - orderRole = from("OrderRole").where("orderId", orderId, "partyId", partyId, "roleTypeId", roleTypeId).queryFirst(); + orderRole = from("OrderRole").where("orderId", orderId, "partyId", partyId, "roleTypeId", roleTypeId).queryFirst() if (!userLogin || !orderRole) { - context.remove("orderHeader"); - orderHeader = null; - Debug.logWarning("Warning: in OrderStatus.groovy before getting order detail info: role not found or user not logged in; partyId=[" + partyId + "], userLoginId=[" + (userLogin == null ? "null" : userLogin.get("userLoginId")) + "]", "orderstatus"); + context.remove("orderHeader") + orderHeader = null + Debug.logWarning("Warning: in OrderStatus.groovy before getting order detail info: role not found or user not logged in; partyId=[" + partyId + "], userLoginId=[" + (userLogin == null ? "null" : userLogin.get("userLoginId")) + "]", "orderstatus") } } } if (orderHeader) { - productStore = orderHeader.getRelatedOne("ProductStore", true); - if (productStore) isDemoStore = !"N".equals(productStore.isDemoStore); + productStore = orderHeader.getRelatedOne("ProductStore", true) + if (productStore) isDemoStore = !"N".equals(productStore.isDemoStore) - orderReadHelper = new OrderReadHelper(orderHeader); - orderItems = orderReadHelper.getOrderItems(); - orderAdjustments = orderReadHelper.getAdjustments(); - orderHeaderAdjustments = orderReadHelper.getOrderHeaderAdjustments(); - orderSubTotal = orderReadHelper.getOrderItemsSubTotal(); - orderItemShipGroups = orderReadHelper.getOrderItemShipGroups(); - headerAdjustmentsToShow = orderReadHelper.getOrderHeaderAdjustmentsToShow(); + orderReadHelper = new OrderReadHelper(orderHeader) + orderItems = orderReadHelper.getOrderItems() + orderAdjustments = orderReadHelper.getAdjustments() + orderHeaderAdjustments = orderReadHelper.getOrderHeaderAdjustments() + orderSubTotal = orderReadHelper.getOrderItemsSubTotal() + orderItemShipGroups = orderReadHelper.getOrderItemShipGroups() + headerAdjustmentsToShow = orderReadHelper.getOrderHeaderAdjustmentsToShow() - orderShippingTotal = OrderReadHelper.getAllOrderItemsAdjustmentsTotal(orderItems, orderAdjustments, false, false, true); - orderShippingTotal = orderShippingTotal.add(OrderReadHelper.calcOrderAdjustments(orderHeaderAdjustments, orderSubTotal, false, false, true)); + orderShippingTotal = OrderReadHelper.getAllOrderItemsAdjustmentsTotal(orderItems, orderAdjustments, false, false, true) + orderShippingTotal = orderShippingTotal.add(OrderReadHelper.calcOrderAdjustments(orderHeaderAdjustments, orderSubTotal, false, false, true)) - orderTaxTotal = OrderReadHelper.getAllOrderItemsAdjustmentsTotal(orderItems, orderAdjustments, false, true, false); - orderTaxTotal = orderTaxTotal.add(OrderReadHelper.calcOrderAdjustments(orderHeaderAdjustments, orderSubTotal, false, true, false)); + orderTaxTotal = OrderReadHelper.getAllOrderItemsAdjustmentsTotal(orderItems, orderAdjustments, false, true, false) + orderTaxTotal = orderTaxTotal.add(OrderReadHelper.calcOrderAdjustments(orderHeaderAdjustments, orderSubTotal, false, true, false)) - placingCustomerOrderRole = from("OrderRole").where("orderId", orderId, "roleTypeId", roleTypeId).queryFirst(); - placingCustomerPerson = placingCustomerOrderRole == null ? null : from("Person").where("partyId", placingCustomerOrderRole.partyId).queryOne(); + placingCustomerOrderRole = from("OrderRole").where("orderId", orderId, "roleTypeId", roleTypeId).queryFirst() + placingCustomerPerson = placingCustomerOrderRole == null ? null : from("Person").where("partyId", placingCustomerOrderRole.partyId).queryOne() - billingAccount = orderHeader.getRelatedOne("BillingAccount", false); + billingAccount = orderHeader.getRelatedOne("BillingAccount", false) - orderPaymentPreferences = EntityUtil.filterByAnd(orderHeader.getRelated("OrderPaymentPreference", null, null, false), [EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "PAYMENT_CANCELLED")]); - paymentMethods = []; + orderPaymentPreferences = EntityUtil.filterByAnd(orderHeader.getRelated("OrderPaymentPreference", null, null, false), [EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "PAYMENT_CANCELLED")]) + paymentMethods = [] orderPaymentPreferences.each { opp -> - paymentMethod = opp.getRelatedOne("PaymentMethod", false); + paymentMethod = opp.getRelatedOne("PaymentMethod", false) if (paymentMethod) { - paymentMethods.add(paymentMethod); + paymentMethods.add(paymentMethod) } else { - paymentMethodType = opp.getRelatedOne("PaymentMethodType", false); + paymentMethodType = opp.getRelatedOne("PaymentMethodType", false) if (paymentMethodType) { - context.paymentMethodType = paymentMethodType; + context.paymentMethodType = paymentMethodType } } } - payToPartyId = productStore.payToPartyId; - paymentAddress = PaymentWorker.getPaymentAddress(delegator, payToPartyId); - if (paymentAddress) context.paymentAddress = paymentAddress; + payToPartyId = productStore.payToPartyId + paymentAddress = PaymentWorker.getPaymentAddress(delegator, payToPartyId) + if (paymentAddress) context.paymentAddress = paymentAddress // get Shipment tracking info orderShipmentInfoSummaryList = select("shipmentId", "shipmentRouteSegmentId", "carrierPartyId", "shipmentMethodTypeId","shipmentPackageSeqId","trackingCode","boxNumber") @@ -158,59 +158,59 @@ if (orderHeader) { .where("orderId", orderId) .orderBy("shipmentId", "shipmentRouteSegmentId", "shipmentPackageSeqId") .distinct(true) - .queryList(); + .queryList() - customerPoNumberSet = new TreeSet(); + customerPoNumberSet = new TreeSet() orderItems.each { orderItemPo -> - correspondingPoId = orderItemPo.correspondingPoId; + correspondingPoId = orderItemPo.correspondingPoId if (correspondingPoId && !"(none)".equals(correspondingPoId)) { - customerPoNumberSet.add(correspondingPoId); + customerPoNumberSet.add(correspondingPoId) } } // check if there are returnable items - returned = 0.00; - totalItems = 0.00; + returned = 0.00 + totalItems = 0.00 orderItems.each { oitem -> - totalItems += oitem.quantity; - ritems = oitem.getRelated("ReturnItem", null, null, false); + totalItems += oitem.quantity + ritems = oitem.getRelated("ReturnItem", null, null, false) ritems.each { ritem -> - rh = ritem.getRelatedOne("ReturnHeader", false); + rh = ritem.getRelatedOne("ReturnHeader", false) if (!rh.statusId.equals("RETURN_CANCELLED")) { - returned += ritem.returnQuantity; + returned += ritem.returnQuantity } } } if (totalItems > returned) { - context.returnLink = "Y"; + context.returnLink = "Y" } - context.orderId = orderId; - context.orderHeader = orderHeader; - context.localOrderReadHelper = orderReadHelper; - context.orderItems = orderItems; - context.orderAdjustments = orderAdjustments; - context.orderHeaderAdjustments = orderHeaderAdjustments; - context.orderSubTotal = orderSubTotal; - context.orderItemShipGroups = orderItemShipGroups; - context.headerAdjustmentsToShow = headerAdjustmentsToShow; - context.currencyUomId = orderReadHelper.getCurrency(); + context.orderId = orderId + context.orderHeader = orderHeader + context.localOrderReadHelper = orderReadHelper + context.orderItems = orderItems + context.orderAdjustments = orderAdjustments + context.orderHeaderAdjustments = orderHeaderAdjustments + context.orderSubTotal = orderSubTotal + context.orderItemShipGroups = orderItemShipGroups + context.headerAdjustmentsToShow = headerAdjustmentsToShow + context.currencyUomId = orderReadHelper.getCurrency() - context.orderShippingTotal = orderShippingTotal; - context.orderTaxTotal = orderTaxTotal; - context.orderGrandTotal = OrderReadHelper.getOrderGrandTotal(orderItems, orderAdjustments); - context.placingCustomerPerson = placingCustomerPerson; + context.orderShippingTotal = orderShippingTotal + context.orderTaxTotal = orderTaxTotal + context.orderGrandTotal = OrderReadHelper.getOrderGrandTotal(orderItems, orderAdjustments) + context.placingCustomerPerson = placingCustomerPerson - context.billingAccount = billingAccount; - context.paymentMethods = paymentMethods; + context.billingAccount = billingAccount + context.paymentMethods = paymentMethods - context.productStore = productStore; - context.isDemoStore = isDemoStore; + context.productStore = productStore + context.isDemoStore = isDemoStore - context.orderShipmentInfoSummaryList = orderShipmentInfoSummaryList; - context.customerPoNumberSet = customerPoNumberSet; + context.orderShipmentInfoSummaryList = orderShipmentInfoSummaryList + context.customerPoNumberSet = customerPoNumberSet - orderItemChangeReasons = from("Enumeration").where("enumTypeId", "ODR_ITM_CH_REASON").queryList(); - context.orderItemChangeReasons = orderItemChangeReasons; + orderItemChangeReasons = from("Enumeration").where("enumTypeId", "ODR_ITM_CH_REASON").queryList() + context.orderItemChangeReasons = orderItemChangeReasons } diff --git a/ecommerce/groovyScripts/order/PaymentInformation.groovy b/ecommerce/groovyScripts/order/PaymentInformation.groovy index 54d41fa01..25cbc48cc 100644 --- a/ecommerce/groovyScripts/order/PaymentInformation.groovy +++ b/ecommerce/groovyScripts/order/PaymentInformation.groovy @@ -17,72 +17,72 @@ * under the License. */ -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.entity.util.*; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.accounting.payment.*; -import org.apache.ofbiz.order.shoppingcart.*; -import org.apache.ofbiz.party.contact.*; +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.entity.util.* +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.accounting.payment.* +import org.apache.ofbiz.order.shoppingcart.* +import org.apache.ofbiz.party.contact.* -cart = ShoppingCartEvents.getCartObject(request); -context.cart = cart; +cart = ShoppingCartEvents.getCartObject(request) +context.cart = cart -partyId = cart.getPartyId(); -currencyUomId = cart.getCurrency(); +partyId = cart.getPartyId() +currencyUomId = cart.getCurrency() if (!partyId) { - partyId = userLogin.partyId; + partyId = userLogin.partyId } -context.partyId = partyId; +context.partyId = partyId if (partyId && !partyId.equals("_NA_")) { - party = from("Party").where("partyId", partyId).queryOne(); - person = party.getRelatedOne("Person", false); - context.party = party; - context.person = person; + party = from("Party").where("partyId", partyId).queryOne() + person = party.getRelatedOne("Person", false) + context.party = party + context.person = person } // nuke the event messages -request.removeAttribute("_EVENT_MESSAGE_"); +request.removeAttribute("_EVENT_MESSAGE_") if (parameters.useShipAddr && cart.getShippingContactMechId()) { - shippingContactMech = cart.getShippingContactMechId(); - postalAddress = from("PostalAddress").where("contactMechId", shippingContactMech).queryOne(); - context.useEntityFields = "Y"; - context.postalAddress = postalAddress; + shippingContactMech = cart.getShippingContactMechId() + postalAddress = from("PostalAddress").where("contactMechId", shippingContactMech).queryOne() + context.useEntityFields = "Y" + context.postalAddress = postalAddress if (postalAddress && partyId) { - partyContactMech = from("PartyContactMech").where("partyId", partyId, "contactMechId", postalAddress.contactMechId).orderBy("-fromDate").filterByDate().queryFirst(); - context.partyContactMech = partyContactMech; + partyContactMech = from("PartyContactMech").where("partyId", partyId, "contactMechId", postalAddress.contactMechId).orderBy("-fromDate").filterByDate().queryFirst() + context.partyContactMech = partyContactMech } } else { - context.postalAddress = UtilHttp.getParameterMap(request); + context.postalAddress = UtilHttp.getParameterMap(request) } if (cart) { if (cart.getPaymentMethodIds()) { - paymentMethods = cart.getPaymentMethods(); + paymentMethods = cart.getPaymentMethods() paymentMethods.each { paymentMethod -> - account = null; + account = null if ("CREDIT_CARD".equals(paymentMethod?.paymentMethodTypeId)) { - account = paymentMethod.getRelatedOne("CreditCard", false); - context.creditCard = account; - context.paymentMethodTypeId = "CREDIT_CARD"; + account = paymentMethod.getRelatedOne("CreditCard", false) + context.creditCard = account + context.paymentMethodTypeId = "CREDIT_CARD" } else if ("EFT_ACCOUNT".equals(paymentMethod?.paymentMethodTypeId)) { - account = paymentMethod.getRelatedOne("EftAccount", false); - context.eftAccount = account; - context.paymentMethodTypeId = "EFT_ACCOUNT"; + account = paymentMethod.getRelatedOne("EftAccount", false) + context.eftAccount = account + context.paymentMethodTypeId = "EFT_ACCOUNT" } else if ("GIFT_CARD".equals(paymentMethod?.paymentMethodTypeId)) { - account = paymentMethod.getRelatedOne("GiftCard", false); - context.giftCard = account; - context.paymentMethodTypeId = "GIFT_CARD"; - context.addGiftCard = "Y"; + account = paymentMethod.getRelatedOne("GiftCard", false) + context.giftCard = account + context.paymentMethodTypeId = "GIFT_CARD" + context.addGiftCard = "Y" } else { - context.paymentMethodTypeId = "EXT_OFFLINE"; + context.paymentMethodTypeId = "EXT_OFFLINE" } if (account && !parameters.useShipAddr) { - address = account.getRelatedOne("PostalAddress", false); - context.postalAddress = address; + address = account.getRelatedOne("PostalAddress", false) + context.postalAddress = address } } } @@ -90,28 +90,28 @@ if (cart) { if (!parameters.useShipAddr) { if (cart && context.postalAddress) { - postalAddress = context.postalAddress; - shippingContactMechId = cart.getShippingContactMechId(); - contactMechId = postalAddress.contactMechId; + postalAddress = context.postalAddress + shippingContactMechId = cart.getShippingContactMechId() + contactMechId = postalAddress.contactMechId if (shippingContactMechId?.equals(contactMechId)) { - context.useShipAddr = "Y"; + context.useShipAddr = "Y" } } } else { - context.useShipAddr = parameters.useShipAddr; + context.useShipAddr = parameters.useShipAddr } // Added here to satisfy GenericAddress.ftl if (context.postalAddress) { - postalAddress = context.postalAddress; - parameters.address1 = postalAddress.address1; - parameters.address2 = postalAddress.address2; - parameters.city = postalAddress.city; - parameters.stateProvinceGeoId = postalAddress.stateProvinceGeoId; - parameters.postalCode = postalAddress.postalCode; - parameters.countryGeoId = postalAddress.countryGeoId; - parameters.contactMechId = postalAddress.contactMechId; + postalAddress = context.postalAddress + parameters.address1 = postalAddress.address1 + parameters.address2 = postalAddress.address2 + parameters.city = postalAddress.city + parameters.stateProvinceGeoId = postalAddress.stateProvinceGeoId + parameters.postalCode = postalAddress.postalCode + parameters.countryGeoId = postalAddress.countryGeoId + parameters.contactMechId = postalAddress.contactMechId if (context.creditCard) { - context.callSubmitForm = true; + context.callSubmitForm = true } } diff --git a/ecommerce/groovyScripts/order/PaymentOptions.groovy b/ecommerce/groovyScripts/order/PaymentOptions.groovy index 3e04c4182..cc1612d45 100644 --- a/ecommerce/groovyScripts/order/PaymentOptions.groovy +++ b/ecommerce/groovyScripts/order/PaymentOptions.groovy @@ -17,16 +17,16 @@ * under the License. */ -import org.apache.ofbiz.order.shoppingcart.*; +import org.apache.ofbiz.order.shoppingcart.* //Get the Cart -cart = ShoppingCartEvents.getCartObject(request); -paymentMethodTypeIds = cart.getPaymentMethodTypeIds(); +cart = ShoppingCartEvents.getCartObject(request) +paymentMethodTypeIds = cart.getPaymentMethodTypeIds() paymentMethodTypeIds.each { paymentMethodTypeId -> - context.callSubmitForm = true; + context.callSubmitForm = true if ("GIFT_CARD".equals(paymentMethodTypeId)) { - context.addGiftCard = "Y"; + context.addGiftCard = "Y" } else { - context.paymentMethodTypeId = paymentMethodTypeId; + context.paymentMethodTypeId = paymentMethodTypeId } } diff --git a/ecommerce/groovyScripts/order/QuickAnonCheckoutLinks.groovy b/ecommerce/groovyScripts/order/QuickAnonCheckoutLinks.groovy index fcc8808e4..8d886fc24 100644 --- a/ecommerce/groovyScripts/order/QuickAnonCheckoutLinks.groovy +++ b/ecommerce/groovyScripts/order/QuickAnonCheckoutLinks.groovy @@ -16,16 +16,16 @@ * specific language governing permissions and limitations * under the License. */ -import org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents; +import org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents -shoppingCart = ShoppingCartEvents.getCartObject(request); +shoppingCart = ShoppingCartEvents.getCartObject(request) -userLogin = context.userLogin; +userLogin = context.userLogin if (userLogin) { - context.enableShippingAddress = true; + context.enableShippingAddress = true } -shippingContactMechId = shoppingCart.getShippingContactMechId(); +shippingContactMechId = shoppingCart.getShippingContactMechId() if (shippingContactMechId) { - context.enableShipmentMethod = true; + context.enableShipmentMethod = true } diff --git a/ecommerce/groovyScripts/order/QuickAnonCustSettings.groovy b/ecommerce/groovyScripts/order/QuickAnonCustSettings.groovy index 0f2f87762..a8e97bfd8 100644 --- a/ecommerce/groovyScripts/order/QuickAnonCustSettings.groovy +++ b/ecommerce/groovyScripts/order/QuickAnonCustSettings.groovy @@ -17,123 +17,123 @@ * under the License. */ -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.util.EntityUtil; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.entity.util.*; -import org.apache.ofbiz.order.shoppingcart.*; -import org.apache.ofbiz.party.contact.*; -import org.apache.ofbiz.product.catalog.*; +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.util.EntityUtil +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.entity.util.* +import org.apache.ofbiz.order.shoppingcart.* +import org.apache.ofbiz.party.contact.* +import org.apache.ofbiz.product.catalog.* -partyId = null; +partyId = null -userLogin = context.userLogin; +userLogin = context.userLogin if (userLogin) { - partyId = userLogin.partyId; + partyId = userLogin.partyId } if (!partyId && parameters.partyId) { - partyId = parameters.partyId; + partyId = parameters.partyId } if (partyId) { - parameters.partyId = partyId; + parameters.partyId = partyId // NOTE: if there was an error, then don't look up and fill in all of this data, just use the values from the previous request (which will be in the parameters Map automagically) if (!request.getAttribute("_ERROR_MESSAGE_") && !request.getAttribute("_ERROR_MESSAGE_LIST_")) { - person = from("Person").where("partyId", partyId).queryOne(); + person = from("Person").where("partyId", partyId).queryOne() if (person) { - context.callSubmitForm = true; + context.callSubmitForm = true // should never be null for the anonymous checkout, but just in case - parameters.firstName = person.firstName; - parameters.middleName = person.middleName; - parameters.lastName = person.lastName; + parameters.firstName = person.firstName + parameters.middleName = person.middleName + parameters.lastName = person.lastName } // get the Email Address - emailPartyContactDetail = from("PartyContactDetailByPurpose").where("partyId", partyId, "contactMechPurposeTypeId", "PRIMARY_EMAIL").filterByDate().queryFirst(); + emailPartyContactDetail = from("PartyContactDetailByPurpose").where("partyId", partyId, "contactMechPurposeTypeId", "PRIMARY_EMAIL").filterByDate().queryFirst() if (emailPartyContactDetail) { - parameters.emailContactMechId = emailPartyContactDetail.contactMechId; - parameters.emailAddress = emailPartyContactDetail.infoString; - parameters.emailSol = emailPartyContactDetail.allowSolicitation; + parameters.emailContactMechId = emailPartyContactDetail.contactMechId + parameters.emailAddress = emailPartyContactDetail.infoString + parameters.emailSol = emailPartyContactDetail.allowSolicitation } // get the Phone Numbers - homePhonePartyContactDetail = from("PartyContactDetailByPurpose").where("partyId", partyId, "contactMechPurposeTypeId", "PHONE_HOME").filterByDate().queryFirst(); + homePhonePartyContactDetail = from("PartyContactDetailByPurpose").where("partyId", partyId, "contactMechPurposeTypeId", "PHONE_HOME").filterByDate().queryFirst() if (homePhonePartyContactDetail) { - parameters.homePhoneContactMechId = homePhonePartyContactDetail.contactMechId; - parameters.homeCountryCode = homePhonePartyContactDetail.countryCode; - parameters.homeAreaCode = homePhonePartyContactDetail.areaCode; - parameters.homeContactNumber = homePhonePartyContactDetail.contactNumber; - parameters.homeExt = homePhonePartyContactDetail.extension; - parameters.homeSol = homePhonePartyContactDetail.allowSolicitation; + parameters.homePhoneContactMechId = homePhonePartyContactDetail.contactMechId + parameters.homeCountryCode = homePhonePartyContactDetail.countryCode + parameters.homeAreaCode = homePhonePartyContactDetail.areaCode + parameters.homeContactNumber = homePhonePartyContactDetail.contactNumber + parameters.homeExt = homePhonePartyContactDetail.extension + parameters.homeSol = homePhonePartyContactDetail.allowSolicitation } - workPhonePartyContactDetail = from("PartyContactDetailByPurpose").where(partyId : partyId, contactMechPurposeTypeId : "PHONE_WORK").filterByDate().queryFirst(); + workPhonePartyContactDetail = from("PartyContactDetailByPurpose").where(partyId : partyId, contactMechPurposeTypeId : "PHONE_WORK").filterByDate().queryFirst() if (workPhonePartyContactDetail) { - parameters.workPhoneContactMechId = workPhonePartyContactDetail.contactMechId; - parameters.workCountryCode = workPhonePartyContactDetail.countryCode; - parameters.workAreaCode = workPhonePartyContactDetail.areaCode; - parameters.workContactNumber = workPhonePartyContactDetail.contactNumber; - parameters.workExt = workPhonePartyContactDetail.extension; - parameters.workSol = workPhonePartyContactDetail.allowSolicitation; + parameters.workPhoneContactMechId = workPhonePartyContactDetail.contactMechId + parameters.workCountryCode = workPhonePartyContactDetail.countryCode + parameters.workAreaCode = workPhonePartyContactDetail.areaCode + parameters.workContactNumber = workPhonePartyContactDetail.contactNumber + parameters.workExt = workPhonePartyContactDetail.extension + parameters.workSol = workPhonePartyContactDetail.allowSolicitation } } } -cart = session.getAttribute("shoppingCart"); -cartPartyId = cart.getPartyId(); -context.cart = cart; +cart = session.getAttribute("shoppingCart") +cartPartyId = cart.getPartyId() +context.cart = cart // nuke the event messages -request.removeAttribute("_EVENT_MESSAGE_"); +request.removeAttribute("_EVENT_MESSAGE_") if (cartPartyId && !cartPartyId.equals("_NA_")) { - cartParty = from("Party").where("partyId", cartPartyId).queryOne(); + cartParty = from("Party").where("partyId", cartPartyId).queryOne() if (cartParty) { - cartPerson = cartParty.getRelatedOne("Person", false); - context.party = cartParty; - context.person = cartPerson; + cartPerson = cartParty.getRelatedOne("Person", false) + context.party = cartParty + context.person = cartPerson } } if (cart && cart.getShippingContactMechId()) { - shippingContactMechId = cart.getShippingContactMechId(); - shippingPartyContactDetail = from("PartyContactDetailByPurpose").where("partyId", cartPartyId, "contactMechId", shippingContactMechId).filterByDate().queryFirst(); - parameters.shippingContactMechId = shippingPartyContactDetail.contactMechId; - context.callSubmitForm = true; - parameters.shipToName = shippingPartyContactDetail.toName; - parameters.shipToAttnName = shippingPartyContactDetail.attnName; - parameters.shipToAddress1 = shippingPartyContactDetail.address1; - parameters.shipToAddress2 = shippingPartyContactDetail.address2; - parameters.shipToCity = shippingPartyContactDetail.city; - parameters.shipToPostalCode = shippingPartyContactDetail.postalCode; - parameters.shipToStateProvinceGeoId = shippingPartyContactDetail.stateProvinceGeoId; - parameters.shipToCountryGeoId = shippingPartyContactDetail.countryGeoId; + shippingContactMechId = cart.getShippingContactMechId() + shippingPartyContactDetail = from("PartyContactDetailByPurpose").where("partyId", cartPartyId, "contactMechId", shippingContactMechId).filterByDate().queryFirst() + parameters.shippingContactMechId = shippingPartyContactDetail.contactMechId + context.callSubmitForm = true + parameters.shipToName = shippingPartyContactDetail.toName + parameters.shipToAttnName = shippingPartyContactDetail.attnName + parameters.shipToAddress1 = shippingPartyContactDetail.address1 + parameters.shipToAddress2 = shippingPartyContactDetail.address2 + parameters.shipToCity = shippingPartyContactDetail.city + parameters.shipToPostalCode = shippingPartyContactDetail.postalCode + parameters.shipToStateProvinceGeoId = shippingPartyContactDetail.stateProvinceGeoId + parameters.shipToCountryGeoId = shippingPartyContactDetail.countryGeoId } else { - context.postalFields = UtilHttp.getParameterMap(request); + context.postalFields = UtilHttp.getParameterMap(request) } -billingContactMechId = session.getAttribute("billingContactMechId"); +billingContactMechId = session.getAttribute("billingContactMechId") if (billingContactMechId) { - billPostalAddress = from("PostalAddress").where("contactMechId", billingContactMechId).queryOne(); - parameters.billingContactMechId = billPostalAddress.contactMechId; - parameters.billToName = billPostalAddress.toName; - parameters.billToAttnName = billPostalAddress.attnName; - parameters.billToAddress1 = billPostalAddress.address1; - parameters.billToAddress2 = billPostalAddress.address2; - parameters.billToCity = billPostalAddress.city; - parameters.billToPostalCode = billPostalAddress.postalCode; - parameters.billToStateProvinceGeoId = billPostalAddress.stateProvinceGeoId; - parameters.billToCountryGeoId = billPostalAddress.countryGeoId; + billPostalAddress = from("PostalAddress").where("contactMechId", billingContactMechId).queryOne() + parameters.billingContactMechId = billPostalAddress.contactMechId + parameters.billToName = billPostalAddress.toName + parameters.billToAttnName = billPostalAddress.attnName + parameters.billToAddress1 = billPostalAddress.address1 + parameters.billToAddress2 = billPostalAddress.address2 + parameters.billToCity = billPostalAddress.city + parameters.billToPostalCode = billPostalAddress.postalCode + parameters.billToStateProvinceGeoId = billPostalAddress.stateProvinceGeoId + parameters.billToCountryGeoId = billPostalAddress.countryGeoId } if (cart?.getShippingContactMechId() && shippingPartyContactDetail) { - shippingContactMechId = shippingPartyContactDetail.contactMechId; + shippingContactMechId = shippingPartyContactDetail.contactMechId if (billingContactMechId?.equals(shippingContactMechId)) { - context.useShippingPostalAddressForBilling = "Y"; + context.useShippingPostalAddressForBilling = "Y" } } -parameters.shippingContactMechPurposeTypeId = "SHIPPING_LOCATION"; -parameters.billingContactMechPurposeTypeId = "BILLING_LOCATION"; +parameters.shippingContactMechPurposeTypeId = "SHIPPING_LOCATION" +parameters.billingContactMechPurposeTypeId = "BILLING_LOCATION" diff --git a/ecommerce/groovyScripts/order/QuickAnonOptionSettings.groovy b/ecommerce/groovyScripts/order/QuickAnonOptionSettings.groovy index e21942981..399d70313 100644 --- a/ecommerce/groovyScripts/order/QuickAnonOptionSettings.groovy +++ b/ecommerce/groovyScripts/order/QuickAnonOptionSettings.groovy @@ -17,40 +17,40 @@ * under the License. */ -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.order.shoppingcart.*; -import org.apache.ofbiz.order.shoppingcart.shipping.*; -import org.apache.ofbiz.party.contact.*; -import org.apache.ofbiz.product.store.*; +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.order.shoppingcart.* +import org.apache.ofbiz.order.shoppingcart.shipping.* +import org.apache.ofbiz.party.contact.* +import org.apache.ofbiz.product.store.* -shoppingCart = session.getAttribute("shoppingCart"); -context.shoppingCart = shoppingCart; -productStore = ProductStoreWorker.getProductStore(request); +shoppingCart = session.getAttribute("shoppingCart") +context.shoppingCart = shoppingCart +productStore = ProductStoreWorker.getProductStore(request) if (shoppingCart) { - shippingEstWpr = new ShippingEstimateWrapper(dispatcher, shoppingCart, 0); - context.shippingEstWpr = shippingEstWpr; - context.carrierShipmentMethodList = shippingEstWpr.getShippingMethods(); + shippingEstWpr = new ShippingEstimateWrapper(dispatcher, shoppingCart, 0) + context.shippingEstWpr = shippingEstWpr + context.carrierShipmentMethodList = shippingEstWpr.getShippingMethods() } // nuke the event messages -request.removeAttribute("_EVENT_MESSAGE_"); +request.removeAttribute("_EVENT_MESSAGE_") -party = null; -partyId = session.getAttribute("orderPartyId"); +party = null +partyId = session.getAttribute("orderPartyId") if (partyId) { - party = from("Party").where("partyId", partyId).queryOne(); - context.party = party; + party = from("Party").where("partyId", partyId).queryOne() + context.party = party } -context.emailList = ContactHelper.getContactMechByType(party, "EMAIL_ADDRESS", false); +context.emailList = ContactHelper.getContactMechByType(party, "EMAIL_ADDRESS", false) if (shoppingCart?.getShipmentMethodTypeId() && shoppingCart.getCarrierPartyId()) { - context.chosenShippingMethod = shoppingCart.getShipmentMethodTypeId() + '@' + shoppingCart.getCarrierPartyId(); - context.callSubmitForm = true; + context.chosenShippingMethod = shoppingCart.getShipmentMethodTypeId() + '@' + shoppingCart.getCarrierPartyId() + context.callSubmitForm = true } -context.productStoreId = productStore.productStoreId; -context.productStore = productStore; +context.productStoreId = productStore.productStoreId +context.productStore = productStore diff --git a/ecommerce/groovyScripts/order/QuickAnonPaymentInformation.groovy b/ecommerce/groovyScripts/order/QuickAnonPaymentInformation.groovy index b1fca05c1..57e3bbda1 100644 --- a/ecommerce/groovyScripts/order/QuickAnonPaymentInformation.groovy +++ b/ecommerce/groovyScripts/order/QuickAnonPaymentInformation.groovy @@ -17,27 +17,27 @@ * under the License. */ -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.entity.util.*; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.accounting.payment.*; -import org.apache.ofbiz.order.shoppingcart.*; -import org.apache.ofbiz.party.contact.*; +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.entity.util.* +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.accounting.payment.* +import org.apache.ofbiz.order.shoppingcart.* +import org.apache.ofbiz.party.contact.* -cart = ShoppingCartEvents.getCartObject(request); -context.cart = cart; +cart = ShoppingCartEvents.getCartObject(request) +context.cart = cart -paymentMethodTypeId = parameters.paymentMethodTypeId ?: "CREDIT_CARD"; +paymentMethodTypeId = parameters.paymentMethodTypeId ?: "CREDIT_CARD" // nuke the event messages -request.removeAttribute("_EVENT_MESSAGE_"); +request.removeAttribute("_EVENT_MESSAGE_") if (cart?.getPaymentMethodIds()) { - paymentMethods = cart.getPaymentMethods(); + paymentMethods = cart.getPaymentMethods() paymentMethods.each {paymentMethod -> if ("CREDIT_CARD".equals(paymentMethod?.paymentMethodTypeId)) { - paymentMethodId = paymentMethod.paymentMethodId; - parameters.paymentMethodId = paymentMethodId; + paymentMethodId = paymentMethod.paymentMethodId + parameters.paymentMethodId = paymentMethodId } } } diff --git a/ecommerce/groovyScripts/order/RequestReturn.groovy b/ecommerce/groovyScripts/order/RequestReturn.groovy index e523d6d0f..39bd5e247 100644 --- a/ecommerce/groovyScripts/order/RequestReturn.groovy +++ b/ecommerce/groovyScripts/order/RequestReturn.groovy @@ -17,39 +17,39 @@ * under the License. */ -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.party.contact.*; +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.party.contact.* -orderId = parameters.orderId; -context.orderId = orderId; +orderId = parameters.orderId +context.orderId = orderId -party = userLogin.getRelatedOne("Party", false); -context.party = party; +party = userLogin.getRelatedOne("Party", false) +context.party = party -returnTypes = from("ReturnType").orderBy("sequenceId").queryList(); -context.returnTypes = returnTypes; +returnTypes = from("ReturnType").orderBy("sequenceId").queryList() +context.returnTypes = returnTypes -returnReasons = from("ReturnReason").orderBy("sequenceId").queryList(); -context.returnReasons = returnReasons; +returnReasons = from("ReturnReason").orderBy("sequenceId").queryList() +context.returnReasons = returnReasons if (orderId) { - returnRes = runService('getReturnableItems', [orderId : orderId]); - context.returnableItems = returnRes.returnableItems; - orderHeader = from("OrderHeader").where("orderId", orderId).queryOne(); - context.orderHeader = orderHeader; + returnRes = runService('getReturnableItems', [orderId : orderId]) + context.returnableItems = returnRes.returnableItems + orderHeader = from("OrderHeader").where("orderId", orderId).queryOne() + context.orderHeader = orderHeader } -returnItemTypeMap = from("ReturnItemTypeMap").where("returnHeaderTypeId", "CUSTOMER_RETURN").queryList(); -typeMap = new HashMap(); +returnItemTypeMap = from("ReturnItemTypeMap").where("returnHeaderTypeId", "CUSTOMER_RETURN").queryList() +typeMap = new HashMap() returnItemTypeMap.each { value -> typeMap[value.returnItemMapKey] = value.returnItemTypeId } -context.returnItemTypeMap = typeMap; +context.returnItemTypeMap = typeMap //put in the return to party information from the order header if (orderId) { - order = from("OrderHeader").where("orderId", orderId).queryOne(); - productStore = order.getRelatedOne("ProductStore", false); - context.toPartyId = productStore.payToPartyId; + order = from("OrderHeader").where("orderId", orderId).queryOne() + productStore = order.getRelatedOne("ProductStore", false) + context.toPartyId = productStore.payToPartyId } -context.shippingContactMechList = ContactHelper.getContactMech(party, "SHIPPING_LOCATION", "POSTAL_ADDRESS", false); +context.shippingContactMechList = ContactHelper.getContactMech(party, "SHIPPING_LOCATION", "POSTAL_ADDRESS", false) diff --git a/ecommerce/groovyScripts/order/ShipSettings.groovy b/ecommerce/groovyScripts/order/ShipSettings.groovy index 1979ae659..7a8d96f24 100644 --- a/ecommerce/groovyScripts/order/ShipSettings.groovy +++ b/ecommerce/groovyScripts/order/ShipSettings.groovy @@ -17,59 +17,59 @@ * under the License. */ -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.entity.util.*; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.order.shoppingcart.*; -import org.apache.ofbiz.party.contact.*; -import org.apache.ofbiz.product.catalog.*; +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.entity.util.* +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.order.shoppingcart.* +import org.apache.ofbiz.party.contact.* +import org.apache.ofbiz.product.catalog.* -cart = session.getAttribute("shoppingCart"); -partyId = cart.getPartyId(); -context.cart = cart; +cart = session.getAttribute("shoppingCart") +partyId = cart.getPartyId() +context.cart = cart // nuke the event messages -request.removeAttribute("_EVENT_MESSAGE_"); +request.removeAttribute("_EVENT_MESSAGE_") if (partyId && !partyId.equals("_NA_")) { - party = from("Party").where("partyId", partyId).queryOne(); - person = party.getRelatedOne("Person", false); - context.party = party; - context.person = person; + party = from("Party").where("partyId", partyId).queryOne() + person = party.getRelatedOne("Person", false) + context.party = party + context.person = person } if (cart?.getShippingContactMechId()) { - shippingContactMechId = cart.getShippingContactMechId(); - shippingPartyContactDetail = from("PartyContactDetailByPurpose").where("partyId", partyId, "contactMechId", shippingContactMechId).filterByDate().queryFirst(); - parameters.shippingContactMechId = shippingPartyContactDetail.contactMechId; - context.callSubmitForm = true; + shippingContactMechId = cart.getShippingContactMechId() + shippingPartyContactDetail = from("PartyContactDetailByPurpose").where("partyId", partyId, "contactMechId", shippingContactMechId).filterByDate().queryFirst() + parameters.shippingContactMechId = shippingPartyContactDetail.contactMechId + context.callSubmitForm = true - fullAddressBuf = new StringBuffer(); - fullAddressBuf.append(shippingPartyContactDetail.address1); + fullAddressBuf = new StringBuffer() + fullAddressBuf.append(shippingPartyContactDetail.address1) if (shippingPartyContactDetail.address2) { - fullAddressBuf.append(", "); - fullAddressBuf.append(shippingPartyContactDetail.address2); + fullAddressBuf.append(", ") + fullAddressBuf.append(shippingPartyContactDetail.address2) } - fullAddressBuf.append(", "); - fullAddressBuf.append(shippingPartyContactDetail.city); - fullAddressBuf.append(", "); - fullAddressBuf.append(shippingPartyContactDetail.postalCode); - parameters.fullAddress = fullAddressBuf.toString(); + fullAddressBuf.append(", ") + fullAddressBuf.append(shippingPartyContactDetail.city) + fullAddressBuf.append(", ") + fullAddressBuf.append(shippingPartyContactDetail.postalCode) + parameters.fullAddress = fullAddressBuf.toString() // NOTE: these parameters are a special case because they might be filled in by the address lookup service, so if they are there we won't fill in over them... if (!parameters.postalCode) { - parameters.attnName = shippingPartyContactDetail.attnName; - parameters.address1 = shippingPartyContactDetail.address1; - parameters.address2 = shippingPartyContactDetail.address2; - parameters.city = shippingPartyContactDetail.city; - parameters.postalCode = shippingPartyContactDetail.postalCode; - parameters.stateProvinceGeoId = shippingPartyContactDetail.stateProvinceGeoId; - parameters.countryGeoId = shippingPartyContactDetail.countryGeoId; - parameters.allowSolicitation = shippingPartyContactDetail.allowSolicitation; + parameters.attnName = shippingPartyContactDetail.attnName + parameters.address1 = shippingPartyContactDetail.address1 + parameters.address2 = shippingPartyContactDetail.address2 + parameters.city = shippingPartyContactDetail.city + parameters.postalCode = shippingPartyContactDetail.postalCode + parameters.stateProvinceGeoId = shippingPartyContactDetail.stateProvinceGeoId + parameters.countryGeoId = shippingPartyContactDetail.countryGeoId + parameters.allowSolicitation = shippingPartyContactDetail.allowSolicitation } - parameters.yearsAtAddress = shippingPartyContactDetail.yearsWithContactMech; - parameters.monthsAtAddress = shippingPartyContactDetail.monthsWithContactMech; + parameters.yearsAtAddress = shippingPartyContactDetail.yearsWithContactMech + parameters.monthsAtAddress = shippingPartyContactDetail.monthsWithContactMech } else { - context.postalFields = UtilHttp.getParameterMap(request); + context.postalFields = UtilHttp.getParameterMap(request) } diff --git a/ecommerce/groovyScripts/order/ShipmentStatus.groovy b/ecommerce/groovyScripts/order/ShipmentStatus.groovy index 4ad612fa0..3ba9e52a0 100644 --- a/ecommerce/groovyScripts/order/ShipmentStatus.groovy +++ b/ecommerce/groovyScripts/order/ShipmentStatus.groovy @@ -17,16 +17,16 @@ * under the License. */ -import org.apache.ofbiz.base.util.UtilMisc; -import org.apache.ofbiz.entity.Delegator; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.entity.condition.*; -import org.apache.ofbiz.entity.util.*; +import org.apache.ofbiz.base.util.UtilMisc +import org.apache.ofbiz.entity.Delegator +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.entity.condition.* +import org.apache.ofbiz.entity.util.* -shipmentId = parameters.shipmentId; +shipmentId = parameters.shipmentId if (shipmentId) { - shipment = from("Shipment").where("shipmentId", shipmentId).queryOne(); - shipmentItems = from("ShipmentItem").where("shipmentId", shipmentId).queryList(); + shipment = from("Shipment").where("shipmentId", shipmentId).queryOne() + shipmentItems = from("ShipmentItem").where("shipmentId", shipmentId).queryList() // get Shipment tracking info orderShipmentInfoSummaryList = select("shipmentId", "shipmentRouteSegmentId", "shipmentPackageSeqId", "carrierPartyId", "trackingCode") @@ -34,9 +34,9 @@ if (shipmentId) { .where("shipmentId", shipmentId) .orderBy("shipmentId", "shipmentRouteSegmentId", "shipmentPackageSeqId") .distinct() - .queryList(); + .queryList() - context.shipment = shipment; - context.shipmentItems = shipmentItems; - context.orderShipmentInfoSummaryList = orderShipmentInfoSummaryList; + context.shipment = shipment + context.shipmentItems = shipmentItems + context.orderShipmentInfoSummaryList = orderShipmentInfoSummaryList } diff --git a/ecommerce/groovyScripts/shoppinglist/EditShoppingList.groovy b/ecommerce/groovyScripts/shoppinglist/EditShoppingList.groovy index 75edadec8..c27379d54 100644 --- a/ecommerce/groovyScripts/shoppinglist/EditShoppingList.groovy +++ b/ecommerce/groovyScripts/shoppinglist/EditShoppingList.groovy @@ -17,212 +17,212 @@ * under the License. */ -import java.util.*; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.entity.util.*; -import org.apache.ofbiz.entity.condition.*; -import org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents; -import org.apache.ofbiz.order.shoppingcart.shipping.*; -import org.apache.ofbiz.order.shoppinglist.*; -import org.apache.ofbiz.party.contact.*; -import org.apache.ofbiz.product.catalog.*; -import org.apache.ofbiz.product.store.*; -import org.apache.ofbiz.service.calendar.*; -import org.apache.ofbiz.webapp.website.WebSiteWorker; +import java.util.* +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.entity.util.* +import org.apache.ofbiz.entity.condition.* +import org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents +import org.apache.ofbiz.order.shoppingcart.shipping.* +import org.apache.ofbiz.order.shoppinglist.* +import org.apache.ofbiz.party.contact.* +import org.apache.ofbiz.product.catalog.* +import org.apache.ofbiz.product.store.* +import org.apache.ofbiz.service.calendar.* +import org.apache.ofbiz.webapp.website.WebSiteWorker if (userLogin) { - party = userLogin.getRelatedOne("Party", false); + party = userLogin.getRelatedOne("Party", false) } else { - return; // session ended, prevents a NPE + return // session ended, prevents a NPE } -cart = ShoppingCartEvents.getCartObject(request); -currencyUomId = cart.getCurrency(); +cart = ShoppingCartEvents.getCartObject(request) +currencyUomId = cart.getCurrency() -productStoreId = ProductStoreWorker.getProductStoreId(request); -prodCatalogId = CatalogWorker.getCurrentCatalogId(request); -webSiteId = WebSiteWorker.getWebSiteId(request); +productStoreId = ProductStoreWorker.getProductStoreId(request) +prodCatalogId = CatalogWorker.getCurrentCatalogId(request) +webSiteId = WebSiteWorker.getWebSiteId(request) -context.productStoreId = productStoreId; -context.currencyUomId = currencyUomId; +context.productStoreId = productStoreId +context.currencyUomId = currencyUomId // get the top level shopping lists for the logged in user exprList = [EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, userLogin.partyId), - EntityCondition.makeCondition("listName", EntityOperator.NOT_EQUAL, "auto-save")]; -condition = EntityCondition.makeCondition(exprList, EntityOperator.AND); -allShoppingLists = from("ShoppingList").where(exprList).orderBy("listName").queryList(); -shoppingLists = EntityUtil.filterByAnd(allShoppingLists, [parentShoppingListId : null]); -context.allShoppingLists = allShoppingLists; -context.shoppingLists = shoppingLists; + EntityCondition.makeCondition("listName", EntityOperator.NOT_EQUAL, "auto-save")] +condition = EntityCondition.makeCondition(exprList, EntityOperator.AND) +allShoppingLists = from("ShoppingList").where(exprList).orderBy("listName").queryList() +shoppingLists = EntityUtil.filterByAnd(allShoppingLists, [parentShoppingListId : null]) +context.allShoppingLists = allShoppingLists +context.shoppingLists = shoppingLists // get all shoppingListTypes -shoppingListTypes = from("ShoppingListType").orderBy("description").cache(true).queryList(); -context.shoppingListTypes = shoppingListTypes; +shoppingListTypes = from("ShoppingListType").orderBy("description").cache(true).queryList() +context.shoppingListTypes = shoppingListTypes // get the shoppingListId for this reqest -parameterMap = UtilHttp.getParameterMap(request); -shoppingListId = parameterMap.shoppingListId ?: request.getAttribute("shoppingListId") ?: session.getAttribute("currentShoppingListId"); -context.shoppingListId = shoppingListId; +parameterMap = UtilHttp.getParameterMap(request) +shoppingListId = parameterMap.shoppingListId ?: request.getAttribute("shoppingListId") ?: session.getAttribute("currentShoppingListId") +context.shoppingListId = shoppingListId // no passed shopping list id default to first list if (!shoppingListId) { - firstList = EntityUtil.getFirst(shoppingLists); + firstList = EntityUtil.getFirst(shoppingLists) if (firstList) { - shoppingListId = firstList.shoppingListId; + shoppingListId = firstList.shoppingListId } } -session.setAttribute("currentShoppingListId", shoppingListId); +session.setAttribute("currentShoppingListId", shoppingListId) // if we passed a shoppingListId get the shopping list info if (shoppingListId) { - shoppingList = from("ShoppingList").where("shoppingListId", shoppingListId).queryOne(); - context.shoppingList = shoppingList; + shoppingList = from("ShoppingList").where("shoppingListId", shoppingListId).queryOne() + context.shoppingList = shoppingList if (shoppingList) { - shoppingListItemTotal = 0.0; - shoppingListChildTotal = 0.0; + shoppingListItemTotal = 0.0 + shoppingListChildTotal = 0.0 - shoppingListItems = shoppingList.getRelated("ShoppingListItem", null, null, true); + shoppingListItems = shoppingList.getRelated("ShoppingListItem", null, null, true) if (shoppingListItems) { - shoppingListItemDatas = new ArrayList(shoppingListItems.size()); + shoppingListItemDatas = new ArrayList(shoppingListItems.size()) shoppingListItems.each { shoppingListItem -> - shoppingListItemData = [:]; + shoppingListItemData = [:] - product = shoppingListItem.getRelatedOne("Product", true); + product = shoppingListItem.getRelatedOne("Product", true) calcPriceOutMap = runService('calculateProductPrice', [product : product, quantity : shoppingListItem.quantity, currencyUomId : currencyUomId, userLogin : userLogin, - webSiteId: webSiteId, prodCatalogId: prodCatalogId, productStoreId: productStoreId]); - price = calcPriceOutMap.price; - totalPrice = price * shoppingListItem.quantity; + webSiteId: webSiteId, prodCatalogId: prodCatalogId, productStoreId: productStoreId]) + price = calcPriceOutMap.price + totalPrice = price * shoppingListItem.quantity // similar code at ShoppingCartItem.java getRentalAdjustment if ("ASSET_USAGE".equals(product.productTypeId) || "ASSET_USAGE_OUT_IN".equals(product.productTypeId)) { - persons = shoppingListItem.reservPersons ?: 0; - reservNthPPPerc = product.reservNthPPPerc ?: 0; - reserv2ndPPPerc = product.reserv2ndPPPerc ?: 0; - rentalValue = 0; + persons = shoppingListItem.reservPersons ?: 0 + reservNthPPPerc = product.reservNthPPPerc ?: 0 + reserv2ndPPPerc = product.reserv2ndPPPerc ?: 0 + rentalValue = 0 if (persons) { if (persons > 2) { - persons -= 2; + persons -= 2 if (reservNthPPPerc) { - rentalValue = persons * reservNthPPPerc; + rentalValue = persons * reservNthPPPerc } else if (reserv2ndPPPerc) { - rentalValue = persons * reserv2ndPPPerc; + rentalValue = persons * reserv2ndPPPerc } - persons = 2; + persons = 2 } if (persons == 2) { if (reserv2ndPPPerc) { - rentalValue += reserv2ndPPPerc; + rentalValue += reserv2ndPPPerc } else if (reservNthPPPerc) { - rentalValue = persons * reservNthPPPerc; + rentalValue = persons * reservNthPPPerc } } } - rentalValue += 100; // add final 100 percent for first person - reservLength = shoppingListItem.reservLength ?: 0; - totalPrice *= (rentalValue/100 * reservLength); + rentalValue += 100 // add final 100 percent for first person + reservLength = shoppingListItem.reservLength ?: 0 + totalPrice *= (rentalValue/100 * reservLength) } - shoppingListItemTotal += totalPrice; + shoppingListItemTotal += totalPrice - productVariantAssocs = null; + productVariantAssocs = null if ("Y".equals(product.isVirtual)) { - productVariantAssocs = product.getRelated("MainProductAssoc", [productAssocTypeId : "PRODUCT_VARIANT"], ["sequenceNum"], true); - productVariantAssocs = EntityUtil.filterByDate(productVariantAssocs); + productVariantAssocs = product.getRelated("MainProductAssoc", [productAssocTypeId : "PRODUCT_VARIANT"], ["sequenceNum"], true) + productVariantAssocs = EntityUtil.filterByDate(productVariantAssocs) } - shoppingListItemData.shoppingListItem = shoppingListItem; - shoppingListItemData.product = product; - shoppingListItemData.unitPrice = price; - shoppingListItemData.totalPrice = totalPrice; - shoppingListItemData.productVariantAssocs = productVariantAssocs; - shoppingListItemDatas.add(shoppingListItemData); + shoppingListItemData.shoppingListItem = shoppingListItem + shoppingListItemData.product = product + shoppingListItemData.unitPrice = price + shoppingListItemData.totalPrice = totalPrice + shoppingListItemData.productVariantAssocs = productVariantAssocs + shoppingListItemDatas.add(shoppingListItemData) } - context.shoppingListItemDatas = shoppingListItemDatas; + context.shoppingListItemDatas = shoppingListItemDatas // pagination for the shopping list - viewIndex = Integer.valueOf(parameters.VIEW_INDEX ?: 1); - viewSize = parameters.VIEW_SIZE ?: EntityUtilProperties.getPropertyAsInteger("widget", "widget.form.defaultViewSize", 20); - listSize = shoppingListItemDatas ? shoppingListItemDatas.size() : 0; + viewIndex = Integer.valueOf(parameters.VIEW_INDEX ?: 1) + viewSize = parameters.VIEW_SIZE ?: EntityUtilProperties.getPropertyAsInteger("widget", "widget.form.defaultViewSize", 20) + listSize = shoppingListItemDatas ? shoppingListItemDatas.size() : 0 - lowIndex = ((viewIndex - 1) * viewSize) + 1; - highIndex = viewIndex * viewSize; - highIndex = highIndex > listSize ? listSize : highIndex; - lowIndex = lowIndex > highIndex ? highIndex : lowIndex; + lowIndex = ((viewIndex - 1) * viewSize) + 1 + highIndex = viewIndex * viewSize + highIndex = highIndex > listSize ? listSize : highIndex + lowIndex = lowIndex > highIndex ? highIndex : lowIndex - context.viewIndex = viewIndex; - context.viewSize = viewSize; - context.listSize = listSize; - context.lowIndex = lowIndex; - context.highIndex = highIndex; + context.viewIndex = viewIndex + context.viewSize = viewSize + context.listSize = listSize + context.lowIndex = lowIndex + context.highIndex = highIndex } - shoppingListType = shoppingList.getRelatedOne("ShoppingListType", false); - context.shoppingListType = shoppingListType; + shoppingListType = shoppingList.getRelatedOne("ShoppingListType", false) + context.shoppingListType = shoppingListType // get the child shopping lists of the current list for the logged in user - childShoppingLists = from("ShoppingList").where("partyId", userLogin.partyId, "parentShoppingListId", shoppingListId).orderBy("listName").cache(true).queryList(); + childShoppingLists = from("ShoppingList").where("partyId", userLogin.partyId, "parentShoppingListId", shoppingListId).orderBy("listName").cache(true).queryList() // now get prices for each child shopping list... if (childShoppingLists) { - childShoppingListDatas = new ArrayList(childShoppingLists.size()); + childShoppingListDatas = new ArrayList(childShoppingLists.size()) childShoppingLists.each { childShoppingList -> - childShoppingListData = [:]; + childShoppingListData = [:] - childShoppingListPriceMap = runService('calculateShoppingListDeepTotalPrice', [shoppingListId : childShoppingList.shoppingListId, prodCatalogId : prodCatalogId, webSiteId : webSiteId, userLogin : userLogin, currencyUomId : currencyUomId]); - totalPrice = childShoppingListPriceMap.totalPrice; - shoppingListChildTotal += totalPrice; + childShoppingListPriceMap = runService('calculateShoppingListDeepTotalPrice', [shoppingListId : childShoppingList.shoppingListId, prodCatalogId : prodCatalogId, webSiteId : webSiteId, userLogin : userLogin, currencyUomId : currencyUomId]) + totalPrice = childShoppingListPriceMap.totalPrice + shoppingListChildTotal += totalPrice - childShoppingListData.childShoppingList = childShoppingList; - childShoppingListData.totalPrice = totalPrice; - childShoppingListDatas.add(childShoppingListData); + childShoppingListData.childShoppingList = childShoppingList + childShoppingListData.totalPrice = totalPrice + childShoppingListDatas.add(childShoppingListData) } - context.childShoppingListDatas = childShoppingListDatas; + context.childShoppingListDatas = childShoppingListDatas } - context.shoppingListTotalPrice = shoppingListItemTotal + shoppingListChildTotal; - context.shoppingListItemTotal = shoppingListItemTotal; - context.shoppingListChildTotal = shoppingListChildTotal; + context.shoppingListTotalPrice = shoppingListItemTotal + shoppingListChildTotal + context.shoppingListItemTotal = shoppingListItemTotal + context.shoppingListChildTotal = shoppingListChildTotal // get the parent shopping list if there is one - parentShoppingList = shoppingList.getRelatedOne("ParentShoppingList", false); - context.parentShoppingList = parentShoppingList; + parentShoppingList = shoppingList.getRelatedOne("ParentShoppingList", false) + context.parentShoppingList = parentShoppingList - context.canView = userLogin.partyId.equals(shoppingList.partyId); + context.canView = userLogin.partyId.equals(shoppingList.partyId) // auto-reorder info if ("SLT_AUTO_REODR".equals(shoppingListType?.shoppingListTypeId)) { - recurrenceVo = shoppingList.getRelatedOne("RecurrenceInfo", false); - context.recurrenceInfo = recurrenceVo; + recurrenceVo = shoppingList.getRelatedOne("RecurrenceInfo", false) + context.recurrenceInfo = recurrenceVo if (userLogin.partyId.equals(shoppingList.partyId)) { - listCart = ShoppingListServices.makeShoppingListCart(dispatcher, shoppingListId, locale); + listCart = ShoppingListServices.makeShoppingListCart(dispatcher, shoppingListId, locale) // get customer's shipping & payment info - context.chosenShippingMethod = shoppingList.shipmentMethodTypeId + "@" + shoppingList.carrierPartyId; - context.shippingContactMechList = ContactHelper.getContactMech(party, "SHIPPING_LOCATION", "POSTAL_ADDRESS", false); - context.paymentMethodList = EntityUtil.filterByDate(party.getRelated("PaymentMethod", null, ["paymentMethodTypeId"], false)); + context.chosenShippingMethod = shoppingList.shipmentMethodTypeId + "@" + shoppingList.carrierPartyId + context.shippingContactMechList = ContactHelper.getContactMech(party, "SHIPPING_LOCATION", "POSTAL_ADDRESS", false) + context.paymentMethodList = EntityUtil.filterByDate(party.getRelated("PaymentMethod", null, ["paymentMethodTypeId"], false)) - shipAddress = from("PostalAddress").where("contactMechId", shoppingList.contactMechId).queryOne(); - Debug.log("SL - address : " + shipAddress); + shipAddress = from("PostalAddress").where("contactMechId", shoppingList.contactMechId).queryOne() + Debug.log("SL - address : " + shipAddress) if (shipAddress) { - listCart = ShoppingListServices.makeShoppingListCart(dispatcher, shoppingListId, locale); + listCart = ShoppingListServices.makeShoppingListCart(dispatcher, shoppingListId, locale) if (listCart) { - shippingEstWpr = new ShippingEstimateWrapper(dispatcher, listCart, 0); - carrierShipMeths = shippingEstWpr.getShippingMethods(); - context.listCart = listCart; - context.shippingEstWpr = shippingEstWpr; - context.carrierShipMethods = carrierShipMeths; + shippingEstWpr = new ShippingEstimateWrapper(dispatcher, listCart, 0) + carrierShipMeths = shippingEstWpr.getShippingMethods() + context.listCart = listCart + context.shippingEstWpr = shippingEstWpr + context.carrierShipMethods = carrierShipMeths } } if (recurrenceVo) { - recInfo = new RecurrenceInfo(recurrenceVo); - context.recInfo = recInfo; - lastSlOrderDate = shoppingList.lastOrderedDate; - context.lastSlOrderDate = lastSlOrderDate; + recInfo = new RecurrenceInfo(recurrenceVo) + context.recInfo = recInfo + lastSlOrderDate = shoppingList.lastOrderedDate + context.lastSlOrderDate = lastSlOrderDate if (!lastSlOrderDate) { - lastSlOrderDate = recurrenceVo.startDateTime; + lastSlOrderDate = recurrenceVo.startDateTime } - context.lastSlOrderTime = lastSlOrderDate.getTime(); + context.lastSlOrderTime = lastSlOrderDate.getTime() } } } diff --git a/example/groovyScripts/FindExampleFeatures.groovy b/example/groovyScripts/FindExampleFeatures.groovy index 3feafc00f..74c826f21 100644 --- a/example/groovyScripts/FindExampleFeatures.groovy +++ b/example/groovyScripts/FindExampleFeatures.groovy @@ -17,24 +17,24 @@ * under the License. */ -import org.apache.ofbiz.entity.condition.EntityCondition; -import org.apache.ofbiz.entity.condition.EntityFieldValue; -import org.apache.ofbiz.entity.condition.EntityFunction; -import org.apache.ofbiz.entity.condition.EntityOperator; +import org.apache.ofbiz.entity.condition.EntityCondition +import org.apache.ofbiz.entity.condition.EntityFieldValue +import org.apache.ofbiz.entity.condition.EntityFunction +import org.apache.ofbiz.entity.condition.EntityOperator -delegator = request.getAttribute("delegator"); +delegator = request.getAttribute("delegator") -andExprs = []; -fieldValue = request.getParameter("exampleFeatureId"); +andExprs = [] +fieldValue = request.getParameter("exampleFeatureId") if (fieldValue) { andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER(EntityFieldValue.makeFieldValue("exampleFeatureId")), - EntityOperator.LIKE, "%" + fieldValue.toUpperCase() + "%")); + EntityOperator.LIKE, "%" + fieldValue.toUpperCase() + "%")) } -autocompleteOptions = []; +autocompleteOptions = [] if (andExprs) { - autocompleteOptions = select("exampleFeatureId", "description").from("ExampleFeature").where(andExprs).orderBy("-exampleFeatureId").queryList(); - //context.autocompleteOptions = autocompleteOptions; - request.setAttribute("autocompleteOptions", autocompleteOptions); + autocompleteOptions = select("exampleFeatureId", "description").from("ExampleFeature").where(andExprs).orderBy("-exampleFeatureId").queryList() + //context.autocompleteOptions = autocompleteOptions + request.setAttribute("autocompleteOptions", autocompleteOptions) } -return "success"; +return "success" diff --git a/example/groovyScripts/PrepareLocalesForDropDown.groovy b/example/groovyScripts/PrepareLocalesForDropDown.groovy index 5e408d1fb..d73fae61c 100644 --- a/example/groovyScripts/PrepareLocalesForDropDown.groovy +++ b/example/groovyScripts/PrepareLocalesForDropDown.groovy @@ -18,5 +18,5 @@ under the License. */ def localeMap = [] -org.apache.ofbiz.base.util.UtilMisc.availableLocales().each { localeMap.add(localeId:it.toString()) }; -parameters.localeList = localeMap; \ No newline at end of file +org.apache.ofbiz.base.util.UtilMisc.availableLocales().each { localeMap.add(localeId:it.toString()) } +parameters.localeList = localeMap diff --git a/hhfacility/groovyScripts/ProductList.groovy b/hhfacility/groovyScripts/ProductList.groovy index b7e4cb1cf..ebb1bf5e7 100644 --- a/hhfacility/groovyScripts/ProductList.groovy +++ b/hhfacility/groovyScripts/ProductList.groovy @@ -17,7 +17,7 @@ * under the License. */ -productList = request.getAttribute("productList"); +productList = request.getAttribute("productList") if (productList) { - context.productList = productList; + context.productList = productList } diff --git a/hhfacility/groovyScripts/ProductStockTake.groovy b/hhfacility/groovyScripts/ProductStockTake.groovy index 6dde25c30..a635abe94 100644 --- a/hhfacility/groovyScripts/ProductStockTake.groovy +++ b/hhfacility/groovyScripts/ProductStockTake.groovy @@ -17,79 +17,79 @@ * under the License. */ -productId = request.getParameter("productId"); +productId = request.getParameter("productId") if (!productId) { - productId = session.getAttribute("productId"); + productId = session.getAttribute("productId") } if (productId) { - product = from("Product").where("productId", productId).cache(true).queryOne(); - context.product = product; + product = from("Product").where("productId", productId).cache(true).queryOne() + context.product = product - facilityId = request.getParameter("facilityId"); - resultOutput = runService('getInventoryAvailableByFacility', [productId : productId, facilityId : facilityId]); - quantitySummary = [:]; - quantitySummary.facilityId = facilityId; + facilityId = request.getParameter("facilityId") + resultOutput = runService('getInventoryAvailableByFacility', [productId : productId, facilityId : facilityId]) + quantitySummary = [:] + quantitySummary.facilityId = facilityId quantitySummary.atp_qoh = ((Double)resultOutput.availableToPromiseTotal).intValue() + " / " + - ((Double)resultOutput.quantityOnHandTotal).intValue(); - context.quantitySummary = quantitySummary; + ((Double)resultOutput.quantityOnHandTotal).intValue() + context.quantitySummary = quantitySummary // For now this just generates a visual list of locations set against the product for this facility. // todo: Will need to be able to edit and change these values at some point in the future. - productFacilityLocList = from("ProductFacilityLocation").where("productId", productId, "facilityId", facilityId).queryList(); - facStr = null; + productFacilityLocList = from("ProductFacilityLocation").where("productId", productId, "facilityId", facilityId).queryList() + facStr = null productFacilityLocList.each { facilityLoc -> if (!facStr) { - facStr = facilityLoc.locationSeqId; + facStr = facilityLoc.locationSeqId } else { - facStr = facStr + ", " + facilityLoc.locationSeqId; + facStr = facStr + ", " + facilityLoc.locationSeqId } } - context.productFacilityLocations = facStr; + context.productFacilityLocations = facStr // Now we build a list of locations for inventory items against the facility. // todo: change this to a select from inv_items where productId and facilityId matches distinct (locationSeqId). - invItemList = from("InventoryItem").where("productId", productId, "facilityId", facilityId).queryList(); + invItemList = from("InventoryItem").where("productId", productId, "facilityId", facilityId).queryList() - locations = [:]; + locations = [:] - boolean negativeQOH = false; + boolean negativeQOH = false invItemList.each { invItem -> - int qoh = ((Double)invItem.quantityOnHandTotal).intValue(); + int qoh = ((Double)invItem.quantityOnHandTotal).intValue() if (qoh < 0) { - negativeQOH = true; + negativeQOH = true } - locationFound = (String)invItem.locationSeqId; + locationFound = (String)invItem.locationSeqId if (!locationFound) { - locationFound = "nullField"; + locationFound = "nullField" } if (!locations.get(locationFound)) { - locations.put(locationFound, locationFound); + locations.put(locationFound, locationFound) } } // Go through and build the list of atp/qoh against each location - productFacilityLocations = new ArrayList(); - locationsIter = locations.keySet().iterator(); + productFacilityLocations = new ArrayList() + locationsIter = locations.keySet().iterator() while (locationsIter.hasNext()) { - location = locationsIter.next(); - resultOutput = runService('getInventoryAvailableByLocation', [productId : productId, facilityId : facilityId, locationSeqId : location]); - quantitySummary = [:]; - quantitySummary.productId = productId; - quantitySummary.facilityId = facilityId; + location = locationsIter.next() + resultOutput = runService('getInventoryAvailableByLocation', [productId : productId, facilityId : facilityId, locationSeqId : location]) + quantitySummary = [:] + quantitySummary.productId = productId + quantitySummary.facilityId = facilityId if ("nullField".equals( location ) == true) { - quantitySummary.locationSeqId = ""; + quantitySummary.locationSeqId = "" } else { - quantitySummary.locationSeqId = location; + quantitySummary.locationSeqId = location } quantitySummary.atp_qoh = ((Double)resultOutput.availableToPromiseTotal).intValue() + " / " + - ((Double)resultOutput.quantityOnHandTotal).intValue(); - productFacilityLocations.add(quantitySummary); + ((Double)resultOutput.quantityOnHandTotal).intValue() + productFacilityLocations.add(quantitySummary) } - context.productQtyByLocations = productFacilityLocations; + context.productQtyByLocations = productFacilityLocations if (negativeQOH) { - context.negativeQOH = "true"; + context.negativeQOH = "true" } } diff --git a/lucene/groovyScripts/content/AdvancedSearchPrep.groovy b/lucene/groovyScripts/content/AdvancedSearchPrep.groovy index 45ce2bf24..6c07ef671 100644 --- a/lucene/groovyScripts/content/AdvancedSearchPrep.groovy +++ b/lucene/groovyScripts/content/AdvancedSearchPrep.groovy @@ -17,22 +17,22 @@ * under the License. */ -import org.apache.ofbiz.product.feature.ParametricSearch; -import org.apache.ofbiz.product.product.ProductSearchSession; +import org.apache.ofbiz.product.feature.ParametricSearch +import org.apache.ofbiz.product.product.ProductSearchSession -productFeaturesByTypeMap = ParametricSearch.getAllFeaturesByType(delegator, 2000); -productFeatureTypeIdsOrdered = new ArrayList(new TreeSet(productFeaturesByTypeMap.keySet())); +productFeaturesByTypeMap = ParametricSearch.getAllFeaturesByType(delegator, 2000) +productFeatureTypeIdsOrdered = new ArrayList(new TreeSet(productFeaturesByTypeMap.keySet())) -searchOperator = request.getParameter("SEARCH_OPERATOR"); +searchOperator = request.getParameter("SEARCH_OPERATOR") if (!"AND".equals(searchOperator) && !"OR".equals(searchOperator)) { - searchOperator = "OR"; + searchOperator = "OR" } -searchConstraintStrings = ProductSearchSession.searchGetConstraintStrings(false, session, delegator); -searchSortOrderString = ProductSearchSession.searchGetSortOrderString(false, request); +searchConstraintStrings = ProductSearchSession.searchGetConstraintStrings(false, session, delegator) +searchSortOrderString = ProductSearchSession.searchGetSortOrderString(false, request) -context.productFeaturesByTypeMap = productFeaturesByTypeMap; -context.productFeatureTypeIdsOrdered = productFeatureTypeIdsOrdered; -context.searchOperator = searchOperator; -context.searchConstraintStrings = searchConstraintStrings; -context.searchSortOrderString = searchSortOrderString; +context.productFeaturesByTypeMap = productFeaturesByTypeMap +context.productFeatureTypeIdsOrdered = productFeatureTypeIdsOrdered +context.searchOperator = searchOperator +context.searchConstraintStrings = searchConstraintStrings +context.searchSortOrderString = searchSortOrderString diff --git a/lucene/groovyScripts/content/IndexProducts.groovy b/lucene/groovyScripts/content/IndexProducts.groovy index 61a8f793b..c2a3b6c50 100644 --- a/lucene/groovyScripts/content/IndexProducts.groovy +++ b/lucene/groovyScripts/content/IndexProducts.groovy @@ -29,7 +29,7 @@ if (pi) { beganTransaction = TransactionUtil.begin() EntityListIterator products try { - products = select("productId").from("Product").queryIterator(); + products = select("productId").from("Product").queryIterator() while (product = products.next()) { pi.queue(new ProductDocument(product.productId)) productsCounter++ diff --git a/lucene/groovyScripts/content/Search.groovy b/lucene/groovyScripts/content/Search.groovy index f9daca765..35b0beec2 100644 --- a/lucene/groovyScripts/content/Search.groovy +++ b/lucene/groovyScripts/content/Search.groovy @@ -27,87 +27,87 @@ import org.apache.ofbiz.content.search.SearchWorker import org.apache.ofbiz.product.feature.ParametricSearch import org.apache.lucene.search.* import org.apache.lucene.index.DirectoryReader -import org.apache.ofbiz.base.util.UtilProperties; +import org.apache.ofbiz.base.util.UtilProperties -queryLine = parameters.queryLine; +queryLine = parameters.queryLine -siteId = parameters.lcSiteId; +siteId = parameters.lcSiteId -searchFeature1 = (String) parameters.SEARCH_FEAT; -searchFeature2 = (String) parameters.SEARCH_FEAT2; -searchFeature3 = (String) parameters.SEARCH_FEAT3; +searchFeature1 = (String) parameters.SEARCH_FEAT +searchFeature2 = (String) parameters.SEARCH_FEAT2 +searchFeature3 = (String) parameters.SEARCH_FEAT3 -featureIdByType = ParametricSearch.makeFeatureIdByTypeMap(UtilHttp.getParameterMap(request)); +featureIdByType = ParametricSearch.makeFeatureIdByTypeMap(UtilHttp.getParameterMap(request)) -combQuery = new BooleanQuery(); +combQuery = new BooleanQuery() try { - DirectoryReader reader = DirectoryReader.open(FSDirectory.open(new File(SearchWorker.getIndexPath("content")).toPath())); - searcher = new IndexSearcher(reader); - analyzer = new StandardAnalyzer(); + DirectoryReader reader = DirectoryReader.open(FSDirectory.open(new File(SearchWorker.getIndexPath("content")).toPath())) + searcher = new IndexSearcher(reader) + analyzer = new StandardAnalyzer() } catch (java.io.FileNotFoundException e) { - context.errorMessageList.add(UtilProperties.getMessage("ContentErrorUiLabels", "ContentSearchNotIndexed", locale)); - return; + context.errorMessageList.add(UtilProperties.getMessage("ContentErrorUiLabels", "ContentSearchNotIndexed", locale)) + return } if (queryLine || siteId) { - Query query = null; + Query query = null if (queryLine) { - QueryParser parser = new QueryParser("content", analyzer); - query = parser.parse(queryLine); - combQuery.add(query, BooleanClause.Occur.MUST); + QueryParser parser = new QueryParser("content", analyzer) + query = parser.parse(queryLine) + combQuery.add(query, BooleanClause.Occur.MUST) } if (siteId) { - termQuery = new TermQuery(new Term("site", siteId.toString())); - combQuery.add(termQuery, BooleanClause.Occur.MUST); + termQuery = new TermQuery(new Term("site", siteId.toString())) + combQuery.add(termQuery, BooleanClause.Occur.MUST) } } if (searchFeature1 || searchFeature2 || searchFeature3 || !featureIdByType.isEmpty()) { - featureQuery = new BooleanQuery(); - featuresRequired = BooleanClause.Occur.MUST; + featureQuery = new BooleanQuery() + featuresRequired = BooleanClause.Occur.MUST if ("any".equals(parameters.any_or_all)) { - featuresRequired = BooleanClause.Occur.SHOULD; + featuresRequired = BooleanClause.Occur.SHOULD } if (searchFeature1) { - termQuery = new TermQuery(new Term("feature", searchFeature1)); - featureQuery.add(termQuery, featuresRequired); + termQuery = new TermQuery(new Term("feature", searchFeature1)) + featureQuery.add(termQuery, featuresRequired) } if (searchFeature2) { - termQuery = new TermQuery(new Term("feature", searchFeature2)); - featureQuery.add(termQuery, featuresRequired); + termQuery = new TermQuery(new Term("feature", searchFeature2)) + featureQuery.add(termQuery, featuresRequired) } if (searchFeature3) { - termQuery = new TermQuery(new Term("feature", searchFeature3)); - featureQuery.add(termQuery, featuresRequired); + termQuery = new TermQuery(new Term("feature", searchFeature3)) + featureQuery.add(termQuery, featuresRequired) } if (featureIdByType) { featureIdByType.each { key, value -> - termQuery = new TermQuery(new Term("feature", value)); - featureQuery.add(termQuery, featuresRequired); + termQuery = new TermQuery(new Term("feature", value)) + featureQuery.add(termQuery, featuresRequired) } - combQuery.add(featureQuery, featuresRequired); + combQuery.add(featureQuery, featuresRequired) } } if (searcher) { - TopScoreDocCollector collector = TopScoreDocCollector.create(100); //defaulting to 100 results - searcher.search(combQuery, collector); - ScoreDoc[] hits = collector.topDocs().scoreDocs; + TopScoreDocCollector collector = TopScoreDocCollector.create(100) //defaulting to 100 results + searcher.search(combQuery, collector) + ScoreDoc[] hits = collector.topDocs().scoreDocs - contentList = [] as ArrayList; - hitSet = [:] as HashSet; + contentList = [] as ArrayList + hitSet = [:] as HashSet for (int start = 0; start < collector.getTotalHits(); start++) { Document doc = searcher.doc(hits[start].doc) - contentId = doc.get("contentId"); - content = from("Content").where("contentId", contentId).cache(true).queryOne(); + contentId = doc.get("contentId") + content = from("Content").where("contentId", contentId).cache(true).queryOne() if (!hitSet.contains(contentId)) { - contentList.add(content); - hitSet.add(contentId); + contentList.add(content) + hitSet.add(contentId) } } - context.queryResults = contentList; + context.queryResults = contentList } diff --git a/lucene/groovyScripts/content/SearchProducts.groovy b/lucene/groovyScripts/content/SearchProducts.groovy index 4188b6cc9..6ae4a9c81 100644 --- a/lucene/groovyScripts/content/SearchProducts.groovy +++ b/lucene/groovyScripts/content/SearchProducts.groovy @@ -23,7 +23,7 @@ import org.apache.ofbiz.content.search.SearchWorker import org.apache.lucene.document.Document import org.apache.lucene.index.DirectoryReader -import org.apache.lucene.queryparser.classic.ParseException; +import org.apache.lucene.queryparser.classic.ParseException import org.apache.lucene.queryparser.classic.QueryParser import org.apache.lucene.search.BooleanClause import org.apache.lucene.search.BooleanQuery @@ -34,40 +34,40 @@ import org.apache.lucene.search.TopScoreDocCollector import org.apache.lucene.store.FSDirectory if (parameters.luceneQuery) { - Query combQuery = new BooleanQuery(); - IndexSearcher searcher; - WhitespaceAnalyzer analyzer; + Query combQuery = new BooleanQuery() + IndexSearcher searcher + WhitespaceAnalyzer analyzer try { - DirectoryReader reader = DirectoryReader.open(FSDirectory.open(new File(SearchWorker.getIndexPath("products")).toPath())); - searcher = new IndexSearcher(reader); - analyzer = new WhitespaceAnalyzer(); + DirectoryReader reader = DirectoryReader.open(FSDirectory.open(new File(SearchWorker.getIndexPath("products")).toPath())) + searcher = new IndexSearcher(reader) + analyzer = new WhitespaceAnalyzer() } catch (FileNotFoundException e) { - context.errorMessageList.add(e.getMessage()); - return; + context.errorMessageList.add(e.getMessage()) + return } - QueryParser parser = new QueryParser("fullText", analyzer); - parser.setLocale(locale); - Query query; + QueryParser parser = new QueryParser("fullText", analyzer) + parser.setLocale(locale) + Query query try { - query = parser.parse(parameters.luceneQuery); + query = parser.parse(parameters.luceneQuery) } catch(ParseException pe) { - context.errorMessageList.add(pe.getMessage()); - return; + context.errorMessageList.add(pe.getMessage()) + return } - combQuery.add(query, BooleanClause.Occur.MUST); + combQuery.add(query, BooleanClause.Occur.MUST) - TopScoreDocCollector collector = TopScoreDocCollector.create(100); // defaulting to 100 results - searcher.search(combQuery, collector); - ScoreDoc[] hits = collector.topDocs().scoreDocs; + TopScoreDocCollector collector = TopScoreDocCollector.create(100) // defaulting to 100 results + searcher.search(combQuery, collector) + ScoreDoc[] hits = collector.topDocs().scoreDocs productList = [] hits.each { hit -> Document doc = searcher.doc(hit.doc) productId = doc.productId - product = from("Product").where("productId", productId).cache(true).queryOne(); + product = from("Product").where("productId", productId).cache(true).queryOne() if (product) { productList.add(product) } } - context.queryResults = productList; + context.queryResults = productList } diff --git a/passport/groovyScripts/login/GetThirdPartyLogins.groovy b/passport/groovyScripts/login/GetThirdPartyLogins.groovy index 5b53b3073..d2287b249 100644 --- a/passport/groovyScripts/login/GetThirdPartyLogins.groovy +++ b/passport/groovyScripts/login/GetThirdPartyLogins.groovy @@ -17,33 +17,33 @@ * under the License. */ -package org.apache.ofbiz.passport; +package org.apache.ofbiz.passport -import org.apache.ofbiz.entity.util.EntityUtil; -import org.apache.ofbiz.product.store.ProductStoreWorker; +import org.apache.ofbiz.entity.util.EntityUtil +import org.apache.ofbiz.product.store.ProductStoreWorker final String module = "GetThirdPartyLogins.groovy" -adminErrorInfo = context.adminErrorInfo; -productStoreId = context.productStoreId; +adminErrorInfo = context.adminErrorInfo +productStoreId = context.productStoreId if (!productStoreId) { - productStore = ProductStoreWorker.getProductStore(request); - productStoreId = productStore.productStoreId; + productStore = ProductStoreWorker.getProductStore(request) + productStoreId = productStore.productStoreId } if (!adminErrorInfo || !adminErrorInfo.hasError()) { - storePassportLoginMethList = null; + storePassportLoginMethList = null // Get lists of passport login methods if (productStoreId) { - storePassportLoginMethList = delegator.findByAnd("ThirdPartyLogin", ["productStoreId": productStoreId], ["sequenceNum ASC"], false); - storePassportLoginMethList = EntityUtil.filterByDate(storePassportLoginMethList); + storePassportLoginMethList = delegator.findByAnd("ThirdPartyLogin", ["productStoreId": productStoreId], ["sequenceNum ASC"], false) + storePassportLoginMethList = EntityUtil.filterByDate(storePassportLoginMethList) } // Extra data preparation for each login method. if (storePassportLoginMethList) { storeLoginMethList = [] for (storeLoginMeth in storePassportLoginMethList) { - storeLoginMethDetail = EntityUtil.getFirst(EntityUtil.filterByDate(delegator.findByAnd(storeLoginMeth.loginMethTypeId + storeLoginMeth.loginProviderId, ["productStoreId": productStoreId], null, false))); + storeLoginMethDetail = EntityUtil.getFirst(EntityUtil.filterByDate(delegator.findByAnd(storeLoginMeth.loginMethTypeId + storeLoginMeth.loginProviderId, ["productStoreId": productStoreId], null, false))) storeLoginMethList.add(storeLoginMethDetail) } context.storeLoginMethList = storeLoginMethList diff --git a/projectmgr/groovyScripts/EditWeekTimesheet.groovy b/projectmgr/groovyScripts/EditWeekTimesheet.groovy index bdceb4504..74c2f18b9 100644 --- a/projectmgr/groovyScripts/EditWeekTimesheet.groovy +++ b/projectmgr/groovyScripts/EditWeekTimesheet.groovy @@ -25,181 +25,181 @@ import org.apache.ofbiz.entity.condition.EntityCondition import org.apache.ofbiz.entity.condition.EntityOperator import org.apache.ofbiz.entity.util.EntityUtil -uiLabelMap = UtilProperties.getResourceBundleMap("ProjectMgrUiLabels", locale); +uiLabelMap = UtilProperties.getResourceBundleMap("ProjectMgrUiLabels", locale) -partyId = parameters.partyId; +partyId = parameters.partyId if (!partyId) { - partyId = parameters.userLogin.partyId; + partyId = parameters.userLogin.partyId } // show the requested timesheet, otherwise the current , if not exist create -timesheet = null; -timesheetId = parameters.timesheetId; +timesheet = null +timesheetId = parameters.timesheetId if (timesheetId) { - timesheet = from("Timesheet").where("timesheetId", timesheetId).queryOne(); - partyId = timesheet.partyId; // use the party from this timesheet + timesheet = from("Timesheet").where("timesheetId", timesheetId).queryOne() + partyId = timesheet.partyId // use the party from this timesheet } else { // make sure because of timezone changes, not a duplicate timesheet is created - midweek = UtilDateTime.addDaysToTimestamp(UtilDateTime.getWeekStart(UtilDateTime.nowTimestamp()),3); + midweek = UtilDateTime.addDaysToTimestamp(UtilDateTime.getWeekStart(UtilDateTime.nowTimestamp()),3) entryExprs = EntityCondition.makeCondition([ EntityCondition.makeCondition("fromDate", EntityComparisonOperator.LESS_THAN, midweek), EntityCondition.makeCondition("thruDate", EntityComparisonOperator.GREATER_THAN, midweek), EntityCondition.makeCondition("partyId", EntityComparisonOperator.EQUALS, partyId) - ], EntityOperator.AND); - entryIterator = from("Timesheet").where(entryExprs).queryIterator(); - timesheet = entryIterator.next(); - entryIterator.close(); + ], EntityOperator.AND) + entryIterator = from("Timesheet").where(entryExprs).queryIterator() + timesheet = entryIterator.next() + entryIterator.close() if (timesheet == null) { - result = runService('createProjectTimesheet', ["userLogin" : parameters.userLogin, "partyId" : partyId]); + result = runService('createProjectTimesheet', ["userLogin" : parameters.userLogin, "partyId" : partyId]) if (result && result.timesheetId) { - timesheet = from("Timesheet").where("timesheetId", result.timesheetId).queryOne(); + timesheet = from("Timesheet").where("timesheetId", result.timesheetId).queryOne() } } } -if (!timesheet) return; -context.timesheet = timesheet; -context.weekNumber = UtilDateTime.weekNumber(timesheet.fromDate); +if (!timesheet) return +context.timesheet = timesheet +context.weekNumber = UtilDateTime.weekNumber(timesheet.fromDate) // get the user names -context.partyNameView = from("PartyNameView").where("partyId", partyId).queryOne(); +context.partyNameView = from("PartyNameView").where("partyId", partyId).queryOne() // get the default rate for this person -rateTypes = from("PartyRate").where("partyId", partyId, "defaultRate", "Y").filterByDate().queryList(); +rateTypes = from("PartyRate").where("partyId", partyId, "defaultRate", "Y").filterByDate().queryList() if (rateTypes) { - context.defaultRateTypeId = rateTypes[0].rateTypeId; + context.defaultRateTypeId = rateTypes[0].rateTypeId } -entries = []; -entry = ["timesheetId" : timesheet.timesheetId]; -taskTotal = 0.00; -day0Total = 0.00; day1Total=0.00; day2Total=0.00; day3Total=0.00; day4Total=0.00; day5Total=0.00; day6Total=0.00; -pHours = 0.00; -timeEntry = null; -lastTimeEntry = null; +entries = [] +entry = ["timesheetId" : timesheet.timesheetId] +taskTotal = 0.00 +day0Total = 0.00; day1Total=0.00; day2Total=0.00; day3Total=0.00; day4Total=0.00; day5Total=0.00; day6Total=0.00 +pHours = 0.00 +timeEntry = null +lastTimeEntry = null // retrieve work effort data when the workeffortId has changed. void retrieveWorkEffortData() { // get the planned number of hours - entryWorkEffort = lastTimeEntry.getRelatedOne("WorkEffort", false); + entryWorkEffort = lastTimeEntry.getRelatedOne("WorkEffort", false) if (entryWorkEffort) { - plannedHours = entryWorkEffort.getRelated("WorkEffortSkillStandard", null, null, false); - pHours = 0.00; + plannedHours = entryWorkEffort.getRelated("WorkEffortSkillStandard", null, null, false) + pHours = 0.00 plannedHours.each { plannedHour -> if (plannedHour.estimatedDuration) { - pHours += plannedHour.estimatedDuration; + pHours += plannedHour.estimatedDuration } } - entry.plannedHours = pHours; - actualHours = entryWorkEffort.getRelated("TimeEntry", null, null, false); - aHours = 0.00; + entry.plannedHours = pHours + actualHours = entryWorkEffort.getRelated("TimeEntry", null, null, false) + aHours = 0.00 actualHours.each { actualHour -> if (actualHour.hours) { - aHours += actualHour.hours; + aHours += actualHour.hours } } - entry.actualHours = aHours; + entry.actualHours = aHours // get party assignment data to be able to set the task to complete - workEffortPartyAssigns = EntityUtil.filterByDate(entryWorkEffort.getRelated("WorkEffortPartyAssignment", ["partyId" : partyId], null, false)); + workEffortPartyAssigns = EntityUtil.filterByDate(entryWorkEffort.getRelated("WorkEffortPartyAssignment", ["partyId" : partyId], null, false)) if (workEffortPartyAssigns) { - workEffortPartyAssign = workEffortPartyAssigns[0]; - entry.fromDate = workEffortPartyAssign.getTimestamp("fromDate"); - entry.roleTypeId = workEffortPartyAssign.roleTypeId; + workEffortPartyAssign = workEffortPartyAssigns[0] + entry.fromDate = workEffortPartyAssign.getTimestamp("fromDate") + entry.roleTypeId = workEffortPartyAssign.roleTypeId if ("PAS_COMPLETED".equals(workEffortPartyAssign.statusId)) { - entry.checkComplete = "Y"; + entry.checkComplete = "Y" } } // get project/phase information - entry.workEffortId = entryWorkEffort.workEffortId; - entry.workEffortName = entryWorkEffort.workEffortName; - result = runService('getProjectIdAndNameFromTask', ["userLogin" : parameters.userLogin,"taskId" : entryWorkEffort.workEffortId]); - entry.phaseId = result.phaseId; - entry.phaseName = result.phaseName; - entry.projectId = result.projectId; - entry.projectName = result.projectName; - entry.taskWbsId = result.taskWbsId; + entry.workEffortId = entryWorkEffort.workEffortId + entry.workEffortName = entryWorkEffort.workEffortName + result = runService('getProjectIdAndNameFromTask', ["userLogin" : parameters.userLogin,"taskId" : entryWorkEffort.workEffortId]) + entry.phaseId = result.phaseId + entry.phaseName = result.phaseName + entry.projectId = result.projectId + entry.projectName = result.projectName + entry.taskWbsId = result.taskWbsId } - entry.total = taskTotal; + entry.total = taskTotal //Drop Down Lists - entries.add(entry); + entries.add(entry) // start new entry - taskTotal = 0.00; - entry = ["timesheetId" : timesheet.timesheetId]; + taskTotal = 0.00 + entry = ["timesheetId" : timesheet.timesheetId] } -timeEntries = timesheet.getRelated("TimeEntry", null, ["workEffortId", "rateTypeId", "fromDate"], false); -te = timeEntries.iterator(); +timeEntries = timesheet.getRelated("TimeEntry", null, ["workEffortId", "rateTypeId", "fromDate"], false) +te = timeEntries.iterator() while (te.hasNext()) { // only fill lastTimeEntry when not the first time if (timeEntry!=void) { - lastTimeEntry = timeEntry; + lastTimeEntry = timeEntry } - timeEntry = te.next(); + timeEntry = te.next() if (lastTimeEntry && (!lastTimeEntry.workEffortId.equals(timeEntry.workEffortId) || !lastTimeEntry.rateTypeId.equals(timeEntry.rateTypeId))) { - retrieveWorkEffortData(); + retrieveWorkEffortData() } if (timeEntry.hours) { - dayNumber = "d" + (timeEntry.fromDate.getTime() - timesheet.fromDate.getTime()) / (24*60*60*1000); - hours = timeEntry.hours.doubleValue(); - entry.put(String.valueOf(dayNumber), hours); - if (dayNumber.equals("d0")) day0Total += hours; - if (dayNumber.equals("d1")) day1Total += hours; - if (dayNumber.equals("d2")) day2Total += hours; - if (dayNumber.equals("d3")) day3Total += hours; - if (dayNumber.equals("d4")) day4Total += hours; - if (dayNumber.equals("d5")) day5Total += hours; - if (dayNumber.equals("d6")) day6Total += hours; - taskTotal += hours; + dayNumber = "d" + (timeEntry.fromDate.getTime() - timesheet.fromDate.getTime()) / (24*60*60*1000) + hours = timeEntry.hours.doubleValue() + entry.put(String.valueOf(dayNumber), hours) + if (dayNumber.equals("d0")) day0Total += hours + if (dayNumber.equals("d1")) day1Total += hours + if (dayNumber.equals("d2")) day2Total += hours + if (dayNumber.equals("d3")) day3Total += hours + if (dayNumber.equals("d4")) day4Total += hours + if (dayNumber.equals("d5")) day5Total += hours + if (dayNumber.equals("d6")) day6Total += hours + taskTotal += hours } - entry.rateTypeId = timeEntry.rateTypeId; + entry.rateTypeId = timeEntry.rateTypeId } if (timeEntry) { - lastTimeEntry = timeEntry; - retrieveWorkEffortData(); + lastTimeEntry = timeEntry + retrieveWorkEffortData() } // add empty lines if timesheet not completed if (!timesheet.statusId.equals("TIMESHEET_COMPLETED")) { for (c=0; c < 3; c++) { // add empty lines - entries.add(["timesheetId" : timesheet.timesheetId]); + entries.add(["timesheetId" : timesheet.timesheetId]) } } // add the totals line if at least one entry if (timeEntry) { - entry = ["timesheetId" : timesheet.timesheetId]; - entry.d0 = day0Total; - entry.d1 = day1Total; - entry.d2 = day2Total; - entry.d3 = day3Total; - entry.d4 = day4Total; - entry.d5 = day5Total; - entry.d6 = day6Total; - entry.phaseName = uiLabelMap.ProjectMgrTotals; - entry.workEffortId = "Totals"; - entry.total = day0Total + day1Total + day2Total + day3Total + day4Total + day5Total + day6Total; - entries.add(entry); + entry = ["timesheetId" : timesheet.timesheetId] + entry.d0 = day0Total + entry.d1 = day1Total + entry.d2 = day2Total + entry.d3 = day3Total + entry.d4 = day4Total + entry.d5 = day5Total + entry.d6 = day6Total + entry.phaseName = uiLabelMap.ProjectMgrTotals + entry.workEffortId = "Totals" + entry.total = day0Total + day1Total + day2Total + day3Total + day4Total + day5Total + day6Total + entries.add(entry) } -context.timeEntries = entries; +context.timeEntries = entries // get all timesheets of this user, including the planned hours -timesheetsDb = from("Timesheet").where("partyId", partyId).orderBy("fromDate DESC").queryList(); -timesheets = new LinkedList(); +timesheetsDb = from("Timesheet").where("partyId", partyId).orderBy("fromDate DESC").queryList() +timesheets = new LinkedList() timesheetsDb.each { timesheetDb -> - timesheet = [:]; - timesheet.putAll(timesheetDb); - entries = timesheetDb.getRelated("TimeEntry", null, null, false); - hours = 0.00; + timesheet = [:] + timesheet.putAll(timesheetDb) + entries = timesheetDb.getRelated("TimeEntry", null, null, false) + hours = 0.00 entries.each { timeEntry -> if (timeEntry.hours) { - hours += timeEntry.hours.doubleValue(); + hours += timeEntry.hours.doubleValue() } } - timesheet.weekNumber = UtilDateTime.weekNumber(timesheetDb.fromDate); - timesheet.hours = hours; - timesheets.add(timesheet); + timesheet.weekNumber = UtilDateTime.weekNumber(timesheetDb.fromDate) + timesheet.hours = hours + timesheets.add(timesheet) } -context.timesheets = timesheets; +context.timesheets = timesheets diff --git a/projectmgr/groovyScripts/GanttChart.groovy b/projectmgr/groovyScripts/GanttChart.groovy index 486b18c8e..a58362611 100644 --- a/projectmgr/groovyScripts/GanttChart.groovy +++ b/projectmgr/groovyScripts/GanttChart.groovy @@ -23,118 +23,118 @@ import org.apache.ofbiz.base.util.UtilValidate import org.apache.ofbiz.entity.condition.EntityCondition import org.apache.ofbiz.entity.condition.EntityOperator -projectId = parameters.projectId; -userLogin = parameters.userLogin; +projectId = parameters.projectId +userLogin = parameters.userLogin //project info -result = runService('getProject', [projectId : projectId, userLogin : userLogin]); -project = result.projectInfo; +result = runService('getProject', [projectId : projectId, userLogin : userLogin]) +project = result.projectInfo if (project && project.startDate) - context.chartStart = project.startDate; + context.chartStart = project.startDate else - context.chartStart = UtilDateTime.nowTimestamp(); // default todays date + context.chartStart = UtilDateTime.nowTimestamp() // default todays date if (project && project.completionDate) - context.chartEnd = project.completionDate; + context.chartEnd = project.completionDate else - context.chartEnd = UtilDateTime.addDaysToTimestamp(UtilDateTime.nowTimestamp(), 14); // default 14 days long + context.chartEnd = UtilDateTime.addDaysToTimestamp(UtilDateTime.nowTimestamp(), 14) // default 14 days long -if (project == null) return; +if (project == null) return -ganttList = new LinkedList(); -result = runService('getProjectPhaseList', [userLogin : userLogin , projectId : projectId]); -phases = result.phaseList; +ganttList = new LinkedList() +result = runService('getProjectPhaseList', [userLogin : userLogin , projectId : projectId]) +phases = result.phaseList if (phases) { phases.each { phase -> - newPhase = phase; - newPhase.phaseNr = phase.phaseId; + newPhase = phase + newPhase.phaseNr = phase.phaseId if (!newPhase.estimatedStartDate && newPhase.actualStartDate) { - newPhase.estimatedStartDate = newPhase.actualStartDate; + newPhase.estimatedStartDate = newPhase.actualStartDate } if (!newPhase.estimatedStartDate) { - newPhase.estimatedStartDate = context.chartStart; + newPhase.estimatedStartDate = context.chartStart } if (!newPhase.estimatedCompletionDate && newPhase.actualCompletionDate) { - newPhase.estimatedCompletionDate = newPhase.actualCompletionDateDate; + newPhase.estimatedCompletionDate = newPhase.actualCompletionDateDate } if (!newPhase.estimatedCompletionDate) { - newPhase.estimatedCompletionDate = UtilDateTime.addDaysToTimestamp(newPhase.estimatedStartDate, 3); + newPhase.estimatedCompletionDate = UtilDateTime.addDaysToTimestamp(newPhase.estimatedStartDate, 3) } - newPhase.workEffortTypeId = "PHASE"; - ganttList.add(newPhase); + newPhase.workEffortTypeId = "PHASE" + ganttList.add(newPhase) cond = EntityCondition.makeCondition( [ EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "PTS_CANCELLED"), EntityCondition.makeCondition("workEffortParentId", EntityOperator.EQUALS, phase.phaseId) - ], EntityOperator.AND); - tasks = from("WorkEffort").where(cond).orderBy("sequenceNum","workEffortName").queryList(); + ], EntityOperator.AND) + tasks = from("WorkEffort").where(cond).orderBy("sequenceNum","workEffortName").queryList() if (tasks) { tasks.each { task -> - resultTaskInfo = runService('getProjectTask', [userLogin : userLogin , taskId : task.workEffortId]); - taskInfo = resultTaskInfo.taskInfo; - taskInfo.taskNr = task.workEffortId; - taskInfo.phaseNr = phase.phaseId; + resultTaskInfo = runService('getProjectTask', [userLogin : userLogin , taskId : task.workEffortId]) + taskInfo = resultTaskInfo.taskInfo + taskInfo.taskNr = task.workEffortId + taskInfo.phaseNr = phase.phaseId if (taskInfo.plannedHours && !taskInfo.currentStatusId.equals("PTS_COMPLETED") && taskInfo.plannedHours > taskInfo.actualHours) { - taskInfo.resource = taskInfo.plannedHours + " Hrs"; + taskInfo.resource = taskInfo.plannedHours + " Hrs" } else { - taskInfo.resource = taskInfo.actualHours + " Hrs"; + taskInfo.resource = taskInfo.actualHours + " Hrs" } - Double duration = resultTaskInfo.plannedHours; + Double duration = resultTaskInfo.plannedHours if (taskInfo.currentStatusId.equals("PTS_COMPLETED")) { - taskInfo.completion = 100; + taskInfo.completion = 100 } else { if (taskInfo.actualHours && taskInfo.plannedHours) { - taskInfo.completion = new BigDecimal(taskInfo.actualHours * 100 / taskInfo.plannedHours).setScale(0, BigDecimal.ROUND_UP); + taskInfo.completion = new BigDecimal(taskInfo.actualHours * 100 / taskInfo.plannedHours).setScale(0, BigDecimal.ROUND_UP) } else { - taskInfo.completion = 0; + taskInfo.completion = 0 } } if (!taskInfo.estimatedStartDate && taskInfo.actualStartDate) { - taskInfo.estimatedStartDate = taskInfo.actualStartDate; + taskInfo.estimatedStartDate = taskInfo.actualStartDate } if (!taskInfo.estimatedStartDate) { - taskInfo.estimatedStartDate = newPhase.estimatedStartDate; + taskInfo.estimatedStartDate = newPhase.estimatedStartDate } if (!taskInfo.estimatedCompletionDate && taskInfo.actualCompletionDate) { - taskInfo.estimatedCompletionDate = taskInfo.actualCompletionDate; + taskInfo.estimatedCompletionDate = taskInfo.actualCompletionDate } if (!taskInfo.estimatedCompletionDate && !duration) { - taskInfo.estimatedCompletionDate = UtilDateTime.addDaysToTimestamp(newPhase.estimatedStartDate, 3); + taskInfo.estimatedCompletionDate = UtilDateTime.addDaysToTimestamp(newPhase.estimatedStartDate, 3) } else if (!taskInfo.estimatedCompletionDate && duration) { - taskInfo.estimatedCompletionDate = UtilDateTime.addDaysToTimestamp(newPhase.estimatedStartDate, duration/8); + taskInfo.estimatedCompletionDate = UtilDateTime.addDaysToTimestamp(newPhase.estimatedStartDate, duration/8) } - taskInfo.estimatedStartDate = UtilDateTime.toDateString(taskInfo.estimatedStartDate, "MM/dd/yyyy"); - taskInfo.estimatedCompletionDate = UtilDateTime.toDateString(taskInfo.estimatedCompletionDate, "MM/dd/yyyy"); - taskInfo.workEffortTypeId = task.workEffortTypeId; + taskInfo.estimatedStartDate = UtilDateTime.toDateString(taskInfo.estimatedStartDate, "MM/dd/yyyy") + taskInfo.estimatedCompletionDate = UtilDateTime.toDateString(taskInfo.estimatedCompletionDate, "MM/dd/yyyy") + taskInfo.workEffortTypeId = task.workEffortTypeId if (security.hasEntityPermission("PROJECTMGR", "_READ", session) || security.hasEntityPermission("PROJECTMGR", "_ADMIN", session)) { - taskInfo.url = "/projectmgr/control/taskView?workEffortId="+task.workEffortId; + taskInfo.url = "/projectmgr/control/taskView?workEffortId="+task.workEffortId } else { - taskInfo.url = ""; + taskInfo.url = "" } // dependency can only show one in the ganttchart, so onl show the latest one.. - preTasks = from("WorkEffortAssoc").where("workEffortIdTo", task.workEffortId).orderBy("workEffortIdFrom").queryList(); - latestTaskIds = new LinkedList(); + preTasks = from("WorkEffortAssoc").where("workEffortIdTo", task.workEffortId).orderBy("workEffortIdFrom").queryList() + latestTaskIds = new LinkedList() preTasks.each { preTask -> - wf = preTask.getRelatedOne("FromWorkEffort", false); - latestTaskIds.add(wf.workEffortId); + wf = preTask.getRelatedOne("FromWorkEffort", false) + latestTaskIds.add(wf.workEffortId) } - count = 0; + count = 0 if (UtilValidate.isNotEmpty(latestTaskIds)) { - taskInfo.preDecessor = ""; + taskInfo.preDecessor = "" for (i in latestTaskIds) { if (count > 0) { - taskInfo.preDecessor = taskInfo.preDecessor +", " + i; + taskInfo.preDecessor = taskInfo.preDecessor +", " + i } else { - taskInfo.preDecessor = taskInfo.preDecessor + i; + taskInfo.preDecessor = taskInfo.preDecessor + i } - count ++; + count ++ } } - ganttList.add(taskInfo); + ganttList.add(taskInfo) } } } } -context.phaseTaskList = ganttList; +context.phaseTaskList = ganttList diff --git a/projectmgr/groovyScripts/GetLastRequestAssignment.groovy b/projectmgr/groovyScripts/GetLastRequestAssignment.groovy index b8f6bf116..6e418791a 100644 --- a/projectmgr/groovyScripts/GetLastRequestAssignment.groovy +++ b/projectmgr/groovyScripts/GetLastRequestAssignment.groovy @@ -20,17 +20,17 @@ // get last request from this user and use that project/task assignment as default on the screen -custRequestList = from("CustRequest").where("fromPartyId", fromPartyId).orderBy("-createdDate").queryList(); +custRequestList = from("CustRequest").where("fromPartyId", fromPartyId).orderBy("-createdDate").queryList() if (custRequestList) { - custReqTaskList = custRequestList.get(0).getRelated("CustRequestWorkEffort", null, null, false); + custReqTaskList = custRequestList.get(0).getRelated("CustRequestWorkEffort", null, null, false) if (custReqTaskList) { - custReqTask = custReqTaskList.get(0).getRelatedOne("WorkEffort", false); // phase - projectChildWorkEffort = custReqTask.getRelatedOne("ParentWorkEffort", false); // phase name + custReqTask = custReqTaskList.get(0).getRelatedOne("WorkEffort", false) // phase + projectChildWorkEffort = custReqTask.getRelatedOne("ParentWorkEffort", false) // phase name if (projectChildWorkEffort) { - partyList = custReqTask.getRelated("WorkEffortPartyAssignment", null, null, false); + partyList = custReqTask.getRelated("WorkEffortPartyAssignment", null, null, false) if (partyList) { - context.childWorkEffortId = projectChildWorkEffort.workEffortId; - context.partyId= partyList.get(0).partyId; + context.childWorkEffortId = projectChildWorkEffort.workEffortId + context.partyId= partyList.get(0).partyId } } } diff --git a/projectmgr/groovyScripts/GetProjectId.groovy b/projectmgr/groovyScripts/GetProjectId.groovy index 53bb0965a..02a1af18f 100644 --- a/projectmgr/groovyScripts/GetProjectId.groovy +++ b/projectmgr/groovyScripts/GetProjectId.groovy @@ -17,14 +17,14 @@ * under the License. */ -import org.apache.ofbiz.base.util.UtilValidate; +import org.apache.ofbiz.base.util.UtilValidate if (parameters.workEffortId) { - workEffortId = parameters.workEffortId; - projects = from("ProjectAndPhaseAndTask").where("workEffortId", workEffortId).queryList(); + workEffortId = parameters.workEffortId + projects = from("ProjectAndPhaseAndTask").where("workEffortId", workEffortId).queryList() if (UtilValidate.isNotEmpty(projects)) { - context.put("projectId", projects.get(0).getString("projectId")); - context.put("projectName", projects.get(0).getString("projectName")); - context.put("phaseName", projects.get(0).getString("phaseName")); + context.put("projectId", projects.get(0).getString("projectId")) + context.put("projectName", projects.get(0).getString("projectName")) + context.put("phaseName", projects.get(0).getString("phaseName")) } } diff --git a/projectmgr/groovyScripts/ListCurrentProjects.groovy b/projectmgr/groovyScripts/ListCurrentProjects.groovy index 6e418f7cd..ff3c8707e 100644 --- a/projectmgr/groovyScripts/ListCurrentProjects.groovy +++ b/projectmgr/groovyScripts/ListCurrentProjects.groovy @@ -25,20 +25,20 @@ import org.apache.ofbiz.entity.condition.EntityOperator cond = EntityCondition.makeCondition([ EntityCondition.makeCondition ("workEffortTypeId", EntityOperator.EQUALS, "PROJECT"), EntityCondition.makeCondition ("currentStatusId", EntityOperator.NOT_EQUAL, "PRJ_CLOSED") - ], EntityJoinOperator.AND); -allProjects = select("workEffortId").from("WorkEffort").where(cond).orderBy("workEffortName").queryList(); + ], EntityJoinOperator.AND) +allProjects = select("workEffortId").from("WorkEffort").where(cond).orderBy("workEffortName").queryList() -projects = []; +projects = [] allProjects.each { project -> - result = runService('getProject', ["userLogin" : parameters.userLogin, "projectId" : project.workEffortId]); + result = runService('getProject', ["userLogin" : parameters.userLogin, "projectId" : project.workEffortId]) if (result.projectInfo) { - resultAssign = from("WorkEffortPartyAssignment").where("partyId", parameters.userLogin.partyId, "workEffortId", project.workEffortId).queryList(); + resultAssign = from("WorkEffortPartyAssignment").where("partyId", parameters.userLogin.partyId, "workEffortId", project.workEffortId).queryList() if (security.hasEntityPermission("PROJECTMGR", "_ADMIN", session) || ((security.hasEntityPermission("PROJECTMGR", "_ROLE_ADMIN", session) || security.hasEntityPermission("PROJECTMGR", "_ROLE_VIEW", session)) && resultAssign)) { - projects.add(result.projectInfo); + projects.add(result.projectInfo) } } } if (projects) { - context.projects = projects; + context.projects = projects } diff --git a/projectmgr/groovyScripts/ListResourceBillingHours.groovy b/projectmgr/groovyScripts/ListResourceBillingHours.groovy index 40919932e..23ddea350 100644 --- a/projectmgr/groovyScripts/ListResourceBillingHours.groovy +++ b/projectmgr/groovyScripts/ListResourceBillingHours.groovy @@ -17,15 +17,15 @@ * under the License. */ -allProjects = select("workEffortId").from("WorkEffortAndPartyAssign").where("workEffortTypeId", "PROJECT", "partyId", parameters.partyId).orderBy("workEffortName").cache(true).queryList(); +allProjects = select("workEffortId").from("WorkEffortAndPartyAssign").where("workEffortTypeId", "PROJECT", "partyId", parameters.partyId).orderBy("workEffortName").cache(true).queryList() -projects = []; +projects = [] allProjects.each { project -> - result = runService('getProject', ["userLogin" : parameters.userLogin, "projectId" : project.workEffortId, partyId : parameters.partyId]); - projects.add(result.projectInfo); + result = runService('getProject', ["userLogin" : parameters.userLogin, "projectId" : project.workEffortId, partyId : parameters.partyId]) + projects.add(result.projectInfo) } if (projects) { - context.billingList = projects; + context.billingList = projects } diff --git a/projectmgr/groovyScripts/ProjectBilling.groovy b/projectmgr/groovyScripts/ProjectBilling.groovy index eae354f0d..ab03660ef 100644 --- a/projectmgr/groovyScripts/ProjectBilling.groovy +++ b/projectmgr/groovyScripts/ProjectBilling.groovy @@ -23,13 +23,13 @@ import org.apache.ofbiz.base.util.UtilDateTime import org.apache.ofbiz.entity.condition.EntityCondition import org.apache.ofbiz.entity.condition.EntityOperator -projectId = parameters.projectId; +projectId = parameters.projectId entryExprs = EntityCondition.makeCondition([ EntityCondition.makeCondition("projectId", EntityOperator.EQUALS, projectId), EntityCondition.makeCondition("invoiceId", EntityOperator.NOT_EQUAL, null), - ], EntityOperator.AND); -orderBy = ["-fromDate"]; + ], EntityOperator.AND) +orderBy = ["-fromDate"] // check if latest invoice generated is still in process so allow re-generation to correct errors entryIterator = from("ProjectPhaseTaskAndTimeEntryTimeSheet") .where(EntityCondition.makeCondition([ @@ -37,16 +37,16 @@ entryIterator = from("ProjectPhaseTaskAndTimeEntryTimeSheet") EntityCondition.makeCondition("invoiceId", EntityOperator.NOT_EQUAL, null), ], EntityOperator.AND)) .orderBy("-fromDate") - .queryIterator(); + .queryIterator() while (entryItem = entryIterator.next()) { - invoice = entryItem.getRelatedOne("Invoice", false); + invoice = entryItem.getRelatedOne("Invoice", false) if (invoice.getString("statusId").equals("INVOICE_IN_PROCESS")) { - context.partyIdFrom = invoice.partyIdFrom; - context.partyId = invoice.partyId; - context.invoiceId = invoice.invoiceId; - break; + context.partyIdFrom = invoice.partyIdFrom + context.partyId = invoice.partyId + context.invoiceId = invoice.invoiceId + break } } -entryIterator.close(); +entryIterator.close() //start of this month -context.thruDate = UtilDateTime.getMonthStart(UtilDateTime.nowTimestamp()); +context.thruDate = UtilDateTime.getMonthStart(UtilDateTime.nowTimestamp()) diff --git a/projectmgr/groovyScripts/ProjectIsBillable.groovy b/projectmgr/groovyScripts/ProjectIsBillable.groovy index cb71e0285..7054e621c 100644 --- a/projectmgr/groovyScripts/ProjectIsBillable.groovy +++ b/projectmgr/groovyScripts/ProjectIsBillable.groovy @@ -17,22 +17,22 @@ * under the License. */ -projectMembers = from("WorkEffortPartyAssignment").where("workEffortId", context.projectId).filterByDate().queryList(); +projectMembers = from("WorkEffortPartyAssignment").where("workEffortId", context.projectId).filterByDate().queryList() -toPartyId = null; -fromPartyId = null; +toPartyId = null +fromPartyId = null projectMembers.each {member -> if (member.roleTypeId.equals("INTERNAL_ORGANIZATIO")) { - fromPartyId = member.partyId; + fromPartyId = member.partyId } if (member.roleTypeId.equals("CLIENT_BILLING")) { - toPartyId = member.partyId; + toPartyId = member.partyId } if (fromPartyId && toPartyId && fromPartyId.equals(toPartyId)) { - context.isBillable = false; + context.isBillable = false } else if (!toPartyId || !fromPartyId){ - context.isBillable = false; + context.isBillable = false } else { - context.isBillable = true; + context.isBillable = true } } diff --git a/scrum/groovyScripts/AddProductBacklogItem.groovy b/scrum/groovyScripts/AddProductBacklogItem.groovy index f33fdb800..edbf4dbb4 100644 --- a/scrum/groovyScripts/AddProductBacklogItem.groovy +++ b/scrum/groovyScripts/AddProductBacklogItem.groovy @@ -17,116 +17,116 @@ * under the License. */ -import java.sql.*; -import java.sql.Timestamp; -import java.util.Calendar; -import net.fortuna.ical4j.model.DateTime; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.condition.*; -import sun.util.calendar.LocalGregorianCalendar.Date; +import java.sql.* +import java.sql.Timestamp +import java.util.Calendar +import net.fortuna.ical4j.model.DateTime +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.condition.* +import sun.util.calendar.LocalGregorianCalendar.Date -def module = "AddProductBacklogItem.groovy"; +def module = "AddProductBacklogItem.groovy" // find cust request and items -def inputFields = [:]; +def inputFields = [:] if(parameters.statusId == null){ - parameters.statusId = ""; + parameters.statusId = "" }else if("Any".equals(parameters.statusId)){ - parameters.statusId = ""; + parameters.statusId = "" } -inputFields.putAll(parameters); -inputFields.custRequestTypeId = "RF_PROD_BACKLOG"; -def performFindResults = runService('performFind', ["entityName": "CustRequestAndCustRequestItem", "inputFields": inputFields, "orderBy": "custSequenceNum"]); -def custRequestAndItems = performFindResults.listIt.getCompleteList(); -performFindResults.listIt.close(); +inputFields.putAll(parameters) +inputFields.custRequestTypeId = "RF_PROD_BACKLOG" +def performFindResults = runService('performFind', ["entityName": "CustRequestAndCustRequestItem", "inputFields": inputFields, "orderBy": "custSequenceNum"]) +def custRequestAndItems = performFindResults.listIt.getCompleteList() +performFindResults.listIt.close() // prepare cust request item list [cust request and item Map] -def countSequence = 1; -def custRequestAndCustRequestItems = []; +def countSequence = 1 +def custRequestAndCustRequestItems = [] custRequestAndItems.each() { custRequestAndItem -> - def tempCustRequestAndItem = [:]; - tempCustRequestAndItem.putAll(custRequestAndItem); - tempCustRequestAndItem.custSequenceNum = countSequence; - tempCustRequestAndItem.realSequenceNum = custRequestAndItem.custSequenceNum; + def tempCustRequestAndItem = [:] + tempCustRequestAndItem.putAll(custRequestAndItem) + tempCustRequestAndItem.custSequenceNum = countSequence + tempCustRequestAndItem.realSequenceNum = custRequestAndItem.custSequenceNum // if custRequest has task then get Actual Hours - custWorkEffortList = from("CustRequestWorkEffort").where("custRequestId", custRequestAndItem.custRequestId).queryList(); + custWorkEffortList = from("CustRequestWorkEffort").where("custRequestId", custRequestAndItem.custRequestId).queryList() if (custWorkEffortList) { - actualHours = 0.00; + actualHours = 0.00 custWorkEffortList.each() { custWorkEffortMap -> - result = runService('getScrumActualHour', ["taskId" : custWorkEffortMap.workEffortId,"partyId" : null, "userLogin" : userLogin]); - actualHours += result.actualHours; + result = runService('getScrumActualHour', ["taskId" : custWorkEffortMap.workEffortId,"partyId" : null, "userLogin" : userLogin]) + actualHours += result.actualHours } if(actualHours) { - tempCustRequestAndItem.actualHours = actualHours; + tempCustRequestAndItem.actualHours = actualHours } else { - tempCustRequestAndItem.actualHours = null; + tempCustRequestAndItem.actualHours = null } } else { - tempCustRequestAndItem.actualHours = null; + tempCustRequestAndItem.actualHours = null } - custRequestAndCustRequestItems.add(tempCustRequestAndItem); - countSequence ++; + custRequestAndCustRequestItems.add(tempCustRequestAndItem) + countSequence ++ } if ("N".equals(parameters.sequence)) { // re-order category list item - custRequestAndCustRequestItems = UtilMisc.sortMaps(custRequestAndCustRequestItems, ["parentCustRequestId"]); + custRequestAndCustRequestItems = UtilMisc.sortMaps(custRequestAndCustRequestItems, ["parentCustRequestId"]) } //set status back for display in Find screen if("".equals(parameters.statusId)){ - parameters.statusId = "Any"; + parameters.statusId = "Any" } -context.custRequestAndCustRequestItems = custRequestAndCustRequestItems; +context.custRequestAndCustRequestItems = custRequestAndCustRequestItems // unplanned backlog item list -productId = parameters.productId; +productId = parameters.productId -conditionList = []; -orConditionList = []; -mainConditionList = []; +conditionList = [] +orConditionList = [] +mainConditionList = [] -conditionList.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.EQUALS, "RF_UNPLAN_BACKLOG")); -conditionList.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, parameters.productId)); +conditionList.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.EQUALS, "RF_UNPLAN_BACKLOG")) +conditionList.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, parameters.productId)) -orConditionList.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "CRQ_ACCEPTED")); -orConditionList.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "CRQ_REOPENED")); +orConditionList.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "CRQ_ACCEPTED")) +orConditionList.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "CRQ_REOPENED")) -orConditions = EntityCondition.makeCondition(orConditionList, EntityOperator.OR); -conditions = EntityCondition.makeCondition(conditionList, EntityOperator.AND); +orConditions = EntityCondition.makeCondition(orConditionList, EntityOperator.OR) +conditions = EntityCondition.makeCondition(conditionList, EntityOperator.AND) -mainConditionList.add(orConditions); -mainConditionList.add(conditions); +mainConditionList.add(orConditions) +mainConditionList.add(conditions) -unplannedList = select("custRequestId", "custSequenceNum", "statusId", "description", "custEstimatedMilliSeconds", "custRequestName", "parentCustRequestId").from("CustRequestAndCustRequestItem").where(mainConditionList).orderBy("custSequenceNum").queryList(); +unplannedList = select("custRequestId", "custSequenceNum", "statusId", "description", "custEstimatedMilliSeconds", "custRequestName", "parentCustRequestId").from("CustRequestAndCustRequestItem").where(mainConditionList).orderBy("custSequenceNum").queryList() -def countSequenceUnplanned = 1; -def unplanBacklogItems = []; +def countSequenceUnplanned = 1 +def unplanBacklogItems = [] unplannedList.each() { unplannedItem -> - def tempUnplanned = [:]; - tempUnplanned.putAll(unplannedItem); - tempUnplanned.custSequenceNum = countSequenceUnplanned; - tempUnplanned.realSequenceNum = unplannedItem.custSequenceNum; + def tempUnplanned = [:] + tempUnplanned.putAll(unplannedItem) + tempUnplanned.custSequenceNum = countSequenceUnplanned + tempUnplanned.realSequenceNum = unplannedItem.custSequenceNum // if custRequest has task then get Actual Hours - unplanCustWorkEffortList = from("CustRequestWorkEffort").where("custRequestId", unplannedItem.custRequestId).queryList(); + unplanCustWorkEffortList = from("CustRequestWorkEffort").where("custRequestId", unplannedItem.custRequestId).queryList() if (unplanCustWorkEffortList) { - actualHours = 0.00; + actualHours = 0.00 unplanCustWorkEffortList.each() { custWorkEffortMap -> - result = runService('getScrumActualHour', ["taskId" : custWorkEffortMap.workEffortId,"partyId" : null, "userLogin" : userLogin]); - actualHours += result.actualHours; + result = runService('getScrumActualHour', ["taskId" : custWorkEffortMap.workEffortId,"partyId" : null, "userLogin" : userLogin]) + actualHours += result.actualHours } if(actualHours) { - tempUnplanned.actualHours = actualHours; + tempUnplanned.actualHours = actualHours } else { - tempUnplanned.actualHours = null; + tempUnplanned.actualHours = null } } else { - tempUnplanned.actualHours = null; + tempUnplanned.actualHours = null } - unplanBacklogItems.add(tempUnplanned); - countSequenceUnplanned ++; + unplanBacklogItems.add(tempUnplanned) + countSequenceUnplanned ++ } if ("N".equals(parameters.UnplannedSequence)) { // re-order category list item - unplanBacklogItems = UtilMisc.sortMaps(unplanBacklogItems, ["parentCustRequestId"]); + unplanBacklogItems = UtilMisc.sortMaps(unplanBacklogItems, ["parentCustRequestId"]) } -context.unplanBacklogItems = unplanBacklogItems; +context.unplanBacklogItems = unplanBacklogItems diff --git a/scrum/groovyScripts/AddResourceTaskParty.groovy b/scrum/groovyScripts/AddResourceTaskParty.groovy index 79b67590e..382108bb5 100644 --- a/scrum/groovyScripts/AddResourceTaskParty.groovy +++ b/scrum/groovyScripts/AddResourceTaskParty.groovy @@ -17,40 +17,40 @@ * under the License. */ -import java.util.*; -import org.apache.ofbiz.base.util.Debug; +import java.util.* +import org.apache.ofbiz.base.util.Debug partyId = parameters.partyId // get existing task that no assign -projectSprintBacklogAndTaskList = []; -projectAndTaskList = from("ProjectSprintBacklogAndTask").where("sprintTypeId", "SCRUM_SPRINT","taskCurrentStatusId", "STS_CREATED").orderBy("taskId DESC").queryList(); +projectSprintBacklogAndTaskList = [] +projectAndTaskList = from("ProjectSprintBacklogAndTask").where("sprintTypeId", "SCRUM_SPRINT","taskCurrentStatusId", "STS_CREATED").orderBy("taskId DESC").queryList() projectAndTaskList.each { projectAndTaskMap -> -userLoginId = userLogin.partyId; - projectId = projectAndTaskMap.projectId; - partyAssignmentProjectList = from("WorkEffortPartyAssignment").where("workEffortId", projectId, "partyId", partyId).queryList(); - partyAssignmentProjectMap = partyAssignmentProjectList[0]; +userLoginId = userLogin.partyId + projectId = projectAndTaskMap.projectId + partyAssignmentProjectList = from("WorkEffortPartyAssignment").where("workEffortId", projectId, "partyId", partyId).queryList() + partyAssignmentProjectMap = partyAssignmentProjectList[0] // if this userLoginId is a member of project if (partyAssignmentProjectMap) { - sprintId = projectAndTaskMap.sprintId; - partyAssignmentSprintList = from("WorkEffortPartyAssignment").where("workEffortId", sprintId, "partyId", partyId).queryList(); - partyAssignmentSprintMap = partyAssignmentSprintList[0]; + sprintId = projectAndTaskMap.sprintId + partyAssignmentSprintList = from("WorkEffortPartyAssignment").where("workEffortId", sprintId, "partyId", partyId).queryList() + partyAssignmentSprintMap = partyAssignmentSprintList[0] // if this userLoginId is a member of sprint if (partyAssignmentSprintMap) { - workEffortId = projectAndTaskMap.taskId; - partyAssignmentTaskList = from("WorkEffortPartyAssignment").where("workEffortId", workEffortId).queryList(); - partyAssignmentTaskMap = partyAssignmentTaskList[0]; + workEffortId = projectAndTaskMap.taskId + partyAssignmentTaskList = from("WorkEffortPartyAssignment").where("workEffortId", workEffortId).queryList() + partyAssignmentTaskMap = partyAssignmentTaskList[0] // if the task do not assigned if (!partyAssignmentTaskMap) { - projectSprintBacklogAndTaskList.add(projectAndTaskMap); + projectSprintBacklogAndTaskList.add(projectAndTaskMap) // if the task do not assigned and assigned with custRequestTypeId = RF_SCRUM_MEETINGS } else { - custRequestTypeId = projectAndTaskMap.custRequestTypeId; - backlogStatusId = projectAndTaskMap.backlogStatusId; + custRequestTypeId = projectAndTaskMap.custRequestTypeId + backlogStatusId = projectAndTaskMap.backlogStatusId if (custRequestTypeId.equals("RF_SCRUM_MEETINGS") && backlogStatusId.equals("CRQ_REVIEWED")) { - projectSprintBacklogAndTaskList.add(projectAndTaskMap); + projectSprintBacklogAndTaskList.add(projectAndTaskMap) } } } } } -context.projectSprintBacklogAndTaskList = projectSprintBacklogAndTaskList; +context.projectSprintBacklogAndTaskList = projectSprintBacklogAndTaskList diff --git a/scrum/groovyScripts/BacklogNotifications.groovy b/scrum/groovyScripts/BacklogNotifications.groovy index 30ef0326a..4f6005480 100644 --- a/scrum/groovyScripts/BacklogNotifications.groovy +++ b/scrum/groovyScripts/BacklogNotifications.groovy @@ -17,48 +17,48 @@ * under the License. */ -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.condition.*; +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.condition.* -def module = "BacklogNotifications.groovy"; +def module = "BacklogNotifications.groovy" -custRequest = from("CustRequest").where("custRequestId", custRequestId).queryOne(); -person = from("PartyNameView").where("partyId", partyIdTo).queryOne(); -informationMap = [:]; -informationMap.internalName = null; -informationMap.productId = null; -informationMap.workEffortName = null; -informationMap.workEffortId = null; +custRequest = from("CustRequest").where("custRequestId", custRequestId).queryOne() +person = from("PartyNameView").where("partyId", partyIdTo).queryOne() +informationMap = [:] +informationMap.internalName = null +informationMap.productId = null +informationMap.workEffortName = null +informationMap.workEffortId = null //check in sprint -backlogList = select("productId", "workEffortId", "custRequestId").from("ProductBacklog").where("workEffortTypeId", "SCRUM_SPRINT", "custRequestId", custRequestId).queryList(); +backlogList = select("productId", "workEffortId", "custRequestId").from("ProductBacklog").where("workEffortTypeId", "SCRUM_SPRINT", "custRequestId", custRequestId).queryList() if (backlogList) { - product = from("Product").where("productId", backlogList[0].productId).queryOne(); - sprint = from("WorkEffort").where("workEffortId", backlogList[0].workEffortId).queryOne(); - informationMap.internalName = product.internalName; - informationMap.productId = product.productId; - informationMap.workEffortName = sprint.workEffortName; - informationMap.workEffortId = sprint.workEffortId; + product = from("Product").where("productId", backlogList[0].productId).queryOne() + sprint = from("WorkEffort").where("workEffortId", backlogList[0].workEffortId).queryOne() + informationMap.internalName = product.internalName + informationMap.productId = product.productId + informationMap.workEffortName = sprint.workEffortName + informationMap.workEffortId = sprint.workEffortId } else { - backlogList = select("productId", "workEffortId", "custRequestId").from("ProductBacklog").where("custRequestId", custRequestId).queryList(); + backlogList = select("productId", "workEffortId", "custRequestId").from("ProductBacklog").where("custRequestId", custRequestId).queryList() if (backlogList) { if (backlogList[0].productId) { - product = from("Product").where("productId", backlogList[0].productId).queryOne(); - informationMap.internalName = product.internalName; - informationMap.productId = product.productId; + product = from("Product").where("productId", backlogList[0].productId).queryOne() + informationMap.internalName = product.internalName + informationMap.productId = product.productId } } } // check backlog removed from sprint. -removedFromSprint = false; +removedFromSprint = false if ("CRQ_ACCEPTED".equals(custRequest.statusId)) { - custStatusList = custRequest.getRelated("CustRequestStatus", null, ["-custRequestStatusId"], false); + custStatusList = custRequest.getRelated("CustRequestStatus", null, ["-custRequestStatusId"], false) if (custStatusList.size() > 2 && "CRQ_REVIEWED".equals(custStatusList[1].statusId)) { - removedFromSprint = true; + removedFromSprint = true } } -context.custRequest = custRequest; -context.person = person; -context.informationMap = informationMap; -context.removedFromSprint = removedFromSprint; +context.custRequest = custRequest +context.person = person +context.informationMap = informationMap +context.removedFromSprint = removedFromSprint diff --git a/scrum/groovyScripts/EditDailyHourReport.groovy b/scrum/groovyScripts/EditDailyHourReport.groovy index 8cd6a03bd..32d833d71 100644 --- a/scrum/groovyScripts/EditDailyHourReport.groovy +++ b/scrum/groovyScripts/EditDailyHourReport.groovy @@ -17,420 +17,420 @@ * under the License. */ -import java.util.*; -import java.lang.*; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.base.util.Debug; -import org.apache.ofbiz.base.util.UtilMisc; -import org.apache.ofbiz.base.util.UtilValidate; -import org.apache.ofbiz.base.util.UtilDateTime; -import org.apache.ofbiz.entity.util.*; -import org.apache.ofbiz.entity.condition.*; -import org.apache.ofbiz.webapp.website.WebSiteWorker; -import java.sql.Timestamp; +import java.util.* +import java.lang.* +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.base.util.Debug +import org.apache.ofbiz.base.util.UtilMisc +import org.apache.ofbiz.base.util.UtilValidate +import org.apache.ofbiz.base.util.UtilDateTime +import org.apache.ofbiz.entity.util.* +import org.apache.ofbiz.entity.condition.* +import org.apache.ofbiz.webapp.website.WebSiteWorker +import java.sql.Timestamp -uiLabelMap = UtilProperties.getResourceBundleMap("scrumUiLabels", locale); -partyId = parameters.partyId; +uiLabelMap = UtilProperties.getResourceBundleMap("scrumUiLabels", locale) +partyId = parameters.partyId if (!partyId) { - partyId = parameters.userLogin.partyId; + partyId = parameters.userLogin.partyId } // show the requested timesheet, otherwise the current , if not exist create -timesheet = null; -timesheetId = parameters.timesheetId; +timesheet = null +timesheetId = parameters.timesheetId if (timesheetId) { - timesheet = from("Timesheet").where("timesheetId", timesheetId).queryOne(); - partyId = timesheet.partyId; // use the party from this timesheet + timesheet = from("Timesheet").where("timesheetId", timesheetId).queryOne() + partyId = timesheet.partyId // use the party from this timesheet } else { // make sure because of timezone changes, not a duplicate timesheet is created - midweek = UtilDateTime.addDaysToTimestamp(UtilDateTime.getWeekStart(UtilDateTime.nowTimestamp()),3); + midweek = UtilDateTime.addDaysToTimestamp(UtilDateTime.getWeekStart(UtilDateTime.nowTimestamp()),3) entryExprs = EntityCondition.makeCondition([ EntityCondition.makeCondition("fromDate", EntityComparisonOperator.LESS_THAN, midweek), EntityCondition.makeCondition("thruDate", EntityComparisonOperator.GREATER_THAN, midweek), EntityCondition.makeCondition("partyId", EntityComparisonOperator.EQUALS, partyId) - ], EntityOperator.AND); - entryIterator = from("Timesheet").where(entryExprs).queryIterator(); - timesheet = entryIterator.next(); - entryIterator.close(); + ], EntityOperator.AND) + entryIterator = from("Timesheet").where(entryExprs).queryIterator() + timesheet = entryIterator.next() + entryIterator.close() if (timesheet == null) { - result = runService('createProjectTimesheet', ["userLogin" : parameters.userLogin, "partyId" : partyId]); + result = runService('createProjectTimesheet', ["userLogin" : parameters.userLogin, "partyId" : partyId]) if (result && result.timesheetId) { - timesheet = from("Timesheet").where("timesheetId", result.timesheetId).queryOne(); + timesheet = from("Timesheet").where("timesheetId", result.timesheetId).queryOne() } } } -if (!timesheet) return; -context.timesheet = timesheet; -context.weekNumber = UtilDateTime.weekNumber(timesheet.fromDate); +if (!timesheet) return +context.timesheet = timesheet +context.weekNumber = UtilDateTime.weekNumber(timesheet.fromDate) // get the user names -context.partyNameView = from("PartyNameView").where("partyId", partyId).queryOne(); +context.partyNameView = from("PartyNameView").where("partyId", partyId).queryOne() // get the default rate for this person -rateTypes = from("PartyRate").where("partyId", partyId, "defaultRate", "Y").filterByDate().queryList(); +rateTypes = from("PartyRate").where("partyId", partyId, "defaultRate", "Y").filterByDate().queryList() if (rateTypes) { - context.defaultRateTypeId = rateTypes[0].rateTypeId; + context.defaultRateTypeId = rateTypes[0].rateTypeId } -entries = []; -entry = ["timesheetId" : timesheet.timesheetId]; -leaveEntry = ["timesheetId" : timesheet.timesheetId]; -taskTotal = 0.00; -planTotal = 0.00; -leaveTaskTotal = 0.00; -leavePlanTotal = 0.00; -day0Total = 0.00; day1Total=0.00; day2Total=0.00; day3Total=0.00; day4Total=0.00; day5Total=0.00; day6Total=0.00; -pDay0Total = 0.00; pDay1Total=0.00; pDay2Total=0.00; pDay3Total=0.00; pDay4Total=0.00; pDay5Total=0.00; pDay6Total=0.00; -pHours = 0.00; -timeEntry = null; -lastTimeEntry = null; -emplLeaveEntry = null; -lastEmplLeaveEntry = null; +entries = [] +entry = ["timesheetId" : timesheet.timesheetId] +leaveEntry = ["timesheetId" : timesheet.timesheetId] +taskTotal = 0.00 +planTotal = 0.00 +leaveTaskTotal = 0.00 +leavePlanTotal = 0.00 +day0Total = 0.00; day1Total=0.00; day2Total=0.00; day3Total=0.00; day4Total=0.00; day5Total=0.00; day6Total=0.00 +pDay0Total = 0.00; pDay1Total=0.00; pDay2Total=0.00; pDay3Total=0.00; pDay4Total=0.00; pDay5Total=0.00; pDay6Total=0.00 +pHours = 0.00 +timeEntry = null +lastTimeEntry = null +emplLeaveEntry = null +lastEmplLeaveEntry = null // retrieve work effort data when the workeffortId has changed. void retrieveWorkEffortData() { // get the planned number of hours - entryWorkEffort = lastTimeEntry.getRelatedOne("WorkEffort", false); + entryWorkEffort = lastTimeEntry.getRelatedOne("WorkEffort", false) if (entryWorkEffort) { - plannedHours = entryWorkEffort.getRelated("WorkEffortSkillStandard", null, null, false); - pHours = 0.00; + plannedHours = entryWorkEffort.getRelated("WorkEffortSkillStandard", null, null, false) + pHours = 0.00 plannedHours.each { plannedHour -> if (plannedHour.estimatedDuration) { - pHours += plannedHour.estimatedDuration; + pHours += plannedHour.estimatedDuration } } - estimatedHour = 0.00; + estimatedHour = 0.00 estimatedMilliSeconds = entryWorkEffort.estimatedMilliSeconds if (estimatedMilliSeconds > 0) - estimatedHour = estimatedMilliSeconds/3600000; - entry.plannedHours = estimatedHour; - //entry.plannedHours = pHours; - planHours = 0.0; - planHours = lastTimeEntry.planHours; - lastTimeEntryOfTasks = from("TimeEntry").where("workEffortId", lastTimeEntry.workEffortId, "partyId", partyId).orderBy("-fromDate").queryList(); - if (lastTimeEntryOfTasks.size() != 0) lastTimeEntry = lastTimeEntryOfTasks[0]; + estimatedHour = estimatedMilliSeconds/3600000 + entry.plannedHours = estimatedHour + //entry.plannedHours = pHours + planHours = 0.0 + planHours = lastTimeEntry.planHours + lastTimeEntryOfTasks = from("TimeEntry").where("workEffortId", lastTimeEntry.workEffortId, "partyId", partyId).orderBy("-fromDate").queryList() + if (lastTimeEntryOfTasks.size() != 0) lastTimeEntry = lastTimeEntryOfTasks[0] if (planHours < 1) { - planHours = estimatedHour; + planHours = estimatedHour } - entry.planHours = lastTimeEntry.planHours; - actualHours = entryWorkEffort.getRelated("TimeEntry", null, null, false); - aHours = 0.00; + entry.planHours = lastTimeEntry.planHours + actualHours = entryWorkEffort.getRelated("TimeEntry", null, null, false) + aHours = 0.00 actualHours.each { actualHour -> if (actualHour.hours) { - aHours += actualHour.hours; + aHours += actualHour.hours } } - entry.actualHours = aHours; + entry.actualHours = aHours // get party assignment data to be able to set the task to complete - workEffortPartyAssigns = EntityUtil.filterByDate(entryWorkEffort.getRelated("WorkEffortPartyAssignment", ["partyId" : partyId], null, false)); + workEffortPartyAssigns = EntityUtil.filterByDate(entryWorkEffort.getRelated("WorkEffortPartyAssignment", ["partyId" : partyId], null, false)) if (workEffortPartyAssigns) { - workEffortPartyAssign = workEffortPartyAssigns[0]; - entry.fromDate = workEffortPartyAssign.getTimestamp("fromDate"); - entry.roleTypeId = workEffortPartyAssign.roleTypeId; + workEffortPartyAssign = workEffortPartyAssigns[0] + entry.fromDate = workEffortPartyAssign.getTimestamp("fromDate") + entry.roleTypeId = workEffortPartyAssign.roleTypeId if ("SCAS_COMPLETED".equals(workEffortPartyAssign.statusId)) { - entry.checkComplete = "Y"; + entry.checkComplete = "Y" } } else { if ("STS_COMPLETED".equals(entryWorkEffort.currentStatusId)) { - entry.checkComplete = "Y"; + entry.checkComplete = "Y" } } // get project/phase information - entry.workEffortId = entryWorkEffort.workEffortId; - entry.workEffortName = entryWorkEffort.workEffortName; - result = runService('getProjectInfoFromTask', ["userLogin" : parameters.userLogin,"taskId" : entryWorkEffort.workEffortId]); - entry.phaseId = result.phaseId; - entry.phaseName = result.phaseName; - entry.projectId = result.projectId; - entry.projectName = result.projectName; - entry.taskWbsId = result.taskWbsId; + entry.workEffortId = entryWorkEffort.workEffortId + entry.workEffortName = entryWorkEffort.workEffortName + result = runService('getProjectInfoFromTask', ["userLogin" : parameters.userLogin,"taskId" : entryWorkEffort.workEffortId]) + entry.phaseId = result.phaseId + entry.phaseName = result.phaseName + entry.projectId = result.projectId + entry.projectName = result.projectName + entry.taskWbsId = result.taskWbsId } - entry.acualTotal = taskTotal; - entry.planTotal = planTotal; + entry.acualTotal = taskTotal + entry.planTotal = planTotal //Drop Down Lists if (entry.checkComplete != "Y") { if (aHours > 0.00) - entries.add(entry); + entries.add(entry) } else { - entries.add(entry); + entries.add(entry) } // start new entry - taskTotal = 0.00; - planTotal = 0.00; - entry = ["timesheetId" : timesheet.timesheetId]; + taskTotal = 0.00 + planTotal = 0.00 + entry = ["timesheetId" : timesheet.timesheetId] } -timeEntries = timesheet.getRelated("TimeEntry", null, ["workEffortId", "rateTypeId", "fromDate"], false); -te = timeEntries.iterator(); +timeEntries = timesheet.getRelated("TimeEntry", null, ["workEffortId", "rateTypeId", "fromDate"], false) +te = timeEntries.iterator() while (te.hasNext()) { // only fill lastTimeEntry when not the first time if (timeEntry!=void) { - lastTimeEntry = timeEntry; + lastTimeEntry = timeEntry } - timeEntry = te.next(); + timeEntry = te.next() if (lastTimeEntry && (!lastTimeEntry.workEffortId.equals(timeEntry.workEffortId) || !lastTimeEntry.rateTypeId.equals(timeEntry.rateTypeId))) { - retrieveWorkEffortData(); + retrieveWorkEffortData() } if (timeEntry.hours) { - dayNumber = "d" + (timeEntry.fromDate.getTime() - timesheet.fromDate.getTime()) / (24*60*60*1000); - hours = timeEntry.hours.doubleValue(); - entry.put(String.valueOf(dayNumber), hours); - if (dayNumber.equals("d0")) day0Total += hours; - if (dayNumber.equals("d1")) day1Total += hours; - if (dayNumber.equals("d2")) day2Total += hours; - if (dayNumber.equals("d3")) day3Total += hours; - if (dayNumber.equals("d4")) day4Total += hours; - if (dayNumber.equals("d5")) day5Total += hours; - if (dayNumber.equals("d6")) day6Total += hours; - taskTotal += hours; + dayNumber = "d" + (timeEntry.fromDate.getTime() - timesheet.fromDate.getTime()) / (24*60*60*1000) + hours = timeEntry.hours.doubleValue() + entry.put(String.valueOf(dayNumber), hours) + if (dayNumber.equals("d0")) day0Total += hours + if (dayNumber.equals("d1")) day1Total += hours + if (dayNumber.equals("d2")) day2Total += hours + if (dayNumber.equals("d3")) day3Total += hours + if (dayNumber.equals("d4")) day4Total += hours + if (dayNumber.equals("d5")) day5Total += hours + if (dayNumber.equals("d6")) day6Total += hours + taskTotal += hours } if (timeEntry.planHours) { - dayNumber = "pd" + (timeEntry.fromDate.getTime() - timesheet.fromDate.getTime()) / (24*60*60*1000); - planHours = timeEntry.planHours.doubleValue(); - entry.put(String.valueOf(dayNumber), planHours); - if (dayNumber.equals("pd0")) pDay0Total += planHours; - if (dayNumber.equals("pd1")) pDay1Total += planHours; - if (dayNumber.equals("pd2")) pDay2Total += planHours; - if (dayNumber.equals("pd3")) pDay3Total += planHours; - if (dayNumber.equals("pd4")) pDay4Total += planHours; - if (dayNumber.equals("pd5")) pDay5Total += planHours; - if (dayNumber.equals("pd6")) pDay6Total += planHours; - planTotal += planHours; + dayNumber = "pd" + (timeEntry.fromDate.getTime() - timesheet.fromDate.getTime()) / (24*60*60*1000) + planHours = timeEntry.planHours.doubleValue() + entry.put(String.valueOf(dayNumber), planHours) + if (dayNumber.equals("pd0")) pDay0Total += planHours + if (dayNumber.equals("pd1")) pDay1Total += planHours + if (dayNumber.equals("pd2")) pDay2Total += planHours + if (dayNumber.equals("pd3")) pDay3Total += planHours + if (dayNumber.equals("pd4")) pDay4Total += planHours + if (dayNumber.equals("pd5")) pDay5Total += planHours + if (dayNumber.equals("pd6")) pDay6Total += planHours + planTotal += planHours } - entry.rateTypeId = timeEntry.rateTypeId; + entry.rateTypeId = timeEntry.rateTypeId } //retrieve Empl Leave data. void retrieveEmplLeaveData() { if (lastEmplLeaveEntry) { //service get Hours result = runService('getPartyLeaveHoursForDate', - ["userLogin": parameters.userLogin, "partyId": lastEmplLeaveEntry.partyId, "leaveTypeId": lastEmplLeaveEntry.leaveTypeId, "fromDate": lastEmplLeaveEntry.fromDate]); + ["userLogin": parameters.userLogin, "partyId": lastEmplLeaveEntry.partyId, "leaveTypeId": lastEmplLeaveEntry.leaveTypeId, "fromDate": lastEmplLeaveEntry.fromDate]) if (result.hours) { - leaveEntry.plannedHours = result.hours; - leaveEntry.planHours = result.hours; + leaveEntry.plannedHours = result.hours + leaveEntry.planHours = result.hours } if (lastEmplLeaveEntry.leaveStatus == "LEAVE_APPROVED") { - leaveEntry.checkComplete = "Y"; + leaveEntry.checkComplete = "Y" } - leaveEntry.partyId = lastEmplLeaveEntry.partyId; - leaveEntry.leaveTypeId = lastEmplLeaveEntry.leaveTypeId; - leaveEntry.leavefromDate = lastEmplLeaveEntry.fromDate; - leaveEntry.leavethruDate = lastEmplLeaveEntry.thruDate; - leaveEntry.description = lastEmplLeaveEntry.description; + leaveEntry.partyId = lastEmplLeaveEntry.partyId + leaveEntry.leaveTypeId = lastEmplLeaveEntry.leaveTypeId + leaveEntry.leavefromDate = lastEmplLeaveEntry.fromDate + leaveEntry.leavethruDate = lastEmplLeaveEntry.thruDate + leaveEntry.description = lastEmplLeaveEntry.description } - leaveEntry.acualTotal = leaveTaskTotal; - leaveEntry.planHours = leavePlanTotal; - leaveEntry.actualHours = leaveTaskTotal; + leaveEntry.acualTotal = leaveTaskTotal + leaveEntry.planHours = leavePlanTotal + leaveEntry.actualHours = leaveTaskTotal //Drop Down Lists - entries.add(leaveEntry); + entries.add(leaveEntry) // start new leaveEntry - leaveTaskTotal = 0.00; - leavePlanTotal = 0.00; - leaveEntry = ["timesheetId" : timesheet.timesheetId]; + leaveTaskTotal = 0.00 + leavePlanTotal = 0.00 + leaveEntry = ["timesheetId" : timesheet.timesheetId] } // define condition -leaveExprs = []; -leaveExprs.add(EntityCondition.makeCondition("fromDate", EntityOperator.GREATER_THAN_EQUAL_TO, timesheet.fromDate)); -leaveExprs.add(EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, timesheet.thruDate)); -leaveExprs.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId)); -emplLeave = from("EmplLeave").where(leaveExprs).cursorScrollInsensitive().distinct().queryIterator(); +leaveExprs = [] +leaveExprs.add(EntityCondition.makeCondition("fromDate", EntityOperator.GREATER_THAN_EQUAL_TO, timesheet.fromDate)) +leaveExprs.add(EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, timesheet.thruDate)) +leaveExprs.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId)) +emplLeave = from("EmplLeave").where(leaveExprs).cursorScrollInsensitive().distinct().queryIterator() while ((emplLeaveMap = emplLeave.next())) { if (emplLeaveEntry!=void) { - lastEmplLeaveEntry = emplLeaveEntry; + lastEmplLeaveEntry = emplLeaveEntry } - emplLeaveEntry = emplLeaveMap; + emplLeaveEntry = emplLeaveMap if (lastEmplLeaveEntry && ( !lastEmplLeaveEntry.leaveTypeId.equals(emplLeaveEntry.leaveTypeId) || !lastEmplLeaveEntry.partyId.equals(emplLeaveEntry.partyId))) { - retrieveEmplLeaveData(); + retrieveEmplLeaveData() } resultHours = runService('getPartyLeaveHoursForDate', - ["userLogin": parameters.userLogin, "partyId": emplLeaveEntry.partyId, "leaveTypeId": emplLeaveEntry.leaveTypeId, "fromDate": emplLeaveEntry.fromDate]); + ["userLogin": parameters.userLogin, "partyId": emplLeaveEntry.partyId, "leaveTypeId": emplLeaveEntry.leaveTypeId, "fromDate": emplLeaveEntry.fromDate]) if (resultHours.hours) { - leaveDayNumber = "d" + (emplLeaveEntry.fromDate.getTime() - timesheet.fromDate.getTime()) / (24*60*60*1000); + leaveDayNumber = "d" + (emplLeaveEntry.fromDate.getTime() - timesheet.fromDate.getTime()) / (24*60*60*1000) resultHours = runService('getPartyLeaveHoursForDate', - ["userLogin": parameters.userLogin, "partyId": emplLeaveEntry.partyId, "leaveTypeId": emplLeaveEntry.leaveTypeId, "fromDate": emplLeaveEntry.fromDate]); - leaveHours = resultHours.hours.doubleValue(); - leaveEntry.put(String.valueOf(leaveDayNumber), leaveHours); - if (leaveDayNumber.equals("d0")) day0Total += leaveHours; - if (leaveDayNumber.equals("d1")) day1Total += leaveHours; - if (leaveDayNumber.equals("d2")) day2Total += leaveHours; - if (leaveDayNumber.equals("d3")) day3Total += leaveHours; - if (leaveDayNumber.equals("d4")) day4Total += leaveHours; - if (leaveDayNumber.equals("d5")) day5Total += leaveHours; - if (leaveDayNumber.equals("d6")) day6Total += leaveHours; - leaveTaskTotal += leaveHours; + ["userLogin": parameters.userLogin, "partyId": emplLeaveEntry.partyId, "leaveTypeId": emplLeaveEntry.leaveTypeId, "fromDate": emplLeaveEntry.fromDate]) + leaveHours = resultHours.hours.doubleValue() + leaveEntry.put(String.valueOf(leaveDayNumber), leaveHours) + if (leaveDayNumber.equals("d0")) day0Total += leaveHours + if (leaveDayNumber.equals("d1")) day1Total += leaveHours + if (leaveDayNumber.equals("d2")) day2Total += leaveHours + if (leaveDayNumber.equals("d3")) day3Total += leaveHours + if (leaveDayNumber.equals("d4")) day4Total += leaveHours + if (leaveDayNumber.equals("d5")) day5Total += leaveHours + if (leaveDayNumber.equals("d6")) day6Total += leaveHours + leaveTaskTotal += leaveHours } if (resultHours.hours) { - leavePlanDay = "pd" + (emplLeaveEntry.fromDate.getTime() - timesheet.fromDate.getTime()) / (24*60*60*1000); + leavePlanDay = "pd" + (emplLeaveEntry.fromDate.getTime() - timesheet.fromDate.getTime()) / (24*60*60*1000) resultPlanHours = runService('getPartyLeaveHoursForDate', - ["userLogin": parameters.userLogin, "partyId": emplLeaveEntry.partyId, "leaveTypeId": emplLeaveEntry.leaveTypeId, "fromDate": emplLeaveEntry.fromDate]); - leavePlanHours = resultPlanHours.hours.doubleValue(); - leaveEntry.put(String.valueOf(leavePlanDay), leavePlanHours); - if (leavePlanDay.equals("pd0")) pDay0Total += leavePlanHours; - if (leavePlanDay.equals("pd1")) pDay1Total += leavePlanHours; - if (leavePlanDay.equals("pd2")) pDay2Total += leavePlanHours; - if (leavePlanDay.equals("pd3")) pDay3Total += leavePlanHours; - if (leavePlanDay.equals("pd4")) pDay4Total += leavePlanHours; - if (leavePlanDay.equals("pd5")) pDay5Total += leavePlanHours; - if (leavePlanDay.equals("pd6")) pDay6Total += leavePlanHours; - leavePlanTotal += leavePlanHours; + ["userLogin": parameters.userLogin, "partyId": emplLeaveEntry.partyId, "leaveTypeId": emplLeaveEntry.leaveTypeId, "fromDate": emplLeaveEntry.fromDate]) + leavePlanHours = resultPlanHours.hours.doubleValue() + leaveEntry.put(String.valueOf(leavePlanDay), leavePlanHours) + if (leavePlanDay.equals("pd0")) pDay0Total += leavePlanHours + if (leavePlanDay.equals("pd1")) pDay1Total += leavePlanHours + if (leavePlanDay.equals("pd2")) pDay2Total += leavePlanHours + if (leavePlanDay.equals("pd3")) pDay3Total += leavePlanHours + if (leavePlanDay.equals("pd4")) pDay4Total += leavePlanHours + if (leavePlanDay.equals("pd5")) pDay5Total += leavePlanHours + if (leavePlanDay.equals("pd6")) pDay6Total += leavePlanHours + leavePlanTotal += leavePlanHours } - leaveEntry.rateTypeId = "STANDARD"; + leaveEntry.rateTypeId = "STANDARD" } -emplLeave.close(); +emplLeave.close() if (timeEntry) { - lastTimeEntry = timeEntry; - retrieveWorkEffortData(); + lastTimeEntry = timeEntry + retrieveWorkEffortData() } if (emplLeaveEntry) { - lastEmplLeaveEntry = emplLeaveEntry; - retrieveEmplLeaveData(); + lastEmplLeaveEntry = emplLeaveEntry + retrieveEmplLeaveData() } // add empty lines if timesheet not completed if (!timesheet.statusId.equals("TIMESHEET_COMPLETED")) { for (c=0; c < 3; c++) { // add empty lines - entries.add(["timesheetId" : timesheet.timesheetId]); + entries.add(["timesheetId" : timesheet.timesheetId]) } } // add the totals line if at least one entry if (timeEntry || emplLeaveEntry) { - entry = ["timesheetId" : timesheet.timesheetId]; - entry.d0 = day0Total; - entry.d1 = day1Total; - entry.d2 = day2Total; - entry.d3 = day3Total; - entry.d4 = day4Total; - entry.d5 = day5Total; - entry.d6 = day6Total; - entry.pd0 = pDay0Total; - entry.pd1 = pDay1Total; - entry.pd2 = pDay2Total; - entry.pd3 = pDay3Total; - entry.pd4 = pDay4Total; - entry.pd5 = pDay5Total; - entry.pd6 = pDay6Total; - entry.phaseName = uiLabelMap.ScrumTotals; - entry.workEffortId = "Totals"; - entry.total = day0Total + day1Total + day2Total + day3Total + day4Total + day5Total + day6Total; - entries.add(entry); + entry = ["timesheetId" : timesheet.timesheetId] + entry.d0 = day0Total + entry.d1 = day1Total + entry.d2 = day2Total + entry.d3 = day3Total + entry.d4 = day4Total + entry.d5 = day5Total + entry.d6 = day6Total + entry.pd0 = pDay0Total + entry.pd1 = pDay1Total + entry.pd2 = pDay2Total + entry.pd3 = pDay3Total + entry.pd4 = pDay4Total + entry.pd5 = pDay5Total + entry.pd6 = pDay6Total + entry.phaseName = uiLabelMap.ScrumTotals + entry.workEffortId = "Totals" + entry.total = day0Total + day1Total + day2Total + day3Total + day4Total + day5Total + day6Total + entries.add(entry) } -context.timeEntries = entries; +context.timeEntries = entries // get all timesheets of this user, including the planned hours -timesheetsDb = from("Timesheet").where("partyId", partyId).orderBy("fromDate DESC").queryList(); -timesheets = new LinkedList(); +timesheetsDb = from("Timesheet").where("partyId", partyId).orderBy("fromDate DESC").queryList() +timesheets = new LinkedList() timesheetsDb.each { timesheetDb -> - //get hours from EmplLeave; - findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true); - leaveExprsList = []; - leaveExprsList.add(EntityCondition.makeCondition("fromDate", EntityOperator.GREATER_THAN_EQUAL_TO, timesheetDb.fromDate)); - leaveExprsList.add(EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, timesheetDb.thruDate)); - leaveExprsList.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId)); - emplLeaveList = from("EmplLeave").where(leaveExprsList).cursorScrollInsensitive().distinct().queryIterator(); - leaveHours = 0.00; + //get hours from EmplLeave + findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true) + leaveExprsList = [] + leaveExprsList.add(EntityCondition.makeCondition("fromDate", EntityOperator.GREATER_THAN_EQUAL_TO, timesheetDb.fromDate)) + leaveExprsList.add(EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, timesheetDb.thruDate)) + leaveExprsList.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId)) + emplLeaveList = from("EmplLeave").where(leaveExprsList).cursorScrollInsensitive().distinct().queryIterator() + leaveHours = 0.00 while ((emplLeaveMap = emplLeaveList.next())) { - emplLeaveEntry = emplLeaveMap; + emplLeaveEntry = emplLeaveMap resultHour = runService('getPartyLeaveHoursForDate', - ["userLogin": parameters.userLogin, "partyId": emplLeaveEntry.partyId, "leaveTypeId": emplLeaveEntry.leaveTypeId, "fromDate": emplLeaveEntry.fromDate]); + ["userLogin": parameters.userLogin, "partyId": emplLeaveEntry.partyId, "leaveTypeId": emplLeaveEntry.leaveTypeId, "fromDate": emplLeaveEntry.fromDate]) if (resultHour) { - leaveActualHours = resultHour.hours.doubleValue(); - leaveHours += leaveActualHours; + leaveActualHours = resultHour.hours.doubleValue() + leaveHours += leaveActualHours } } - //get hours from TimeEntry; - timesheet = [:]; - timesheet.putAll(timesheetDb); - entries = timesheetDb.getRelated("TimeEntry", null, null, false); - hours = 0.00; + //get hours from TimeEntry + timesheet = [:] + timesheet.putAll(timesheetDb) + entries = timesheetDb.getRelated("TimeEntry", null, null, false) + hours = 0.00 entries.each { timeEntry -> if (timeEntry.hours) { - hours += timeEntry.hours.doubleValue(); + hours += timeEntry.hours.doubleValue() } } - timesheet.weekNumber = UtilDateTime.weekNumber(timesheetDb.fromDate); - timesheet.hours = hours + leaveHours; - timesheets.add(timesheet); - emplLeaveList.close(); + timesheet.weekNumber = UtilDateTime.weekNumber(timesheetDb.fromDate) + timesheet.hours = hours + leaveHours + timesheets.add(timesheet) + emplLeaveList.close() } -context.timesheets = timesheets; +context.timesheets = timesheets // get existing task that no assign -taskList=[]; -projectSprintBacklogAndTaskList = []; -backlogIndexList = []; -projectAndTaskList = from("ProjectSprintBacklogAndTask").where("sprintTypeId" : "SCRUM_SPRINT","taskCurrentStatusId" : "STS_CREATED").orderBy("projectName ASC","taskActualStartDate DESC").queryList(); +taskList=[] +projectSprintBacklogAndTaskList = [] +backlogIndexList = [] +projectAndTaskList = from("ProjectSprintBacklogAndTask").where("sprintTypeId" : "SCRUM_SPRINT","taskCurrentStatusId" : "STS_CREATED").orderBy("projectName ASC","taskActualStartDate DESC").queryList() projectAndTaskList.each { projectAndTaskMap -> -userLoginId = userLogin.partyId; - sprintId = projectAndTaskMap.sprintId; - workEffortList = from("WorkEffortAndProduct").where("workEffortId", projectAndTaskMap.projectId).queryList(); - backlogIndexList.add(workEffortList[0].productId); +userLoginId = userLogin.partyId + sprintId = projectAndTaskMap.sprintId + workEffortList = from("WorkEffortAndProduct").where("workEffortId", projectAndTaskMap.projectId).queryList() + backlogIndexList.add(workEffortList[0].productId) - partyAssignmentSprintList = from("WorkEffortPartyAssignment").where("workEffortId", sprintId, "partyId", userLoginId).queryList(); - partyAssignmentSprintMap = partyAssignmentSprintList[0]; + partyAssignmentSprintList = from("WorkEffortPartyAssignment").where("workEffortId", sprintId, "partyId", userLoginId).queryList() + partyAssignmentSprintMap = partyAssignmentSprintList[0] // if this userLoginId is a member of sprint if (partyAssignmentSprintMap) { - workEffortId = projectAndTaskMap.taskId; - partyAssignmentTaskList = from("WorkEffortPartyAssignment").where("workEffortId", workEffortId).queryList(); - partyAssignmentTaskMap = partyAssignmentTaskList[0]; + workEffortId = projectAndTaskMap.taskId + partyAssignmentTaskList = from("WorkEffortPartyAssignment").where("workEffortId", workEffortId).queryList() + partyAssignmentTaskMap = partyAssignmentTaskList[0] // if the task do not assigned if (partyAssignmentTaskMap) { - custRequestTypeId = projectAndTaskMap.custRequestTypeId; - backlogStatusId = projectAndTaskMap.backlogStatusId; + custRequestTypeId = projectAndTaskMap.custRequestTypeId + backlogStatusId = projectAndTaskMap.backlogStatusId if (custRequestTypeId.equals("RF_SCRUM_MEETINGS") && backlogStatusId.equals("CRQ_REVIEWED")) { - projectSprintBacklogAndTaskList.add(projectAndTaskMap); + projectSprintBacklogAndTaskList.add(projectAndTaskMap) } } else { - projectSprintBacklogAndTaskList.add(0,projectAndTaskMap); + projectSprintBacklogAndTaskList.add(0,projectAndTaskMap) } } } // for unplanned taks. -unplanList=[]; +unplanList=[] if (backlogIndexList) { - backlogIndex = new HashSet(backlogIndexList); - custRequestList = from("CustRequest").where("custRequestTypeId", "RF_UNPLAN_BACKLOG","statusId", "CRQ_REVIEWED").orderBy("custRequestDate DESC").queryList(); + backlogIndex = new HashSet(backlogIndexList) + custRequestList = from("CustRequest").where("custRequestTypeId", "RF_UNPLAN_BACKLOG","statusId", "CRQ_REVIEWED").orderBy("custRequestDate DESC").queryList() if (custRequestList) { custRequestList.each { custRequestMap -> - custRequestItemList = custRequestMap.getRelated("CustRequestItem", null, null, false); + custRequestItemList = custRequestMap.getRelated("CustRequestItem", null, null, false) custRequestItem = - productOut = custRequestItemList[0].productId; - product = from("Product").where("productId", productOut).queryOne(); + productOut = custRequestItemList[0].productId + product = from("Product").where("productId", productOut).queryOne() backlogIndex.each { backlogProduct -> productId = backlogProduct if (productId.equals(productOut)) { - custRequestWorkEffortList = from("CustRequestWorkEffort").where("custRequestId", custRequestItemList[0].custRequestId).queryList(); + custRequestWorkEffortList = from("CustRequestWorkEffort").where("custRequestId", custRequestItemList[0].custRequestId).queryList() custRequestWorkEffortList.each { custRequestWorkEffortMap -> - partyAssignmentTaskList = from("WorkEffortPartyAssignment").where("workEffortId", custRequestWorkEffortMap.workEffortId).queryList(); - partyAssignmentTaskMap = partyAssignmentTaskList[0]; + partyAssignmentTaskList = from("WorkEffortPartyAssignment").where("workEffortId", custRequestWorkEffortMap.workEffortId).queryList() + partyAssignmentTaskMap = partyAssignmentTaskList[0] // if the task do not assigned if (!partyAssignmentTaskMap) { - result = [:]; - workEffortMap = from("WorkEffort").where("workEffortId", custRequestWorkEffortMap.workEffortId).queryOne(); - result.description = custRequestMap.description; - result.productName = product.internalName; - result.taskId = workEffortMap.workEffortId; - result.taskName = workEffortMap.workEffortName; - result.custRequestTypeId = custRequestMap.custRequestTypeId; - result.taskTypeId = workEffortMap.workEffortTypeId; - unplanList.add(result); + result = [:] + workEffortMap = from("WorkEffort").where("workEffortId", custRequestWorkEffortMap.workEffortId).queryOne() + result.description = custRequestMap.description + result.productName = product.internalName + result.taskId = workEffortMap.workEffortId + result.taskName = workEffortMap.workEffortName + result.custRequestTypeId = custRequestMap.custRequestTypeId + result.taskTypeId = workEffortMap.workEffortTypeId + unplanList.add(result) } } } @@ -438,26 +438,26 @@ if (backlogIndexList) { } } } -projectSprintBacklogAndTaskList = UtilMisc.sortMaps(projectSprintBacklogAndTaskList, ["projectName","sprintName","-taskTypeId","custRequestId"]); +projectSprintBacklogAndTaskList = UtilMisc.sortMaps(projectSprintBacklogAndTaskList, ["projectName","sprintName","-taskTypeId","custRequestId"]) projectSprintBacklogAndTaskList.each { projectSprintBacklogAndTaskMap -> - blTypeId = projectSprintBacklogAndTaskMap.custRequestTypeId; + blTypeId = projectSprintBacklogAndTaskMap.custRequestTypeId if (blTypeId == "RF_SCRUM_MEETINGS"){ - taskList.add(projectSprintBacklogAndTaskMap); + taskList.add(projectSprintBacklogAndTaskMap) } } -projectSprintBacklogAndTaskList = UtilMisc.sortMaps(projectSprintBacklogAndTaskList, ["-projectName","sprintName","-taskTypeId","custRequestId"]); +projectSprintBacklogAndTaskList = UtilMisc.sortMaps(projectSprintBacklogAndTaskList, ["-projectName","sprintName","-taskTypeId","custRequestId"]) projectSprintBacklogAndTaskList.each { projectSprintBacklogAndTaskMap -> - blTypeId = projectSprintBacklogAndTaskMap.custRequestTypeId; + blTypeId = projectSprintBacklogAndTaskMap.custRequestTypeId if (blTypeId == "RF_PROD_BACKLOG"){ - taskList.add(0,projectSprintBacklogAndTaskMap); + taskList.add(0,projectSprintBacklogAndTaskMap) } } -unplanList = UtilMisc.sortMaps(unplanList,["-productName","-taskTypeId","custRequestId"]); +unplanList = UtilMisc.sortMaps(unplanList,["-productName","-taskTypeId","custRequestId"]) unplanList.each { unplanMap-> - taskList.add(0,unplanMap); + taskList.add(0,unplanMap) } -context.taskList = taskList; +context.taskList = taskList // notification context -webSiteId = WebSiteWorker.getWebSiteId(request); -context.webSiteId = webSiteId; +webSiteId = WebSiteWorker.getWebSiteId(request) +context.webSiteId = webSiteId diff --git a/scrum/groovyScripts/EditWeekTimesheet.groovy b/scrum/groovyScripts/EditWeekTimesheet.groovy index a7bd1c2c8..fa5d7b718 100644 --- a/scrum/groovyScripts/EditWeekTimesheet.groovy +++ b/scrum/groovyScripts/EditWeekTimesheet.groovy @@ -17,192 +17,192 @@ * under the License. */ -import java.util.*; -import java.lang.*; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.base.util.UtilMisc; -import org.apache.ofbiz.base.util.UtilValidate; -import org.apache.ofbiz.base.util.UtilDateTime; -import org.apache.ofbiz.entity.util.*; -import org.apache.ofbiz.entity.condition.*; -import java.sql.Timestamp; +import java.util.* +import java.lang.* +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.base.util.UtilMisc +import org.apache.ofbiz.base.util.UtilValidate +import org.apache.ofbiz.base.util.UtilDateTime +import org.apache.ofbiz.entity.util.* +import org.apache.ofbiz.entity.condition.* +import java.sql.Timestamp -uiLabelMap = UtilProperties.getResourceBundleMap("scrumUiLabels", locale); +uiLabelMap = UtilProperties.getResourceBundleMap("scrumUiLabels", locale) -partyId = parameters.partyId; +partyId = parameters.partyId if (!partyId) { - partyId = parameters.userLogin.partyId; + partyId = parameters.userLogin.partyId } // show the requested timesheet, otherwise the current , if not exist create -timesheet = null; -timesheetId = parameters.timesheetId; +timesheet = null +timesheetId = parameters.timesheetId if (timesheetId) { - timesheet = from("Timesheet").where("timesheetId", timesheetId).queryOne(); - partyId = timesheet.partyId; // use the party from this timesheet + timesheet = from("Timesheet").where("timesheetId", timesheetId).queryOne() + partyId = timesheet.partyId // use the party from this timesheet } else { // make sure because of timezone changes, not a duplicate timesheet is created - midweek = UtilDateTime.addDaysToTimestamp(UtilDateTime.getWeekStart(UtilDateTime.nowTimestamp()),3); + midweek = UtilDateTime.addDaysToTimestamp(UtilDateTime.getWeekStart(UtilDateTime.nowTimestamp()),3) entryExprs = EntityCondition.makeCondition([ EntityCondition.makeCondition("fromDate", EntityComparisonOperator.LESS_THAN, midweek), EntityCondition.makeCondition("thruDate", EntityComparisonOperator.GREATER_THAN, midweek), EntityCondition.makeCondition("partyId", EntityComparisonOperator.EQUALS, partyId) - ], EntityOperator.AND); - entryIterator = from("Timesheet").where(entryExprs).queryIterator(); - timesheet = entryIterator.next(); - entryIterator.close(); + ], EntityOperator.AND) + entryIterator = from("Timesheet").where(entryExprs).queryIterator() + timesheet = entryIterator.next() + entryIterator.close() if (timesheet == null) { - result = runService('createProjectTimesheet', ["userLogin" : parameters.userLogin, "partyId" : partyId]); + result = runService('createProjectTimesheet', ["userLogin" : parameters.userLogin, "partyId" : partyId]) if (result && result.timesheetId) { - timesheet = from("Timesheet").where("timesheetId", result.timesheetId).queryOne(); + timesheet = from("Timesheet").where("timesheetId", result.timesheetId).queryOne() } } } -if (!timesheet) return; -context.timesheet = timesheet; -context.weekNumber = UtilDateTime.weekNumber(timesheet.fromDate); +if (!timesheet) return +context.timesheet = timesheet +context.weekNumber = UtilDateTime.weekNumber(timesheet.fromDate) // get the user names -context.partyNameView = from("PartyNameView").where("partyId", partyId).queryOne(); +context.partyNameView = from("PartyNameView").where("partyId", partyId).queryOne() // get the default rate for this person -rateTypes = from("PartyRate").where("partyId", partyId, "defaultRate", "Y").filterByDate().queryList(); +rateTypes = from("PartyRate").where("partyId", partyId, "defaultRate", "Y").filterByDate().queryList() if (rateTypes) { - context.defaultRateTypeId = rateTypes[0].rateTypeId; + context.defaultRateTypeId = rateTypes[0].rateTypeId } -entries = []; -entry = ["timesheetId" : timesheet.timesheetId]; -taskTotal = 0.00; -day0Total = 0.00; day1Total=0.00; day2Total=0.00; day3Total=0.00; day4Total=0.00; day5Total=0.00; day6Total=0.00; -pHours = 0.00; -timeEntry = null; -lastTimeEntry = null; +entries = [] +entry = ["timesheetId" : timesheet.timesheetId] +taskTotal = 0.00 +day0Total = 0.00; day1Total=0.00; day2Total=0.00; day3Total=0.00; day4Total=0.00; day5Total=0.00; day6Total=0.00 +pHours = 0.00 +timeEntry = null +lastTimeEntry = null // retrieve work effort data when the workeffortId has changed. void retrieveWorkEffortData() { // get the planned number of hours - entryWorkEffort = lastTimeEntry.getRelatedOne("WorkEffort", false); + entryWorkEffort = lastTimeEntry.getRelatedOne("WorkEffort", false) if (entryWorkEffort) { - plannedHours = entryWorkEffort.getRelated("WorkEffortSkillStandard", null, null, false); - pHours = 0.00; + plannedHours = entryWorkEffort.getRelated("WorkEffortSkillStandard", null, null, false) + pHours = 0.00 plannedHours.each { plannedHour -> if (plannedHour.estimatedDuration) { - pHours += plannedHour.estimatedDuration; + pHours += plannedHour.estimatedDuration } } - entry.plannedHours = pHours; - actualHours = entryWorkEffort.getRelated("TimeEntry", null, null, false); - aHours = 0.00; + entry.plannedHours = pHours + actualHours = entryWorkEffort.getRelated("TimeEntry", null, null, false) + aHours = 0.00 actualHours.each { actualHour -> if (actualHour.hours) { - aHours += actualHour.hours; + aHours += actualHour.hours } } - entry.actualHours = aHours; + entry.actualHours = aHours // get party assignment data to be able to set the task to complete - workEffortPartyAssigns = EntityUtil.filterByDate(entryWorkEffort.getRelated("WorkEffortPartyAssignment", ["partyId" : partyId], null, false)); + workEffortPartyAssigns = EntityUtil.filterByDate(entryWorkEffort.getRelated("WorkEffortPartyAssignment", ["partyId" : partyId], null, false)) if (workEffortPartyAssigns) { - workEffortPartyAssign = workEffortPartyAssigns[0]; - entry.fromDate = workEffortPartyAssign.getTimestamp("fromDate"); - entry.roleTypeId = workEffortPartyAssign.roleTypeId; + workEffortPartyAssign = workEffortPartyAssigns[0] + entry.fromDate = workEffortPartyAssign.getTimestamp("fromDate") + entry.roleTypeId = workEffortPartyAssign.roleTypeId if ("PAS_COMPLETED".equals(workEffortPartyAssign.statusId)) { - entry.checkComplete = "Y"; + entry.checkComplete = "Y" } } // get project/phase information - entry.workEffortId = entryWorkEffort.workEffortId; - entry.workEffortName = entryWorkEffort.workEffortName; - result = runService('getProjectIdAndNameFromTask', ["userLogin" : parameters.userLogin,"taskId" : entryWorkEffort.workEffortId]); - entry.sprintId = result.phaseId; - entry.sprintName = result.phaseName; - entry.projectId = result.projectId; - entry.projectName = result.projectName; - entry.taskWbsId = result.taskWbsId; + entry.workEffortId = entryWorkEffort.workEffortId + entry.workEffortName = entryWorkEffort.workEffortName + result = runService('getProjectIdAndNameFromTask', ["userLogin" : parameters.userLogin,"taskId" : entryWorkEffort.workEffortId]) + entry.sprintId = result.phaseId + entry.sprintName = result.phaseName + entry.projectId = result.projectId + entry.projectName = result.projectName + entry.taskWbsId = result.taskWbsId } - entry.total = taskTotal; + entry.total = taskTotal //Drop Down Lists - entries.add(entry); + entries.add(entry) // start new entry - taskTotal = 0.00; - entry = ["timesheetId" : timesheet.timesheetId]; + taskTotal = 0.00 + entry = ["timesheetId" : timesheet.timesheetId] } -timeEntries = timesheet.getRelated("TimeEntry", null, ["workEffortId", "rateTypeId", "fromDate"], false); -te = timeEntries.iterator(); +timeEntries = timesheet.getRelated("TimeEntry", null, ["workEffortId", "rateTypeId", "fromDate"], false) +te = timeEntries.iterator() while (te.hasNext()) { // only fill lastTimeEntry when not the first time if (timeEntry!=void) { - lastTimeEntry = timeEntry; + lastTimeEntry = timeEntry } - timeEntry = te.next(); + timeEntry = te.next() if (lastTimeEntry && (!lastTimeEntry.workEffortId.equals(timeEntry.workEffortId) || !lastTimeEntry.rateTypeId.equals(timeEntry.rateTypeId))) { - retrieveWorkEffortData(); + retrieveWorkEffortData() } if (timeEntry.hours) { - dayNumber = "d" + (timeEntry.fromDate.getTime() - timesheet.fromDate.getTime()) / (24*60*60*1000); - hours = timeEntry.hours.doubleValue(); - entry.put(String.valueOf(dayNumber), hours); - if (dayNumber.equals("d0")) day0Total += hours; - if (dayNumber.equals("d1")) day1Total += hours; - if (dayNumber.equals("d2")) day2Total += hours; - if (dayNumber.equals("d3")) day3Total += hours; - if (dayNumber.equals("d4")) day4Total += hours; - if (dayNumber.equals("d5")) day5Total += hours; - if (dayNumber.equals("d6")) day6Total += hours; - taskTotal += hours; + dayNumber = "d" + (timeEntry.fromDate.getTime() - timesheet.fromDate.getTime()) / (24*60*60*1000) + hours = timeEntry.hours.doubleValue() + entry.put(String.valueOf(dayNumber), hours) + if (dayNumber.equals("d0")) day0Total += hours + if (dayNumber.equals("d1")) day1Total += hours + if (dayNumber.equals("d2")) day2Total += hours + if (dayNumber.equals("d3")) day3Total += hours + if (dayNumber.equals("d4")) day4Total += hours + if (dayNumber.equals("d5")) day5Total += hours + if (dayNumber.equals("d6")) day6Total += hours + taskTotal += hours } - entry.rateTypeId = timeEntry.rateTypeId; + entry.rateTypeId = timeEntry.rateTypeId } if (timeEntry) { - lastTimeEntry = timeEntry; - retrieveWorkEffortData(); + lastTimeEntry = timeEntry + retrieveWorkEffortData() } // add empty lines if timesheet not completed if (!timesheet.statusId.equals("TIMESHEET_COMPLETED")) { for (c=0; c < 3; c++) { // add empty lines - entries.add(["timesheetId" : timesheet.timesheetId]); + entries.add(["timesheetId" : timesheet.timesheetId]) } } // add the totals line if at least one entry if (timeEntry) { - entry = ["timesheetId" : timesheet.timesheetId]; - entry.d0 = day0Total; - entry.d1 = day1Total; - entry.d2 = day2Total; - entry.d3 = day3Total; - entry.d4 = day4Total; - entry.d5 = day5Total; - entry.d6 = day6Total; - entry.phaseName = uiLabelMap.ScrumTotals; - entry.workEffortId = "Totals"; - entry.total = day0Total + day1Total + day2Total + day3Total + day4Total + day5Total + day6Total; - entries.add(entry); + entry = ["timesheetId" : timesheet.timesheetId] + entry.d0 = day0Total + entry.d1 = day1Total + entry.d2 = day2Total + entry.d3 = day3Total + entry.d4 = day4Total + entry.d5 = day5Total + entry.d6 = day6Total + entry.phaseName = uiLabelMap.ScrumTotals + entry.workEffortId = "Totals" + entry.total = day0Total + day1Total + day2Total + day3Total + day4Total + day5Total + day6Total + entries.add(entry) } -context.timeEntries = entries; +context.timeEntries = entries // get all timesheets of this user, including the planned hours -timesheetsDb = from("Timesheet").where("partyId", partyId).orderBy("fromDate DESC").queryList(); -timesheets = new LinkedList(); +timesheetsDb = from("Timesheet").where("partyId", partyId).orderBy("fromDate DESC").queryList() +timesheets = new LinkedList() timesheetsDb.each { timesheetDb -> - timesheet = [:]; - timesheet.putAll(timesheetDb); - entries = timesheetDb.getRelated("TimeEntry", null, null, false); - hours = 0.00; + timesheet = [:] + timesheet.putAll(timesheetDb) + entries = timesheetDb.getRelated("TimeEntry", null, null, false) + hours = 0.00 entries.each { timeEntry -> if (timeEntry.hours) { - hours += timeEntry.hours.doubleValue(); + hours += timeEntry.hours.doubleValue() } } - timesheet.weekNumber = UtilDateTime.weekNumber(timesheetDb.fromDate); - timesheet.hours = hours; - timesheets.add(timesheet); + timesheet.weekNumber = UtilDateTime.weekNumber(timesheetDb.fromDate) + timesheet.hours = hours + timesheets.add(timesheet) } -context.timesheets = timesheets; +context.timesheets = timesheets diff --git a/scrum/groovyScripts/FindBacklogItem.groovy b/scrum/groovyScripts/FindBacklogItem.groovy index f6be2baa8..39dd3cb59 100644 --- a/scrum/groovyScripts/FindBacklogItem.groovy +++ b/scrum/groovyScripts/FindBacklogItem.groovy @@ -17,71 +17,71 @@ * under the License. */ -import java.util.*; -import java.lang.*; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.base.util.UtilMisc; -import org.apache.ofbiz.base.util.UtilValidate; -import org.apache.ofbiz.base.util.UtilDateTime; -import org.apache.ofbiz.entity.util.*; -import org.apache.ofbiz.entity.condition.*; -import java.sql.Timestamp; +import java.util.* +import java.lang.* +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.base.util.UtilMisc +import org.apache.ofbiz.base.util.UtilValidate +import org.apache.ofbiz.base.util.UtilDateTime +import org.apache.ofbiz.entity.util.* +import org.apache.ofbiz.entity.condition.* +import java.sql.Timestamp -productId =parameters.productId; -custRequestList=[]; -backlogList=[]; -custRequestList = from("CustRequestItem").where("productId", productId).queryList(); +productId =parameters.productId +custRequestList=[] +backlogList=[] +custRequestList = from("CustRequestItem").where("productId", productId).queryList() custRequestList.each { custRequestListMap -> - custRequestId=custRequestListMap.custRequestId; - exprBldr = []; - exprBldr.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "CRQ_REOPENED")); - exprBldr.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "CRQ_REVIEWED")); - andExprs = []; - andExprs.add(EntityCondition.makeCondition("custRequestId", EntityOperator.EQUALS, custRequestId)); - andExprs.add(EntityCondition.makeCondition(exprBldr, EntityOperator.OR)); - custRequestTypeCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND); - orderBy = ["custRequestTypeId"]; - productBacklogList = from("CustRequest").where(andExprs).orderBy("custRequestTypeId").queryList(); + custRequestId=custRequestListMap.custRequestId + exprBldr = [] + exprBldr.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "CRQ_REOPENED")) + exprBldr.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "CRQ_REVIEWED")) + andExprs = [] + andExprs.add(EntityCondition.makeCondition("custRequestId", EntityOperator.EQUALS, custRequestId)) + andExprs.add(EntityCondition.makeCondition(exprBldr, EntityOperator.OR)) + custRequestTypeCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND) + orderBy = ["custRequestTypeId"] + productBacklogList = from("CustRequest").where(andExprs).orderBy("custRequestTypeId").queryList() productBacklogList.each { productBacklogMap -> - productBackId = productBacklogMap.custRequestId; - taskBacklogList = from("CustRequestWorkEffort").where("custRequestId", productBackId).queryList(); - int countImplTask=0, countImplTaskComplete=0, countInstallTask=0, countInstallTaskComplete=0, countErrTask=0, countErrTaskComplete=0, countTestTask=0; + productBackId = productBacklogMap.custRequestId + taskBacklogList = from("CustRequestWorkEffort").where("custRequestId", productBackId).queryList() + int countImplTask=0, countImplTaskComplete=0, countInstallTask=0, countInstallTaskComplete=0, countErrTask=0, countErrTaskComplete=0, countTestTask=0 taskBacklogList.each { taskBacklogMap -> - taskId = taskBacklogMap.workEffortId; + taskId = taskBacklogMap.workEffortId - task = from("WorkEffort").where("workEffortId", taskId).queryOne(); + task = from("WorkEffort").where("workEffortId", taskId).queryOne() if (task.workEffortTypeId == "SCRUM_TASK_IMPL") { - countImplTask+=1; + countImplTask+=1 if ( task.currentStatusId == "STS_COMPLETED" || task.currentStatusId == "STS_CANCELLED") { - countImplTaskComplete+=1; + countImplTaskComplete+=1 } } else if (task.workEffortTypeId == "SCRUM_TASK_INST") { - countInstallTask+=1; + countInstallTask+=1 if ( task.currentStatusId == "STS_COMPLETED" || task.currentStatusId == "STS_CANCELLED") { - countInstallTaskComplete+=1; + countInstallTaskComplete+=1 } } else if (task.workEffortTypeId == "SCRUM_TASK_ERROR") { - countErrTask+=1; + countErrTask+=1 if ( task.currentStatusId == "STS_COMPLETED" || task.currentStatusId == "STS_CANCELLED") { - countErrTaskComplete+=1; + countErrTaskComplete+=1 } } else if (task.workEffortTypeId == "SCRUM_TASK_TEST" || task.currentStatusId == "STS_CANCELLED") { - countTestTask+=1; + countTestTask+=1 } } if ((countImplTask > 0 || countErrTask > 0 || countInstallTask > 0) && countImplTask == countImplTaskComplete && countInstallTask == countInstallTaskComplete && countErrTask == countErrTaskComplete && countTestTask > 0) { - productBacklogMap = productBacklogMap.getAllFields(); - backlogList.add(productBacklogMap); + productBacklogMap = productBacklogMap.getAllFields() + backlogList.add(productBacklogMap) } } } if (backlogList) { backlogList = UtilMisc.sortMaps(backlogList, ["-custRequestName"]) - context.backlogList = backlogList; + context.backlogList = backlogList } diff --git a/scrum/groovyScripts/FindProductBacklogItem.groovy b/scrum/groovyScripts/FindProductBacklogItem.groovy index 34da0495c..46e126c46 100644 --- a/scrum/groovyScripts/FindProductBacklogItem.groovy +++ b/scrum/groovyScripts/FindProductBacklogItem.groovy @@ -17,122 +17,122 @@ * under the License. */ -import java.sql.*; -import java.sql.Timestamp; -import java.util.Calendar; -import net.fortuna.ical4j.model.DateTime; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.condition.*; -import sun.util.calendar.LocalGregorianCalendar.Date; +import java.sql.* +import java.sql.Timestamp +import java.util.Calendar +import net.fortuna.ical4j.model.DateTime +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.condition.* +import sun.util.calendar.LocalGregorianCalendar.Date -def module = "FindProductBacklogItem.groovy"; +def module = "FindProductBacklogItem.groovy" // list planned and unplanned backlog -conditionBacklogList = []; -orConditionBacklogList = []; -mainConditionBacklogList = []; -orConditionsBacklog = null; -orderBy = "custRequestDate"; +conditionBacklogList = [] +orConditionBacklogList = [] +mainConditionBacklogList = [] +orConditionsBacklog = null +orderBy = "custRequestDate" // Prevents the query on all records when loading the screen for the first time if ("Y".equals(parameters.noConditionFind)) { if(parameters.productId){ - conditionBacklogList.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, parameters.productId)); + conditionBacklogList.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, parameters.productId)) } if(parameters.custRequestTypeId){ - conditionBacklogList.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.EQUALS, parameters.custRequestTypeId)); + conditionBacklogList.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.EQUALS, parameters.custRequestTypeId)) }else{ // Adding both possibilities to the condition - orConditionBacklogList.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.EQUALS, "RF_UNPLAN_BACKLOG")); - orConditionBacklogList.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.EQUALS, "RF_PROD_BACKLOG")); - orConditionsBacklog = EntityCondition.makeCondition(orConditionBacklogList, EntityOperator.OR); + orConditionBacklogList.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.EQUALS, "RF_UNPLAN_BACKLOG")) + orConditionBacklogList.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.EQUALS, "RF_PROD_BACKLOG")) + orConditionsBacklog = EntityCondition.makeCondition(orConditionBacklogList, EntityOperator.OR) } if(parameters.billed){ - conditionBacklogList.add(EntityCondition.makeCondition("billed", EntityOperator.EQUALS, parameters.billed)); + conditionBacklogList.add(EntityCondition.makeCondition("billed", EntityOperator.EQUALS, parameters.billed)) }else{ // Adding both choices to the condition - orConditionBacklogList.add(EntityCondition.makeCondition("billed", EntityOperator.EQUALS, "Y")); - orConditionBacklogList.add(EntityCondition.makeCondition("billed", EntityOperator.EQUALS, "N")); - orConditionsBacklog = EntityCondition.makeCondition(orConditionBacklogList, EntityOperator.OR); + orConditionBacklogList.add(EntityCondition.makeCondition("billed", EntityOperator.EQUALS, "Y")) + orConditionBacklogList.add(EntityCondition.makeCondition("billed", EntityOperator.EQUALS, "N")) + orConditionsBacklog = EntityCondition.makeCondition(orConditionBacklogList, EntityOperator.OR) } if(parameters.statusId){ - orderBy = "custSequenceNum"; - conditionBacklogList.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, parameters.statusId)); + orderBy = "custSequenceNum" + conditionBacklogList.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, parameters.statusId)) } if(parameters.parentCustRequestId){ - conditionBacklogList.add(EntityCondition.makeCondition("parentCustRequestId", EntityOperator.EQUALS, parameters.parentCustRequestId)); + conditionBacklogList.add(EntityCondition.makeCondition("parentCustRequestId", EntityOperator.EQUALS, parameters.parentCustRequestId)) } if(parameters.description){ - conditionBacklogList.add(EntityCondition.makeCondition("description", EntityOperator.LIKE, "%" + parameters.description + "%")); + conditionBacklogList.add(EntityCondition.makeCondition("description", EntityOperator.LIKE, "%" + parameters.description + "%")) } if(parameters.fromPartyId){ - conditionBacklogList.add(EntityCondition.makeCondition("fromPartyId", EntityOperator.LIKE, "%" + parameters.fromPartyId + "%")); + conditionBacklogList.add(EntityCondition.makeCondition("fromPartyId", EntityOperator.LIKE, "%" + parameters.fromPartyId + "%")) } if (parameters.custRequestDate){ - fromDate = parameters.custRequestDate; - fromDate = fromDate + " " + "00:00:00.000"; - conditionBacklogList.add(EntityCondition.makeCondition("custRequestDate", EntityOperator.GREATER_THAN_EQUAL_TO, Timestamp.valueOf(fromDate))); - thruDate = parameters.custRequestDate; - thruDate = thruDate + " " + "23:59:59.999"; - conditionBacklogList.add(EntityCondition.makeCondition("custRequestDate", EntityOperator.LESS_THAN_EQUAL_TO, Timestamp.valueOf(thruDate))); + fromDate = parameters.custRequestDate + fromDate = fromDate + " " + "00:00:00.000" + conditionBacklogList.add(EntityCondition.makeCondition("custRequestDate", EntityOperator.GREATER_THAN_EQUAL_TO, Timestamp.valueOf(fromDate))) + thruDate = parameters.custRequestDate + thruDate = thruDate + " " + "23:59:59.999" + conditionBacklogList.add(EntityCondition.makeCondition("custRequestDate", EntityOperator.LESS_THAN_EQUAL_TO, Timestamp.valueOf(thruDate))) } if(parameters.custRequestId){ - conditionBacklogList.add(EntityCondition.makeCondition("custRequestId", EntityOperator.LIKE, parameters.custRequestId + "%")); + conditionBacklogList.add(EntityCondition.makeCondition("custRequestId", EntityOperator.LIKE, parameters.custRequestId + "%")) } - conditionsBacklog = EntityCondition.makeCondition(conditionBacklogList, EntityOperator.AND); + conditionsBacklog = EntityCondition.makeCondition(conditionBacklogList, EntityOperator.AND) if(UtilValidate.isNotEmpty(orConditionsBacklog)){ - mainConditionBacklogList.add(orConditionsBacklog); + mainConditionBacklogList.add(orConditionsBacklog) } - mainConditionBacklogList.add(conditionsBacklog); + mainConditionBacklogList.add(conditionsBacklog) // Request backlogList = select("custRequestId","custRequestTypeId", "custSequenceNum", "statusId", "description", "custEstimatedMilliSeconds", "custRequestName", "parentCustRequestId","productId","billed","custRequestDate","fromPartyId") .from("CustRequestAndCustRequestItem") .where(mainConditionBacklogList) .orderBy("-custRequestTypeId", orderBy) - .queryList(); + .queryList() - def countSequenceBacklog = 1; - def backlogItems = []; + def countSequenceBacklog = 1 + def backlogItems = [] backlogList.each() { backlogItem -> - def tempBacklog = [:]; - tempBacklog.putAll(backlogItem); - tempBacklog.custSequenceNum = countSequenceBacklog; - tempBacklog.realSequenceNum = backlogItem.custSequenceNum; + def tempBacklog = [:] + tempBacklog.putAll(backlogItem) + tempBacklog.custSequenceNum = countSequenceBacklog + tempBacklog.realSequenceNum = backlogItem.custSequenceNum // if custRequest has task then get Actual Hours - backlogCustWorkEffortList = from("CustRequestWorkEffort").where("custRequestId", backlogItem.custRequestId).queryList(); + backlogCustWorkEffortList = from("CustRequestWorkEffort").where("custRequestId", backlogItem.custRequestId).queryList() if (backlogCustWorkEffortList) { - actualHours = 0.00; + actualHours = 0.00 backlogCustWorkEffortList.each() { custWorkEffortMap -> - result = runService('getScrumActualHour', ["taskId" : custWorkEffortMap.workEffortId,"partyId" : null, "userLogin" : userLogin]); - actualHours += result.actualHours; + result = runService('getScrumActualHour', ["taskId" : custWorkEffortMap.workEffortId,"partyId" : null, "userLogin" : userLogin]) + actualHours += result.actualHours } if(actualHours) { - tempBacklog.actualHours = actualHours; + tempBacklog.actualHours = actualHours } else { - tempBacklog.actualHours = null; + tempBacklog.actualHours = null } } else { - tempBacklog.actualHours = null; + tempBacklog.actualHours = null } - backlogItems.add(tempBacklog); - countSequenceBacklog ++; + backlogItems.add(tempBacklog) + countSequenceBacklog ++ } // re-order category list item if ("N".equals(parameters.sequence)) { - backlogItems = UtilMisc.sortMaps(backlogItems, ["parentCustRequestId"]); + backlogItems = UtilMisc.sortMaps(backlogItems, ["parentCustRequestId"]) } - context.backlogItems = backlogItems; + context.backlogItems = backlogItems } diff --git a/scrum/groovyScripts/FindTaskList.groovy b/scrum/groovyScripts/FindTaskList.groovy index 61d507819..028ae5d9c 100644 --- a/scrum/groovyScripts/FindTaskList.groovy +++ b/scrum/groovyScripts/FindTaskList.groovy @@ -17,37 +17,37 @@ * under the License. */ -import java.util.*; -import java.lang.*; -import org.apache.tools.ant.taskdefs.Parallel.TaskList; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.base.util.UtilMisc; -import org.apache.ofbiz.base.util.UtilValidate; -import org.apache.ofbiz.base.util.UtilDateTime; -import org.apache.ofbiz.entity.util.*; -import org.apache.ofbiz.entity.condition.*; -import java.sql.Timestamp; +import java.util.* +import java.lang.* +import org.apache.tools.ant.taskdefs.Parallel.TaskList +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.base.util.UtilMisc +import org.apache.ofbiz.base.util.UtilValidate +import org.apache.ofbiz.base.util.UtilDateTime +import org.apache.ofbiz.entity.util.* +import org.apache.ofbiz.entity.condition.* +import java.sql.Timestamp -taskId = parameters.taskId;; -taskName = parameters.taskName; -sprintId = parameters.sprintId; -sprintName = parameters.sprintName; -taskTypeId = parameters.taskTypeId; -projectId = parameters.projectId; -projectName = parameters.projectName; -backlogTypeId = parameters.unplannedFlag; -statusId = parameters.statusId; -partyId = parameters.partyId; +taskId = parameters.taskId +taskName = parameters.taskName +sprintId = parameters.sprintId +sprintName = parameters.sprintName +taskTypeId = parameters.taskTypeId +projectId = parameters.projectId +projectName = parameters.projectName +backlogTypeId = parameters.unplannedFlag +statusId = parameters.statusId +partyId = parameters.partyId -unplannedTaskList = []; -plannedTaskList = []; -resultList=[]; -taskList=[]; -implementTaskList=[]; -testTaskList=[]; -errorTaskList = []; -installTaskList = []; +unplannedTaskList = [] +plannedTaskList = [] +resultList=[] +taskList=[] +implementTaskList=[] +testTaskList=[] +errorTaskList = [] +installTaskList = [] // get Unplaned task list if ((taskId != null)||(taskName != null)||(taskTypeId != null)||(sprintId != null)||(sprintName != null) @@ -55,164 +55,164 @@ if ((taskId != null)||(taskName != null)||(taskTypeId != null)||(sprintId != nul ||(partyId != null)||(viewIndex_1 > 0)||(viewIndex_2 > 0)||(viewIndex_3 > 0)||(viewIndex_4 > 0) ||(viewIndexNo_1 > 0)||(viewIndexNo_2 > 0)||(viewIndexNo_3 > 0)||(viewIndexNo_4 > 0)){ if ((taskId != null)||(taskName != null)||(taskTypeId != null)){ - exprBldr = []; + exprBldr = [] if (taskId) { - exprBldr.add(EntityCondition.makeCondition("workEffortId", EntityOperator.EQUALS, taskId)); + exprBldr.add(EntityCondition.makeCondition("workEffortId", EntityOperator.EQUALS, taskId)) } if (taskName){ - exprBldr.add(EntityCondition.makeCondition("workEffortName", EntityOperator.LIKE, "%"+taskName+"%")); + exprBldr.add(EntityCondition.makeCondition("workEffortName", EntityOperator.LIKE, "%"+taskName+"%")) } if (taskTypeId){ - exprBldr.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, taskTypeId)); + exprBldr.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, taskTypeId)) } if (statusId){ - exprBldr.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.EQUALS, statusId)); + exprBldr.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.EQUALS, statusId)) } - unplannedTaskList = from("UnPlannedBacklogsAndTasks").where(exprBldr).orderBy("-createdDate").queryList(); + unplannedTaskList = from("UnPlannedBacklogsAndTasks").where(exprBldr).orderBy("-createdDate").queryList() } else{ - unplannedTaskList = from("UnPlannedBacklogsAndTasks").orderBy("-createdDate").queryList(); + unplannedTaskList = from("UnPlannedBacklogsAndTasks").orderBy("-createdDate").queryList() } - exprBldr2 = []; + exprBldr2 = [] if (taskId) { - exprBldr2.add(EntityCondition.makeCondition("taskId", EntityOperator.EQUALS, taskId)); + exprBldr2.add(EntityCondition.makeCondition("taskId", EntityOperator.EQUALS, taskId)) } if (taskName){ - exprBldr2.add(EntityCondition.makeCondition("taskName", EntityOperator.LIKE, "%"+taskName+"%")); + exprBldr2.add(EntityCondition.makeCondition("taskName", EntityOperator.LIKE, "%"+taskName+"%")) } if (taskTypeId){ - exprBldr2.add(EntityCondition.makeCondition("taskTypeId", EntityOperator.EQUALS, taskTypeId)); + exprBldr2.add(EntityCondition.makeCondition("taskTypeId", EntityOperator.EQUALS, taskTypeId)) } if (statusId){ - exprBldr2.add(EntityCondition.makeCondition("taskCurrentStatusId", EntityOperator.EQUALS, statusId)); + exprBldr2.add(EntityCondition.makeCondition("taskCurrentStatusId", EntityOperator.EQUALS, statusId)) } if (sprintId){ - exprBldr2.add(EntityCondition.makeCondition("sprintId", EntityOperator.EQUALS, sprintId)); + exprBldr2.add(EntityCondition.makeCondition("sprintId", EntityOperator.EQUALS, sprintId)) } if (sprintName){ - exprBldr2.add(EntityCondition.makeCondition("sprintName", EntityOperator.LIKE, "%"+sprintName+"%")); + exprBldr2.add(EntityCondition.makeCondition("sprintName", EntityOperator.LIKE, "%"+sprintName+"%")) } if (projectId){ - exprBldr2.add(EntityCondition.makeCondition("projectId", EntityOperator.EQUALS, projectId)); + exprBldr2.add(EntityCondition.makeCondition("projectId", EntityOperator.EQUALS, projectId)) } if (projectName){ - exprBldr2.add(EntityCondition.makeCondition("projectName", EntityOperator.LIKE, "%"+projectName+"%")); + exprBldr2.add(EntityCondition.makeCondition("projectName", EntityOperator.LIKE, "%"+projectName+"%")) } - exprBldr2.add(EntityCondition.makeCondition("sprintTypeId", EntityOperator.EQUALS, "SCRUM_SPRINT")); - plannedTaskList = from("ProjectSprintBacklogAndTask").where(exprBldr2).orderBy("-taskCreatedDate").queryList(); + exprBldr2.add(EntityCondition.makeCondition("sprintTypeId", EntityOperator.EQUALS, "SCRUM_SPRINT")) + plannedTaskList = from("ProjectSprintBacklogAndTask").where(exprBldr2).orderBy("-taskCreatedDate").queryList() unplannedTaskList.each{ unplannedTaskMap -> - unplannedMap = [:]; - unplannedMap.taskId = unplannedTaskMap.workEffortId; - unplannedMap.sprintId = null; - unplannedMap.projectId = null; - unplannedMap.productId = unplannedTaskMap.productId; - unplannedMap.taskName = unplannedTaskMap.workEffortName; - unplannedMap.taskTypeId = unplannedTaskMap.workEffortTypeId; - unplannedMap.taskCurrentStatusId = unplannedTaskMap.currentStatusId; - unplannedMap.taskEstimatedMilliSeconds = unplannedTaskMap.estimatedMilliSeconds; - unplannedMap.taskCreatedDate = unplannedTaskMap.createdDate; - unplannedMap.custRequestId = unplannedTaskMap.custRequestId; - unplannedMap.description = unplannedTaskMap.description; - unplannedMap.custRequestTypeId = unplannedTaskMap.custRequestTypeId; - unplannedMap.taskActualMilliSeconds = unplannedTaskMap.actualMilliSeconds; - unplannedMap.taskEstimatedStartDate = unplannedTaskMap.estimatedStartDate; - taskList.add(unplannedMap); + unplannedMap = [:] + unplannedMap.taskId = unplannedTaskMap.workEffortId + unplannedMap.sprintId = null + unplannedMap.projectId = null + unplannedMap.productId = unplannedTaskMap.productId + unplannedMap.taskName = unplannedTaskMap.workEffortName + unplannedMap.taskTypeId = unplannedTaskMap.workEffortTypeId + unplannedMap.taskCurrentStatusId = unplannedTaskMap.currentStatusId + unplannedMap.taskEstimatedMilliSeconds = unplannedTaskMap.estimatedMilliSeconds + unplannedMap.taskCreatedDate = unplannedTaskMap.createdDate + unplannedMap.custRequestId = unplannedTaskMap.custRequestId + unplannedMap.description = unplannedTaskMap.description + unplannedMap.custRequestTypeId = unplannedTaskMap.custRequestTypeId + unplannedMap.taskActualMilliSeconds = unplannedTaskMap.actualMilliSeconds + unplannedMap.taskEstimatedStartDate = unplannedTaskMap.estimatedStartDate + taskList.add(unplannedMap) } plannedTaskList.each{ plannedTaskMap -> - plannedMap = [:]; - plannedMap.taskId = plannedTaskMap.taskId; - plannedMap.taskName = plannedTaskMap.taskName; - plannedMap.taskTypeId = plannedTaskMap.taskTypeId; - plannedMap.taskCurrentStatusId = plannedTaskMap.taskCurrentStatusId; - plannedMap.taskEstimatedMilliSeconds = plannedTaskMap.taskEstimatedMilliSeconds; - plannedMap.taskCreatedDate = plannedTaskMap.taskCreatedDate; - plannedMap.sprintId = plannedTaskMap.sprintId; - plannedMap.sprintName = plannedTaskMap.sprintName; - plannedMap.projectId = plannedTaskMap.projectId; - plannedMap.projectName = plannedTaskMap.projectName; - plannedMap.custRequestId = plannedTaskMap.custRequestId; - plannedMap.description = plannedTaskMap.description; - plannedMap.custRequestTypeId = plannedTaskMap.custRequestTypeId; - plannedMap.taskActualMilliSeconds = plannedTaskMap.taskActualMilliSeconds; - plannedMap.taskEstimatedStartDate = plannedTaskMap.taskEstimatedStartDate; - taskList.add(plannedMap); + plannedMap = [:] + plannedMap.taskId = plannedTaskMap.taskId + plannedMap.taskName = plannedTaskMap.taskName + plannedMap.taskTypeId = plannedTaskMap.taskTypeId + plannedMap.taskCurrentStatusId = plannedTaskMap.taskCurrentStatusId + plannedMap.taskEstimatedMilliSeconds = plannedTaskMap.taskEstimatedMilliSeconds + plannedMap.taskCreatedDate = plannedTaskMap.taskCreatedDate + plannedMap.sprintId = plannedTaskMap.sprintId + plannedMap.sprintName = plannedTaskMap.sprintName + plannedMap.projectId = plannedTaskMap.projectId + plannedMap.projectName = plannedTaskMap.projectName + plannedMap.custRequestId = plannedTaskMap.custRequestId + plannedMap.description = plannedTaskMap.description + plannedMap.custRequestTypeId = plannedTaskMap.custRequestTypeId + plannedMap.taskActualMilliSeconds = plannedTaskMap.taskActualMilliSeconds + plannedMap.taskEstimatedStartDate = plannedTaskMap.taskEstimatedStartDate + taskList.add(plannedMap) } //Check the backlog if (backlogTypeId){ if (backlogTypeId=="Y"){ taskList.each{taskMap -> if(taskMap.custRequestTypeId=="RF_UNPLAN_BACKLOG"){ - resultList.add(taskMap); + resultList.add(taskMap) } } } if (backlogTypeId=="N"){ taskList.each{taskMap -> if(taskMap.custRequestTypeId=="RF_PROD_BACKLOG"){ - resultList.add(taskMap); + resultList.add(taskMap) } } } } else { taskList.each { taskMap -> - resultList.add(taskMap); + resultList.add(taskMap) } } // Check party assigned if (partyId){ - assignedList = resultList; - resultList = []; + assignedList = resultList + resultList = [] assignedList.each { assignedMap -> - workEffortId = assignedMap.taskId; - assignToList = from("WorkEffortPartyAssignment").where("workEffortId", workEffortId, "partyId", partyId).queryList(); + workEffortId = assignedMap.taskId + assignToList = from("WorkEffortPartyAssignment").where("workEffortId", workEffortId, "partyId", partyId).queryList() if (assignToList) { - assignedMap.partyId = assignToList[0].partyId; - resultList.add(assignedMap); + assignedMap.partyId = assignToList[0].partyId + resultList.add(assignedMap) } } } else { - assignedList = resultList; - resultList = []; + assignedList = resultList + resultList = [] assignedList.each { assignedMap -> - workEffortId = assignedMap.taskId; - assignToList = from("WorkEffortPartyAssignment").where("workEffortId", workEffortId).queryList(); + workEffortId = assignedMap.taskId + assignToList = from("WorkEffortPartyAssignment").where("workEffortId", workEffortId).queryList() if (assignToList) { - assignedMap.partyId = assignToList[0].partyId; - resultList.add(assignedMap); + assignedMap.partyId = assignToList[0].partyId + resultList.add(assignedMap) } else { - resultList.add(assignedMap); + resultList.add(assignedMap) } } } resultList.each{resultMap -> if (resultMap.taskTypeId=="SCRUM_TASK_IMPL"){ - implementTaskList.add(resultMap); + implementTaskList.add(resultMap) } if (resultMap.taskTypeId=="SCRUM_TASK_INST"){ - installTaskList.add(resultMap); + installTaskList.add(resultMap) } if (resultMap.taskTypeId=="SCRUM_TASK_TEST"){ - testTaskList.add(resultMap); + testTaskList.add(resultMap) } if (resultMap.taskTypeId=="SCRUM_TASK_ERROR"){ - errorTaskList.add(resultMap); + errorTaskList.add(resultMap) } } if (implementTaskList){ - context.implementTaskList = implementTaskList; + context.implementTaskList = implementTaskList } if (installTaskList){ - context.installTaskList = installTaskList; + context.installTaskList = installTaskList } if (testTaskList){ - context.testTaskList = testTaskList; + context.testTaskList = testTaskList } if (errorTaskList){ - context.errorTaskList = errorTaskList; + context.errorTaskList = errorTaskList } } diff --git a/scrum/groovyScripts/ListCurrentProducts.groovy b/scrum/groovyScripts/ListCurrentProducts.groovy index e8c948f5a..7c4c41fcc 100644 --- a/scrum/groovyScripts/ListCurrentProducts.groovy +++ b/scrum/groovyScripts/ListCurrentProducts.groovy @@ -16,50 +16,50 @@ * specific language governing permissions and limitations * under the License. */ -import org.apache.ofbiz.entity.condition.*; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.util.EntityUtil; +import org.apache.ofbiz.entity.condition.* +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.util.EntityUtil -roleTypeId = null; -paramCond = []; -products = []; -productId = parameters.productId; -internalName = parameters.internalName; -statusId = parameters.statusId; +roleTypeId = null +paramCond = [] +products = [] +productId = parameters.productId +internalName = parameters.internalName +statusId = parameters.statusId if ("Any".equals(statusId)) { - statusId = null; + statusId = null } -partyId = parameters.partyId; +partyId = parameters.partyId if(!security.hasEntityPermission("SCRUM", "_ADMIN", session)){ if(security.hasEntityPermission("SCRUM_PRODUCT", "_ADMIN", session)){ - roleTypeId = "PRODUCT_OWNER"; + roleTypeId = "PRODUCT_OWNER" } } if (userLogin) { if(UtilValidate.isNotEmpty(partyId)){ - paramCond.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId)); + paramCond.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId)) } if(UtilValidate.isNotEmpty(productId)){ - paramCond.add(EntityCondition.makeCondition("productId", EntityOperator.LIKE, productId + "%")); + paramCond.add(EntityCondition.makeCondition("productId", EntityOperator.LIKE, productId + "%")) } if(UtilValidate.isNotEmpty(internalName)){ - paramCond.add(EntityCondition.makeCondition("internalName", EntityOperator.LIKE, "%" + internalName + "%")); + paramCond.add(EntityCondition.makeCondition("internalName", EntityOperator.LIKE, "%" + internalName + "%")) } if(UtilValidate.isNotEmpty(statusId)){ if ("PRODUCT_ACTIVE".equals(statusId)) { - paramCond.add(EntityCondition.makeCondition("supportDiscontinuationDate", EntityOperator.EQUALS, null)); + paramCond.add(EntityCondition.makeCondition("supportDiscontinuationDate", EntityOperator.EQUALS, null)) } else { - paramCond.add(EntityCondition.makeCondition("supportDiscontinuationDate", EntityOperator.NOT_EQUAL, null)); + paramCond.add(EntityCondition.makeCondition("supportDiscontinuationDate", EntityOperator.NOT_EQUAL, null)) } } - paramCond.add(EntityCondition.makeCondition("productTypeId", EntityOperator.EQUALS, "SCRUM_ITEM")); - paramCond.add(EntityCondition.makeCondition("roleTypeId", EntityOperator.EQUALS, "PRODUCT_OWNER_COMP")); - paramCond.add(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null)); + paramCond.add(EntityCondition.makeCondition("productTypeId", EntityOperator.EQUALS, "SCRUM_ITEM")) + paramCond.add(EntityCondition.makeCondition("roleTypeId", EntityOperator.EQUALS, "PRODUCT_OWNER_COMP")) + paramCond.add(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null)) - allProducts = from("ProductAndRole").where(paramCond).orderBy("groupName", "internalName").queryList(); + allProducts = from("ProductAndRole").where(paramCond).orderBy("groupName", "internalName").queryList() partyAndSecurityGroupList = select("partyId", "groupId") .from("ScrumMemberUserLoginAndSecurityGroup").where(EntityCondition.makeCondition([ @@ -68,27 +68,27 @@ if (userLogin) { EntityCondition.makeCondition ("thruDate", EntityOperator.EQUALS, null) ], EntityJoinOperator.AND)) .orderBy("partyId") - .queryList(); + .queryList() - context.partyAndSecurityGroupList = partyAndSecurityGroupList; - boolean addAllProducts = false; + context.partyAndSecurityGroupList = partyAndSecurityGroupList + boolean addAllProducts = false allProducts.each { product -> - product = product.getAllFields(); - productMap = from("Product").where("productId", product.productId).queryOne(); + product = product.getAllFields() + productMap = from("Product").where("productId", product.productId).queryOne() product.put("longDescription",productMap.longDescription) if(security.hasEntityPermission("SCRUM", "_ADMIN", session)){ - addAllProducts = true; + addAllProducts = true }else{ - ismember = false; + ismember = false if (partyAndSecurityGroupList) { - groupId = partyAndSecurityGroupList[0].groupId; + groupId = partyAndSecurityGroupList[0].groupId if ("SCRUM_PRODUCT_OWNER".equals(groupId)) { - productAndRoleList = from("ProductRole").where("productId", product.productId, "partyId", userLogin.partyId, "thruDate", null).queryList(); + productAndRoleList = from("ProductRole").where("productId", product.productId, "partyId", userLogin.partyId, "thruDate", null).queryList() if (productAndRoleList) { productAndRoleList.each { productAndRoleMap -> - productIdInner = productAndRoleMap.productId; + productIdInner = productAndRoleMap.productId if (productIdInner.equals(product.productId)) { - ismember = true; + ismember = true } } } @@ -99,14 +99,14 @@ if (userLogin) { EntityCondition.makeCondition ("roleTypeId", EntityOperator.EQUALS, "STAKEHOLDER"), EntityCondition.makeCondition ("partyStatusId", EntityOperator.NOT_EQUAL, "PARTY_DISABLED"), EntityCondition.makeCondition ("thruDate", EntityOperator.EQUALS, null) - ], EntityJoinOperator.AND); - scrumRolesPersonAndCompanyList = from("ScrumRolesPersonAndCompany").where(scrumRolesCond).queryList(); - productRoleList = from("ProductRole").where("partyId", scrumRolesPersonAndCompanyList[0].partyIdFrom, "roleTypeId", "PRODUCT_OWNER_COMP", "thruDate", null).queryList(); + ], EntityJoinOperator.AND) + scrumRolesPersonAndCompanyList = from("ScrumRolesPersonAndCompany").where(scrumRolesCond).queryList() + productRoleList = from("ProductRole").where("partyId", scrumRolesPersonAndCompanyList[0].partyIdFrom, "roleTypeId", "PRODUCT_OWNER_COMP", "thruDate", null).queryList() if (productRoleList) { productRoleList.each { productRoleMap -> - stakeholderProduct = productRoleMap.productId; + stakeholderProduct = productRoleMap.productId if (stakeholderProduct.equals(product.productId)) { - ismember = true; + ismember = true } } } @@ -114,25 +114,25 @@ if (userLogin) { if (ismember == false) { productAndRoleList = from("ProductAndRole").where("productId" : product.productId, "partyId" : userLogin.partyId, "roleTypeId" : "STAKEHOLDER", "supportDiscontinuationDate" : null, "thruDate" : null).queryList() if (productAndRoleList) { - ismember = true; + ismember = true } } } else if ("SCRUM_MASTER".equals(groupId)) { //check in product. - productRoleList = []; - productRoleList = from("ProductAndRole").where("productId" : product.productId, "partyId" : userLogin.partyId, "roleTypeId" : "SCRUM_MASTER", "supportDiscontinuationDate" : null, "thruDate" : null).queryList(); + productRoleList = [] + productRoleList = from("ProductAndRole").where("productId" : product.productId, "partyId" : userLogin.partyId, "roleTypeId" : "SCRUM_MASTER", "supportDiscontinuationDate" : null, "thruDate" : null).queryList() if (productRoleList) { - ismember = true; + ismember = true } //check in project. if (ismember == false) { - projects = []; - projects = from("WorkEffortAndProduct").where("productId", product.productId, "workEffortTypeId", "SCRUM_PROJECT", "currentStatusId", "SPJ_ACTIVE").queryList(); + projects = [] + projects = from("WorkEffortAndProduct").where("productId", product.productId, "workEffortTypeId", "SCRUM_PROJECT", "currentStatusId", "SPJ_ACTIVE").queryList() if (projects) { projects.each { project -> - projectPartyAssignment = from("WorkEffortPartyAssignment").where("partyId", userLogin.partyId, "workEffortId", project.workEffortId).queryList(); + projectPartyAssignment = from("WorkEffortPartyAssignment").where("partyId", userLogin.partyId, "workEffortId", project.workEffortId).queryList() if (projectPartyAssignment) { - ismember = true; + ismember = true } } } @@ -140,47 +140,47 @@ if (userLogin) { //check in sprint. if (ismember == false) { projects.each { project -> - allSprintList = []; - allSprintList = from("WorkEffort").where("workEffortParentId", project.workEffortId, "currentStatusId", "SPRINT_ACTIVE").queryList(); + allSprintList = [] + allSprintList = from("WorkEffort").where("workEffortParentId", project.workEffortId, "currentStatusId", "SPRINT_ACTIVE").queryList() allSprintList.each { SprintListMap -> - sprintId = SprintListMap.workEffortId; - workEffortPartyAssignment = from("WorkEffortPartyAssignment").where("partyId", userLogin.partyId, "workEffortId", sprintId).queryList(); + sprintId = SprintListMap.workEffortId + workEffortPartyAssignment = from("WorkEffortPartyAssignment").where("partyId", userLogin.partyId, "workEffortId", sprintId).queryList() if (workEffortPartyAssignment) { - ismember = true; + ismember = true } } } } } else { - projects = []; - projects = from("WorkEffortAndProduct").where("productId", product.productId, "workEffortTypeId", "SCRUM_PROJECT", "currentStatusId", "SPJ_ACTIVE").queryList(); + projects = [] + projects = from("WorkEffortAndProduct").where("productId", product.productId, "workEffortTypeId", "SCRUM_PROJECT", "currentStatusId", "SPJ_ACTIVE").queryList() if (projects) { projects.each { project -> - allSprintList = []; - allSprintList = from("WorkEffort").where("workEffortParentId", project.workEffortId, "currentStatusId", "SPRINT_ACTIVE").queryList(); + allSprintList = [] + allSprintList = from("WorkEffort").where("workEffortParentId", project.workEffortId, "currentStatusId", "SPRINT_ACTIVE").queryList() allSprintList.each { SprintListMap -> - sprintId = SprintListMap.workEffortId; - workEffortPartyAssignment = from("WorkEffortPartyAssignment").where("partyId", userLogin.partyId, "workEffortId", sprintId).queryList(); + sprintId = SprintListMap.workEffortId + workEffortPartyAssignment = from("WorkEffortPartyAssignment").where("partyId", userLogin.partyId, "workEffortId", sprintId).queryList() if (workEffortPartyAssignment) { - ismember = true; + ismember = true } } } } if (ismember == false) { exprBldr = [EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "CRQ_REVIEWED"), - EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "CRQ_REOPENED")]; + EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "CRQ_REOPENED")] andExprs = [EntityCondition.makeCondition("productId", EntityOperator.EQUALS, product.productId), EntityCondition.makeCondition("currentStatusId", EntityOperator.EQUALS, "STS_CREATED"), - EntityCondition.makeCondition(exprBldr, EntityOperator.OR)]; - unplannedBacklogCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND); - unplannedBacklogList = from("UnPlannedBacklogsAndTasks").where(unplannedBacklogCond).queryList(); + EntityCondition.makeCondition(exprBldr, EntityOperator.OR)] + unplannedBacklogCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND) + unplannedBacklogList = from("UnPlannedBacklogsAndTasks").where(unplannedBacklogCond).queryList() if (unplannedBacklogList) { unplannedBacklogList.each { unplannedMap -> - workEffortId = unplannedMap.workEffortId; - workEffortPartyAssignment = from("WorkEffortPartyAssignment").where("partyId", userLogin.partyId, "workEffortId", workEffortId).queryList(); + workEffortId = unplannedMap.workEffortId + workEffortPartyAssignment = from("WorkEffortPartyAssignment").where("partyId", userLogin.partyId, "workEffortId", workEffortId).queryList() if (workEffortPartyAssignment) { - ismember = true; + ismember = true } } } @@ -188,17 +188,17 @@ if (userLogin) { } if (ismember) { - products.add(product); + products.add(product) } } } if(addAllProducts) - products.add(product); + products.add(product) } } else { - Debug.logError("Party ID missing =========>>> : null ", ""); + Debug.logError("Party ID missing =========>>> : null ", "") } if (products){ - context.listIt = products; + context.listIt = products } diff --git a/scrum/groovyScripts/ListCurrentSprints.groovy b/scrum/groovyScripts/ListCurrentSprints.groovy index 56c4695f7..11ed080d7 100644 --- a/scrum/groovyScripts/ListCurrentSprints.groovy +++ b/scrum/groovyScripts/ListCurrentSprints.groovy @@ -17,53 +17,53 @@ * under the License. */ -import org.apache.ofbiz.entity.condition.*; -import org.apache.ofbiz.base.util.*; +import org.apache.ofbiz.entity.condition.* +import org.apache.ofbiz.base.util.* cond = EntityCondition.makeCondition([ EntityCondition.makeCondition ("projectTypeId", EntityOperator.EQUALS, "SCRUM_PROJECT"), EntityCondition.makeCondition ("projectStatusId", EntityOperator.NOT_EQUAL, "SPJ_CLOSED") - ], EntityJoinOperator.AND); + ], EntityJoinOperator.AND) securityGroupCond = EntityCondition.makeCondition([ EntityCondition.makeCondition ("partyId", EntityOperator.EQUALS, userLogin.partyId), EntityCondition.makeCondition ("partyStatusId", EntityOperator.NOT_EQUAL, "PARTY_DISABLED"), EntityCondition.makeCondition ("thruDate", EntityOperator.EQUALS, null) - ], EntityJoinOperator.AND); -fields = new HashSet(["partyId", "groupId"]); + ], EntityJoinOperator.AND) +fields = new HashSet(["partyId", "groupId"]) -allSprints = from("ProjectSprint").where(cond).orderBy("projectName", "-sprintActualStartDate").queryList(); -partyAndSecurityGroupList = select("partyId", "groupId").from("ScrumMemberUserLoginAndSecurityGroup").where(securityGroupCond).orderBy("partyId").queryList(); -oldProjectId = null; -newProjectId = null; -countSprint = 0; -sprints = []; +allSprints = from("ProjectSprint").where(cond).orderBy("projectName", "-sprintActualStartDate").queryList() +partyAndSecurityGroupList = select("partyId", "groupId").from("ScrumMemberUserLoginAndSecurityGroup").where(securityGroupCond).orderBy("partyId").queryList() +oldProjectId = null +newProjectId = null +countSprint = 0 +sprints = [] allSprints.each { sprint -> - newProjectId = sprint.projectId; - productAndRole = from("ProductAndRole").where("roleTypeId", "PRODUCT_OWNER_COMP", "productId", sprint.productId).queryList(); - companyId = ""; - companyName = ""; + newProjectId = sprint.projectId + productAndRole = from("ProductAndRole").where("roleTypeId", "PRODUCT_OWNER_COMP", "productId", sprint.productId).queryList() + companyId = "" + companyName = "" if (productAndRole.size() > 0) { - companyName = productAndRole.get(0).groupName; - companyId = productAndRole.get(0).partyId; + companyName = productAndRole.get(0).groupName + companyId = productAndRole.get(0).partyId } - sprint = sprint.getAllFields(); + sprint = sprint.getAllFields() sprint.put("companyId", companyId) sprint.put("companyName", companyName) - product = from("Product").where("productId", sprint.productId).queryOne(); - productName = ""; - if (product != null) productName = product.internalName; - sprint.put("productName", productName); + product = from("Product").where("productId", sprint.productId).queryOne() + productName = "" + if (product != null) productName = product.internalName + sprint.put("productName", productName) //sprint.add("companyName", companyName, "String") if (oldProjectId != newProjectId) { - oldProjectId = newProjectId; - countSprint = 0; - ismember = false; + oldProjectId = newProjectId + countSprint = 0 + ismember = false if (partyAndSecurityGroupList) { - groupId = partyAndSecurityGroupList[0].groupId; + groupId = partyAndSecurityGroupList[0].groupId if ("SCRUM_PRODUCT_OWNER".equals(groupId)) { - productAndRoleList = from("ProductRole").where("productId", sprint.productId, "partyId", partyAndSecurityGroupList.getAt(0).partyId, "thruDate", null).queryList(); + productAndRoleList = from("ProductRole").where("productId", sprint.productId, "partyId", partyAndSecurityGroupList.getAt(0).partyId, "thruDate", null).queryList() if (productAndRoleList) { - ismember = true; + ismember = true } }else if("SCRUM_STAKEHOLDER".equals(groupId)) { // check in company relationship. @@ -72,14 +72,14 @@ allSprints.each { sprint -> EntityCondition.makeCondition ("roleTypeId", EntityOperator.EQUALS, "STAKEHOLDER"), EntityCondition.makeCondition ("partyStatusId", EntityOperator.NOT_EQUAL, "PARTY_DISABLED"), EntityCondition.makeCondition ("thruDate", EntityOperator.EQUALS, null) - ], EntityJoinOperator.AND); - scrumRolesPersonAndCompanyList = from("ScrumRolesPersonAndCompany").where(scrumRolesCond).queryList(); - productRoleList = from("ProductRole").where("partyId", scrumRolesPersonAndCompanyList[0].partyIdFrom, "roleTypeId", "PRODUCT_OWNER_COMP", "thruDate", null).queryList(); + ], EntityJoinOperator.AND) + scrumRolesPersonAndCompanyList = from("ScrumRolesPersonAndCompany").where(scrumRolesCond).queryList() + productRoleList = from("ProductRole").where("partyId", scrumRolesPersonAndCompanyList[0].partyIdFrom, "roleTypeId", "PRODUCT_OWNER_COMP", "thruDate", null).queryList() if (productRoleList) { productRoleList.each { productRoleMap -> - stakeholderProduct = productRoleMap.productId; + stakeholderProduct = productRoleMap.productId if (stakeholderProduct.equals(sprint.productId)) { - ismember = true; + ismember = true } } } @@ -88,49 +88,49 @@ allSprints.each { sprint -> productAndRoleList = from("ProductAndRole") .where("productId", sprint.productId, "partyId", userLogin.partyId, "roleTypeId", "STAKEHOLDER", "supportDiscontinuationDate", null, "thruDate", null) - .queryList(); + .queryList() if (productAndRoleList) { - ismember = true; + ismember = true } } } else if("SCRUM_MASTER".equals(groupId)) { //check in product - productRoleList = []; + productRoleList = [] productRoleList = from("ProductAndRole") .where("productId" : sprint.productId, "partyId" : userLogin.partyId, "roleTypeId" : "SCRUM_MASTER", "supportDiscontinuationDate" : null, "thruDate" : null) - .queryList(); + .queryList() if (productRoleList) { - ismember = true; + ismember = true } //check in project. if (ismember == false) { - projectPartyAssignment = from("WorkEffortPartyAssignment").where("workEffortId", sprint.projectId, "partyId", userLogin.partyId).queryList(); + projectPartyAssignment = from("WorkEffortPartyAssignment").where("workEffortId", sprint.projectId, "partyId", userLogin.partyId).queryList() if (projectPartyAssignment) { - ismember = true; + ismember = true } } //check in sprint. if (ismember == false) { - allSprintList = []; - allSprintList = from("WorkEffort").where("workEffortParentId", sprint.projectId).queryList(); + allSprintList = [] + allSprintList = from("WorkEffort").where("workEffortParentId", sprint.projectId).queryList() allSprintList.each { SprintListMap -> - sprintId = SprintListMap.workEffortId; - workEffortPartyAssignment = from("WorkEffortPartyAssignment").where("workEffortId", sprintId, "partyId", userLogin.partyId).queryList(); + sprintId = SprintListMap.workEffortId + workEffortPartyAssignment = from("WorkEffortPartyAssignment").where("workEffortId", sprintId, "partyId", userLogin.partyId).queryList() if (workEffortPartyAssignment) { - ismember = true; + ismember = true } } } } else { - allSprintList = []; - allSprintList = from("WorkEffort").where("workEffortParentId", sprint.projectId).queryList(); + allSprintList = [] + allSprintList = from("WorkEffort").where("workEffortParentId", sprint.projectId).queryList() allSprintList.each { SprintListMap -> - sprintId = SprintListMap.workEffortId; - workEffortPartyAssignment = from("WorkEffortPartyAssignment").where("workEffortId", sprintId, "partyId", userLogin.partyId).queryList(); + sprintId = SprintListMap.workEffortId + workEffortPartyAssignment = from("WorkEffortPartyAssignment").where("workEffortId", sprintId, "partyId", userLogin.partyId).queryList() if (workEffortPartyAssignment) { - ismember = true; + ismember = true } } } @@ -139,18 +139,18 @@ allSprints.each { sprint -> || ((security.hasEntityPermission("SCRUM", "_ROLE_ADMIN", session) || security.hasEntityPermission("SCRUM", "_ROLE_VIEW", session) || security.hasEntityPermission("SCRUM_PROJECT", "_ROLE_ADMIN", session) || security.hasEntityPermission("SCRUM_PROJECT", "_ROLE_VIEW", session) || security.hasEntityPermission("SCRUM_PROJECT", "_VIEW", session)) && ismember)) { - sprints.add(sprint); - countSprint++; + sprints.add(sprint) + countSprint++ } } else { if (countSprint < 4) { - ismember = false; + ismember = false if (partyAndSecurityGroupList) { - groupId = partyAndSecurityGroupList[0].groupId; + groupId = partyAndSecurityGroupList[0].groupId if ("SCRUM_PRODUCT_OWNER".equals(groupId)) { - productAndRoleList = from("ProductRole").where("productId", sprint.productId, "partyId", partyAndSecurityGroupList.getAt(0).partyId, "thruDate", null).queryList(); + productAndRoleList = from("ProductRole").where("productId", sprint.productId, "partyId", partyAndSecurityGroupList.getAt(0).partyId, "thruDate", null).queryList() if (productAndRoleList) { - ismember = true; + ismember = true } }else if("SCRUM_STAKEHOLDER".equals(groupId)) { // check in company relationship. @@ -159,58 +159,58 @@ allSprints.each { sprint -> EntityCondition.makeCondition ("roleTypeId", EntityOperator.EQUALS, "STAKEHOLDER"), EntityCondition.makeCondition ("partyStatusId", EntityOperator.NOT_EQUAL, "PARTY_DISABLED"), EntityCondition.makeCondition ("thruDate", EntityOperator.EQUALS, null) - ], EntityJoinOperator.AND); - scrumRolesPersonAndCompanyList = from("ScrumRolesPersonAndCompany").where(scrumRolesCond).queryList(); - productRoleList = from("ProductRole").where("partyId", scrumRolesPersonAndCompanyList[0].partyIdFrom, "roleTypeId", "PRODUCT_OWNER_COMP", "thruDate", null).queryList(); + ], EntityJoinOperator.AND) + scrumRolesPersonAndCompanyList = from("ScrumRolesPersonAndCompany").where(scrumRolesCond).queryList() + productRoleList = from("ProductRole").where("partyId", scrumRolesPersonAndCompanyList[0].partyIdFrom, "roleTypeId", "PRODUCT_OWNER_COMP", "thruDate", null).queryList() if (productRoleList) { productRoleList.each { productRoleMap -> - stakeholderProduct = productRoleMap.productId; + stakeholderProduct = productRoleMap.productId if (stakeholderProduct.equals(sprint.productId)) { - ismember = true; + ismember = true } } } //check in product. if (ismember == false) { - productAndRoleList = from("ProductAndRole").where("productId" : sprint.productId, "partyId" : userLogin.partyId, "roleTypeId" : "STAKEHOLDER", "supportDiscontinuationDate" : null, "thruDate" : null).queryList(); + productAndRoleList = from("ProductAndRole").where("productId" : sprint.productId, "partyId" : userLogin.partyId, "roleTypeId" : "STAKEHOLDER", "supportDiscontinuationDate" : null, "thruDate" : null).queryList() if (productAndRoleList) { - ismember = true; + ismember = true } } } else if("SCRUM_MASTER".equals(groupId)) { //check in product - productRoleList = []; - productRoleList = from("ProductAndRole").where("productId" : sprint.productId, "partyId" : userLogin.partyId, "roleTypeId" : "SCRUM_MASTER", "supportDiscontinuationDate" : null, "thruDate" : null).queryList(); + productRoleList = [] + productRoleList = from("ProductAndRole").where("productId" : sprint.productId, "partyId" : userLogin.partyId, "roleTypeId" : "SCRUM_MASTER", "supportDiscontinuationDate" : null, "thruDate" : null).queryList() if (productRoleList) { - ismember = true; + ismember = true } //check in project. if (ismember == false) { - projectPartyAssignment = from("WorkEffortPartyAssignment").where("workEffortId", sprint.projectId, "partyId", userLogin.partyId).queryList(); + projectPartyAssignment = from("WorkEffortPartyAssignment").where("workEffortId", sprint.projectId, "partyId", userLogin.partyId).queryList() if (projectPartyAssignment) { - ismember = true; + ismember = true } } //check in sprint. if (ismember == false) { - allSprintList = []; - allSprintList = from("WorkEffort").where("workEffortParentId", sprint.projectId).queryList(); + allSprintList = [] + allSprintList = from("WorkEffort").where("workEffortParentId", sprint.projectId).queryList() allSprintList.each { SprintListMap -> - sprintId = SprintListMap.workEffortId; - workEffortPartyAssignment = from("WorkEffortPartyAssignment").where("workEffortId", sprintId, "partyId", userLogin.partyId).queryList(); + sprintId = SprintListMap.workEffortId + workEffortPartyAssignment = from("WorkEffortPartyAssignment").where("workEffortId", sprintId, "partyId", userLogin.partyId).queryList() if (workEffortPartyAssignment) { - ismember = true; + ismember = true } } } } else { - allSprintList = []; - allSprintList = from("WorkEffort").where("workEffortParentId", sprint.projectId).queryList(); + allSprintList = [] + allSprintList = from("WorkEffort").where("workEffortParentId", sprint.projectId).queryList() allSprintList.each { SprintListMap -> - sprintId = SprintListMap.workEffortId; - workEffortPartyAssignment = from("WorkEffortPartyAssignment").where("workEffortId", sprintId, "partyId", userLogin.partyId).queryList(); + sprintId = SprintListMap.workEffortId + workEffortPartyAssignment = from("WorkEffortPartyAssignment").where("workEffortId", sprintId, "partyId", userLogin.partyId).queryList() if (workEffortPartyAssignment) { - ismember = true; + ismember = true } } } @@ -219,13 +219,13 @@ allSprints.each { sprint -> || ((security.hasEntityPermission("SCRUM", "_ROLE_ADMIN", session) || security.hasEntityPermission("SCRUM", "_ROLE_VIEW", session) || security.hasEntityPermission("SCRUM_PROJECT", "_ROLE_ADMIN", session) || security.hasEntityPermission("SCRUM_PROJECT", "_ROLE_VIEW", session) || security.hasEntityPermission("SCRUM_PROJECT", "_VIEW", session)) && ismember)) { - sprints.add(sprint); - countSprint++; + sprints.add(sprint) + countSprint++ } } } } if (sprints) { sprints = UtilMisc.sortMaps(sprints, ["companyName", "projectName", "productName"]) - context.sprints = sprints; + context.sprints = sprints } diff --git a/scrum/groovyScripts/ListRevision.groovy b/scrum/groovyScripts/ListRevision.groovy index 5b53fd44c..128a682f6 100644 --- a/scrum/groovyScripts/ListRevision.groovy +++ b/scrum/groovyScripts/ListRevision.groovy @@ -17,76 +17,76 @@ * under the License. */ -import org.apache.ofbiz.base.util.UtilMisc; -import org.apache.ofbiz.base.util.Debug; -import org.apache.ofbiz.entity.util.*; -import org.apache.ofbiz.entity.condition.*; +import org.apache.ofbiz.base.util.UtilMisc +import org.apache.ofbiz.base.util.Debug +import org.apache.ofbiz.entity.util.* +import org.apache.ofbiz.entity.condition.* -custRequestList = []; -custAndWorkEffortList = []; -revisionList = []; -listIt = []; +custRequestList = [] +custAndWorkEffortList = [] +revisionList = [] +listIt = [] //for productId and custRequestId if ((parameters.productId != null)||(parameters.custRequestId != null)||(parameters.workEffortId != null)||(viewIndex > 0)) { - orList = []; - orList.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.EQUALS, "RF_PROD_BACKLOG")); - orList.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.EQUALS, "RF_UNPLAN_BACKLOG")); - andList = []; + orList = [] + orList.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.EQUALS, "RF_PROD_BACKLOG")) + orList.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.EQUALS, "RF_UNPLAN_BACKLOG")) + andList = [] if (parameters.productId) { - andList.add(EntityCondition.makeCondition("productId", EntityOperator.LIKE, parameters.productId + "%")); + andList.add(EntityCondition.makeCondition("productId", EntityOperator.LIKE, parameters.productId + "%")) } if (parameters.custRequestId) { - andList.add(EntityCondition.makeCondition("custRequestId", EntityOperator.LIKE, parameters.custRequestId + "%")); + andList.add(EntityCondition.makeCondition("custRequestId", EntityOperator.LIKE, parameters.custRequestId + "%")) } - andList.add(EntityCondition.makeCondition(orList, EntityOperator.OR)); - custRequestCond = EntityCondition.makeCondition(andList, EntityOperator.AND); - custRequestList = from("CustRequestAndCustRequestItem").where(custRequestCond).queryList(); + andList.add(EntityCondition.makeCondition(orList, EntityOperator.OR)) + custRequestCond = EntityCondition.makeCondition(andList, EntityOperator.AND) + custRequestList = from("CustRequestAndCustRequestItem").where(custRequestCond).queryList() - custRequestIds = EntityUtil.getFieldListFromEntityList(custRequestList, "custRequestId", true); - taskOrList = []; - taskOrList.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "SCRUM_TASK_ERROR")); - taskOrList.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "SCRUM_TASK_TEST")); - taskOrList.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "SCRUM_TASK_IMPL")); - taskOrList.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "SCRUM_TASK_INST")); - taskAndList = []; - taskAndList.add(EntityCondition.makeCondition("custRequestId", EntityOperator.IN, custRequestIds)); - taskAndList.add(EntityCondition.makeCondition(taskOrList, EntityOperator.OR)); - custAndWorkEffortCond = EntityCondition.makeCondition(taskAndList, EntityOperator.AND); - custAndWorkEffortList = from("CustRequestAndWorkEffort").where(custAndWorkEffortCond).queryList(); + custRequestIds = EntityUtil.getFieldListFromEntityList(custRequestList, "custRequestId", true) + taskOrList = [] + taskOrList.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "SCRUM_TASK_ERROR")) + taskOrList.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "SCRUM_TASK_TEST")) + taskOrList.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "SCRUM_TASK_IMPL")) + taskOrList.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "SCRUM_TASK_INST")) + taskAndList = [] + taskAndList.add(EntityCondition.makeCondition("custRequestId", EntityOperator.IN, custRequestIds)) + taskAndList.add(EntityCondition.makeCondition(taskOrList, EntityOperator.OR)) + custAndWorkEffortCond = EntityCondition.makeCondition(taskAndList, EntityOperator.AND) + custAndWorkEffortList = from("CustRequestAndWorkEffort").where(custAndWorkEffortCond).queryList() //for workEffortId - workEffortIds = EntityUtil.getFieldListFromEntityList(custAndWorkEffortList, "workEffortId", true); - revisionAndList = []; + workEffortIds = EntityUtil.getFieldListFromEntityList(custAndWorkEffortList, "workEffortId", true) + revisionAndList = [] if (parameters.workEffortId) { - revisionAndList.add(EntityCondition.makeCondition("workEffortId", EntityOperator.LIKE, parameters.workEffortId + "%")); + revisionAndList.add(EntityCondition.makeCondition("workEffortId", EntityOperator.LIKE, parameters.workEffortId + "%")) } else { - revisionAndList.add(EntityCondition.makeCondition("workEffortId", EntityOperator.IN, workEffortIds)); + revisionAndList.add(EntityCondition.makeCondition("workEffortId", EntityOperator.IN, workEffortIds)) } - revisionAndList.add(EntityCondition.makeCondition("workEffortContentTypeId", EntityOperator.EQUALS, "TASK_SUB_INFO")); - revisionCond = EntityCondition.makeCondition(revisionAndList, EntityOperator.AND); - revisionList = from("WorkEffortAndContentDataResource").where(revisionCond).orderBy("-fromDate").queryList(); + revisionAndList.add(EntityCondition.makeCondition("workEffortContentTypeId", EntityOperator.EQUALS, "TASK_SUB_INFO")) + revisionCond = EntityCondition.makeCondition(revisionAndList, EntityOperator.AND) + revisionList = from("WorkEffortAndContentDataResource").where(revisionCond).orderBy("-fromDate").queryList() if (revisionList) { revisionList.each { revisionMap -> - inputMap = [:]; - inputMap.workEffortId = revisionMap.workEffortId; - inputMap.contentId = revisionMap.contentId; - inputMap.fromDate = revisionMap.fromDate; - inputMap.contentName = revisionMap.contentName; - inputMap.description = revisionMap.description; - inputMap.drObjectInfo = revisionMap.drObjectInfo; - custAndWorkEfffList = from("CustRequestAndWorkEffort").where("workEffortId", revisionMap.workEffortId).queryList(); + inputMap = [:] + inputMap.workEffortId = revisionMap.workEffortId + inputMap.contentId = revisionMap.contentId + inputMap.fromDate = revisionMap.fromDate + inputMap.contentName = revisionMap.contentName + inputMap.description = revisionMap.description + inputMap.drObjectInfo = revisionMap.drObjectInfo + custAndWorkEfffList = from("CustRequestAndWorkEffort").where("workEffortId", revisionMap.workEffortId).queryList() if (custAndWorkEfffList) { - custAndWorkEfffMap = custAndWorkEfffList[0]; - custAndCustItemList = from("CustRequestAndCustRequestItem").where("custRequestId", custAndWorkEfffMap.custRequestId).queryList(); + custAndWorkEfffMap = custAndWorkEfffList[0] + custAndCustItemList = from("CustRequestAndCustRequestItem").where("custRequestId", custAndWorkEfffMap.custRequestId).queryList() if (custAndCustItemList) { - custAndCustItemMap = custAndCustItemList[0]; - inputMap.productId = custAndCustItemMap.productId; - inputMap.custRequestId = custAndCustItemMap.custRequestId; + custAndCustItemMap = custAndCustItemList[0] + inputMap.productId = custAndCustItemMap.productId + inputMap.custRequestId = custAndCustItemMap.custRequestId } } - listIt.add(inputMap); + listIt.add(inputMap) } - context.listIt = listIt; + context.listIt = listIt } } diff --git a/scrum/groovyScripts/ListScrumPreferenceSecurityGroup.groovy b/scrum/groovyScripts/ListScrumPreferenceSecurityGroup.groovy index 4ee0050f5..b82a676b5 100644 --- a/scrum/groovyScripts/ListScrumPreferenceSecurityGroup.groovy +++ b/scrum/groovyScripts/ListScrumPreferenceSecurityGroup.groovy @@ -17,70 +17,70 @@ * under the License. */ -import org.apache.ofbiz.entity.condition.*; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.util.EntityUtil; -import org.apache.ofbiz.entity.condition.EntityCondition; -import org.apache.ofbiz.entity.condition.EntityOperator; +import org.apache.ofbiz.entity.condition.* +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.util.EntityUtil +import org.apache.ofbiz.entity.condition.EntityCondition +import org.apache.ofbiz.entity.condition.EntityOperator -partyId = parameters.partyId; +partyId = parameters.partyId -andCond = []; -orCond = []; -combinedCondList = []; +andCond = [] +orCond = [] +combinedCondList = [] -andCond.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId)); -andCond.add(EntityCondition.makeCondition("partyStatusId", EntityOperator.EQUALS, "PARTY_ENABLED")); +andCond.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId)) +andCond.add(EntityCondition.makeCondition("partyStatusId", EntityOperator.EQUALS, "PARTY_ENABLED")) -orCond.add(EntityCondition.makeCondition("groupId", EntityOperator.EQUALS, "SCRUM_PRODUCT_OWNER")); -orCond.add(EntityCondition.makeCondition("groupId", EntityOperator.EQUALS, "SCRUM_MASTER")); -orCond.add(EntityCondition.makeCondition("groupId", EntityOperator.EQUALS, "SCRUM_TEAM")); -orCond.add(EntityCondition.makeCondition("enabled", EntityOperator.EQUALS, "Y")); -orCond.add(EntityCondition.makeCondition("enabled", EntityOperator.EQUALS, null)); +orCond.add(EntityCondition.makeCondition("groupId", EntityOperator.EQUALS, "SCRUM_PRODUCT_OWNER")) +orCond.add(EntityCondition.makeCondition("groupId", EntityOperator.EQUALS, "SCRUM_MASTER")) +orCond.add(EntityCondition.makeCondition("groupId", EntityOperator.EQUALS, "SCRUM_TEAM")) +orCond.add(EntityCondition.makeCondition("enabled", EntityOperator.EQUALS, "Y")) +orCond.add(EntityCondition.makeCondition("enabled", EntityOperator.EQUALS, null)) -orCondList = EntityCondition.makeCondition(orCond, EntityOperator.OR); -andCondList = EntityCondition.makeCondition(andCond, EntityOperator.AND); +orCondList = EntityCondition.makeCondition(orCond, EntityOperator.OR) +andCondList = EntityCondition.makeCondition(andCond, EntityOperator.AND) -combinedCondList.add(orCondList); -combinedCondList.add(andCondList); +combinedCondList.add(orCondList) +combinedCondList.add(andCondList) -combinedConds = EntityCondition.makeCondition(combinedCondList, EntityOperator.AND); +combinedConds = EntityCondition.makeCondition(combinedCondList, EntityOperator.AND) -scrumUserLoginSecurityGroupList = from("ScrumMemberUserLoginAndSecurityGroup").where(combinedConds).queryList(); -userPreferenceList = []; -userPreferenceOutList = []; +scrumUserLoginSecurityGroupList = from("ScrumMemberUserLoginAndSecurityGroup").where(combinedConds).queryList() +userPreferenceList = [] +userPreferenceOutList = [] if (scrumUserLoginSecurityGroupList) { scrumUserLoginSecurityGroupList.each { scrumUserLoginSecurityGroupMap -> if (scrumUserLoginSecurityGroupMap.groupId == "SCRUM_PRODUCT_OWNER") { - ownerCond = []; - ownerCond.add(EntityCondition.makeCondition("enumTypeId", EntityOperator.EQUALS, "SCRUM_PREFERENCE")); - ownerCond.add(EntityCondition.makeCondition("enumId", EntityOperator.NOT_EQUAL, "MASTER_NOTIFY")); - ownerConds = EntityCondition.makeCondition(ownerCond, EntityOperator.AND); - userPreferenceList = from("Enumeration").where(ownerConds).queryList(); + ownerCond = [] + ownerCond.add(EntityCondition.makeCondition("enumTypeId", EntityOperator.EQUALS, "SCRUM_PREFERENCE")) + ownerCond.add(EntityCondition.makeCondition("enumId", EntityOperator.NOT_EQUAL, "MASTER_NOTIFY")) + ownerConds = EntityCondition.makeCondition(ownerCond, EntityOperator.AND) + userPreferenceList = from("Enumeration").where(ownerConds).queryList() } else if (scrumUserLoginSecurityGroupMap.groupId == "SCRUM_MASTER") { - masterCond = []; - masterCond.add(EntityCondition.makeCondition("enumTypeId", EntityOperator.EQUALS, "SCRUM_PREFERENCE")); - masterCond.add(EntityCondition.makeCondition("enumId", EntityOperator.EQUALS, "MASTER_NOTIFY")); - masterConds = EntityCondition.makeCondition(masterCond, EntityOperator.AND); - userPreferenceList = from("Enumeration").where(masterConds).queryList(); + masterCond = [] + masterCond.add(EntityCondition.makeCondition("enumTypeId", EntityOperator.EQUALS, "SCRUM_PREFERENCE")) + masterCond.add(EntityCondition.makeCondition("enumId", EntityOperator.EQUALS, "MASTER_NOTIFY")) + masterConds = EntityCondition.makeCondition(masterCond, EntityOperator.AND) + userPreferenceList = from("Enumeration").where(masterConds).queryList() } /*else if (scrumUserLoginSecurityGroupMap.groupId == "SCRUM_TEAM") { - teamCond = []; - teamCond.add(EntityCondition.makeCondition("enumTypeId", EntityOperator.EQUALS, "SCRUM_PREFERENCE")); - teamCond.add(EntityCondition.makeCondition("enumId", EntityOperator.EQUALS, "INVITE_NOTIFI")); - teamConds = EntityCondition.makeCondition(teamCond, EntityOperator.AND); - userPreferenceList = delegator.findList("Enumeration" , teamConds, null, null, null, false); + teamCond = [] + teamCond.add(EntityCondition.makeCondition("enumTypeId", EntityOperator.EQUALS, "SCRUM_PREFERENCE")) + teamCond.add(EntityCondition.makeCondition("enumId", EntityOperator.EQUALS, "INVITE_NOTIFI")) + teamConds = EntityCondition.makeCondition(teamCond, EntityOperator.AND) + userPreferenceList = delegator.findList("Enumeration" , teamConds, null, null, null, false) }*/ if (userPreferenceList) { userPreferenceList.each { userPreferenceMap -> - userPreferenceOutList.add(userPreferenceMap); + userPreferenceOutList.add(userPreferenceMap) } } } - context.userPreferenceList = userPreferenceOutList; + context.userPreferenceList = userPreferenceOutList } else { if (security.hasEntityPermission("SCRUM", "_ADMIN", session)) { - userPreferenceList = from("Enumeration").where("enumTypeId", "SCRUM_PREFERENCE").queryList(); - context.userPreferenceList = userPreferenceList; + userPreferenceList = from("Enumeration").where("enumTypeId", "SCRUM_PREFERENCE").queryList() + context.userPreferenceList = userPreferenceList } } diff --git a/scrum/groovyScripts/ListScrumResource.groovy b/scrum/groovyScripts/ListScrumResource.groovy index 64c71757b..68bdf50ec 100644 --- a/scrum/groovyScripts/ListScrumResource.groovy +++ b/scrum/groovyScripts/ListScrumResource.groovy @@ -17,37 +17,37 @@ * under the License. */ -import java.util.*; -import java.lang.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.entity.condition.*; -import org.apache.ofbiz.entity.util.*; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.condition.EntityFunction; +import java.util.* +import java.lang.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.entity.condition.* +import org.apache.ofbiz.entity.util.* +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.condition.EntityFunction -def module = "ListScrumResource.groovy"; +def module = "ListScrumResource.groovy" -performFindInMap = [:]; -performFindInMap.entityName = "ScrumMemberUserLoginAndSecurityGroup"; -inputFields = [:]; -outputList = []; +performFindInMap = [:] +performFindInMap.entityName = "ScrumMemberUserLoginAndSecurityGroup" +inputFields = [:] +outputList = [] -inputFields.putAll(parameters); -performFindInMap.noConditionFind = "Y"; -performFindInMap.inputFields = inputFields; -performFindInMap.orderBy = parameters.sortField; +inputFields.putAll(parameters) +performFindInMap.noConditionFind = "Y" +performFindInMap.inputFields = inputFields +performFindInMap.orderBy = parameters.sortField if (parameters.sortField) { - performFindInMap.orderBy = "lastName"; + performFindInMap.orderBy = "lastName" } -performFindResults = runService('performFind', performFindInMap); -resultList = performFindResults.listIt.getCompleteList(); -performFindResults.listIt.close(); +performFindResults = runService('performFind', performFindInMap) +resultList = performFindResults.listIt.getCompleteList() +performFindResults.listIt.close() resultList.each() { result -> if (!"N".equals(result.enabled)) { - outputList.add(result); + outputList.add(result) } } if (outputList) { - context.listIt = outputList; + context.listIt = outputList } \ No newline at end of file diff --git a/scrum/groovyScripts/ListScrumRolesPersonAndCompany.groovy b/scrum/groovyScripts/ListScrumRolesPersonAndCompany.groovy index 95afcca16..b3ccd53c0 100644 --- a/scrum/groovyScripts/ListScrumRolesPersonAndCompany.groovy +++ b/scrum/groovyScripts/ListScrumRolesPersonAndCompany.groovy @@ -17,51 +17,51 @@ * under the License. */ -import org.apache.ofbiz.entity.condition.*; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.util.EntityUtil; +import org.apache.ofbiz.entity.condition.* +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.util.EntityUtil productId = parameters.productId -personAndCompanyList = []; +personAndCompanyList = [] if (productId) { - productRoleList = from("ProductRole").where("productId" : productId, "roleTypeId" : "PRODUCT_OWNER_COMP").queryList(); + productRoleList = from("ProductRole").where("productId" : productId, "roleTypeId" : "PRODUCT_OWNER_COMP").queryList() if (productRoleList) { personAndComCond = EntityCondition.makeCondition([ EntityCondition.makeCondition ("roleTypeId", EntityOperator.EQUALS, "PRODUCT_OWNER"), EntityCondition.makeCondition ("partyIdFrom", EntityOperator.EQUALS, productRoleList[0].partyId), EntityCondition.makeCondition ("partyStatusId", EntityOperator.NOT_EQUAL, "PARTY_DISABLED"), EntityCondition.makeCondition ("thruDate", EntityOperator.EQUALS, null) - ], EntityJoinOperator.AND); - personAndCompanyList = from("ScrumRolesPersonAndCompany").where(personAndComCond).orderBy("groupName").queryList(); + ], EntityJoinOperator.AND) + personAndCompanyList = from("ScrumRolesPersonAndCompany").where(personAndComCond).orderBy("groupName").queryList() } } if (personAndCompanyList) { - context.companyCurrentList = personAndCompanyList; - context.companyCurrent = personAndCompanyList[0].partyId; + context.companyCurrentList = personAndCompanyList + context.companyCurrent = personAndCompanyList[0].partyId } else { - context.companyCurrent = null; + context.companyCurrent = null } // Get owner with security group -scrumRolesPersonAndCompanyList = []; +scrumRolesPersonAndCompanyList = [] personAndComConds = EntityCondition.makeCondition([ EntityCondition.makeCondition ("roleTypeId", EntityOperator.EQUALS, "PRODUCT_OWNER"), EntityCondition.makeCondition ("partyStatusId", EntityOperator.NOT_EQUAL, "PARTY_DISABLED"), EntityCondition.makeCondition ("thruDate", EntityOperator.EQUALS, null) - ], EntityJoinOperator.AND); -personAndCompanyList = from("ScrumRolesPersonAndCompany").where(personAndComConds).orderBy("groupName").queryList(); + ], EntityJoinOperator.AND) +personAndCompanyList = from("ScrumRolesPersonAndCompany").where(personAndComConds).orderBy("groupName").queryList() if (personAndCompanyList) { personAndCompanyList.each { personAndCompanyMap -> - partyId = personAndCompanyMap.partyId; + partyId = personAndCompanyMap.partyId securityGroupCond = EntityCondition.makeCondition([ EntityCondition.makeCondition ("partyId", EntityOperator.EQUALS, partyId), EntityCondition.makeCondition ("partyStatusId", EntityOperator.NOT_EQUAL, "PARTY_DISABLED") - ], EntityJoinOperator.AND); - securityGroupList = from("ScrumMemberUserLoginAndSecurityGroup").where(securityGroupCond).queryList(); + ], EntityJoinOperator.AND) + securityGroupList = from("ScrumMemberUserLoginAndSecurityGroup").where(securityGroupCond).queryList() if (securityGroupList) { - scrumRolesPersonAndCompanyList.add(personAndCompanyMap); + scrumRolesPersonAndCompanyList.add(personAndCompanyMap) } } } -context.scrumRolesPersonAndCompanyList = scrumRolesPersonAndCompanyList; +context.scrumRolesPersonAndCompanyList = scrumRolesPersonAndCompanyList diff --git a/scrum/groovyScripts/ListTimeSheets.groovy b/scrum/groovyScripts/ListTimeSheets.groovy index 65ad25015..0f758c666 100644 --- a/scrum/groovyScripts/ListTimeSheets.groovy +++ b/scrum/groovyScripts/ListTimeSheets.groovy @@ -17,58 +17,58 @@ * under the License. */ -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.entity.util.*; -import org.apache.ofbiz.entity.condition.*; -import org.apache.ofbiz.base.util.Debug; -import org.apache.ofbiz.base.util.UtilDateTime; +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.entity.util.* +import org.apache.ofbiz.entity.condition.* +import org.apache.ofbiz.base.util.Debug +import org.apache.ofbiz.base.util.UtilDateTime // get all timesheets of all user, including the planned hours -timesheets = []; -inputFields = [:]; +timesheets = [] +inputFields = [:] if (!parameters.noConditionFind) { parameters.noConditionFind = "N" } -inputFields.putAll(parameters); -performFindResults = runService('performFind', ["entityName": "Timesheet", "inputFields": inputFields, "orderBy": "fromDate DESC"]); +inputFields.putAll(parameters) +performFindResults = runService('performFind', ["entityName": "Timesheet", "inputFields": inputFields, "orderBy": "fromDate DESC"]) if (performFindResults.listSize > 0) { - timesheetsDb = performFindResults.listIt.getCompleteList(); - performFindResults.listIt.close(); + timesheetsDb = performFindResults.listIt.getCompleteList() + performFindResults.listIt.close() timesheetsDb.each { timesheetDb -> - //get hours from EmplLeave; - findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true); - leaveExprsList = []; - leaveExprsList.add(EntityCondition.makeCondition("fromDate", EntityOperator.GREATER_THAN_EQUAL_TO, timesheetDb.fromDate)); - leaveExprsList.add(EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, timesheetDb.thruDate)); - leaveExprsList.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, timesheetDb.partyId)); - emplLeaveList = from("EmplLeave").where(leaveExprsList).cursorScrollInsensitive().distinct().queryIterator(); - leaveHours = 0.00; + //get hours from EmplLeave + findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true) + leaveExprsList = [] + leaveExprsList.add(EntityCondition.makeCondition("fromDate", EntityOperator.GREATER_THAN_EQUAL_TO, timesheetDb.fromDate)) + leaveExprsList.add(EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, timesheetDb.thruDate)) + leaveExprsList.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, timesheetDb.partyId)) + emplLeaveList = from("EmplLeave").where(leaveExprsList).cursorScrollInsensitive().distinct().queryIterator() + leaveHours = 0.00 while ((emplLeaveMap = emplLeaveList.next())) { - emplLeaveEntry = emplLeaveMap; + emplLeaveEntry = emplLeaveMap resultHour = runService('getPartyLeaveHoursForDate', - ["userLogin": parameters.userLogin, "partyId": emplLeaveEntry.partyId, "leaveTypeId": emplLeaveEntry.leaveTypeId, "fromDate": emplLeaveEntry.fromDate]); + ["userLogin": parameters.userLogin, "partyId": emplLeaveEntry.partyId, "leaveTypeId": emplLeaveEntry.leaveTypeId, "fromDate": emplLeaveEntry.fromDate]) if (resultHour) { - leaveActualHours = resultHour.hours.doubleValue(); - leaveHours += leaveActualHours; + leaveActualHours = resultHour.hours.doubleValue() + leaveHours += leaveActualHours } } - //get hours from TimeEntry; - timesheet = [:]; - timesheet.putAll(timesheetDb); - entries = timesheetDb.getRelated("TimeEntry", null, null, false); - hours = 0.00; + //get hours from TimeEntry + timesheet = [:] + timesheet.putAll(timesheetDb) + entries = timesheetDb.getRelated("TimeEntry", null, null, false) + hours = 0.00 entries.each { timeEntry -> if (timeEntry.hours) { - hours += timeEntry.hours.doubleValue(); + hours += timeEntry.hours.doubleValue() } } - timesheet.weekNumber = UtilDateTime.weekNumber(timesheetDb.fromDate); - timesheet.hours = hours + leaveHours; - timesheets.add(timesheet); - emplLeaveList.close(); + timesheet.weekNumber = UtilDateTime.weekNumber(timesheetDb.fromDate) + timesheet.hours = hours + leaveHours + timesheets.add(timesheet) + emplLeaveList.close() } - context.timesheets = timesheets; + context.timesheets = timesheets } diff --git a/scrum/groovyScripts/ListUnplanBacklog.groovy b/scrum/groovyScripts/ListUnplanBacklog.groovy index 30d6b8343..2aa7716c2 100644 --- a/scrum/groovyScripts/ListUnplanBacklog.groovy +++ b/scrum/groovyScripts/ListUnplanBacklog.groovy @@ -17,32 +17,32 @@ * under the License. */ -import org.apache.ofbiz.entity.condition.*; -import org.apache.ofbiz.base.util.*; +import org.apache.ofbiz.entity.condition.* +import org.apache.ofbiz.base.util.* -taskStatusId = null; -paraBacklogStatusId = backlogStatusId; +taskStatusId = null +paraBacklogStatusId = backlogStatusId -orStsExprs = []; +orStsExprs = [] if (backlogStatusId != "Any") { - taskStatusId = "STS_CREATED"; - orStsExprs.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "CRQ_REVIEWED")); + taskStatusId = "STS_CREATED" + orStsExprs.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "CRQ_REVIEWED")) } else { - orStsExprs.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "CRQ_REVIEWED")); - orStsExprs.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "CRQ_COMPLETED")); + orStsExprs.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "CRQ_REVIEWED")) + orStsExprs.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "CRQ_COMPLETED")) } -orCurentExprs = []; +orCurentExprs = [] if (taskStatusId) { - orCurentExprs.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.EQUALS, taskStatusId)); - orCurentExprs.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.EQUALS, null)); + orCurentExprs.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.EQUALS, taskStatusId)) + orCurentExprs.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.EQUALS, null)) } -andExprs = []; - andExprs.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, parameters.productId)); - andExprs.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.EQUALS, "RF_UNPLAN_BACKLOG")); - andExprs.add(EntityCondition.makeCondition(orStsExprs, EntityOperator.OR)); - andExprs.add(EntityCondition.makeCondition(orCurentExprs, EntityOperator.OR)); -unplannedBacklogCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND); -unplannedBacklogList = from("UnPlannedBacklogsAndTasks").where(unplannedBacklogCond).orderBy("-custRequestId","workEffortTypeId","custSequenceNum").queryList(); +andExprs = [] + andExprs.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, parameters.productId)) + andExprs.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.EQUALS, "RF_UNPLAN_BACKLOG")) + andExprs.add(EntityCondition.makeCondition(orStsExprs, EntityOperator.OR)) + andExprs.add(EntityCondition.makeCondition(orCurentExprs, EntityOperator.OR)) +unplannedBacklogCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND) +unplannedBacklogList = from("UnPlannedBacklogsAndTasks").where(unplannedBacklogCond).orderBy("-custRequestId","workEffortTypeId","custSequenceNum").queryList() -context.listIt = unplannedBacklogList; -context.paraBacklogStatusId = paraBacklogStatusId; +context.listIt = unplannedBacklogList +context.paraBacklogStatusId = paraBacklogStatusId diff --git a/scrum/groovyScripts/ProductBilling.groovy b/scrum/groovyScripts/ProductBilling.groovy index 5b2f479f3..0ddcbf55b 100644 --- a/scrum/groovyScripts/ProductBilling.groovy +++ b/scrum/groovyScripts/ProductBilling.groovy @@ -18,76 +18,76 @@ * under the License. */ -import java.sql.Timestamp; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.base.util.UtilDateTime; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.entity.condition.*; -import org.apache.ofbiz.entity.util.*; +import java.sql.Timestamp +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.base.util.UtilDateTime +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.entity.condition.* +import org.apache.ofbiz.entity.util.* -productId = parameters.productId; +productId = parameters.productId entryExprs = EntityCondition.makeCondition([ EntityCondition.makeCondition("productId", EntityOperator.EQUALS, productId), EntityCondition.makeCondition("invoiceId", EntityOperator.NOT_EQUAL, null), - ], EntityOperator.AND); + ], EntityOperator.AND) // check if latest invoice generated is still in process so allow re-generation to correct errors -entryIterator = from("ProjectSprintBacklogTaskAndTimeEntryTimeSheet").where(entryExprs).orderBy("-fromDate").queryIterator(); +entryIterator = from("ProjectSprintBacklogTaskAndTimeEntryTimeSheet").where(entryExprs).orderBy("-fromDate").queryIterator() while (entryItem = entryIterator.next()) { - invoice = entryItem.getRelatedOne("Invoice", false); + invoice = entryItem.getRelatedOne("Invoice", false) if (invoice.getString("statusId").equals("INVOICE_IN_PROCESS")) { - context.partyIdFrom = invoice.partyIdFrom; - context.partyId = invoice.partyId; - context.invoiceId = invoice.invoiceId; - context.invoiceDate = invoice.invoiceDate; - break; + context.partyIdFrom = invoice.partyIdFrom + context.partyId = invoice.partyId + context.invoiceId = invoice.invoiceId + context.invoiceDate = invoice.invoiceDate + break } } -entryIterator.close(); +entryIterator.close() //start of this month -context.thruDate = UtilDateTime.getMonthStart(UtilDateTime.nowTimestamp()); +context.thruDate = UtilDateTime.getMonthStart(UtilDateTime.nowTimestamp()) // build find task conditions -def taskConds = UtilMisc.toList(EntityCondition.makeCondition("productId", parameters.productId)); -taskConds.add(EntityCondition.makeCondition("invoiceId", null)); -taskConds.add(EntityCondition.makeCondition("timesheetStatusId", "TIMESHEET_COMPLETED")); +def taskConds = UtilMisc.toList(EntityCondition.makeCondition("productId", parameters.productId)) +taskConds.add(EntityCondition.makeCondition("invoiceId", null)) +taskConds.add(EntityCondition.makeCondition("timesheetStatusId", "TIMESHEET_COMPLETED")) if (parameters.fromDate) { - fromDate = parameters.fromDate; + fromDate = parameters.fromDate if (fromDate.length() < 14) { - fromDate = fromDate + " " + "00:00:00.000"; + fromDate = fromDate + " " + "00:00:00.000" } - taskConds.add(EntityCondition.makeCondition("fromDate", EntityOperator.GREATER_THAN_EQUAL_TO, Timestamp.valueOf(fromDate))); + taskConds.add(EntityCondition.makeCondition("fromDate", EntityOperator.GREATER_THAN_EQUAL_TO, Timestamp.valueOf(fromDate))) } if (parameters.thruDate) { - thruDate = parameters.thruDate; + thruDate = parameters.thruDate if (thruDate.length() < 14) { - thruDate = thruDate + " " + "00:00:00.000"; + thruDate = thruDate + " " + "00:00:00.000" } - taskConds.add(EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN, Timestamp.valueOf(thruDate))); + taskConds.add(EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN, Timestamp.valueOf(thruDate))) } else { - taskConds.add(EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN, context.thruDate)); + taskConds.add(EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN, context.thruDate)) } // include meeting ? if ("N".equals(includeMeeting)) { - taskConds.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.NOT_EQUAL, "RF_SCRUM_MEETINGS")); + taskConds.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.NOT_EQUAL, "RF_SCRUM_MEETINGS")) } // get sprint task list -def sprintTasks = from("ProjectSprintBacklogTaskAndTimeEntryTimeSheet").where(taskConds).queryList(); +def sprintTasks = from("ProjectSprintBacklogTaskAndTimeEntryTimeSheet").where(taskConds).queryList() // get cancelled backlog task list -def cancelledBacklogTasks = from("CancelledBacklogsTaskAndTimeEntryTimeSheet").where(taskConds).queryList(); +def cancelledBacklogTasks = from("CancelledBacklogsTaskAndTimeEntryTimeSheet").where(taskConds).queryList() // get unplanned task list -def unplannedTasks = from("UnPlannedBacklogsTaskAndTimeEntryTimeSheet").where(taskConds).queryList(); +def unplannedTasks = from("UnPlannedBacklogsTaskAndTimeEntryTimeSheet").where(taskConds).queryList() -def hoursNotYetBilledTasks = []; -hoursNotYetBilledTasks.addAll(sprintTasks); -hoursNotYetBilledTasks.addAll(cancelledBacklogTasks); -hoursNotYetBilledTasks.addAll(unplannedTasks); +def hoursNotYetBilledTasks = [] +hoursNotYetBilledTasks.addAll(sprintTasks) +hoursNotYetBilledTasks.addAll(cancelledBacklogTasks) +hoursNotYetBilledTasks.addAll(unplannedTasks) context.hoursNotYetBilledTasks = UtilMisc.sortMaps(hoursNotYetBilledTasks, ["productId","custRequestId","taskId","fromDate"]) // get time entry date timeEntryList = UtilMisc.sortMaps(hoursNotYetBilledTasks, ["fromDate"]) if (!parameters.fromDate && timeEntryList) { - context.resultDate = timeEntryList[0].fromDate; + context.resultDate = timeEntryList[0].fromDate } diff --git a/scrum/groovyScripts/ProductEmail.groovy b/scrum/groovyScripts/ProductEmail.groovy index 271f2756f..e329ac8e3 100644 --- a/scrum/groovyScripts/ProductEmail.groovy +++ b/scrum/groovyScripts/ProductEmail.groovy @@ -17,86 +17,86 @@ * under the License. */ -import java.util.*; -import java.lang.*; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.base.util.Debug; -import org.apache.ofbiz.base.util.UtilValidate; -import org.apache.ofbiz.entity.util.*; +import java.util.* +import java.lang.* +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.base.util.Debug +import org.apache.ofbiz.base.util.UtilValidate +import org.apache.ofbiz.entity.util.* -productId = parameters.productId; -loginPartyId = userLogin.partyId; -communicationEventId = parameters.communicationEventId; -now = UtilDateTime.nowTimestamp(); +productId = parameters.productId +loginPartyId = userLogin.partyId +communicationEventId = parameters.communicationEventId +now = UtilDateTime.nowTimestamp() try{ if (UtilValidate.isNotEmpty(loginPartyId)) { if (UtilValidate.isNotEmpty(productId)) { - context.product = from("Product").where("productId", productId).queryOne(); + context.product = from("Product").where("productId", productId).queryOne() } - communicationEvent = from("CommunicationEvent").where("communicationEventId", communicationEventId).queryOne(); - communicationEvent.communicationEventTypeId = "EMAIL_COMMUNICATION"; - communicationEvent.contactMechTypeId = "EMAIL_ADDRESS"; - communicationEvent.datetimeStarted = now; - checkOwner = from("ProductRole").where("productId", productId,"partyId", loginPartyId,"roleTypeId", "PRODUCT_OWNER").queryList(); + communicationEvent = from("CommunicationEvent").where("communicationEventId", communicationEventId).queryOne() + communicationEvent.communicationEventTypeId = "EMAIL_COMMUNICATION" + communicationEvent.contactMechTypeId = "EMAIL_ADDRESS" + communicationEvent.datetimeStarted = now + checkOwner = from("ProductRole").where("productId", productId,"partyId", loginPartyId,"roleTypeId", "PRODUCT_OWNER").queryList() if (checkOwner) { /* for product owner to our company */ // for owner - productRole = from("ProductRole").where("productId", productId,"roleTypeId", "PRODUCT_OWNER").queryList(); + productRole = from("ProductRole").where("productId", productId,"roleTypeId", "PRODUCT_OWNER").queryList() context.productOwnerId = productRole[0].partyId - parentCom = from("CommunicationEvent").where("communicationEventId", communicationEventId).queryOne(); + parentCom = from("CommunicationEvent").where("communicationEventId", communicationEventId).queryOne() if (parentCom) { - context.partyIdFrom = productRole[0].partyId; + context.partyIdFrom = productRole[0].partyId } else { - context.partyIdFrom = parentCom.partyIdTo; + context.partyIdFrom = parentCom.partyIdTo } - resultsIdFrom = runService('getPartyEmail', ["partyId" : productRole[0].partyId, "userLogin" : userLogin]); + resultsIdFrom = runService('getPartyEmail', ["partyId" : productRole[0].partyId, "userLogin" : userLogin]) if (resultsIdFrom.contactMechId != null) { - context.contactMechIdFrom = resultsIdFrom.contactMechId; - communicationEvent.contactMechIdFrom = resultsIdFrom.contactMechId; + context.contactMechIdFrom = resultsIdFrom.contactMechId + communicationEvent.contactMechIdFrom = resultsIdFrom.contactMechId } // for team - defaultPartyIdTo = organizationPartyId; - resultsIdTo = runService('getPartyEmail', ["partyId" : defaultPartyIdTo,"contactMechPurposeTypeId" :"SUPPORT_EMAIL", "userLogin" : userLogin]); + defaultPartyIdTo = organizationPartyId + resultsIdTo = runService('getPartyEmail', ["partyId" : defaultPartyIdTo,"contactMechPurposeTypeId" :"SUPPORT_EMAIL", "userLogin" : userLogin]) if (resultsIdTo.contactMechId != null) { - context.contactMechIdTo = resultsIdTo.contactMechId; - communicationEvent.contactMechIdTo = resultsIdTo.contactMechId; + context.contactMechIdTo = resultsIdTo.contactMechId + communicationEvent.contactMechIdTo = resultsIdTo.contactMechId } - context.partyIdTo = defaultPartyIdTo; - communicationEvent.store(); - context.communicationEvent = communicationEvent; + context.partyIdTo = defaultPartyIdTo + communicationEvent.store() + context.communicationEvent = communicationEvent } else { /* from company to owner */ // for team - defaultPartyIdFrom = organizationPartyId; - context.partyIdFrom = defaultPartyIdFrom; - resultsIdFrom = runService('getPartyEmail', ["partyId" : defaultPartyIdFrom,"contactMechPurposeTypeId" :"SUPPORT_EMAIL", "userLogin" : userLogin]); + defaultPartyIdFrom = organizationPartyId + context.partyIdFrom = defaultPartyIdFrom + resultsIdFrom = runService('getPartyEmail', ["partyId" : defaultPartyIdFrom,"contactMechPurposeTypeId" :"SUPPORT_EMAIL", "userLogin" : userLogin]) if (resultsIdFrom.contactMechId != null) { - context.contactMechIdFrom = resultsIdFrom.contactMechId; - communicationEvent.contactMechIdFrom = resultsIdFrom.contactMechId; + context.contactMechIdFrom = resultsIdFrom.contactMechId + communicationEvent.contactMechIdFrom = resultsIdFrom.contactMechId } // for owner - productRole = from("ProductRole").where("productId", productId,"roleTypeId", "PRODUCT_OWNER").queryList(); - context.productOwnerId = productRole[0].partyId; - parentCom = from("CommunicationEvent").where("communicationEventId", communicationEventId).queryOne(); + productRole = from("ProductRole").where("productId", productId,"roleTypeId", "PRODUCT_OWNER").queryList() + context.productOwnerId = productRole[0].partyId + parentCom = from("CommunicationEvent").where("communicationEventId", communicationEventId).queryOne() if(parentCom){ - context.partyIdTo = productRole[0].partyId; + context.partyIdTo = productRole[0].partyId } else { - context.partyIdTo = parentCom.partyIdFrom; + context.partyIdTo = parentCom.partyIdFrom } - resultsIdTo = runService('getPartyEmail', ["partyId" : productRole[0].partyId, "userLogin" : userLogin]); + resultsIdTo = runService('getPartyEmail', ["partyId" : productRole[0].partyId, "userLogin" : userLogin]) if (resultsIdTo.contactMechId != null) { - context.contactMechIdTo = resultsIdTo.contactMechId; - communicationEvent.contactMechIdTo = resultsIdTo.contactMechId; + context.contactMechIdTo = resultsIdTo.contactMechId + communicationEvent.contactMechIdTo = resultsIdTo.contactMechId } - communicationEvent.store(); - context.communicationEvent = communicationEvent; + communicationEvent.store() + context.communicationEvent = communicationEvent } } } catch (exeption) { - Debug.logInfo("catch exeption ================" + exeption,""); + Debug.logInfo("catch exeption ================" + exeption,"") } catch (GenericEntityException e) { - Debug.logInfo("catch GenericEntityException ================" + e.getMessage(),""); + Debug.logInfo("catch GenericEntityException ================" + e.getMessage(),"") } diff --git a/scrum/groovyScripts/QuickAddBacklog.groovy b/scrum/groovyScripts/QuickAddBacklog.groovy index 0e1360279..76c2156a3 100644 --- a/scrum/groovyScripts/QuickAddBacklog.groovy +++ b/scrum/groovyScripts/QuickAddBacklog.groovy @@ -17,77 +17,77 @@ * under the License. */ -import org.apache.ofbiz.base.util.Debug; +import org.apache.ofbiz.base.util.Debug try{ // for sprint dropdown - workEffortList = []; - sprintList = from("WorkEffort").where("workEffortTypeId", "SCRUM_SPRINT","currentStatusId", "SPRINT_ACTIVE").queryList(); + workEffortList = [] + sprintList = from("WorkEffort").where("workEffortTypeId", "SCRUM_SPRINT","currentStatusId", "SPRINT_ACTIVE").queryList() if (sprintList) { sprintList.each{ sprintMap -> - workEffortMap = [:]; - workEffortParentId = sprintMap.workEffortParentId; + workEffortMap = [:] + workEffortParentId = sprintMap.workEffortParentId if (workEffortParentId) { - projectList = from("WorkEffortAndProduct").where("workEffortId", workEffortParentId).queryList(); - projectMap = projectList[0]; + projectList = from("WorkEffortAndProduct").where("workEffortId", workEffortParentId).queryList() + projectMap = projectList[0] // make sure that project dose not closed if (projectMap.currentStatusId != "SPJ_CLOSED") { - productMap = from("Product").where("productId", projectMap.productId).queryOne(); - workEffortMap.productId = productMap.productId; - workEffortMap.internalName = returnNameAsString(productMap.internalName,30); - workEffortMap.projectId = projectMap.workEffortId; - workEffortMap.projectName = returnNameAsString(projectMap.workEffortName,30); - workEffortMap.sprintId = sprintMap.workEffortId; - workEffortMap.sprintName = returnNameAsString(sprintMap.workEffortName,30); - workEffortMap.keyId = productMap.productId+","+projectMap.workEffortId+","+sprintMap.workEffortId; - workEffortList.add(workEffortMap); + productMap = from("Product").where("productId", projectMap.productId).queryOne() + workEffortMap.productId = productMap.productId + workEffortMap.internalName = returnNameAsString(productMap.internalName,30) + workEffortMap.projectId = projectMap.workEffortId + workEffortMap.projectName = returnNameAsString(projectMap.workEffortName,30) + workEffortMap.sprintId = sprintMap.workEffortId + workEffortMap.sprintName = returnNameAsString(sprintMap.workEffortName,30) + workEffortMap.keyId = productMap.productId+","+projectMap.workEffortId+","+sprintMap.workEffortId + workEffortList.add(workEffortMap) } } } - context.workEffortList = workEffortList; + context.workEffortList = workEffortList } // for backlog category - productId = null; + productId = null if (parameters.productId) { - productId = parameters.productId; + productId = parameters.productId } else { if (parameters.keyId) { - indexList = parameters.keyId.tokenize(","); - productId = indexList[0].toString().trim(); + indexList = parameters.keyId.tokenize(",") + productId = indexList[0].toString().trim() } } - categoryList = []; + categoryList = [] if (productId) { - sprintList = from("CustRequestAndCustRequestItem").where("custRequestTypeId", "RF_PARENT_BACKLOG","productId", productId).queryList(); + sprintList = from("CustRequestAndCustRequestItem").where("custRequestTypeId", "RF_PARENT_BACKLOG","productId", productId).queryList() } else { - sprintList = from("CustRequestAndCustRequestItem").where("custRequestTypeId", "RF_PARENT_BACKLOG").queryList(); + sprintList = from("CustRequestAndCustRequestItem").where("custRequestTypeId", "RF_PARENT_BACKLOG").queryList() } if (sprintList) { sprintList.each{ categoryMap -> - inputMap = [:]; - productIdIn = categoryMap.productId; + inputMap = [:] + productIdIn = categoryMap.productId if (productIdIn) { - productMap = from("Product").where("productId", productIdIn).queryOne(); - inputMap.productId = productMap.productId; - inputMap.internalName = productMap.internalName; - inputMap.custRequestId = categoryMap.custRequestId; - inputMap.custRequestName = categoryMap.custRequestName; - categoryList.add(inputMap); + productMap = from("Product").where("productId", productIdIn).queryOne() + inputMap.productId = productMap.productId + inputMap.internalName = productMap.internalName + inputMap.custRequestId = categoryMap.custRequestId + inputMap.custRequestName = categoryMap.custRequestName + categoryList.add(inputMap) } } - context.categoryList = categoryList; + context.categoryList = categoryList } }catch(e){ - Debug.logInfo("catch e ================" + e,""); + Debug.logInfo("catch e ================" + e,"") } //subString function def String returnNameAsString(input,length) { if (input.length() > length ) { - ansValue = input.toString().substring(0,Math.min(input.toString().length(),length)); - return ansValue; + ansValue = input.toString().substring(0,Math.min(input.toString().length(),length)) + return ansValue } else { - return input; + return input } } diff --git a/scrum/groovyScripts/SprintBacklogListItems.groovy b/scrum/groovyScripts/SprintBacklogListItems.groovy index 64ce827f7..5d8bf1bdb 100644 --- a/scrum/groovyScripts/SprintBacklogListItems.groovy +++ b/scrum/groovyScripts/SprintBacklogListItems.groovy @@ -17,105 +17,105 @@ * under the License. */ -import org.apache.ofbiz.entity.condition.*; -import org.apache.ofbiz.base.util.*; +import org.apache.ofbiz.entity.condition.* +import org.apache.ofbiz.base.util.* -taskStatusId = null; -reopenedStatusId = null; -backlogStatusId = parameters.backlogStatusId; -paraBacklogStatusId = backlogStatusId; -currentStatus = sprintStatus.currentStatusId; -projectSprintList = []; +taskStatusId = null +reopenedStatusId = null +backlogStatusId = parameters.backlogStatusId +paraBacklogStatusId = backlogStatusId +currentStatus = sprintStatus.currentStatusId +projectSprintList = [] if ("SPRINT_CLOSED".equals(currentStatus)) { - backlogStatusId = null; + backlogStatusId = null } else { if (backlogStatusId == "Any") { - backlogStatusId = null; + backlogStatusId = null } else { - backlogStatusId = "CRQ_REVIEWED"; - reopenedStatusId = "CRQ_REOPENED"; - taskStatusId = "STS_CREATED"; + backlogStatusId = "CRQ_REVIEWED" + reopenedStatusId = "CRQ_REOPENED" + taskStatusId = "STS_CREATED" } } -orCurentExprs = []; +orCurentExprs = [] if (taskStatusId) { - orCurentExprs.add(EntityCondition.makeCondition("taskCurrentStatusId", EntityOperator.EQUALS, taskStatusId)); - orCurentExprs.add(EntityCondition.makeCondition("taskCurrentStatusId", EntityOperator.EQUALS, "SPRINT_ACTIVE")); + orCurentExprs.add(EntityCondition.makeCondition("taskCurrentStatusId", EntityOperator.EQUALS, taskStatusId)) + orCurentExprs.add(EntityCondition.makeCondition("taskCurrentStatusId", EntityOperator.EQUALS, "SPRINT_ACTIVE")) } -orBacklogExprs = []; +orBacklogExprs = [] if (backlogStatusId) { - orBacklogExprs.add(EntityCondition.makeCondition("backlogStatusId", EntityOperator.EQUALS, backlogStatusId)); + orBacklogExprs.add(EntityCondition.makeCondition("backlogStatusId", EntityOperator.EQUALS, backlogStatusId)) } if (reopenedStatusId) { - orBacklogExprs.add(EntityCondition.makeCondition("backlogStatusId", EntityOperator.EQUALS, reopenedStatusId)); + orBacklogExprs.add(EntityCondition.makeCondition("backlogStatusId", EntityOperator.EQUALS, reopenedStatusId)) } -andExprs = []; +andExprs = [] if (parameters.projectId) { - andExprs.add(EntityCondition.makeCondition("projectId", EntityOperator.EQUALS, parameters.projectId)); + andExprs.add(EntityCondition.makeCondition("projectId", EntityOperator.EQUALS, parameters.projectId)) } else { - andExprs.add(EntityCondition.makeCondition("projectId", EntityOperator.EQUALS, sprintStatus.workEffortParentId)); + andExprs.add(EntityCondition.makeCondition("projectId", EntityOperator.EQUALS, sprintStatus.workEffortParentId)) } if (orBacklogExprs) { - andExprs.add(EntityCondition.makeCondition(orBacklogExprs, EntityOperator.OR)); + andExprs.add(EntityCondition.makeCondition(orBacklogExprs, EntityOperator.OR)) } if (orCurentExprs) { - andExprs.add(EntityCondition.makeCondition(orCurentExprs, EntityOperator.OR)); + andExprs.add(EntityCondition.makeCondition(orCurentExprs, EntityOperator.OR)) } - andExprs.add(EntityCondition.makeCondition("sprintId", EntityOperator.EQUALS, parameters.sprintId)); - andExprs.add(EntityCondition.makeCondition("sprintTypeId", EntityOperator.EQUALS, "SCRUM_SPRINT")); + andExprs.add(EntityCondition.makeCondition("sprintId", EntityOperator.EQUALS, parameters.sprintId)) + andExprs.add(EntityCondition.makeCondition("sprintTypeId", EntityOperator.EQUALS, "SCRUM_SPRINT")) -projectSprintCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND); -projectSprintList = from("ProjectSprintBacklogAndTask").where(andExprs).orderBy("custSequenceNum","custRequestId","taskTypeId").queryList(); +projectSprintCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND) +projectSprintList = from("ProjectSprintBacklogAndTask").where(andExprs).orderBy("custSequenceNum","custRequestId","taskTypeId").queryList() -context.listIt = projectSprintList; -context.paraBacklogStatusId = paraBacklogStatusId; +context.listIt = projectSprintList +context.paraBacklogStatusId = paraBacklogStatusId //get backlog and task information if (parameters.sprintId) { //get total backlog size - completedBacklog = 0; - reviewedBacklog = 0; - totalbacklog = 0; - allTask = []; - sprintList = from("CustRequestWorkEffort").where("workEffortId", parameters.sprintId).queryList(); + completedBacklog = 0 + reviewedBacklog = 0 + totalbacklog = 0 + allTask = [] + sprintList = from("CustRequestWorkEffort").where("workEffortId", parameters.sprintId).queryList() sprintList.each { sprintMap -> - custMap = sprintMap.getRelatedOne("CustRequest", false); + custMap = sprintMap.getRelatedOne("CustRequest", false) //if ("RF_PROD_BACKLOG".equals(custMap.custRequestTypeId)) { - totalbacklog += 1; + totalbacklog += 1 if ("CRQ_REVIEWED".equals(custMap.statusId)){ - reviewedBacklog += 1; + reviewedBacklog += 1 } else { - completedBacklog += 1; + completedBacklog += 1 } //get task - workEffortList = custMap.getRelated("CustRequestWorkEffort", null, null, false); + workEffortList = custMap.getRelated("CustRequestWorkEffort", null, null, false) if (workEffortList) { - allTask.addAll(workEffortList); + allTask.addAll(workEffortList) } //} } //get total task size - completedTask = 0; - createdTask = 0; - totalTask = 0; + completedTask = 0 + createdTask = 0 + totalTask = 0 if (allTask) { allTask.each { taskMap -> - workEffMap = taskMap.getRelatedOne("WorkEffort", false); + workEffMap = taskMap.getRelatedOne("WorkEffort", false) if (!"SCRUM_SPRINT".equals(workEffMap.workEffortTypeId)) { - totalTask += 1; + totalTask += 1 if ("STS_CREATED".equals(workEffMap.currentStatusId)){ - createdTask += 1; + createdTask += 1 } else { - completedTask += 1; + completedTask += 1 } } } } - context.completedBacklog = completedBacklog; - context.reviewedBacklog = reviewedBacklog; - context.totalbacklog = totalbacklog; - context.completedTask = completedTask; - context.createdTask = createdTask; - context.totalTask = totalTask; + context.completedBacklog = completedBacklog + context.reviewedBacklog = reviewedBacklog + context.totalbacklog = totalbacklog + context.completedTask = completedTask + context.createdTask = createdTask + context.totalTask = totalTask } diff --git a/scrum/groovyScripts/SprintBacklogOptions.groovy b/scrum/groovyScripts/SprintBacklogOptions.groovy index 8935b8191..00084b05c 100644 --- a/scrum/groovyScripts/SprintBacklogOptions.groovy +++ b/scrum/groovyScripts/SprintBacklogOptions.groovy @@ -17,21 +17,21 @@ * under the License. */ -import org.apache.ofbiz.base.util.Debug; +import org.apache.ofbiz.base.util.Debug -custRequestWorkEffortList = []; -sprintStatusId = "SPRINT_CLOSED"; -sprintId = null; -custRequestWorkEffortList = custRequestMap.getRelated("CustRequestWorkEffort", null, null, false); +custRequestWorkEffortList = [] +sprintStatusId = "SPRINT_CLOSED" +sprintId = null +custRequestWorkEffortList = custRequestMap.getRelated("CustRequestWorkEffort", null, null, false) if (custRequestWorkEffortList) { custRequestWorkEffortList.each { custWorkEffortMap -> - workEffortMap = custWorkEffortMap.getRelatedOne("WorkEffort", false); + workEffortMap = custWorkEffortMap.getRelatedOne("WorkEffort", false) if ("SCRUM_SPRINT".equals(workEffortMap.workEffortTypeId) && "SPRINT_ACTIVE".equals(workEffortMap.currentStatusId)) { - sprintId = workEffortMap.workEffortId; - sprintStatusId = "SPRINT_ACTIVE"; + sprintId = workEffortMap.workEffortId + sprintStatusId = "SPRINT_ACTIVE" } } } -context.sprintId = sprintId; -context.sprintStatusId = sprintStatusId; +context.sprintId = sprintId +context.sprintStatusId = sprintStatusId diff --git a/scrum/groovyScripts/TaskList.groovy b/scrum/groovyScripts/TaskList.groovy index f8e791477..514b7fc0e 100644 --- a/scrum/groovyScripts/TaskList.groovy +++ b/scrum/groovyScripts/TaskList.groovy @@ -17,101 +17,101 @@ * under the License. */ -import java.util.*; -import java.lang.*; -import org.apache.tools.ant.taskdefs.Parallel.TaskList; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.base.util.UtilMisc; -import org.apache.ofbiz.base.util.UtilValidate; -import org.apache.ofbiz.base.util.UtilDateTime; -import org.apache.ofbiz.entity.util.*; -import org.apache.ofbiz.entity.condition.*; -import java.sql.Timestamp; +import java.util.* +import java.lang.* +import org.apache.tools.ant.taskdefs.Parallel.TaskList +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.base.util.UtilMisc +import org.apache.ofbiz.base.util.UtilValidate +import org.apache.ofbiz.base.util.UtilDateTime +import org.apache.ofbiz.entity.util.* +import org.apache.ofbiz.entity.condition.* +import java.sql.Timestamp -partyId = userLogin.partyId; -taskUnplanList = []; -taskPlanList = []; -taskPartyList = []; -taskListDropdown = []; +partyId = userLogin.partyId +taskUnplanList = [] +taskPlanList = [] +taskPartyList = [] +taskListDropdown = [] //${projectId} - ${projectName} - ${sprintName} - ${groovy:description.substring(0,Math.min(description.length(),30))}[${custRequestId}] - ${groovy:taskName.substring(0,Math.min(taskName.length(),20))}[${taskId}]"/> -taskUnplanList = from("ProjectSprintBacklogTaskAndParty").where("partyId", partyId,"taskCurrentStatusId", "STS_CREATED","custRequestTypeId","RF_UNPLAN_BACKLOG").orderBy("taskTypeId").queryList(); +taskUnplanList = from("ProjectSprintBacklogTaskAndParty").where("partyId", partyId,"taskCurrentStatusId", "STS_CREATED","custRequestTypeId","RF_UNPLAN_BACKLOG").orderBy("taskTypeId").queryList() taskUnplanList.each { taskUnplanMap -> - unplanMap=[:]; - custRequestId = taskUnplanMap.custRequestId; - productlist = from("CustRequestItem").where("custRequestId", custRequestId).orderBy("productId").queryList(); + unplanMap=[:] + custRequestId = taskUnplanMap.custRequestId + productlist = from("CustRequestItem").where("custRequestId", custRequestId).orderBy("productId").queryList() productlist.each { productMap -> - productId = productMap.productId; - product = from("Product").where("productId", productId).queryOne(); - productName = product.internalName; - unplanMap.taskId = taskUnplanMap.taskId; - unplanMap.taskName = taskUnplanMap.taskName; - unplanMap.projectId = taskUnplanMap.projectId; - unplanMap.projectName = taskUnplanMap.projectName; - unplanMap.sprintId = taskUnplanMap.sprintId; - unplanMap.sprintName = taskUnplanMap.sprintName; - unplanMap.custRequestId = custRequestId; - unplanMap.description = taskUnplanMap.description; - unplanMap.productId = productId; - unplanMap.productName = productName; + productId = productMap.productId + product = from("Product").where("productId", productId).queryOne() + productName = product.internalName + unplanMap.taskId = taskUnplanMap.taskId + unplanMap.taskName = taskUnplanMap.taskName + unplanMap.projectId = taskUnplanMap.projectId + unplanMap.projectName = taskUnplanMap.projectName + unplanMap.sprintId = taskUnplanMap.sprintId + unplanMap.sprintName = taskUnplanMap.sprintName + unplanMap.custRequestId = custRequestId + unplanMap.description = taskUnplanMap.description + unplanMap.productId = productId + unplanMap.productName = productName } - taskPartyList.add(taskUnplanMap); - taskListDropdown.add(unplanMap); + taskPartyList.add(taskUnplanMap) + taskListDropdown.add(unplanMap) } -exprBldr = []; -exprBldr.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.EQUALS, "RF_PROD_BACKLOG")); -exprBldr.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.EQUALS, "RF_SCRUM_MEETINGS")); -andExprs = []; -andExprs.add(EntityCondition.makeCondition("taskCurrentStatusId", EntityOperator.EQUALS, "STS_CREATED")); -andExprs.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId)); -andExprs.add(EntityCondition.makeCondition(exprBldr, EntityOperator.OR)); -custRequestTypeCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND); +exprBldr = [] +exprBldr.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.EQUALS, "RF_PROD_BACKLOG")) +exprBldr.add(EntityCondition.makeCondition("custRequestTypeId", EntityOperator.EQUALS, "RF_SCRUM_MEETINGS")) +andExprs = [] +andExprs.add(EntityCondition.makeCondition("taskCurrentStatusId", EntityOperator.EQUALS, "STS_CREATED")) +andExprs.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId)) +andExprs.add(EntityCondition.makeCondition(exprBldr, EntityOperator.OR)) +custRequestTypeCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND) -taskPlanList = from("ProjectSprintBacklogTaskAndParty").where(custRequestTypeCond).orderBy("taskTypeId","projectId","sprintId").queryList(); +taskPlanList = from("ProjectSprintBacklogTaskAndParty").where(custRequestTypeCond).orderBy("taskTypeId","projectId","sprintId").queryList() taskPlanList.each { taskPlanMap -> - planMap=[:]; + planMap=[:] if ("RF_SCRUM_MEETINGS".equals(taskPlanMap.custRequestTypeId)) { - workEffPartyAssignedList = from("WorkEffortPartyAssignment").where("partyId", partyId, "workEffortId", taskPlanMap.taskId).queryList(); - workEffPartyAssignedMap = workEffPartyAssignedList[0]; + workEffPartyAssignedList = from("WorkEffortPartyAssignment").where("partyId", partyId, "workEffortId", taskPlanMap.taskId).queryList() + workEffPartyAssignedMap = workEffPartyAssignedList[0] if (!"SCAS_COMPLETED".equals(workEffPartyAssignedMap.statusId)) { - taskPartyList.add(taskPlanMap); - taskListDropdown.add(taskPlanMap); + taskPartyList.add(taskPlanMap) + taskListDropdown.add(taskPlanMap) } } else { if (taskPlanMap.projectId) { - taskPartyList.add(taskPlanMap); - taskListDropdown.add(taskPlanMap); + taskPartyList.add(taskPlanMap) + taskListDropdown.add(taskPlanMap) } else { - custRequestId = taskPlanMap.custRequestId; - productlist = from("CustRequestItem").where("custRequestId", custRequestId).orderBy("productId").queryList(); - product = from("Product").where("productId", productlist[0].productId).queryOne(); - productName = product.internalName; - planMap.taskId = taskPlanMap.taskId; - planMap.taskTypeId = taskPlanMap.taskTypeId; - planMap.taskName = taskPlanMap.taskName; - planMap.projectId = taskPlanMap.projectId; - planMap.projectName = taskPlanMap.projectName; - planMap.sprintId = taskPlanMap.sprintId; - planMap.sprintName = taskPlanMap.sprintName; - planMap.custRequestId = custRequestId; - planMap.description = taskPlanMap.description; - planMap.productId = productlist[0].productId; - planMap.productName = productName; - taskPartyList.add(planMap); - taskListDropdown.add(planMap); + custRequestId = taskPlanMap.custRequestId + productlist = from("CustRequestItem").where("custRequestId", custRequestId).orderBy("productId").queryList() + product = from("Product").where("productId", productlist[0].productId).queryOne() + productName = product.internalName + planMap.taskId = taskPlanMap.taskId + planMap.taskTypeId = taskPlanMap.taskTypeId + planMap.taskName = taskPlanMap.taskName + planMap.projectId = taskPlanMap.projectId + planMap.projectName = taskPlanMap.projectName + planMap.sprintId = taskPlanMap.sprintId + planMap.sprintName = taskPlanMap.sprintName + planMap.custRequestId = custRequestId + planMap.description = taskPlanMap.description + planMap.productId = productlist[0].productId + planMap.productName = productName + taskPartyList.add(planMap) + taskListDropdown.add(planMap) } } } if (taskPartyList){ - context.taskPartyList = taskPartyList; + context.taskPartyList = taskPartyList } if (taskListDropdown){ - context.taskListDropdown = taskListDropdown; + context.taskListDropdown = taskListDropdown } diff --git a/webpos/groovyScripts/Login.groovy b/webpos/groovyScripts/Login.groovy index beb9eb543..c162203c9 100644 --- a/webpos/groovyScripts/Login.groovy +++ b/webpos/groovyScripts/Login.groovy @@ -17,30 +17,30 @@ * under the License. */ -import org.apache.ofbiz.product.store.ProductStoreWorker; -import org.apache.ofbiz.webapp.control.LoginWorker; +import org.apache.ofbiz.product.store.ProductStoreWorker +import org.apache.ofbiz.webapp.control.LoginWorker -context.autoUserLogin = session.getAttribute("autoUserLogin"); -context.autoLogoutUrl = LoginWorker.makeLoginUrl(request, "autoLogout"); +context.autoUserLogin = session.getAttribute("autoUserLogin") +context.autoLogoutUrl = LoginWorker.makeLoginUrl(request, "autoLogout") -previousParams = session.getAttribute("_PREVIOUS_PARAMS_"); +previousParams = session.getAttribute("_PREVIOUS_PARAMS_") if (previousParams) { - previousParams = UtilHttp.stripNamedParamsFromQueryString(previousParams, ['USERNAME', 'PASSWORD']); - previousParams = "?" + previousParams; + previousParams = UtilHttp.stripNamedParamsFromQueryString(previousParams, ['USERNAME', 'PASSWORD']) + previousParams = "?" + previousParams } else { - previousParams = ""; + previousParams = "" } -context.previousParams = previousParams; +context.previousParams = previousParams -productStoreId = ProductStoreWorker.getProductStoreId(request); -productStore = ProductStoreWorker.getProductStore(productStoreId, delegator); +productStoreId = ProductStoreWorker.getProductStoreId(request) +productStore = ProductStoreWorker.getProductStore(productStoreId, delegator) if (productStore) { - facilityId = productStore.getString("inventoryFacilityId"); + facilityId = productStore.getString("inventoryFacilityId") if (facilityId) { - context.posTerminals = from("PosTerminal").where("facilityId", facilityId).orderBy("posTerminalId").queryList(); + context.posTerminals = from("PosTerminal").where("facilityId", facilityId).orderBy("posTerminalId").queryList() } else { - context.posTerminals = from("PosTerminal").orderBy("posTerminalId").queryList(); + context.posTerminals = from("PosTerminal").orderBy("posTerminalId").queryList() } } diff --git a/webpos/groovyScripts/WebPosMenus.groovy b/webpos/groovyScripts/WebPosMenus.groovy index df6849298..464b51a4f 100644 --- a/webpos/groovyScripts/WebPosMenus.groovy +++ b/webpos/groovyScripts/WebPosMenus.groovy @@ -17,22 +17,22 @@ * under the License. */ -import org.apache.ofbiz.webpos.WebPosEvents; -import org.apache.ofbiz.webpos.session.WebPosSession; -import org.apache.ofbiz.webpos.transaction.WebPosTransaction; +import org.apache.ofbiz.webpos.WebPosEvents +import org.apache.ofbiz.webpos.session.WebPosSession +import org.apache.ofbiz.webpos.transaction.WebPosTransaction -webPosSession = WebPosEvents.getWebPosSession(request, null); +webPosSession = WebPosEvents.getWebPosSession(request, null) if (webPosSession) { - context.shoppingCartSize = webPosSession.getCart().size(); - context.isManagerLoggedIn = webPosSession.isManagerLoggedIn(); - webPosTransaction = webPosSession.getCurrentTransaction(); + context.shoppingCartSize = webPosSession.getCart().size() + context.isManagerLoggedIn = webPosSession.isManagerLoggedIn() + webPosTransaction = webPosSession.getCurrentTransaction() if (webPosTransaction) { - context.isOpen = webPosTransaction.isOpen(); + context.isOpen = webPosTransaction.isOpen() } - context.cart = webPosSession.getCart(); - context.totalDue = webPosSession.getCurrentTransaction().getTotalDue(); - context.totalPayments = webPosSession.getCurrentTransaction().getPaymentTotal(); + context.cart = webPosSession.getCart() + context.totalDue = webPosSession.getCurrentTransaction().getTotalDue() + context.totalPayments = webPosSession.getCurrentTransaction().getPaymentTotal() } else { - context.shoppingCartSize = 0; + context.shoppingCartSize = 0 } \ No newline at end of file diff --git a/webpos/groovyScripts/WebPosSetup.groovy b/webpos/groovyScripts/WebPosSetup.groovy index e2eb4db6a..e99a0fdd4 100644 --- a/webpos/groovyScripts/WebPosSetup.groovy +++ b/webpos/groovyScripts/WebPosSetup.groovy @@ -17,24 +17,24 @@ * under the License. */ -import org.apache.ofbiz.product.catalog.CatalogWorker; -import org.apache.ofbiz.product.store.ProductStoreWorker; -import org.apache.ofbiz.webapp.control.LoginWorker; +import org.apache.ofbiz.product.catalog.CatalogWorker +import org.apache.ofbiz.product.store.ProductStoreWorker +import org.apache.ofbiz.webapp.control.LoginWorker -productStore = ProductStoreWorker.getProductStore(request); +productStore = ProductStoreWorker.getProductStore(request) -prodCatalog = CatalogWorker.getProdCatalog(request); +prodCatalog = CatalogWorker.getProdCatalog(request) if (prodCatalog) { - catalogStyleSheet = prodCatalog.styleSheet; + catalogStyleSheet = prodCatalog.styleSheet if (catalogStyleSheet) { - globalContext.catalogStyleSheet = catalogStyleSheet; + globalContext.catalogStyleSheet = catalogStyleSheet } - catalogHeaderLogo = prodCatalog.headerLogo; + catalogHeaderLogo = prodCatalog.headerLogo if (catalogHeaderLogo) { - globalContext.catalogHeaderLogo = catalogHeaderLogo; + globalContext.catalogHeaderLogo = catalogHeaderLogo } } -globalContext.productStore = productStore; -globalContext.checkLoginUrl = LoginWorker.makeLoginUrl(request, "checkLogin"); -globalContext.catalogQuickaddUse = CatalogWorker.getCatalogQuickaddUse(request); +globalContext.productStore = productStore +globalContext.checkLoginUrl = LoginWorker.makeLoginUrl(request, "checkLogin") +globalContext.catalogQuickaddUse = CatalogWorker.getCatalogQuickaddUse(request) diff --git a/webpos/groovyScripts/catalog/Category.groovy b/webpos/groovyScripts/catalog/Category.groovy index 5b2f68916..9a823f387 100644 --- a/webpos/groovyScripts/catalog/Category.groovy +++ b/webpos/groovyScripts/catalog/Category.groovy @@ -22,41 +22,41 @@ * should not contain order component's specific code. */ -import org.apache.ofbiz.product.catalog.CatalogWorker; -import org.apache.ofbiz.product.category.CategoryContentWrapper; +import org.apache.ofbiz.product.catalog.CatalogWorker +import org.apache.ofbiz.product.category.CategoryContentWrapper -detailScreen = "categorydetail"; -catalogName = CatalogWorker.getCatalogName(request); +detailScreen = "categorydetail" +catalogName = CatalogWorker.getCatalogName(request) -productCategoryId = parameters.productCategoryId; +productCategoryId = parameters.productCategoryId if (!(productCategoryId) && request.getAttribute("topCategoryId")) { - productCategoryId = request.getAttribute("topCategoryId"); + productCategoryId = request.getAttribute("topCategoryId") } -category = from("ProductCategory").where("productCategoryId", productCategoryId).cache(true).queryOne(); +category = from("ProductCategory").where("productCategoryId", productCategoryId).cache(true).queryOne() if (category) { if (category.detailScreen) { - detailScreen = category.detailScreen; + detailScreen = category.detailScreen } - categoryContentWrapper = new CategoryContentWrapper(category, request); - context.title = categoryContentWrapper.get("CATEGORY_NAME", "html"); - categoryDescription = categoryContentWrapper.get("DESCRIPTION", "html"); + categoryContentWrapper = new CategoryContentWrapper(category, request) + context.title = categoryContentWrapper.get("CATEGORY_NAME", "html") + categoryDescription = categoryContentWrapper.get("DESCRIPTION", "html") if (categoryDescription) { - context.metaDescription = categoryDescription; - context.metaKeywords = categoryDescription + ", " + catalogName; + context.metaDescription = categoryDescription + context.metaKeywords = categoryDescription + ", " + catalogName } else { - context.metaKeywords = catalogName; + context.metaKeywords = catalogName } - context.productCategory = category; + context.productCategory = category } // check the catalogs template path and update -templatePathPrefix = CatalogWorker.getTemplatePathPrefix(request); +templatePathPrefix = CatalogWorker.getTemplatePathPrefix(request) if (templatePathPrefix) { - detailScreen = templatePathPrefix + detailScreen; + detailScreen = templatePathPrefix + detailScreen } -context.detailScreen = detailScreen; +context.detailScreen = detailScreen -request.setAttribute("productCategoryId", productCategoryId); -request.setAttribute("defaultViewSize", 10); -request.setAttribute("limitView", true); +request.setAttribute("productCategoryId", productCategoryId) +request.setAttribute("defaultViewSize", 10) +request.setAttribute("limitView", true) diff --git a/webpos/groovyScripts/catalog/SideDeepCategory.groovy b/webpos/groovyScripts/catalog/SideDeepCategory.groovy index 270464bea..56176a926 100644 --- a/webpos/groovyScripts/catalog/SideDeepCategory.groovy +++ b/webpos/groovyScripts/catalog/SideDeepCategory.groovy @@ -16,21 +16,21 @@ * specific language governing permissions and limitations * under the License. */ -import org.apache.ofbiz.product.catalog.CatalogWorker; -import org.apache.ofbiz.product.category.CategoryWorker; +import org.apache.ofbiz.product.catalog.CatalogWorker +import org.apache.ofbiz.product.category.CategoryWorker -CategoryWorker.getRelatedCategories(request, "topLevelList", CatalogWorker.getCatalogTopCategoryId(request, CatalogWorker.getCurrentCatalogId(request)), true); -curCategoryId = parameters.category_id ?: parameters.CATEGORY_ID ?: ""; -request.setAttribute("curCategoryId", curCategoryId); -CategoryWorker.setTrail(request, curCategoryId); +CategoryWorker.getRelatedCategories(request, "topLevelList", CatalogWorker.getCatalogTopCategoryId(request, CatalogWorker.getCurrentCatalogId(request)), true) +curCategoryId = parameters.category_id ?: parameters.CATEGORY_ID ?: "" +request.setAttribute("curCategoryId", curCategoryId) +CategoryWorker.setTrail(request, curCategoryId) -categoryList = request.getAttribute("topLevelList"); +categoryList = request.getAttribute("topLevelList") if (categoryList) { - catContentWrappers = [:]; - CategoryWorker.getCategoryContentWrappers(catContentWrappers, categoryList, request); - context.catContentWrappers = catContentWrappers; + catContentWrappers = [:] + CategoryWorker.getCategoryContentWrappers(catContentWrappers, categoryList, request) + context.catContentWrappers = catContentWrappers } if (!curCategoryId && categoryList) { - curCategoryId = categoryList[0].productCategoryId; - request.setAttribute("topCategoryId", curCategoryId); + curCategoryId = categoryList[0].productCategoryId + request.setAttribute("topCategoryId", curCategoryId) } \ No newline at end of file diff --git a/webpos/groovyScripts/customer/EditAddress.groovy b/webpos/groovyScripts/customer/EditAddress.groovy index 03390dbd1..aa52f108f 100644 --- a/webpos/groovyScripts/customer/EditAddress.groovy +++ b/webpos/groovyScripts/customer/EditAddress.groovy @@ -17,34 +17,34 @@ * under the License. */ -person = from("Person").where("partyId", parameters.partyId).queryOne(); +person = from("Person").where("partyId", parameters.partyId).queryOne() if (person) { - request.setAttribute("lastName", person.lastName); - request.setAttribute("firstName", person.firstName); - request.setAttribute("partyId", parameters.partyId); + request.setAttribute("lastName", person.lastName) + request.setAttribute("firstName", person.firstName) + request.setAttribute("partyId", parameters.partyId) } -contactMech = from("ContactMech").where("contactMechId", parameters.contactMechId).queryOne(); +contactMech = from("ContactMech").where("contactMechId", parameters.contactMechId).queryOne() if (contactMech) { - postalAddress = contactMech.getRelatedOne("PostalAddress", false); + postalAddress = contactMech.getRelatedOne("PostalAddress", false) if (postalAddress) { - request.setAttribute("contactMechId", postalAddress.contactMechId); - request.setAttribute("toName", postalAddress.toName); - request.setAttribute("attnName", postalAddress.attnName); - request.setAttribute("address1", postalAddress.address1); - request.setAttribute("address2", postalAddress.address2); - request.setAttribute("city", postalAddress.city); - request.setAttribute("postalCode", postalAddress.postalCode); - request.setAttribute("stateProvinceGeoId", postalAddress.stateProvinceGeoId); - request.setAttribute("countryGeoId", postalAddress.countryGeoId); - stateProvinceGeo = from("Geo").where("geoId", postalAddress.stateProvinceGeoId).queryOne(); + request.setAttribute("contactMechId", postalAddress.contactMechId) + request.setAttribute("toName", postalAddress.toName) + request.setAttribute("attnName", postalAddress.attnName) + request.setAttribute("address1", postalAddress.address1) + request.setAttribute("address2", postalAddress.address2) + request.setAttribute("city", postalAddress.city) + request.setAttribute("postalCode", postalAddress.postalCode) + request.setAttribute("stateProvinceGeoId", postalAddress.stateProvinceGeoId) + request.setAttribute("countryGeoId", postalAddress.countryGeoId) + stateProvinceGeo = from("Geo").where("geoId", postalAddress.stateProvinceGeoId).queryOne() if (stateProvinceGeo) { - request.setAttribute("stateProvinceGeo", stateProvinceGeo.get("geoName", locale)); + request.setAttribute("stateProvinceGeo", stateProvinceGeo.get("geoName", locale)) } - countryProvinceGeo = from("Geo").where("geoId", postalAddress.countryGeoId).queryOne(); + countryProvinceGeo = from("Geo").where("geoId", postalAddress.countryGeoId).queryOne() if (countryProvinceGeo) { - request.setAttribute("countryProvinceGeo", countryProvinceGeo.get("geoName", locale)); + request.setAttribute("countryProvinceGeo", countryProvinceGeo.get("geoName", locale)) } } } -request.setAttribute("contactMechPurposeTypeId", parameters.contactMechPurposeTypeId); +request.setAttribute("contactMechPurposeTypeId", parameters.contactMechPurposeTypeId) diff --git a/webpos/groovyScripts/manager/PaidOutAndIn.groovy b/webpos/groovyScripts/manager/PaidOutAndIn.groovy index b00a50ee0..5544abca7 100644 --- a/webpos/groovyScripts/manager/PaidOutAndIn.groovy +++ b/webpos/groovyScripts/manager/PaidOutAndIn.groovy @@ -17,5 +17,5 @@ * under the License. */ -context.paidReasonIn = from("Enumeration").where("enumTypeId", "POS_PAID_REASON_IN").orderBy("sequenceId").queryList(); -context.paidReasonOut = from("Enumeration").where("enumTypeId", "POS_PAID_REASON_OUT").orderBy("sequenceId").queryList(); +context.paidReasonIn = from("Enumeration").where("enumTypeId", "POS_PAID_REASON_IN").orderBy("sequenceId").queryList() +context.paidReasonOut = from("Enumeration").where("enumTypeId", "POS_PAID_REASON_OUT").orderBy("sequenceId").queryList() diff --git a/webpos/groovyScripts/search/CustomerAddress.groovy b/webpos/groovyScripts/search/CustomerAddress.groovy index 6a880a6ec..ee0e8a5c2 100644 --- a/webpos/groovyScripts/search/CustomerAddress.groovy +++ b/webpos/groovyScripts/search/CustomerAddress.groovy @@ -16,32 +16,32 @@ * specific language governing permissions and limitations * under the License. */ -import org.apache.ofbiz.base.util.UtilValidate; -import org.apache.ofbiz.webpos.WebPosEvents; +import org.apache.ofbiz.base.util.UtilValidate +import org.apache.ofbiz.webpos.WebPosEvents -webPosSession = WebPosEvents.getWebPosSession(request, null); +webPosSession = WebPosEvents.getWebPosSession(request, null) if (webPosSession) { - shoppingCart = webPosSession.getCart(); - shipToCustomerPartyId = shoppingCart.getShipToCustomerPartyId(); + shoppingCart = webPosSession.getCart() + shipToCustomerPartyId = shoppingCart.getShipToCustomerPartyId() if (UtilValidate.isNotEmpty(shipToCustomerPartyId)) { - context.personShipTo = from("Person").where("partyId", shipToCustomerPartyId).queryOne(); + context.personShipTo = from("Person").where("partyId", shipToCustomerPartyId).queryOne() } - shippingContactMechId = shoppingCart.getContactMech("SHIPPING_LOCATION"); + shippingContactMechId = shoppingCart.getContactMech("SHIPPING_LOCATION") if (UtilValidate.isNotEmpty(shippingContactMechId)) { - contactMech = from("ContactMech").where("contactMechId", shippingContactMechId).queryOne(); + contactMech = from("ContactMech").where("contactMechId", shippingContactMechId).queryOne() if (UtilValidate.isNotEmpty(contactMech) && "POSTAL_ADDRESS".equals(contactMech.contactMechTypeId)) { - context.shippingPostalAddress = contactMech.getRelatedOne("PostalAddress", false); + context.shippingPostalAddress = contactMech.getRelatedOne("PostalAddress", false) } } - billToCustomerPartyId = shoppingCart.getBillToCustomerPartyId(); + billToCustomerPartyId = shoppingCart.getBillToCustomerPartyId() if (UtilValidate.isNotEmpty(billToCustomerPartyId)) { - context.personBillTo = from("Person").where("partyId", billToCustomerPartyId).queryOne(); + context.personBillTo = from("Person").where("partyId", billToCustomerPartyId).queryOne() } - billingContactMechId = shoppingCart.getContactMech("BILLING_LOCATION"); + billingContactMechId = shoppingCart.getContactMech("BILLING_LOCATION") if (UtilValidate.isNotEmpty(billingContactMechId)) { - contactMech = from("ContactMech").where("contactMechId", billingContactMechId).queryOne(); + contactMech = from("ContactMech").where("contactMechId", billingContactMechId).queryOne() if (UtilValidate.isNotEmpty(contactMech) && "POSTAL_ADDRESS".equals(contactMech.contactMechTypeId)) { - context.billingPostalAddress = contactMech.getRelatedOne("PostalAddress", false); + context.billingPostalAddress = contactMech.getRelatedOne("PostalAddress", false) } } } diff --git a/webpos/groovyScripts/search/SearchSalesReps.groovy b/webpos/groovyScripts/search/SearchSalesReps.groovy index f510d2520..bae6dd4ef 100644 --- a/webpos/groovyScripts/search/SearchSalesReps.groovy +++ b/webpos/groovyScripts/search/SearchSalesReps.groovy @@ -17,9 +17,9 @@ * under the License. */ -context.salesReps = from("PartyRoleNameDetail").where("roleTypeId", "SALES_REP").orderBy("lastName", "firstName").queryList(); +context.salesReps = from("PartyRoleNameDetail").where("roleTypeId", "SALES_REP").orderBy("lastName", "firstName").queryList() -shoppingCart = session.getAttribute("shoppingCart"); +shoppingCart = session.getAttribute("shoppingCart") if (shoppingCart) { - context.cartSalesReps = shoppingCart.getAdditionalPartyRoleMap().SALES_REP; + context.cartSalesReps = shoppingCart.getAdditionalPartyRoleMap().SALES_REP } \ No newline at end of file