1 package com.dotmarketing.portlets.product.model; 2 3 import java.util.List ; 4 5 import com.dotmarketing.beans.Identifier; 6 import com.dotmarketing.beans.Inode; 7 import com.dotmarketing.factories.IdentifierFactory; 8 import com.dotmarketing.factories.InodeFactory; 9 import com.dotmarketing.portlets.categories.model.Category; 10 import com.dotmarketing.portlets.files.model.File; 11 import com.dotmarketing.util.WebKeys; 12 import com.dotmarketing.portlets.product.factories.ProductFormatFactory; 13 14 19 public class Product extends Inode { 20 21 private static final long serialVersionUID = 1L; 22 private String title; private String shortDescription; private String longDescription; private boolean reqShipping; private boolean featured; private int sortOrder; private String comments; private boolean showOnWeb; public Product(String title, String shortDescription, String longDescription, boolean reqShipping, boolean featured) { 31 this.title = title; 32 this.shortDescription = shortDescription; 33 this.longDescription = longDescription; 34 this.reqShipping = reqShipping; 35 this.featured = featured; 36 } 37 38 public Product() { 39 setType("ecom_product"); 40 } 41 42 public Product(String title) { 43 this.title = title; 44 } 45 46 public String getTitle() { 47 return this.title; 48 } 49 50 public void setTitle(String title) { 51 this.title = title; 52 } 53 public String getShortDescription() { 54 return this.shortDescription; 55 } 56 57 public void setShortDescription(String shortDescription) { 58 this.shortDescription = shortDescription; 59 } 60 public String getLongDescription() { 61 return this.longDescription; 62 } 63 64 public void setLongDescription(String longDescription) { 65 this.longDescription = longDescription; 66 } 67 public boolean getReqShipping() { 68 return this.reqShipping; 69 } 70 71 public void setReqShipping(boolean reqShipping) { 72 this.reqShipping = reqShipping; 73 } 74 public boolean getFeatured() { 75 return this.featured; 76 } 77 78 public void setFeatured(boolean featured) { 79 this.featured = featured; 80 } 81 82 public List <ProductFormat> getFormats() 83 { 84 return ProductFormatFactory.getAllFormatsByProduct(this); 85 } 86 87 public Category getProductType() 88 { 89 Category category = (Category) InodeFactory.getParentOfClassByRelationType(this,Category.class,WebKeys.PRODUCT_PRODUCTS_TYPE); 90 return category; 91 } 92 93 public int getSortOrder() { 94 return sortOrder; 95 } 96 97 public void setSortOrder(int sortOrder) { 98 this.sortOrder = sortOrder; 99 } 100 101 public List <Product> getRelatedProducts() 102 { 103 List <Product> products = InodeFactory.getChildrenClassByRelationType(this,Product.class,WebKeys.PRODUCT_RELATED); 104 return products; 105 } 106 107 public List <Category> getProductCategories(){ 108 List <Category> categories = InodeFactory.getParentsOfClass(this,Category.class); 109 return categories; 110 } 111 112 public boolean isOnlyOnPartners(){ 113 boolean res = false; 114 List <Category> categories = getProductCategories(); 115 for(Category category : categories){ 116 if (category.getCategoryName().equals("Partner Only")){ 117 res = true; 118 break; 119 } 120 } 121 return res; 122 } 123 124 public String getComments() { 125 return comments; 126 } 127 128 public void setComments(String comments) { 129 this.comments = comments; 130 } 131 132 public long getSmallImageInode() 133 { 134 Identifier identifier = (Identifier) InodeFactory.getChildOfClassByRelationType(this,Identifier.class,WebKeys.PRODUCT_SMALL_IMAGE); 135 File image = (File) IdentifierFactory.getLiveChildOfClass(identifier,File.class); 136 return image.getInode(); 137 } 138 139 public long getMediumImageInode() 140 { 141 Identifier identifier = (Identifier) InodeFactory.getChildOfClassByRelationType(this,Identifier.class,WebKeys.PRODUCT_MEDIUM_IMAGE); 142 File image = (File) IdentifierFactory.getLiveChildOfClass(identifier,File.class); 143 return image.getInode(); 144 } 145 146 public long getLargeImageInode() 147 { 148 Identifier identifier = (Identifier) InodeFactory.getChildOfClassByRelationType(this,Identifier.class,WebKeys.PRODUCT_LARGE_IMAGE); 149 File image = (File) IdentifierFactory.getLiveChildOfClass(identifier,File.class); 150 return image.getInode(); 151 } 152 153 public boolean hasBulkPricing() 154 { 155 boolean bulkPricing = false; 156 List <ProductFormat> formats = ProductFormatFactory.getAllFormatsByProduct(this); 157 for(ProductFormat format : formats) 158 { 159 bulkPricing = (format.getBulkPrices().size() > 1 ? true : false); 160 if(bulkPricing) 161 { 162 break; 163 } 164 } 165 return bulkPricing; 166 } 167 public boolean getShowOnWeb() { 168 return this.showOnWeb; 169 } 170 171 public void setShowOnWeb(boolean showOnWeb) { 172 this.showOnWeb = showOnWeb; 173 } 174 } 175 | Popular Tags |