// Path: testapps/jpa_model_id/src/main/java/jpa_test/model/Order.java
// @Entity(name = "orders")
// public class Order implements SimpleBean, UserLinked, CustomerLinked {
// 
//     @Id
//     @GeneratedValue(strategy = GenerationType.IDENTITY)
//     public Long id;
// 
//     @ManyToOne(optional = false)
//     @JoinColumn(name = "agent_id")
//     public User agent;
// 
//     @ManyToOne(optional = false)
//     @JoinColumn(name = "cust_id", nullable = false)
//     public User customer;
// 
//     public String product;
// 
//     public int quantity;
// 
//     @Override
//     public boolean isLinkedTo(Principal user) {
//         String agentName = null == agent ? null : agent.email;
//         String username = user.getName();
//         return S.eq(username, agentName);
//     }
// 
//     @Override
//     public boolean isLinkedToCustomer(Principal principal) {
//         String customerName = null == customer ? null : customer.email;
//         String username = principal.getName();
//         return S.eq(username, customerName);
//     }
// 
//     @Stateless
//     public static class Dao extends JPADao<Long, Order> {
//     }
// 
// }
// 
// Path: testapps/jpa_model_id/src/main/java/jpa_test/model/User.java
// @Entity(name = "user")
// public class User extends UserBase implements UserLinked {
// 
//     @Id
//     @GeneratedValue(strategy = GenerationType.IDENTITY)
//     public Long id;
// 
//     public String firstName;
//     public String lastName;
// 
//     @Override
//     public boolean isLinkedTo(Principal user) {
//         return S.eq(email, user.getName());
//     }
// 
//     @Stateless
//     public static class Dao extends JPADao<Long, User> {
// 
//         public User findByUsername(String username) {
//             return findOneBy("email", username);
//         }
// 
//         public boolean authenticate(String username, char[] password) {
//             User user = findByUsername(username);
//             if (null == user) {
//                 return false;
//             }
//             return user.verifyPassword(password);
//         }
// 
//     }
// }


import act.controller.annotation.UrlContext;
import act.db.DbBind;
import org.osgl.aaa.AAA;
import org.osgl.mvc.annotation.GetAction;
import jpa_test.model.Order;
import jpa_test.model.User;
package jpa_test.endpoint;


@UrlContext("my")
public class MyService extends AuthenticatedServiceBaseV1 {

    @GetAction
    public User myProfile() {
        AAA.requirePermission(me, "view-my-profile");
        return me;
    }

    @GetAction("orders/{order}")
// Path: testapps/jpa_model_id/src/main/java/jpa_test/model/Order.java
// @Entity(name = "orders")
// public class Order implements SimpleBean, UserLinked, CustomerLinked {
// 
//     @Id
//     @GeneratedValue(strategy = GenerationType.IDENTITY)
//     public Long id;
// 
//     @ManyToOne(optional = false)
//     @JoinColumn(name = "agent_id")
//     public User agent;
// 
//     @ManyToOne(optional = false)
//     @JoinColumn(name = "cust_id", nullable = false)
//     public User customer;
// 
//     public String product;
// 
//     public int quantity;
// 
//     @Override
//     public boolean isLinkedTo(Principal user) {
//         String agentName = null == agent ? null : agent.email;
//         String username = user.getName();
//         return S.eq(username, agentName);
//     }
// 
//     @Override
//     public boolean isLinkedToCustomer(Principal principal) {
//         String customerName = null == customer ? null : customer.email;
//         String username = principal.getName();
//         return S.eq(username, customerName);
//     }
// 
//     @Stateless
//     public static class Dao extends JPADao<Long, Order> {
//     }
// 
// }
// 
// Path: testapps/jpa_model_id/src/main/java/jpa_test/model/User.java
// @Entity(name = "user")
// public class User extends UserBase implements UserLinked {
// 
//     @Id
//     @GeneratedValue(strategy = GenerationType.IDENTITY)
//     public Long id;
// 
//     public String firstName;
//     public String lastName;
// 
//     @Override
//     public boolean isLinkedTo(Principal user) {
//         return S.eq(email, user.getName());
//     }
// 
//     @Stateless
//     public static class Dao extends JPADao<Long, User> {
// 
//         public User findByUsername(String username) {
//             return findOneBy("email", username);
//         }
// 
//         public boolean authenticate(String username, char[] password) {
//             User user = findByUsername(username);
//             if (null == user) {
//                 return false;
//             }
//             return user.verifyPassword(password);
//         }
// 
//     }
// }


// Path: testapps/jpa_model_id/src/main/java/jpa_test/endpoint/MyService.java
import act.controller.annotation.UrlContext;
import act.db.DbBind;
import org.osgl.aaa.AAA;
import org.osgl.mvc.annotation.GetAction;
import jpa_test.model.Order;
import jpa_test.model.User;

package jpa_test.endpoint;


@UrlContext("my")
public class MyService extends AuthenticatedServiceBaseV1 {

    @GetAction
    public User myProfile() {
        AAA.requirePermission(me, "view-my-profile");
        return me;
    }

    @GetAction("orders/{order}")
    public Order myOrder(@DbBind Order order) {