Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Sub Class Handler provides you to facility to add different child classes of single resource with handling all the complex works behind by just providing you with annotation to handle @SubClassHandler. Like 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 for this not Resource class. OpenMRS Rest Module resolves all the complex task behind it. Developer just have to add few things to resolve this problem without worrying to much.




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

Wiki Markup
/**
 * 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> .

Wiki Markup
@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.