CVS: TapestryBook/petstore/src/org/apache/tapestry/pets/domain Address.java,NONE,1.1 UserLogin.java,NONE,1.1 CustomerInfo.java,NONE,1.1 CreditCardInfo.java,NONE,1.1 ItemDetail.java,NONE,1.1 Category.java,NONE,1.1 CategoryDetail.java,NONE,1.1 Petshop.hbm.xml,NONE,1.1 ProductDetail.java,NONE,1.1 Product.java,NONE,1.1 Item.java,NONE,1.1

Howard Lewis Ship <[email protected]>
Newsgroups gmane.comp.java.tapestry.cvs
Message-ID <[email protected]>
Update of /cvsroot/tapestry/TapestryBook/petstore/src/org/apache/tapestry/pets/domain
In directory sc8-pr-cvs1:/tmp/cvs-serv19059/petstore/src/org/apache/tapestry/pets/domain

Added Files:
	Address.java UserLogin.java CustomerInfo.java 
	CreditCardInfo.java ItemDetail.java Category.java 
	CategoryDetail.java Petshop.hbm.xml ProductDetail.java 
	Product.java Item.java 
Log Message:
Add start of petstore application.

--- NEW FILE: Address.java ---
package org.apache.tapestry.pets.domain;

/**
 *  Component object type (not a full fledged entity) used to store
 *  an address.
 *
 *  @author Howard Lewis Ship
 *  @version $Id: Address.java,v 1.1 2003/02/07 16:44:56 hship Exp $
 *
 **/

public class Address
{
	private String _firstName;
	private String _lastName;
	private String _address1;
	private String _address2;
	private String _city;
	private String _state;
	private String _zip;
	private String _country;
	private String _phone;
	
    public String getAddress1()
    {
        return _address1;
    }

    public String getAddress2()
    {
        return _address2;
    }

    public String getCity()
    {
        return _city;
    }

    public String getCountry()
    {
        return _country;
    }

    public String getFirstName()
    {
        return _firstName;
    }

    public String getLastName()
    {
        return _lastName;
    }

    public String getPhone()
    {
        return _phone;
    }

    public String getState()
    {
        return _state;
    }

    public String getZip()
    {
        return _zip;
    }

    public void setAddress1(String address1)
    {
        _address1 = address1;
    }

    public void setAddress2(String address2)
    {
        _address2 = address2;
    }

    public void setCity(String city)
    {
        _city = city;
    }

    public void setCountry(String country)
    {
        _country = country;
    }

    public void setFirstName(String firstName)
    {
        _firstName = firstName;
    }

    public void setLastName(String lastName)
    {
        _lastName = lastName;
    }

    public void setPhone(String phone)
    {
        _phone = phone;
    }

    public void setState(String state)
    {
        _state = state;
    }

    public void setZip(String zip)
    {
        _zip = zip;
    }

}

--- NEW FILE: UserLogin.java ---
package org.apache.tapestry.pets.domain;

/**
 *  Persistent class that stores user login information.
 *
 *  @author Howard Lewis Ship
 *  @version $Id: UserLogin.java,v 1.1 2003/02/07 16:44:56 hship Exp $
 *
 **/

public class UserLogin
{
	private String _userId;
	private String _password;
	
    public String getPassword()
    {
        return _password;
    }

    public String getUserId()
    {
        return _userId;
    }

    public void setPassword(String password)
    {
        _password = password;
    }

    public void setUserId(String userId)
    {
        _userId = userId;
    }

}

--- NEW FILE: CustomerInfo.java ---
package org.apache.tapestry.pets.domain;

/**
 *  Persistent class that stores information about a customer, including
 *  preferences, default address, and credit card information.
 *
 *  @author Howard Lewis Ship
 *  @version $Id: CustomerInfo.java,v 1.1 2003/02/07 16:44:56 hship Exp $
 *
 **/
public class CustomerInfo
{
	private Long _id;
	private String _userName;
	private Address _primaryAddress;
	private CreditCardInfo _creditCard;
	private String _favoriteCategory;
	private boolean _enableMyList;
	private boolean _enableBanner;
	
    public CreditCardInfo getCreditCard()
    {
        return _creditCard;
    }

    public boolean isEnableBanner()
    {
        return _enableBanner;
    }

    public boolean isEnableMyList()
    {
        return _enableMyList;
    }

    public String getFavoriteCategory()
    {
        return _favoriteCategory;
    }

    public Long getId()
    {
        return _id;
    }

    public Address getPrimaryAddress()
    {
        return _primaryAddress;
    }

    public String getUserName()
    {
        return _userName;
    }

    public void setCreditCard(CreditCardInfo creditCard)
    {
        _creditCard = creditCard;
    }

    public void setEnableBanner(boolean enableBanner)
    {
        _enableBanner = enableBanner;
    }

    public void setEnableMyList(boolean enableMyList)
    {
        _enableMyList = enableMyList;
    }

    public void setFavoriteCategory(String favoriteCategory)
    {
        _favoriteCategory = favoriteCategory;
    }

    public void setId(Long id)
    {
        _id = id;
    }

    public void setPrimaryAddress(Address primaryAddress)
    {
        _primaryAddress = primaryAddress;
    }

    public void setUserName(String userName)
    {
        _userName = userName;
    }

}

--- NEW FILE: CreditCardInfo.java ---
package org.apache.tapestry.pets.domain;

/**
 *  Component data class for storing credit card information.
 *
 *  @author Howard Lewis Ship
 *  @version $Id: CreditCardInfo.java,v 1.1 2003/02/07 16:44:56 hship Exp $
 *
 **/

public class CreditCardInfo
{
    private String _type;
    private String _number;
    private int _expirationMonth;
    private int _expirationYear;

    /**
     *  Month of expiration, with January as 1, February as 2, ...
     * 
     **/

    public int getExpirationMonth()
    {
        return _expirationMonth;
    }

	/**
	 *  Year of expiration, as natural four digit number.
	 * 
	 **/
	
    public int getExpirationYear()
    {
        return _expirationYear;
    }

	/**
	 *  The formatted card number, typically sixteen digits plus punctuation.
	 * 
	 **/
	
    public String getNumber()
    {
        return _number;
    }

	/**
	 *  Encoding of the card type (may switch to an Enum soon).
	 * 
	 **/
	
    public String getType()
    {
        return _type;
    }

    public void setExpirationMonth(int expirationMonth)
    {
        _expirationMonth = expirationMonth;
    }

    public void setExpirationYear(int expirationYear)
    {
        _expirationYear = expirationYear;
    }

    public void setNumber(String number)
    {
        _number = number;
    }

    public void setType(String type)
    {
        _type = type;
    }

}

--- NEW FILE: ItemDetail.java ---
package org.apache.tapestry.pets.domain;

import java.util.ArrayList;
import java.util.List;

/**
 *  Detail about a specific item, including the name, description and image
 *  (in a particular locale) and the unit cost and list price
 *  (in a currency implicitly determined from the language).
 *  In addition, a number of attributes are allowed.  Attributes are
 *  localized strings that further describe the item.
 * 
 **/

public class ItemDetail
{
    private Long _id;
    private String _language;
    private double _unitCost;
    private double _listPrice;
    private String _name;
    private String _description;
    private String _image;
    private String _attribute1;
    private String _attribute2;
    private String _attribute3;
    private String _attribute4;
    private String _attribute5;

    public List getAttributes()
    {
        List result = new ArrayList();

        add(result, _attribute1);
        add(result, _attribute2);
        add(result, _attribute3);
        add(result, _attribute4);
        add(result, _attribute5);

        return result;
    }

    private void add(List list, String value)
    {
        if (value == null || value.length() == 0)
            return;

        list.add(value);
    }

    public String getAttribute1()
    {
        return _attribute1;
    }

    public String getAttribute2()
    {
        return _attribute2;
    }

    public String getAttribute3()
    {
        return _attribute3;
    }

    public String getAttribute4()
    {
        return _attribute4;
    }

    public String getAttribute5()
    {
        return _attribute5;
    }

    public String getDescription()
    {
        return _description;
    }

    public Long getId()
    {
        return _id;
    }

    public String getImage()
    {
        return _image;
    }

    public String getLanguage()
    {
        return _language;
    }

    public double getListPrice()
    {
        return _listPrice;
    }

    public String getName()
    {
        return _name;
    }

    public double getUnitCost()
    {
        return _unitCost;
    }

    public void setAttribute1(String attribute1)
    {
        _attribute1 = attribute1;
    }

    public void setAttribute2(String attribute2)
    {
        _attribute2 = attribute2;
    }

    public void setAttribute3(String attribute3)
    {
        _attribute3 = attribute3;
    }

    public void setAttribute4(String attribute4)
    {
        _attribute4 = attribute4;
    }

    public void setAttribute5(String attribute5)
    {
        _attribute5 = attribute5;
    }

    public void setDescription(String description)
    {
        _description = description;
    }

    public void setId(Long id)
    {
        _id = id;
    }

    public void setImage(String image)
    {
        _image = image;
    }

    public void setLanguage(String language)
    {
        _language = language;
    }

    public void setListPrice(double listPrice)
    {
        _listPrice = listPrice;
    }

    public void setName(String name)
    {
        _name = name;
    }

    public void setUnitCost(double unitCost)
    {
        _unitCost = unitCost;
    }

}

--- NEW FILE: Category.java ---
package org.apache.tapestry.pets.domain;

import java.util.Set;

/**
 *  A category is a general type of creature
 *  that may be available.  The initial
 *  set of categories are birds, fish, dogs, etc.
 *
 *  @author Howard Lewis Ship
 *  @version $Id: Category.java,v 1.1 2003/02/07 16:44:57 hship Exp $
 *
 **/

public class Category
{
	private String _id;
	private Set _categoryDetails;
	
    public Set getCategoryDetails()
    {
        return _categoryDetails;
    }

    public String getId()
    {
        return _id;
    }

    public void setCategoryDetails(Set categoryDetails)
    {
        _categoryDetails = categoryDetails;
    }

    public void setId(String id)
    {
        _id = id;
    }

}

--- NEW FILE: CategoryDetail.java ---
package org.apache.tapestry.pets.domain;

/**
 *  Stores the details of a category in a
 *  specific languge.  Each 
 *  {@link org.apache.tapestry.pets.domain.Category}
 *  contains a number of details.  At runtime,
 *  the one matching the user's prefered language
 *  is selected.
 *
 *  @author Howard Lewis Ship
 *  @version $Id: CategoryDetail.java,v 1.1 2003/02/07 16:44:57 hship Exp $
 *
 **/

public class CategoryDetail
{
	private Long _id;
	private Category _category;
	private String _language;
	private String _name;
	private String _description;
	private String _image;
	
    public String getDescription()
    {
        return _description;
    }

    public Long getId()
    {
        return _id;
    }

    public String getImage()
    {
        return _image;
    }

    public String getLanguage()
    {
        return _language;
    }

    public String getName()
    {
        return _name;
    }

    public void setDescription(String description)
    {
        _description = description;
    }

    public void setId(Long id)
    {
        _id = id;
    }

    public void setImage(String image)
    {
        _image = image;
    }

    public void setLanguage(String language)
    {
        _language = language;
    }

    public void setName(String name)
    {
        _name = name;
    }

    public Category getCategory()
    {
        return _category;
    }

    public void setCategory(Category category)
    {
        _category = category;
    }

}

--- NEW FILE: Petshop.hbm.xml ---
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-1.1.dtd">

<hibernate-mapping>

	<class 
		name="org.apache.tapestry.pets.domain.UserLogin"
		table="USER_LOGIN">
		<id	name="id" column="USER_ID" type="string">
			<generator class="assigned"/>
		</id>
		
		<property name="password" column="PASSWORD" type="string"/>
		
	</class>
	
	<class
		name="org.apache.tapestry.pets.domain.CustomerInfo"
		table="CUST_INFO">
	
		<id	name="id" column="ID" type="long">
			<generator class="sequence"/>
		</id>
		
		<property name="userName" column="USER_NAME" type="string"/>
		
		<component name="primaryAddress" class="org.apache.tapestry.pets.domain.Address">
			<property name="firstName" column="FIRST_NAME" type="string"/>
			<property name="lastName" column="LAST_NAME" type="string"/>
			<property name="address1" column="ADDR_1" type="string"/>
			<property name="address2" column="ADDR_2" type="string"/>
			<property name="city" column="CITY" type="string"/>
			<property name="state" column="STATE" type="string"/>
			<property name="zip" column="ZIP" type="string"/>
			<property name="country" column="COUNTRY" type="string"/>
			<property name="phone" column="PHONE" type="string"/>
		</component>
		
		<component name="creditCard" class="org.apache.tapestry.pets.domain.CreditCardInfo">
			<property name="type" column="CC_TYPE" type="string"/>
			<property name="number" column="CC_NUMBER" type="string"/>
			<property name="expirationMonth" column="CC_EXP_MONTH" type="integer"/>
			<property name="expirationYear" column="CC_EXP_YEAR" type="integer"/>
		</component>
		
		<property name="favoriteCategory" column="FAVORITE_CATEGORY_ID" type="string"/>
		<property name="enableMyList" column="ENABLE_MY_LIST" type="boolean"/>
		<property name="enableBanner" column="ENABLE_BANNER" type="boolean"/>
	</class>
	
	<class
		name="org.apache.tapestry.pets.domain.Category"
		table="CATEGORY">
	
		<id name="id" column="ID" type="string">
			<generator class="assigned"/>
		</id>
		
		<set role="categoryDetails" table="CAT_DETAIL">
			<key column="CATEGORY_ID"/>
			<one-to-many class="org.apache.tapestry.pets.domain.CategoryDetail"/>
		</set>
	</class>
	
	<class
		name="org.apache.tapestry.pets.domain.CategoryDetail"
		table="CAT_DETAIL">
		<id name="id" column="ID" type="long">
			<generator class="sequence"/>
		</id>
		
		<property name="language" column="LANG" type="string"/>
		<property name="name" column="NAME" type="string"/>
		<property name="description" column="NAME" type="string"/>
		<property name="image" column="IMAGE" type="string"/>
		
	</class>
	
	<class
		name="org.apache.tapestry.pets.domain.Product"
		table="PRODUCT">
		<id name="id" column="ID" type="string">
			<generator class="assigned"/>
		</id>
		
		<many-to-one
			name="category"
			column="CATEGORY_ID"
			class="org.apache.tapestry.pets.domain.Category"/>

		<set role="productDetails" table="PROD_DETAIL">
			<key column="PRODUCT_ID"/>
			<one-to-many class="org.apache.tapestry.pets.domain.ProductDetail"/>
		</set>		
	</class>
			
	<class
		name="org.apache.tapestry.pets.domain.ProductDetail"
		table="PROD_DETAIL">
		<id name="id" column="ID" type="long">
			<generator class="sequence"/>
		</id>
		
		<property name="language" column="LANG" type="string"/>
		<property name="name" column="NAME" type="string"/>
		<property name="description" column="NAME" type="string"/>
		<property name="image" column="IMAGE" type="string"/>
		
	</class>
	
	<class
		name="org.apache.tapestry.pets.domain.Item"
		table="ITEM">
		
		<id name="id" column="ID" type="string">
			<generator class="assigned"/>
		</id>
		
		<many-to-one
			name="product"
			column="PRODUCT_ID"
			class="org.apache.tapestry.pets.domain.Product"/>

		<set role="itemDetails" table="ITEM_DETAIL">
			<key column="ITEM_ID"/>
			<one-to-many class="org.apache.tapestry.pets.domain.ItemDetail"/>
		</set>
	</class>
	
	<class
		name="org.apache.tapestry.pets.domain.ItemDetail"
		table="ITEM_DETAIL">
	
		<id name="id" column="ID" type="long">
			<generator class="sequence"/>
		</id>	
		
		<property name="language" column="LANGUAGE" type="string"/>
		<property name="unitCost" column="UNIT_COST" type="double"/>
		<property name="listPrice" column="LIST_PRICE" type="double"/>
		<property name="name" column="NAME" type="string"/>
		<property name="description" column="DESCRIPTION" type="string"/>
		<property name="image" column="IMAGE" type="string"/>
		
		<property name="attribute1" column="ATTR_1" type="string"/>
		<property name="attribute2" column="ATTR_2" type="string"/>
		<property name="attribute3" column="ATTR_3" type="string"/>
		<property name="attribute4" column="ATTR_4" type="string"/>
		<property name="attribute5" column="ATTR_5" type="string"/>

	</class>
	
	
</hibernate-mapping>
--- NEW FILE: ProductDetail.java ---
package org.apache.tapestry.pets.domain;

public class ProductDetail
{
	private Long _id;
	private String _language;
	private String _name;
	private String _description;
	private String _image;
	
    public Long getId()
    {
        return _id;
    }

    public String getImage()
    {
        return _image;
    }

    public String getLanguage()
    {
        return _language;
    }

    public String getName()
    {
        return _name;
    }

    public void setId(Long id)
    {
        _id = id;
    }

    public void setImage(String image)
    {
        _image = image;
    }

    public void setLanguage(String language)
    {
        _language = language;
    }

    public void setName(String name)
    {
        _name = name;
    }

}

--- NEW FILE: Product.java ---
package org.apache.tapestry.pets.domain;

import java.util.Set;

/**
 *  Really, more of a product family within
 *  a {@link org.apache.tapestry.pets.domain.Category}.
 * 
 * 
 **/

public class Product
{
	private String _id;
	private Category _category;
	private Set _productDetails;
	
    public Category getCategory()
    {
        return _category;
    }

    public String getId()
    {
        return _id;
    }

    public Set getProductDetails()
    {
        return _productDetails;
    }

    public void setCategory(Category category)
    {
        _category = category;
    }

    public void setId(String id)
    {
        _id = id;
    }

    public void setProductDetails(Set productDetails)
    {
        _productDetails = productDetails;
    }

}

--- NEW FILE: Item.java ---
package org.apache.tapestry.pets.domain;

import java.util.Set;

/**
 *  A particular item within a Product; this
 *  is finally an item specific enough to be
 *  purchased.
 * 
 **/

public class Item
{
	private String _id;
	private Product _product;
	private Set _itemDetails;
	
    public String getId()
    {
        return _id;
    }

    public Set getItemDetails()
    {
        return _itemDetails;
    }

    public Product getProduct()
    {
        return _product;
    }

    public void setId(String id)
    {
        _id = id;
    }

    public void setItemDetails(Set itemDetails)
    {
        _itemDetails = itemDetails;
    }

    public void setProduct(Product product)
    {
        _product = product;
    }

}



-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.