/* * 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 java.io.*; import org.ofbiz.entity.*; import org.ofbiz.entity.util.*; import org.ofbiz.base.util.*; import org.ofbiz.widget.html.*; delegator = request.getAttribute("delegator"); String facilityId = request.getParameter("facilityId"); String inventoryTransferId = request.getParameter("inventoryTransferId"); context.put("inventoryTransferId", inventoryTransferId); String inventoryItemId = request.getParameter("inventoryItemId"); GenericValue inventoryTransfer = null; GenericValue inventoryItem = null; GenericValue inventoryItemType = null; GenericValue inventoryStatus = null; if (inventoryTransferId != null) { inventoryTransfer = delegator.findByPrimaryKey("InventoryTransfer", UtilMisc.toMap("inventoryTransferId", inventoryTransferId)); if (inventoryTransfer != null) { context.put("inventoryTransfer", inventoryTransfer); if (facilityId == null) { facilityId = inventoryTransfer.getString("facilityId"); parameters.put("facilityId", facilityId); } if (inventoryItemId == null) { inventoryItemId = inventoryTransfer.getString("inventoryItemId"); } } } GenericValue facility = null; facility = delegator.findByPrimaryKey("Facility", UtilMisc.toMap("facilityId", facilityId)); context.put("facilityId", facilityId); context.put("facility", facility); context.put("inventoryItemId", inventoryItemId); if (facilityId != null) { facility = delegator.findByPrimaryKey("Facility", UtilMisc.toMap("facilityId", facilityId)); } String illegalInventoryItem = null; if (inventoryItemId != null) { inventoryItem = delegator.findByPrimaryKey("InventoryItem", UtilMisc.toMap("inventoryItemId", inventoryItemId)); if (facilityId != null && inventoryItem != null && inventoryItem.get("facilityId") != null && !inventoryItem.getString("facilityId").equals(facilityId)) { illegalInventoryItem = "Inventory item not found for this facility."; inventoryItem = null; } if (inventoryItem != null) { context.put("inventoryItem", inventoryItem); inventoryItemType = inventoryItem.getRelatedOne("InventoryItemType"); if (inventoryItemType != null) context.put("inventoryItemType", inventoryItemType); if (inventoryItem.getString("statusId") != null) { inventoryStatus = inventoryItem.getRelatedOne("StatusItem"); if (inventoryStatus != null) context.put("inventoryStatus", inventoryStatus); } } } // facilities List facilities = delegator.findAll("Facility"); context.put("facilities", facilities); // status items if (inventoryTransfer != null && UtilValidate.isNotEmpty(inventoryTransfer.getString("statusId"))) { List statusChange = delegator.findByAnd("StatusValidChange", UtilMisc.toMap("statusId", inventoryTransfer.getString("statusId"))); if (statusChange != null) { List statusItems = new ArrayList(); Iterator statusChangeIter = statusChange.iterator(); while (statusChangeIter.hasNext()) { GenericValue curStatusChange = (GenericValue) statusChangeIter.next(); GenericValue curStatusItem = delegator.findByPrimaryKey("StatusItem", UtilMisc.toMap("statusId", curStatusChange.get("statusIdTo"))); if (curStatusItem != null) statusItems.add(curStatusItem); } List statusItem = EntityUtil.orderBy(statusItems, UtilMisc.toList("sequenceId")); context.put("statusItems", statusItems); } } else { List statusItems = delegator.findByAnd("StatusItem", UtilMisc.toMap("statusTypeId", "INVENTORY_XFER_STTS"), UtilMisc.toList("sequenceId")); if (statusItems != null) context.put("statusItems", statusItems); }