[dna-commits] DNA SVN: r1522 - in trunk/dna-graph/src/main/java/org/jboss/dna/graph: request and 1 other directories.
dna-commits at lists.jboss.org
dna-commits at lists.jboss.org
Mon Jan 4 15:11:45 EST 2010
Author: elvisisking
Date: 2010-01-04 15:11:45 -0500 (Mon, 04 Jan 2010)
New Revision: 1522
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/NetChangeObserver.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdateValuesRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java
Log:
DNA-549 Creating A New Property And Changing An Existing Property Should Have Different ChangeRequest Types: The request processor now sets the actual property on the UpdateValuesRequest. This property is used by the NetChangeObserver. Reviewed by Randall H.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/NetChangeObserver.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/NetChangeObserver.java 2010-01-04 19:10:52 UTC (rev 1521)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/NetChangeObserver.java 2010-01-04 20:11:45 UTC (rev 1522)
@@ -225,12 +225,18 @@
// the new location is a new node event
details.addEventType(ChangeType.NODE_ADDED);
} else if (change instanceof UpdateValuesRequest) {
- // TODO need to know if this is a new property
UpdateValuesRequest updateValuesRequest = (UpdateValuesRequest)change;
if (!updateValuesRequest.addedValues().isEmpty() || !updateValuesRequest.removedValues().isEmpty()) {
- details.addEventType(ChangeType.PROPERTY_CHANGED);
- // TODO need to set property like details.changeProperty(property);
+ assert (updateValuesRequest.getActualProperty() != null);
+
+ if (updateValuesRequest.isNewProperty()) {
+ details.addEventType(ChangeType.PROPERTY_ADDED);
+ details.addProperty(updateValuesRequest.getActualProperty());
+ } else {
+ details.addEventType(ChangeType.PROPERTY_CHANGED);
+ details.changeProperty(updateValuesRequest.getActualProperty());
+ }
} else if (details.getEventTypes().isEmpty()) {
// details was just created for this request and now it is not needed
deleteLocationDetails(workspace, location, detailsByLocationByWorkspace);
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdateValuesRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdateValuesRequest.java 2010-01-04 19:10:52 UTC (rev 1521)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdateValuesRequest.java 2010-01-04 20:11:45 UTC (rev 1522)
@@ -2,6 +2,7 @@
import java.util.Collections;
import java.util.List;
+import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.graph.GraphI18n;
import org.jboss.dna.graph.Location;
import org.jboss.dna.graph.property.Name;
@@ -40,6 +41,7 @@
private List<Object> actualAddedValues;
private List<Object> actualRemovedValues;
private boolean actualCreation;
+ private Property actualProperty;
public UpdateValuesRequest( String workspaceName,
Location on,
@@ -150,15 +152,29 @@
/**
* Record that the property did not exist prior to the processing of this request and was actually created by this request.
- * This method must be called when processing the request, and the actual location must have a {@link Location#getPath() path}
- * .
+ * This method must be called when processing the request, and the actual location must have a {@link Location#getPath() path}.
*
+ * @param property the property being created or updated (may not be <code>null</code>)
* @param created true if the property was created by this request, or false if this request updated an existing property
* @throws IllegalStateException if the request is frozen
+ * @throws IllegalArgumentException if the property is <code>null</code>
*/
- public void setNewProperty( boolean created ) {
+ public void setActualProperty( Property property,
+ boolean created ) {
+ CheckArg.isNotNull(property, "property");
+ checkNotFrozen();
+ this.actualProperty = property;
this.actualCreation = created;
}
+
+ /**
+ * Get the actual node property that was created or updated.
+ *
+ * @return the actual property or <code>null</code> if the actual property was not set
+ */
+ public Property getActualProperty() {
+ return this.actualProperty;
+ }
/**
* Get the actual location of the node that was updated.
@@ -210,7 +226,11 @@
UpdateValuesRequest request = new UpdateValuesRequest(workspaceName, actualLocation != null ? actualLocation : on,
propertyName, addedValues, removedValues);
request.setActualLocation(actualLocation, actualAddedValues, actualRemovedValues);
- request.setNewProperty(actualCreation);
+
+ // don't call request.setActualProperty(Property, boolean) here as the actual property may have not been set
+ request.actualProperty = actualProperty;
+ request.actualCreation = actualCreation;
+
return request;
}
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java 2010-01-04 19:10:52 UTC (rev 1521)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java 2010-01-04 20:11:45 UTC (rev 1522)
@@ -822,13 +822,13 @@
// Update the current values
SetPropertyRequest setProperty = new SetPropertyRequest(on, workspaceName, newProperty);
process(setProperty);
- request.setNewProperty(setProperty.isNewProperty());
if (setProperty.hasError()) {
request.setError(setProperty.getError());
} else {
- // Set the actual location ...
+ // Set the actual location and property
request.setActualLocation(setProperty.getActualLocationOfNode(), request.addedValues(), actualRemovedValues);
+ request.setActualProperty(newProperty, setProperty.isNewProperty());
}
}
More information about the dna-commits
mailing list