}
private void copyProperties(HttpServletRequest request, ItemMaintActionForm form, Item item) throws Exception {
EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
Long siteCurrencyClassId = form.getSiteCurrencyClassId();
ItemLanguage defaultItemLanguage = null;
for (ItemLanguage language : item.getItemLanguages()) {
if (language.getSiteProfileClass().getSiteProfileClassId().equals(form.getSiteProfileClassDefaultId())) {
defaultItemLanguage = language;
}
}
ItemPriceCurrency regularPrice = item.getItemPrice();
ItemPriceCurrency specialPrice = item.getItemSpecPrice();
MessageResources resources = this.getResources(request);
form.setItemId(Format.getLong(item.getItemId()));
form.setItemNum(item.getItemNum());
form.setItemUpcCd(item.getItemUpcCd());
form.setItemSkuCd(item.getItemSkuCd());
form.setItemSellable(item.getItemSellable() == 'Y' ? true : false);
form.setItemTypeCd(item.getItemTypeCd());
form.setItemTypeDesc(resources.getMessage("item.typeCode." + item.getItemTypeCd()));
form.setItemShortDesc(defaultItemLanguage.getItemShortDesc());
form.setItemDesc(defaultItemLanguage.getItemDesc());
form.setPageTitle(defaultItemLanguage.getPageTitle());
form.setMetaKeywords(defaultItemLanguage.getMetaKeywords());
form.setMetaDescription(defaultItemLanguage.getMetaDescription());
form.setItemCost(Format.getFloatObj(item.getItemCost()));
form.setItemPrice(Format.getFloatObj(regularPrice.getItemPrice()));
form.setItemSpecPrice("");
form.setItemSpecPublishOn("");
form.setItemSpecExpireOn("");
if (specialPrice != null) {
form.setItemSpecPrice(Format.getFloatObj(specialPrice.getItemPrice()));
form.setItemSpecPublishOn(Format.getDate(specialPrice.getItemPricePublishOn()));
form.setItemSpecExpireOn(Format.getDate(specialPrice.getItemPriceExpireOn()));
}
form.setItemPublishOn(Format.getDate(item.getItemPublishOn()));
form.setItemExpireOn(Format.getDate(item.getItemExpireOn()));
form.setPublished(item.getPublished() == 'Y' ? true : false);
if (item.getCustomAttributeGroup() != null) {
form.setCustomAttribGroupId(Format.getLong(item.getCustomAttributeGroup().getCustomAttribGroupId()));
form.setCustomAttribGroupName(item.getCustomAttributeGroup().getCustomAttribGroupName());
}
form.setRemoveImages(null);
form.setRemoveMenus(null);
form.setMenuWindowMode("");
ShippingType shippingType = item.getShippingType();
if (shippingType != null) {
form.setShippingTypeId(shippingType.getShippingTypeId().toString());
}
ProductClass productClass = item.getProductClass();
if (productClass != null) {
form.setProductClassId(productClass.getProductClassId().toString());
}
form.setRecUpdateBy(item.getRecUpdateBy());
form.setRecUpdateDatetime(Format.getFullDatetime(item.getRecUpdateDatetime()));
form.setRecCreateBy(item.getRecCreateBy());
form.setRecCreateDatetime(Format.getFullDatetime(item.getRecCreateDatetime()));
if (!form.isSiteProfileClassDefault()) {
form.setItemImageOverride(false);
form.setItemShortDescLangFlag(false);
form.setItemDescLangFlag(false);
form.setPageTitleLangFlag(false);
form.setMetaKeywordsLangFlag(false);
form.setMetaDescriptionLangFlag(false);
form.setItemShortDescLang(defaultItemLanguage.getItemShortDesc());
form.setItemDescLang(defaultItemLanguage.getItemDesc());
form.setPageTitleLang(defaultItemLanguage.getPageTitle());
form.setMetaKeywordsLang(defaultItemLanguage.getMetaKeywords());
form.setMetaDescriptionLang(defaultItemLanguage.getMetaDescription());
Iterator<?> iterator = item.getItemLanguages().iterator();
boolean found = false;
ItemLanguage itemLanguage = null;
Long siteProfileClassId = form.getSiteProfileClassId();
while (iterator.hasNext()) {
itemLanguage = (ItemLanguage) iterator.next();
if (itemLanguage.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassId)) {
found = true;
break;
}
}
if (found) {
if (itemLanguage.getItemShortDesc() != null) {
form.setItemShortDescLangFlag(true);
form.setItemShortDescLang(itemLanguage.getItemShortDesc());
}
if (itemLanguage.getItemDesc() != null) {
form.setItemDescLangFlag(true);
form.setItemDescLang(itemLanguage.getItemDesc());
}
if (itemLanguage.getPageTitle() != null) {
form.setPageTitleLangFlag(true);
form.setPageTitleLang(itemLanguage.getPageTitle());
}
if (itemLanguage.getMetaKeywords() != null) {
form.setMetaKeywordsLangFlag(true);
form.setMetaKeywordsLang(itemLanguage.getMetaKeywords());
}
if (itemLanguage.getMetaDescription() != null) {
form.setMetaDescriptionLangFlag(true);
form.setMetaDescriptionLang(itemLanguage.getMetaDescription());
}
if (itemLanguage.getItemImageOverride().equalsIgnoreCase(String.valueOf(Constants.VALUE_YES))) {
form.setItemImageOverride(true);
}
}
}