Subversion Repositories SmartDukaan

Rev

Rev 24374 | Rev 24704 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 24374 Rev 24375
Line 602... Line 602...
602
				shopAddress.setAddressId(address.getId());
602
				shopAddress.setAddressId(address.getId());
603
				shopAddress.setShopId(shop.getId());
603
				shopAddress.setShopId(shop.getId());
604
			}
604
			}
605
			shopAddressRepository.persist(shopAddress);
605
			shopAddressRepository.persist(shopAddress);
606
		} else {
606
		} else {
-
 
607
			Address address = null;
-
 
608
			try {
607
			Address address = addressRepository.selectById(shop.getAddressId());
609
				address = addressRepository.selectById(shop.getAddressId());
608
			LOGGER.info("found address : {}", address);
-
 
609
			CustomAddress customAddress = customShop.getAddress();
610
				CustomAddress customAddress = customShop.getAddress();
610
			LOGGER.info("requested address : {}", customAddress);
-
 
611
			if (!(address.getName().equals(customAddress.getName())
611
				if (!(address.getName().equals(customAddress.getName())
612
					&& address.getLine1().equals(customAddress.getLine1())
612
						&& address.getLine1().equals(customAddress.getLine1())
613
					&& address.getLine2().equals(customAddress.getLine2())
613
						&& address.getLine2().equals(customAddress.getLine2())
614
					&& address.getCity().equals(customAddress.getCity())
614
						&& address.getCity().equals(customAddress.getCity())
615
					&& address.getPinCode().equals(customAddress.getPinCode())
615
						&& address.getPinCode().equals(customAddress.getPinCode())
616
					&& address.getState().equals(customAddress.getState()))) {
616
						&& address.getState().equals(customAddress.getState()))) {
617
				address = new Address();
617
					address = new Address();
618
				ShopAddress shopAddress = shopAddressRepository.selectByShopId(shop.getId());
618
					ShopAddress shopAddress = shopAddressRepository.selectByShopId(shop.getId());
619
				this.updateAddress(address, customAddress);
619
					this.updateAddress(address, customAddress);
620
				shopAddress.setAddressId(address.getId());
620
					shopAddress.setAddressId(address.getId());
621
				shopAddressRepository.persist(shopAddress);
621
					shopAddressRepository.persist(shopAddress);
-
 
622
					shop.setAddress(address);
-
 
623
					shopRepository.persist(shop);
-
 
624
				}
-
 
625
			} catch(Exception e) {
-
 
626
				if (customShop.isSameAsRetailerAddress()) {
-
 
627
					address = sameAsRetailerAddressValue;
-
 
628
				} else {
-
 
629
					// shop.setDocumentId(customShop.getDocumentId());
-
 
630
					address = new Address();
-
 
631
					this.updateAddress(address, customShop.getAddress());
622
			}
632
				}
-
 
633
				shop.setAddressId(address.getId());
-
 
634
				shop.setAddress(address);
-
 
635
				shopRepository.persist(shop);
-
 
636
				ShopAddress shopAddress = null;
-
 
637
				try {
-
 
638
					shopAddress = shopAddressRepository.selectByShopId(shop.getId());
-
 
639
					shopAddress.setAddressId(address.getId());
-
 
640
				} catch (ProfitMandiBusinessException profitMandiBusinessException) {
-
 
641
					shopAddress = new ShopAddress();
-
 
642
					shopAddress.setAddressId(address.getId());
-
 
643
					shopAddress.setShopId(shop.getId());
-
 
644
				}
-
 
645
				shopAddressRepository.persist(shopAddress);			}
623
 
646
 
624
			shop.setAddress(address);
-
 
625
			shopRepository.persist(shop);
-
 
626
		}
647
		}
627
 
648
 
628
	}
649
	}
629
 
650
 
630
	private void addAddress(List<Shop> shops) {
651
	private void addAddress(List<Shop> shops) {