Example 79 : Verify allocation

Printer-friendly version

 This example shows you how to verify a consignments allocation.

package com.metapack.dm.test;
 
import java.util.Calendar;
import com.metapack.deliverymanager.client.AllocationFilter;
import com.metapack.deliverymanager.client.Consignment;
import com.metapack.deliverymanager.client.DateRange;
import com.metapack.deliverymanager.client.webservices.AllocationService;
 
public class Example79 extends ExampleBase {
 
	public void run() throws Exception {
 
		AllocationService service = createAllocationService();
 
		Consignment[] consignments = service.createAndAllocateConsignments( 
				new Consignment[] { super.createDefaultConsignment( "Example-94" , 1 ) },
				null );
 
		String consignmentCode = consignments[0].getConsignmentCode();
 
		AllocationFilter filter = new AllocationFilter();
		filter.setFirstCollectionOnly( true );
		filter.setAcceptableCollectionSlots( new DateRange[] { new DateRange( Calendar.getInstance() , null ) } );
		filter.setPreFilterSortOrder1( ExampleBase.SORT_EARLIEST_COLLECTION_ASCENDING );
		filter.setFilterGroup1( ExampleBase.FILTER_GROUP_SERVICE );
		filter.setSortOrder1( ExampleBase.SORT_COST_CHEAPEST );
 
		service.verifyAllocation( consignmentCode , filter );
	}
 
	public static void main(String[] args ){
		Example79 ex = new Example79();
		try {
			ex.run();
		} catch( Exception e ) {
			e.printStackTrace();
		}
	}
}