Permalink
Browse files

updated to match latest API changes

  • Loading branch information...
1 parent 6fe0936 commit 7ff6d577617ef06944e461bcaddbdf463af1f61f @trisberg trisberg committed Feb 10, 2011
@@ -1,14 +1,14 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" output="target/classes" path="src/main/java"/>
- <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
- <attributes>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
- <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
- <classpathentry kind="output" path="target/classes"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
+ <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
@@ -1,16 +1,16 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project-modules id="moduleCoreId" project-version="1.5.0">
- <wb-module deploy-name="myrestaurants-analytics">
- <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
- <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
- <wb-resource deploy-path="/" source-path="/src/main/webapp"/>
- <dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/spring-datastore-mongodb/spring-datastore-mongodb">
- <dependency-type>uses</dependency-type>
- </dependent-module>
- <dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/spring-datastore-document-core/spring-datastore-document-core">
- <dependency-type>uses</dependency-type>
- </dependent-module>
- <property name="context-root" value="myrestaurants-analytics"/>
- <property name="java-output-path" value="/myrestaurants-analytics/target/classes"/>
- </wb-module>
-</project-modules>
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+ <wb-module deploy-name="myrestaurants-analytics">
+ <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
+ <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
+ <wb-resource deploy-path="/" source-path="/src/main/webapp"/>
+ <dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/spring-data-mongodb/spring-data-mongodb">
+ <dependency-type>uses</dependency-type>
+ </dependent-module>
+ <dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/spring-data-document-core/spring-data-document-core">
+ <dependency-type>uses</dependency-type>
+ </dependent-module>
+ <property name="context-root" value="myrestaurants-analytics"/>
+ <property name="java-output-path" value="/myrestaurants-analytics/target/classes"/>
+ </wb-module>
+</project-modules>
@@ -397,13 +397,13 @@
<dependency>
<groupId>org.springframework.data</groupId>
- <artifactId>spring-datastore-mongodb</artifactId>
+ <artifactId>spring-data-mongodb</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
- <artifactId>spring-datastore-document-core</artifactId>
+ <artifactId>spring-data-document-core</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version>
</dependency>
@@ -5,8 +5,8 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.ConversionService;
-import org.springframework.datastore.document.web.servlet.ActionInterceptor;
-import org.springframework.datastore.document.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter;
+import org.springframework.data.document.web.servlet.ActionInterceptor;
+import org.springframework.data.document.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter;
import org.springframework.format.support.FormattingConversionService;
import org.springframework.format.support.FormattingConversionServiceFactoryBean;
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
@@ -2,7 +2,7 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.datastore.document.mongodb.MongoTemplate;
+import org.springframework.data.document.mongodb.MongoTemplate;
import com.mongodb.DB;
import com.mongodb.Mongo;
@@ -14,8 +14,7 @@
public MongoTemplate mongoTemplate() throws Exception {
Mongo m = new Mongo();
- DB db = m.getDB("mvc");
- MongoTemplate mongoTemplate = new MongoTemplate(db, "mvc");
+ MongoTemplate mongoTemplate = new MongoTemplate(m, "mvc");
mongoTemplate.afterPropertiesSet();
if (!mongoTemplate.collectionExists("mvc")) {
mongoTemplate.createCollection("mvc");
@@ -1,5 +1,7 @@
package com.springone.myrestaurants.web;
+import static org.springframework.data.document.mongodb.query.Criteria.where;
+
import java.awt.Color;
import java.awt.GradientPaint;
import java.io.OutputStream;
@@ -21,8 +23,11 @@
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.datastore.document.analytics.ControllerCounter;
-import org.springframework.datastore.document.mongodb.MongoTemplate;
+import org.springframework.data.document.analytics.ControllerCounter;
+import org.springframework.data.document.mongodb.MongoTemplate;
+import org.springframework.data.document.mongodb.query.BasicQuery;
+import org.springframework.data.document.mongodb.query.Criteria;
+import org.springframework.data.document.mongodb.query.Query;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -99,15 +104,14 @@ private DefaultCategoryDataset getControllerData(String controllerName) {
DefaultCategoryDataset ds = null;
try {
Mongo m = new Mongo();
- DB db = m.getDB("mvc");
- mongoTemplate = new MongoTemplate(db, "counters");
+ mongoTemplate = new MongoTemplate(m, "counters");
mongoTemplate.afterPropertiesSet();
List<ControllerCounter> counters;
ds = new DefaultCategoryDataset();
if (controllerName != null) {
- counters = mongoTemplate.queryForList("counters", new BasicDBObject("name", controllerName), ControllerCounter.class);
+ counters = mongoTemplate.find("counters", new Query(where("name").is(controllerName)), ControllerCounter.class);
for (ControllerCounter controllerCounter : counters) {
Map<String, Double> methodInvocations = controllerCounter.getMethods();
Set<Entry<String, Double>> es = methodInvocations.entrySet();
@@ -116,7 +120,7 @@ private DefaultCategoryDataset getControllerData(String controllerName) {
}
}
} else {
- counters = mongoTemplate.queryForCollection("counters", ControllerCounter.class);
+ counters = mongoTemplate.getCollection("counters", ControllerCounter.class);
for (ControllerCounter controllerCounter : counters) {
ds.addValue(controllerCounter.getCount(), "invoked (aggregate)", controllerCounter.getName());
}
@@ -146,8 +150,7 @@ private DefaultCategoryDataset getFavoritesData() {
DefaultCategoryDataset ds = null;
try {
Mongo m = new Mongo();
- DB db = m.getDB("mvc");
- mongoTemplate = new MongoTemplate(db, "mvc");
+ mongoTemplate = new MongoTemplate(m, "mvc");
mongoTemplate.afterPropertiesSet();
DBObject result = getTopRecommendedRestaurants(mongoTemplate);
@@ -182,7 +185,7 @@ private DefaultCategoryDataset getFavoritesData() {
public DBObject getTopRecommendedRestaurants(MongoTemplate mongoTemplate) {
//This circumvents exception translation
- DBCollection collection = mongoTemplate.getConnection().getCollection("mvc");
+ DBCollection collection = mongoTemplate.getCollection("mvc");
Date startDate = createDate(1, 5, 2010);
Date endDate = createDate(1,12,2010);
@@ -6,12 +6,12 @@
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.datastore.document.analytics.MvcEvent;
-import org.springframework.datastore.document.analytics.Parameters;
-import org.springframework.datastore.document.mongodb.MongoTemplate;
-import org.springframework.datastore.document.web.servlet.ActionExecutedContext;
-import org.springframework.datastore.document.web.servlet.ActionExecutingContext;
-import org.springframework.datastore.document.web.servlet.ActionInterceptor;
+import org.springframework.data.document.analytics.MvcEvent;
+import org.springframework.data.document.analytics.Parameters;
+import org.springframework.data.document.mongodb.MongoTemplate;
+import org.springframework.data.document.web.servlet.ActionExecutedContext;
+import org.springframework.data.document.web.servlet.ActionExecutingContext;
+import org.springframework.data.document.web.servlet.ActionInterceptor;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@@ -62,7 +62,7 @@ public void storeCounterData(String controllerName, String methodName) {
System.out.println(r);
changes = new BasicDBObject("$inc", new BasicDBObject("methods." + methodName, 1));
- r = mongoTemplate.getConnection().getCollection("counters").update(query, changes, true, false);
+ r = mongoTemplate.getCollection("counters").update(query, changes, true, false);
System.out.println(r);
}

0 comments on commit 7ff6d57

Please sign in to comment.