001    /**
002     *  Licensed to the Apache Software Foundation (ASF) under one or more
003     *  contributor license agreements.  See the NOTICE file distributed with
004     *  this work for additional information regarding copyright ownership.
005     *  The ASF licenses this file to You under the Apache License, Version 2.0
006     *  (the "License"); you may not use this file except in compliance with
007     *  the License.  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    package org.apache.geronimo.samples.daytrader.ejb;
018    
019    import javax.ejb.*;
020    import org.apache.geronimo.samples.daytrader.*;
021    
022    public abstract class AccountProfileBean
023                    implements EntityBean {
024    
025        private EntityContext context;
026    
027        /* Accessor methods for persistent fields */
028    
029            public abstract String          getUserID();                            /* userID */
030        public abstract void                setUserID(String userID);  
031        public abstract String              getPasswd();                            /* password */
032        public abstract void                setPasswd(String password);
033        public abstract String              getFullName();                          /* fullName */
034        public abstract void                setFullName(String fullName);  
035        public abstract String              getAddress();                           /* address */
036        public abstract void                setAddress(String address);  
037        public abstract String              getEmail();                                     /* email */
038        public abstract void                setEmail(String email);  
039        public abstract String              getCreditCard();                        /* creditCard */
040        public abstract void                setCreditCard(String creditCard);  
041     
042        /* Accessor methods for relationship fields */
043        
044        //Account --> AccountProfile is a unidirectional relationship
045        //          no relationship fields here
046        /* Accessor methods for relationship fields */
047        public abstract LocalAccount        getAccount();                           /* This profile's account */
048        public abstract void                                setAccount(LocalAccount account);    
049    
050    
051        /* Select methods */
052    
053    
054        /* Business methods */
055        public LocalAccount getAccountForUpdate() /* Get ths profile's account with a lock */
056        {
057             return getAccount();
058        }
059        
060            public AccountProfileDataBean updateAccountProfile(AccountProfileDataBean profileData)
061            {
062                    setPasswd(profileData.getPassword());    
063                    setFullName(profileData.getFullName());      
064                    setAddress(profileData.getAddress());  
065                    setEmail(profileData.getEmail());          
066                    setCreditCard(profileData.getCreditCard());      
067                    return getDataBean();
068            }   
069    
070    
071            public AccountProfileDataBean getDataBean()
072            {
073                    return new AccountProfileDataBean(getUserID(),
074                                                                            getPasswd(),
075                                                                            getFullName(),
076                                                                            getAddress(),
077                                                                            getEmail(),
078                                                                            getCreditCard());
079            }
080            
081            
082            public String toString()
083            {
084                    return getDataBean().toString();
085            }
086    
087    
088        /* Required javax.ejb.EntityBean interface methods */
089        public String ejbCreate (String userID, String password, String fullname, 
090                                                            String address, String email, String creditcard)
091        throws CreateException {
092                    
093            setUserID(userID);
094            setPasswd(password);
095            setFullName(fullname);
096            setAddress(address);
097            setEmail(email);
098            setCreditCard(creditcard);
099            
100            return null;
101        }
102    
103        public void ejbPostCreate (String userID, String password, String fullname, 
104                                                            String address, String email, String creditcard)
105    
106            throws CreateException { }
107                
108    
109        public void setEntityContext(EntityContext ctx) {
110            context = ctx;
111        }
112        
113        public void unsetEntityContext() {
114            context = null;
115        }
116        
117        public void ejbRemove() {
118        }
119        
120        public void ejbLoad() {
121        }
122        
123        public void ejbStore() {
124        }
125        
126        public void ejbPassivate() { 
127        }
128        
129        public void ejbActivate() { 
130        }
131    }