/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. */
  7. component
  8. {
  9. // identifier
  10. property name="ArtistID" fieldtype="id" generator="increment";
  11. // properties
  12. property name="Firstname";
  13. property name="Lastname";
  14. property name="Address";
  15. property name="City";
  16. property name="State";
  17. property name="PostalCode";
  18. property name="Email";
  19. property name="Phone";
  20. property name="Fax";
  21. property name="Password" column="ThePassword";
  22. /* one artist can have many... */
  23. /* return an array of Art objects */
  24. property name="Art" fieldtype="one-to-many" cfc="Art" fkcolumn="ArtistID" type="array" orderby="Price Asc";
  25. /* if we wanted to return a struct of Art objects we'd use this syntax */
  26. // property name="Art" fieldtype="one-to-many" cfc="Art" fkcolumn="ArtistID" type="struct" structkeycolumn="ArtID" orderby="Price Asc";
  27. /**
  28. * I return the number of itemd of art associated with this Artist
  29. * @output false
  30. */
  31. public numeric function getArtCount()
  32. {
  33. if ( this.hasArt() )
  34. {
  35. return ArrayLen( this.getArt() );
  36. }
  37. else
  38. {
  39. return 0;
  40. }
  41. }
  42. /**
  43. * I return the number of items sold for this artist
  44. * @output false
  45. */
  46. public numeric function getSoldItemsCount()
  47. {
  48. return ORMExecuteQuery(
  49. "SELECT COUNT(*) FROM Art as ArtEntity WHERE ArtEntity.Artist.ArtistID=:ArtistID AND ArtEntity.IsSold=:IsSold",
  50. { ArtistID=this.getArtistID(), IsSold=True }
  51. , True );
  52. }
  53. /**
  54. * I return the number of itemd of art associated with this Artist
  55. * @output false
  56. */
  57. public string function getFullname()
  58. {
  59. return this.getFirstName() & " " & this.getLastname();
  60. }
  61. }