DNA SVN: r684 - in trunk/extensions/dna-connector-store-jpa/src: test/java/org/jboss/dna/connector/store/jpa/models/basic and 1 other directory.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2008-12-11 19:05:32 -0500 (Thu, 11 Dec 2008)
New Revision: 684
Added:
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/models/basic/ChildEntityTest.java
Modified:
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/BasicRequestProcessor.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/ChildEntity.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/SubgraphNodeEntity.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/SubgraphQuery.java
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/models/basic/BasicModelTest.java
Log:
DNA-40
Implemented the logic to adjust the indexes in parent and same-name-sibling indexes when a node is removed from a parent (either deleted or moved to another parent).
Modified: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/BasicRequestProcessor.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/BasicRequestProcessor.java 2008-12-11 22:02:26 UTC (rev 683)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/BasicRequestProcessor.java 2008-12-12 00:05:32 UTC (rev 684)
@@ -237,6 +237,9 @@
// Since we've just created this node, we know about all the children (actually, there are none).
cache.setAllChildren(path, new LinkedList<Location>());
+ // Flush the entities ...
+ // entities.flush();
+
} catch (Throwable e) { // Includes PathNotFoundException
request.setError(e);
logger.trace(e, "Problem " + request);
@@ -666,6 +669,11 @@
// Compute the subgraph, including the root ...
SubgraphQuery query = SubgraphQuery.create(getExecutionContext(), entities, actualLocation.getUuid(), path, 0);
+ ChildEntity deleted = query.getNode();
+ String parentUuidString = deleted.getId().getParentUuidString();
+ String childName = deleted.getChildName();
+ long nsId = deleted.getChildNamespace().getId();
+ int indexInParent = deleted.getIndexInParent();
// Get the locations of all deleted nodes, which will be required by events ...
List<Location> deletedLocations = query.getNodeLocations(true, true);
@@ -674,7 +682,8 @@
query.deleteSubgraph(true);
// And adjust the SNS index and indexes ...
- // adjustSnsIndexesAndIndexesAfterRemoving(oldParentUuid, childLocalName, ns.getId(), oldIndex, oldSnsIndex);
+ ChildEntity.adjustSnsIndexesAndIndexesAfterRemoving(entities, parentUuidString, childName, nsId, indexInParent);
+ entities.flush();
// Remove from the cache of children locations all entries for deleted nodes ...
cache.removeBranch(deletedLocations);
@@ -724,7 +733,6 @@
toUuidString = actualIntoLocation.uuid;
if (!toUuidString.equals(oldParentUuid)) {
// Now we know that the new parent is not the existing parent ...
- final int oldSnsIndex = fromEntity.getSameNameSiblingIndex();
final int oldIndex = fromEntity.getIndexInParent();
// Find the largest SNS index in the existing ChildEntity objects with the same name ...
@@ -754,6 +762,9 @@
fromEntity.setIndexInParent(nextIndexInParent);
fromEntity.setSameNameSiblingIndex(nextSnsIndex);
+ // Flush the entities to the database ...
+ entities.flush();
+
// Determine the new location ...
Path newParentPath = actualIntoLocation.location.getPath();
Name childName = oldPath.getLastSegment().getName();
@@ -761,10 +772,15 @@
actualNewLocation = actualOldLocation.with(newPath);
// And adjust the SNS index and indexes ...
- adjustSnsIndexesAndIndexesAfterRemoving(oldParentUuid, childLocalName, ns.getId(), oldIndex, oldSnsIndex);
+ ChildEntity.adjustSnsIndexesAndIndexesAfterRemoving(entities,
+ oldParentUuid,
+ childLocalName,
+ ns.getId(),
+ oldIndex);
// Update the cache ...
cache.moveNode(actualOldLocation, oldIndex, actualNewLocation);
+
}
}
@@ -776,15 +792,6 @@
request.setActualLocations(actualOldLocation, actualNewLocation);
}
- protected void adjustSnsIndexesAndIndexesAfterRemoving( String uuidParent,
- String childName,
- long childNamespaceIndex,
- int childIndex,
- int childSnsIndex ) {
- // TODO: Now update the 'index in parent' and SNS indexes of the siblings of the deleted node.
-
- }
-
protected String createProperties( String uuidString,
Collection<Property> properties ) throws IOException {
assert uuidString != null;
Modified: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/ChildEntity.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/ChildEntity.java 2008-12-11 22:02:26 UTC (rev 683)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/ChildEntity.java 2008-12-12 00:05:32 UTC (rev 684)
@@ -21,15 +21,19 @@
*/
package org.jboss.dna.connector.store.jpa.models.basic;
+import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
+import javax.persistence.EntityManager;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
+import javax.persistence.Query;
import javax.persistence.Table;
import org.hibernate.annotations.Index;
+import org.jboss.dna.common.text.Inflector;
import org.jboss.dna.common.util.HashCode;
import org.jboss.dna.connector.store.jpa.models.common.NamespaceEntity;
@@ -48,11 +52,13 @@
@Index( name = "CHILDUUID_INX", columnNames = {"CHILD_UUID"} ),
@Index( name = "CHILDNAME_INX", columnNames = {"PARENT_UUID", "CHILD_NAME_NS_ID", "CHILD_NAME_LOCAL", "SNS_INDEX"} )} )
@NamedQueries( {
- @NamedQuery( name = "ChildEntity.findByPathSegment", query = "select child from ChildEntity as child where child.id.parentUuidString = :parentUuidString AND child.childNamespace.id = :ns AND child.childName = :childName AND child.sameNameSiblingIndex = :sns and child.deleted is null" ),
- @NamedQuery( name = "ChildEntity.findAllUnderParent", query = "select child from ChildEntity as child where child.id.parentUuidString = :parentUuidString and child.deleted is null" ),
- @NamedQuery( name = "ChildEntity.findByChildUuid", query = "select child from ChildEntity as child where child.id.childUuidString = :childUuidString and child.deleted is null" ),
- @NamedQuery( name = "ChildEntity.findMaximumSnsIndex", query = "select max(child.sameNameSiblingIndex) from ChildEntity as child where child.id.parentUuidString = :parentUuid AND child.childNamespace.id = :ns AND child.childName = :childName and child.deleted is null" ),
- @NamedQuery( name = "ChildEntity.findMaximumChildIndex", query = "select max(child.indexInParent) from ChildEntity as child where child.id.parentUuidString = :parentUuid and child.deleted is null" )} )
+ @NamedQuery( name = "ChildEntity.findByPathSegment", query = "select child from ChildEntity as child where child.id.parentUuidString = :parentUuidString AND child.childNamespace.id = :ns AND child.childName = :childName AND child.sameNameSiblingIndex = :sns" ),
+ @NamedQuery( name = "ChildEntity.findAllUnderParent", query = "select child from ChildEntity as child where child.id.parentUuidString = :parentUuidString order by child.indexInParent" ),
+ @NamedQuery( name = "ChildEntity.findRangeUnderParent", query = "select child from ChildEntity as child where child.id.parentUuidString = :parentUuidString and child.indexInParent >= :firstIndex and child.indexInParent < :afterIndex order by child.indexInParent" ),
+ @NamedQuery( name = "ChildEntity.findChildrenAfterIndexUnderParent", query = "select child from ChildEntity as child where child.id.parentUuidString = :parentUuidString and child.indexInParent >= :afterIndex order by child.indexInParent" ),
+ @NamedQuery( name = "ChildEntity.findByChildUuid", query = "select child from ChildEntity as child where child.id.childUuidString = :childUuidString" ),
+ @NamedQuery( name = "ChildEntity.findMaximumSnsIndex", query = "select max(child.sameNameSiblingIndex) from ChildEntity as child where child.id.parentUuidString = :parentUuid AND child.childNamespace.id = :ns AND child.childName = :childName" ),
+ @NamedQuery( name = "ChildEntity.findMaximumChildIndex", query = "select max(child.indexInParent) from ChildEntity as child where child.id.parentUuidString = :parentUuid" )} )
public class ChildEntity {
@Id
@@ -71,9 +77,6 @@
@Column( name = "SNS_INDEX", nullable = false, unique = false )
private int sameNameSiblingIndex;
- @Column( name = "DELETED", nullable = true, unique = false )
- private Boolean deleted;
-
public ChildEntity() {
}
@@ -85,6 +88,7 @@
this.indexInParent = indexInParent;
this.childNamespace = ns;
this.childName = name;
+ this.sameNameSiblingIndex = 1;
}
public ChildEntity( ChildId id,
@@ -170,20 +174,6 @@
}
/**
- * @return deleted
- */
- public boolean isDeleted() {
- return Boolean.TRUE.equals(deleted);
- }
-
- /**
- * @param deleted Sets deleted to the specified value.
- */
- public void setDeleted( boolean deleted ) {
- this.deleted = deleted ? Boolean.TRUE : null;
- }
-
- /**
* {@inheritDoc}
*
* @see java.lang.Object#hashCode()
@@ -232,7 +222,10 @@
sb.append(" (id=").append(id.getChildUuidString()).append(")");
String parentId = id.getParentUuidString();
if (parentId != null) {
- sb.append(" is child of ").append(parentId);
+ sb.append(" is ");
+ sb.append(Inflector.getInstance().ordinalize(indexInParent));
+ sb.append(" child of ");
+ sb.append(parentId);
} else {
sb.append(" is root");
}
@@ -240,4 +233,24 @@
return sb.toString();
}
+ @SuppressWarnings( "unchecked" )
+ public static void adjustSnsIndexesAndIndexesAfterRemoving( EntityManager entities,
+ String uuidParent,
+ String childName,
+ long childNamespaceIndex,
+ int childIndex ) {
+ // Decrement the 'indexInParent' index values for all nodes above the previously removed sibling ...
+ Query query = entities.createNamedQuery("ChildEntity.findChildrenAfterIndexUnderParent");
+ query.setParameter("parentUuidString", uuidParent);
+ query.setParameter("afterIndex", childIndex);
+ for (ChildEntity entity : (List<ChildEntity>)query.getResultList()) {
+ // Decrement the index in parent ...
+ entity.setIndexInParent(entity.getIndexInParent() - 1);
+ if (entity.getChildName().equals(childName) && entity.getChildNamespace().getId() == childNamespaceIndex) {
+ // The name matches, so decrement the SNS index ...
+ entity.setSameNameSiblingIndex(entity.getSameNameSiblingIndex() - 1);
+ }
+ }
+ }
+
}
Modified: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/SubgraphNodeEntity.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/SubgraphNodeEntity.java 2008-12-11 22:02:26 UTC (rev 683)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/SubgraphNodeEntity.java 2008-12-12 00:05:32 UTC (rev 684)
@@ -41,7 +41,7 @@
@Table( name = "DNA_SUBGRAPH_NODES" )
@org.hibernate.annotations.Table( appliesTo = "DNA_SUBGRAPH_NODES", indexes = @Index( name = "QUERYID_INX", columnNames = {"QUERY_ID"} ) )
@NamedQueries( {
- @NamedQuery( name = "SubgraphNodeEntity.insertChildren", query = "insert into SubgraphNodeEntity(queryId,nodeUuid,depth,parentIndexInParent,indexInParent) select parentNode.queryId, child.id.childUuidString, parentNode.depth+1, parentNode.indexInParent, child.indexInParent from ChildEntity child, SubgraphNodeEntity parentNode where child.deleted is null and child.id.parentUuidString = parentNode.nodeUuid and parentNode.queryId = :queryId and parentNode.depth = :parentDepth" ),
+ @NamedQuery( name = "SubgraphNodeEntity.insertChildren", query = "insert into SubgraphNodeEntity(queryId,nodeUuid,depth,parentIndexInParent,indexInParent) select parentNode.queryId, child.id.childUuidString, parentNode.depth+1, parentNode.indexInParent, child.indexInParent from ChildEntity child, SubgraphNodeEntity parentNode where child.id.parentUuidString = parentNode.nodeUuid and parentNode.queryId = :queryId and parentNode.depth = :parentDepth" ),
@NamedQuery( name = "SubgraphNodeEntity.getCount", query = "select count(*) from SubgraphNodeEntity where queryId = :queryId" ),
@NamedQuery( name = "SubgraphNodeEntity.getPropertiesEntities", query = "select props from PropertiesEntity props, SubgraphNodeEntity node where props.id.uuidString = node.nodeUuid and node.queryId = :queryId and node.depth >= :depth and node.depth <= :maxDepth order by node.depth, node.parentIndexInParent, node.indexInParent" ),
@NamedQuery( name = "SubgraphNodeEntity.getPropertiesEntitiesWithLargeValues", query = "select props from PropertiesEntity props, SubgraphNodeEntity node where props.id.uuidString = node.nodeUuid and node.queryId = :queryId and node.depth >= :depth and size(props.largeValues) > 0" ),
Modified: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/SubgraphQuery.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/SubgraphQuery.java 2008-12-11 22:02:26 UTC (rev 683)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/SubgraphQuery.java 2008-12-12 00:05:32 UTC (rev 684)
@@ -175,6 +175,22 @@
}
/**
+ * Get the {@link ChildEntity root node} of the subgraph. This must be called before the query is {@link #close() closed}.
+ *
+ * @return the subgraph's root nodes
+ */
+ public ChildEntity getNode() {
+ // Now query for all the nodes and put into a list ...
+ Query search = manager.createNamedQuery("SubgraphNodeEntity.getChildEntities");
+ search.setParameter("queryId", query.getId());
+ search.setParameter("depth", 0);
+ search.setParameter("maxDepth", 0);
+
+ // Now process the nodes below the subgraph's root ...
+ return (ChildEntity)search.getSingleResult();
+ }
+
+ /**
* Get the {@link ChildEntity nodes} in the subgraph. This must be called before the query is {@link #close() closed}.
*
* @param includeRoot true if the subgraph's root node is to be included, or false otherwise
Modified: trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/models/basic/BasicModelTest.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/models/basic/BasicModelTest.java 2008-12-11 22:02:26 UTC (rev 683)
+++ trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/models/basic/BasicModelTest.java 2008-12-12 00:05:32 UTC (rev 684)
@@ -334,13 +334,13 @@
assertThat(child1a.getIndexInParent(), is(1));
assertThat(child1a.getChildName(), is("child1"));
assertThat(child1a.getChildNamespace(), is(ns));
- assertThat(child1a.getSameNameSiblingIndex(), is(0));
+ assertThat(child1a.getSameNameSiblingIndex(), is(1));
assertThat(child2a.getId(), is(childId2));
assertThat(child2a.getIndexInParent(), is(2));
assertThat(child2a.getChildName(), is("child2"));
assertThat(child2a.getChildNamespace(), is(ns));
- assertThat(child2a.getSameNameSiblingIndex(), is(0));
+ assertThat(child2a.getSameNameSiblingIndex(), is(1));
assertThat(child3a.getId(), is(childId3));
assertThat(child3a.getIndexInParent(), is(3));
Added: trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/models/basic/ChildEntityTest.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/models/basic/ChildEntityTest.java (rev 0)
+++ trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/models/basic/ChildEntityTest.java 2008-12-12 00:05:32 UTC (rev 684)
@@ -0,0 +1,404 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.store.jpa.models.basic;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.junit.Assert.assertThat;
+import java.util.List;
+import java.util.UUID;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Query;
+import org.hibernate.ejb.Ejb3Configuration;
+import org.jboss.dna.connector.store.jpa.models.common.NamespaceEntity;
+import org.jboss.dna.graph.BasicExecutionContext;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.properties.Path;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Randall Hauch
+ */
+public class ChildEntityTest {
+
+ private EntityManagerFactory factory;
+ private EntityManager manager;
+ private BasicModel model;
+ private ExecutionContext context;
+
+ @Before
+ public void beforeEach() throws Exception {
+ model = new BasicModel();
+ context = new BasicExecutionContext();
+ // Connect to the database ...
+ Ejb3Configuration configurator = new Ejb3Configuration();
+ model.configure(configurator);
+ configurator.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
+ configurator.setProperty("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver");
+ configurator.setProperty("hibernate.connection.username", "sa");
+ configurator.setProperty("hibernate.connection.password", "");
+ configurator.setProperty("hibernate.connection.url", "jdbc:hsqldb:.");
+ configurator.setProperty("hibernate.show_sql", "false");
+ configurator.setProperty("hibernate.format_sql", "true");
+ configurator.setProperty("hibernate.use_sql_comments", "true");
+ configurator.setProperty("hibernate.hbm2ddl.auto", "create");
+ factory = configurator.buildEntityManagerFactory();
+ manager = factory.createEntityManager();
+ }
+
+ @After
+ public void afterEach() throws Exception {
+ try {
+ if (manager != null) manager.close();
+ } finally {
+ manager = null;
+ if (factory != null) {
+ try {
+ factory.close();
+ } finally {
+ factory = null;
+ }
+ }
+ }
+ }
+
+ protected ChildId[] createChildren( UUID parentUuid,
+ NamespaceEntity ns,
+ int startingIndex,
+ int numChildren,
+ String localName,
+ boolean useSns ) {
+
+ ChildId[] result = new ChildId[numChildren];
+ manager.getTransaction().begin();
+ try {
+ // Create the child entities ...
+ for (int i = 0; i != numChildren; ++i) {
+ int indexInParent = i + startingIndex;
+ ChildId id = new ChildId(parentUuid.toString(), UUID.randomUUID().toString());
+ ChildEntity child = null;
+ if (useSns) {
+ child = new ChildEntity(id, indexInParent, ns, localName, i + 1);
+ } else {
+ String name = numChildren == 1 ? localName : localName + indexInParent;
+ child = new ChildEntity(id, indexInParent, ns, name);
+ }
+ result[i] = id;
+ manager.persist(child);
+ }
+ manager.getTransaction().commit();
+ } catch (RuntimeException t) {
+ // manager.getTransaction().rollback();
+ throw t;
+ }
+ return result;
+ }
+
+ protected ChildId[] createMixtureOfChildren( UUID parentUuid,
+ NamespaceEntity ns ) {
+ ChildId[] ids1 = createChildren(parentUuid, ns, 1, 10, "child", false);
+ ChildId[] ids2 = createChildren(parentUuid, ns, 11, 10, "childWithSameName", true);
+ ChildId[] ids3 = createChildren(parentUuid, ns, 21, 1, "anotherChild", false);
+ ChildId[] ids4 = createChildren(parentUuid, ns, 22, 1, "nextToLastChild", false);
+ ChildId[] ids5 = createChildren(parentUuid, ns, 23, 1, "lastChild", false);
+ ChildId[][] ids = new ChildId[][] {ids1, ids2, ids3, ids4, ids5};
+ ChildId[] results = new ChildId[ids1.length + ids2.length + ids3.length + ids4.length + ids5.length];
+ int i = 0;
+ for (ChildId[] idArray : ids) {
+ for (ChildId id : idArray)
+ results[i++] = id;
+ }
+ return results;
+ }
+
+ protected ChildEntity getChild( String childUuid ) {
+ Query query = manager.createNamedQuery("ChildEntity.findByChildUuid");
+ query.setParameter("childUuidString", childUuid);
+ return (ChildEntity)query.getSingleResult();
+ }
+
+ @Test
+ public void shouldCreateChildrenWithDifferentNames() {
+ UUID parentUuid = UUID.randomUUID();
+ NamespaceEntity ns = NamespaceEntity.findByUri(manager, "http://www.example.com");
+ ChildId[] ids = createChildren(parentUuid, ns, 1, 10, "child", false);
+
+ // Look up the object ...
+ manager.getTransaction().begin();
+ try {
+ int index = 1;
+ for (ChildId id : ids) {
+ ChildEntity child = manager.find(ChildEntity.class, id);
+ assertThat(child.getId(), is(id));
+ assertThat(child.getIndexInParent(), is(index));
+ assertThat(child.getChildName(), is("child" + index));
+ assertThat(child.getChildNamespace(), is(ns));
+ assertThat(child.getSameNameSiblingIndex(), is(1));
+ ++index;
+ }
+ } finally {
+ manager.getTransaction().rollback();
+ }
+ }
+
+ @Test
+ public void shouldCreateChildrenWithSameNameSiblingIndex() {
+ UUID parentUuid = UUID.randomUUID();
+ NamespaceEntity ns = NamespaceEntity.findByUri(manager, "http://www.example.com");
+ ChildId[] ids = createChildren(parentUuid, ns, 1, 10, "child", true);
+
+ // Look up the object ...
+ manager.getTransaction().begin();
+ try {
+ int index = 1;
+ for (ChildId id : ids) {
+ ChildEntity child = manager.find(ChildEntity.class, id);
+ assertThat(child.getId(), is(id));
+ assertThat(child.getIndexInParent(), is(index));
+ assertThat(child.getChildName(), is("child"));
+ assertThat(child.getChildNamespace(), is(ns));
+ assertThat(child.getSameNameSiblingIndex(), is(index));
+ ++index;
+ }
+ } finally {
+ manager.getTransaction().rollback();
+ }
+ }
+
+ @SuppressWarnings( "unchecked" )
+ @Test
+ public void shouldCreateMixtureOfChildrenWithDifferentNamesAndSameNameSiblingIndexes() {
+ UUID parentUuid = UUID.randomUUID();
+ NamespaceEntity ns = NamespaceEntity.findByUri(manager, "http://www.example.com");
+ createChildren(parentUuid, ns, 1, 10, "child", false);
+ createChildren(parentUuid, ns, 11, 10, "childWithSameName", true);
+ createChildren(parentUuid, ns, 21, 1, "anotherChild", false);
+ createChildren(parentUuid, ns, 22, 1, "nextToLastChild", false);
+ createChildren(parentUuid, ns, 23, 1, "lastChild", false);
+
+ // Look up the object ...
+ manager.getTransaction().begin();
+ try {
+ Query query = manager.createNamedQuery("ChildEntity.findAllUnderParent");
+ query.setParameter("parentUuidString", parentUuid.toString());
+ List<ChildEntity> children = query.getResultList();
+ int index = 1;
+ assertThat(children.size(), is(23));
+ for (ChildEntity child : children) {
+ assertThat(child.getIndexInParent(), is(index++));
+ }
+ } finally {
+ manager.getTransaction().rollback();
+ }
+ }
+
+ @SuppressWarnings( "unchecked" )
+ @Test
+ public void shouldCreateMixtureOfChildrenWithDifferentNamesAndSameNameSiblingIndexesMethod2() {
+ UUID parentUuid = UUID.randomUUID();
+ NamespaceEntity ns = NamespaceEntity.findByUri(manager, "http://www.example.com");
+ ChildId[] ids = createMixtureOfChildren(parentUuid, ns);
+ assertThat(ids.length, is(23));
+
+ // Look up the object ...
+ manager.getTransaction().begin();
+ try {
+ Query query = manager.createNamedQuery("ChildEntity.findAllUnderParent");
+ query.setParameter("parentUuidString", parentUuid.toString());
+ List<ChildEntity> children = query.getResultList();
+ int index = 1;
+ assertThat(children.size(), is(23));
+ for (ChildEntity child : children) {
+ assertThat(child.getIndexInParent(), is(index++));
+ }
+
+ index = 1;
+ for (ChildId id : ids) {
+ ChildEntity entity = getChild(id.getChildUuidString());
+ assertThat(entity.getIndexInParent(), is(index++));
+ }
+ } finally {
+ manager.getTransaction().rollback();
+ }
+ }
+
+ @SuppressWarnings( "unchecked" )
+ @Test
+ public void shouldFindEntitiesInIndexRange() {
+ UUID parentUuid = UUID.randomUUID();
+ NamespaceEntity ns = NamespaceEntity.findByUri(manager, "http://www.example.com");
+ ChildId[] ids = createMixtureOfChildren(parentUuid, ns);
+ assertThat(ids.length, is(23));
+
+ // Look up the objects ...
+ manager.getTransaction().begin();
+ try {
+ Query query = manager.createNamedQuery("ChildEntity.findAllUnderParent");
+ query.setParameter("parentUuidString", parentUuid.toString());
+ List<ChildEntity> children = query.getResultList();
+ int index = 1;
+ assertThat(children.size(), is(23));
+ for (ChildEntity child : children) {
+ assertThat(child.getIndexInParent(), is(index++));
+ }
+
+ query = manager.createNamedQuery("ChildEntity.findRangeUnderParent");
+ query.setParameter("parentUuidString", parentUuid.toString());
+ query.setParameter("firstIndex", 3);
+ query.setParameter("afterIndex", 6);
+ children = query.getResultList();
+ assertThat(children.size(), is(3));
+ assertThat(children.get(0).getIndexInParent(), is(3));
+ assertThat(children.get(1).getIndexInParent(), is(4));
+ assertThat(children.get(2).getIndexInParent(), is(5));
+
+ } finally {
+ manager.getTransaction().rollback();
+ }
+ }
+
+ @SuppressWarnings( "unchecked" )
+ @Test
+ public void shouldFindEntitiesAfterIndex() {
+ UUID parentUuid = UUID.randomUUID();
+ NamespaceEntity ns = NamespaceEntity.findByUri(manager, "http://www.example.com");
+ ChildId[] ids = createMixtureOfChildren(parentUuid, ns);
+ assertThat(ids.length, is(23));
+
+ // Look up the objects ...
+ manager.getTransaction().begin();
+ try {
+ Query query = manager.createNamedQuery("ChildEntity.findAllUnderParent");
+ query.setParameter("parentUuidString", parentUuid.toString());
+ List<ChildEntity> children = query.getResultList();
+ int index = 1;
+ assertThat(children.size(), is(23));
+ for (ChildEntity child : children) {
+ assertThat(child.getIndexInParent(), is(index++));
+ }
+
+ query = manager.createNamedQuery("ChildEntity.findChildrenAfterIndexUnderParent");
+ query.setParameter("parentUuidString", parentUuid.toString());
+ query.setParameter("afterIndex", 18);
+ children = query.getResultList();
+ assertThat(children.size(), is(6));
+ assertThat(children.get(0).getIndexInParent(), is(18));
+ assertThat(children.get(1).getIndexInParent(), is(19));
+ assertThat(children.get(2).getIndexInParent(), is(20));
+ assertThat(children.get(3).getIndexInParent(), is(21));
+ assertThat(children.get(4).getIndexInParent(), is(22));
+ assertThat(children.get(5).getIndexInParent(), is(23));
+
+ } finally {
+ manager.getTransaction().rollback();
+ }
+ }
+
+ @SuppressWarnings( "unchecked" )
+ @Test
+ public void shouldFindAdjustChildIndexesAfterRemovalOfFirstSibling() {
+ UUID parentUuid = UUID.randomUUID();
+ NamespaceEntity ns = NamespaceEntity.findByUri(manager, "http://www.example.com");
+ ChildId[] ids = createMixtureOfChildren(parentUuid, ns);
+ assertThat(ids.length, is(23));
+
+ // Look up the objects ...
+ manager.getTransaction().begin();
+ try {
+ Query query = manager.createNamedQuery("ChildEntity.findAllUnderParent");
+ query.setParameter("parentUuidString", parentUuid.toString());
+ List<ChildEntity> children = query.getResultList();
+ int index = 1;
+ assertThat(children.size(), is(23));
+ for (ChildEntity child : children) {
+ assertThat(child.getIndexInParent(), is(index++));
+ }
+
+ // Remove the first child ...
+ ChildEntity child = getChild(ids[0].getChildUuidString());
+ assertThat(child, is(notNullValue()));
+ String childName = child.getChildName();
+ manager.remove(child);
+
+ ChildEntity.adjustSnsIndexesAndIndexesAfterRemoving(manager, parentUuid.toString(), childName, ns.getId(), 0);
+
+ assertChildren(parentUuid.toString(),
+ // "child1",
+ "child2",
+ "child3",
+ "child4",
+ "child5",
+ "child6",
+ "child7",
+ "child8",
+ "child9",
+ "child10",
+ "childWithSameName[1]",
+ "childWithSameName[2]",
+ "childWithSameName[3]",
+ "childWithSameName[4]",
+ "childWithSameName[5]",
+ "childWithSameName[6]",
+ "childWithSameName[7]",
+ "childWithSameName[8]",
+ "childWithSameName[9]",
+ "childWithSameName[10]",
+ "anotherChild",
+ "nextToLastChild",
+ "lastChild");
+
+ } finally {
+ manager.getTransaction().rollback();
+ }
+ }
+
+ @SuppressWarnings( "unchecked" )
+ protected void assertChildren( String parentUuid,
+ String... childNames ) {
+ Query query = manager.createNamedQuery("ChildEntity.findAllUnderParent");
+ query.setParameter("parentUuidString", parentUuid.toString());
+ List<ChildEntity> children = query.getResultList();
+ int index = 0;
+ for (ChildEntity child : children) {
+ // System.out.println("found " + child);
+ String childName = childNames[index++];
+ Path.Segment segment = context.getValueFactories().getPathFactory().createSegment(childName);
+ assertThat(child.getChildName(), is(segment.getName().getLocalName()));
+ assertThat(child.getSameNameSiblingIndex(), is(segment.hasIndex() ? segment.getIndex() : 1));
+ assertThat(child.getIndexInParent(), is(index)); // index is incremented
+ }
+ }
+
+ @SuppressWarnings( "unchecked" )
+ protected void printChildren( String parentUuid ) {
+ Query query = manager.createNamedQuery("ChildEntity.findAllUnderParent");
+ query.setParameter("parentUuidString", parentUuid.toString());
+ List<ChildEntity> children = query.getResultList();
+ for (ChildEntity child : children) {
+ System.out.println("found " + child);
+ }
+
+ }
+}
17 years
DNA SVN: r683 - in trunk/extensions/dna-connector-svn/src: test/java/org/jboss/dna/connector/svn and 1 other directory.
by dna-commits@lists.jboss.org
Author: spagop
Date: 2008-12-11 17:02:26 -0500 (Thu, 11 Dec 2008)
New Revision: 683
Modified:
trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryRequestProcessor.java
trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNRepositoryConnectionTest.java
Log:
more testing about node properties
Modified: trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryRequestProcessor.java
===================================================================
--- trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryRequestProcessor.java 2008-12-11 20:55:11 UTC (rev 682)
+++ trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryRequestProcessor.java 2008-12-11 22:02:26 UTC (rev 683)
@@ -28,6 +28,7 @@
import java.util.Date;
import java.util.List;
import org.jboss.dna.common.i18n.I18n;
+import org.jboss.dna.common.util.Logger;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.JcrLexicon;
import org.jboss.dna.graph.JcrNtLexicon;
@@ -76,6 +77,7 @@
private final String defaultNamespaceUri;
private final boolean updatesAllowed;
private SVNRepository repository;
+ protected final Logger logger;
/**
* @param sourceName
@@ -92,6 +94,7 @@
this.defaultNamespaceUri = getExecutionContext().getNamespaceRegistry().getDefaultNamespaceUri();
this.updatesAllowed = updatesAllowed;
this.repository = repository;
+ this.logger = getExecutionContext().getLogger(getClass());
}
/**
@@ -142,6 +145,7 @@
@SuppressWarnings( "unchecked" )
@Override
public void process( ReadAllChildrenRequest request ) {
+ logger.trace(request.toString());
Location myLocation = request.of();
Path nodePath = getPathFor(myLocation, request);
try {
@@ -201,6 +205,7 @@
*/
@Override
public void process( ReadAllPropertiesRequest request ) {
+ logger.trace(request.toString());
Location myLocation = request.at();
Path nodePath = getPathFor(myLocation, request);
if (nodePath.isRoot()) {
@@ -218,29 +223,26 @@
Path parent = nodePath.getParent();
ByteArrayOutputStream os = new ByteArrayOutputStream();
SVNProperties fileProperties = new SVNProperties();
- List<Property> properties = new ArrayList<Property>();
getData(parent.getString(getExecutionContext().getNamespaceRegistry()), fileProperties, os);
Property ntResourceproperty = propertyFactory().create(JcrLexicon.PRIMARY_TYPE, JcrNtLexicon.RESOURCE);
- properties.add(ntResourceproperty);
+ request.addProperty(ntResourceproperty);
String mimeType = fileProperties.getStringValue(SVNProperty.MIME_TYPE);
if (mimeType != null) {
Property jcrMimeTypeProperty = propertyFactory().create(JcrLexicon.MIMETYPE, mimeType);
- properties.add(jcrMimeTypeProperty);
+ request.addProperty(jcrMimeTypeProperty);
}
SVNDirEntry entry = getEntryInfo(parent.getString(getExecutionContext().getNamespaceRegistry()));
Date lastModified = entry.getDate();
if (lastModified != null) {
Property jcrLastModifiedProperty = propertyFactory().create(JcrLexicon.LAST_MODIFIED,
dateFactory().create(lastModified));
- properties.add(jcrLastModifiedProperty);
+ request.addProperty(jcrLastModifiedProperty);
}
if (os.toByteArray().length > 0) {
Property jcrDataProperty = propertyFactory().create(JcrLexicon.DATA,
- binaryFactory().create(new InMemoryBinary(
- os.toByteArray())));
- properties.add(jcrDataProperty);
+ binaryFactory().create(os.toByteArray()));
+ request.addProperty(jcrDataProperty);
}
- request.addProperties(properties.toArray(new BasicMultiValueProperty[0]));
} else {
SVNNodeKind kind = validateNodeKind(nodePath);
if (kind == SVNNodeKind.FILE) {
@@ -259,10 +261,12 @@
} else if (kind == SVNNodeKind.DIR) {
// A directory maps to a single node with a name that represents the name of the directory and a
// "jcr:primaryType" property whose value is "nt:folder"
- Property property = propertyFactory().create(JcrLexicon.PRIMARY_TYPE, JcrNtLexicon.FOLDER);
- request.addProperty(property);
+ Property jcrPrimaryTypeProp = propertyFactory().create(JcrLexicon.PRIMARY_TYPE, JcrNtLexicon.FOLDER);
+ request.addProperty(jcrPrimaryTypeProp);
SVNDirEntry dirEntry = getEntryInfo(nodePath.getString(getExecutionContext().getNamespaceRegistry()));
- request.addProperty(propertyFactory().create(JcrLexicon.CREATED, dateFactory().create(dirEntry.getDate())));
+ Property jcrCreatedProp = propertyFactory().create(JcrLexicon.CREATED,
+ dateFactory().create(dirEntry.getDate()));
+ request.addProperty(jcrCreatedProp);
}
}
request.setActualLocationOfNode(myLocation);
Modified: trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNRepositoryConnectionTest.java
===================================================================
--- trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNRepositoryConnectionTest.java 2008-12-11 20:55:11 UTC (rev 682)
+++ trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNRepositoryConnectionTest.java 2008-12-11 22:02:26 UTC (rev 683)
@@ -26,10 +26,13 @@
import static org.hamcrest.core.IsSame.sameInstance;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.stub;
+import static org.mockito.Mockito.verify;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import org.jboss.dna.common.text.UrlEncoder;
import org.jboss.dna.common.util.FileUtil;
import org.jboss.dna.graph.BasicExecutionContext;
@@ -44,6 +47,7 @@
import org.jboss.dna.graph.properties.NameFactory;
import org.jboss.dna.graph.properties.PathFactory;
import org.jboss.dna.graph.properties.PathNotFoundException;
+import org.jboss.dna.graph.properties.Property;
import org.jboss.dna.graph.properties.PropertyFactory;
import org.jboss.dna.graph.requests.ReadAllChildrenRequest;
import org.junit.After;
@@ -74,6 +78,7 @@
@Mock
private ReadAllChildrenRequest request;
+ @SuppressWarnings( "deprecation" )
@Before
public void beforeEach() throws Exception {
MockitoAnnotations.initMocks(this);
@@ -96,7 +101,7 @@
// Now set the two path roots
String svnUrl = dst.getCanonicalFile().toURL().toString();
- svnUrl = svnUrl.replaceFirst("file:/", "file:///"); // add the 'localhost'
+ svnUrl = svnUrl.replaceFirst("file:/", "file://localhost/");
String username = "sp";
String password = "";
// Create a Repository instance from the http-protocol, that use a anonymous credential.
@@ -151,7 +156,7 @@
// CachePolicy policy = mock(CachePolicy.class);
// repository = mock(SVNRepository.class);
// connection = new SVNRepositoryConnection("the source name", policy, false, repository);
- // stub(repository.getRepositoryRoot(true)).toReturn(null);
+ // // stub(repository.getRepositoryRoot(true)).toReturn(null);
// assertThat(connection.ping(1, TimeUnit.SECONDS), is(true));
// verify(repository).getRepositoryRoot(true);
// }
@@ -190,7 +195,7 @@
}
@Test
- public void shouldListLocationForChildrenOfAParentPath() {
+ public void shouldListChildrenLocationPathsOfASpecificPath() {
// read children from the root node.
List<Location> l = graph.getChildren().of(pathFactory.create("/"));
@@ -208,6 +213,45 @@
assertThat(containsPaths(locations03).contains("/nodeB/nodeB1"), is(true));
}
+ @Test
+ public void shouldNotHaveProperties() {
+ // Root location does not need properties.
+ Location root = new Location(pathFactory.create("/"));
+ Collection<Property> nilProperties = graph.getProperties().on(root);
+ assertThat(nilProperties, is(notNullValue()));
+ assertThat(nilProperties.isEmpty(), is(true));
+ }
+
+ @Test
+ public void shouldJustCatchThePropertiesOnLocation() {
+ // directory nodeA has "jcr:primaryType" with value "nt:folder" and also "jcr:created" with value folder created date
+ Location nodeA = new Location(pathFactory.create("/nodeA"));
+ Collection<Property> nodeAProperties = graph.getProperties().on(nodeA);
+ assertThat(nodeAProperties, is(notNullValue()));
+ assertThat(nodeAProperties.isEmpty(), is(false));
+ assertThat(nodeAProperties.size(), is(2));
+
+ // file itemA.txt has "jcr:primaryType" property whose value is "nt:file" and also "jcr:created" with value folder created
+ // date
+ Location itemA1 = new Location(pathFactory.create("/nodeA/itemA1.txt"));
+ Collection<Property> itemA1Properties = graph.getProperties().on(itemA1);
+ assertThat(itemA1Properties, is(notNullValue()));
+ assertThat(itemA1Properties.isEmpty(), is(false));
+ assertThat(itemA1Properties.size(), is(2));
+
+ // content itemA1.txt/jcr:content
+ // //"jcr:primaryType" property value of "nt:resource",
+ // "jcr:data" property whose value are the contents of the file
+ // and a few other properties, like "jcr:encoding", "jcr:mimeType" and "jcr:lastModified" and
+ // also "jcr:created" property
+ Location content = new Location(pathFactory.create("/nodeA/itemA2.txt/jcr:content"));
+ Collection<Property> itemA2ContentProperties = graph.getProperties().on(content);
+ assertThat(itemA2ContentProperties, is(notNullValue()));
+ assertThat(itemA2ContentProperties.isEmpty(), is(false));
+ // then for any causes, that I do not know now mimeType of this content is null.
+ assertThat(itemA2ContentProperties.size(), is(3));
+ }
+
protected Collection<String> containsPaths( Collection<Location> locations ) {
List<String> paths = new ArrayList<String>();
for (Location location : locations) {
17 years
DNA SVN: r682 - trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/basic.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2008-12-11 15:55:11 -0500 (Thu, 11 Dec 2008)
New Revision: 682
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/basic/BasicName.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/basic/NameValueFactory.java
Log:
DNA-250 - Creating a path from a parent path and a segment is not fast
Minor tweaks to NameValueFactory.create(String,...) to more efficiently determine the pattern (either internal form with full namespace URIs, or traditional prefixed form) that is used to first parse the string. Before this change, the internal pattern was almost always used first, despite the fact that most names are created with strings containing the prefixed form.
Also changed the BasicName constructor so that strings representing URIs are interned, since there shouldn't be too many of those, and we really want there to be one string instance for each namespace shared by all the names.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/basic/BasicName.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/basic/BasicName.java 2008-12-11 19:42:19 UTC (rev 681)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/basic/BasicName.java 2008-12-11 20:55:11 UTC (rev 682)
@@ -38,6 +38,12 @@
@Immutable
public class BasicName implements Name {
+ private String trimNonEmptyStrings( String value ) {
+ if (value == null) return null;
+ String trimmed = value.trim();
+ return trimmed.length() == 0 ? value : trimmed;
+ }
+
/**
*/
private static final long serialVersionUID = -1737537720336990144L;
@@ -48,8 +54,8 @@
public BasicName( String namespaceUri,
String localName ) {
CheckArg.isNotEmpty(localName, "localName");
- this.namespaceUri = namespaceUri != null ? namespaceUri.trim() : "";
- this.localName = localName != null ? localName.trim() : "";
+ this.namespaceUri = namespaceUri != null ? namespaceUri.trim().intern() : "";
+ this.localName = trimNonEmptyStrings(localName);
this.hc = HashCode.compute(this.namespaceUri, this.localName);
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/basic/NameValueFactory.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/basic/NameValueFactory.java 2008-12-11 19:42:19 UTC (rev 681)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/basic/NameValueFactory.java 2008-12-11 20:55:11 UTC (rev 682)
@@ -89,7 +89,28 @@
if (value == null) return null;
if (decoder == null) decoder = getDecoder();
try {
- // First see whether the value fits the internal pattern ...
+ if (value.length() == 0) {
+ return new BasicName("", "");
+ }
+ if (value.charAt(0) != '{') {
+ // First, see whether the value fits the prefixed name pattern ...
+ Matcher matcher = PREFIXED_NAME_PATTERN.matcher(value);
+ if (matcher.matches()) {
+ String prefix = matcher.group(2);
+ String localName = matcher.group(3);
+ // Decode the parts ...
+ prefix = prefix == null ? "" : decoder.decode(prefix);
+ localName = decoder.decode(localName);
+ // Look for a namespace match ...
+ String namespaceUri = this.namespaceRegistry.getNamespaceForPrefix(prefix);
+ // Fail if no namespace is found ...
+ if (namespaceUri == null) {
+ throw new NamespaceException(GraphI18n.noNamespaceRegisteredForPrefix.text(prefix));
+ }
+ return new BasicName(namespaceUri, localName);
+ }
+ }
+ // If it doesn't fit the prefixed pattern, then try the internal pattern
Matcher matcher = FULLY_QUALIFIED_NAME_PATTERN.matcher(value);
if (matcher.matches()) {
String namespaceUri = matcher.group(1);
@@ -99,31 +120,15 @@
localName = decoder.decode(localName);
return new BasicName(namespaceUri, localName);
}
- // Second, see whether the value fits the prefixed name pattern ...
- matcher = PREFIXED_NAME_PATTERN.matcher(value);
- if (matcher.matches()) {
- String prefix = matcher.group(2);
- String localName = matcher.group(3);
- // Decode the parts ...
- prefix = prefix == null ? "" : decoder.decode(prefix);
- localName = decoder.decode(localName);
- // Look for a namespace match ...
- String namespaceUri = this.namespaceRegistry.getNamespaceForPrefix(prefix);
- // Fail if no namespace is found ...
- if (namespaceUri == null) {
- throw new NamespaceException(GraphI18n.noNamespaceRegisteredForPrefix.text(prefix));
- }
- return new BasicName(namespaceUri, localName);
- }
} catch (NamespaceException err) {
throw new ValueFormatException(value, getPropertyType(),
GraphI18n.errorConvertingType.text(String.class.getSimpleName(),
- Name.class.getSimpleName(),
- value), err);
+ Name.class.getSimpleName(),
+ value), err);
}
throw new ValueFormatException(value, getPropertyType(), GraphI18n.errorConvertingType.text(String.class.getSimpleName(),
- Name.class.getSimpleName(),
- value));
+ Name.class.getSimpleName(),
+ value));
}
/**
@@ -151,9 +156,10 @@
* {@inheritDoc}
*/
public Name create( int value ) {
- throw new ValueFormatException(value, getPropertyType(), GraphI18n.unableToCreateValue.text(getPropertyType().getName(),
- Integer.class.getSimpleName(),
- value));
+ throw new ValueFormatException(value, getPropertyType(),
+ GraphI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Integer.class.getSimpleName(),
+ value));
}
/**
@@ -161,17 +167,18 @@
*/
public Name create( long value ) {
throw new ValueFormatException(value, getPropertyType(), GraphI18n.unableToCreateValue.text(getPropertyType().getName(),
- Long.class.getSimpleName(),
- value));
+ Long.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
public Name create( boolean value ) {
- throw new ValueFormatException(value, getPropertyType(), GraphI18n.unableToCreateValue.text(getPropertyType().getName(),
- Boolean.class.getSimpleName(),
- value));
+ throw new ValueFormatException(value, getPropertyType(),
+ GraphI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Boolean.class.getSimpleName(),
+ value));
}
/**
@@ -179,8 +186,8 @@
*/
public Name create( float value ) {
throw new ValueFormatException(value, getPropertyType(), GraphI18n.unableToCreateValue.text(getPropertyType().getName(),
- Float.class.getSimpleName(),
- value));
+ Float.class.getSimpleName(),
+ value));
}
/**
@@ -188,8 +195,8 @@
*/
public Name create( double value ) {
throw new ValueFormatException(value, getPropertyType(), GraphI18n.unableToCreateValue.text(getPropertyType().getName(),
- Double.class.getSimpleName(),
- value));
+ Double.class.getSimpleName(),
+ value));
}
/**
@@ -198,17 +205,18 @@
public Name create( BigDecimal value ) {
throw new ValueFormatException(value, getPropertyType(),
GraphI18n.unableToCreateValue.text(getPropertyType().getName(),
- BigDecimal.class.getSimpleName(),
- value));
+ BigDecimal.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
public Name create( Calendar value ) {
- throw new ValueFormatException(value, getPropertyType(), GraphI18n.unableToCreateValue.text(getPropertyType().getName(),
- Calendar.class.getSimpleName(),
- value));
+ throw new ValueFormatException(value, getPropertyType(),
+ GraphI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Calendar.class.getSimpleName(),
+ value));
}
/**
@@ -216,8 +224,8 @@
*/
public Name create( Date value ) {
throw new ValueFormatException(value, getPropertyType(), GraphI18n.unableToCreateValue.text(getPropertyType().getName(),
- Date.class.getSimpleName(),
- value));
+ Date.class.getSimpleName(),
+ value));
}
/**
@@ -226,9 +234,10 @@
* @see org.jboss.dna.graph.properties.ValueFactory#create(org.jboss.dna.graph.properties.DateTime)
*/
public Name create( DateTime value ) throws ValueFormatException {
- throw new ValueFormatException(value, getPropertyType(), GraphI18n.unableToCreateValue.text(getPropertyType().getName(),
- DateTime.class.getSimpleName(),
- value));
+ throw new ValueFormatException(value, getPropertyType(),
+ GraphI18n.unableToCreateValue.text(getPropertyType().getName(),
+ DateTime.class.getSimpleName(),
+ value));
}
/**
@@ -248,8 +257,8 @@
return value.getSegment(0).getName();
}
throw new ValueFormatException(value, getPropertyType(), GraphI18n.errorConvertingType.text(Path.class.getSimpleName(),
- Name.class.getSimpleName(),
- value));
+ Name.class.getSimpleName(),
+ value));
}
/**
@@ -258,8 +267,8 @@
public Name create( Reference value ) {
throw new ValueFormatException(value, getPropertyType(),
GraphI18n.unableToCreateValue.text(getPropertyType().getName(),
- Reference.class.getSimpleName(),
- value));
+ Reference.class.getSimpleName(),
+ value));
}
/**
@@ -276,8 +285,8 @@
return create(asciiString);
}
throw new ValueFormatException(value, getPropertyType(), GraphI18n.errorConvertingType.text(URI.class.getSimpleName(),
- Path.class.getSimpleName(),
- value));
+ Path.class.getSimpleName(),
+ value));
}
/**
@@ -287,8 +296,8 @@
*/
public Name create( UUID value ) throws IoException {
throw new ValueFormatException(value, getPropertyType(), GraphI18n.unableToCreateValue.text(getPropertyType().getName(),
- UUID.class.getSimpleName(),
- value));
+ UUID.class.getSimpleName(),
+ value));
}
/**
17 years
DNA SVN: r681 - in trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models: common and 1 other directory.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2008-12-11 14:42:19 -0500 (Thu, 11 Dec 2008)
New Revision: 681
Added:
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/common/ChangeLogEntity.java
Modified:
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/BasicModel.java
Log:
DNA-40
Added a table to store the change log, and changed BasicModel to include it in its schema (though it is not currently populated in BasicModel). Also added some explanatory JavaDocs to BasicModel.
Modified: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/BasicModel.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/BasicModel.java 2008-12-11 17:41:47 UTC (rev 680)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/BasicModel.java 2008-12-11 19:42:19 UTC (rev 681)
@@ -26,13 +26,65 @@
import org.hibernate.ejb.Ejb3Configuration;
import org.jboss.dna.connector.store.jpa.JpaConnectorI18n;
import org.jboss.dna.connector.store.jpa.Model;
+import org.jboss.dna.connector.store.jpa.models.common.ChangeLogEntity;
import org.jboss.dna.connector.store.jpa.models.common.NamespaceEntity;
import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.requests.CopyBranchRequest;
+import org.jboss.dna.graph.requests.DeleteBranchRequest;
+import org.jboss.dna.graph.requests.MoveBranchRequest;
+import org.jboss.dna.graph.requests.ReadBranchRequest;
import org.jboss.dna.graph.requests.processor.RequestProcessor;
/**
* Database model that stores node properties as opaque records and children as transparent records. Large property values are
* stored separately.
+ * <p>
+ * The set of tables used in this model includes:
+ * <ul>
+ * <li>Namespaces - the set of namespace URIs used in paths, property names, and property values.</li>
+ * <li>Properties - the properties for each node, stored in a serialized (and optionally compressed) form.</li>
+ * <li>Large values - property values larger than a certain size will be broken out into this table, where they are tracked by
+ * their SHA-1 has and shared by all properties that have that same value. The values are stored in a binary (and optionally
+ * compressed) form.</li>
+ * <li>Children - the children for each node, where each child is represented by a separate record. This approach makes it
+ * possible to efficiently work with nodes containing large numbers of children, where adding and removing child nodes is largely
+ * independent of the number of children. Also, working with properties is also completely independent of the number of child
+ * nodes.</li>
+ * <li>Subgraph - a working area for efficiently computing the space of a subgraph; see below</li>
+ * <li>Change log - a record of the changes that have been made to the repository. This is used to distribute change events across
+ * multiple distributed processes, and to allow a recently-connected client to identify the set of changes that have been made
+ * since a particular time or date. Changes are serialized into a binary, compressed format.</i></li>
+ * <li>Options - the parameters for this store's configuration (common to all models)</li>
+ * </ul>
+ * </p>
+ * <h3>Subgraph queries</h3>
+ * <p>
+ * This database model contains two tables that are used in an efficient mechanism to find all of the nodes in the subgraph below
+ * a certain node. This process starts by creating a record for the subgraph query, and then proceeds by executing a join to find
+ * all the children of the top-level node, and inserting them into the database (in a working area associated with the subgraph
+ * query). Then, another join finds all the children of those children and inserts them into the same working area. This continues
+ * until the maximum depth has been reached, or until there are no more children (whichever comes first). All of the nodes in the
+ * subgraph are then represented by records in the working area, and can be used to quickly and efficient work with the subgraph
+ * nodes. When finished, the mechanism deletes the records in the working area associated with the subgraph query.
+ * </p>
+ * <p>
+ * This subgraph query mechanism is extremely efficient, performing one join/insert statement <i>per level of the subgraph</i>,
+ * and is completely independent of the number of nodes in the subgraph. For example, consider a subgraph of node A, where A has
+ * 10 children, and each child contains 10 children, and each grandchild contains 10 children. This subgraph has a total of 1111
+ * nodes (1 root + 10 children + 10*10 grandchildren + 10*10*10 great-grandchildren). Finding the nodes in this subgraph would
+ * normally require 1 query per node (in other words, 1111 queries). But with this subgraph query mechanism, all of the nodes in
+ * the subgraph can be found with 1 insert plus 4 additional join/inserts.
+ * </p>
+ * <p>
+ * This mechanism has the added benefit that the set of nodes in the subgraph are kept in a working area in the database, meaning
+ * they don't have to be pulled into memory.
+ * </p>
+ * <p>
+ * Subgraph queries are used to efficiently process a number of different requests, including {@link ReadBranchRequest},
+ * {@link DeleteBranchRequest}, {@link MoveBranchRequest}, and {@link CopyBranchRequest}. Processing each of these kinds of
+ * requests requires knowledge of the subgraph, and in fact all but the <code>ReadBranchRequest</code> need to know the complete
+ * subgraph.
+ * </p>
*
* @author Randall Hauch
*/
@@ -76,6 +128,7 @@
configurator.addAnnotatedClass(ChildId.class);
configurator.addAnnotatedClass(SubgraphQueryEntity.class);
configurator.addAnnotatedClass(SubgraphNodeEntity.class);
+ configurator.addAnnotatedClass(ChangeLogEntity.class);
// Set the cache information for each persistent class ...
// configurator.setProperty("hibernate.ejb.classcache." + KidpackNode.class.getName(), "read-write");
Added: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/common/ChangeLogEntity.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/common/ChangeLogEntity.java (rev 0)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/common/ChangeLogEntity.java 2008-12-11 19:42:19 UTC (rev 681)
@@ -0,0 +1,148 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.store.jpa.models.common;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import org.hibernate.annotations.Index;
+import org.jboss.dna.graph.properties.DateTime;
+import org.jboss.dna.graph.properties.basic.JodaDateTime;
+
+/**
+ * Represents a record of the changes that have been made to the repository. The actual change events are serialized and stored in
+ * a binary (and compressed) format.
+ *
+ * @author Randall Hauch
+ */
+@Entity
+@Table( name = "DNA_CHANGELOG" )
+(a)org.hibernate.annotations.Table( appliesTo = "DNA_CHANGELOG", indexes = @Index( name = "NS_CHANGE_TS_INX", columnNames = {"UTC_TIMESTAMP"} ) )
+@NamedQueries( {
+ @NamedQuery( name = "ChangeLogEntity.findBetween", query = "select entry from ChangeLogEntity as entry where entry.timestampInUtc >= :start and entry.timestampInUtc <= :end" ),
+ @NamedQuery( name = "ChangeLogEntity.deleteBefore", query = "delete ChangeLogEntity entry where entry.timestampInUtc < :timestamp" )} )
+public class ChangeLogEntity {
+
+ @Id
+ @GeneratedValue( strategy = GenerationType.AUTO )
+ @Column( name = "ID", updatable = false )
+ private Long id;
+
+ @Column( name = "USERNAME", updatable = false, nullable = false, length = 64, unique = false )
+ private String username;
+
+ @Column( name = "UTC_TIMESTAMP", updatable = false, nullable = false, unique = false )
+ private long timestampInUtc;
+
+ @Column( name = "CHANGE_COUNT", updatable = false, nullable = false, unique = false )
+ private int numChanges;
+
+ @Lob
+ @Column( name = "CHANGES", updatable = false, nullable = false, unique = false )
+ private byte[] changes;
+
+ public ChangeLogEntity( String username,
+ DateTime timestamp,
+ int numChanges,
+ byte[] changes ) {
+ this.username = username;
+ this.timestampInUtc = timestamp.toUtcTimeZone().getMilliseconds();
+ this.numChanges = numChanges;
+ this.changes = changes;
+ }
+
+ /**
+ * @return id
+ */
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * @return username
+ */
+ public String getUsername() {
+ return username;
+ }
+
+ /**
+ * @return timestampInUtc
+ */
+ public long getTimestampInUtc() {
+ return timestampInUtc;
+ }
+
+ /**
+ * @return changes
+ */
+ public byte[] getChanges() {
+ return changes;
+ }
+
+ /**
+ * @return numChanges
+ */
+ public int getNumChanges() {
+ return numChanges;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals( Object obj ) {
+ if (obj == this) return true;
+ if (obj instanceof ChangeLogEntity) {
+ ChangeLogEntity that = (ChangeLogEntity)obj;
+ return id.equals(that.id);
+ }
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "" + numChanges + " changes by " + username + " at " + new JodaDateTime(timestampInUtc);
+ }
+}
Property changes on: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/common/ChangeLogEntity.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
17 years
DNA SVN: r680 - trunk/dna-graph/src/test/java/org/jboss/dna/graph.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2008-12-11 12:41:47 -0500 (Thu, 11 Dec 2008)
New Revision: 680
Added:
trunk/dna-graph/src/test/java/org/jboss/dna/graph/IsNodeWithChildren.java
Log:
DNA-40 Added some optimizations to the basic model implementation, centered around a cache of locations that have been found during the current transaction. This dramatically improves the performance of the connector when requests are processed in batches. Also corrected some behavior related to getting subgraphs and to making changes (primarily deleting).
Finally, I added some 'getString(...)' methods to Property and Location, making it easier to get usable string representations that use namespaces and encodings.
Added: trunk/dna-graph/src/test/java/org/jboss/dna/graph/IsNodeWithChildren.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/IsNodeWithChildren.java (rev 0)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/IsNodeWithChildren.java 2008-12-11 17:41:47 UTC (rev 680)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.graph;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.hamcrest.Description;
+import org.hamcrest.Factory;
+import org.hamcrest.Matcher;
+import org.jboss.dna.graph.properties.Name;
+import org.jboss.dna.graph.properties.Path;
+import org.jboss.dna.graph.properties.basic.BasicPathSegment;
+import org.junit.matchers.IsCollectionContaining;
+import org.junit.matchers.TypeSafeMatcher;
+
+/**
+ * @author Randall Hauch
+ */
+public class IsNodeWithChildren extends TypeSafeMatcher<List<Location>> {
+ private final Matcher<Iterable<Path.Segment>> childMatcher;
+
+ public IsNodeWithChildren( Matcher<Iterable<Path.Segment>> childMatcher ) {
+ this.childMatcher = childMatcher;
+ }
+
+ @Override
+ public boolean matchesSafely( List<Location> children ) {
+ List<Path.Segment> childSegments = new ArrayList<Path.Segment>(children.size());
+ for (Location child : children) {
+ childSegments.add(child.getPath().getLastSegment());
+ }
+ return childMatcher.matches(childSegments);
+ }
+
+ public void describeTo( Description description ) {
+ description.appendText("children").appendDescriptionOf(childMatcher);
+ }
+
+ @Factory
+ public static IsNodeWithChildren hasChild( Name name,
+ int sameNameSiblingIndex ) {
+ Path.Segment segment = new BasicPathSegment(name, sameNameSiblingIndex);
+ return new IsNodeWithChildren(IsCollectionContaining.hasItem(segment));
+ }
+
+ @Factory
+ public static IsNodeWithChildren hasChild( Path.Segment child ) {
+ return new IsNodeWithChildren(IsCollectionContaining.hasItem(child));
+ }
+
+ @Factory
+ public static IsNodeWithChildren hasChildren( Path.Segment... childSegments ) {
+ return new IsNodeWithChildren(IsCollectionContaining.hasItems(childSegments));
+ }
+
+ @Factory
+ public static IsNodeWithChildren isEmpty() {
+ Path.Segment[] childSegments = new Path.Segment[] {};
+ return new IsNodeWithChildren(IsCollectionContaining.hasItems(childSegments));
+ }
+
+}
17 years
DNA SVN: r679 - in trunk: dna-graph/src/main/java/org/jboss/dna/graph/properties and 9 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2008-12-11 12:37:40 -0500 (Thu, 11 Dec 2008)
New Revision: 679
Added:
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/util/RequestProcessorCache.java
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectionUsingHsqldbTest.java
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/util/RequestProcessorCacheTest.java
Removed:
trunk/dna-graph/src/test/java/org/jboss/dna/graph/IsNodeWithChildren.java
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/Location.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/Subgraph.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/Property.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/basic/BasicName.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/basic/BasicProperty.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/BasicRequestProcessor.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/SubgraphNodeEntity.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/SubgraphQuery.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/common/NamespaceEntity.java
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectionTest.java
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/models/basic/SubgraphQueryTest.java
trunk/extensions/dna-connector-store-jpa/src/test/resources/log4j.properties
Log:
DNA-40 Added some optimizations to the basic model implementation, centered around a cache of locations that have been found during the current transaction. This dramatically improves the performance of the connector when requests are processed in batches. Also corrected some behavior related to getting subgraphs and to making changes (primarily deleting).
Finally, I added some 'getString(...)' methods to Property and Location, making it easier to get usable string representations that use namespaces and encodings.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/Location.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/Location.java 2008-12-10 02:27:52 UTC (rev 678)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/Location.java 2008-12-11 17:37:40 UTC (rev 679)
@@ -28,9 +28,11 @@
import java.util.NoSuchElementException;
import java.util.UUID;
import net.jcip.annotations.Immutable;
+import org.jboss.dna.common.text.TextEncoder;
import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.common.util.HashCode;
import org.jboss.dna.graph.properties.Name;
+import org.jboss.dna.graph.properties.NamespaceRegistry;
import org.jboss.dna.graph.properties.Path;
import org.jboss.dna.graph.properties.Property;
import org.jboss.dna.graph.properties.basic.BasicSingleValueProperty;
@@ -461,6 +463,108 @@
}
/**
+ * Get the string form of the location.
+ *
+ * @return the string
+ * @see #getString(TextEncoder)
+ * @see #getString(NamespaceRegistry)
+ * @see #getString(NamespaceRegistry, TextEncoder)
+ * @see #getString(NamespaceRegistry, TextEncoder, TextEncoder)
+ */
+ public String getString() {
+ return getString(null, null, null);
+ }
+
+ /**
+ * Get the encoded string form of the location, using the supplied encoder to encode characters in each of the location's path
+ * and properties.
+ *
+ * @param encoder the encoder to use, or null if the default encoder should be used
+ * @return the encoded string
+ * @see #getString()
+ * @see #getString(NamespaceRegistry)
+ * @see #getString(NamespaceRegistry, TextEncoder)
+ * @see #getString(NamespaceRegistry, TextEncoder, TextEncoder)
+ */
+ public String getString( TextEncoder encoder ) {
+ return getString(null, encoder, null);
+ }
+
+ /**
+ * Get the encoded string form of the location, using the supplied encoder to encode characters in each of the location's path
+ * and properties.
+ *
+ * @param namespaceRegistry the namespace registry to use for getting the string form of the path and properties, or null if
+ * no namespace registry should be used
+ * @return the encoded string
+ * @see #getString()
+ * @see #getString(TextEncoder)
+ * @see #getString(NamespaceRegistry, TextEncoder)
+ * @see #getString(NamespaceRegistry, TextEncoder, TextEncoder)
+ */
+ public String getString( NamespaceRegistry namespaceRegistry ) {
+ CheckArg.isNotNull(namespaceRegistry, "namespaceRegistry");
+ return getString(namespaceRegistry, null, null);
+ }
+
+ /**
+ * Get the encoded string form of the location, using the supplied encoder to encode characters in each of the location's path
+ * and properties.
+ *
+ * @param namespaceRegistry the namespace registry to use for getting the string form of the path and properties, or null if
+ * no namespace registry should be used
+ * @param encoder the encoder to use, or null if the default encoder should be used
+ * @return the encoded string
+ * @see #getString()
+ * @see #getString(TextEncoder)
+ * @see #getString(NamespaceRegistry)
+ * @see #getString(NamespaceRegistry, TextEncoder, TextEncoder)
+ */
+ public String getString( NamespaceRegistry namespaceRegistry,
+ TextEncoder encoder ) {
+ CheckArg.isNotNull(namespaceRegistry, "namespaceRegistry");
+ return getString(namespaceRegistry, encoder, null);
+ }
+
+ /**
+ * Get the encoded string form of the location, using the supplied encoder to encode characters in each of the location's path
+ * and properties.
+ *
+ * @param namespaceRegistry the namespace registry to use for getting the string form of the path and properties, or null if
+ * no namespace registry should be used
+ * @param encoder the encoder to use, or null if the default encoder should be used
+ * @param delimiterEncoder the encoder to use for encoding the delimiters in paths, names, and properties, or null if the
+ * standard delimiters should be used
+ * @return the encoded string
+ * @see #getString()
+ * @see #getString(TextEncoder)
+ * @see #getString(NamespaceRegistry)
+ * @see #getString(NamespaceRegistry, TextEncoder)
+ */
+ public String getString( NamespaceRegistry namespaceRegistry,
+ TextEncoder encoder,
+ TextEncoder delimiterEncoder ) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("{ ");
+ if (this.hasPath()) {
+ sb.append(this.getPath().getString(namespaceRegistry, encoder, delimiterEncoder));
+ if (this.hasIdProperties()) sb.append(" && ");
+ }
+ if (this.hasIdProperties()) {
+ sb.append("[");
+ boolean first = true;
+ for (Property idProperty : this.getIdProperties()) {
+ if (first) first = false;
+ else sb.append(", ");
+ sb.append(idProperty.getString(namespaceRegistry, encoder, delimiterEncoder));
+ }
+ sb.append("]");
+ }
+ sb.append(" }");
+ return sb.toString();
+ }
+
+ /**
* {@inheritDoc}
*
* @see java.lang.Object#toString()
@@ -468,15 +572,22 @@
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
+ sb.append("{ ");
if (this.hasPath()) {
- if (this.hasIdProperties()) sb.append("[ ");
sb.append(this.getPath());
if (this.hasIdProperties()) sb.append(" && ");
}
if (this.hasIdProperties()) {
- sb.append(this.getIdProperties().toString());
- if (this.hasPath()) sb.append(" ]");
+ sb.append("[");
+ boolean first = true;
+ for (Property idProperty : this.getIdProperties()) {
+ if (first) first = false;
+ else sb.append(", ");
+ sb.append(idProperty);
+ }
+ sb.append("]");
}
+ sb.append(" }");
return sb.toString();
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/Subgraph.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/Subgraph.java 2008-12-10 02:27:52 UTC (rev 678)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/Subgraph.java 2008-12-11 17:37:40 UTC (rev 679)
@@ -31,6 +31,12 @@
* Since this subgraph has a single {@link #getLocation() node that is the top of the subgraph}, the methods that take a String
* path or {@link Path path object} will accept absolute or relative paths.
* </p>
+ * <p>
+ * This subgraph will not contain any {@link #iterator() nodes} that exist below the {@link #getMaximumDepth() maximum depth}.
+ * Also, all nodes included in the subgraph have all their properties and children. However, nodes that are at the maximum depth
+ * of the subgraph will contain the locations for child nodes that are below the maximum depth and therefore not included in this
+ * subgraph.
+ * </p>
*
* @author Randall Hauch
*/
@@ -38,9 +44,9 @@
public interface Subgraph extends Results {
/**
- * Get the location of the node.
+ * Get the location of the subgraph, which is the location of the node at the top of the subgraph.
*
- * @return the node's location
+ * @return the location of the top node in the subgraph; never null
*/
Location getLocation();
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/Property.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/Property.java 2008-12-10 02:27:52 UTC (rev 678)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/Property.java 2008-12-11 17:37:40 UTC (rev 679)
@@ -23,6 +23,7 @@
import java.util.Iterator;
import net.jcip.annotations.Immutable;
+import org.jboss.dna.common.text.TextEncoder;
/**
* Representation of a property consisting of a name and value(s). Note that this property is immutable, meaning that the property
@@ -153,4 +154,66 @@
*/
Object[] getValuesAsArray();
+ /**
+ * Get the string form of the property, using the default encoder.
+ *
+ * @return the encoded string
+ * @see #getString(TextEncoder)
+ */
+ public String getString();
+
+ /**
+ * Get the encoded string form of the property, using the supplied encoder to encode characters in the property's name and
+ * values.
+ *
+ * @param encoder the encoder to use, or null if the default encoder should be used
+ * @return the encoded string
+ * @see #getString()
+ */
+ public String getString( TextEncoder encoder );
+
+ /**
+ * Get the string form of the property, using the supplied namespace registry to convert the property's name and values.
+ *
+ * @param namespaceRegistry the namespace registry that should be used to obtain the prefix for the
+ * {@link Name#getNamespaceUri() namespace URIs} in the property {@link #getName() name}
+ * @return the string
+ * @throws IllegalArgumentException if the namespace registry is null
+ * @see #getString(NamespaceRegistry,TextEncoder)
+ * @see #getString(NamespaceRegistry, TextEncoder, TextEncoder)
+ */
+ public String getString( NamespaceRegistry namespaceRegistry );
+
+ /**
+ * Get the encoded string form of the property, using the supplied namespace registry to convert the property's namespace URIs
+ * to prefixes and the supplied encoder to encode characters in the property's name and values.
+ *
+ * @param namespaceRegistry the namespace registry that should be used to obtain the prefix for the
+ * {@link Name#getNamespaceUri() namespace URIs} in the property {@link #getName() name}, or null if the namespace
+ * registry should not be used
+ * @param encoder the encoder to use for encoding the name and values, or null if the default encoder should be used
+ * @return the encoded string
+ * @see #getString(NamespaceRegistry)
+ * @see #getString(NamespaceRegistry, TextEncoder, TextEncoder)
+ */
+ public String getString( NamespaceRegistry namespaceRegistry,
+ TextEncoder encoder );
+
+ /**
+ * Get the encoded string form of the property, using the supplied namespace registry to convert the property's namespace URIs
+ * to prefixes and the supplied encoder to encode characters in the property's name and values.
+ *
+ * @param namespaceRegistry the namespace registry that should be used to obtain the prefix for the
+ * {@link Name#getNamespaceUri() namespace URIs} in the property {@link #getName() name}, or null if the namespace
+ * registry should not be used
+ * @param encoder the encoder to use for encoding the name and values, or null if the default encoder should be used
+ * @param delimiterEncoder the encoder to use for encoding delimiters used in paths and names, or null if the standard
+ * delimiters should be used
+ * @return the encoded string
+ * @see #getString(NamespaceRegistry)
+ * @see #getString(NamespaceRegistry, TextEncoder)
+ */
+ public String getString( NamespaceRegistry namespaceRegistry,
+ TextEncoder encoder,
+ TextEncoder delimiterEncoder );
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/basic/BasicName.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/basic/BasicName.java 2008-12-10 02:27:52 UTC (rev 678)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/basic/BasicName.java 2008-12-11 17:37:40 UTC (rev 679)
@@ -134,6 +134,7 @@
return "{" + encoder.encode(this.namespaceUri) + "}" + encoder.encode(this.localName);
}
+ if (encoder == null) encoder = Path.DEFAULT_ENCODER;
String prefix = namespaceRegistry.getPrefixForNamespaceUri(this.namespaceUri, true);
if (prefix != null && prefix.length() != 0) {
String delim = delimiterEncoder != null ? delimiterEncoder.encode(":") : ":";
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/basic/BasicProperty.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/basic/BasicProperty.java 2008-12-10 02:27:52 UTC (rev 678)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/basic/BasicProperty.java 2008-12-11 17:37:40 UTC (rev 679)
@@ -24,7 +24,11 @@
import java.util.Arrays;
import java.util.Iterator;
import net.jcip.annotations.Immutable;
+import org.jboss.dna.common.text.TextEncoder;
+import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.graph.properties.Name;
+import org.jboss.dna.graph.properties.NamespaceRegistry;
+import org.jboss.dna.graph.properties.Path;
import org.jboss.dna.graph.properties.Property;
import org.jboss.dna.graph.properties.ValueComparators;
@@ -111,7 +115,73 @@
/**
* {@inheritDoc}
+ */
+ public String getString() {
+ return getString(null, null, null);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getString( TextEncoder encoder ) {
+ return getString(null, encoder, null);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getString( NamespaceRegistry namespaceRegistry ) {
+ CheckArg.isNotNull(namespaceRegistry, "namespaceRegistry");
+ return getString(namespaceRegistry, null, null);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getString( NamespaceRegistry namespaceRegistry,
+ TextEncoder encoder ) {
+ CheckArg.isNotNull(namespaceRegistry, "namespaceRegistry");
+ return getString(namespaceRegistry, encoder, null);
+ }
+
+ /**
+ * {@inheritDoc}
*
+ * @see org.jboss.dna.graph.properties.Path#getString(org.jboss.dna.graph.properties.NamespaceRegistry,
+ * org.jboss.dna.common.text.TextEncoder, org.jboss.dna.common.text.TextEncoder)
+ */
+ public String getString( NamespaceRegistry namespaceRegistry,
+ TextEncoder encoder,
+ TextEncoder delimiterEncoder ) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(getName().getString(namespaceRegistry, encoder, delimiterEncoder));
+ sb.append(" = ");
+ if (isEmpty()) {
+ sb.append("null");
+ } else {
+ if (isMultiple()) sb.append("[");
+ boolean first = true;
+ for (Object value : this) {
+ if (first) first = false;
+ else sb.append(",");
+ if (value instanceof Path) {
+ Path path = (Path)value;
+ sb.append(path.getString(namespaceRegistry, encoder, delimiterEncoder));
+ } else if (value instanceof Name) {
+ Name name = (Name)value;
+ sb.append(name.getString(namespaceRegistry, encoder, delimiterEncoder));
+ } else {
+ sb.append(value);
+ }
+ }
+ if (isMultiple()) sb.append("]");
+ }
+ return sb.toString();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see java.lang.Object#toString()
*/
@Override
Deleted: trunk/dna-graph/src/test/java/org/jboss/dna/graph/IsNodeWithChildren.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/IsNodeWithChildren.java 2008-12-10 02:27:52 UTC (rev 678)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/IsNodeWithChildren.java 2008-12-11 17:37:40 UTC (rev 679)
@@ -1,82 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.graph;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.hamcrest.Description;
-import org.hamcrest.Factory;
-import org.hamcrest.Matcher;
-import org.jboss.dna.graph.properties.Name;
-import org.jboss.dna.graph.properties.Path;
-import org.jboss.dna.graph.properties.basic.BasicPathSegment;
-import org.junit.matchers.IsCollectionContaining;
-import org.junit.matchers.TypeSafeMatcher;
-
-/**
- * @author Randall Hauch
- */
-public class IsNodeWithChildren extends TypeSafeMatcher<Node> {
- private final Matcher<Iterable<Path.Segment>> childMatcher;
-
- public IsNodeWithChildren( Matcher<Iterable<Path.Segment>> childMatcher ) {
- this.childMatcher = childMatcher;
- }
-
- @Override
- public boolean matchesSafely( Node node ) {
- List<Location> children = node.getChildren();
- List<Path.Segment> childSegments = new ArrayList<Path.Segment>(children.size());
- for (Location child : children) {
- childSegments.add(child.getPath().getLastSegment());
- }
- return childMatcher.matches(childSegments);
- }
-
- public void describeTo( Description description ) {
- description.appendText("a node containing children").appendDescriptionOf(childMatcher);
- }
-
- @Factory
- public static IsNodeWithChildren hasChild( Name name,
- int sameNameSiblingIndex ) {
- Path.Segment segment = new BasicPathSegment(name, sameNameSiblingIndex);
- return new IsNodeWithChildren(IsCollectionContaining.hasItem(segment));
- }
-
- @Factory
- public static IsNodeWithChildren hasChild( Path.Segment child ) {
- return new IsNodeWithChildren(IsCollectionContaining.hasItem(child));
- }
-
- @Factory
- public static IsNodeWithChildren hasChildren( Path.Segment... childSegments ) {
- return new IsNodeWithChildren(IsCollectionContaining.hasItems(childSegments));
- }
-
- @Factory
- public static IsNodeWithChildren hasNoChildren() {
- Path.Segment[] childSegments = new Path.Segment[] {};
- return new IsNodeWithChildren(IsCollectionContaining.hasItems(childSegments));
- }
-
-}
Modified: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/BasicRequestProcessor.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/BasicRequestProcessor.java 2008-12-10 02:27:52 UTC (rev 678)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/BasicRequestProcessor.java 2008-12-11 17:37:40 UTC (rev 679)
@@ -35,11 +35,12 @@
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
+import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
-import java.util.zip.ZipInputStream;
-import java.util.zip.ZipOutputStream;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import javax.persistence.NoResultException;
@@ -52,10 +53,12 @@
import org.jboss.dna.connector.store.jpa.JpaConnectorI18n;
import org.jboss.dna.connector.store.jpa.models.common.NamespaceEntity;
import org.jboss.dna.connector.store.jpa.util.Namespaces;
+import org.jboss.dna.connector.store.jpa.util.RequestProcessorCache;
import org.jboss.dna.connector.store.jpa.util.Serializer;
import org.jboss.dna.connector.store.jpa.util.Serializer.LargeValues;
import org.jboss.dna.graph.DnaLexicon;
import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.JcrLexicon;
import org.jboss.dna.graph.Location;
import org.jboss.dna.graph.properties.Binary;
import org.jboss.dna.graph.properties.Name;
@@ -97,6 +100,7 @@
protected final long largeValueMinimumSizeInBytes;
protected final boolean compressData;
protected final Logger logger;
+ protected final RequestProcessorCache cache;
/**
* @param sourceName
@@ -126,6 +130,7 @@
this.compressData = compressData;
this.serializer = new Serializer(context, true);
this.logger = getExecutionContext().getLogger(getClass());
+ this.cache = new RequestProcessorCache(this.pathFactory);
// Start the transaction ...
this.entities.getTransaction().begin();
@@ -166,40 +171,72 @@
NamespaceEntity ns = namespaces.get(childNsUri, true);
assert ns != null;
- // Find the largest SNS index in the existing ChildEntity objects with the same name ...
- String childLocalName = childName.getLocalName();
- Query query = entities.createNamedQuery("ChildEntity.findMaximumSnsIndex");
- query.setParameter("parentUuid", parentUuidString);
- query.setParameter("ns", ns.getId());
- query.setParameter("childName", childLocalName);
+ // Figure out the next SNS index and index-in-parent for this new child ...
int nextSnsIndex = 1;
- try {
- Integer result = (Integer)query.getSingleResult();
- nextSnsIndex = result != null ? result + 1 : 1;
- } catch (NoResultException e) {
- }
+ int nextIndexInParent = 1;
+ final Path parentPath = actual.location.getPath();
+ assert parentPath != null;
+ // Look in the cache for the children of the parent node.
+ LinkedList<Location> childrenOfParent = cache.getAllChildren(parentPath);
+ if (childrenOfParent != null) {
+ // The cache had the complete list of children for the parent node, which means
+ // we know about all of the children and can walk the children to figure out the next indexes.
+ nextIndexInParent = childrenOfParent.size() + 1;
+ if (nextIndexInParent > 1) {
+ // Since we want the last indexes, process the list backwards ...
+ ListIterator<Location> iter = childrenOfParent.listIterator(childrenOfParent.size());
+ while (iter.hasPrevious()) {
+ Location existing = iter.previous();
+ Path.Segment segment = existing.getPath().getLastSegment();
+ if (!segment.getName().equals(childName)) continue;
+ // Otherwise the name matched, so get the indexes ...
+ nextSnsIndex = segment.getIndex() + 1;
+ }
+ }
+ } else {
+ // The cache did not have the complete list of children for the parent node,
+ // so we need to look the values up by querying the database ...
- // Find the largest child index in the existing ChildEntity objects ...
- query = entities.createNamedQuery("ChildEntity.findMaximumChildIndex");
- query.setParameter("parentUuid", parentUuidString);
- int nextIndexInParent = 1;
- try {
- Integer result = (Integer)query.getSingleResult();
- nextIndexInParent = result != null ? result + 1 : 1;
- } catch (NoResultException e) {
+ // Find the largest SNS index in the existing ChildEntity objects with the same name ...
+ String childLocalName = childName.getLocalName();
+ Query query = entities.createNamedQuery("ChildEntity.findMaximumSnsIndex");
+ query.setParameter("parentUuid", parentUuidString);
+ query.setParameter("ns", ns.getId());
+ query.setParameter("childName", childLocalName);
+ try {
+ Integer result = (Integer)query.getSingleResult();
+ nextSnsIndex = result != null ? result + 1 : 1;
+ } catch (NoResultException e) {
+ }
+
+ // Find the largest child index in the existing ChildEntity objects ...
+ query = entities.createNamedQuery("ChildEntity.findMaximumChildIndex");
+ query.setParameter("parentUuid", parentUuidString);
+ try {
+ Integer result = (Integer)query.getSingleResult();
+ nextIndexInParent = result != null ? result + 1 : 1;
+ } catch (NoResultException e) {
+ }
}
// Create the new ChildEntity ...
ChildId id = new ChildId(parentUuidString, childUuidString);
- ChildEntity entity = new ChildEntity(id, nextIndexInParent, ns, childLocalName, nextSnsIndex);
+ ChildEntity entity = new ChildEntity(id, nextIndexInParent, ns, childName.getLocalName(), nextSnsIndex);
entities.persist(entity);
- // Look up the actual path, regardless of the supplied path...
+ // Set the actual path, regardless of the supplied path...
assert childUuidString != null;
- assert actual.location.getPath() != null;
- Path path = pathFactory.create(actual.location.getPath(), childName, nextSnsIndex);
+ Path path = pathFactory.create(parentPath, childName, nextSnsIndex);
actualLocation = new Location(path, UUID.fromString(childUuidString));
+ // Finally, update the cache with the information we know ...
+ if (childrenOfParent != null) {
+ // Add to the cached list of children ...
+ childrenOfParent.add(actualLocation);
+ }
+ // Since we've just created this node, we know about all the children (actually, there are none).
+ cache.setAllChildren(path, new LinkedList<Location>());
+
} catch (Throwable e) { // Includes PathNotFoundException
request.setError(e);
logger.trace(e, "Problem " + request);
@@ -213,7 +250,6 @@
*
* @see org.jboss.dna.graph.requests.processor.RequestProcessor#process(org.jboss.dna.graph.requests.ReadNodeRequest)
*/
- @SuppressWarnings( "unchecked" )
@Override
public void process( ReadNodeRequest request ) {
logger.trace(request.toString());
@@ -223,7 +259,6 @@
ActualLocation actual = getActualLocation(location);
String parentUuidString = actual.uuid;
actualLocation = actual.location;
- Path path = actualLocation.getPath();
// Record the UUID as a property, since it's not stored in the serialized properties...
request.addProperty(actualLocation.getIdProperty(DnaLexicon.UUID));
@@ -240,7 +275,7 @@
byte[] data = entity.getData();
LargeValueSerializer largeValues = new LargeValueSerializer(entity);
ByteArrayInputStream bais = new ByteArrayInputStream(data);
- InputStream is = compressed ? new ZipInputStream(bais) : bais;
+ InputStream is = compressed ? new GZIPInputStream(bais) : bais;
ObjectInputStream ois = new ObjectInputStream(is);
try {
serializer.deserializeAllProperties(ois, properties, largeValues);
@@ -254,18 +289,9 @@
} catch (NoResultException e) {
// No properties, but that's okay...
}
- // Find the children of the supplied node ...
- query = entities.createNamedQuery("ChildEntity.findAllUnderParent");
- query.setParameter("parentUuidString", parentUuidString);
- List<ChildEntity> children = query.getResultList();
- for (ChildEntity child : children) {
- String namespaceUri = child.getChildNamespace().getUri();
- String localName = child.getChildName();
- Name childName = nameFactory.create(namespaceUri, localName);
- int sns = child.getSameNameSiblingIndex();
- Path childPath = pathFactory.create(path, childName, sns);
- String childUuidString = child.getId().getChildUuidString();
- Location childLocation = new Location(childPath, UUID.fromString(childUuidString));
+
+ // Get the children for this node ...
+ for (Location childLocation : getAllChildren(actual)) {
request.addChild(childLocation);
}
} catch (NoResultException e) {
@@ -282,7 +308,6 @@
*
* @see org.jboss.dna.graph.requests.processor.RequestProcessor#process(org.jboss.dna.graph.requests.ReadAllChildrenRequest)
*/
- @SuppressWarnings( "unchecked" )
@Override
public void process( ReadAllChildrenRequest request ) {
logger.trace(request.toString());
@@ -290,22 +315,10 @@
try {
Location location = request.of();
ActualLocation actual = getActualLocation(location);
- String parentUuidString = actual.uuid;
actualLocation = actual.location;
- Path path = actualLocation.getPath();
- // Find the children of the supplied node ...
- Query query = entities.createNamedQuery("ChildEntity.findAllUnderParent");
- query.setParameter("parentUuidString", parentUuidString);
- List<ChildEntity> children = query.getResultList();
- for (ChildEntity child : children) {
- String namespaceUri = child.getChildNamespace().getUri();
- String localName = child.getChildName();
- Name childName = nameFactory.create(namespaceUri, localName);
- int sns = child.getSameNameSiblingIndex();
- Path childPath = pathFactory.create(path, childName, sns);
- String childUuidString = child.getId().getChildUuidString();
- Location childLocation = new Location(childPath, UUID.fromString(childUuidString));
+ // Get the children for this node ...
+ for (Location childLocation : getAllChildren(actual)) {
request.addChild(childLocation);
}
} catch (NoResultException e) {
@@ -318,6 +331,44 @@
}
/**
+ * Utility method to obtain all of the children for a node, either from the cache (if all children are known to this
+ * processor) or by querying the database (and caching the list of children).
+ *
+ * @param parent the actual location of the parent node; may not be null
+ * @return the list of child locations
+ */
+ protected LinkedList<Location> getAllChildren( ActualLocation parent ) {
+ assert parent != null;
+ Path parentPath = parent.location.getPath();
+ assert parentPath != null;
+ LinkedList<Location> cachedChildren = cache.getAllChildren(parentPath);
+ if (cachedChildren != null) {
+ // The cache has all of the children for the node ...
+ return cachedChildren;
+ }
+
+ // Not found in the cache, so query the database ...
+ Query query = entities.createNamedQuery("ChildEntity.findAllUnderParent");
+ query.setParameter("parentUuidString", parent.uuid);
+ LinkedList<Location> childLocations = new LinkedList<Location>();
+ @SuppressWarnings( "unchecked" )
+ List<ChildEntity> children = query.getResultList();
+ for (ChildEntity child : children) {
+ String namespaceUri = child.getChildNamespace().getUri();
+ String localName = child.getChildName();
+ Name childName = nameFactory.create(namespaceUri, localName);
+ int sns = child.getSameNameSiblingIndex();
+ Path childPath = pathFactory.create(parentPath, childName, sns);
+ String childUuidString = child.getId().getChildUuidString();
+ Location childLocation = new Location(childPath, UUID.fromString(childUuidString));
+ childLocations.add(childLocation);
+ }
+ // Update the cache ...
+ cache.setAllChildren(parentPath, childLocations);
+ return childLocations;
+ }
+
+ /**
* {@inheritDoc}
*
* @see org.jboss.dna.graph.requests.processor.RequestProcessor#process(org.jboss.dna.graph.requests.ReadAllPropertiesRequest)
@@ -347,7 +398,7 @@
byte[] data = entity.getData();
LargeValueSerializer largeValues = new LargeValueSerializer(entity);
ByteArrayInputStream bais = new ByteArrayInputStream(data);
- InputStream is = compressed ? new ZipInputStream(bais) : bais;
+ InputStream is = compressed ? new GZIPInputStream(bais) : bais;
ObjectInputStream ois = new ObjectInputStream(is);
try {
serializer.deserializeAllProperties(ois, properties, largeValues);
@@ -407,7 +458,7 @@
byte[] data = entity.getData();
LargeValueSerializer largeValues = new LargeValueSerializer(entity);
ByteArrayInputStream bais = new ByteArrayInputStream(data);
- InputStream is = compressed ? new ZipInputStream(bais) : bais;
+ InputStream is = compressed ? new GZIPInputStream(bais) : bais;
ObjectInputStream ois = new ObjectInputStream(is);
try {
Serializer.LargeValues skippedLargeValues = Serializer.NO_LARGE_VALUES;
@@ -453,10 +504,10 @@
// properties ...
boolean compressed = entity.isCompressed();
ByteArrayInputStream bais = new ByteArrayInputStream(entity.getData());
- InputStream is = compressed ? new ZipInputStream(bais) : bais;
+ InputStream is = compressed ? new GZIPInputStream(bais) : bais;
ObjectInputStream ois = new ObjectInputStream(is);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- OutputStream os = compressed ? new ZipOutputStream(baos) : baos;
+ OutputStream os = compressed ? new GZIPOutputStream(baos) : baos;
ObjectOutputStream oos = new ObjectOutputStream(os);
int numProperties = 0;
Set<String> largeValueHashesWritten = hadLargeValues ? new HashSet<String>() : null;
@@ -517,40 +568,49 @@
locationsByUuid.put(actual.uuid, location);
// Compute the subgraph, including the root ...
- SubgraphQuery query = SubgraphQuery.create(getExecutionContext(), entities, actualLocation.getUuid(), path, 0);
+ int maxDepth = request.maximumDepth();
+ SubgraphQuery query = SubgraphQuery.create(getExecutionContext(), entities, actualLocation.getUuid(), path, maxDepth);
// Record all of the children ...
Path parent = path;
+ String parentUuid = actual.uuid;
Location parentLocation = actualLocation;
List<Location> children = new LinkedList<Location>();
- for (ChildEntity child : query.getNodes(false)) {
+ boolean includeChildrenOfNodesAtMaxDepth = true;
+ for (ChildEntity child : query.getNodes(false, includeChildrenOfNodesAtMaxDepth)) {
String namespaceUri = child.getChildNamespace().getUri();
String localName = child.getChildName();
Name childName = nameFactory.create(namespaceUri, localName);
int sns = child.getSameNameSiblingIndex();
- Path childPath = pathFactory.create(path, childName, sns);
- String childUuidString = child.getId().getChildUuidString();
- Location childLocation = new Location(childPath, UUID.fromString(childUuidString));
- locationsByUuid.put(childUuidString, childLocation);
- // Determine if this child goes into the current list of children ...
- Path childParent = childPath.getParent();
- if (childParent.equals(parent)) {
- children.add(childLocation);
- } else {
- // Record the children found so far ...
+ // Figure out who the parent is ...
+ String childParentUuid = child.getId().getParentUuidString();
+ if (!parentUuid.equals(childParentUuid)) {
+ // The parent isn't the last parent, so record the children found so far ...
request.setChildren(parentLocation, children);
- parentLocation = locationsByUuid.get(child.getId().getParentUuidString());
+ // And find the correct parent ...
+ parentLocation = locationsByUuid.get(childParentUuid);
parent = parentLocation.getPath();
+ parentUuid = childParentUuid;
children = new LinkedList<Location>();
- children.add(childLocation);
}
+ Path childPath = pathFactory.create(parent, childName, sns);
+ String childUuidString = child.getId().getChildUuidString();
+ Location childLocation = new Location(childPath, UUID.fromString(childUuidString));
+ locationsByUuid.put(childUuidString, childLocation);
+ children.add(childLocation);
}
if (!children.isEmpty()) {
request.setChildren(parentLocation, children);
}
+ // Note that we've found children for nodes that are at the maximum depth. This is so that the nodes
+ // in the subgraph all have the correct children. However, we don't want to store the properties for
+ // any node whose depth is greater than the maximum depth. Therefore, only get the properties that
+ // include nodes within the maximum depth...
+ includeChildrenOfNodesAtMaxDepth = false;
+
// Now record all of the properties ...
- for (PropertiesEntity props : query.getProperties(true)) {
+ for (PropertiesEntity props : query.getProperties(true, includeChildrenOfNodesAtMaxDepth)) {
boolean compressed = props.isCompressed();
int propertyCount = props.getPropertyCount();
Collection<Property> properties = new ArrayList<Property>(propertyCount);
@@ -562,7 +622,7 @@
byte[] data = props.getData();
LargeValueSerializer largeValues = new LargeValueSerializer(props);
ByteArrayInputStream bais = new ByteArrayInputStream(data);
- InputStream is = compressed ? new ZipInputStream(bais) : bais;
+ InputStream is = compressed ? new GZIPInputStream(bais) : bais;
ObjectInputStream ois = new ObjectInputStream(is);
try {
serializer.deserializeAllProperties(ois, properties, largeValues);
@@ -572,8 +632,6 @@
}
}
- // TODO: Now update the 'index in parent' and SNS indexes of the siblings of the deleted node.
-
} catch (Throwable e) { // Includes PathNotFoundException
request.setError(e);
return;
@@ -610,11 +668,17 @@
SubgraphQuery query = SubgraphQuery.create(getExecutionContext(), entities, actualLocation.getUuid(), path, 0);
// Get the locations of all deleted nodes, which will be required by events ...
- // List<Location> deletedLocations = query.getNodeLocations(true);
+ List<Location> deletedLocations = query.getNodeLocations(true, true);
// Now delete the subgraph ...
query.deleteSubgraph(true);
+ // And adjust the SNS index and indexes ...
+ // adjustSnsIndexesAndIndexesAfterRemoving(oldParentUuid, childLocalName, ns.getId(), oldIndex, oldSnsIndex);
+
+ // Remove from the cache of children locations all entries for deleted nodes ...
+ cache.removeBranch(deletedLocations);
+
} catch (Throwable e) { // Includes PathNotFoundException
request.setError(e);
return;
@@ -637,9 +701,10 @@
ActualLocation actualLocation = getActualLocation(fromLocation);
String fromUuidString = actualLocation.uuid;
actualOldLocation = actualLocation.location;
+ Path oldPath = actualOldLocation.getPath();
// It's not possible to move the root node
- if (actualOldLocation.getPath().isRoot()) {
+ if (oldPath.isRoot()) {
String msg = JpaConnectorI18n.unableToMoveRootNode.text(getSourceName());
throw new InvalidRequestException(msg);
}
@@ -689,9 +754,19 @@
fromEntity.setIndexInParent(nextIndexInParent);
fromEntity.setSameNameSiblingIndex(nextSnsIndex);
+ // Determine the new location ...
+ Path newParentPath = actualIntoLocation.location.getPath();
+ Name childName = oldPath.getLastSegment().getName();
+ Path newPath = pathFactory.create(newParentPath, childName, nextSnsIndex);
+ actualNewLocation = actualOldLocation.with(newPath);
+
// And adjust the SNS index and indexes ...
adjustSnsIndexesAndIndexesAfterRemoving(oldParentUuid, childLocalName, ns.getId(), oldIndex, oldSnsIndex);
+
+ // Update the cache ...
+ cache.moveNode(actualOldLocation, oldIndex, actualNewLocation);
}
+
}
} catch (Throwable e) { // Includes PathNotFoundException
@@ -703,15 +778,18 @@
protected void adjustSnsIndexesAndIndexesAfterRemoving( String uuidParent,
String childName,
- int childNamespaceIndex,
+ long childNamespaceIndex,
int childIndex,
int childSnsIndex ) {
+ // TODO: Now update the 'index in parent' and SNS indexes of the siblings of the deleted node.
}
protected String createProperties( String uuidString,
Collection<Property> properties ) throws IOException {
assert uuidString != null;
+ if (properties.isEmpty()) return uuidString;
+ if (properties.size() == 1 && properties.iterator().next().getName().equals(JcrLexicon.NAME)) return uuidString;
// Create the PropertiesEntity ...
NodeId nodeId = new NodeId(uuidString);
@@ -719,7 +797,7 @@
LargeValueSerializer largeValues = new LargeValueSerializer(props);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- OutputStream os = compressData ? new ZipOutputStream(baos) : baos;
+ OutputStream os = compressData ? new GZIPOutputStream(baos) : baos;
ObjectOutputStream oos = new ObjectOutputStream(os);
int numProperties = properties.size();
try {
@@ -781,6 +859,15 @@
Property uuidProperty = original.getIdProperty(DnaLexicon.UUID);
String uuidString = uuidProperty != null && !uuidProperty.isEmpty() ? stringFactory.create(uuidProperty.getFirstValue()) : null;
+ Path path = original.getPath();
+ if (path != null) {
+ // See if the location is already in the cache ...
+ Location cached = cache.getLocationFor(path);
+ if (cached != null) {
+ return new ActualLocation(cached, cached.getUuid().toString(), null);
+ }
+ }
+
// If the original location has a UUID, then use that to find the child entity that represents the location ...
if (uuidString != null) {
// The original has a UUID, so use that to find the child entity.
@@ -805,11 +892,12 @@
}
}
Path fullPath = pathFactory.createAbsolutePath(segments);
- return new ActualLocation(new Location(fullPath, uuidProperty), nodeUuidString, entity);
+ Location newLocation = new Location(fullPath, uuidProperty);
+ cache.addNewNode(newLocation);
+ return new ActualLocation(newLocation, nodeUuidString, entity);
}
// There is no UUID, so look for a path ...
- Path path = original.getPath();
if (path == null) {
String propName = DnaLexicon.UUID.getString(getExecutionContext().getNamespaceRegistry());
String msg = JpaConnectorI18n.locationShouldHavePathAndOrProperty.text(getSourceName(), propName);
@@ -818,36 +906,11 @@
// Walk the child entities, starting at the root, down the to the path ...
if (path.isRoot()) {
- return new ActualLocation(original.with(rootNodeUuid), rootNodeUuidString, null);
+ Location newLocation = original.with(rootNodeUuid);
+ cache.addNewNode(newLocation);
+ return new ActualLocation(newLocation, rootNodeUuidString, null);
}
String parentUuid = this.rootNodeUuidString;
- // String childUuid = null;
- // for (Path.Segment segment : path) {
- // Name name = segment.getName();
- // String localName = name.getLocalName();
- // String nsUri = name.getNamespaceUri();
- // int snsIndex = segment.hasIndex() ? segment.getIndex() : 1;
- //
- // Query query = entities.createNamedQuery("ChildEntity.findChildUuidByPathSegment");
- // query.setParameter("parentUuidString", parentUuid);
- // query.setParameter("nsUri", nsUri);
- // query.setParameter("childName", localName);
- // query.setParameter("sns", snsIndex);
- // try {
- // childUuid = (String)query.getSingleResult();
- // } catch (NoResultException e) {
- // // Unable to complete the path, so prepare the exception by determining the lowest path that exists ...
- // Path lowest = path;
- // while (lowest.getLastSegment() != segment) {
- // lowest = lowest.getParent();
- // }
- // lowest = lowest.getParent();
- // throw new PathNotFoundException(original, lowest);
- // }
- // parentUuid = childUuid;
- // }
- // return new ActualLocation(original.with(UUID.fromString(childUuid)), childUuid, null);
-
ChildEntity child = null;
for (Path.Segment segment : path) {
child = findByPathSegment(parentUuid, segment);
@@ -864,7 +927,9 @@
}
assert child != null;
uuidString = child.getId().getChildUuidString();
- return new ActualLocation(original.with(UUID.fromString(uuidString)), uuidString, child);
+ Location newLocation = original.with(UUID.fromString(uuidString));
+ cache.addNewNode(newLocation);
+ return new ActualLocation(newLocation, uuidString, child);
}
/**
@@ -960,6 +1025,14 @@
if (entity != null) {
// Find the large value from the existing property entity ...
byte[] data = entity.getData();
+ if (entity.isCompressed()) {
+ InputStream stream = new GZIPInputStream(new ByteArrayInputStream(data));
+ try {
+ data = IoUtil.readBytes(stream);
+ } finally {
+ stream.close();
+ }
+ }
return valueFactories.getValueFactory(entity.getType()).create(data);
}
throw new IOException(JpaConnectorI18n.unableToReadLargeValue.text(getSourceName(), hashStr));
@@ -1004,7 +1077,7 @@
try {
binary.acquire();
stream = binary.getStream();
- if (compressData) stream = new ZipInputStream(stream);
+ if (compressData) stream = new GZIPInputStream(stream);
bytes = IoUtil.readBytes(stream);
} finally {
try {
@@ -1016,14 +1089,17 @@
break;
default:
String str = factories.getStringFactory().create(value);
- bytes = str.getBytes();
if (compressData) {
- InputStream strStream = new ZipInputStream(new ByteArrayInputStream(bytes));
+ ByteArrayOutputStream bs = new ByteArrayOutputStream();
+ OutputStream strStream = new GZIPOutputStream(bs);
try {
- bytes = IoUtil.readBytes(strStream);
+ IoUtil.write(str, strStream);
} finally {
strStream.close();
}
+ bytes = bs.toByteArray();
+ } else {
+ bytes = str.getBytes();
}
break;
}
Modified: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/SubgraphNodeEntity.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/SubgraphNodeEntity.java 2008-12-10 02:27:52 UTC (rev 678)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/SubgraphNodeEntity.java 2008-12-11 17:37:40 UTC (rev 679)
@@ -43,9 +43,9 @@
@NamedQueries( {
@NamedQuery( name = "SubgraphNodeEntity.insertChildren", query = "insert into SubgraphNodeEntity(queryId,nodeUuid,depth,parentIndexInParent,indexInParent) select parentNode.queryId, child.id.childUuidString, parentNode.depth+1, parentNode.indexInParent, child.indexInParent from ChildEntity child, SubgraphNodeEntity parentNode where child.deleted is null and child.id.parentUuidString = parentNode.nodeUuid and parentNode.queryId = :queryId and parentNode.depth = :parentDepth" ),
@NamedQuery( name = "SubgraphNodeEntity.getCount", query = "select count(*) from SubgraphNodeEntity where queryId = :queryId" ),
- @NamedQuery( name = "SubgraphNodeEntity.getPropertiesEntities", query = "select props from PropertiesEntity props, SubgraphNodeEntity node where props.id.uuidString = node.nodeUuid and node.queryId = :queryId and node.depth >= :depth order by node.depth, node.parentIndexInParent, node.indexInParent" ),
+ @NamedQuery( name = "SubgraphNodeEntity.getPropertiesEntities", query = "select props from PropertiesEntity props, SubgraphNodeEntity node where props.id.uuidString = node.nodeUuid and node.queryId = :queryId and node.depth >= :depth and node.depth <= :maxDepth order by node.depth, node.parentIndexInParent, node.indexInParent" ),
@NamedQuery( name = "SubgraphNodeEntity.getPropertiesEntitiesWithLargeValues", query = "select props from PropertiesEntity props, SubgraphNodeEntity node where props.id.uuidString = node.nodeUuid and node.queryId = :queryId and node.depth >= :depth and size(props.largeValues) > 0" ),
- @NamedQuery( name = "SubgraphNodeEntity.getChildEntities", query = "select child from ChildEntity child, SubgraphNodeEntity node where child.id.childUuidString = node.nodeUuid and node.queryId = :queryId and node.depth >= :depth order by node.depth, node.parentIndexInParent, node.indexInParent" ),
+ @NamedQuery( name = "SubgraphNodeEntity.getChildEntities", query = "select child from ChildEntity child, SubgraphNodeEntity node where child.id.childUuidString = node.nodeUuid and node.queryId = :queryId and node.depth >= :depth and node.depth <= :maxDepth order by node.depth, node.parentIndexInParent, node.indexInParent" ),
@NamedQuery( name = "SubgraphNodeEntity.deletePropertiesEntities", query = "delete PropertiesEntity props where props.id.uuidString in ( select node.nodeUuid from SubgraphNodeEntity node where node.queryId = :queryId and node.depth >= :depth )" ),
@NamedQuery( name = "SubgraphNodeEntity.deleteChildEntities", query = "delete ChildEntity child where child.id.childUuidString in ( select node.nodeUuid from SubgraphNodeEntity node where node.queryId = :queryId and node.depth >= :depth )" ),
@NamedQuery( name = "SubgraphNodeEntity.deleteByQueryId", query = "delete SubgraphNodeEntity where queryId = :queryId" )} )
@@ -54,7 +54,7 @@
@Id
@Column( name = "ID" )
@GeneratedValue( strategy = GenerationType.AUTO )
- private Integer id;
+ private Long id;
@Column( name = "QUERY_ID", nullable = false, unique = false, updatable = false )
private Long queryId;
@@ -85,7 +85,7 @@
/**
* @return id
*/
- public Integer getId() {
+ public Long getId() {
return id;
}
@@ -131,7 +131,7 @@
*/
@Override
public int hashCode() {
- return id;
+ return id != null ? id.intValue() : 0;
}
/**
Modified: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/SubgraphQuery.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/SubgraphQuery.java 2008-12-10 02:27:52 UTC (rev 678)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/basic/SubgraphQuery.java 2008-12-11 17:37:40 UTC (rev 679)
@@ -80,11 +80,14 @@
SubgraphNodeEntity root = new SubgraphNodeEntity(queryId, subgraphRootUuidString, 0);
entities.persist(root);
- // Now add the children by inserting the children, one level at a time ...
+ // Now add the children by inserting the children, one level at a time.
+ // Note that we do this for the root, and for each level until 1 BEYOND
+ // the max depth (so that we can get the children for the nodes that are
+ // at the maximum depth)...
Query statement = entities.createNamedQuery("SubgraphNodeEntity.insertChildren");
int numChildrenInserted = 0;
int parentLevel = 0;
- while (parentLevel < maxDepth - 1) {
+ while (parentLevel <= maxDepth) {
// Insert the children of the next level by inserting via a select (join) of the children
statement.setParameter("queryId", queryId);
statement.setParameter("parentDepth", parentLevel);
@@ -175,15 +178,19 @@
* Get the {@link ChildEntity nodes} in the subgraph. This must be called before the query is {@link #close() closed}.
*
* @param includeRoot true if the subgraph's root node is to be included, or false otherwise
+ * @param includeChildrenOfMaxDepthNodes true if the method is to include nodes that are children of nodes that are at the
+ * maximum depth, or false if only nodes up to the maximum depth are to be included
* @return the list of nodes, in breadth-first order
*/
@SuppressWarnings( "unchecked" )
- public List<ChildEntity> getNodes( boolean includeRoot ) {
+ public List<ChildEntity> getNodes( boolean includeRoot,
+ boolean includeChildrenOfMaxDepthNodes ) {
if (query == null) throw new IllegalStateException();
// Now query for all the nodes and put into a list ...
Query search = manager.createNamedQuery("SubgraphNodeEntity.getChildEntities");
search.setParameter("queryId", query.getId());
search.setParameter("depth", includeRoot ? 0 : 1);
+ search.setParameter("maxDepth", includeChildrenOfMaxDepthNodes ? maxDepth : maxDepth - 1);
// Now process the nodes below the subgraph's root ...
return search.getResultList();
@@ -194,15 +201,19 @@
* {@link #close() closed}.
*
* @param includeRoot true if the properties for the subgraph's root node are to be included, or false otherwise
+ * @param includeChildrenOfMaxDepthNodes true if the method is to include nodes that are children of nodes that are at the
+ * maximum depth, or false if only nodes up to the maximum depth are to be included
* @return the list of properties for each of the nodes, in breadth-first order
*/
@SuppressWarnings( "unchecked" )
- public List<PropertiesEntity> getProperties( boolean includeRoot ) {
+ public List<PropertiesEntity> getProperties( boolean includeRoot,
+ boolean includeChildrenOfMaxDepthNodes ) {
if (query == null) throw new IllegalStateException();
// Now query for all the nodes and put into a list ...
Query search = manager.createNamedQuery("SubgraphNodeEntity.getPropertiesEntities");
search.setParameter("queryId", query.getId());
search.setParameter("depth", includeRoot ? 0 : 1);
+ search.setParameter("maxDepth", includeChildrenOfMaxDepthNodes ? maxDepth : maxDepth - 1);
// Now process the nodes below the subgraph's root ...
return search.getResultList();
@@ -212,14 +223,17 @@
* Get the {@link Location} for each of the nodes in the subgraph. This must be called before the query is {@link #close()
* closed}.
* <p>
- * This method calls {@link #getNodes(boolean)}. Therefore, calling {@link #getNodes(boolean)} and this method for the same
- * subgraph is not efficient; consider just calling {@link #getNodes(boolean)} alone.
+ * This method calls {@link #getNodes(boolean,boolean)}. Therefore, calling {@link #getNodes(boolean,boolean)} and this method
+ * for the same subgraph is not efficient; consider just calling {@link #getNodes(boolean,boolean)} alone.
* </p>
*
* @param includeRoot true if the properties for the subgraph's root node are to be included, or false otherwise
+ * @param includeChildrenOfMaxDepthNodes true if the method is to include nodes that are children of nodes that are at the
+ * maximum depth, or false if only nodes up to the maximum depth are to be included
* @return the list of {@link Location locations}, one for each of the nodes in the subgraph, in breadth-first order
*/
- public List<Location> getNodeLocations( boolean includeRoot ) {
+ public List<Location> getNodeLocations( boolean includeRoot,
+ boolean includeChildrenOfMaxDepthNodes ) {
if (query == null) throw new IllegalStateException();
// Set up a map of the paths to the nodes, keyed by UUIDs. This saves us from having to build
// the paths every time ...
@@ -235,7 +249,7 @@
// Now iterate over the child nodes in the subgraph (we've already included the root) ...
final PathFactory pathFactory = context.getValueFactories().getPathFactory();
final NameFactory nameFactory = context.getValueFactories().getNameFactory();
- for (ChildEntity entity : getNodes(false)) {
+ for (ChildEntity entity : getNodes(false, includeChildrenOfMaxDepthNodes)) {
String parentUuid = entity.getId().getParentUuidString();
Path parentPath = pathByUuid.get(parentUuid);
assert parentPath != null;
Modified: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/common/NamespaceEntity.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/common/NamespaceEntity.java 2008-12-10 02:27:52 UTC (rev 678)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/models/common/NamespaceEntity.java 2008-12-11 17:37:40 UTC (rev 679)
@@ -50,7 +50,7 @@
@Id
@GeneratedValue( strategy = GenerationType.AUTO )
- private Integer id;
+ private Long id;
@Column( name = "URI", nullable = false, unique = false, length = 512, updatable = false )
private String uri;
@@ -71,14 +71,14 @@
/**
* @return id
*/
- public Integer getId() {
+ public Long getId() {
return id;
}
/**
* @param id Sets id to the specified value.
*/
- public void setId( Integer id ) {
+ public void setId( Long id ) {
this.id = id;
}
Added: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/util/RequestProcessorCache.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/util/RequestProcessorCache.java (rev 0)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/util/RequestProcessorCache.java 2008-12-11 17:37:40 UTC (rev 679)
@@ -0,0 +1,276 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.store.jpa.util;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Set;
+import org.jboss.dna.common.util.StringUtil;
+import org.jboss.dna.graph.Location;
+import org.jboss.dna.graph.properties.Name;
+import org.jboss.dna.graph.properties.NamespaceRegistry;
+import org.jboss.dna.graph.properties.Path;
+import org.jboss.dna.graph.properties.PathFactory;
+
+/**
+ * Represents a cache of the known node information, including a node's actual {@link Location} and the complete set of children.
+ *
+ * @author Randall Hauch
+ */
+public class RequestProcessorCache {
+
+ private final PathFactory pathFactory;
+ private final Map<Path, Location> locationByPath = new HashMap<Path, Location>();
+ private final Map<Path, LinkedList<Location>> childrenByParentPath = new HashMap<Path, LinkedList<Location>>();
+
+ public RequestProcessorCache( PathFactory pathFactory ) {
+ assert pathFactory != null;
+ this.pathFactory = pathFactory;
+ }
+
+ public Location getLocationFor( Path node ) {
+ return locationByPath.get(node);
+ }
+
+ public void addNewNode( Location location ) {
+ assert location != null;
+ Path path = location.getPath();
+ assert path != null;
+ locationByPath.put(path, location);
+ }
+
+ public LinkedList<Location> getAllChildren( Path parent ) {
+ return childrenByParentPath.get(parent);
+ }
+
+ public void setAllChildren( Path parent,
+ LinkedList<Location> children ) {
+ if (children == null) {
+ childrenByParentPath.remove(parent);
+ } else {
+ childrenByParentPath.put(parent, children);
+ }
+ }
+
+ public boolean moveNode( Location oldLocation,
+ int oldIndexInParent,
+ Location newLocation ) {
+ assert oldLocation != null;
+ assert newLocation != null;
+ Path oldPath = oldLocation.getPath();
+ assert oldPath != null;
+
+ // Now the locations of all nodes below the old location are invalid, as are all lists of children ...
+ // The easiest and most efficient thing to do would be to simply remove them from the cache ...
+ removeNodesBelow(oldPath, true);
+
+ // Remove the node from the list of children for the old parent ...
+ LinkedList<Location> siblings = childrenByParentPath.get(oldPath.getParent());
+ boolean removed = false;
+ if (siblings != null) {
+ removed = removeChildFromParentListOfChildren(siblings, oldLocation, -1);
+ }
+
+ // If the children are cached for the new parent ...
+ Path newPath = newLocation.getPath();
+ assert newPath != null;
+ LinkedList<Location> newSiblings = childrenByParentPath.get(newPath.getParent());
+ if (newSiblings != null) {
+ newSiblings.add(newLocation);
+ }
+
+ return removed;
+ }
+
+ protected void removeNodesBelow( Path path,
+ boolean removeNodeAtSuppliedPath ) {
+ if (removeNodeAtSuppliedPath) {
+ locationByPath.remove(path);
+ childrenByParentPath.remove(path);
+ }
+ for (Iterator<Path> iter = locationByPath.keySet().iterator(); iter.hasNext();) {
+ Path nextPath = iter.next();
+ if (nextPath.isDecendantOf(path)) iter.remove();
+ }
+ for (Iterator<Path> iter = childrenByParentPath.keySet().iterator(); iter.hasNext();) {
+ Path nextPath = iter.next();
+ if (nextPath.isDecendantOf(path)) iter.remove();
+ }
+ }
+
+ public boolean removeBranch( Iterable<Location> locations ) {
+ if (locations == null) return false;
+ Iterator<Location> iter = locations.iterator();
+ if (!iter.hasNext()) return false;
+
+ Location topNode = iter.next();
+
+ // Now remove all cached locations and child lists for each deleted node ...
+ boolean removed = false;
+ while (iter.hasNext()) {
+ Location location = iter.next();
+ Path path = location.getPath();
+ assert path != null;
+ if (locationByPath.remove(path) != null) removed = true;
+ if (childrenByParentPath.remove(path) != null) removed = true;
+ }
+
+ // The first node will be the root of the branch, so remove this from the parent's list of children
+ // and adjust all SNS indexes of same-name-siblings that appear after the removed node ...
+ Path path = topNode.getPath();
+ assert path != null;
+ LinkedList<Location> siblings = childrenByParentPath.get(path.getParent());
+ if (siblings != null) {
+ removed = removeChildFromParentListOfChildren(siblings, topNode, -1);
+ }
+ childrenByParentPath.remove(path);
+
+ return removed;
+ }
+
+ protected boolean removeChildFromParentListOfChildren( LinkedList<Location> siblings,
+ Location deletedNode,
+ int expectedIndex ) {
+ assert siblings != null;
+ Path path = deletedNode.getPath();
+ Path parentPath = path.getParent();
+
+ // Find and remove the deleted node ...
+ boolean removed = false;
+ int index = 0;
+ Path.Segment deletedNodeSegment = path.getLastSegment();
+ ListIterator<Location> iter = null;
+ if (expectedIndex > -1 && expectedIndex < siblings.size()) {
+ Location locationAtExpectedIndex = siblings.get(expectedIndex);
+ if (locationAtExpectedIndex.equals(deletedNode)) {
+ siblings.remove(expectedIndex);
+ removed = true;
+ index = expectedIndex;
+ }
+ }
+ if (!removed) {
+ iter = siblings.listIterator();
+ while (iter.hasNext()) {
+ Location sibling = iter.next();
+ Path.Segment segment = sibling.getPath().getLastSegment();
+ if (segment.equals(deletedNodeSegment)) {
+ iter.remove();
+ removed = true;
+ break;
+ }
+ ++index;
+ }
+ }
+
+ // Iterate starting at the supplied index, and adjust the locations for same-name-siblings ...
+ iter = siblings.listIterator(index);
+ Name name = deletedNodeSegment.getName();
+ while (iter.hasNext()) {
+ Location laterSibling = iter.next();
+ Path siblingPath = laterSibling.getPath();
+ Path.Segment segment = siblingPath.getLastSegment();
+ // If this sibling has the same name and appeared after deleted node, so decrement the SNS index ...
+ if (segment.getName().equals(name)) {
+ assert segment.getIndex() > 1;
+ Path newPath = pathFactory.create(parentPath, name, segment.getIndex() - 1);
+ Location newLocation = laterSibling.with(newPath);
+ iter.set(newLocation);
+
+ // Remove the existing location for the old path ...
+ locationByPath.remove(siblingPath);
+
+ // Remove all nodes below (not at) this sibling ...
+ removeNodesBelow(siblingPath, false);
+
+ // Now put in the location for the modified sibling ...
+ locationByPath.put(newPath, newLocation);
+ }
+ }
+ return removed;
+ }
+
+ public String getString( NamespaceRegistry namespaces ) {
+ StringBuilder sb = new StringBuilder();
+ Set<Path> pathSet = new HashSet<Path>();
+ pathSet.addAll(locationByPath.keySet());
+ pathSet.addAll(childrenByParentPath.keySet());
+ List<Path> paths = new ArrayList<Path>(pathSet);
+ Collections.sort(paths);
+
+ // For printing purposes, figure out the maximum length needed for the paths ...
+ int maxLength = 0;
+ for (Path path : paths) {
+ String str = pathString(path, namespaces);
+ maxLength = Math.max(maxLength, str.length());
+ }
+ for (Path path : paths) {
+ Location loc = locationByPath.get(path);
+ String str = pathString(path, namespaces);
+ sb.append(StringUtil.justifyLeft(str, maxLength, ' '));
+ if (loc != null) {
+ // sb.append("\t\tlocation");
+ sb.append(" @" + loc.getUuid());
+ }
+ LinkedList<Location> children = childrenByParentPath.get(path);
+ if (children != null) {
+ sb.append("\twith children: ");
+ for (int i = 0; i < children.size(); i++) {
+ Location child = children.get(i);
+ String segmentString = pathSegmentString(child.getPath().getLastSegment(), namespaces);
+ sb.append("\n");
+ sb.append(StringUtil.justifyRight(segmentString, maxLength, ' '));
+ sb.append(" @" + child.getUuid());
+ }
+ }
+ sb.append("\n");
+ }
+ return sb.toString();
+ }
+
+ protected String pathString( Path path,
+ NamespaceRegistry registry ) {
+ return path.getString(registry, null, null);
+ }
+
+ protected String pathSegmentString( Path.Segment segment,
+ NamespaceRegistry registry ) {
+ return registry != null ? segment.getString(registry) : segment.getString();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return getString(null);
+ }
+
+}
Modified: trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectionTest.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectionTest.java 2008-12-10 02:27:52 UTC (rev 678)
+++ trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectionTest.java 2008-12-11 17:37:40 UTC (rev 679)
@@ -25,7 +25,7 @@
import static org.hamcrest.core.IsNull.notNullValue;
import static org.jboss.dna.graph.IsNodeWithChildren.hasChild;
import static org.jboss.dna.graph.IsNodeWithChildren.hasChildren;
-import static org.jboss.dna.graph.IsNodeWithChildren.hasNoChildren;
+import static org.jboss.dna.graph.IsNodeWithChildren.isEmpty;
import static org.jboss.dna.graph.IsNodeWithProperty.hasProperty;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
@@ -58,7 +58,7 @@
*
* @author Randall Hauch
*/
-public class JpaConnectionTest {
+public abstract class JpaConnectionTest {
private ExecutionContext context;
private JpaConnection connection;
@@ -71,6 +71,7 @@
private boolean compressData;
private Graph graph;
private String[] validLargeValues;
+ private int numPropsOnEach;
@Before
public void beforeEach() throws Exception {
@@ -78,7 +79,8 @@
model = getModel();
rootNodeUuid = UUID.randomUUID();
largeValueSize = 2 ^ 10; // 1 kilobyte
- compressData = false;
+ compressData = true;
+ numPropsOnEach = 0;
// Load in the large value ...
validLargeValues = new String[] {IoUtil.read(getClass().getClassLoader().getResourceAsStream("LoremIpsum1.txt")),
@@ -88,11 +90,12 @@
// Connect to the database ...
Ejb3Configuration configurator = new Ejb3Configuration();
model.configure(configurator);
- configurator.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
- configurator.setProperty("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver");
- configurator.setProperty("hibernate.connection.username", "sa");
- configurator.setProperty("hibernate.connection.password", "");
- configurator.setProperty("hibernate.connection.url", "jdbc:hsqldb:.");
+ configureDatabaseProperties(configurator);
+ // configurator.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
+ // configurator.setProperty("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver");
+ // configurator.setProperty("hibernate.connection.username", "sa");
+ // configurator.setProperty("hibernate.connection.password", "");
+ // configurator.setProperty("hibernate.connection.url", "jdbc:hsqldb:.");
configurator.setProperty("hibernate.show_sql", "false");
configurator.setProperty("hibernate.format_sql", "true");
configurator.setProperty("hibernate.use_sql_comments", "true");
@@ -108,6 +111,8 @@
graph = Graph.create(connection, context);
}
+ protected abstract void configureDatabaseProperties( Ejb3Configuration configurator );
+
@After
public void afterEach() throws Exception {
try {
@@ -152,6 +157,12 @@
return context.getValueFactories().getNameFactory().create(name);
}
+ protected Property property( String name,
+ Object... values ) {
+ Name propName = name(name);
+ return context.getPropertyFactory().create(propName, values);
+ }
+
protected Path.Segment child( String name ) {
return context.getValueFactories().getPathFactory().createSegment(name);
}
@@ -192,57 +203,56 @@
Node root = graph.getNodeAt("/");
assertThat(root, is(notNullValue()));
assertThat(root, hasProperty(DnaLexicon.UUID, rootNodeUuid));
- assertThat(root, hasChild(child("a")));
+ assertThat(root.getChildren(), hasChild(child("a")));
// Now look up node A ...
Node nodeA = graph.getNodeAt("/a");
assertThat(nodeA, is(notNullValue()));
assertThat(nodeA, hasProperty("propB", "valueB"));
assertThat(nodeA, hasProperty("propC", "valueC"));
- assertThat(nodeA, hasNoChildren());
+ assertThat(nodeA.getChildren(), isEmpty());
}
@Test
public void shouldAddChildrenOnRootNode() {
- graph.batch().set("propA").to("valueA").on("/").and()
- .create("/a").with("propB", "valueB").and("propC", "valueC").and()
- .create("/b").with("propD", "valueD").and("propE", "valueE")
- .execute();
+ graph.batch().set("propA").to("valueA").on("/").and().create("/a").with("propB", "valueB").and("propC", "valueC").and().create("/b").with("propD",
+ "valueD").and("propE",
+ "valueE").execute();
// Now look up the root node ...
Node root = graph.getNodeAt("/");
assertThat(root, is(notNullValue()));
assertThat(root, hasProperty(DnaLexicon.UUID, rootNodeUuid));
assertThat(root, hasProperty("propA", "valueA"));
- assertThat(root, hasChildren(child("a"), child("b")));
+ assertThat(root.getChildren(), hasChildren(child("a"), child("b")));
// Now look up node A ...
Node nodeA = graph.getNodeAt("/a");
assertThat(nodeA, is(notNullValue()));
assertThat(nodeA, hasProperty("propB", "valueB"));
assertThat(nodeA, hasProperty("propC", "valueC"));
- assertThat(nodeA, hasNoChildren());
+ assertThat(nodeA.getChildren(), isEmpty());
// Now look up node B ...
Node nodeB = graph.getNodeAt("/b");
assertThat(nodeB, is(notNullValue()));
assertThat(nodeB, hasProperty("propD", "valueD"));
assertThat(nodeB, hasProperty("propE", "valueE"));
- assertThat(nodeB, hasNoChildren());
+ assertThat(nodeB.getChildren(), isEmpty());
// Get the subgraph ...
Subgraph subgraph = graph.getSubgraphOfDepth(3).at("/");
assertThat(subgraph, is(notNullValue()));
assertThat(subgraph.getNode("."), hasProperty(DnaLexicon.UUID, rootNodeUuid));
assertThat(subgraph.getNode("."), hasProperty("propA", "valueA"));
- assertThat(subgraph.getNode("."), hasChildren(child("a"), child("b")));
+ assertThat(subgraph.getNode(".").getChildren(), hasChildren(child("a"), child("b")));
assertThat(subgraph.getNode("a"), is(notNullValue()));
assertThat(subgraph.getNode("a"), hasProperty("propB", "valueB"));
assertThat(subgraph.getNode("a"), hasProperty("propC", "valueC"));
- assertThat(subgraph.getNode("a"), hasNoChildren());
+ assertThat(subgraph.getNode("a").getChildren(), isEmpty());
assertThat(subgraph.getNode("b"), is(notNullValue()));
assertThat(subgraph.getNode("b"), hasProperty("propD", "valueD"));
assertThat(subgraph.getNode("b"), hasProperty("propE", "valueE"));
- assertThat(subgraph.getNode("b"), hasNoChildren());
+ assertThat(subgraph.getNode("b").getChildren(), isEmpty());
}
@Test
@@ -258,7 +268,7 @@
for (int i = 0; i != 100; ++i) {
assertThat(nodeA, hasProperty("property" + i, "value" + i));
}
- assertThat(nodeA, hasNoChildren());
+ assertThat(nodeA.getChildren(), isEmpty());
}
@Test
@@ -276,7 +286,7 @@
for (int i = 0; i != 10; ++i) {
assertThat(nodeA, hasProperty("property" + i, "value" + i));
}
- assertThat(nodeA, hasNoChildren());
+ assertThat(nodeA.getChildren(), isEmpty());
// Now, remove some of the properties and add some others ...
Graph.Batch batch = graph.batch();
@@ -296,7 +306,7 @@
assertThat(nodeA, hasProperty("property" + i, "value" + i));
}
}
- assertThat(nodeA, hasNoChildren());
+ assertThat(nodeA.getChildren(), isEmpty());
}
@@ -319,7 +329,7 @@
}
assertThat(nodeA, hasProperty("largeProperty1", validLargeValues[0]));
assertThat(nodeA, hasProperty("largeProperty2", validLargeValues[1]));
- assertThat(nodeA, hasNoChildren());
+ assertThat(nodeA.getChildren(), isEmpty());
// Now, remove some of the properties and add some others ...
Graph.Batch batch = graph.batch();
@@ -342,7 +352,7 @@
}
assertThat(nodeA, hasProperty("largeProperty2", validLargeValues[1]));
assertThat(nodeA, hasProperty("largeProperty3", validLargeValues[2]));
- assertThat(nodeA, hasNoChildren());
+ assertThat(nodeA.getChildren(), isEmpty());
}
@@ -404,97 +414,349 @@
@Test
public void shouldCreateDeepBranch() {
- createTree("", 1, 50, "deep and narrow tree, 1x50", false);
+ createTree("", 1, 50, numPropsOnEach, "deep and narrow tree, 1x50", false, false);
}
+ @Test
+ public void shouldCreateDeepBranchUsingOneBatch() {
+ createTree("", 1, 50, numPropsOnEach, "deep and narrow tree, 1x50", true, false);
+ }
+
// @Test
// public void shouldCreateBinaryTree() {
- // createTree("", 2, 8, "binary tree, 2x8", false);
+ // createTree("", 2, 8, "binary tree, 2x8", false,false);
// }
@Test
public void shouldCreate10x2Tree() {
- createTree("", 10, 2, null, false);
+ createTree("", 10, 2, numPropsOnEach, null, false, false);
}
+ @Test
+ public void shouldCreate10x2TreeUsingOneBatch() {
+ createTree("", 10, 2, numPropsOnEach, null, true, false);
+ }
+
+ @Test
+ public void shouldCreate10x2TreeWith10PropertiesOnEachNodeUsingOneBatch() {
+ numPropsOnEach = 10;
+ createTree("", 10, 2, numPropsOnEach, null, true, false);
+ }
+
// @Test
// public void shouldCreate10x3DecimalTree() {
- // createTree("", 10, 3, null, false);
+ // createTree("", 10, 3, numPropsOnEach, null, false, true);
// }
-
+ //
// @Test
- // public void shouldCreateWideTree() {
- // createTree("", 1000, 1, "wide/flat tree, 1000x1", false);
+ // public void shouldCreate10x3DecimalTreeUsingOneBatch() {
+ // createTree("", 10, 3, numPropsOnEach, null, true, false);
// }
-
+ //
// @Test
- // public void shouldCreateVeryWideTree() {
- // createTree("", 3000, 1, "wide/flat tree, 3000x1", false);
+ // public void shouldCreate10x3DecimalTreeWith10PropertiesOnEachNodeCompressedUsingOneBatch() {
+ // // compressData = true; the default
+ // connection = new JpaConnection("source", cachePolicy, manager, model, rootNodeUuid, largeValueSize, compressData);
+ // graph = Graph.create(connection, context);
+ //
+ // numPropsOnEach = 10;
+ // createTree("", 10, 3, numPropsOnEach, null, true, false);
// }
-
+ //
// @Test
- // public void shouldCreate10KDecimalTree() {
- // createTree("", 10, 4, "10K decimal tree, 10x4", false);
+ // public void shouldCreate10x3DecimalTreeWith10PropertiesOnEachNodeUsingOneBatch() {
+ // compressData = false;
+ // connection = new JpaConnection("source", cachePolicy, manager, model, rootNodeUuid, largeValueSize, compressData);
+ // graph = Graph.create(connection, context);
+ //
+ // numPropsOnEach = 10;
+ // createTree("", 10, 3, numPropsOnEach, null, true, false);
// }
- // @Test
- // public void shouldCreate8x4Tree() {
- // createTree("", 8, 4, null, false);
- // }
+ @Test
+ public void shouldReadNodes() {
+ // Create the tree (at total of 40 nodes, plus the extra 6 added later)...
+ // /
+ // /node1
+ // /node1/node1
+ // /node1/node1/node1
+ // /node1/node1/node2
+ // /node1/node1/node3
+ // /node1/node2
+ // /node1/node2/node1
+ // /node1/node2/node2
+ // /node1/node2/node3
+ // /node1/node3
+ // /node1/node3/node1
+ // /node1/node3/node2
+ // /node1/node3/node3
+ // /node2
+ // /node2/node1
+ // /node2/node1/node1
+ // /node2/node1/node2
+ // /node2/node1/node3
+ // /node2/node2
+ // /node2/node2/node1
+ // /node2/node2/node2
+ // /node2/node2/node3
+ // /node2/node3
+ // /node2/node3/node1
+ // /node2/node3/node2
+ // /node2/node3/node3
+ // /node3
+ // /node3/node1
+ // /node3/node1/node1
+ // /node3/node1/node2
+ // /node3/node1/node3
+ // /node3/node2
+ // /node3/node2/node1
+ // /node3/node2/node2
+ // /node3/node2/node3
+ // /node3/node3
+ // /node3/node3/node1
+ // /node3/node3/node2
+ // /node3/node3/node3
+ // /secondBranch1
+ // /secondBranch1/secondBranch1
+ // /secondBranch1/secondBranch2
+ // /secondBranch2
+ // /secondBranch2/secondBranch1
+ // /secondBranch2/secondBranch2
+ numPropsOnEach = 3;
+ createTree("", 3, 3, numPropsOnEach, null, true, false);
+ assertThat(graph.getChildren().of("/node1"), hasChildren(child("node1"), child("node2"), child("node3")));
+ assertThat(graph.getChildren().of("/node1/node1"), hasChildren(child("node1"), child("node2"), child("node3")));
+ assertThat(graph.getChildren().of("/node1/node2"), hasChildren(child("node1"), child("node2"), child("node3")));
+ assertThat(graph.getChildren().of("/node1/node3"), hasChildren(child("node1"), child("node2"), child("node3")));
+ assertThat(graph.getChildren().of("/node1/node3/node1"), isEmpty());
+
+ assertThat(graph.getChildren().of("/node2"), hasChildren(child("node1"), child("node2"), child("node3")));
+ assertThat(graph.getChildren().of("/node2/node1"), hasChildren(child("node1"), child("node2"), child("node3")));
+ assertThat(graph.getChildren().of("/node2/node2"), hasChildren(child("node1"), child("node2"), child("node3")));
+ assertThat(graph.getChildren().of("/node2/node3"), hasChildren(child("node1"), child("node2"), child("node3")));
+ assertThat(graph.getChildren().of("/node2/node3/node1"), isEmpty());
+
+ assertThat(graph.getChildren().of("/node3"), hasChildren(child("node1"), child("node2"), child("node3")));
+ assertThat(graph.getChildren().of("/node3/node1"), hasChildren(child("node1"), child("node2"), child("node3")));
+ assertThat(graph.getChildren().of("/node3/node2"), hasChildren(child("node1"), child("node2"), child("node3")));
+ assertThat(graph.getChildren().of("/node3/node3"), hasChildren(child("node1"), child("node2"), child("node3")));
+ assertThat(graph.getChildren().of("/node3/node3/node1"), isEmpty());
+
+ Subgraph subgraph = graph.getSubgraphOfDepth(2).at("/node3/node2");
+ assertThat(subgraph, is(notNullValue()));
+ assertThat(subgraph.getNode(".").getChildren(), hasChildren(child("node1"), child("node2"), child("node3")));
+ assertThat(subgraph.getNode("."), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("."), hasProperty("property2", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("."), hasProperty("property3", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node1").getChildren(), isEmpty());
+ assertThat(subgraph.getNode("node1"), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node1"), hasProperty("property2", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node1"), hasProperty("property3", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node2").getChildren(), isEmpty());
+ assertThat(subgraph.getNode("node2"), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node2"), hasProperty("property2", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node2"), hasProperty("property3", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node3").getChildren(), isEmpty());
+ assertThat(subgraph.getNode("node3"), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node3"), hasProperty("property2", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node3"), hasProperty("property3", "The quick brown fox jumped over the moon. What? "));
+
+ subgraph = graph.getSubgraphOfDepth(2).at("/node3");
+ assertThat(subgraph, is(notNullValue()));
+ assertThat(subgraph.getNode(".").getChildren(), hasChildren(child("node1"), child("node2"), child("node3")));
+ assertThat(subgraph.getNode("."), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("."), hasProperty("property2", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("."), hasProperty("property3", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node1").getChildren(), isEmpty());
+ assertThat(subgraph.getNode("node1"), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node1"), hasProperty("property2", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node1"), hasProperty("property3", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node2").getChildren(), isEmpty());
+ assertThat(subgraph.getNode("node2"), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node2"), hasProperty("property2", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node2"), hasProperty("property3", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node3").getChildren(), isEmpty());
+ assertThat(subgraph.getNode("node3"), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node3"), hasProperty("property2", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node3"), hasProperty("property3", "The quick brown fox jumped over the moon. What? "));
+ }
+
+ @Test
+ public void shouldDeleteNodes() {
+ // Create the tree (at total of 40 nodes, plus the extra 6 added later)...
+ // /
+ // /node1
+ // /node1/node1
+ // /node1/node1/node1
+ // /node1/node1/node2
+ // /node1/node1/node3
+ // /node1/node2
+ // /node1/node2/node1
+ // /node1/node2/node2
+ // /node1/node2/node3
+ // /node1/node3
+ // /node1/node3/node1
+ // /node1/node3/node2
+ // /node1/node3/node3
+ // /node2
+ // /node2/node1
+ // /node2/node1/node1
+ // /node2/node1/node2
+ // /node2/node1/node3
+ // /node2/node2
+ // /node2/node2/node1
+ // /node2/node2/node2
+ // /node2/node2/node3
+ // /node2/node3
+ // /node2/node3/node1
+ // /node2/node3/node2
+ // /node2/node3/node3
+ // /node3
+ // /node3/node1
+ // /node3/node1/node1
+ // /node3/node1/node2
+ // /node3/node1/node3
+ // /node3/node2
+ // /node3/node2/node1
+ // /node3/node2/node2
+ // /node3/node2/node3
+ // /node3/node3
+ // /node3/node3/node1
+ // /node3/node3/node2
+ // /node3/node3/node3
+ // /secondBranch1
+ // /secondBranch1/secondBranch1
+ // /secondBranch1/secondBranch2
+ // /secondBranch2
+ // /secondBranch2/secondBranch1
+ // /secondBranch2/secondBranch2
+
+ numPropsOnEach = 3;
+ createTree("", 3, 3, numPropsOnEach, null, true, false);
+
+ // Delete two branches ...
+ graph.delete("/node2/node2").and().delete("/node3/node1");
+
+ assertThat(graph.getChildren().of("/node1"), hasChildren(child("node1"), child("node2"), child("node3")));
+ assertThat(graph.getChildren().of("/node1/node1"), hasChildren(child("node1"), child("node2"), child("node3")));
+ assertThat(graph.getChildren().of("/node1/node2"), hasChildren(child("node1"), child("node2"), child("node3")));
+ assertThat(graph.getChildren().of("/node1/node3"), hasChildren(child("node1"), child("node2"), child("node3")));
+ assertThat(graph.getChildren().of("/node1/node3/node1"), hasChildren());
+
+ assertThat(graph.getChildren().of("/node2"), hasChildren(child("node1"), child("node3")));
+ assertThat(graph.getChildren().of("/node2/node1"), hasChildren(child("node1"), child("node2"), child("node3")));
+ assertThat(graph.getChildren().of("/node2/node3"), hasChildren(child("node1"), child("node2"), child("node3")));
+ assertThat(graph.getChildren().of("/node2/node3/node1"), hasChildren());
+
+ assertThat(graph.getChildren().of("/node3"), hasChildren(child("node2"), child("node3")));
+ assertThat(graph.getChildren().of("/node3/node2"), hasChildren(child("node1"), child("node2"), child("node3")));
+ assertThat(graph.getChildren().of("/node3/node3"), hasChildren(child("node1"), child("node2"), child("node3")));
+ assertThat(graph.getChildren().of("/node3/node3/node1"), hasChildren());
+
+ Subgraph subgraph = graph.getSubgraphOfDepth(3).at("/");
+ assertThat(subgraph, is(notNullValue()));
+ assertThat(subgraph.getNode(".").getChildren(), hasChildren(child("node1"), child("node3")));
+ assertThat(subgraph.getNode("node1").getChildren(), hasChildren(child("node1"), child("node2"), child("node3")));
+ assertThat(subgraph.getNode("node1"), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node1"), hasProperty("property2", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node1"), hasProperty("property3", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node2").getChildren(), hasChildren(child("node1"), child("node3")));
+ assertThat(subgraph.getNode("node2"), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node2"), hasProperty("property2", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node2"), hasProperty("property3", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node3").getChildren(), hasChildren(child("node2"), child("node3")));
+ assertThat(subgraph.getNode("node3"), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node3"), hasProperty("property2", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node3"), hasProperty("property3", "The quick brown fox jumped over the moon. What? "));
+
+ subgraph = graph.getSubgraphOfDepth(2).at("/node3");
+ assertThat(subgraph, is(notNullValue()));
+ assertThat(subgraph.getNode(".").getChildren(), hasChildren(child("node2"), child("node3")));
+ assertThat(subgraph.getNode("."), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("."), hasProperty("property2", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("."), hasProperty("property3", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node2").getChildren(), isEmpty());
+ assertThat(subgraph.getNode("node2"), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node2"), hasProperty("property2", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node2"), hasProperty("property3", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node3").getChildren(), isEmpty());
+ assertThat(subgraph.getNode("node3"), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node3"), hasProperty("property2", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node3"), hasProperty("property3", "The quick brown fox jumped over the moon. What? "));
+ }
+
protected int createTree( String initialPath,
int numberPerDepth,
int depth,
+ int numProps,
String description,
- boolean oneBatch ) {
- int totalNumber = numberNodesInTree(numberPerDepth, depth) - 1; // this method doesn't create the root
- if (description == null) description = "" + numberPerDepth + "x" + depth + " tree";
- boolean printIntermediate = totalNumber > 500;
+ boolean oneBatch,
+ boolean printIntermediate ) {
+ long totalNumber = numberNodesInTree(numberPerDepth, depth) - 1; // this method doesn't create the root
+ if (description == null) description = "" + numberPerDepth + "x" + depth + " tree with " + numProps
+ + " properties per node" + (compressData ? " (compressed)" : "");
System.out.println(description + " (" + totalNumber + " nodes):");
- int totalNumberCreated = 0;
+ long totalNumberCreated = 0;
+ String batchStr = "batch ";
Graph.Batch batch = oneBatch ? graph.batch() : null;
Stopwatch sw = new Stopwatch();
if (batch != null) {
- totalNumberCreated += createChildren(batch, initialPath, "node", numberPerDepth, depth, printIntermediate);
+ totalNumberCreated += createChildren(batch, initialPath, "node", numberPerDepth, numProps, depth, printIntermediate);
sw.start();
batch.execute();
} else {
+ batchStr = "";
sw.start();
- totalNumberCreated += createChildren(null, initialPath, "node", numberPerDepth, depth, printIntermediate);
+ totalNumberCreated += createChildren(null, initialPath, "node", numberPerDepth, numProps, depth, printIntermediate);
}
sw.stop();
- long totalDurationInMillis = TimeUnit.NANOSECONDS.toMillis(sw.getTotalDuration().longValue());
- long avgDurationInMillis = totalDurationInMillis / totalNumber;
- System.out.println(" Total = " + sw.getTotalDuration() + "; avg = " + avgDurationInMillis + " ms");
+ long totalDurationInMicroseconds = TimeUnit.NANOSECONDS.toMicros(sw.getTotalDuration().longValue());
+ long avgDuration = totalDurationInMicroseconds / totalNumber / 1000L;
+ String units = " millisecond(s)";
+ if (avgDuration == 0L) {
+ avgDuration = totalDurationInMicroseconds / totalNumber;
+ units = " microsecond(s)";
+ }
+ System.out.println(" Total = " + sw.getTotalDuration() + "; avg = " + avgDuration + units);
// Perform second batch ...
batch = graph.batch();
- totalNumberCreated += createChildren(batch, initialPath, "secondBranch", 2, 2, printIntermediate);
+ totalNumberCreated += createChildren(batch, initialPath, "secondBranch", 2, numProps, 2, printIntermediate);
sw = new Stopwatch();
sw.start();
batch.execute();
sw.stop();
- System.out.println(" Final batch total = " + sw.getTotalDuration() + "; avg = " + avgDurationInMillis + " ms");
+ totalDurationInMicroseconds = TimeUnit.NANOSECONDS.toMicros(sw.getTotalDuration().longValue());
+ avgDuration = totalDurationInMicroseconds / totalNumber / 1000L;
+ units = " millisecond(s)";
+ if (avgDuration == 0L) {
+ avgDuration = totalDurationInMicroseconds / totalNumber;
+ units = " microsecond(s)";
+ }
+ System.out.println(" Final " + batchStr + "total = " + sw.getTotalDuration() + "; avg = " + avgDuration + units);
assertThat(totalNumberCreated, is(totalNumber + numberNodesInTree(2, 2) - 1));
- return totalNumberCreated;
+ return (int)totalNumberCreated;
}
protected int createChildren( Graph.Batch useBatch,
String parentPath,
String nodePrefix,
int number,
+ int numProps,
int depthRemaining,
boolean printIntermediateStatus ) {
int numberCreated = 0;
Graph.Batch batch = useBatch;
if (batch == null) batch = graph.batch();
for (int i = 0; i != number; ++i) {
- String path = parentPath + "/" + nodePrefix + i;
+ String path = parentPath + "/" + nodePrefix + (i + 1);
Graph.Create<Graph.Batch> create = batch.create(path);
- String value = "the quick brown fox jumped over the moon. What? ";
- for (int j = 0; j != 10; ++j) {
- // value = value + value;
- create = create.with("property" + j, value);
+ String originalValue = "The quick brown fox jumped over the moon. What? ";
+ String value = originalValue;
+ for (int j = 0; j != numProps; ++j) {
+ // value = value + originalValue;
+ create = create.with("property" + (j + 1), value);
}
create.and();
}
@@ -507,8 +769,8 @@
}
if (depthRemaining > 1) {
for (int i = 0; i != number; ++i) {
- String path = parentPath + "/" + nodePrefix + i;
- numberCreated += createChildren(useBatch, path, nodePrefix, number, depthRemaining - 1, false);
+ String path = parentPath + "/" + nodePrefix + (i + 1);
+ numberCreated += createChildren(useBatch, path, nodePrefix, number, numProps, depthRemaining - 1, false);
if (printIntermediateStatus) {
System.out.println(" total created ... " + numberCreated);
}
Added: trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectionUsingHsqldbTest.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectionUsingHsqldbTest.java (rev 0)
+++ trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectionUsingHsqldbTest.java 2008-12-11 17:37:40 UTC (rev 679)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.store.jpa;
+
+import org.hibernate.ejb.Ejb3Configuration;
+
+/**
+ * @author Randall Hauch
+ */
+public class JpaConnectionUsingHsqldbTest extends JpaConnectionTest {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.connector.store.jpa.JpaConnectionTest#configureDatabaseProperties(org.hibernate.ejb.Ejb3Configuration)
+ */
+ @Override
+ protected void configureDatabaseProperties( Ejb3Configuration configurator ) {
+ configurator.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
+ configurator.setProperty("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver");
+ configurator.setProperty("hibernate.connection.username", "sa");
+ configurator.setProperty("hibernate.connection.password", "");
+ configurator.setProperty("hibernate.connection.url", "jdbc:hsqldb:.");
+ }
+
+}
Modified: trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/models/basic/SubgraphQueryTest.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/models/basic/SubgraphQueryTest.java 2008-12-10 02:27:52 UTC (rev 678)
+++ trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/models/basic/SubgraphQueryTest.java 2008-12-11 17:37:40 UTC (rev 679)
@@ -275,7 +275,7 @@
Path path = path("/a/a1");
UUID uuid = uuidByPath.get(path);
query = SubgraphQuery.create(context, manager, uuid, path, Integer.MAX_VALUE);
- locations = query.getNodeLocations(true);
+ locations = query.getNodeLocations(true, true);
verifyNextLocationIs("/a/a1");
verifyNextLocationIs("/a/a1/a1");
verifyNextLocationIs("/a/a1/a2");
@@ -289,7 +289,7 @@
Path path = path("/a/a2");
UUID uuid = uuidByPath.get(path);
query = SubgraphQuery.create(context, manager, uuid, path, Integer.MAX_VALUE);
- locations = query.getNodeLocations(true);
+ locations = query.getNodeLocations(true, true);
verifyNextLocationIs("/a/a2");
verifyNextLocationIs("/a/a2/a1");
verifyNextLocationIs("/a/a2/a2");
@@ -308,7 +308,7 @@
Path path = path("/a");
UUID uuid = uuidByPath.get(path);
query = SubgraphQuery.create(context, manager, uuid, path, Integer.MAX_VALUE);
- locations = query.getNodeLocations(true);
+ locations = query.getNodeLocations(true, true);
verifyNextLocationIs("/a");
verifyNextLocationIs("/a/a1");
verifyNextLocationIs("/a/a2");
@@ -332,7 +332,7 @@
Path path = path("/a");
UUID uuid = uuidByPath.get(path);
query = SubgraphQuery.create(context, manager, uuid, path, 4);
- locations = query.getNodeLocations(true);
+ locations = query.getNodeLocations(true, true);
verifyNextLocationIs("/a");
verifyNextLocationIs("/a/a1");
verifyNextLocationIs("/a/a2");
@@ -345,19 +345,50 @@
verifyNextLocationIs("/a/a2/a4");
verifyNextLocationIs("/a/a2/a1/a1");
verifyNextLocationIs("/a/a2/a1/a2");
+ verifyNextLocationIs("/a/a2/a1/a1/a1");
+ verifyNextLocationIs("/a/a2/a1/a1/a2");
verifyNoMoreLocations();
+
+ locations = query.getNodeLocations(true, false);
+ verifyNextLocationIs("/a");
+ verifyNextLocationIs("/a/a1");
+ verifyNextLocationIs("/a/a2");
+ verifyNextLocationIs("/a/a1/a1");
+ verifyNextLocationIs("/a/a1/a2");
+ verifyNextLocationIs("/a/a1/a3");
+ verifyNextLocationIs("/a/a2/a1");
+ verifyNextLocationIs("/a/a2/a2");
+ verifyNextLocationIs("/a/a2/a3");
+ verifyNextLocationIs("/a/a2/a4");
+ verifyNextLocationIs("/a/a2/a1/a1");
+ verifyNextLocationIs("/a/a2/a1/a2");
+ verifyNoMoreLocations();
query.close();
query = SubgraphQuery.create(context, manager, uuid, path, 2);
- locations = query.getNodeLocations(true);
+ locations = query.getNodeLocations(true, true);
verifyNextLocationIs("/a");
verifyNextLocationIs("/a/a1");
verifyNextLocationIs("/a/a2");
+ verifyNextLocationIs("/a/a1/a1");
+ verifyNextLocationIs("/a/a1/a2");
+ verifyNextLocationIs("/a/a1/a3");
+ verifyNextLocationIs("/a/a2/a1");
+ verifyNextLocationIs("/a/a2/a2");
+ verifyNextLocationIs("/a/a2/a3");
+ verifyNextLocationIs("/a/a2/a4");
verifyNoMoreLocations();
+
+ locations = query.getNodeLocations(true, false);
+ verifyNextLocationIs("/a");
+ verifyNextLocationIs("/a/a1");
+ verifyNextLocationIs("/a/a2");
+ verifyNoMoreLocations();
+
query.close();
query = SubgraphQuery.create(context, manager, uuid, path, 3);
- locations = query.getNodeLocations(true);
+ locations = query.getNodeLocations(true, false);
verifyNextLocationIs("/a");
verifyNextLocationIs("/a/a1");
verifyNextLocationIs("/a/a2");
@@ -369,6 +400,21 @@
verifyNextLocationIs("/a/a2/a3");
verifyNextLocationIs("/a/a2/a4");
verifyNoMoreLocations();
+
+ locations = query.getNodeLocations(true, true);
+ verifyNextLocationIs("/a");
+ verifyNextLocationIs("/a/a1");
+ verifyNextLocationIs("/a/a2");
+ verifyNextLocationIs("/a/a1/a1");
+ verifyNextLocationIs("/a/a1/a2");
+ verifyNextLocationIs("/a/a1/a3");
+ verifyNextLocationIs("/a/a2/a1");
+ verifyNextLocationIs("/a/a2/a2");
+ verifyNextLocationIs("/a/a2/a3");
+ verifyNextLocationIs("/a/a2/a4");
+ verifyNextLocationIs("/a/a2/a1/a1");
+ verifyNextLocationIs("/a/a2/a1/a2");
+ verifyNoMoreLocations();
query.close();
}
@@ -388,7 +434,7 @@
UUID uuid = uuidByPath.get(path);
query = SubgraphQuery.create(context, manager, uuid, path, Integer.MAX_VALUE);
- locations = query.getNodeLocations(true);
+ locations = query.getNodeLocations(true, true);
verifyNextLocationIs("/a/a1");
verifyNextLocationIs("/a/a1/a1");
verifyNextLocationIs("/a/a1/a2");
@@ -411,7 +457,7 @@
path = path("/a");
uuid = uuidByPath.get(path);
query = SubgraphQuery.create(context, manager, uuid, path, 4);
- locations = query.getNodeLocations(true);
+ locations = query.getNodeLocations(true, true);
verifyNextLocationIs("/a");
verifyNextLocationIs("/a/a2");
verifyNextLocationIs("/a/a2/a1");
@@ -420,7 +466,20 @@
verifyNextLocationIs("/a/a2/a4");
verifyNextLocationIs("/a/a2/a1/a1");
verifyNextLocationIs("/a/a2/a1/a2");
+ verifyNextLocationIs("/a/a2/a1/a1/a1");
+ verifyNextLocationIs("/a/a2/a1/a1/a2");
verifyNoMoreLocations();
+
+ locations = query.getNodeLocations(true, false);
+ verifyNextLocationIs("/a");
+ verifyNextLocationIs("/a/a2");
+ verifyNextLocationIs("/a/a2/a1");
+ verifyNextLocationIs("/a/a2/a2");
+ verifyNextLocationIs("/a/a2/a3");
+ verifyNextLocationIs("/a/a2/a4");
+ verifyNextLocationIs("/a/a2/a1/a1");
+ verifyNextLocationIs("/a/a2/a1/a2");
+ verifyNoMoreLocations();
query.close();
// Verify that all the nodes with large values do indeed have them ...
Added: trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/util/RequestProcessorCacheTest.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/util/RequestProcessorCacheTest.java (rev 0)
+++ trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/util/RequestProcessorCacheTest.java 2008-12-11 17:37:40 UTC (rev 679)
@@ -0,0 +1,422 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.store.jpa.util;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.nullValue;
+import static org.hamcrest.core.IsSame.sameInstance;
+import static org.junit.Assert.assertThat;
+import static org.junit.matchers.JUnitMatchers.hasItems;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.UUID;
+import org.jboss.dna.graph.BasicExecutionContext;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.Location;
+import org.jboss.dna.graph.properties.Name;
+import org.jboss.dna.graph.properties.NameFactory;
+import org.jboss.dna.graph.properties.NamespaceRegistry;
+import org.jboss.dna.graph.properties.Path;
+import org.jboss.dna.graph.properties.PathFactory;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Randall Hauch
+ */
+public class RequestProcessorCacheTest {
+
+ private RequestProcessorCache cache;
+ private PathFactory pathFactory;
+ private NameFactory nameFactory;
+ private NamespaceRegistry namespaces;
+ private Location location;
+ private Location[] children;
+ private LinkedList<Location> childrenList;
+ private Location location2;
+ private Location[] children2;
+ private LinkedList<Location> childrenList2;
+
+ @Before
+ public void beforeEach() {
+ ExecutionContext context = new BasicExecutionContext();
+ pathFactory = context.getValueFactories().getPathFactory();
+ nameFactory = context.getValueFactories().getNameFactory();
+ namespaces = context.getNamespaceRegistry();
+ cache = new RequestProcessorCache(pathFactory);
+
+ Path parent = pathFactory.create("/a/b/c");
+ location = new Location(parent, UUID.randomUUID());
+ children = new Location[] {new Location(pathFactory.create(parent, "d1"), UUID.randomUUID()),
+ new Location(pathFactory.create(parent, "d2"), UUID.randomUUID()),
+ new Location(pathFactory.create(parent, "d3"), UUID.randomUUID()),
+ new Location(pathFactory.create(parent, "d4"), UUID.randomUUID()),
+ new Location(pathFactory.create(parent, name("e"), 1), UUID.randomUUID()),
+ new Location(pathFactory.create(parent, name("e"), 2), UUID.randomUUID()),
+ new Location(pathFactory.create(parent, name("e"), 3), UUID.randomUUID()),
+ new Location(pathFactory.create(parent, name("e"), 4), UUID.randomUUID())};
+ childrenList = new LinkedList<Location>();
+ for (Location loc : children) {
+ childrenList.add(loc);
+ }
+
+ parent = pathFactory.create("/a/b/c/e[2]");
+ location2 = new Location(parent, children[5].getUuid());
+ children2 = new Location[] {new Location(pathFactory.create(parent, "f1"), UUID.randomUUID()),
+ new Location(pathFactory.create(parent, "f2"), UUID.randomUUID()),
+ new Location(pathFactory.create(parent, "f3"), UUID.randomUUID()),
+ new Location(pathFactory.create(parent, "f4"), UUID.randomUUID()),
+ new Location(pathFactory.create(parent, name("g"), 1), UUID.randomUUID()),
+ new Location(pathFactory.create(parent, name("g"), 2), UUID.randomUUID()),
+ new Location(pathFactory.create(parent, name("g"), 3), UUID.randomUUID()),
+ new Location(pathFactory.create(parent, name("g"), 4), UUID.randomUUID())};
+ childrenList2 = new LinkedList<Location>();
+ for (Location loc : children2) {
+ childrenList2.add(loc);
+ }
+ }
+
+ protected Path path( String name ) {
+ return pathFactory.create(name);
+ }
+
+ protected Name name( String name ) {
+ return nameFactory.create(name);
+ }
+
+ @Test
+ public void shouldNotFindLocationForPathWhenEmpty() {
+ assertThat(cache.getLocationFor(location.getPath()), is(nullValue()));
+ }
+
+ @Test
+ public void shouldNotFindLocationForNullPath() {
+ assertThat(cache.getLocationFor(null), is(nullValue()));
+ }
+
+ @Test
+ public void shouldFindLocationForPathAfterAdding() {
+ assertThat(cache.getLocationFor(location.getPath()), is(nullValue()));
+ cache.addNewNode(location);
+ assertThat(cache.getLocationFor(location.getPath()), is(sameInstance(location)));
+ }
+
+ @Test
+ public void shouldNotFindChildrenForPathEvenAfterLocationForSamePathIsAdded() {
+ cache.addNewNode(location);
+ assertThat(cache.getLocationFor(location.getPath()), is(sameInstance(location)));
+ assertThat(cache.getAllChildren(location.getPath()), is(nullValue()));
+ }
+
+ @Test
+ public void shouldNotFindChildrenForPathWhenEmpty() {
+ assertThat(cache.getAllChildren(location.getPath()), is(nullValue()));
+ }
+
+ @Test
+ public void shouldNotFindChildrenForNullPath() {
+ assertThat(cache.getAllChildren(null), is(nullValue()));
+ }
+
+ @Test
+ public void shouldFindChildrenForPathAfterChildrenAreSet() {
+ assertThat(cache.getAllChildren(location.getPath()), is(nullValue()));
+ cache.setAllChildren(location.getPath(), childrenList);
+ assertThat(cache.getAllChildren(location.getPath()), is(sameInstance(childrenList)));
+ }
+
+ @Test
+ public void shouldRemoveChildrenForPathIfSuppliedListIsNull() {
+ assertThat(cache.getAllChildren(location.getPath()), is(nullValue()));
+ cache.setAllChildren(location.getPath(), childrenList);
+ assertThat(cache.getAllChildren(location.getPath()), is(sameInstance(childrenList)));
+ cache.setAllChildren(location.getPath(), null);
+ assertThat(cache.getAllChildren(location.getPath()), is(nullValue()));
+ }
+
+ @Test
+ public void shouldSetEmptyChildrenForPathIfSuppliedListIsEmpty() {
+ assertThat(cache.getAllChildren(location.getPath()), is(nullValue()));
+ LinkedList<Location> emptyList = new LinkedList<Location>();
+ cache.setAllChildren(location.getPath(), emptyList);
+ assertThat(cache.getAllChildren(location.getPath()), is(sameInstance(emptyList)));
+ }
+
+ @Test
+ public void shouldUpdateCacheWhenNodeIsMoved() {
+ // The cache knows about the children of "/a/b/c" and "/a/b/c/e[2]".
+ // This test moves "/a/b/c/e[2]" into "/a/b/c/d3"
+ Location oldLocation = location2;
+ Location newLocation = new Location(pathFactory.create("/a/b/c/d3/e[1]"));
+ assertThat(oldLocation.getPath().getString(namespaces), is("/a/b/c/e[2]"));
+ assertThat(newLocation.getPath().getString(namespaces), is("/a/b/c/d3/e[1]"));
+ cache.addNewNode(location);
+ cache.addNewNode(location2);
+ for (Location loc : children)
+ cache.addNewNode(loc);
+ for (Location loc : children2)
+ cache.addNewNode(loc);
+ cache.addNewNode(location);
+ cache.addNewNode(location2);
+ cache.setAllChildren(location.getPath(), childrenList);
+ cache.setAllChildren(location2.getPath(), childrenList2);
+
+ // Assert the information before the move ...
+ assertThat(cache.getAllChildren(location.getPath()), hasItems(children));
+ assertThat(cache.getAllChildren(location2.getPath()), hasItems(children2));
+ assertThat(cache.getAllChildren(oldLocation.getPath()), hasItems(children2));
+ assertThat(cache.getAllChildren(newLocation.getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[0].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[1].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[2].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[3].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[4].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[5].getPath()), hasItems(children2));
+ assertThat(cache.getAllChildren(children[6].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[7].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[0].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[1].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[2].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[3].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[4].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[5].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[6].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[7].getPath()), is(nullValue()));
+ assertThat(cache.getLocationFor(location.getPath()), is(location));
+ assertThat(cache.getLocationFor(location2.getPath()), is(location2));
+ assertThat(cache.getLocationFor(oldLocation.getPath()), is(oldLocation));
+ assertThat(cache.getLocationFor(newLocation.getPath()), is(nullValue()));
+ assertThat(cache.getLocationFor(children[0].getPath()), is(children[0]));
+ assertThat(cache.getLocationFor(children[1].getPath()), is(children[1]));
+ assertThat(cache.getLocationFor(children[2].getPath()), is(children[2]));
+ assertThat(cache.getLocationFor(children[3].getPath()), is(children[3]));
+ assertThat(cache.getLocationFor(children[4].getPath()), is(children[4]));
+ assertThat(cache.getLocationFor(children[5].getPath()), is(children[5]));
+ assertThat(cache.getLocationFor(children[6].getPath()), is(children[6]));
+ assertThat(cache.getLocationFor(children[7].getPath()), is(children[7]));
+ assertThat(cache.getLocationFor(children2[0].getPath()), is(children2[0]));
+ assertThat(cache.getLocationFor(children2[1].getPath()), is(children2[1]));
+ assertThat(cache.getLocationFor(children2[2].getPath()), is(children2[2]));
+ assertThat(cache.getLocationFor(children2[3].getPath()), is(children2[3]));
+ assertThat(cache.getLocationFor(children2[4].getPath()), is(children2[4]));
+ assertThat(cache.getLocationFor(children2[5].getPath()), is(children2[5]));
+ assertThat(cache.getLocationFor(children2[6].getPath()), is(children2[6]));
+ assertThat(cache.getLocationFor(children2[7].getPath()), is(children2[7]));
+
+ System.out.println("Before:");
+ System.out.println(cache.getString(namespaces));
+
+ // Move the branch (without a known index) ...
+ assertThat(cache.moveNode(oldLocation, -1, newLocation), is(true));
+
+ System.out.println("After moving " + oldLocation.getPath().getString(namespaces) + " to "
+ + newLocation.getPath().getString(namespaces));
+ System.out.println(cache.getString(namespaces));
+
+ // Check the cache content, which should no longer have any content below the old and new locations ...
+ LinkedList<Location> afterRemoval = cache.getAllChildren(location.getPath());
+ assertThat(afterRemoval.get(0), is(children[0]));
+ assertThat(afterRemoval.get(1), is(children[1]));
+ assertThat(afterRemoval.get(2), is(children[2]));
+ assertThat(afterRemoval.get(3), is(children[3]));
+ assertThat(afterRemoval.get(4), is(children[4]));
+ assertThat(afterRemoval.get(5), is(children[6].with(path("/a/b/c/e[2]"))));
+ assertThat(afterRemoval.get(6), is(children[7].with(path("/a/b/c/e[3]"))));
+
+ assertThat(cache.getAllChildren(location2.getPath()), is(nullValue())); // old location
+ assertThat(cache.getAllChildren(oldLocation.getPath()), is(nullValue())); // old location
+ assertThat(cache.getAllChildren(newLocation.getPath()), is(nullValue())); // all children removed
+
+ assertThat(cache.getAllChildren(children[0].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[1].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[2].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[3].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[4].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[5].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[6].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[1].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[2].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[3].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[4].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[5].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[6].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[7].getPath()), is(nullValue()));
+ assertThat(cache.getLocationFor(location.getPath()), is(location));
+ // location 2 was moved, so it's been replaced by the next SNS (children 6 with SNS index of 2) ...
+ assertThat(cache.getLocationFor(location2.getPath()), is(children[6].with(path("/a/b/c/e[2]"))));
+ assertThat(cache.getLocationFor(oldLocation.getPath()), is(children[6].with(path("/a/b/c/e[2]"))));
+ assertThat(cache.getLocationFor(newLocation.getPath()), is(nullValue()));
+ assertThat(cache.getLocationFor(children[0].getPath()), is(children[0]));
+ assertThat(cache.getLocationFor(children[1].getPath()), is(children[1]));
+ assertThat(cache.getLocationFor(children[2].getPath()), is(children[2]));
+ assertThat(cache.getLocationFor(children[3].getPath()), is(children[3]));
+ assertThat(cache.getLocationFor(children[4].getPath()), is(children[4]));
+ // children[6] replaced children[5]'s path, and [7] replaced [6]
+ assertThat(cache.getLocationFor(children[5].getPath()), is(children[6].with(path("/a/b/c/e[2]"))));
+ assertThat(cache.getLocationFor(children[6].getPath()), is(children[7].with(path("/a/b/c/e[3]"))));
+ assertThat(cache.getLocationFor(children[7].getPath()), is(nullValue()));
+ // The following nodes were moved, but as children they were removed from the cache
+ // rather than having a non-last-segment in their paths updated.
+ assertThat(cache.getLocationFor(children2[0].getPath()), is(nullValue()));
+ assertThat(cache.getLocationFor(children2[1].getPath()), is(nullValue()));
+ assertThat(cache.getLocationFor(children2[2].getPath()), is(nullValue()));
+ assertThat(cache.getLocationFor(children2[3].getPath()), is(nullValue()));
+ assertThat(cache.getLocationFor(children2[4].getPath()), is(nullValue()));
+ assertThat(cache.getLocationFor(children2[5].getPath()), is(nullValue()));
+ assertThat(cache.getLocationFor(children2[6].getPath()), is(nullValue()));
+ assertThat(cache.getLocationFor(children2[7].getPath()), is(nullValue()));
+ }
+
+ @Test
+ public void shouldUpdateCacheWhenNodeIsRemoved() {
+ // The cache knows about the children of "/a/b/c" and "/a/b/c/e[2]".
+ // This test removes "/a/b/c/e[2]"
+ Location oldLocation = location2;
+ Location newLocation = new Location(pathFactory.create("/a/b/c/d3/e[1]"));
+ assertThat(oldLocation.getPath().getString(namespaces), is("/a/b/c/e[2]"));
+ assertThat(newLocation.getPath().getString(namespaces), is("/a/b/c/d3/e[1]"));
+ cache.addNewNode(location);
+ cache.addNewNode(location2);
+ for (Location loc : children)
+ cache.addNewNode(loc);
+ for (Location loc : children2)
+ cache.addNewNode(loc);
+ cache.addNewNode(location);
+ cache.addNewNode(location2);
+ cache.setAllChildren(location.getPath(), childrenList);
+ cache.setAllChildren(location2.getPath(), childrenList2);
+
+ // Assert the information before the move ...
+ assertThat(cache.getAllChildren(location.getPath()), hasItems(children));
+ assertThat(cache.getAllChildren(location2.getPath()), hasItems(children2));
+ assertThat(cache.getAllChildren(oldLocation.getPath()), hasItems(children2));
+ assertThat(cache.getAllChildren(newLocation.getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[0].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[1].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[2].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[3].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[4].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[5].getPath()), hasItems(children2));
+ assertThat(cache.getAllChildren(children[6].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[7].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[0].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[1].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[2].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[3].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[4].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[5].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[6].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[7].getPath()), is(nullValue()));
+ assertThat(cache.getLocationFor(location.getPath()), is(location));
+ assertThat(cache.getLocationFor(location2.getPath()), is(location2));
+ assertThat(cache.getLocationFor(oldLocation.getPath()), is(oldLocation));
+ assertThat(cache.getLocationFor(newLocation.getPath()), is(nullValue()));
+ assertThat(cache.getLocationFor(children[0].getPath()), is(children[0]));
+ assertThat(cache.getLocationFor(children[1].getPath()), is(children[1]));
+ assertThat(cache.getLocationFor(children[2].getPath()), is(children[2]));
+ assertThat(cache.getLocationFor(children[3].getPath()), is(children[3]));
+ assertThat(cache.getLocationFor(children[4].getPath()), is(children[4]));
+ assertThat(cache.getLocationFor(children[5].getPath()), is(children[5]));
+ assertThat(cache.getLocationFor(children[6].getPath()), is(children[6]));
+ assertThat(cache.getLocationFor(children[7].getPath()), is(children[7]));
+ assertThat(cache.getLocationFor(children2[0].getPath()), is(children2[0]));
+ assertThat(cache.getLocationFor(children2[1].getPath()), is(children2[1]));
+ assertThat(cache.getLocationFor(children2[2].getPath()), is(children2[2]));
+ assertThat(cache.getLocationFor(children2[3].getPath()), is(children2[3]));
+ assertThat(cache.getLocationFor(children2[4].getPath()), is(children2[4]));
+ assertThat(cache.getLocationFor(children2[5].getPath()), is(children2[5]));
+ assertThat(cache.getLocationFor(children2[6].getPath()), is(children2[6]));
+ assertThat(cache.getLocationFor(children2[7].getPath()), is(children2[7]));
+
+ System.out.println("Before:");
+ System.out.println(cache.getString(namespaces));
+
+ // Create the locations that in the branch to be removed ...
+ List<Location> locationsToRemove = new LinkedList<Location>();
+ locationsToRemove.add(location2);
+ for (Location childLocation : children2) {
+ locationsToRemove.add(childLocation);
+ }
+ locationsToRemove.add(new Location(pathFactory.create(children2[6].getPath(), "m1")));
+ locationsToRemove.add(new Location(pathFactory.create(children2[6].getPath(), "m2")));
+ locationsToRemove.add(new Location(pathFactory.create(children2[6].getPath(), "m3")));
+
+ // Remove the branch ...
+ assertThat(cache.removeBranch(locationsToRemove), is(true));
+
+ System.out.println("After removing " + locationsToRemove.get(0).getString(namespaces));
+ System.out.println(cache.getString(namespaces));
+
+ // Check the cache content, which should no longer have any content below the old and new locations ...
+ LinkedList<Location> afterRemoval = cache.getAllChildren(location.getPath());
+ assertThat(afterRemoval.get(0), is(children[0]));
+ assertThat(afterRemoval.get(1), is(children[1]));
+ assertThat(afterRemoval.get(2), is(children[2]));
+ assertThat(afterRemoval.get(3), is(children[3]));
+ assertThat(afterRemoval.get(4), is(children[4]));
+ assertThat(afterRemoval.get(5), is(children[6].with(path("/a/b/c/e[2]"))));
+ assertThat(afterRemoval.get(6), is(children[7].with(path("/a/b/c/e[3]"))));
+
+ assertThat(cache.getAllChildren(location2.getPath()), is(nullValue())); // old location
+ assertThat(cache.getAllChildren(oldLocation.getPath()), is(nullValue())); // old location
+ assertThat(cache.getAllChildren(newLocation.getPath()), is(nullValue())); // all children removed
+
+ assertThat(cache.getAllChildren(children[0].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[1].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[2].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[3].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[4].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[5].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children[6].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[1].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[2].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[3].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[4].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[5].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[6].getPath()), is(nullValue()));
+ assertThat(cache.getAllChildren(children2[7].getPath()), is(nullValue()));
+ assertThat(cache.getLocationFor(location.getPath()), is(location));
+ // location 2 was moved, so it's been replaced by the next SNS (children 6 with SNS index of 2) ...
+ assertThat(cache.getLocationFor(location2.getPath()), is(children[6].with(path("/a/b/c/e[2]"))));
+ assertThat(cache.getLocationFor(oldLocation.getPath()), is(children[6].with(path("/a/b/c/e[2]"))));
+ assertThat(cache.getLocationFor(newLocation.getPath()), is(nullValue()));
+ assertThat(cache.getLocationFor(children[0].getPath()), is(children[0]));
+ assertThat(cache.getLocationFor(children[1].getPath()), is(children[1]));
+ assertThat(cache.getLocationFor(children[2].getPath()), is(children[2]));
+ assertThat(cache.getLocationFor(children[3].getPath()), is(children[3]));
+ assertThat(cache.getLocationFor(children[4].getPath()), is(children[4]));
+ // children[6] replaced children[5]'s path, and [7] replaced [6]
+ assertThat(cache.getLocationFor(children[5].getPath()), is(children[6].with(path("/a/b/c/e[2]"))));
+ assertThat(cache.getLocationFor(children[6].getPath()), is(children[7].with(path("/a/b/c/e[3]"))));
+ assertThat(cache.getLocationFor(children[7].getPath()), is(nullValue()));
+ // The following nodes were moved, but as children they were removed from the cache
+ // rather than having a non-last-segment in their paths updated.
+ assertThat(cache.getLocationFor(children2[0].getPath()), is(nullValue()));
+ assertThat(cache.getLocationFor(children2[1].getPath()), is(nullValue()));
+ assertThat(cache.getLocationFor(children2[2].getPath()), is(nullValue()));
+ assertThat(cache.getLocationFor(children2[3].getPath()), is(nullValue()));
+ assertThat(cache.getLocationFor(children2[4].getPath()), is(nullValue()));
+ assertThat(cache.getLocationFor(children2[5].getPath()), is(nullValue()));
+ assertThat(cache.getLocationFor(children2[6].getPath()), is(nullValue()));
+ assertThat(cache.getLocationFor(children2[7].getPath()), is(nullValue()));
+ }
+}
Modified: trunk/extensions/dna-connector-store-jpa/src/test/resources/log4j.properties
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/test/resources/log4j.properties 2008-12-10 02:27:52 UTC (rev 678)
+++ trunk/extensions/dna-connector-store-jpa/src/test/resources/log4j.properties 2008-12-11 17:37:40 UTC (rev 679)
@@ -14,6 +14,7 @@
# Hibernate
log4j.logger.org.hibernate=ERROR
log4j.logger.org.hibernate.hql=ERROR
+#log4j.logger.org.hibernate.tool.hbm2ddl=DEBUG
# C3P0
log4j.logger.com.mchange=ERROR
17 years
DNA SVN: r678 - trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/basic.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2008-12-09 21:27:52 -0500 (Tue, 09 Dec 2008)
New Revision: 678
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/basic/AbstractPath.java
Log:
DNA-250 - Creating a path from a parent path and a segment is not fast
Added an optimized check during the isAtOrBelow and isAtOrAbove methods, and removed the caching of the string form of the path (which was cached based upon the first call to any of the getString methods, regardless of the NamespaceRegistry instance used, meaning the cached string might have used no namespace registry and was returned from a getString(...) that took a namespace registry. Also, the extra overhead of the cached string was not worth the memory.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/basic/AbstractPath.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/basic/AbstractPath.java 2008-12-09 15:09:16 UTC (rev 677)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/properties/basic/AbstractPath.java 2008-12-10 02:27:52 UTC (rev 678)
@@ -51,7 +51,6 @@
public static final Path SELF_PATH = new BasicPath(Collections.singletonList(Path.SELF_SEGMENT), false);
- private transient String cachedStringPath;
private transient int hc = 0;
protected boolean isNormalized( List<Segment> segments ) {
@@ -221,7 +220,6 @@
TextEncoder encoder,
TextEncoder delimiterEncoder ) {
if (encoder == null) encoder = DEFAULT_ENCODER;
- if (encoder == DEFAULT_ENCODER && cachedStringPath != null && delimiterEncoder == null) return cachedStringPath;
final String delimiter = delimiterEncoder != null ? delimiterEncoder.encode(DELIMITER_STR) : DELIMITER_STR;
// Since the segments are immutable, this code need not be synchronized because concurrent threads
@@ -241,7 +239,6 @@
String result = sb.toString();
// Save the result to the internal string if this the default encoder is used.
// This is not synchronized, but it's okay
- if (encoder == DEFAULT_ENCODER && cachedStringPath == null && delimiterEncoder == null) cachedStringPath = result;
return result;
}
@@ -287,6 +284,7 @@
CheckArg.isNotNull(other, "other");
if (this == other) return true;
if (other.isRoot()) return true;
+ if (other.size() > this.size()) return false;
Iterator<Segment> thisIter = iterator();
Iterator<Segment> thatIter = other.iterator();
while (thisIter.hasNext() && thatIter.hasNext()) {
@@ -304,6 +302,7 @@
public boolean isAtOrAbove( Path other ) {
CheckArg.isNotNull(other, "other");
if (this == other) return true;
+ if (this.size() > other.size()) return false;
Iterator<Segment> thisIter = iterator();
Iterator<Segment> thatIter = other.iterator();
while (thisIter.hasNext() && thatIter.hasNext()) {
17 years
DNA SVN: r677 - in trunk/extensions: dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api and 7 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2008-12-09 10:09:16 -0500 (Tue, 09 Dec 2008)
New Revision: 677
Modified:
trunk/extensions/dna-common-jdbc/.classpath
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/BestRowIdentifierScopeType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/ColumnPseudoType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/IndexType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/KeyDeferrabilityType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/KeyModifyRuleType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/NullabilityType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/ParameterIoType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/PrivilegeType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/SortSequenceType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/StoredProcedureResultType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/TransactionIsolationLevelType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/CoreMetaDataBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/provider/DefaultDriverDatabaseMetadataProvider.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/util/DatabaseUtil.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/AttributeBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/BestRowIdentifierBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/CatalogBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ColumnBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/CoreMetaDataBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/DatabaseBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/DatabaseNamedObjectBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ForeignKeyBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ForeignKeyColumnBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/IndexBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/IndexColumnBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/KeyColumnBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ParameterBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/PrimaryKeyBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/PrimaryKeyColumnBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/PrivilegeBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ReferenceBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/SchemaBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/SchemaObjectBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/SqlTypeConversionPairBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/SqlTypeInfoBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/StoredProcedureBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/TableBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/TableColumnBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/TableTypeBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/UserDefinedTypeBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/provider/DataSourceDatabaseMetadataProviderTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/util/DatabaseUtilTest.java
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRepositorySource.java
Log:
Corrected most of the compiler warnings.
Modified: trunk/extensions/dna-common-jdbc/.classpath
===================================================================
--- trunk/extensions/dna-common-jdbc/.classpath 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/.classpath 2008-12-09 15:09:16 UTC (rev 677)
@@ -1,10 +1,10 @@
<?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="src" output="target/test-classes" path="src/test/java"/>
- <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
- <classpathentry kind="output" path="target/classes"/>
-</classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/main/resources"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
\ No newline at end of file
Modified: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/BestRowIdentifierScopeType.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/BestRowIdentifierScopeType.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/BestRowIdentifierScopeType.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -31,7 +31,7 @@
public enum BestRowIdentifierScopeType {
TEMPORARY(DatabaseMetaData.bestRowTemporary), // Indicates that the scope is very temporary, lasting only while the row is
- // being used.
+ // being used.
TRANSACTION(DatabaseMetaData.bestRowTransaction), // Indicates that the scope is the remainder of the current transaction.
SESSION(DatabaseMetaData.bestRowSession); // Indicates that the scope is the remainder of the current session.
@@ -43,7 +43,7 @@
public int getScope() {
return scope;
- };
+ }
public String getName() {
return name();
Modified: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/ColumnPseudoType.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/ColumnPseudoType.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/ColumnPseudoType.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -40,7 +40,7 @@
public int getType() {
return type;
- };
+ }
public String getName() {
return name();
Modified: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/IndexType.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/IndexType.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/IndexType.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -45,7 +45,7 @@
public int getType() {
return type;
- };
+ }
public String getName() {
return name();
Modified: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/KeyDeferrabilityType.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/KeyDeferrabilityType.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/KeyDeferrabilityType.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -42,7 +42,7 @@
public int getDeferrability() {
return deferrability;
- };
+ }
public String getName() {
return name();
Modified: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/KeyModifyRuleType.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/KeyModifyRuleType.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/KeyModifyRuleType.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -31,14 +31,14 @@
public enum KeyModifyRuleType {
CASCADE(DatabaseMetaData.importedKeyCascade), // when the primary key is updated/deleted, the foreign key (imported key) is
- // changed/deleted to agree with it;
+ // changed/deleted to agree with it;
RESTRICT(DatabaseMetaData.importedKeyRestrict), // a primary key may not be updated/deleted if it has been imported by another
- // table as a foreign key.
+ // table as a foreign key.
SET_NULL(DatabaseMetaData.importedKeySetNull), // when the primary key is updated or deleted, the foreign key (imported key)
- // is changed to <code>NULL</code>.
+ // is changed to <code>NULL</code>.
NO_ACTION(DatabaseMetaData.importedKeyNoAction), // if the primary key has been imported, it cannot be updated or deleted.
SET_DEFAULT(DatabaseMetaData.importedKeySetDefault); // if the primary key is updated or deleted, the foreign key (imported
- // key) is set to the default value.
+ // key) is set to the default value.
private final int rule;
@@ -48,7 +48,7 @@
public int getRule() {
return rule;
- };
+ }
public String getName() {
return name();
Modified: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/NullabilityType.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/NullabilityType.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/NullabilityType.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -40,7 +40,7 @@
public int getNullability() {
return nullability;
- };
+ }
public String getName() {
return name();
Modified: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/ParameterIoType.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/ParameterIoType.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/ParameterIoType.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -45,7 +45,7 @@
public int getType() {
return type;
- };
+ }
public String getName() {
return name();
Modified: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/PrivilegeType.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/PrivilegeType.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/PrivilegeType.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.common.jdbc.model.api;
-import java.sql.DatabaseMetaData;
/**
* Provides RDBMS supported privilege types as enumeration set.
@@ -44,7 +43,7 @@
public String getType() {
return type;
- };
+ }
public String getName() {
return name();
Modified: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/SortSequenceType.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/SortSequenceType.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/SortSequenceType.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.common.jdbc.model.api;
-import java.sql.DatabaseMetaData;
/**
* Provides RDBMS supported sort sequence types as enumeration set.
@@ -41,7 +40,7 @@
public String getType() {
return type;
- };
+ }
public String getName() {
return name();
Modified: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/StoredProcedureResultType.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/StoredProcedureResultType.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/StoredProcedureResultType.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -42,7 +42,7 @@
public int getType() {
return type;
- };
+ }
public String getName() {
return name();
Modified: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/TransactionIsolationLevelType.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/TransactionIsolationLevelType.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/TransactionIsolationLevelType.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -44,7 +44,7 @@
public int getLevel() {
return level;
- };
+ }
public String getName() {
return name();
Modified: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/CoreMetaDataBean.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/CoreMetaDataBean.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/CoreMetaDataBean.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.common.jdbc.model.spi;
-import java.io.Serializable;
import org.jboss.dna.common.jdbc.model.api.CoreMetaData;
/**
@@ -30,7 +29,13 @@
* @author <a href="mailto:litsenko_sergey@yahoo.com">Sergiy Litsenko</a>
*/
public class CoreMetaDataBean implements CoreMetaData {
+
/**
+ * Serializable version {@value}
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
* Default constructor
*/
public CoreMetaDataBean() {
Modified: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/provider/DefaultDriverDatabaseMetadataProvider.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/provider/DefaultDriverDatabaseMetadataProvider.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/provider/DefaultDriverDatabaseMetadataProvider.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -62,8 +62,9 @@
* Opens new database connection based on suppied parameters
*
* @return new database connection based on suppied parameters
- * @throws Exception
+ * @throws Exception
*/
+ @Override
protected Connection openConnection() throws Exception {
// log debug info
if (log.isDebugEnabled()) {
Modified: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/util/DatabaseUtil.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/util/DatabaseUtil.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/util/DatabaseUtil.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -27,12 +27,48 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-
import org.apache.commons.beanutils.PropertyUtils;
-import org.jboss.dna.common.util.Logger;
import org.jboss.dna.common.jdbc.JdbcMetadataI18n;
-import org.jboss.dna.common.jdbc.model.api.*;
import org.jboss.dna.common.jdbc.model.ModelFactory;
+import org.jboss.dna.common.jdbc.model.api.Attribute;
+import org.jboss.dna.common.jdbc.model.api.BestRowIdentifier;
+import org.jboss.dna.common.jdbc.model.api.BestRowIdentifierScopeType;
+import org.jboss.dna.common.jdbc.model.api.Catalog;
+import org.jboss.dna.common.jdbc.model.api.ColumnPseudoType;
+import org.jboss.dna.common.jdbc.model.api.Database;
+import org.jboss.dna.common.jdbc.model.api.DatabaseMetaDataMethodException;
+import org.jboss.dna.common.jdbc.model.api.ForeignKey;
+import org.jboss.dna.common.jdbc.model.api.ForeignKeyColumn;
+import org.jboss.dna.common.jdbc.model.api.Index;
+import org.jboss.dna.common.jdbc.model.api.IndexColumn;
+import org.jboss.dna.common.jdbc.model.api.IndexType;
+import org.jboss.dna.common.jdbc.model.api.KeyDeferrabilityType;
+import org.jboss.dna.common.jdbc.model.api.KeyModifyRuleType;
+import org.jboss.dna.common.jdbc.model.api.NullabilityType;
+import org.jboss.dna.common.jdbc.model.api.Parameter;
+import org.jboss.dna.common.jdbc.model.api.ParameterIoType;
+import org.jboss.dna.common.jdbc.model.api.PrimaryKey;
+import org.jboss.dna.common.jdbc.model.api.PrimaryKeyColumn;
+import org.jboss.dna.common.jdbc.model.api.Privilege;
+import org.jboss.dna.common.jdbc.model.api.PrivilegeType;
+import org.jboss.dna.common.jdbc.model.api.Reference;
+import org.jboss.dna.common.jdbc.model.api.ResultSetConcurrencyType;
+import org.jboss.dna.common.jdbc.model.api.ResultSetHoldabilityType;
+import org.jboss.dna.common.jdbc.model.api.ResultSetType;
+import org.jboss.dna.common.jdbc.model.api.SQLStateType;
+import org.jboss.dna.common.jdbc.model.api.Schema;
+import org.jboss.dna.common.jdbc.model.api.SearchabilityType;
+import org.jboss.dna.common.jdbc.model.api.SortSequenceType;
+import org.jboss.dna.common.jdbc.model.api.SqlType;
+import org.jboss.dna.common.jdbc.model.api.SqlTypeInfo;
+import org.jboss.dna.common.jdbc.model.api.StoredProcedure;
+import org.jboss.dna.common.jdbc.model.api.StoredProcedureResultType;
+import org.jboss.dna.common.jdbc.model.api.Table;
+import org.jboss.dna.common.jdbc.model.api.TableColumn;
+import org.jboss.dna.common.jdbc.model.api.TableType;
+import org.jboss.dna.common.jdbc.model.api.TransactionIsolationLevelType;
+import org.jboss.dna.common.jdbc.model.api.UserDefinedType;
+import org.jboss.dna.common.util.Logger;
/**
* Database related utilities
@@ -50,7 +86,7 @@
*/
private static String standardUserDefinedTypes = "JAVA_OBJECT,STRUCT,DISTINCT";
- private static Map standardUserDefinedTypesMapping = new HashMap();
+ private static Map<String, Integer> standardUserDefinedTypesMapping = new HashMap<String, Integer>();
static {
standardUserDefinedTypesMapping.put("JAVA_OBJECT", new Integer(SqlType.JAVA_OBJECT.getType()));
@@ -91,7 +127,7 @@
// fill array
for (int i = 0; i < userDefinedTypesStringArray.length; i++) {
// get value from map
- Integer udtType = (Integer)standardUserDefinedTypesMapping.get(userDefinedTypesStringArray[i]);
+ Integer udtType = standardUserDefinedTypesMapping.get(userDefinedTypesStringArray[i]);
// set int value
userDefinedTypesArray[i] = (udtType == null) ? Types.NULL : udtType.intValue();
}
@@ -104,7 +140,7 @@
* @param resultSet the result set to fetch from
* @param columnName the name of column
* @return boolean with respect to NULL values (could be null)
- * @throws SQLException
+ * @throws SQLException
*/
public static Boolean getBoolean( ResultSet resultSet,
String columnName ) throws SQLException {
@@ -125,7 +161,7 @@
* @param columnName the name of column
* @param failOnError if true raises exception
* @return boolean with respect to NULL values (could be null)
- * @throws SQLException
+ * @throws SQLException
*/
public static Boolean getBoolean( ResultSet resultSet,
String columnName,
@@ -143,10 +179,9 @@
} catch (SQLException e) {
if (failOnError) {
throw e;
- } else {
- log.error(JdbcMetadataI18n.unableToGetValueFromColumn, columnName, e.getMessage());
- return null;
}
+ log.error(JdbcMetadataI18n.unableToGetValueFromColumn, columnName, e.getMessage());
+ return null;
}
}
@@ -156,7 +191,7 @@
* @param resultSet the result set to fetch from
* @param columnIndex the index of column
* @return boolean with respect to NULL values (could be null)
- * @throws SQLException
+ * @throws SQLException
*/
public static Boolean getBoolean( ResultSet resultSet,
int columnIndex ) throws SQLException {
@@ -177,7 +212,7 @@
* @param columnIndex the index of column
* @param failOnError if true raises exception
* @return boolean with respect to NULL values (could be null)
- * @throws SQLException
+ * @throws SQLException
*/
public static Boolean getBoolean( ResultSet resultSet,
int columnIndex,
@@ -195,10 +230,9 @@
} catch (SQLException e) {
if (failOnError) {
throw e;
- } else {
- log.error(JdbcMetadataI18n.unableToGetValueFromColumn, columnIndex, e.getMessage());
- return null;
}
+ log.error(JdbcMetadataI18n.unableToGetValueFromColumn, columnIndex, e.getMessage());
+ return null;
}
}
@@ -208,7 +242,7 @@
* @param resultSet the result set to fetch from
* @param columnName the name of column
* @return integer with respect to NULL values (could be null)
- * @throws SQLException
+ * @throws SQLException
*/
public static Integer getInteger( ResultSet resultSet,
String columnName ) throws SQLException {
@@ -229,7 +263,7 @@
* @param columnName the name of column
* @param failOnError if true raises exception
* @return integer with respect to NULL values (could be null)
- * @throws SQLException
+ * @throws SQLException
*/
public static Integer getInteger( ResultSet resultSet,
String columnName,
@@ -248,10 +282,9 @@
} catch (SQLException e) {
if (failOnError) {
throw e;
- } else {
- log.error(JdbcMetadataI18n.unableToGetValueFromColumn, columnName, e.getMessage());
- return null;
}
+ log.error(JdbcMetadataI18n.unableToGetValueFromColumn, columnName, e.getMessage());
+ return null;
}
}
@@ -261,7 +294,7 @@
* @param resultSet the result set to fetch from
* @param columnIndex the index of column
* @return integer with respect to NULL values (could be null)
- * @throws SQLException
+ * @throws SQLException
*/
public static Integer getInteger( ResultSet resultSet,
int columnIndex ) throws SQLException {
@@ -282,7 +315,7 @@
* @param columnIndex the index of column
* @param failOnError if true raises exception
* @return integer with respect to NULL values (could be null)
- * @throws SQLException
+ * @throws SQLException
*/
public static Integer getInteger( ResultSet resultSet,
int columnIndex,
@@ -301,10 +334,9 @@
} catch (SQLException e) {
if (failOnError) {
throw e;
- } else {
- log.error(JdbcMetadataI18n.unableToGetValueFromColumn, columnIndex, e.getMessage());
- return null;
}
+ log.error(JdbcMetadataI18n.unableToGetValueFromColumn, columnIndex, e.getMessage());
+ return null;
}
}
@@ -314,7 +346,7 @@
* @param resultSet the result set to fetch from
* @param columnName the name of column
* @return long with respect to NULL values (could be null)
- * @throws SQLException
+ * @throws SQLException
*/
public static Long getLong( ResultSet resultSet,
String columnName ) throws SQLException {
@@ -335,7 +367,7 @@
* @param columnName the name of column
* @param failOnError if true raises exception
* @return long with respect to NULL values (could be null)
- * @throws SQLException
+ * @throws SQLException
*/
public static Long getLong( ResultSet resultSet,
String columnName,
@@ -354,10 +386,9 @@
} catch (SQLException e) {
if (failOnError) {
throw e;
- } else {
- log.error(JdbcMetadataI18n.unableToGetValueFromColumn, columnName, e.getMessage());
- return null;
}
+ log.error(JdbcMetadataI18n.unableToGetValueFromColumn, columnName, e.getMessage());
+ return null;
}
}
@@ -367,7 +398,7 @@
* @param resultSet the result set to fetch from
* @param columnIndex the index of column
* @return long with respect to NULL values (could be null)
- * @throws SQLException
+ * @throws SQLException
*/
public static Long getLong( ResultSet resultSet,
int columnIndex ) throws SQLException {
@@ -388,7 +419,7 @@
* @param columnIndex the index of column
* @param failOnError if true raises exception
* @return long with respect to NULL values (could be null)
- * @throws SQLException
+ * @throws SQLException
*/
public static Long getLong( ResultSet resultSet,
int columnIndex,
@@ -407,10 +438,9 @@
} catch (SQLException e) {
if (failOnError) {
throw e;
- } else {
- log.error(JdbcMetadataI18n.unableToGetValueFromColumn, columnIndex, e.getMessage());
- return null;
}
+ log.error(JdbcMetadataI18n.unableToGetValueFromColumn, columnIndex, e.getMessage());
+ return null;
}
}
@@ -420,7 +450,7 @@
* @param resultSet the result set to fetch from
* @param columnName the name of column
* @return double with respect to NULL values (could be null)
- * @throws SQLException
+ * @throws SQLException
*/
public static Double getDouble( ResultSet resultSet,
String columnName ) throws SQLException {
@@ -441,7 +471,7 @@
* @param columnName the name of column
* @param failOnError if true raises exception
* @return double with respect to NULL values (could be null)
- * @throws SQLException
+ * @throws SQLException
*/
public static Double getDouble( ResultSet resultSet,
String columnName,
@@ -460,10 +490,9 @@
} catch (SQLException e) {
if (failOnError) {
throw e;
- } else {
- log.error(JdbcMetadataI18n.unableToGetValueFromColumn, columnName, e.getMessage());
- return null;
}
+ log.error(JdbcMetadataI18n.unableToGetValueFromColumn, columnName, e.getMessage());
+ return null;
}
}
@@ -473,7 +502,7 @@
* @param resultSet the result set to fetch from
* @param columnIndex the index of column
* @return double with respect to NULL values (could be null)
- * @throws SQLException
+ * @throws SQLException
*/
public static Double getDouble( ResultSet resultSet,
int columnIndex ) throws SQLException {
@@ -494,7 +523,7 @@
* @param columnIndex the index of column
* @param failOnError if true raises exception
* @return double with respect to NULL values (could be null)
- * @throws SQLException
+ * @throws SQLException
*/
public static Double getDouble( ResultSet resultSet,
int columnIndex,
@@ -513,10 +542,9 @@
} catch (SQLException e) {
if (failOnError) {
throw e;
- } else {
- log.error(JdbcMetadataI18n.unableToGetValueFromColumn, columnIndex, e.getMessage());
- return null;
}
+ log.error(JdbcMetadataI18n.unableToGetValueFromColumn, columnIndex, e.getMessage());
+ return null;
}
}
@@ -526,7 +554,7 @@
* @param resultSet the result set to fetch from
* @param columnName the name of column
* @return double with respect to NULL values (could be null)
- * @throws SQLException
+ * @throws SQLException
*/
public static String getString( ResultSet resultSet,
String columnName ) throws SQLException {
@@ -547,7 +575,7 @@
* @param columnName the name of column
* @param failOnError if true raises exception
* @return double with respect to NULL values (could be null)
- * @throws SQLException
+ * @throws SQLException
*/
public static String getString( ResultSet resultSet,
String columnName,
@@ -566,10 +594,9 @@
} catch (SQLException e) {
if (failOnError) {
throw e;
- } else {
- log.error(JdbcMetadataI18n.unableToGetValueFromColumn, columnName, e.getMessage());
- return null;
}
+ log.error(JdbcMetadataI18n.unableToGetValueFromColumn, columnName, e.getMessage());
+ return null;
}
}
@@ -579,7 +606,7 @@
* @param resultSet the result set to fetch from
* @param columnIndex the index of column
* @return double with respect to NULL values (could be null)
- * @throws SQLException
+ * @throws SQLException
*/
public static String getString( ResultSet resultSet,
int columnIndex ) throws SQLException {
@@ -600,7 +627,7 @@
* @param columnIndex the index of column
* @param failOnError if true raises exception
* @return double with respect to NULL values (could be null)
- * @throws SQLException
+ * @throws SQLException
*/
public static String getString( ResultSet resultSet,
int columnIndex,
@@ -618,10 +645,9 @@
} catch (SQLException e) {
if (failOnError) {
throw e;
- } else {
- log.error(JdbcMetadataI18n.unableToGetValueFromColumn, columnIndex, e.getMessage());
- return null;
}
+ log.error(JdbcMetadataI18n.unableToGetValueFromColumn, columnIndex, e.getMessage());
+ return null;
}
}
@@ -644,7 +670,7 @@
}
// log only if not found
log.debug(String.format("[%s] Unknown best row identifier scope type %d", "getBestRowIdentifierScopeType", type));
-
+
return null;
}
@@ -949,6 +975,7 @@
/**
* Returns SqlType based on data type, or null
+ *
* @param type the SQL type
* @return SqlType based on data type, or null
*/
@@ -1021,7 +1048,7 @@
* @param factory the model factory to create table
* @param resultSet the table result set from DatabaseMetadata
* @param traceLog the log to write if any
- * @param failOnError
+ * @param failOnError
* @param database the owner database
* @return created catalog
* @throws Exception if any error occurs and failOnError is true then generates exception
@@ -1089,7 +1116,7 @@
* @param factory the model factory to create table
* @param resultSet the table result set from DatabaseMetadata
* @param traceLog the log to write if any
- * @param failOnError
+ * @param failOnError
* @param database the owner database
* @return created schema
* @throws Exception if any error occurs and failOnError is true then generates exception
@@ -1166,7 +1193,7 @@
* @param factory the model factory to create table
* @param resultSet the table result set from DatabaseMetadata
* @param traceLog the log to write if any
- * @param failOnError
+ * @param failOnError
* @param database the owner database
* @return created schema
* @throws Exception if any error occurs and failOnError is true then generates exception
@@ -1235,7 +1262,7 @@
* @param factory the model factory to create SP
* @param resultSet the stored procedure result set from DatabaseMetadata
* @param traceLog the log to write if any
- * @param failOnError
+ * @param failOnError
* @param database the owner database
* @return created SP
* @throws Exception if any error occurs and failOnError is true then generates exception
@@ -1303,10 +1330,10 @@
// warn if null
if (catalog == null) {
traceLog.debug(String.format("[Database %s] Unable to find catalog '%4$s' for the procedure %s (schema %s, catalog %s)",
- database.getName(),
- procedureName,
- procedureSchema,
- procedureCatalog));
+ database.getName(),
+ procedureName,
+ procedureSchema,
+ procedureCatalog));
}
// if fail is enabled
if (failOnError && (catalog == null)) {
@@ -1323,14 +1350,14 @@
// warn if null
if (schema == null) {
traceLog.debug(String.format("[Database %s] Unable to find schema '%3$s' for the procedure %s (schema %s, catalog %s)",
- database.getName(),
- procedureName,
- procedureSchema,
- procedureCatalog));
+ database.getName(),
+ procedureName,
+ procedureSchema,
+ procedureCatalog));
}
// if fail is enabled
if (failOnError && (schema == null)) {
- throw new DatabaseMetaDataMethodException("Schema name shall be provided", "populateStoredProcedure");
+ throw new DatabaseMetaDataMethodException("Schema name shall be provided", "populateStoredProcedure");
}
}
@@ -1362,7 +1389,7 @@
* @param factory the model factory to create SP parameter
* @param resultSet the stored procedure parameter result set from DatabaseMetadata
* @param traceLog the log to write if any
- * @param failOnError
+ * @param failOnError
* @param database the owner database
* @param storedProcedure the owner stored procedure
* @param ordinalPosition the parameter ordinal position
@@ -1500,7 +1527,7 @@
* @param factory the model factory to create table
* @param resultSet the table result set from DatabaseMetadata
* @param traceLog the log to write if any
- * @param failOnError
+ * @param failOnError
* @param database the owner database
* @return created table
* @throws Exception if any error occurs and failOnError is true then generates exception
@@ -1581,10 +1608,10 @@
// warn if null
if (catalog == null) {
traceLog.debug(String.format("[Database %s] Unable to find catalog '%4$s' for the table %s (schema %s, catalog %s)",
- database.getName(),
- tableName,
- tableSchema,
- tableCatalog));
+ database.getName(),
+ tableName,
+ tableSchema,
+ tableCatalog));
}
// if fail is enabled
if (failOnError) {
@@ -1602,10 +1629,10 @@
// warn if null
if (schema == null) {
traceLog.debug(String.format("[Database %s] Unable to find schema '%3$s' for the table %s (schema %s, catalog %s)",
- database.getName(),
- tableName,
- tableSchema,
- tableCatalog));
+ database.getName(),
+ tableName,
+ tableSchema,
+ tableCatalog));
}
// if fail is enabled
if (failOnError) {
@@ -1636,10 +1663,10 @@
// warn if null
if (typeCatalog == null) {
traceLog.debug(String.format("[Database %s] Unable to find catalog '%4$s' for the table %s (schema %s, catalog %s)",
- database.getName(),
- tableName,
- tableSchema,
- typeCatalogName));
+ database.getName(),
+ tableName,
+ tableSchema,
+ typeCatalogName));
}
}
@@ -1652,10 +1679,10 @@
// warn if null
if (typeSchema == null) {
traceLog.debug(String.format("[Database %s] Unable to find schema '%3$s' for the table %s (schema %s, catalog %s)",
- database.getName(),
- tableName,
- typeSchemaName,
- typeCatalogName));
+ database.getName(),
+ tableName,
+ typeSchemaName,
+ typeCatalogName));
}
// if fail is enabled
if (failOnError && (typeSchema == null)) {
@@ -1691,7 +1718,7 @@
* @param factory the model factory to create SP parameter
* @param resultSet the stored procedure parameter result set from DatabaseMetadata
* @param traceLog the log to write if any
- * @param failOnError
+ * @param failOnError
* @param database the owner database
* @param table the owner table
* @return created table column
@@ -1757,7 +1784,7 @@
// ordinal position
Integer ordinalPosition = getInteger(resultSet, "ORDINAL_POSITION", false);
// is nullable string
- String isNullableString = getString(resultSet, "IS_NULLABLE", false);
+ // String isNullableString = getString(resultSet, "IS_NULLABLE", false);
// scope catalog
String scopeCatalog = getString(resultSet, "SCOPE_CATLOG", false);
// scope schema
@@ -1850,7 +1877,7 @@
* @param factory the model factory to create SP parameter
* @param resultSet the stored procedure parameter result set from DatabaseMetadata
* @param traceLog the log to write if any
- * @param failOnError
+ * @param failOnError
* @param database the owner database
* @param table the owner table
* @return created table best row identifier
@@ -1920,9 +1947,8 @@
// if exception generation is enabled then raise exception - invalid scope
if (failOnError == true) {
throw new IllegalArgumentException("scopeType");
- } else {
- return null;
}
+ return null;
}
// find table best row identifier object
@@ -2018,7 +2044,7 @@
* @param factory the model factory to create SP parameter
* @param resultSet the stored procedure parameter result set from DatabaseMetadata
* @param traceLog the log to write if any
- * @param failOnError
+ * @param failOnError
* @param database the owner database
* @param table the owner table
* @return created primary key
@@ -2161,7 +2187,7 @@
* @param factory the model factory to create SP parameter
* @param resultSet the stored procedure parameter result set from DatabaseMetadata
* @param traceLog the log to write if any
- * @param failOnError
+ * @param failOnError
* @param database the owner database
* @param table the owner table
* @return created list of foreign keys
@@ -2284,7 +2310,7 @@
// trying to find table column with specified name
TableColumn tableColumn = table.findColumnByName(fkColumnName);
-
+
String errMessage = null;
// warn if null
if (tableColumn == null) {
@@ -2365,7 +2391,7 @@
* @param factory the model factory to create SP parameter
* @param resultSet the stored procedure parameter result set from DatabaseMetadata
* @param traceLog the log to write if any
- * @param failOnError
+ * @param failOnError
* @param database the owner database
* @param table the owner table
* @return created list of index
@@ -2499,7 +2525,7 @@
// trying to find table column with specified name
TableColumn tableColumn = table.findColumnByName(indexColumnName);
-
+
String errMessage = null;
// warn if null
if (tableColumn == null) {
@@ -2563,7 +2589,7 @@
* @param factory the model factory to create SP parameter
* @param resultSet the stored procedure parameter result set from DatabaseMetadata
* @param traceLog the log to write if any
- * @param failOnError
+ * @param failOnError
* @param database the owner database
* @param table the owner table
* @return created/updated version table column
@@ -2616,7 +2642,7 @@
// size
Integer size = getInteger(resultSet, "COLUMN_SIZE", false);
// column length in bytes
- Integer bufferLength = getInteger(resultSet, "BUFFER_LENGTH", false);
+ // Integer bufferLength = getInteger(resultSet, "BUFFER_LENGTH", false);
// precision
Integer precision = getInteger(resultSet, "DECIMAL_DIGITS", false);
@@ -2685,7 +2711,7 @@
* @param factory the model factory to create SP parameter
* @param resultSet the stored procedure parameter result set from DatabaseMetadata
* @param traceLog the log to write if any
- * @param failOnError
+ * @param failOnError
* @param database the owner database
* @param table the owner table
* @return created list of privileges
@@ -2775,7 +2801,7 @@
* @param factory the model factory to create SP parameter
* @param resultSet the stored procedure parameter result set from DatabaseMetadata
* @param traceLog the log to write if any
- * @param failOnError
+ * @param failOnError
* @param database the owner database
* @param table the owner table
* @param column the table column
@@ -2874,7 +2900,7 @@
* @param factory the model factory to create table
* @param resultSet the table result set from DatabaseMetadata
* @param traceLog the log to write if any
- * @param failOnError
+ * @param failOnError
* @param database the owner database
* @return created SQL type info
* @throws Exception if any error occurs and failOnError is true then generates exception
@@ -3003,7 +3029,7 @@
* @param factory the model factory to create table
* @param resultSet the table result set from DatabaseMetadata
* @param traceLog the log to write if any
- * @param failOnError
+ * @param failOnError
* @param database the owner database
* @return created UDT
* @throws Exception if any error occurs and failOnError is true then generates exception
@@ -3072,7 +3098,7 @@
Catalog catalog = database.findCatalogByName(udtCatalog);
// set catalog
udt.setCatalog(catalog);
-
+
String errMessage = null;
// warn if null
if (catalog == null) {
@@ -3085,7 +3111,7 @@
}
// if fail is enabled
if (failOnError) {
- throw new DatabaseMetaDataMethodException(errMessage,"populateUDT");
+ throw new DatabaseMetaDataMethodException(errMessage, "populateUDT");
}
}
@@ -3095,7 +3121,7 @@
Schema schema = database.findSchemaByName(udtCatalog, udtSchema);
// set schema
udt.setSchema(schema);
-
+
String errMessage = null;
// warn if null
if (schema == null) {
@@ -3145,7 +3171,7 @@
* @param factory the model factory to create SP parameter
* @param resultSet the stored procedure parameter result set from DatabaseMetadata
* @param traceLog the log to write if any
- * @param failOnError
+ * @param failOnError
* @param database the owner database
* @param udt the owner UDT
* @return created UDT attribute
@@ -3211,7 +3237,7 @@
// ordinal position
Integer ordinalPosition = getInteger(resultSet, "ORDINAL_POSITION", false);
// is nullable string
- String isNullableString = getString(resultSet, "IS_NULLABLE", false);
+ // String isNullableString = getString(resultSet, "IS_NULLABLE", false);
// scope catalog
String scopeCatalog = getString(resultSet, "SCOPE_CATLOG", false);
// scope schema
@@ -3301,7 +3327,7 @@
* @param factory the model factory to create SP parameter
* @param resultSet the stored procedure parameter result set from DatabaseMetadata
* @param traceLog the log to write if any
- * @param failOnError
+ * @param failOnError
* @param database the owner database
* @param udt the UDT to update
* @throws Exception if any error occurs and failOnError is true then generates exception
@@ -3376,7 +3402,7 @@
* @param factory the model factory to create SP parameter
* @param resultSet the stored procedure parameter result set from DatabaseMetadata
* @param traceLog the log to write if any
- * @param failOnError
+ * @param failOnError
* @param database the owner database
* @param table the table to update
* @throws Exception if any error occurs and failOnError is true then generates exception
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/AttributeBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/AttributeBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/AttributeBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -21,10 +21,10 @@
*/
package org.jboss.dna.common.jdbc.model.spi;
+import junit.framework.TestCase;
import org.jboss.dna.common.jdbc.model.DefaultModelFactory;
import org.jboss.dna.common.jdbc.model.api.Attribute;
import org.jboss.dna.common.jdbc.model.api.Reference;
-import junit.framework.TestCase;
/**
* AttributeBean test
@@ -38,6 +38,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
// create
@@ -47,6 +48,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
// release
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/BestRowIdentifierBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/BestRowIdentifierBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/BestRowIdentifierBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -22,11 +22,11 @@
package org.jboss.dna.common.jdbc.model.spi;
import java.util.Set;
+import junit.framework.TestCase;
import org.jboss.dna.common.jdbc.model.DefaultModelFactory;
+import org.jboss.dna.common.jdbc.model.api.BestRowIdentifier;
import org.jboss.dna.common.jdbc.model.api.BestRowIdentifierScopeType;
-import org.jboss.dna.common.jdbc.model.api.BestRowIdentifier;
import org.jboss.dna.common.jdbc.model.api.Column;
-import junit.framework.TestCase;
/**
* BestRowIdentifierBean test
@@ -40,6 +40,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
@@ -50,6 +51,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
// release
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/CatalogBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/CatalogBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/CatalogBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -22,7 +22,6 @@
package org.jboss.dna.common.jdbc.model.spi;
import junit.framework.TestCase;
-import org.jboss.dna.common.jdbc.model.spi.CatalogBean;
import org.jboss.dna.common.jdbc.model.api.Catalog;
/**
@@ -37,6 +36,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
// create
@@ -46,6 +46,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
// release
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ColumnBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ColumnBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ColumnBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -21,15 +21,14 @@
*/
package org.jboss.dna.common.jdbc.model.spi;
+import java.util.Set;
import junit.framework.TestCase;
-import java.util.Set;
import org.jboss.dna.common.jdbc.model.DefaultModelFactory;
-import org.jboss.dna.common.jdbc.model.spi.ColumnBean;
import org.jboss.dna.common.jdbc.model.api.Column;
-import org.jboss.dna.common.jdbc.model.api.Table;
import org.jboss.dna.common.jdbc.model.api.NullabilityType;
+import org.jboss.dna.common.jdbc.model.api.Privilege;
import org.jboss.dna.common.jdbc.model.api.SqlType;
-import org.jboss.dna.common.jdbc.model.api.Privilege;
+import org.jboss.dna.common.jdbc.model.api.Table;
/**
* ColumnBean test
@@ -43,6 +42,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
// create
@@ -52,6 +52,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
// release
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/CoreMetaDataBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/CoreMetaDataBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/CoreMetaDataBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -23,7 +23,6 @@
import junit.framework.TestCase;
import org.jboss.dna.common.jdbc.model.api.CoreMetaData;
-import org.jboss.dna.common.jdbc.model.spi.CoreMetaDataBean;
/**
* CoreMetaDataBean test
@@ -37,6 +36,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
// create
@@ -46,6 +46,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
// release
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/DatabaseBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/DatabaseBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/DatabaseBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -21,13 +21,27 @@
*/
package org.jboss.dna.common.jdbc.model.spi;
+import java.util.List;
+import java.util.Set;
import junit.framework.TestCase;
-import java.util.Set;
-import java.util.List;
-import org.jboss.dna.common.jdbc.model.api.*;
import org.jboss.dna.common.jdbc.model.DefaultModelFactory;
import org.jboss.dna.common.jdbc.model.ModelFactory;
+import org.jboss.dna.common.jdbc.model.api.Catalog;
+import org.jboss.dna.common.jdbc.model.api.Database;
import org.jboss.dna.common.jdbc.model.api.DatabaseMetaDataMethodException;
+import org.jboss.dna.common.jdbc.model.api.ResultSetConcurrencyType;
+import org.jboss.dna.common.jdbc.model.api.ResultSetHoldabilityType;
+import org.jboss.dna.common.jdbc.model.api.ResultSetType;
+import org.jboss.dna.common.jdbc.model.api.SQLStateType;
+import org.jboss.dna.common.jdbc.model.api.Schema;
+import org.jboss.dna.common.jdbc.model.api.SqlType;
+import org.jboss.dna.common.jdbc.model.api.SqlTypeConversionPair;
+import org.jboss.dna.common.jdbc.model.api.SqlTypeInfo;
+import org.jboss.dna.common.jdbc.model.api.StoredProcedure;
+import org.jboss.dna.common.jdbc.model.api.Table;
+import org.jboss.dna.common.jdbc.model.api.TableType;
+import org.jboss.dna.common.jdbc.model.api.TransactionIsolationLevelType;
+import org.jboss.dna.common.jdbc.model.api.UserDefinedType;
/**
* DatabaseBean test
@@ -42,6 +56,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
// create
@@ -52,6 +67,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
// release
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/DatabaseNamedObjectBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/DatabaseNamedObjectBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/DatabaseNamedObjectBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -21,10 +21,9 @@
*/
package org.jboss.dna.common.jdbc.model.spi;
+import java.util.Map;
import junit.framework.TestCase;
-import java.util.Map;
import org.jboss.dna.common.jdbc.model.api.DatabaseNamedObject;
-import org.jboss.dna.common.jdbc.model.spi.DatabaseNamedObjectBean;
/**
* DatabaseNamedObjectBean test
@@ -38,6 +37,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
// create
@@ -47,6 +47,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
// release
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ForeignKeyBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ForeignKeyBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ForeignKeyBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -21,11 +21,9 @@
*/
package org.jboss.dna.common.jdbc.model.spi;
+import java.util.Set;
import junit.framework.TestCase;
-import java.util.Set;
import org.jboss.dna.common.jdbc.model.DefaultModelFactory;
-import org.jboss.dna.common.jdbc.model.spi.ForeignKeyBean;
-import org.jboss.dna.common.jdbc.model.api.Column;
import org.jboss.dna.common.jdbc.model.api.ForeignKey;
import org.jboss.dna.common.jdbc.model.api.ForeignKeyColumn;
import org.jboss.dna.common.jdbc.model.api.KeyDeferrabilityType;
@@ -45,6 +43,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
// create
@@ -54,6 +53,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
// release
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ForeignKeyColumnBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ForeignKeyColumnBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ForeignKeyColumnBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -22,9 +22,9 @@
package org.jboss.dna.common.jdbc.model.spi;
import junit.framework.TestCase;
+import org.jboss.dna.common.jdbc.model.DefaultModelFactory;
import org.jboss.dna.common.jdbc.model.api.ForeignKeyColumn;
import org.jboss.dna.common.jdbc.model.api.TableColumn;
-import org.jboss.dna.common.jdbc.model.DefaultModelFactory;
/**
* ForeignKeyColumnBean test
@@ -38,6 +38,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
// create
@@ -47,6 +48,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
// release
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/IndexBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/IndexBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/IndexBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -21,10 +21,9 @@
*/
package org.jboss.dna.common.jdbc.model.spi;
+import java.util.Set;
import junit.framework.TestCase;
-import java.util.Set;
import org.jboss.dna.common.jdbc.model.DefaultModelFactory;
-import org.jboss.dna.common.jdbc.model.api.ForeignKeyColumn;
import org.jboss.dna.common.jdbc.model.api.Index;
import org.jboss.dna.common.jdbc.model.api.IndexColumn;
import org.jboss.dna.common.jdbc.model.api.IndexType;
@@ -40,6 +39,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
// create
@@ -49,6 +49,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
// release
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/IndexColumnBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/IndexColumnBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/IndexColumnBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -22,7 +22,6 @@
package org.jboss.dna.common.jdbc.model.spi;
import junit.framework.TestCase;
-import org.jboss.dna.common.jdbc.model.DefaultModelFactory;
import org.jboss.dna.common.jdbc.model.api.IndexColumn;
import org.jboss.dna.common.jdbc.model.api.SortSequenceType;
@@ -37,6 +36,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
// create
@@ -46,6 +46,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
// release
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/KeyColumnBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/KeyColumnBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/KeyColumnBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -34,6 +34,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
// create
@@ -43,6 +44,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
// release
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ParameterBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ParameterBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ParameterBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -36,6 +36,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
// create
@@ -45,6 +46,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
// release
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/PrimaryKeyBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/PrimaryKeyBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/PrimaryKeyBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -21,8 +21,8 @@
*/
package org.jboss.dna.common.jdbc.model.spi;
+import java.util.Set;
import junit.framework.TestCase;
-import java.util.Set;
import org.jboss.dna.common.jdbc.model.DefaultModelFactory;
import org.jboss.dna.common.jdbc.model.api.PrimaryKey;
import org.jboss.dna.common.jdbc.model.api.PrimaryKeyColumn;
@@ -39,6 +39,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
// create
@@ -48,6 +49,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
// release
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/PrimaryKeyColumnBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/PrimaryKeyColumnBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/PrimaryKeyColumnBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -36,6 +36,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
// create
@@ -45,6 +46,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
// release
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/PrivilegeBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/PrivilegeBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/PrivilegeBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -37,6 +37,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
// create
@@ -46,6 +47,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ReferenceBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ReferenceBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ReferenceBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -39,6 +39,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
// create
@@ -48,6 +49,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
// release
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/SchemaBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/SchemaBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/SchemaBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -38,6 +38,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
// create
@@ -47,6 +48,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
// release
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/SchemaObjectBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/SchemaObjectBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/SchemaObjectBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -39,6 +39,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
// create
@@ -48,6 +49,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
// release
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/SqlTypeConversionPairBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/SqlTypeConversionPairBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/SqlTypeConversionPairBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -22,7 +22,6 @@
package org.jboss.dna.common.jdbc.model.spi;
import junit.framework.TestCase;
-import org.jboss.dna.common.jdbc.model.DefaultModelFactory;
import org.jboss.dna.common.jdbc.model.api.SqlType;
import org.jboss.dna.common.jdbc.model.api.SqlTypeConversionPair;
@@ -38,6 +37,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
// create
@@ -47,6 +47,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
// release
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/SqlTypeInfoBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/SqlTypeInfoBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/SqlTypeInfoBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -39,6 +39,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
// create
@@ -49,6 +50,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
// release
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/StoredProcedureBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/StoredProcedureBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/StoredProcedureBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -21,10 +21,9 @@
*/
package org.jboss.dna.common.jdbc.model.spi;
+import java.util.Set;
import junit.framework.TestCase;
-import java.util.Set;
import org.jboss.dna.common.jdbc.model.DefaultModelFactory;
-import org.jboss.dna.common.jdbc.model.api.ForeignKeyColumn;
import org.jboss.dna.common.jdbc.model.api.Parameter;
import org.jboss.dna.common.jdbc.model.api.StoredProcedure;
import org.jboss.dna.common.jdbc.model.api.StoredProcedureResultType;
@@ -41,6 +40,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
// create
@@ -50,6 +50,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
// release
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/TableBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/TableBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/TableBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -21,9 +21,8 @@
*/
package org.jboss.dna.common.jdbc.model.spi;
-import junit.framework.TestCase;
import java.util.Set;
-import java.util.HashSet;
+import junit.framework.TestCase;
import org.jboss.dna.common.jdbc.model.DefaultModelFactory;
import org.jboss.dna.common.jdbc.model.ModelFactory;
import org.jboss.dna.common.jdbc.model.api.BestRowIdentifier;
@@ -31,14 +30,12 @@
import org.jboss.dna.common.jdbc.model.api.Catalog;
import org.jboss.dna.common.jdbc.model.api.ForeignKey;
import org.jboss.dna.common.jdbc.model.api.Index;
-import org.jboss.dna.common.jdbc.model.api.Parameter;
import org.jboss.dna.common.jdbc.model.api.PrimaryKey;
import org.jboss.dna.common.jdbc.model.api.Privilege;
import org.jboss.dna.common.jdbc.model.api.Schema;
import org.jboss.dna.common.jdbc.model.api.Table;
import org.jboss.dna.common.jdbc.model.api.TableColumn;
import org.jboss.dna.common.jdbc.model.api.TableType;
-import org.jboss.dna.common.jdbc.model.spi.TableBean;
/**
* TableBean test
@@ -53,6 +50,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
// create
@@ -63,6 +61,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
// release
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/TableColumnBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/TableColumnBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/TableColumnBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -24,8 +24,8 @@
import junit.framework.TestCase;
import org.jboss.dna.common.jdbc.model.DefaultModelFactory;
import org.jboss.dna.common.jdbc.model.api.ColumnPseudoType;
+import org.jboss.dna.common.jdbc.model.api.Reference;
import org.jboss.dna.common.jdbc.model.api.TableColumn;
-import org.jboss.dna.common.jdbc.model.api.Reference;
/**
* TableColumnBean test
@@ -39,6 +39,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
// create
@@ -48,6 +49,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
// release
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/TableTypeBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/TableTypeBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/TableTypeBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -36,6 +36,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
// create
@@ -45,6 +46,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
// release
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/UserDefinedTypeBeanTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/UserDefinedTypeBeanTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/UserDefinedTypeBeanTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -21,13 +21,12 @@
*/
package org.jboss.dna.common.jdbc.model.spi;
+import java.util.Set;
import junit.framework.TestCase;
-import java.util.Set;
+import org.jboss.dna.common.jdbc.model.DefaultModelFactory;
import org.jboss.dna.common.jdbc.model.api.Attribute;
+import org.jboss.dna.common.jdbc.model.api.SqlType;
import org.jboss.dna.common.jdbc.model.api.UserDefinedType;
-import org.jboss.dna.common.jdbc.model.api.SqlType;
-import org.jboss.dna.common.jdbc.model.DefaultModelFactory;
-import org.jboss.dna.common.jdbc.model.spi.UserDefinedTypeBean;
/**
* UserDefinedTypeBean test
@@ -41,6 +40,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
// create
@@ -50,6 +50,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
// release
bean = null;
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/provider/DataSourceDatabaseMetadataProviderTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/provider/DataSourceDatabaseMetadataProviderTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/provider/DataSourceDatabaseMetadataProviderTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -21,13 +21,9 @@
*/
package org.jboss.dna.common.jdbc.provider;
+import java.util.Properties;
import junit.framework.TestCase;
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.util.Properties;
-import javax.sql.DataSource;
-
/**
* Data Source Database Metadata Provider Test
*
@@ -72,8 +68,8 @@
/**
* Test get data source
- * @throws Exception
*
+ * @throws Exception
*/
public void testGetDataSource() throws Exception {
// set provider name
@@ -97,7 +93,7 @@
// TODO: validate the testGetDataSource
try {
// trying to get data source
- DataSource dataSource = dataSourceProvider.getDataSource();
+ dataSourceProvider.getDataSource();
fail("DataSource provider should raise an exception when app server is not running");
} catch (Exception e) {
// we're should be here because app server is not running so far
@@ -147,7 +143,7 @@
// TODO: validate the testGetDatabaseMetaData
try {
// trying to get connection
- DatabaseMetaData databaseMetaData = dataSourceProvider.getDatabaseMetaData();
+ dataSourceProvider.getDatabaseMetaData();
fail("DataSource provider should raise an exception when app server is not running");
} catch (Exception e) {
// we're should be here because app server is not running so far
@@ -157,7 +153,7 @@
/**
* Test get connection
*
- * @throws Exception
+ * @throws Exception
*/
public void testGetConnection() throws Exception {
// set provider name
@@ -181,7 +177,7 @@
// TODO: validate the testGetConnection
try {
// trying to get connection
- Connection connection = dataSourceProvider.getConnection();
+ dataSourceProvider.getConnection();
fail("DataSource provider should raise an exception when app server is not running");
} catch (Exception e) {
// we're should be here because app server is not running so far
Modified: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/util/DatabaseUtilTest.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/util/DatabaseUtilTest.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/util/DatabaseUtilTest.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -35,6 +35,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
}
@@ -42,6 +43,7 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
}
Modified: trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRepositorySource.java
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRepositorySource.java 2008-12-09 10:19:19 UTC (rev 676)
+++ trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRepositorySource.java 2008-12-09 15:09:16 UTC (rev 677)
@@ -35,12 +35,10 @@
import javax.naming.BinaryRefAddr;
import javax.naming.Context;
import javax.naming.Name;
-import javax.naming.NamingException;
import javax.naming.RefAddr;
import javax.naming.Reference;
import javax.naming.StringRefAddr;
import javax.naming.spi.ObjectFactory;
-
import net.jcip.annotations.ThreadSafe;
import org.jboss.dna.common.i18n.I18n;
import org.jboss.dna.graph.cache.CachePolicy;
@@ -51,10 +49,9 @@
import org.jboss.dna.graph.connectors.RepositorySourceException;
/**
- * A description of a JDBC resource that can be used to access database information.
+ * A description of a JDBC resource that can be used to access database information.
*
* @author <a href="mailto:litsenko_sergey@yahoo.com">Sergiy Litsenko</a>
- *
*/
public class JdbcRepositorySource implements RepositorySource, ObjectFactory {
private static final long serialVersionUID = 1L;
@@ -77,7 +74,7 @@
* This source does not support same-name-siblings.
*/
protected static final boolean SUPPORTS_SAME_NAME_SIBLINGS = false;
-
+
private final AtomicInteger retryLimit = new AtomicInteger(DEFAULT_RETRY_LIMIT);
protected String name;
protected final Capabilities capabilities = new Capabilities();
@@ -89,7 +86,7 @@
protected static final String REPO_JNDI_NAME = "jndiName";
protected static final String REPO_FACTORY_JNDI_NAME = "factoryJndiName";
protected static final String RETRY_LIMIT = "retryLimit";
-
+
/**
* default constructor
*/
@@ -98,7 +95,7 @@
/**
* {@inheritDoc}
- *
+ *
* @see org.jboss.dna.graph.connectors.RepositorySource#getCapabilities()
*/
public RepositorySourceCapabilities getCapabilities() {
@@ -107,7 +104,7 @@
/**
* {@inheritDoc}
- *
+ *
* @see org.jboss.dna.graph.connectors.RepositorySource#getConnection()
*/
public RepositoryConnection getConnection() throws RepositorySourceException {
@@ -117,7 +114,7 @@
/**
* {@inheritDoc}
- *
+ *
* @see org.jboss.dna.graph.connectors.RepositorySource#getName()
*/
public String getName() {
@@ -132,10 +129,10 @@
public void setName( String name ) {
this.name = name;
}
-
+
/**
* {@inheritDoc}
- *
+ *
* @see org.jboss.dna.graph.connectors.RepositorySource#getRetryLimit()
*/
public int getRetryLimit() {
@@ -144,7 +141,7 @@
/**
* {@inheritDoc}
- *
+ *
* @see org.jboss.dna.graph.connectors.RepositorySource#initialize(org.jboss.dna.graph.connectors.RepositoryContext)
*/
public void initialize( RepositoryContext context ) throws RepositorySourceException {
@@ -153,7 +150,7 @@
/**
* {@inheritDoc}
- *
+ *
* @see org.jboss.dna.graph.connectors.RepositorySource#setRetryLimit(int)
*/
public void setRetryLimit( int limit ) {
@@ -176,7 +173,7 @@
* content.
*/
public synchronized void setSupportsUpdates( boolean supportsUpdates ) {
- capabilities.setSupportsUpdates (supportsUpdates);
+ capabilities.setSupportsUpdates(supportsUpdates);
}
/**
@@ -194,7 +191,7 @@
public synchronized void setDefaultCachePolicy( CachePolicy defaultCachePolicy ) {
this.defaultCachePolicy = defaultCachePolicy;
}
-
+
/**
* {@inheritDoc}
*/
@@ -212,13 +209,13 @@
}
return false;
}
-
+
/**
* {@inheritDoc}
- *
+ *
* @see javax.naming.Referenceable#getReference()
*/
- public Reference getReference() throws NamingException {
+ public Reference getReference() {
String className = getClass().getName();
String factoryClassName = this.getClass().getName();
Reference ref = new Reference(className, factoryClassName, null);
@@ -245,8 +242,9 @@
/**
* {@inheritDoc}
- *
- * @see javax.naming.spi.ObjectFactory#getObjectInstance(java.lang.Object, javax.naming.Name, javax.naming.Context, java.util.Hashtable)
+ *
+ * @see javax.naming.spi.ObjectFactory#getObjectInstance(java.lang.Object, javax.naming.Name, javax.naming.Context,
+ * java.util.Hashtable)
*/
public Object getObjectInstance( Object obj,
Name name,
17 years
DNA SVN: r676 - trunk.
by dna-commits@lists.jboss.org
Author: lisbor
Date: 2008-12-09 05:19:19 -0500 (Tue, 09 Dec 2008)
New Revision: 676
Modified:
trunk/pom.xml
Log:
DNA-37 Federate schema information from relational sources
https://jira.jboss.org/jira/browse/DNA-37
Restoring link to JDBC modlules
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2008-12-09 10:16:14 UTC (rev 675)
+++ trunk/pom.xml 2008-12-09 10:19:19 UTC (rev 676)
@@ -131,8 +131,8 @@
<module>extensions/dna-connector-svn</module>
<module>extensions/dna-connector-store-jpa</module>
<module>extensions/dna-mimetype-detector-aperture</module>
- <!--module>extensions/dna-common-jdbc</module>
- <module>extensions/dna-connector-jdbc-metadata</module-->
+ <module>extensions/dna-common-jdbc</module>
+ <module>extensions/dna-connector-jdbc-metadata</module>
<module>dna-integration-tests</module>
<module>docs/examples/gettingstarted</module>
</modules>
17 years
DNA SVN: r675 - trunk/extensions/dna-connector-jdbc-metadata.
by dna-commits@lists.jboss.org
Author: lisbor
Date: 2008-12-09 05:16:14 -0500 (Tue, 09 Dec 2008)
New Revision: 675
Modified:
trunk/extensions/dna-connector-jdbc-metadata/.classpath
Log:
DNA-37 Federate schema information from relational sources
https://jira.jboss.org/jira/browse/DNA-37
Modified: trunk/extensions/dna-connector-jdbc-metadata/.classpath
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/.classpath 2008-12-09 10:14:26 UTC (rev 674)
+++ trunk/extensions/dna-connector-jdbc-metadata/.classpath 2008-12-09 10:16:14 UTC (rev 675)
@@ -4,7 +4,7 @@
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
17 years