Report.java

  1. /*
  2.  * This software was designed and created by Jason Carroll.
  3.  * Copyright (c) 2002, 2003, 2004 Jason Carroll.
  4.  * The author can be reached at jcarroll@cowsultants.com
  5.  * ITracker website: http://www.cowsultants.com
  6.  * ITracker forums: http://www.cowsultants.com/phpBB/index.php
  7.  *
  8.  * This program is free software; you can redistribute it and/or modify
  9.  * it only under the terms of the GNU General Public License as published by
  10.  * the Free Software Foundation; either version 2 of the License, or
  11.  * (at your option) any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  * GNU General Public License for more details.
  17.  */

  18. package org.itracker.model;

  19. import org.apache.commons.lang.builder.CompareToBuilder;
  20. import org.apache.commons.lang.builder.ToStringBuilder;

  21. import java.util.Comparator;

  22. /**
  23.  * This is a POJO Business Domain Object.
  24.  * <p/>
  25.  * <p>
  26.  * Hibernate Bean.
  27.  * </p>
  28.  *
  29.  * @author ready
  30.  */
  31. public class Report extends AbstractEntity {

  32.     public static final Comparator<Report> NAME_COMPARATOR = new NameComparator();
  33.     /**
  34.      *
  35.      */
  36.     private static final long serialVersionUID = 1L;

  37.     private String name;

  38.     private String nameKey;

  39.     private String description;

  40.     private byte[] fileData;

  41.     private String className;

  42.     /**
  43.      * Default constructor (required by Hibernate).
  44.      * <p/>
  45.      * <p>
  46.      * PENDING: should be <code>private</code> so that it can only be used by
  47.      * Hibernate, to ensure that the fields which form an instance's identity
  48.      * are always initialized/never <tt>null</tt>.
  49.      * </p>
  50.      */
  51.     public Report() {
  52.     }

  53.     public String getName() {
  54.         return name;
  55.     }

  56.     public void setName(String name) {
  57.         this.name = name;
  58.     }

  59.     public String getNameKey() {
  60.         return nameKey;
  61.     }

  62.     public void setNameKey(String nameKey) {
  63.         this.nameKey = nameKey;
  64.     }

  65.     public String getClassName() {
  66.         return className;
  67.     }

  68.     public void setClassName(String className) {
  69.         this.className = className;
  70.     }


  71.     public String getDescription() {
  72.         return description;
  73.     }

  74.     public void setDescription(String description) {
  75.         this.description = description;
  76.     }

  77.     public byte[] getFileData() {
  78.         return fileData;
  79.     }

  80.     public void setFileData(byte[] fileData) {
  81.         this.fileData = fileData;
  82.     }

  83.     @Override
  84.     public String toString() {
  85.         return new ToStringBuilder(this).append("id", getId()).append("name",
  86.                 getName()).append("description", getDescription()).append(
  87.                 "nameKey", getNameKey())
  88.                 .toString();
  89.     }

  90.     private static final class NameComparator implements Comparator<Report> {
  91.         public int compare(Report o1, Report o2) {
  92.             return new CompareToBuilder().append(o1.getName(), o2.getName())
  93.                     .append(o1.getNameKey(), o2.getNameKey()).append(
  94.                             o1.getId(), o2.getId()).toComparison();
  95.         }
  96.     }

  97. }