// Path: reladomo-tour/tour-examples/simple-bank/src/main/java/simplebank/domain/Customer.java
// public class Customer extends CustomerAbstract
// {
//     public Customer()
//     {
//         super();
//         // You must not modify this constructor. Mithra calls this internally.
//         // You can call this constructor. You can also add new constructors.
//     }
// 
//     public Customer(int customerId, String firstName, String lastName)
//     {
//         super();
//         this.setCustomerId(customerId);
//         this.setFirstName(firstName);
//         this.setLastName(lastName);
//     }
// }
// 
// Path: reladomo-tour/tour-examples/simple-bank/src/main/java/simplebank/domain/CustomerList.java
// public class CustomerList extends CustomerListAbstract
// {
//     public CustomerList()
//     {
//         super();
//     }
// 
//     public CustomerList(int initialSize)
//     {
//         super(initialSize);
//     }
// 
//     public CustomerList(Collection c)
//     {
//         super(c);
//     }
// 
//     public CustomerList(Operation operation)
//     {
//         super(operation);
//     }
// }


import com.fasterxml.jackson.core.JsonProcessingException;
import com.gs.fw.common.mithra.MithraManager;
import com.gs.fw.common.mithra.util.serializer.SerializationConfig;
import com.gs.fw.common.mithra.util.serializer.Serialized;
import com.gs.fw.common.mithra.util.serializer.SerializedList;
import simplebank.domain.Customer;
import simplebank.domain.CustomerFinder;
import simplebank.domain.CustomerList;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
/*
Copyright 2016 Goldman Sachs.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
*/

package simplebank.web;



@Path("/api/customer")
public class CustomerResource
{
    private final SerializationConfig serializationConfig;

    public CustomerResource()
    {
        this.serializationConfig = SerializationConfig
                .shallowWithDefaultAttributes(CustomerFinder.getFinderInstance());
        serializationConfig.withDeepDependents();
    }

    @POST
    public Response createCustomer(
            @FormParam("customerId") int customerId,
            @FormParam("firstName") String firstName,
            @FormParam("lastName") String lastName)
    {
        Customer customer = new Customer();
        customer.setCustomerId(customerId);
        customer.setFirstName(firstName);
        customer.setLastName(lastName);
        customer.insert();
        return Response.ok().build();
    }

    @GET
    @Path("/{id}")
// Path: reladomo-tour/tour-examples/simple-bank/src/main/java/simplebank/domain/Customer.java
// public class Customer extends CustomerAbstract
// {
//     public Customer()
//     {
//         super();
//         // You must not modify this constructor. Mithra calls this internally.
//         // You can call this constructor. You can also add new constructors.
//     }
// 
//     public Customer(int customerId, String firstName, String lastName)
//     {
//         super();
//         this.setCustomerId(customerId);
//         this.setFirstName(firstName);
//         this.setLastName(lastName);
//     }
// }
// 
// Path: reladomo-tour/tour-examples/simple-bank/src/main/java/simplebank/domain/CustomerList.java
// public class CustomerList extends CustomerListAbstract
// {
//     public CustomerList()
//     {
//         super();
//     }
// 
//     public CustomerList(int initialSize)
//     {
//         super(initialSize);
//     }
// 
//     public CustomerList(Collection c)
//     {
//         super(c);
//     }
// 
//     public CustomerList(Operation operation)
//     {
//         super(operation);
//     }
// }


// Path: reladomo-tour/tour-examples/simple-bank/src/main/java/simplebank/web/CustomerResource.java
import com.fasterxml.jackson.core.JsonProcessingException;
import com.gs.fw.common.mithra.MithraManager;
import com.gs.fw.common.mithra.util.serializer.SerializationConfig;
import com.gs.fw.common.mithra.util.serializer.Serialized;
import com.gs.fw.common.mithra.util.serializer.SerializedList;
import simplebank.domain.Customer;
import simplebank.domain.CustomerFinder;
import simplebank.domain.CustomerList;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

/*
Copyright 2016 Goldman Sachs.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
*/

package simplebank.web;



@Path("/api/customer")
public class CustomerResource
{
    private final SerializationConfig serializationConfig;

    public CustomerResource()
    {
        this.serializationConfig = SerializationConfig
                .shallowWithDefaultAttributes(CustomerFinder.getFinderInstance());
        serializationConfig.withDeepDependents();
    }

    @POST
    public Response createCustomer(
            @FormParam("customerId") int customerId,
            @FormParam("firstName") String firstName,
            @FormParam("lastName") String lastName)
    {
        Customer customer = new Customer();
        customer.setCustomerId(customerId);
        customer.setFirstName(firstName);
        customer.setLastName(lastName);
        customer.insert();
        return Response.ok().build();
    }

    @GET
    @Path("/{id}")
    @Produces(MediaType.APPLICATION_JSON)