Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Sub Class Handler provides you the facility to add different child classes of single resource while handling all the complex work behind. You only need to provide annotation @SubClassHandler. For example, Order class has two child classes DrugOrder and TestOrder, but there is only one single  @Resource  class of OrderResource. The child classes have their @subclasshandler classes instead of separate resource.

In Order model, Rest Module has only used single @Resource for parent only. The child classes have only  

OrderResource
/**
 * Resource for {@link Order} and all of its subclasses
 */
@Resource(name = RestConstants.VERSION_1 + "/order", supportedClass = Order.class, supportedOpenmrsVersions = { "1.8.*",
        "1.9.*" }, order = 1)
public class OrderResource1_8 extends DataDelegatingCrudResource<Order> {

}


The Child classes of Order have annotated @SubClassHandler , extends BaseDelegatingSubclassHandler<parent, child> and implements DelegatingSubclassHandler<parent,child> .

DrugOrderSubclassHandler
@SubClassHandler(supportedClass = DrugOrder.class, supportedOpenmrsVersions = { "1.8.*", "1.9.*" })
public class DrugOrderSubclassHandler1_8 extends BaseDelegatingSubclassHandler<Order, DrugOrder> implements DelegatingSubclassHandler<Order, DrugOrder> {
	
	public DrugOrderSubclassHandler1_8() {
		//RESTWS-439
		//Order subclass fields
		allowedMissingProperties.add("dose");
		allowedMissingProperties.add("units");
		allowedMissingProperties.add("frequency");
		allowedMissingProperties.add("prn");
		allowedMissingProperties.add("complex");
		allowedMissingProperties.add("quantity");
		allowedMissingProperties.add("drug");
	}

}


This has resolved all the type and heritage issues and rest module take controls of all the rest.

  • No labels