// Path: src/main/java/act/aaa/model/UserLinked.java
// public interface UserLinked {
// 
//     boolean isLinkedTo(Principal user);
// 
//     class DynamicPermissionChecker extends DynamicPermissionCheckHelperBase<UserLinked> {
//         @Override
//         public boolean isAssociated(UserLinked target, Principal user) {
//             return target.isLinkedTo(user);
//         }
//     }
// 
// }
// 
// Path: testapps/morphia_model/src/main/java/test/endpoint/CustomerLinked.java
// public interface CustomerLinked {
// 
//     boolean isLinkedToCustomer(Principal principal);
// 
//     class DynamicPermissionChecker extends DynamicPermissionCheckHelperBase<CustomerLinked> {
//         @Override
//         public boolean isAssociated(CustomerLinked target, Principal user) {
//             return target.isLinkedToCustomer(user);
//         }
// 
//         @Override
//         protected List<String> permissionNames() {
//             return C.list("view-my-order");
//         }
//     }
// 
// }


import act.aaa.model.UserLinked;
import act.db.morphia.MorphiaAdaptiveRecord;
import act.db.morphia.MorphiaDao;
import act.util.Stateless;
import org.mongodb.morphia.annotations.Entity;
import org.osgl.aaa.Principal;
import org.osgl.util.S;
import test.endpoint.CustomerLinked;
package test.model;


@Entity("order")
public class Order extends MorphiaAdaptiveRecord<Order> implements UserLinked, CustomerLinked {

    public String agent;

    public String customer;

    public String product;

    public int quantity;

    @Override
    public boolean isLinkedTo(Principal user) {
        String username = user.getName();
        return S.eq(username, agent);
    }

    @Override
    public boolean isLinkedToCustomer(Principal principal) {
        String username = principal.getName();
        return S.eq(username, customer);
    }

    @Stateless
// Path: src/main/java/act/aaa/model/UserLinked.java
// public interface UserLinked {
// 
//     boolean isLinkedTo(Principal user);
// 
//     class DynamicPermissionChecker extends DynamicPermissionCheckHelperBase<UserLinked> {
//         @Override
//         public boolean isAssociated(UserLinked target, Principal user) {
//             return target.isLinkedTo(user);
//         }
//     }
// 
// }
// 
// Path: testapps/morphia_model/src/main/java/test/endpoint/CustomerLinked.java
// public interface CustomerLinked {
// 
//     boolean isLinkedToCustomer(Principal principal);
// 
//     class DynamicPermissionChecker extends DynamicPermissionCheckHelperBase<CustomerLinked> {
//         @Override
//         public boolean isAssociated(CustomerLinked target, Principal user) {
//             return target.isLinkedToCustomer(user);
//         }
// 
//         @Override
//         protected List<String> permissionNames() {
//             return C.list("view-my-order");
//         }
//     }
// 
// }


// Path: testapps/morphia_model/src/main/java/test/model/Order.java
import act.aaa.model.UserLinked;
import act.db.morphia.MorphiaAdaptiveRecord;
import act.db.morphia.MorphiaDao;
import act.util.Stateless;
import org.mongodb.morphia.annotations.Entity;
import org.osgl.aaa.Principal;
import org.osgl.util.S;
import test.endpoint.CustomerLinked;

package test.model;


@Entity("order")
public class Order extends MorphiaAdaptiveRecord<Order> implements UserLinked, CustomerLinked {

    public String agent;

    public String customer;

    public String product;

    public int quantity;

    @Override
    public boolean isLinkedTo(Principal user) {
        String username = user.getName();
        return S.eq(username, agent);
    }

    @Override
    public boolean isLinkedToCustomer(Principal principal) {
        String username = principal.getName();
        return S.eq(username, customer);
    }

    @Stateless
    public static class Dao extends MorphiaDao<Order> {