package ${packageName};

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

import javax.validation.Valid;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.NonUniqueObjectException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.http.*;

import ${domainPackageName}.*;
import edu.uiowa.icts.exception.EntityNotFoundException;
import edu.uiowa.icts.spring.GenericDaoListOptions;

/**
 * Generated by Protogen 
 * @since ${date}
 */
@RestController( value = "${resourceName}" )
@RequestMapping( "${pathPrefix}" )
public class ${className} extends ${abstractApiResourceClassName} {

    private static final Log log = LogFactory.getLog( ${className}.class );
    
    @RequestMapping( value = { "{${lowerDomainName}Id}" }, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE )
    public ${domainName} get( @PathVariable( "${lowerDomainName}Id" ) ${domainClass.getPrimaryKey().getAttribute().getJavaTypeClass()} ${lowerDomainName}Id ) {
    	 ${domainName} ${lowerDomainName} = ${daoServiceName}.get${domainName}Service().findById( ${lowerDomainName}Id );
		 if (${lowerDomainName} == null){
			 throw new EntityNotFoundException();
		 } 
	     return ${lowerDomainName};
    }
    
    @RequestMapping( method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE  )
    public ${domainName} create( @RequestBody @Valid ${domainName} ${lowerDomainName} ) {
		 ${daoServiceName}.get${domainName}Service().save( ${lowerDomainName} );
		 return ${lowerDomainName};
    }
    
    @RequestMapping( value = { "{${lowerDomainName}Id}" }, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE  )
    public ${domainName} update( @PathVariable( "${lowerDomainName}Id" ) ${domainClass.getPrimaryKey().getAttribute().getJavaTypeClass()} ${lowerDomainName}Id, @RequestBody @Valid ${domainName} ${lowerDomainName} ) {
    	${domainName} ${lowerDomainName}Record = ${daoServiceName}.get${domainName}Service().findById( ${lowerDomainName}Id );
    	if ( ${lowerDomainName}Record == null || !${lowerDomainName}Record.get${domainClass.getPrimaryKey().getUpperIdentifier()}().equals(${lowerDomainName}.get${domainClass.getPrimaryKey().getUpperIdentifier()}())){
			 throw new EntityNotFoundException(); 
		 } 
    	 ${daoServiceName}.get${domainName}Service().getSession().flush();
         ${daoServiceName}.get${domainName}Service().getSession().clear();
		 ${daoServiceName}.get${domainName}Service().update( ${lowerDomainName} );
		 return ${lowerDomainName};
    }
    
    @RequestMapping( value = { "{${lowerDomainName}Id}" }, method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE )
    public String delete( @PathVariable( "${lowerDomainName}Id" ) ${domainClass.getPrimaryKey().getAttribute().getJavaTypeClass()} ${lowerDomainName}Id ) {
    	${domainName} ${lowerDomainName} = ${daoServiceName}.get${domainName}Service().findById( ${lowerDomainName}Id );
		 if ( ${lowerDomainName} == null ){
			 throw new EntityNotFoundException();
		 } 
		 ${daoServiceName}.get${domainName}Service().delete(${lowerDomainName});
	     return "";
    }
    
    @RequestMapping( value = {  "", "/"  }, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE )
    public List<${domainName}> list() {
    	 return ${daoServiceName}.get${domainName}Service().list();
    }

}
@@ -2214,32 +2214,34 @@
 Id%7D%22 %7D, method =
+ %7B
  RequestMethod.P
@@ -2236,32 +2236,53 @@
 uestMethod.POST,
+ RequestMethod.PUT %7D,
  produces = Medi

add PUT to rest resource edit