/* * 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.*; import org.ofbiz.widget.html.*; delegator = request.getAttribute("delegator"); shipmentId = request.getParameter("shipmentId"); if (UtilValidate.isEmpty(shipmentId)) shipmentId = request.getAttribute("shipmentId"); shipment = delegator.findByPrimaryKey("Shipment", UtilMisc.toMap("shipmentId", shipmentId)); // orderHeader is needed here to determine type of order and hence types of shipment status orderHeader = null; primaryOrderId = null; if (shipment == null) { primaryOrderId = request.getParameter("primaryOrderId"); } else { primaryOrderId = shipment.get("primaryOrderId"); } orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", primaryOrderId)); HtmlFormWrapper editShipmentWrapper = new HtmlFormWrapper("component://product/webapp/facility/shipment/ShipmentForms.xml", "EditShipment", request, response); editShipmentWrapper.putInContext("shipmentId", shipmentId); editShipmentWrapper.putInContext("shipment", shipment); editShipmentWrapper.putInContext("productStoreId", null); // seems to be needed not exist != null if (shipment == null) editShipmentWrapper.setUseRequestParameters(true); // the kind of StatusItem to use is based on the type of order if ((orderHeader != null) && (orderHeader.getString("orderTypeId").equals("PURCHASE_ORDER"))) { statusItemType = "PURCH_SHIP_STATUS"; } else { statusItemType = "SHIPMENT_STATUS"; } editShipmentWrapper.putInContext("statusItemType", statusItemType); context.put("shipmentId", shipmentId); context.put("shipment", shipment); context.put("editShipmentWrapper", editShipmentWrapper); if (shipment != null) { currentStatus = shipment.getRelatedOne("StatusItem"); originPostalAddress = shipment.getRelatedOne("OriginPostalAddress"); destinationPostalAddress = shipment.getRelatedOne("DestinationPostalAddress"); originTelecomNumber = shipment.getRelatedOne("OriginTelecomNumber"); destinationTelecomNumber = shipment.getRelatedOne("DestinationTelecomNumber"); toPerson = shipment.getRelatedOne("ToPerson"); toPartyGroup = shipment.getRelatedOne("ToPartyGroup"); fromPerson = shipment.getRelatedOne("FromPerson"); fromPartyGroup = shipment.getRelatedOne("FromPartyGroup"); primaryOrderId = shipment.getString("primaryOrderId"); editShipmentWrapper.putInContext("currentStatus", currentStatus); editShipmentWrapper.putInContext("originPostalAddress", originPostalAddress); editShipmentWrapper.putInContext("destinationPostalAddress", destinationPostalAddress); editShipmentWrapper.putInContext("originTelecomNumber", originTelecomNumber); editShipmentWrapper.putInContext("destinationTelecomNumber", destinationTelecomNumber); editShipmentWrapper.putInContext("toPerson", toPerson); editShipmentWrapper.putInContext("toPartyGroup", toPartyGroup); editShipmentWrapper.putInContext("fromPerson", fromPerson); editShipmentWrapper.putInContext("fromPartyGroup", fromPartyGroup); editShipmentWrapper.putInContext("orderHeader", orderHeader); if (orderHeader != null) { editShipmentWrapper.putInContext("productStoreId", orderHeader.get("productStoreId")); } context.put("currentStatus", currentStatus); context.put("originPostalAddress", originPostalAddress); context.put("destinationPostalAddress", destinationPostalAddress); context.put("originTelecomNumber", originTelecomNumber); context.put("destinationTelecomNumber", destinationTelecomNumber); context.put("toPerson", toPerson); context.put("toPartyGroup", toPartyGroup); context.put("fromPerson", fromPerson); context.put("fromPartyGroup", fromPartyGroup); if (primaryOrderId != null) { ord = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", primaryOrderId)); pfc = delegator.findAll("ProductStoreFacility"); fac = delegator.findByAnd("ProductStoreFacilityByOrder", UtilMisc.toMap("orderId", primaryOrderId)); Debug.log("" + ord); Debug.log("" + pfc); Debug.log("" + fac); } }