| Line 17... |
Line 17... |
| 17 |
import com.mongodb.DBCursor;
|
17 |
import com.mongodb.DBCursor;
|
| 18 |
import com.mongodb.DBObject;
|
18 |
import com.mongodb.DBObject;
|
| 19 |
import com.mongodb.MongoClient;
|
19 |
import com.mongodb.MongoClient;
|
| 20 |
import com.mongodb.util.JSON;
|
20 |
import com.mongodb.util.JSON;
|
| 21 |
import com.spice.profitmandi.dao.model.FofoForm;
|
21 |
import com.spice.profitmandi.dao.model.FofoForm;
|
| - |
|
22 |
import com.spice.profitmandi.dao.model.RetailerFofoInterest;
|
| 22 |
|
23 |
|
| 23 |
public class Mongo {
|
24 |
public class Mongo {
|
| 24 |
|
25 |
|
| 25 |
private static final Logger LOGGER = LoggerFactory.getLogger(Mongo.class);
|
26 |
private static final Logger LOGGER = LoggerFactory.getLogger(Mongo.class);
|
| 26 |
|
27 |
|
| Line 29... |
Line 30... |
| 29 |
private static final String CATALOG_DB = "Catalog";
|
30 |
private static final String CATALOG_DB = "Catalog";
|
| 30 |
private static final String MASTER_DATA = "MasterData";
|
31 |
private static final String MASTER_DATA = "MasterData";
|
| 31 |
private static final String FOFO_DB = "Fofo";
|
32 |
private static final String FOFO_DB = "Fofo";
|
| 32 |
private static final String FOFO_BRANDS = "brands";
|
33 |
private static final String FOFO_BRANDS = "brands";
|
| 33 |
private static final String PROFITMANDI_BANNERS = "banners";
|
34 |
private static final String PROFITMANDI_BANNERS = "banners";
|
| - |
|
35 |
private static final String RETAILER_FOFO_INTEREST = "RetailerFofoInterest";
|
| 34 |
private static final String FOFO_FORM_COLLECTION = "RegistrationForm";
|
36 |
private static final String FOFO_FORM_COLLECTION = "RegistrationForm";
|
| 35 |
private static final int MONGO_PORT = 27017;
|
37 |
private static final int MONGO_PORT = 27017;
|
| 36 |
|
38 |
|
| 37 |
private MongoClient mongoClient;
|
39 |
private MongoClient mongoClient;
|
| 38 |
private MongoClient contentMongoClient;
|
40 |
private MongoClient contentMongoClient;
|
| Line 222... |
Line 224... |
| 222 |
DB db = mongoClient.getDB(CATALOG_DB);
|
224 |
DB db = mongoClient.getDB(CATALOG_DB);
|
| 223 |
BasicDBObject filter = new BasicDBObject();
|
225 |
BasicDBObject filter = new BasicDBObject();
|
| 224 |
filter.append("type", bannerType);
|
226 |
filter.append("type", bannerType);
|
| 225 |
return db.getCollection(PROFITMANDI_BANNERS).find(filter).toArray();
|
227 |
return db.getCollection(PROFITMANDI_BANNERS).find(filter).toArray();
|
| 226 |
}
|
228 |
}
|
| - |
|
229 |
|
| - |
|
230 |
public boolean saveRetailerInterestOnFofo(RetailerFofoInterest retailerInterest) {
|
| - |
|
231 |
DB db = mongoClient.getDB(FOFO_DB);
|
| - |
|
232 |
Gson gs = new Gson();
|
| - |
|
233 |
DBCollection fofoInterestCollection = db.getCollection(RETAILER_FOFO_INTEREST);
|
| - |
|
234 |
DBObject dbObject = (DBObject) JSON.parse(gs.toJson(retailerInterest));
|
| - |
|
235 |
fofoInterestCollection.save(dbObject);
|
| - |
|
236 |
return true;
|
| - |
|
237 |
}
|
| - |
|
238 |
|
| - |
|
239 |
public boolean hasRetailerShownInterest(int userId) {
|
| - |
|
240 |
DB db = mongoClient.getDB(FOFO_DB);
|
| - |
|
241 |
BasicDBObject filter = new BasicDBObject();
|
| - |
|
242 |
filter.append("userId", userId);
|
| - |
|
243 |
DBCollection fofoInterestCollection = db.getCollection(RETAILER_FOFO_INTEREST);
|
| - |
|
244 |
return fofoInterestCollection.findOne(filter)!=null;
|
| - |
|
245 |
}
|
| 227 |
|
246 |
|
| 228 |
}
|
247 |
}
|