Package xpetstore.domain

Examples of xpetstore.domain.Customer


        try
        {
            tx = s.beginTransaction(  );

            /* Customer */
            Customer cst = ( Customer ) s.load( Customer.class, getUserId(  ) );

            /* Order + Items*/
            Order    order = new Order( cst );
            Map      cart = getCart(  );
            Iterator it = cart.keySet(  ).iterator(  );

            while ( it.hasNext(  ) )
            {
                String  itemId = ( String ) it.next(  );
                Item    item = ( Item ) s.load( Item.class, itemId );
                Integer quantity = ( Integer ) cart.get( itemId );
                order.add( item, quantity.intValue(  ) );
            }

            /* Save */
            s.save( order );
            tx.commit(  );

            /* Empty the cart */
            getCart(  ).clear(  );

            /* send the email */
            String subject = "[xpetstore] Order Confimation";
            String body = "Your order has been submitted.\nThe order number is: " + order.getOrderId(  );

            try
            {
                MailUtil.send( cst.getEmail(  ), subject, body );
            }
            catch ( Exception e )
            {
                _log.error( "Unexpected error while sending email", e );
            }
View Full Code Here


    {
        Session s = getHibernateSession(  );

        try
        {
            Customer c = ( Customer ) s.load( Customer.class, _userId );

            if ( c.getAccount(  ).matchPassword( _password ) )
            {
                initSession( c );

                /* Redirect */
                if ( ( _redirectUri != null ) && ( _redirectUri.length(  ) > 0 ) )
View Full Code Here

     */
    public void save( Customer customer,
                      Session  session )
        throws Exception
    {
        Customer cst = ( Customer ) session.load( Customer.class, customer.getUserId(  ) );
        cst.set( customer );
        session.update( cst );
    }
View Full Code Here

            tx = s.beginTransaction(  );

            /* Make sure that the user-id is unique */
            try
            {
                Customer c = ( Customer ) s.load( Customer.class, customerId );

                if ( !c.getUserId(  ).equalsIgnoreCase( _customer.getUserId(  ) ) )
                {
                    addError( "customer", getText( "duplicate_account" ) );

                    return ERROR;
                }
            }
            catch ( ObjectNotFoundException o ) {}

            /* Make sure that the email is unique */
            String     oql = "FROM cst IN CLASS " + Customer.class + " WHERE cst.email=?";
            Collection col = s.find( oql, _customer.getEmail(  ), Hibernate.STRING );

            if ( col.size(  ) > 0 )
            {
                Customer c = ( Customer ) col.iterator(  ).next(  );

                if ( !c.getUserId(  ).equalsIgnoreCase( customerId ) )
                {
                    addError( "customer", getText( "duplicate_email" ) );

                    return ERROR;
                }
View Full Code Here

TOP

Related Classes of xpetstore.domain.Customer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.