| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.dao.repository.dtr;
|
1 |
package com.spice.profitmandi.dao.repository.dtr;
|
| 2 |
|
2 |
|
| 3 |
import java.lang.reflect.Type;
|
3 |
import java.lang.reflect.Type;
|
| 4 |
import java.util.ArrayList;
|
4 |
import java.util.ArrayList;
|
| 5 |
import java.util.Arrays;
|
5 |
import java.util.Arrays;
|
| - |
|
6 |
import java.util.HashMap;
|
| 6 |
import java.util.List;
|
7 |
import java.util.List;
|
| 7 |
import java.util.Map;
|
8 |
import java.util.Map;
|
| - |
|
9 |
import java.util.stream.Collectors;
|
| 8 |
|
10 |
|
| 9 |
import org.apache.logging.log4j.LogManager;
|
11 |
import org.apache.logging.log4j.LogManager;
|
| 10 |
import org.apache.logging.log4j.Logger;
|
12 |
import org.apache.logging.log4j.Logger;
|
| 11 |
import org.bson.Document;
|
13 |
import org.bson.Document;
|
| 12 |
import org.json.JSONObject;
|
14 |
import org.json.JSONObject;
|
| Line 41... |
Line 43... |
| 41 |
private static final String RETAILER_FOFO_INTEREST = "RetailerFofoInterest";
|
43 |
private static final String RETAILER_FOFO_INTEREST = "RetailerFofoInterest";
|
| 42 |
private static final String FOFO_FORM_COLLECTION = "RegistrationForm";
|
44 |
private static final String FOFO_FORM_COLLECTION = "RegistrationForm";
|
| 43 |
private static final String NOTIFICATION_CAMPAIGNS = "notificationcampaigns";
|
45 |
private static final String NOTIFICATION_CAMPAIGNS = "notificationcampaigns";
|
| 44 |
private static final String USER_DB = "User";
|
46 |
private static final String USER_DB = "User";
|
| 45 |
private static final int MONGO_PORT = 27017;
|
47 |
private static final int MONGO_PORT = 27017;
|
| - |
|
48 |
|
| - |
|
49 |
public static final Map<String, List<String>> EMAIL_BLOCKED_BRANDS = new HashMap<>();
|
| - |
|
50 |
|
| - |
|
51 |
static {
|
| - |
|
52 |
EMAIL_BLOCKED_BRANDS.put("sachinindri2006@gmail.com", Arrays.asList("Vivo"));
|
| - |
|
53 |
EMAIL_BLOCKED_BRANDS.put("akamboj828@gmail.com", Arrays.asList("Vivo"));
|
| - |
|
54 |
EMAIL_BLOCKED_BRANDS.put("babitaranirk@gmail.com", Arrays.asList("Vivo"));
|
| - |
|
55 |
EMAIL_BLOCKED_BRANDS.put("testpxps@gmail.com", Arrays.asList("Gionee"));
|
| - |
|
56 |
}
|
| 46 |
|
57 |
|
| 47 |
private MongoClient mongoClient;
|
58 |
private MongoClient mongoClient;
|
| 48 |
private MongoClient contentMongoClient;
|
59 |
private MongoClient contentMongoClient;
|
| 49 |
|
60 |
|
| 50 |
public Mongo(String mongoHost, String contentMongoHost) {
|
61 |
public Mongo(String mongoHost, String contentMongoHost) {
|
| Line 66... |
Line 77... |
| 66 |
if (result == null) {
|
77 |
if (result == null) {
|
| 67 |
throw new Exception();
|
78 |
throw new Exception();
|
| 68 |
}
|
79 |
}
|
| 69 |
return new JSONObject(JSON.serialize(result));
|
80 |
return new JSONObject(JSON.serialize(result));
|
| 70 |
}
|
81 |
}
|
| - |
|
82 |
|
| - |
|
83 |
public List<DBObject> getMongoBrands(int fofoId, String email, int categoryId) {
|
| - |
|
84 |
List<DBObject> brandsDisplay = this.getBrandsToDisplay(categoryId);
|
| - |
|
85 |
if (EMAIL_BLOCKED_BRANDS.containsKey(email)) {
|
| - |
|
86 |
List<String> blockedBrands = EMAIL_BLOCKED_BRANDS.get(email);
|
| - |
|
87 |
brandsDisplay = brandsDisplay.stream().filter(x -> !blockedBrands.contains(x.get("name")))
|
| - |
|
88 |
.collect(Collectors.toList());
|
| - |
|
89 |
}
|
| - |
|
90 |
return brandsDisplay;
|
| - |
|
91 |
|
| - |
|
92 |
}
|
| 71 |
|
93 |
|
| 72 |
public JSONObject getEntityByName(String name) throws Exception {
|
94 |
public JSONObject getEntityByName(String name) throws Exception {
|
| 73 |
LOGGER.info("Name --- {}", name);
|
95 |
LOGGER.info("Name --- {}", name);
|
| 74 |
DB db = contentMongoClient.getDB(CONTENT);
|
96 |
DB db = contentMongoClient.getDB(CONTENT);
|
| 75 |
DBCollection collection = db.getCollection(SITE_CONTENT);
|
97 |
DBCollection collection = db.getCollection(SITE_CONTENT);
|