String shipmentItemSeqId = issue.getString("shipmentItemSeqId");
String productId = orderItem.getString("productId");
String orderId = issue.getString("orderId");
googleOrder = findGoogleOrder(delegator, orderId);
if (UtilValidate.isNotEmpty(googleOrder)) {
MerchantInfo mInfo = getMerchantInfo(delegator, getProductStoreFromOrder(googleOrder));
if (UtilValidate.isEmpty(mInfo)) {
Debug.logInfo("Cannot find Google MerchantInfo for Order #" + orderId, module);
continue;
}
String externalId = googleOrder.getString("externalId");
if (UtilValidate.isEmpty(isr)) {
isr = new ShipItemsRequest(mInfo, externalId);
}
// locate the shipment package content record
Map<String, ? extends Object> spcLup = UtilMisc.toMap("shipmentId", shipmentId, "shipmentItemSeqId", shipmentItemSeqId);
List<GenericValue> spc = delegator.findByAnd("ShipmentPackageContent", spcLup);
GenericValue packageContent = EntityUtil.getFirst(spc);
String carrier = null;
if (UtilValidate.isNotEmpty(packageContent)) {
GenericValue shipPackage = packageContent.getRelatedOne("ShipmentPackage");
if (UtilValidate.isNotEmpty(shipPackage)) {
List<GenericValue> prs = shipPackage.getRelated("ShipmentPackageRouteSeg");
GenericValue packageRoute = EntityUtil.getFirst(prs);
if (UtilValidate.isNotEmpty(packageRoute)) {
List<GenericValue> srs = packageRoute.getRelated("ShipmentRouteSegment");
GenericValue route = EntityUtil.getFirst(srs);
String track = packageRoute.getString("trackingCode");
if (UtilValidate.isNotEmpty(route)) {
carrier = route.getString("carrierPartyId");
if (UtilValidate.isEmpty(track)) {
track = route.getString("trackingIdNumber");
}
if (track == null) {
track = "";
}
isr.addItemShippingInformation(productId, carrier, track);
Debug.logInfo("Sending item shipped notification: " + productId + " / " + carrier + " / " + track, module);
Debug.logInfo("Using merchantInfo : " + mInfo.getMerchantId() + " #" + externalId, module);
}
}
}
}
}