Subversion Repositories SmartDukaan

Rev

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

Rev 22335 Rev 22384
Line 19... Line 19...
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
 
22
 
23
public class Mongo {
23
public class Mongo {
24
	
24
 
25
	private static final Logger LOGGER = LoggerFactory.getLogger(Mongo.class);
25
	private static final Logger LOGGER = LoggerFactory.getLogger(Mongo.class);
26
 
26
 
27
	private static final String CONTENT = "CONTENT";
27
	private static final String CONTENT = "CONTENT";
28
	private static final String SITE_CONTENT = "siteContent";
28
	private static final String SITE_CONTENT = "siteContent";
29
	private static final String CATALOG_DB = "Catalog";
29
	private static final String CATALOG_DB = "Catalog";
Line 54... Line 54...
54
		DBObject result = collection.findOne(obj);
54
		DBObject result = collection.findOne(obj);
55
		if (result == null) {
55
		if (result == null) {
56
			throw new Exception();
56
			throw new Exception();
57
		}
57
		}
58
		return new JSONObject(JSON.serialize(result));
58
		return new JSONObject(JSON.serialize(result));
-
 
59
	}
-
 
60
 
-
 
61
	public JSONObject getEntityByName(String name) throws Exception {
-
 
62
		DB db = contentMongoClient.getDB(CONTENT);
-
 
63
		DBCollection collection = db.getCollection(SITE_CONTENT);
-
 
64
		BasicDBObject obj = new BasicDBObject();
-
 
65
		obj.append("title", name);
-
 
66
		DBObject result = collection.findOne(obj);
-
 
67
		if (result == null) {
-
 
68
			throw new Exception();
-
 
69
		}
-
 
70
		return new JSONObject(JSON.serialize(result));
59
	}
71
	}
60
 
72
 
61
	public JSONObject getItemsByBundleId(long bundleId) throws Exception {
73
	public JSONObject getItemsByBundleId(long bundleId) throws Exception {
62
		DB db = mongoClient.getDB(CATALOG_DB);
74
		DB db = mongoClient.getDB(CATALOG_DB);
63
		DBCollection collection = db.getCollection(MASTER_DATA);
75
		DBCollection collection = db.getCollection(MASTER_DATA);