Subversion Repositories SmartDukaan

Rev

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

Rev 24031 Rev 24383
Line 44... Line 44...
44
	private static final String USER_DB = "User";
44
	private static final String USER_DB = "User";
45
	private static final int MONGO_PORT = 27017;
45
	private static final int MONGO_PORT = 27017;
46
 
46
 
47
	private MongoClient mongoClient;
47
	private MongoClient mongoClient;
48
	private MongoClient contentMongoClient;
48
	private MongoClient contentMongoClient;
49
	private MongoClient dtrDataMongoClient;
-
 
50
 
49
 
51
	public Mongo(String mongoHost, String contentMongoHost) {
50
	public Mongo(String mongoHost, String contentMongoHost) {
52
		try {
51
		try {
53
			LOGGER.info("mongoHost => {}, contentMongoHost {} ", mongoHost, contentMongoHost);
52
			LOGGER.info("mongoHost => {}, contentMongoHost {} ", mongoHost, contentMongoHost);
54
			mongoClient = new MongoClient(mongoHost, MONGO_PORT);
53
			mongoClient = new MongoClient(mongoHost, MONGO_PORT);
Line 56... Line 55...
56
		} catch (Exception e) {
55
		} catch (Exception e) {
57
			e.printStackTrace();
56
			e.printStackTrace();
58
		}
57
		}
59
	}
58
	}
60
 
59
 
61
	public Mongo(String mongoHost, String contentMongoHost, String dtrDataMongoHost) {
-
 
62
		try {
-
 
63
			LOGGER.info("mongoHost => {}, contentMongoHost {},dtrDataMongoHost {} ", mongoHost, contentMongoHost,
-
 
64
					dtrDataMongoHost);
-
 
65
			mongoClient = new MongoClient(mongoHost, MONGO_PORT);
-
 
66
			contentMongoClient = new MongoClient(contentMongoHost, MONGO_PORT);
-
 
67
			dtrDataMongoClient = new MongoClient(dtrDataMongoHost, MONGO_PORT);
-
 
68
		} catch (Exception e) {
-
 
69
			e.printStackTrace();
-
 
70
		}
-
 
71
	}
-
 
72
 
-
 
73
	public JSONObject getEntityById(long id) throws Exception {
60
	public JSONObject getEntityById(long id) throws Exception {
74
		DB db = contentMongoClient.getDB(CONTENT);
61
		DB db = contentMongoClient.getDB(CONTENT);
75
		DBCollection collection = db.getCollection(SITE_CONTENT);
62
		DBCollection collection = db.getCollection(SITE_CONTENT);
76
		BasicDBObject obj = new BasicDBObject();
63
		BasicDBObject obj = new BasicDBObject();
77
		obj.append("_id", id);
64
		obj.append("_id", id);
Line 293... Line 280...
293
		DBCollection fofoInterestCollection = db.getCollection(RETAILER_FOFO_INTEREST);
280
		DBCollection fofoInterestCollection = db.getCollection(RETAILER_FOFO_INTEREST);
294
		return fofoInterestCollection.findOne(filter) != null;
281
		return fofoInterestCollection.findOne(filter) != null;
295
	}
282
	}
296
 
283
 
297
	public void persistNotificationCmpInfo(NotificationCampaigns ff) {
284
	public void persistNotificationCmpInfo(NotificationCampaigns ff) {
298
		DB db = dtrDataMongoClient.getDB(USER_DB);
285
		DB db = mongoClient.getDB(USER_DB);
299
		DBCollection collection = db.getCollection(NOTIFICATION_CAMPAIGNS);
286
		DBCollection collection = db.getCollection(NOTIFICATION_CAMPAIGNS);
300
		if (ff.get_id() == 0) {
287
		if (ff.get_id() == 0) {
301
			BasicDBObject orderBy = new BasicDBObject();
288
			BasicDBObject orderBy = new BasicDBObject();
302
			orderBy.put("_id", -1);
289
			orderBy.put("_id", -1);
303
			DBCursor cursor = collection.find().sort(orderBy).limit(1);
290
			DBCursor cursor = collection.find().sort(orderBy).limit(1);