Subversion Repositories SmartDukaan

Rev

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

Rev 27947 Rev 28025
Line 11... Line 11...
11
 
11
 
12
import org.apache.logging.log4j.LogManager;
12
import org.apache.logging.log4j.LogManager;
13
import org.apache.logging.log4j.Logger;
13
import org.apache.logging.log4j.Logger;
14
import org.bson.Document;
14
import org.bson.Document;
15
import org.json.JSONObject;
15
import org.json.JSONObject;
-
 
16
import org.springframework.beans.factory.annotation.Autowired;
16
 
17
 
17
import com.google.gson.Gson;
18
import com.google.gson.Gson;
18
import com.google.gson.reflect.TypeToken;
19
import com.google.gson.reflect.TypeToken;
19
import com.mongodb.BasicDBObject;
20
import com.mongodb.BasicDBObject;
20
import com.mongodb.DB;
21
import com.mongodb.DB;
Line 139... Line 140...
139
		PARTNER_ALLOWED_BRANDS.put(175138884, Arrays.asList("Realme"));
140
		PARTNER_ALLOWED_BRANDS.put(175138884, Arrays.asList("Realme"));
140
		PARTNER_ALLOWED_BRANDS.put(175138872, Arrays.asList("Realme"));
141
		PARTNER_ALLOWED_BRANDS.put(175138872, Arrays.asList("Realme"));
141
		PARTNER_ALLOWED_BRANDS.put(175138866, Arrays.asList("Realme"));
142
		PARTNER_ALLOWED_BRANDS.put(175138866, Arrays.asList("Realme"));
142
 
143
 
143
	}
144
	}
-
 
145
	@Autowired
-
 
146
	private RetailerBlockBrandsRepository retailerBlockBrandsRepository;
144
 
147
 
145
	private MongoClient mongoClient;
148
	private MongoClient mongoClient;
146
	private MongoClient contentMongoClient;
149
	private MongoClient contentMongoClient;
147
 
150
 
148
	public Mongo(String mongoHost, String contentMongoHost) {
151
	public Mongo(String mongoHost, String contentMongoHost) {
Line 171... Line 174...
171
		return cp;
174
		return cp;
172
	}
175
	}
173
 
176
 
174
	public List<DBObject> getMongoBrands(int fofoId, String email, int categoryId) {
177
	public List<DBObject> getMongoBrands(int fofoId, String email, int categoryId) {
175
		List<DBObject> brandsDisplay = this.getBrandsToDisplay(categoryId);
178
		List<DBObject> brandsDisplay = this.getBrandsToDisplay(categoryId);
176
		if(fofoId==Utils.SYSTEM_PARTNER_ID) {
179
		if (fofoId == Utils.SYSTEM_PARTNER_ID) {
177
			return brandsDisplay; 
180
			return brandsDisplay;
178
		}
181
		}
179
		Iterator<DBObject> brandsDisplayIterator = brandsDisplay.iterator();
-
 
180
		List<String> partnerAllowedBrands = PARTNER_ALLOWED_BRANDS.get(fofoId);
182
		List<String> blockedBrands = retailerBlockBrandsRepository.selectAllByRetailer(fofoId).stream()
181
		while(brandsDisplayIterator.hasNext()) {
-
 
182
			String brand = brandsDisplayIterator.next().get("name").toString();
-
 
183
			if(BLOCKED_BRANDS.contains(brand)) {
-
 
184
				if(partnerAllowedBrands == null || !partnerAllowedBrands.contains(brand)) {
183
				.map(x -> x.getBlockBrands()).collect(Collectors.toList());
185
					brandsDisplayIterator.remove();
-
 
186
				}
-
 
187
			}
-
 
188
		}
-
 
189
		if (PARTNER_BLoCKED_BRANDS.containsKey(fofoId)) {
-
 
190
			List<String> blockedBrands = PARTNER_BLoCKED_BRANDS.get(fofoId);
184
		LOGGER.info("blockedBrands"+blockedBrands);
191
			brandsDisplay = brandsDisplay.stream().filter(x -> !blockedBrands.contains(x.get("name")))
185
		brandsDisplay = brandsDisplay.stream().filter(x -> !blockedBrands.contains(x.get("name")))
192
					.collect(Collectors.toList());
186
				.collect(Collectors.toList());
193
		}
-
 
194
		return brandsDisplay;
-
 
195
 
187
 
-
 
188
		LOGGER.info("brandsDisplay"+brandsDisplay);
-
 
189
		return brandsDisplay;
196
	}
190
	}
197
 
191
 
198
	public ContentPojo getEntityByName(String name) throws Exception {
192
	public ContentPojo getEntityByName(String name) throws Exception {
199
		LOGGER.info("Name --- {}", name);
193
		LOGGER.info("Name --- {}", name);
200
		DB db = contentMongoClient.getDB(CONTENT);
194
		DB db = contentMongoClient.getDB(CONTENT);