Revision: 8861
Author: [email protected]
Date: Thu Sep 23 15:15:17 2010
Log: Fixed https://jira.springsource.org/browse/ROO-1429
1. Renamed setFoo -> putFoo, isFoo -> hasFoo, getFoo -> foo() in ProxyImpl.
2. Added a bang at the beginning of all meta-data fields in the response.

Patch by: amitmanjhi
Review by: rjrjr
Review at http://gwt-code-reviews.appspot.com/915801

http://code.google.com/p/google-web-toolkit/source/detail?r=8861

Modified:
/trunk/user/src/com/google/gwt/requestfactory/client/impl/AbstractRequest.java /trunk/user/src/com/google/gwt/requestfactory/client/impl/DeltaValueStoreJsonImpl.java
 /trunk/user/src/com/google/gwt/requestfactory/client/impl/ProxyImpl.java
 /trunk/user/src/com/google/gwt/requestfactory/client/impl/ProxyJsoImpl.java
/trunk/user/src/com/google/gwt/requestfactory/client/impl/RequestFactoryJsonImpl.java /trunk/user/src/com/google/gwt/requestfactory/rebind/RequestFactoryGenerator.java /trunk/user/src/com/google/gwt/requestfactory/server/JsonRequestProcessor.java
 /trunk/user/src/com/google/gwt/requestfactory/shared/impl/RequestData.java
/trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryStringTest.java /trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java /trunk/user/test/com/google/gwt/requestfactory/client/SimpleRequestFactoryInstance.java /trunk/user/test/com/google/gwt/requestfactory/client/impl/DeltaValueStoreJsonImplTest.java /trunk/user/test/com/google/gwt/requestfactory/server/JsonRequestProcessorTest.java

=======================================
--- /trunk/user/src/com/google/gwt/requestfactory/client/impl/AbstractRequest.java Wed Sep 22 11:52:53 2010 +++ /trunk/user/src/com/google/gwt/requestfactory/client/impl/AbstractRequest.java Thu Sep 23 15:15:17 2010
@@ -65,9 +65,9 @@

   @SuppressWarnings("unchecked")
   public <P extends EntityProxy> P edit(P record) {
-    P returnRecordImpl = (P) ((ProxyImpl) record).getSchema().create(
-        ((ProxyImpl) record).asJso(), ((ProxyImpl) record).isFuture());
-    ((ProxyImpl) returnRecordImpl).setDeltaValueStore(deltaValueStore);
+    P returnRecordImpl = (P) ((ProxyImpl) record).schema().create(
+        ((ProxyImpl) record).asJso(), ((ProxyImpl) record).unpersisted());
+    ((ProxyImpl) returnRecordImpl).putDeltaValueStore(deltaValueStore);
     return returnRecordImpl;
   }

=======================================
--- /trunk/user/src/com/google/gwt/requestfactory/client/impl/DeltaValueStoreJsonImpl.java Wed Sep 22 11:52:53 2010 +++ /trunk/user/src/com/google/gwt/requestfactory/client/impl/DeltaValueStoreJsonImpl.java Thu Sep 23 15:15:17 2010
@@ -72,7 +72,7 @@
     }

     public final native String getFutureId()/*-{
-      return this.futureId;
+ return [email protected]::ENCODED_FUTUREID_PROPERTY];
     }-*/;

     public final String getSchema() {
@@ -81,19 +81,19 @@
     }

     public final native String getSchemaAndId() /*-{
-      return this.id;
+ return [email protected]::ENCODED_ID_PROPERTY];
     }-*/;

     public final native String getVersion()/*-{
-      return this.version;
+ return [email protected]::ENCODED_VERSION_PROPERTY];
     }-*/;

     public final native boolean hasFutureId()/*-{
-      return 'futureId' in this;
+ return @com.google.gwt.requestfactory.shared.impl.RequestData::ENCODED_FUTUREID_PROPERTY in this;
     }-*/;

     public final native boolean hasId()/*-{
-      return 'id' in this;
+ return @com.google.gwt.requestfactory.shared.impl.RequestData::ENCODED_ID_PROPERTY in this;
     }-*/;

     public final native boolean hasViolations()/*-{
=======================================
--- /trunk/user/src/com/google/gwt/requestfactory/client/impl/ProxyImpl.java Thu Sep 23 06:34:46 2010 +++ /trunk/user/src/com/google/gwt/requestfactory/client/impl/ProxyImpl.java Thu Sep 23 15:15:17 2010
@@ -36,7 +36,7 @@
  */
 public class ProxyImpl implements EntityProxy {

-  protected static String getWireFormatId(String id, boolean isFuture,
+  protected static String wireFormatId(String id, boolean isFuture,
       ProxySchema<?> schema) {
     return id + "@" + (isFuture ? "IS" : "NO") + "@" + schema.getToken();
   }
@@ -100,23 +100,15 @@
     return jso.<V> get(propertyName, propertyType);
   }

-  public ProxySchema<?> getSchema() {
-    return jso.getSchema();
-  }
-
-  public String getWireFormatId() {
-    return getWireFormatId(jso.encodedId(), isFuture, jso.getSchema());
-  }
-
-  public boolean isChanged() {
+  public boolean hasChanged() {
     if (deltaValueStore == null) {
       return false;
     }
     return deltaValueStore.isChanged();
   }

-  public boolean isFuture() {
-    return isFuture;
+  public ProxySchema<?> schema() {
+    return jso.getSchema();
   }

   public <V> void set(Property<V> property, ProxyImpl record, V value) {
@@ -133,22 +125,30 @@
     if (!isFuture) {
       return new EntityProxyIdImpl<ProxyImpl>(
           encodedId(),
-          getSchema(),
+          schema(),
           false,
- jso.getRequestFactory().datastoreToFutureMap.get(encodedId(), getSchema()));
-    }
-    return new EntityProxyIdImpl(encodedId(), getSchema(), isFuture, null);
+ jso.getRequestFactory().datastoreToFutureMap.get(encodedId(), schema()));
+    }
+    return new EntityProxyIdImpl(encodedId(), schema(), isFuture, null);
+  }
+
+  public boolean unpersisted() {
+    return isFuture;
   }

   public Integer version() {
     return jso.version();
   }

-  protected ValueStoreJsonImpl getValueStore() {
+  public String wireFormatId() {
+    return wireFormatId(jso.encodedId(), isFuture, jso.getSchema());
+  }
+
+  protected ValueStoreJsonImpl valueStore() {
     return jso.getRequestFactory().getValueStore();
   }

-  void setDeltaValueStore(DeltaValueStoreJsonImpl deltaValueStore) {
+  void putDeltaValueStore(DeltaValueStoreJsonImpl deltaValueStore) {
     this.deltaValueStore = deltaValueStore;
   }
 }
=======================================
--- /trunk/user/src/com/google/gwt/requestfactory/client/impl/ProxyJsoImpl.java Thu Sep 23 06:34:46 2010 +++ /trunk/user/src/com/google/gwt/requestfactory/client/impl/ProxyJsoImpl.java Thu Sep 23 15:15:17 2010
@@ -92,7 +92,7 @@
     } else if (o instanceof Date) {
       return String.valueOf(((Date) o).getTime());
     } else if (o instanceof ProxyImpl) {
-      return ((ProxyImpl) o).getWireFormatId();
+      return ((ProxyImpl) o).wireFormatId();
     } else if (o instanceof Enum) {
       return (double) ((Enum) o).ordinal();
     }
@@ -355,7 +355,7 @@
     }

     if (value instanceof ProxyImpl) {
-      setString(property.getName(), ((ProxyImpl) value).getWireFormatId());
+      setString(property.getName(), ((ProxyImpl) value).wireFormatId());
       return;
     }

=======================================
--- /trunk/user/src/com/google/gwt/requestfactory/client/impl/RequestFactoryJsonImpl.java Thu Sep 23 10:27:34 2010 +++ /trunk/user/src/com/google/gwt/requestfactory/client/impl/RequestFactoryJsonImpl.java Thu Sep 23 15:15:17 2010
@@ -152,7 +152,7 @@
       }
       id = datastoreId;
     }
-    return ProxyImpl.getWireFormatId(id, NOT_FUTURE, proxyIdImpl.schema);
+    return ProxyImpl.wireFormatId(id, NOT_FUTURE, proxyIdImpl.schema);
   }

   public void initialize(EventBus eventBus) {
=======================================
--- /trunk/user/src/com/google/gwt/requestfactory/rebind/RequestFactoryGenerator.java Wed Sep 22 11:52:53 2010 +++ /trunk/user/src/com/google/gwt/requestfactory/rebind/RequestFactoryGenerator.java Thu Sep 23 15:15:17 2010
@@ -829,7 +829,7 @@
       }
       sb.append(parameter.getName());
       if (classType != null && classType.isAssignableTo(entityProxyType)) {
-        sb.append(").getWireFormatId()");
+        sb.append(").wireFormatId()");
       }
     }
     return "new Object[] {" + sb.toString() + "}";
=======================================
--- /trunk/user/src/com/google/gwt/requestfactory/server/JsonRequestProcessor.java Thu Sep 23 06:34:46 2010 +++ /trunk/user/src/com/google/gwt/requestfactory/server/JsonRequestProcessor.java Thu Sep 23 15:15:17 2010
@@ -1206,7 +1206,7 @@
     Object entityInstance = entityData.entityInstance;
     assert entityInstance != null;
     JSONObject returnObject = new JSONObject();
-    returnObject.put("futureId", originalEntityKey.encodedId + "");
+ returnObject.put(ENCODED_FUTUREID_PROPERTY, originalEntityKey.encodedId + "");
     // violations have already been taken care of.
     Object newId = getRawPropertyValueFromDatastore(entityInstance,
         ENTITY_ID_PROPERTY, propertyRefs);
@@ -1217,7 +1217,7 @@
     }

     newId = encodeId(newId);
- returnObject.put("id", getSchemaAndId(originalEntityKey.proxyType, newId)); + returnObject.put(ENCODED_ID_PROPERTY, getSchemaAndId(originalEntityKey.proxyType, newId)); returnObject.put(ENCODED_VERSION_PROPERTY, encodePropertyValueFromDataStore(
         entityInstance, ENTITY_VERSION_PROPERTY,
         ENTITY_VERSION_PROPERTY.getName(), propertyRefs));
@@ -1347,13 +1347,13 @@
           entityData);
       if (writeOperation == WriteOperation.DELETE) {
         JSONObject deleteRecord = new JSONObject();
-        deleteRecord.put("id", getSchemaAndId(entityKey.proxyType,
+ deleteRecord.put(ENCODED_ID_PROPERTY, getSchemaAndId(entityKey.proxyType,
             entityKey.encodedId));
         deleteArray.put(deleteRecord);
       }
       if (writeOperation == WriteOperation.UPDATE) {
         JSONObject updateRecord = new JSONObject();
-        updateRecord.put("id", getSchemaAndId(entityKey.proxyType,
+ updateRecord.put(ENCODED_ID_PROPERTY, getSchemaAndId(entityKey.proxyType,
             entityKey.encodedId));
         updateArray.put(updateRecord);
       }
@@ -1383,10 +1383,10 @@
         JSONObject returnObject = new JSONObject();
         returnObject.put(VIOLATIONS_TOKEN, entityData.violations);
         if (entityKey.isFuture) {
-          returnObject.put("futureId", entityKey.encodedId);
- returnObject.put("id", getSchemaAndId(entityKey.proxyType, null));
+          returnObject.put(ENCODED_FUTUREID_PROPERTY, entityKey.encodedId);
+ returnObject.put(ENCODED_ID_PROPERTY, getSchemaAndId(entityKey.proxyType, null));
         } else {
-          returnObject.put("id", getSchemaAndId(entityKey.proxyType,
+ returnObject.put(ENCODED_ID_PROPERTY, getSchemaAndId(entityKey.proxyType,
               entityKey.encodedId));
         }
         violations.put(returnObject);
=======================================
--- /trunk/user/src/com/google/gwt/requestfactory/shared/impl/RequestData.java Thu Sep 23 06:34:46 2010 +++ /trunk/user/src/com/google/gwt/requestfactory/shared/impl/RequestData.java Thu Sep 23 15:15:17 2010
@@ -44,6 +44,11 @@

   public static final String VIOLATIONS_TOKEN = "violations";

+  /**
+   * Property on a proxy JSO that holds its futureId.
+   */
+  public static final String ENCODED_FUTUREID_PROPERTY = "!futureId";
+
   /**
* Property on a proxy JSO that holds its encoded server side data store id.
    */
@@ -53,7 +58,7 @@
    * Property on a proxy JSO that holds its server side version data.
    */
   public static final String ENCODED_VERSION_PROPERTY = "!version";
-
+
   /**
    * Id property that server entity objects are required to define.
    */
=======================================
--- /trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryStringTest.java Thu Sep 23 13:21:05 2010 +++ /trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryStringTest.java Thu Sep 23 15:15:17 2010
@@ -115,7 +115,7 @@
final SimpleFooStringProxy foo = req.create(SimpleFooStringProxy.class);
     Object futureId = foo.getId();
     assertEquals(futureId, foo.getId());
-    assertTrue(((ProxyImpl) foo).isFuture());
+    assertTrue(((ProxyImpl) foo).unpersisted());
Request<SimpleFooStringProxy> fooReq = req.simpleFooStringRequest().persistAndReturnSelf(
         foo);
     fooReq.fire(new Receiver<SimpleFooStringProxy>() {
@@ -124,7 +124,7 @@
       public void onSuccess(final SimpleFooStringProxy returned) {
         Object futureId = foo.getId();
         assertEquals(futureId, foo.getId());
-        assertTrue(((ProxyImpl) foo).isFuture());
+        assertTrue(((ProxyImpl) foo).unpersisted());

         assertEquals(1, handler.acquireEventCount);
         assertEquals(1, handler.createEventCount);
@@ -142,7 +142,7 @@
     final SimpleBarProxy foo = req.create(SimpleBarProxy.class);
     Object futureId = foo.getId();
     assertEquals(futureId, foo.getId());
-    assertTrue(((ProxyImpl) foo).isFuture());
+    assertTrue(((ProxyImpl) foo).unpersisted());
Request<SimpleBarProxy> fooReq = req.simpleBarRequest().persistAndReturnSelf(
         foo);
     fooReq.fire(new Receiver<SimpleBarProxy>() {
@@ -151,7 +151,7 @@
       public void onSuccess(final SimpleBarProxy returned) {
         Object futureId = foo.getId();
         assertEquals(futureId, foo.getId());
-        assertTrue(((ProxyImpl) foo).isFuture());
+        assertTrue(((ProxyImpl) foo).unpersisted());

         checkStableIdEquals(foo, returned);
         finishTestAndReset();
@@ -591,15 +591,15 @@

final SimpleFooStringProxy foo = req.create(SimpleFooStringProxy.class);
     final Object futureId = foo.getId();
-    assertTrue(((ProxyImpl) foo).isFuture());
+    assertTrue(((ProxyImpl) foo).unpersisted());
Request<SimpleFooStringProxy> fooReq = req.simpleFooStringRequest().persistAndReturnSelf(
         foo);

     final SimpleFooStringProxy newFoo = fooReq.edit(foo);
     assertEquals(futureId, foo.getId());
-    assertTrue(((ProxyImpl) foo).isFuture());
+    assertTrue(((ProxyImpl) foo).unpersisted());
     assertEquals(futureId, newFoo.getId());
-    assertTrue(((ProxyImpl) newFoo).isFuture());
+    assertTrue(((ProxyImpl) newFoo).unpersisted());

     newFoo.setUserName("GWT basic user");
     fooReq.fire(new Receiver<SimpleFooStringProxy>() {
@@ -607,11 +607,11 @@
       @Override
       public void onSuccess(final SimpleFooStringProxy returned) {
         assertEquals(futureId, foo.getId());
-        assertTrue(((ProxyImpl) foo).isFuture());
+        assertTrue(((ProxyImpl) foo).unpersisted());
         assertEquals(futureId, newFoo.getId());
-        assertTrue(((ProxyImpl) newFoo).isFuture());
-
-        assertFalse(((ProxyImpl) returned).isFuture());
+        assertTrue(((ProxyImpl) newFoo).unpersisted());
+
+        assertFalse(((ProxyImpl) returned).unpersisted());

         checkStableIdEquals(foo, returned);
         checkStableIdEquals(newFoo, returned);
=======================================
--- /trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java Thu Sep 23 13:21:05 2010 +++ /trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java Thu Sep 23 15:15:17 2010
@@ -145,7 +145,7 @@
     final SimpleFooProxy foo = req.create(SimpleFooProxy.class);
     Object futureId = foo.getId();
     assertEquals(futureId, foo.getId());
-    assertTrue(((ProxyImpl) foo).isFuture());
+    assertTrue(((ProxyImpl) foo).unpersisted());
Request<SimpleFooProxy> fooReq = req.simpleFooRequest().persistAndReturnSelf(
         foo);
     fooReq.fire(new Receiver<SimpleFooProxy>() {
@@ -154,7 +154,7 @@
       public void onSuccess(final SimpleFooProxy returned) {
         Object futureId = foo.getId();
         assertEquals(futureId, foo.getId());
-        assertTrue(((ProxyImpl) foo).isFuture());
+        assertTrue(((ProxyImpl) foo).unpersisted());

         assertEquals(1, handler.acquireEventCount);
         assertEquals(1, handler.createEventCount);
@@ -172,7 +172,7 @@
     final SimpleBarProxy foo = req.create(SimpleBarProxy.class);
     Object futureId = foo.getId();
     assertEquals(futureId, foo.getId());
-    assertTrue(((ProxyImpl) foo).isFuture());
+    assertTrue(((ProxyImpl) foo).unpersisted());
Request<SimpleBarProxy> fooReq = req.simpleBarRequest().persistAndReturnSelf(
         foo);
     fooReq.fire(new Receiver<SimpleBarProxy>() {
@@ -181,7 +181,7 @@
       public void onSuccess(final SimpleBarProxy returned) {
         Object futureId = foo.getId();
         assertEquals(futureId, foo.getId());
-        assertTrue(((ProxyImpl) foo).isFuture());
+        assertTrue(((ProxyImpl) foo).unpersisted());

         checkStableIdEquals(foo, returned);
         finishTestAndReset();
@@ -1118,15 +1118,15 @@

     final SimpleFooProxy foo = req.create(SimpleFooProxy.class);
     final Object futureId = foo.getId();
-    assertTrue(((ProxyImpl) foo).isFuture());
+    assertTrue(((ProxyImpl) foo).unpersisted());
Request<SimpleFooProxy> fooReq = req.simpleFooRequest().persistAndReturnSelf(
         foo);

     final SimpleFooProxy newFoo = fooReq.edit(foo);
     assertEquals(futureId, foo.getId());
-    assertTrue(((ProxyImpl) foo).isFuture());
+    assertTrue(((ProxyImpl) foo).unpersisted());
     assertEquals(futureId, newFoo.getId());
-    assertTrue(((ProxyImpl) newFoo).isFuture());
+    assertTrue(((ProxyImpl) newFoo).unpersisted());

     newFoo.setUserName("GWT basic user");
     fooReq.fire(new Receiver<SimpleFooProxy>() {
@@ -1134,11 +1134,11 @@
       @Override
       public void onSuccess(final SimpleFooProxy returned) {
         assertEquals(futureId, foo.getId());
-        assertTrue(((ProxyImpl) foo).isFuture());
+        assertTrue(((ProxyImpl) foo).unpersisted());
         assertEquals(futureId, newFoo.getId());
-        assertTrue(((ProxyImpl) newFoo).isFuture());
-
-        assertFalse(((ProxyImpl) returned).isFuture());
+        assertTrue(((ProxyImpl) newFoo).unpersisted());
+
+        assertFalse(((ProxyImpl) returned).unpersisted());

         checkStableIdEquals(foo, returned);
         checkStableIdEquals(newFoo, returned);
=======================================
--- /trunk/user/test/com/google/gwt/requestfactory/client/SimpleRequestFactoryInstance.java Tue Sep 7 10:09:37 2010 +++ /trunk/user/test/com/google/gwt/requestfactory/client/SimpleRequestFactoryInstance.java Thu Sep 23 15:15:17 2010
@@ -37,7 +37,7 @@
   }

   public static ProxySchema<?> schema() {
- return ((ProxyImpl) factory().create(SimpleFooProxy.class)).getSchema();
+    return ((ProxyImpl) factory().create(SimpleFooProxy.class)).schema();
   }

   public static RequestFactoryJsonImpl impl() {
=======================================
--- /trunk/user/test/com/google/gwt/requestfactory/client/impl/DeltaValueStoreJsonImplTest.java Thu Sep 23 06:34:46 2010 +++ /trunk/user/test/com/google/gwt/requestfactory/client/impl/DeltaValueStoreJsonImplTest.java Thu Sep 23 15:15:17 2010
@@ -141,7 +141,7 @@

   public void testSeparateIds() {
ProxyImpl createProxy = (ProxyImpl) requestFactory.create(SimpleFooProxy.class);
-    assertTrue(createProxy.isFuture());
+    assertTrue(createProxy.unpersisted());
     String futureId = createProxy.encodedId();

     ProxyImpl mockProxy = new ProxyImpl(ProxyJsoImpl.create(futureId, 1,
=======================================
--- /trunk/user/test/com/google/gwt/requestfactory/server/JsonRequestProcessorTest.java Thu Sep 23 06:34:46 2010 +++ /trunk/user/test/com/google/gwt/requestfactory/server/JsonRequestProcessorTest.java Thu Sep 23 15:15:17 2010
@@ -135,7 +135,7 @@
         "UPDATE");
     assertEquals(1, updateArray.length());
     assertEquals(1, updateArray.getJSONObject(0).length());
-    assertTrue(updateArray.getJSONObject(0).has("id"));
+ assertTrue(updateArray.getJSONObject(0).has(RequestData.ENCODED_ID_PROPERTY));
     assertFalse(updateArray.getJSONObject(0).has("violations"));
     assertEquals(45, (int) fooResult.getIntId());
     assertEquals("JSC", fooResult.getUserName());

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to