1 5 package com.nightlabs.ipanema.store; 6 7 import java.io.Serializable ; 8 import java.util.Date ; 9 10 import com.nightlabs.ipanema.security.User; 11 12 27 public class ProductStatus 28 implements Serializable { 30 34 private String organisationID; 35 36 40 private String productID; 41 42 45 private int statusID; 46 47 50 private ProductStatusTracker productStatusTracker; 51 52 55 private Product product; 56 57 61 private String status; 62 63 private Date timestamp; 64 65 69 public static final String STATUS_BLOCKED = "blocked"; 70 71 75 public static final String STATUS_AVAILABLE = "available"; 76 77 82 public static final String STATUS_ALLOCATED = "allocated"; 83 84 88 public static final String STATUS_RESERVED = "reserved"; 89 90 94 public static final String STATUS_SOLD = "sold"; 95 96 102 private boolean hollow; 103 104 public static boolean isValidStatus(String status) 105 { 106 return 107 STATUS_BLOCKED.equals(status) || 108 STATUS_AVAILABLE.equals(status) || 109 STATUS_ALLOCATED.equals(status) || 110 STATUS_RESERVED.equals(status) || 111 STATUS_SOLD.equals(status); 112 } 113 114 public static void assertValidStatus(String status) 115 { 116 if (!isValidStatus(status)) 117 throw new IllegalArgumentException ("Status \""+status+"\" is not valid!"); 118 } 119 120 126 private User user; 127 128 public ProductStatus() { } 129 130 public ProductStatus(ProductStatusTracker productStatusRegistry, User user, int statusID, String status, boolean hollow) 131 { 132 if (productStatusRegistry == null) 133 throw new NullPointerException ("productStatusTracker must not be null!"); 134 if (productStatusRegistry.getOrganisationID() == null) 135 throw new NullPointerException ("productStatusTracker.organisationID must not be null!"); 136 if (productStatusRegistry.getProductID() == null) 137 throw new NullPointerException ("productStatusTracker.productID must not be null!"); 138 139 if (statusID < 0) 140 throw new IllegalArgumentException ("statusID must be >= 0!"); 141 142 assertValidStatus(status); 143 144 if (user == null) 145 throw new NullPointerException ("user must not be null!"); 146 147 this.organisationID = productStatusRegistry.getOrganisationID(); 148 this.productID = productStatusRegistry.getProductID(); 149 this.statusID = statusID; 150 this.productStatusTracker = productStatusRegistry; 151 this.product = productStatusRegistry.getProduct(); 152 this.timestamp = new Date (); 153 this.status = status; 154 this.user = user; 155 this.hollow = hollow; 156 } 157 public Product getProduct() 158 { 159 return product; 160 } 161 164 public String getOrganisationID() 165 { 166 return organisationID; 167 } 168 public String getProductID() 169 { 170 return productID; 171 } 172 173 176 public ProductStatusTracker getProductStatusTracker() 177 { 178 return productStatusTracker; 179 } 180 183 public String getStatus() 184 { 185 return status; 186 } 187 190 public int getStatusID() 191 { 192 return statusID; 193 } 194 197 public Date getTimestamp() 198 { 199 return timestamp; 200 } 201 204 public User getUser() 205 { 206 return user; 207 } 208 211 public boolean isHollow() 212 { 213 return hollow; 214 } 215 218 public void setHollow(boolean hollow) 219 { 220 this.hollow = hollow; 221 } 222 } 223 | Popular Tags |