package custom.app.inventory.virtual; import java.rmi.RemoteException; import psdi.app.asset.SparePart; import psdi.app.asset.SparePartSet; import psdi.app.inventory.Inventory; import psdi.app.inventory.virtual.WhereUsed; import psdi.app.item.Item; import psdi.mbo.MboRemote; import psdi.mbo.MboSet; import psdi.mbo.SqlFormat; import psdi.util.MXException; public class WhereUsedExt extends WhereUsed { @Override public void add() throws MXException, RemoteException { // TODO Auto-generated method stub super.add(); } public WhereUsedExt(MboSet ms) throws MXException, RemoteException { super(ms); // TODO Auto-generated constructor stub } @Override public void deleteAssociatedSparePart() throws MXException, RemoteException { // TODO Auto-generated method stub if (this.getLong("sparepartid") > 0L) { MboRemote owner = this.getOwner(); Inventory owningInventory = null; SqlFormat sqf = null; Item owningItem = null; if(owner instanceof Inventory) { owningInventory = (Inventory)this.getOwner(); sqf = new SqlFormat(this.getUserInfo(), "itemnum=:1 and itemsetid=:2 and assetnum=:3 and siteid=:4"); sqf.setObject(1, "ITEM", "ITEMNUM", owningInventory.getString("itemnum")); sqf.setObject(2, "ITEM", "ITEMSETID", owningInventory.getString("itemsetid")); sqf.setObject(3, "ASSET", "ASSETNUM", this.getString("assetnum")); sqf.setObject(4, "SITE", "SITEID", this.getString("Siteid")); SparePartSet sparePartSet = (SparePartSet)this.getMboSet("$sparePartForWhereUse", "SPAREPART", sqf.format()); SparePart sparePart = (SparePart)sparePartSet.getMbo(0); if (sparePart != null) { sparePart.deleteSparePart(this.getLong("sparepartid")); } }else if(owner instanceof Item) { owningItem = (Item)this.getOwner(); sqf = new SqlFormat(this.getUserInfo(), "itemnum=:1 and itemsetid=:2 and assetnum=:3 and siteid=:4"); sqf.setObject(1, "ITEM", "ITEMNUM", owningItem.getString("itemnum")); sqf.setObject(2, "ITEM", "ITEMSETID", owningItem.getString("itemsetid")); sqf.setObject(3, "ASSET", "ASSETNUM", this.getString("assetnum")); sqf.setObject(4, "SITE", "SITEID", this.getString("Siteid")); SparePartSet sparePartSet = (SparePartSet)this.getMboSet("$sparePartForWhereUse", "SPAREPART", sqf.format()); SparePart sparePart = (SparePart)sparePartSet.getMbo(0); if (sparePart != null) { sparePart.deleteSparePart(this.getLong("sparepartid")); } } } } }