/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.*; import org.ofbiz.entity.*; import org.ofbiz.base.util.*; delegator = request.getAttribute("delegator"); shipmentId = request.getParameter("shipmentId"); if (UtilValidate.isEmpty(shipmentId)) { shipmentId = context.get("shipmentId"); } shipment = null; if (UtilValidate.isNotEmpty(shipmentId)) { shipment = delegator.findByPrimaryKey("Shipment", UtilMisc.toMap("shipmentId", shipmentId)); } if (shipment != null) { shipmentRouteSegments = shipment.getRelated("ShipmentRouteSegment", null, UtilMisc.toList("shipmentRouteSegmentId")); shipmentRouteSegmentDatas = new LinkedList(); if (shipmentRouteSegments != null && shipmentRouteSegments.size() > 0) { shipmentRouteSegmentIter = shipmentRouteSegments.iterator(); while (shipmentRouteSegmentIter.hasNext()) { shipmentRouteSegment = shipmentRouteSegmentIter.next(); shipmentRouteSegmentData = new HashMap(); shipmentRouteSegmentData.put("shipmentRouteSegment", shipmentRouteSegment); shipmentRouteSegmentData.put("originFacility", shipmentRouteSegment.getRelatedOne("OriginFacility")); shipmentRouteSegmentData.put("destFacility", shipmentRouteSegment.getRelatedOne("DestFacility")); shipmentRouteSegmentData.put("originPostalAddress", shipmentRouteSegment.getRelatedOne("OriginPostalAddress")); shipmentRouteSegmentData.put("originTelecomNumber", shipmentRouteSegment.getRelatedOne("OriginTelecomNumber")); shipmentRouteSegmentData.put("destPostalAddress", shipmentRouteSegment.getRelatedOne("DestPostalAddress")); shipmentRouteSegmentData.put("destTelecomNumber", shipmentRouteSegment.getRelatedOne("DestTelecomNumber")); shipmentRouteSegmentData.put("shipmentMethodType", shipmentRouteSegment.getRelatedOne("ShipmentMethodType")); shipmentRouteSegmentData.put("carrierPerson", shipmentRouteSegment.getRelatedOne("CarrierPerson")); shipmentRouteSegmentData.put("carrierPartyGroup", shipmentRouteSegment.getRelatedOne("CarrierPartyGroup")); shipmentRouteSegmentData.put("shipmentPackageRouteSegs", shipmentRouteSegment.getRelated("ShipmentPackageRouteSeg")); shipmentRouteSegmentData.put("carrierServiceStatusItem", shipmentRouteSegment.getRelatedOne("CarrierServiceStatusItem")); shipmentRouteSegmentData.put("currencyUom", shipmentRouteSegment.getRelatedOne("CurrencyUom")); shipmentRouteSegmentData.put("billingWeightUom", shipmentRouteSegment.getRelatedOne("BillingWeightUom")); if (UtilValidate.isNotEmpty(shipmentRouteSegment.getString("carrierServiceStatusId"))) { shipmentRouteSegmentData.put("carrierServiceStatusValidChangeToDetails", delegator.findByAnd("StatusValidChangeToDetail", UtilMisc.toMap("statusId", shipmentRouteSegment.get("carrierServiceStatusId")), UtilMisc.toList("sequenceId"))); } else { shipmentRouteSegmentData.put("carrierServiceStatusValidChangeToDetails", delegator.findByAnd("StatusValidChangeToDetail", UtilMisc.toMap("statusId", "SHRSCS_NOT_STARTED"), UtilMisc.toList("sequenceId"))); } shipmentRouteSegmentData.put("thirdPartyPostalAddress", shipmentRouteSegment.getRelatedOne("ThirdPartyPostalAddress")); shipmentRouteSegmentDatas.add(shipmentRouteSegmentData); } } shipmentPackages = shipment.getRelated("ShipmentPackage", null, UtilMisc.toList("shipmentPackageSeqId")); facilities = delegator.findAll("Facility", UtilMisc.toList("facilityName")); shipmentMethodTypes = delegator.findAll("ShipmentMethodType", UtilMisc.toList("description")); weightUoms = delegator.findByAnd("Uom", UtilMisc.toMap("uomTypeId", "WEIGHT_MEASURE")); currencyUoms = delegator.findByAnd("Uom", UtilMisc.toMap("uomTypeId", "CURRENCY_MEASURE")); carrierPartyRoles = delegator.findByAnd("PartyRole", UtilMisc.toMap("roleTypeId", "CARRIER")); carrierPartyDatas = new LinkedList(); carrierPartyRoleIter = carrierPartyRoles.iterator(); while (carrierPartyRoleIter.hasNext()) { carrierPartyRole = carrierPartyRoleIter.next(); party = carrierPartyRole.getRelatedOne("Party"); carrierPartyData = new HashMap(); carrierPartyData.put("party", party); carrierPartyData.put("person", party.getRelatedOne("Person")); carrierPartyData.put("partyGroup", party.getRelatedOne("PartyGroup")); carrierPartyDatas.add(carrierPartyData); } context.put("shipment", shipment); context.put("shipmentRouteSegmentDatas", shipmentRouteSegmentDatas); context.put("shipmentPackages", shipmentPackages); context.put("facilities", facilities); context.put("shipmentMethodTypes", shipmentMethodTypes); context.put("weightUoms", weightUoms); context.put("currencyUoms", currencyUoms); context.put("carrierPartyDatas", carrierPartyDatas); } context.put("shipmentId", shipmentId); nowTimestampString = UtilDateTime.nowTimestamp().toString(); context.put("nowTimestampString", nowTimestampString);