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 2 Next »


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  

/**

  • Resource for
    Unknown macro: {@link Order}
    and all of its subclasses
    */
    @Resource(name = RestConstants.VERSION_1 + "/order", supportedClass = Order.class, supportedOpenmrsVersions =
    Unknown macro: { "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> .

@SubClassHandler(supportedClass = DrugOrder.class, supportedOpenmrsVersions =

Unknown macro: { "1.8.*", "1.9.*" }

)
public class DrugOrderSubclassHandler1_8 extends BaseDelegatingSubclassHandler<Order, DrugOrder> implements DelegatingSubclassHandler<Order, DrugOrder> {

public DrugOrderSubclassHandler1_8()

Unknown macro: { //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