Subversion Repositories SmartDukaan

Rev

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

Rev 22352 Rev 22416
Line 126... Line 126...
126
        }
126
        }
127
        
127
        
128
	}
128
	}
129
	
129
	
130
	public void migrateUserToRetailer(){
130
	public void migrateUserToRetailer(){
131
		Set<Integer> ids = new HashSet<>();
131
		Set<Integer> retailersAdded = new HashSet<>();
132
		List<Integer> userIds = userRepository.selectIdAll();
132
		List<Integer> userIds = userRepository.selectIdAll();
133
		List<UserAccounts> saholicUserAccounts = userAccountRepository.selectAllSaholicByUserIds(new HashSet<>(userIds));
133
		List<UserAccounts> saholicUserAccounts = userAccountRepository.selectAllSaholicByUserIds(new HashSet<>(userIds));
134
		for(UserAccounts saholicUserAccount : saholicUserAccounts){
134
		for(UserAccounts saholicUserAccount : saholicUserAccounts){
135
			Retailer retailer = new Retailer();
-
 
136
			int retailerId = Integer.parseInt(saholicUserAccount.getAccount_key());
135
			int retailerId = Integer.parseInt(saholicUserAccount.getAccount_key());
137
			retailer.setId(retailerId);
136
			if(retailerRepository.isExistById(retailerId)) {
-
 
137
				LOGGER.info("Already reatiler with retailerId {}", retailerId);
138
			retailer.setMigrated(true);
138
				continue;
-
 
139
			}
139
			if(!ids.add(retailerId)){
140
			if(!retailersAdded.add(retailerId)){
140
				LOGGER.info("Duplicate retailerId {}", retailerId);
141
				LOGGER.info("Duplicate retailerId {}", retailerId);
-
 
142
				continue;
141
			}
143
			}
-
 
144
			Retailer retailer = new Retailer();
142
			try {
145
			try {
-
 
146
				retailer.setId(retailerId);
-
 
147
				retailer.setMigrated(true);
143
				retailerRepository.persist(retailer);
148
				retailerRepository.persist(retailer);
144
			} catch (ProfitMandiBusinessException e) {
149
			} catch (ProfitMandiBusinessException e) {
145
				LOGGER.info("Error occured while commiting retailer");
150
				LOGGER.info("Error occured while commiting retailer");
146
				e.printStackTrace();
151
				e.printStackTrace();
147
			}
152
			}
Line 160... Line 165...
160
			try {
165
			try {
161
				userRoleRepository.persist(userRole2);
166
				userRoleRepository.persist(userRole2);
162
			} catch (ProfitMandiBusinessException e) {
167
			} catch (ProfitMandiBusinessException e) {
163
				e.printStackTrace();
168
				e.printStackTrace();
164
			}
169
			}
-
 
170
			LOGGER.info("Retailer migrated {}", retailerId);
165
		}
171
		}
166
	}
172
	}
167
	
173
	
168
	public void migrateMongoDocToRetailer() throws ProfitMandiBusinessException{
174
	public void migrateMongoDocToRetailer() throws ProfitMandiBusinessException{
169
		List<Map<String, String>> maps = this.getMongoFofoDoc();
175
		List<Map<String, String>> maps = this.getMongoFofoDoc();