Package com.swinarta.sunflower.server.resources

Source Code of com.swinarta.sunflower.server.resources.ReceivingOrderByCodeResource

package com.swinarta.sunflower.server.resources;

import java.io.Serializable;

import org.dozer.Mapper;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;

import com.swinarta.sunflower.core.manager.CoreManager;
import com.swinarta.sunflower.core.model.ReceivingOrder;
import com.swinarta.sunflower.server.model.DisplayReceivingOrder;
import com.swinarta.sunflower.server.model.SgwtRestFetchResponseBase;
import com.swinarta.sunflower.server.util.RequestUtil;

public class ReceivingOrderByCodeResource extends ServerResource{

  private CoreManager coreManager;
 
  private Mapper mapper;
 
  public void setMapper(Mapper mapper) {
    this.mapper = mapper;
  }
 
  public void setCoreManager(CoreManager coreManager) {
    this.coreManager = coreManager;
  }

  @Get("json")
  public SgwtRestFetchResponseBase getRepresent(){
    Serializable resp = null;
   
    String code = RequestUtil.getString(getRequestAttributes().get("code"));
    ReceivingOrder ro = coreManager.getReceivingOrderByCode(code);
   
    if(ro != null){
      DisplayReceivingOrder disp = mapper.map(ro, DisplayReceivingOrder.class);
      resp = disp;
    }
   
    SgwtRestFetchResponseBase ret = new SgwtRestFetchResponseBase(resp);
    return ret;
   
  }
 
}
TOP

Related Classes of com.swinarta.sunflower.server.resources.ReceivingOrderByCodeResource

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.