/*
* 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 org.ofbiz.entity.*;
import org.ofbiz.base.util.*;
import org.ofbiz.order.order.*;
facilityId = parameters.get("facilityId");
if (UtilValidate.isNotEmpty(facilityId)) {
facility = delegator.findByPrimaryKey("Facility", UtilMisc.toMap("facilityId", facilityId));
context.put("facilityId", facilityId);
context.put("facility", facility);
}
orderId = parameters.get("orderId");
if (UtilValidate.isNotEmpty(orderId)) {
orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId));
if (orderHeader != null) {
OrderReadHelper orh = new OrderReadHelper(orderHeader);
context.put("orderId", orderId);
context.put("orderHeader", orderHeader);
context.put("orderReadHelper", orh);
} else {
request.setAttribute("_ERROR_MESSAGE_", "
Order #" + orderId + " cannot be found.");
}
}
shipmentId = parameters.get("shipmentId");
if (UtilValidate.isNotEmpty(shipmentId)) {
shipment = delegator.findByPrimaryKey("Shipment", UtilMisc.toMap("shipmentId", shipmentId));
if (shipment != null) {
// nuke event message - throws off the flow
request.setAttribute("_EVENT_MESSAGE_", null);
// set the shipment context info
context.put("shipmentType", shipment.getRelatedOneCache("ShipmentType"));
context.put("statusItem", shipment.getRelatedOne("StatusItem"));
context.put("primaryOrderHeader", shipment.getRelatedOne("PrimaryOrderHeader"));
context.put("toPerson", shipment.getRelatedOne("ToPerson"));
context.put("toPartyGroup", shipment.getRelatedOne("ToPartyGroup"));
context.put("fromPerson", shipment.getRelatedOne("FromPerson"));
context.put("fromPartyGroup", shipment.getRelatedOne("FromPartyGroup"));
context.put("originFacility", shipment.getRelatedOne("OriginFacility"));
context.put("destinationFacility", shipment.getRelatedOne("DestinationFacility"));
context.put("originPostalAddress", shipment.getRelatedOne("OriginPostalAddress"));
context.put("destinationPostalAddress", shipment.getRelatedOne("DestinationPostalAddress"));
context.put("shipmentPackages", shipment.getRelated("ShipmentPackage", null, UtilMisc.toList("shipmentPackageSeqId")));
context.put("shipmentRoutes", shipment.getRelated("ShipmentRouteSegment", null, UtilMisc.toList("shipmentRouteSegmentId")));
context.put("shipment", shipment);
context.put("shipmentId", shipmentId);
weightUoms = delegator.findByAnd("Uom", UtilMisc.toMap("uomTypeId", "WEIGHT_MEASURE"), UtilMisc.toList("description"));
defaultWeightUom = UtilProperties.getPropertyValue("shipment.properties", "shipment.default.weight.uom");
if (UtilValidate.isNotEmpty(defaultWeightUom)) {
defaultWeight = delegator.findByPrimaryKey("Uom", UtilMisc.toMap("uomId", defaultWeightUom));
if (defaultWeight != null) {
weightUoms.add(0, defaultWeight);
}
}
context.put("weightUomList", weightUoms);
}
}