Example 11 : Trying to allocate an existing consignment to a group, using a different group if that fails

Printer-friendly version

 This will attempt to allocate an existing consignment to a carrier service group with a code of CHEAPSERVICES. If the allocation is unsuccessful, it will attempt to allocate it to one of the services in the EXPENSIVESERVICES group.

package com.metapack.dm.test;
 
import com.metapack.deliverymanager.client.Consignment;
import com.metapack.deliverymanager.client.webservices.AllocationService;
 
public class Example11 extends ExampleBase {
 
	public void run() throws Exception {
		AllocationService service = createAllocationService();
 
		Consignment consignment = service.allocateConsignmentWithBookingCode(
			"DMC01V00M0BQ" ,"@CHEAPSERVICES" );
		if( ! "Allocated".equals( consignment.getStatus() ) ) {
			consignment = service.allocateConsignmentWithBookingCode(
				"DMC01V00M0BQ" , "@EXPENSIVESERVICES" );
		}
	}
}