[dna-commits] DNA SVN: r826 - trunk/dna-jcr/src/main/java/org/jboss/dna/jcr.
dna-commits at lists.jboss.org
dna-commits at lists.jboss.org
Wed Apr 15 08:50:45 EDT 2009
Author: rhauch
Date: 2009-04-15 08:50:45 -0400 (Wed, 15 Apr 2009)
New Revision: 826
Modified:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java
Log:
DNA-354 JcrSession.hasPendingChanges Is Not Implemented
Applied the patch (with changes) that implements this method by checking the SessionCache for unsaved (pending) changes. The patch had checked the 'changes' map to determine whether there were changes, but this misses deletes. Added a method to SessionCache that determines whether there are any pending changes, and implemented this method by checking whether there are any pending operations.
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java 2009-04-15 12:35:50 UTC (rev 825)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java 2009-04-15 12:50:45 UTC (rev 826)
@@ -571,11 +571,10 @@
/**
* {@inheritDoc}
*
- * @return false
* @see javax.jcr.Session#hasPendingChanges()
*/
public boolean hasPendingChanges() {
- return false;
+ return cache.hasPendingChanges();
}
/**
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java 2009-04-15 12:35:50 UTC (rev 825)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java 2009-04-15 12:50:45 UTC (rev 826)
@@ -218,6 +218,15 @@
}
/**
+ * Returns whether the session cache has any pending changes that need to be executed.
+ *
+ * @return true if there are pending changes, or false if there is currently no changes
+ */
+ boolean hasPendingChanges() {
+ return operations.isExecuteRequired();
+ }
+
+ /**
* Save any changes that have been accumulated by this session.
*
* @throws RepositoryException if any error resulting while saving the changes to the repository
@@ -785,8 +794,8 @@
if (!definition.getId().equals(node.getDefinitionId())) {
// The node definition changed, so try to set the property ...
try {
- JcrValue value = new JcrValue(factories(), SessionCache.this, PropertyType.STRING,
- definition.getId().getString());
+ JcrValue value = new JcrValue(factories(), SessionCache.this, PropertyType.STRING, definition.getId()
+ .getString());
setProperty(DnaLexicon.NODE_DEFINITON, value);
} catch (ConstraintViolationException e) {
// We can't set this property on the node (according to the node definition).
@@ -886,7 +895,7 @@
if (desiredUuid == null) {
desiredUuid = UUID.randomUUID();
}
-
+
// We know that this property is single-valued
JcrValue value = new JcrValue(factories(), SessionCache.this, PropertyType.STRING, desiredUuid.toString());
PropertyDefinition propertyDefinition = nodeTypes().findPropertyDefinition(primaryTypeName,
@@ -898,7 +907,8 @@
PropertyId propId = new PropertyId(desiredUuid, JcrLexicon.UUID);
JcrPropertyDefinition defn = (JcrPropertyDefinition)propertyDefinition;
org.jboss.dna.graph.property.Property uuidProperty = propertyFactory.create(JcrLexicon.UUID, desiredUuid);
- PropertyInfo propInfo = new PropertyInfo(propId, defn.getId(), PropertyType.STRING, uuidProperty, defn.isMultiple());
+ PropertyInfo propInfo = new PropertyInfo(propId, defn.getId(), PropertyType.STRING, uuidProperty,
+ defn.isMultiple());
properties.put(JcrLexicon.UUID, propInfo);
}
@@ -936,7 +946,10 @@
// ---------------------------------------
// Now record the changes to the store ...
// ---------------------------------------
- Graph.Create<Graph.Batch> create = operations.createUnder(currentLocation).nodeNamed(name).with(desiredUuid).with(primaryTypeProp);
+ Graph.Create<Graph.Batch> create = operations.createUnder(currentLocation)
+ .nodeNamed(name)
+ .with(desiredUuid)
+ .with(primaryTypeProp);
if (nodeDefnDefn != null) {
create = create.with(nodeDefinitionProp);
}
More information about the dna-commits
mailing list