PageRenderTime 92ms CodeModel.GetById 40ms app.highlight 1ms RepoModel.GetById 40ms app.codeStats 0ms

/SampleApplication/ColdBox3/model/artist/Artist.cfc

http://github.com/bobsilverberg/ValidateThisColdBoxPlugin
ColdFusion CFScript | 69 lines | 37 code | 8 blank | 24 comment | 2 complexity | 69600bb60ad06c778dba74e903d5e98b MD5 | raw file
 1/**
 2* I am a Artist Persisted Entity
 3* @output false
 4* @table ARTISTS
 5* @persistent true
 6*/
 7component
 8{	
 9	// identifier
10	property name="ArtistID" fieldtype="id" generator="increment"; 
11	
12	// properties
13	property name="Firstname";
14	property name="Lastname";
15	property name="Address";
16	property name="City";
17	property name="State";
18	property name="PostalCode";
19	property name="Email";
20	property name="Phone";
21	property name="Fax";
22	property name="Password" column="ThePassword";
23	
24	/* one artist can have many... */
25
26	/* return an array of Art objects */
27	property name="Art" fieldtype="one-to-many" cfc="Art" fkcolumn="ArtistID" type="array" orderby="Price Asc";
28	
29	/* if we wanted to return a struct of Art objects we'd use this syntax */
30	// property name="Art" fieldtype="one-to-many" cfc="Art" fkcolumn="ArtistID" type="struct" structkeycolumn="ArtID" orderby="Price Asc";
31
32	/**
33	* I return the number of itemd of art associated with this Artist
34	* @output false
35	*/
36	public numeric function getArtCount()
37	{
38		if ( this.hasArt() )
39		{
40			return ArrayLen( this.getArt() ); 
41		}
42		else 
43		{
44			return 0;
45		}
46	}
47	
48	/**
49	* I return the number of items sold for this artist
50	* @output false
51	*/
52	public numeric function getSoldItemsCount()
53	{
54		return ORMExecuteQuery( 
55			"SELECT COUNT(*) FROM Art as ArtEntity WHERE ArtEntity.Artist.ArtistID=:ArtistID AND ArtEntity.IsSold=:IsSold", 
56			{ ArtistID=this.getArtistID(), IsSold=True }
57			, True );
58	}
59	
60	/**
61	* I return the number of itemd of art associated with this Artist
62	* @output false
63	*/
64	public string function getFullname()
65	{
66		return this.getFirstName() & " " & this.getLastname();
67	}
68
69}