Author: bcarothers
Date: 2009-12-04 21:53:36 -0500 (Fri, 04 Dec 2009)
New Revision: 1407
Added:
trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/SimpleJpaRepositoryTckTest.java
trunk/dna-integration-tests/src/test/resources/tck/simple-jpa/
trunk/dna-integration-tests/src/test/resources/tck/simple-jpa/configRepository.xml
trunk/dna-integration-tests/src/test/resources/tck/simple-jpa/repositoryOverlay.properties
Removed:
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/ReferenceEntity.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/ReferenceId.java
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/AbstractMapWorkspace.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/LoggingRequestProcessor.java
trunk/dna-integration-tests/src/test/resources/log4j.properties
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaConnection.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaRepository.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleRequestProcessor.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/SubgraphQuery.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/package-info.java
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/basic/BasicCreateWorkspacesTest.java
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/basic/BasicNoCreateWorkspaceTest.java
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/NodeEntityTest.java
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleCreateWorkspacesTest.java
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaConnectorReadableTest.java
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaConnectorWritableTest.java
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaSourceTest.java
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleNoCreateWorkspaceTest.java
Log:
DNA-546 JCR Workspace and Session Imports Can Fail on JPA Connector
Applied patch that cleans up the simple JPA model by fixing the last broken test, removing
semi-implemented referential integrity checks, adding copyright headers to a number of
files, and adding a full TCK integration test.
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/AbstractMapWorkspace.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/AbstractMapWorkspace.java 2009-12-04
20:38:39 UTC (rev 1406)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/AbstractMapWorkspace.java 2009-12-05
02:53:36 UTC (rev 1407)
@@ -446,7 +446,48 @@
MapNode newParent,
Name desiredName,
boolean recursive ) {
- return copyNode(context, original, newWorkspace, newParent, desiredName, true,
new HashMap<UUID, UUID>());
+
+ Map<UUID, UUID> oldToNewUuids = new HashMap<UUID, UUID>();
+ MapNode copyRoot = copyNode(context, original, newWorkspace, newParent,
desiredName, true, oldToNewUuids);
+
+ // Now, adjust any references in the new subgraph to objects in the original
subgraph
+ // (because they were internal references, and need to be internal to the new
subgraph)
+ PropertyFactory propertyFactory = context.getPropertyFactory();
+ UuidFactory uuidFactory = context.getValueFactories().getUuidFactory();
+ ValueFactory<Reference> referenceFactory =
context.getValueFactories().getReferenceFactory();
+ for (Map.Entry<UUID, UUID> oldToNew : oldToNewUuids.entrySet()) {
+ MapNode oldNode = this.getNode(oldToNew.getKey());
+ MapNode newNode = newWorkspace.getNode(oldToNew.getValue());
+ assert oldNode != null;
+ assert newNode != null;
+ // Iterate over the properties of the new ...
+ for (Map.Entry<Name, Property> entry :
newNode.getProperties().entrySet()) {
+ Property property = entry.getValue();
+ // Now see if any of the property values are references ...
+ List<Object> newValues = new ArrayList<Object>();
+ boolean foundReference = false;
+ for (Iterator<?> iter = property.getValues(); iter.hasNext();) {
+ Object value = iter.next();
+ PropertyType type = PropertyType.discoverType(value);
+ if (type == PropertyType.REFERENCE) {
+ UUID oldReferencedUuid = uuidFactory.create(value);
+ UUID newReferencedUuid = oldToNewUuids.get(oldReferencedUuid);
+ if (newReferencedUuid != null) {
+ newValues.add(referenceFactory.create(newReferencedUuid));
+ foundReference = true;
+ }
+ } else {
+ newValues.add(value);
+ }
+ }
+ // If we found at least one reference, we have to build a new Property
object ...
+ if (foundReference) {
+ Property newProperty = propertyFactory.create(property.getName(),
newValues);
+ entry.setValue(newProperty);
+ }
+ }
+ }
+ return copyRoot;
}
/**
@@ -494,47 +535,6 @@
}
}
- if (!reuseUuids) {
- assert oldToNewUuids != null;
- // Now, adjust any references in the new subgraph to objects in the original
subgraph
- // (because they were internal references, and need to be internal to the new
subgraph)
- PropertyFactory propertyFactory = context.getPropertyFactory();
- UuidFactory uuidFactory = context.getValueFactories().getUuidFactory();
- ValueFactory<Reference> referenceFactory =
context.getValueFactories().getReferenceFactory();
- for (Map.Entry<UUID, UUID> oldToNew : oldToNewUuids.entrySet()) {
- MapNode oldNode = this.getNode(oldToNew.getKey());
- MapNode newNode = newWorkspace.getNode(oldToNew.getValue());
- assert oldNode != null;
- assert newNode != null;
- // Iterate over the properties of the new ...
- for (Map.Entry<Name, Property> entry :
newNode.getProperties().entrySet()) {
- Property property = entry.getValue();
- // Now see if any of the property values are references ...
- List<Object> newValues = new ArrayList<Object>();
- boolean foundReference = false;
- for (Iterator<?> iter = property.getValues(); iter.hasNext();)
{
- Object value = iter.next();
- PropertyType type = PropertyType.discoverType(value);
- if (type == PropertyType.REFERENCE) {
- UUID oldReferencedUuid = uuidFactory.create(value);
- UUID newReferencedUuid =
oldToNewUuids.get(oldReferencedUuid);
- if (newReferencedUuid != null) {
-
newValues.add(referenceFactory.create(newReferencedUuid));
- foundReference = true;
- }
- } else {
- newValues.add(value);
- }
- }
- // If we found at least one reference, we have to build a new
Property object ...
- if (foundReference) {
- Property newProperty = propertyFactory.create(property.getName(),
newValues);
- entry.setValue(newProperty);
- }
- }
- }
- }
-
return copy;
}
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/LoggingRequestProcessor.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/LoggingRequestProcessor.java 2009-12-04
20:38:39 UTC (rev 1406)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/LoggingRequestProcessor.java 2009-12-05
02:53:36 UTC (rev 1407)
@@ -92,7 +92,7 @@
public void process( VerifyWorkspaceRequest request ) {
logger.log(level, GraphI18n.executingRequest, request);
delegate.process(request);
- logger.log(level, GraphI18n.executedRequest, request);
+ // logger.log(level, GraphI18n.executedRequest, request);
}
/**
@@ -452,7 +452,7 @@
public void close() {
logger.log(level, GraphI18n.closingRequestProcessor);
delegate.close();
- logger.log(level, GraphI18n.closingRequestProcessor);
+ logger.log(level, GraphI18n.closedRequestProcessor);
}
}
Added:
trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/SimpleJpaRepositoryTckTest.java
===================================================================
---
trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/SimpleJpaRepositoryTckTest.java
(rev 0)
+++
trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/SimpleJpaRepositoryTckTest.java 2009-12-05
02:53:36 UTC (rev 1407)
@@ -0,0 +1,32 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you 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.
+ *
+ * JBoss DNA 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.test.integration;
+
+import junit.framework.Test;
+
+public class SimpleJpaRepositoryTckTest {
+ public static Test suite() {
+ return
AbstractRepositoryTckTest.readWriteRepositorySuite("simple-jpa");
+ }
+}
Property changes on:
trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/SimpleJpaRepositoryTckTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/dna-integration-tests/src/test/resources/log4j.properties
===================================================================
--- trunk/dna-integration-tests/src/test/resources/log4j.properties 2009-12-04 20:38:39
UTC (rev 1406)
+++ trunk/dna-integration-tests/src/test/resources/log4j.properties 2009-12-05 02:53:36
UTC (rev 1407)
@@ -4,17 +4,37 @@
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %m%n
+# Direct log messages to a file
+log4j.appender.file=org.apache.log4j.RollingFileAppender
+log4j.appender.file.File=/tck.log
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %m%n
+log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} [%t] %m%n
+#log4j.appender.file.layout.ConversionPattern=%5p [%c{1}] %m%n
+
# Root logger option
-log4j.rootLogger=INFO, stdout
+log4j.rootLogger=WARN, file
# Set up the default logging to be INFO level, then override specific units
-log4j.logger.org.jboss.dna=INFO
+log4j.logger.org.jboss.dna=WARN
log4j.logger.org.junit=DEBUG
#
log4j.logger.org.jboss.dna.tests.integration.jackrabbit.JackrabbitMySqlStressTest=DEBUG
-log4j.logger.org.hibernate=WARN, stdout
+log4j.logger.org.hibernate=WARN
+log4j.logger.org.hibernate.pretty.Printer=WARN
+log4j.logger.org.hibernate.engine.Collections=WARN
+log4j.logger.org.hibernate.cfg=WARN
+log4j.logger.org.hibernate.tool.hbm2ddl.SchemaExport=WARN
+log4j.logger.org.hibernate.persister.entity.AbstractEntityPersister=WARN
+log4j.logger.org.hibernate.event.def.AbstractFlushingEventListener=WARN
+log4j.logger.org.hibernate.engine.TwoPhaseLoad=WARN
+log4j.logger.org.hibernate.jdbc.AbstractBatcher=WARN
+log4j.logger.org.hibernate.hql.ast=WARN
+log4j.logger.org.hibernate.engine.loading.CollectionLoadContext=WARN
# Jackrabbit logging
log4j.logger.org.apache.jackrabbit=WARN, stdout
log4j.logger.org.apache.derby=INFO, stdout
+
+log4j.logger.org.jboss.dna.connector.store=DEBUG
Added: trunk/dna-integration-tests/src/test/resources/tck/simple-jpa/configRepository.xml
===================================================================
--- trunk/dna-integration-tests/src/test/resources/tck/simple-jpa/configRepository.xml
(rev 0)
+++
trunk/dna-integration-tests/src/test/resources/tck/simple-jpa/configRepository.xml 2009-12-05
02:53:36 UTC (rev 1407)
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ JBoss DNA (
http://www.jboss.org/dna)
+ ~
+ ~ See the COPYRIGHT.txt file distributed with this work for information
+ ~ regarding copyright ownership. Some portions may be licensed
+ ~ to Red Hat, Inc. under one or more contributor license agreements.
+ ~ See the AUTHORS.txt file in the distribution for a full listing of
+ ~ individual contributors.
+ ~
+ ~ JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ ~ is licensed to you 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.
+ ~
+ ~ JBoss DNA 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 distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ -->
+<configuration
xmlns:dna="http://www.jboss.org/dna/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0">
+ <!--
+ Define the sources for the content. These sources are directly accessible using the
DNA-specific Graph API.
+ In fact, this is how the DNA JCR implementation works. You can think of these as
being similar to
+ JDBC DataSource objects, except that they expose graph content via the Graph API
instead of records via SQL or JDBC.
+ -->
+ <dna:sources jcr:primaryType="nt:unstructured">
+ <!--
+ The 'JCR' repository is a JBoss Cache source with a single default
workspace (though others could be created, too).
+ -->
+ <dna:source jcr:name="Store"
dna:classname="org.jboss.dna.connector.store.jpa.JpaSource"
+ dna:dialect="org.hibernate.dialect.HSQLDialect"
+ dna:model="Simple"
+ dna:driverClassName="org.hsqldb.jdbcDriver"
+ dna:username="sa"
+ dna:password=""
+ dna:url="jdbc:hsqldb:mem:."
+ dna:predefinedWorkspaceNames="otherWorkspace"
+ dna:showSql="false"
+ dna:autoGenerateSchema="create"
+ dna:maximumConnectionsInPool="5"
+ dna:defaultWorkspaceName="default"/>
+ </dna:sources>
+ <!--
+ Define the mime type detectors. This is an optional section. By default, each engine
will use the
+ MIME type detector that uses filename extensions. So we wouldn't need to define
the same detector again,
+ but this is how you'd define another extension.
+ -->
+ <dna:mimeTypeDetectors>
+ <dna:mimeTypeDetector jcr:name="Detector">
+ <dna:description>Standard extension-based MIME type
detector</dna:description>
+ <!--
+ Specify the implementation class (required), as a child element or attribute
on parent element.
+ -->
+
<dna:classname>org.jboss.dna.graph.mimetype.ExtensionBasedMimeTypeDetector</dna:classname>
+ <!--
+ Specify the classpath (optional) as an ordered list of 'names', where
each name is significant to
+ the classpath factory. For example, a name could be an OSGI identifier or a
Maven coordinate,
+ depending upon the classpath factory being used. If there is only one
'name' in the classpath,
+ it may be specified as an attribute on the 'mimeTypeDetector'
element. If there is more than one
+ 'name', then they must be specified as child 'classpath'
elements. Blank or empty values are ignored.
+ -->
+ <dna:classpath></dna:classpath>
+ </dna:mimeTypeDetector>
+ </dna:mimeTypeDetectors>
+ <!--
+ Define the JCR repositories
+ -->
+ <dna:repositories>
+ <!--
+ Define a JCR repository that accesses the 'JCR' source directly.
+ This of course is optional, since we could access the same content through
'JCR'.
+ -->
+ <dna:repository jcr:name="Test Repository Source">
+ <!-- Specify the source that should be used for the repository -->
+ <dna:source>Store</dna:source>
+ <!-- Define the options for the JCR repository, using camelcase version of
JcrRepository.Option names
+-->
+ <dna:options jcr:primaryType="dna:options">
+ <jaasLoginConfigName jcr:primaryType="dna:option"
dna:value="dna-jcr"/>
+ <projectNodeTypes jcr:primaryType="dna:option"
dna:value="false"/>
+ </dna:options>
+ <!-- Define any namespaces for this repository, other than those already
defined by JCR or DNA
+-->
+ <namespaces jcr:primaryType="dna:namespaces">
+ <dnatest jcr:primaryType="dna:namespace"
dna:uri="http://jboss.org/dna/test/1.0"/>
+ </namespaces>
+ </dna:repository>
+ </dna:repositories>
+</configuration>
Property changes on:
trunk/dna-integration-tests/src/test/resources/tck/simple-jpa/configRepository.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Added:
trunk/dna-integration-tests/src/test/resources/tck/simple-jpa/repositoryOverlay.properties
===================================================================
---
trunk/dna-integration-tests/src/test/resources/tck/simple-jpa/repositoryOverlay.properties
(rev 0)
+++
trunk/dna-integration-tests/src/test/resources/tck/simple-jpa/repositoryOverlay.properties 2009-12-05
02:53:36 UTC (rev 1407)
@@ -0,0 +1 @@
+# Placeholder for any overlaid properties for this repo configuration
Deleted:
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/ReferenceEntity.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/ReferenceEntity.java 2009-12-04
20:38:39 UTC (rev 1406)
+++
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/ReferenceEntity.java 2009-12-05
02:53:36 UTC (rev 1407)
@@ -1,211 +0,0 @@
-/*
- * JBoss DNA (
http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you 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.
- *
- * JBoss DNA 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.model.simple;
-
-import java.util.Collection;
-import java.util.List;
-import javax.persistence.Entity;
-import javax.persistence.EntityManager;
-import javax.persistence.Id;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.NoResultException;
-import javax.persistence.Query;
-import javax.persistence.Table;
-import org.hibernate.annotations.Index;
-
-/**
- * A record of a reference from one node to another.
- */
-@Entity
-@Table( name = "DNA_SIMPLE_REFERENCES" )
-(a)org.hibernate.annotations.Table( appliesTo = "DNA_SIMPLE_REFERENCES", indexes
= {
- @Index( name = "REFINDEX_INX", columnNames = {"WORKSPACE_ID",
"FROM_UUID", "TO_UUID"} ),
- @Index( name = "REFTOUUID_INX", columnNames = {"WORKSPACE_ID",
"TO_UUID"} )} )
-@NamedQueries( {
- @NamedQuery( name = "ReferenceEntity.removeReferencesFrom", query =
"delete ReferenceEntity where id.workspaceId = :workspaceId and id.fromUuidString =
:fromUuid" ),
- @NamedQuery( name = "ReferenceEntity.removeNonEnforcedReferences", query =
"delete ReferenceEntity as ref where ref.id.workspaceId = :workspaceId and
ref.id.fromUuidString not in ( select props.id.uuidString from PropertiesEntity props
where props.referentialIntegrityEnforced = true and props.id.workspaceId = :workspaceId
)" ),
- @NamedQuery( name = "ReferenceEntity.countUnresolveReferences", query =
"select count(*) from ReferenceEntity as ref where ref.id.workspaceId = :workspaceId
and ref.id.toUuidString not in ( select props.id.uuidString from PropertiesEntity props
where props.referentialIntegrityEnforced = true and props.id.workspaceId = :workspaceId
)" ),
- @NamedQuery( name = "ReferenceEntity.getUnresolveReferences", query =
"select ref from ReferenceEntity as ref where ref.id.workspaceId = :workspaceId and
ref.id.toUuidString not in ( select props.id.uuidString from PropertiesEntity props where
props.referentialIntegrityEnforced = true and props.id.workspaceId = :workspaceId )"
),
- @NamedQuery( name = "ReferenceEntity.findInWorkspace", query = "select
ref from ReferenceEntity as ref where ref.id.workspaceId = :workspaceId" ),
- @NamedQuery( name = "ReferenceEntity.getInwardReferencesForList", query =
"select ref from ReferenceEntity as ref where ref.id.workspaceId = :workspaceId and
ref.id.toUuidString in (:toUuidList)" )} )
-public class ReferenceEntity {
-
- @Id
- private ReferenceId id;
-
- /**
- *
- */
- public ReferenceEntity() {
- }
-
- /**
- * @param id the id
- */
- public ReferenceEntity( ReferenceId id ) {
- this.id = id;
- }
-
- /**
- * @return id
- */
- public ReferenceId getId() {
- return id;
- }
-
- /**
- * @param id Sets id to the specified value.
- */
- public void setId( ReferenceId id ) {
- this.id = id;
- }
-
- /**
- * {@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 ReferenceEntity) {
- ReferenceEntity that = (ReferenceEntity)obj;
- if (this.getId().equals(that.getId())) return true;
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return this.id.toString();
- }
-
- /**
- * Delete all references that start from the node with the supplied UUID.
- *
- * @param workspaceId the ID of the workspace; may not be null
- * @param uuid the UUID of the node from which the references start
- * @param manager the manager; may not be null
- * @return the number of deleted references
- */
- public static int deleteReferencesFrom( Long workspaceId,
- String uuid,
- EntityManager manager ) {
- assert manager != null;
- Query delete =
manager.createNamedQuery("ReferenceEntity.removeReferencesFrom");
- delete.setParameter("fromUuid", uuid);
- delete.setParameter("workspaceId", workspaceId);
- int result = delete.executeUpdate();
- manager.flush();
- return result;
- }
-
- /**
- * Delete all references (in all workspaces) that start from nodes that do not
require enforced referential integrity.
- *
- * @param workspaceId the ID of the workspace; may not be null
- * @param manager the manager; may not be null
- * @return the number of deleted references
- */
- public static int deleteUnenforcedReferences( Long workspaceId,
- EntityManager manager ) {
- assert manager != null;
- Query delete =
manager.createNamedQuery("ReferenceEntity.removeNonEnforcedReferences");
- delete.setParameter("workspaceId", workspaceId);
- int result = delete.executeUpdate();
- manager.flush();
- return result;
- }
-
- /**
- * Delete all references that start from nodes that do not support enforced
referential integrity.
- *
- * @param workspaceId the ID of the workspace; may not be null
- * @param manager the manager; may not be null
- * @return the number of deleted references
- */
- public static int countAllReferencesResolved( Long workspaceId,
- EntityManager manager ) {
- assert manager != null;
- Query query =
manager.createNamedQuery("ReferenceEntity.getUnresolveReferences");
- query.setParameter("workspaceId", workspaceId);
- try {
- return (Integer)query.getSingleResult();
- } catch (NoResultException e) {
- return 0;
- }
- }
-
- /**
- * Delete all references that start from nodes that do not support enforced
referential integrity.
- *
- * @param workspaceId the ID of the workspace; may not be null
- * @param manager the manager; may not be null
- * @return the number of deleted references
- */
- @SuppressWarnings( "unchecked" )
- public static List<ReferenceEntity> verifyAllReferencesResolved( Long
workspaceId,
- EntityManager
manager ) {
- assert manager != null;
- Query query =
manager.createNamedQuery("ReferenceEntity.getUnresolveReferences");
- query.setParameter("workspaceId", workspaceId);
- return query.getResultList();
- }
-
- /**
- * Returns a list of all references to UUIDs in the given list within the given
workspace
- *
- * @param workspaceId the ID of the workspace; may not be null
- * @param uuids the UUIDs (as strings) of the nodes to check; may not be null
- * @param manager the manager; may not be null
- * @return the number of deleted references
- */
- @SuppressWarnings( "unchecked" )
- public static List<ReferenceEntity> getReferencesToUuids( Long workspaceId,
- Collection<String>
uuids,
- EntityManager manager ) {
- assert manager != null;
-
- Query query =
manager.createNamedQuery("ReferenceEntity.getInwardReferencesForList");
- query.setParameter("workspaceId", workspaceId);
- query.setParameter("toUuidList", uuids);
- return query.getResultList();
- }
-}
Deleted:
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/ReferenceId.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/ReferenceId.java 2009-12-04
20:38:39 UTC (rev 1406)
+++
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/ReferenceId.java 2009-12-05
02:53:36 UTC (rev 1407)
@@ -1,137 +0,0 @@
-/*
- * JBoss DNA (
http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you 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.
- *
- * JBoss DNA 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.model.simple;
-
-import java.io.Serializable;
-import javax.persistence.Column;
-import javax.persistence.Embeddable;
-import net.jcip.annotations.Immutable;
-import org.jboss.dna.common.util.HashCode;
-
-/**
- * An identifier for a reference, comprised of a workspace ID, a single UUID (in string
form) of the node containing the
- * reference, and a single UUID (in string form) of the node being referenced.
- */
-@Embeddable
-@Immutable
-(a)org.hibernate.annotations.Immutable
-public class ReferenceId implements Serializable {
-
- /**
- * Version {@value}
- */
- private static final long serialVersionUID = 1L;
-
- @Column( name = "WORKSPACE_ID", nullable = false )
- private Long workspaceId;
-
- @Column( name = "FROM_UUID", nullable = false, updatable = false, length =
36 )
- private String fromUuidString;
-
- @Column( name = "TO_UUID", nullable = false, updatable = false, length = 36
)
- private String toUuidString;
-
- public ReferenceId() {
- }
-
- public ReferenceId( Long workspaceId,
- String fromUuid,
- String toUuid ) {
- this.workspaceId = workspaceId;
- this.fromUuidString = fromUuid;
- this.toUuidString = toUuid;
- }
-
- /**
- * @return fromUuidString
- */
- public String getFromUuidString() {
- return fromUuidString;
- }
-
- /**
- * @return toUuidString
- */
- public String getToUuidString() {
- return toUuidString;
- }
-
- /**
- * @return workspaceId
- */
- public Long getWorkspaceId() {
- return workspaceId;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- return HashCode.compute(fromUuidString, toUuidString);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals( Object obj ) {
- if (obj == this) return true;
- if (obj instanceof ReferenceId) {
- ReferenceId that = (ReferenceId)obj;
- if (this.workspaceId == null) {
- if (that.workspaceId != null) return false;
- } else {
- if (!this.workspaceId.equals(that.workspaceId)) return false;
- }
- if (this.fromUuidString == null) {
- if (that.fromUuidString != null) return false;
- } else {
- if (!this.fromUuidString.equals(that.fromUuidString)) return false;
- }
- if (this.toUuidString == null) {
- if (that.toUuidString != null) return false;
- } else {
- if (!this.toUuidString.equals(that.toUuidString)) return false;
- }
- return true;
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "Reference from " + fromUuidString + " to " +
toUuidString + " in workspace " + workspaceId;
- }
-
-}
Modified:
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaConnection.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaConnection.java 2009-12-04
20:38:39 UTC (rev 1406)
+++
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaConnection.java 2009-12-05
02:53:36 UTC (rev 1407)
@@ -56,8 +56,7 @@
this.repository = new SimpleJpaRepository(source.getName(), source.getRootUuid(),
source.getDefaultWorkspaceName(),
source.getPredefinedWorkspaceNames(),
entityManager,
source.getRepositoryContext().getExecutionContext(), source.isCompressData(),
- source.isCreatingWorkspacesAllowed(),
source.isReferentialIntegrityEnforced(),
- source.getLargeValueSizeInBytes());
+ source.isCreatingWorkspacesAllowed(),
source.getLargeValueSizeInBytes());
}
public boolean ping( long time,
@@ -114,7 +113,7 @@
if (logger.isTraceEnabled()) {
assert sw != null;
sw.stop();
- logger.trace("MapRepositoryConnection.execute(...) took " +
sw.getTotalDuration());
+ logger.trace(this.getClass().getSimpleName() + ".execute(...) took
" + sw.getTotalDuration());
}
}
}
Modified:
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaRepository.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaRepository.java 2009-12-04
20:38:39 UTC (rev 1406)
+++
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaRepository.java 2009-12-05
02:53:36 UTC (rev 1407)
@@ -36,6 +36,7 @@
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.Map;
@@ -71,7 +72,10 @@
import org.jboss.dna.graph.property.Property;
import org.jboss.dna.graph.property.PropertyFactory;
import org.jboss.dna.graph.property.PropertyType;
+import org.jboss.dna.graph.property.Reference;
+import org.jboss.dna.graph.property.UuidFactory;
import org.jboss.dna.graph.property.ValueFactories;
+import org.jboss.dna.graph.property.ValueFactory;
import org.jboss.dna.graph.property.Path.Segment;
import org.jboss.dna.graph.request.CompositeRequest;
import org.jboss.dna.graph.request.LockBranchRequest.LockScope;
@@ -101,8 +105,6 @@
protected final boolean creatingWorkspacesAllowed;
protected final long minimumSizeOfLargeValuesInBytes;
- // private final boolean referentialIntegrityEnforced;
-
public SimpleJpaRepository( String sourceName,
UUID rootNodeUuid,
String defaultWorkspaceName,
@@ -111,7 +113,6 @@
ExecutionContext context,
boolean compressData,
boolean creatingWorkspacesAllowed,
- boolean referentialIntegrityEnforced,
long minimumSizeOfLargeValuesInBytes ) {
super(sourceName, rootNodeUuid, defaultWorkspaceName);
@@ -122,7 +123,6 @@
this.predefinedWorkspaceNames = Arrays.asList(predefinedWorkspaceNames);
this.compressData = compressData;
this.creatingWorkspacesAllowed = creatingWorkspacesAllowed;
- // this.referentialIntegrityEnforced = referentialIntegrityEnforced;
this.minimumSizeOfLargeValuesInBytes = minimumSizeOfLargeValuesInBytes;
this.entityManager = entityManager;
@@ -137,7 +137,6 @@
ExecutionContext context,
boolean compressData,
boolean creatingWorkspacesAllowed,
- boolean referentialIntegrityEnforced,
long minimumSizeOfLargeValuesInBytes ) {
super(sourceName, rootNodeUuid);
@@ -148,7 +147,6 @@
this.predefinedWorkspaceNames = Collections.emptyList();
this.compressData = compressData;
this.creatingWorkspacesAllowed = creatingWorkspacesAllowed;
- // this.referentialIntegrityEnforced = referentialIntegrityEnforced;
this.minimumSizeOfLargeValuesInBytes = minimumSizeOfLargeValuesInBytes;
this.entityManager = entityManager;
@@ -259,6 +257,76 @@
initialize();
}
+ /**
+ * This should copy the subgraph given by the original node and place the new
copy under the supplied new parent. Note
+ * that internal references between nodes within the original subgraph must be
reflected as internal nodes within the new
+ * subgraph.
+ *
+ * @param context the context; may not be null
+ * @param original the node to be copied; may not be null
+ * @param newWorkspace the workspace containing the new parent node; may not be
null
+ * @param newParent the parent where the copy is to be placed; may not be null
+ * @param desiredName the desired name for the node; if null, the name will be
obtained from the original node
+ * @param recursive true if the copy should be recursive
+ * @return the new node, which is the top of the new subgraph
+ */
+ @Override
+ public MapNode copyNode( ExecutionContext context,
+ MapNode original,
+ MapWorkspace newWorkspace,
+ MapNode newParent,
+ Name desiredName,
+ boolean recursive ) {
+
+ Map<UUID, UUID> oldToNewUuids = new HashMap<UUID, UUID>();
+ MapNode copyRoot = copyNode(context, original, newWorkspace, newParent,
desiredName, true, oldToNewUuids);
+
+ // Now, adjust any references in the new subgraph to objects in the original
subgraph
+ // (because they were internal references, and need to be internal to the new
subgraph)
+ PropertyFactory propertyFactory = context.getPropertyFactory();
+ UuidFactory uuidFactory = context.getValueFactories().getUuidFactory();
+ ValueFactory<Reference> referenceFactory =
context.getValueFactories().getReferenceFactory();
+ boolean refChanged = false;
+ for (Map.Entry<UUID, UUID> oldToNew : oldToNewUuids.entrySet()) {
+ MapNode oldNode = this.getNode(oldToNew.getKey());
+ MapNode newNode = newWorkspace.getNode(oldToNew.getValue());
+ assert oldNode != null;
+ assert newNode != null;
+ // Iterate over the properties of the new ...
+ for (Map.Entry<Name, Property> entry :
newNode.getProperties().entrySet()) {
+ Property property = entry.getValue();
+ // Now see if any of the property values are references ...
+ List<Object> newValues = new ArrayList<Object>();
+ boolean foundReference = false;
+ for (Iterator<?> iter = property.getValues(); iter.hasNext();)
{
+ Object value = iter.next();
+ PropertyType type = PropertyType.discoverType(value);
+ if (type == PropertyType.REFERENCE) {
+ UUID oldReferencedUuid = uuidFactory.create(value);
+ UUID newReferencedUuid =
oldToNewUuids.get(oldReferencedUuid);
+ if (newReferencedUuid != null) {
+
newValues.add(referenceFactory.create(newReferencedUuid));
+ foundReference = true;
+ refChanged = true;
+ }
+ } else {
+ newValues.add(value);
+ }
+ }
+ // If we found at least one reference, we have to build a new
Property object ...
+ if (foundReference) {
+ Property newProperty = propertyFactory.create(property.getName(),
newValues);
+ entry.setValue(newProperty);
+ }
+ }
+
+ if (refChanged) {
+ ((JpaNode)newNode).serializeProperties();
+ }
+ }
+ return copyRoot;
+ }
+
/*
* (non-Javadoc)
* @see
org.jboss.dna.graph.connector.map.AbstractMapWorkspace#correctSameNameSiblingIndexes(org.jboss.dna.graph.ExecutionContext,
org.jboss.dna.graph.connector.map.MapNode, org.jboss.dna.graph.property.Name)
@@ -303,6 +371,7 @@
NodeEntity nodeEntity = ((JpaNode)node).entity;
nodeEntity.setWorkspaceId(this.workspaceId);
+ nodeEntity.setReferentialIntegrityEnforced(false);
entityManager.persist(nodeEntity);
}
@@ -320,7 +389,7 @@
*/
@Override
protected void removeUuidReference( MapNode node ) {
- SubgraphQuery branch = SubgraphQuery.create(context, entityManager,
workspaceId, node.getUuid(), null, 0);
+ SubgraphQuery branch = SubgraphQuery.create(entityManager, workspaceId,
node.getUuid(), 0);
branch.deleteSubgraph(true);
branch.close();
}
@@ -398,12 +467,9 @@
assert subgraphRootUuid != null;
}
- Path subgraphRootPath = null; // Don't need the path for this
- SubgraphQuery subgraph = SubgraphQuery.create(context,
- entityManager,
+ SubgraphQuery subgraph = SubgraphQuery.create(entityManager,
workspaceId,
subgraphRootUuid,
- subgraphRootPath,
maximumDepth);
List<NodeEntity> entities = subgraph.getNodes(true, true);
Modified:
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleRequestProcessor.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleRequestProcessor.java 2009-12-04
20:38:39 UTC (rev 1406)
+++
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleRequestProcessor.java 2009-12-05
02:53:36 UTC (rev 1407)
@@ -148,4 +148,5 @@
super.process(request);
}
+
}
Modified:
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/SubgraphQuery.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/SubgraphQuery.java 2009-12-04
20:38:39 UTC (rev 1406)
+++
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/SubgraphQuery.java 2009-12-05
02:53:36 UTC (rev 1407)
@@ -27,10 +27,7 @@
import java.util.List;
import java.util.UUID;
import javax.persistence.EntityManager;
-import javax.persistence.NoResultException;
import javax.persistence.Query;
-import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.property.Path;
/**
* Represents a temporary working area for a query that efficiently retrieves the nodes
in a subgraph. This class uses the
@@ -47,19 +44,15 @@
/**
* Create a query that returns a subgraph at and below the node with the supplied
path and the supplied UUID.
*
- * @param context the execution context; may not be null
* @param entities the entity manager; may not be null
* @param workspaceId the ID of the workspace; may not be null
* @param subgraphRootUuid the UUID (in string form) of the root node in the
subgraph
- * @param subgraphRootPath the path of the root node in the subgraph
* @param maxDepth the maximum depth of the subgraph, or 0 if there is no maximum
depth
* @return the object representing the subgraph
*/
- public static SubgraphQuery create( ExecutionContext context,
- EntityManager entities,
+ public static SubgraphQuery create( EntityManager entities,
Long workspaceId,
UUID subgraphRootUuid,
- Path subgraphRootPath,
int maxDepth ) {
assert entities != null;
assert subgraphRootUuid != null;
@@ -106,33 +99,26 @@
throw t;
}
- return new SubgraphQuery(context, entities, workspaceId, query, subgraphRootPath,
maxDepth);
+ return new SubgraphQuery(entities, workspaceId, query, maxDepth);
}
- // private final ExecutionContext context;
private final EntityManager manager;
private final Long workspaceId;
private SubgraphQueryEntity query;
private final int maxDepth;
- private final Path subgraphRootPath;
- protected SubgraphQuery( ExecutionContext context,
- EntityManager manager,
+ protected SubgraphQuery( EntityManager manager,
Long workspaceId,
SubgraphQueryEntity query,
- Path subgraphRootPath,
int maxDepth ) {
assert manager != null;
assert query != null;
- assert context != null;
- // assert subgraphRootPath != null;
assert workspaceId != null;
- // this.context = context;
+
this.manager = manager;
this.workspaceId = workspaceId;
this.query = query;
this.maxDepth = maxDepth;
- this.subgraphRootPath = subgraphRootPath;
}
/**
@@ -150,35 +136,6 @@
}
/**
- * @return subgraphRootPath
- */
- public Path getSubgraphRootPath() {
- return subgraphRootPath;
- }
-
- /**
- * @return query
- */
- public SubgraphQueryEntity getSubgraphQueryEntity() {
- if (query == null) throw new IllegalStateException();
- return query;
- }
-
- public int getNodeCount( boolean includeRoot ) {
- if (query == null) throw new IllegalStateException();
- // Now query for all the nodes and put into a list ...
- Query search =
manager.createNamedQuery("SubgraphNodeEntity.getCount");
- search.setParameter("queryId", query.getId());
-
- // Now process the nodes below the subgraph's root ...
- try {
- return ((Long)search.getSingleResult()).intValue() - (includeRoot ? 0 : 1);
- } catch (NoResultException e) {
- return 0;
- }
- }
-
- /**
* Get the {@link NodeEntity root node} of the subgraph. This must be called before
the query is {@link #close() closed}.
*
* @return the subgraph's root nodes
@@ -219,102 +176,8 @@
}
/**
- * 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,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>
+ * Delete the nodes in the subgraph.
*
- * @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,
- // 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 ...
- // Map<String, Path> pathByUuid = new HashMap<String, Path>();
- // LinkedList<Location> locations = new LinkedList<Location>();
- // String subgraphRootUuid = query.getRootUuid();
- // pathByUuid.put(subgraphRootUuid, subgraphRootPath);
- // UUID uuid = UUID.fromString(subgraphRootUuid);
- // if (includeRoot) {
- // locations.add(Location.create(subgraphRootPath, uuid));
- // }
- //
- // // 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, includeChildrenOfMaxDepthNodes)) {
- // String parentUuid = entity.getParentUuidString();
- // Path parentPath = pathByUuid.get(parentUuid);
- // assert parentPath != null;
- // String nsUri = entity.getChildNamespace().getUri();
- // String localName = entity.getChildName();
- // int sns = entity.getSameNameSiblingIndex();
- // Name childName = nameFactory.create(nsUri, localName);
- // Path childPath = pathFactory.create(parentPath, childName, sns);
- // String childUuid = entity.getId().getChildUuidString();
- // pathByUuid.put(childUuid, childPath);
- // uuid = UUID.fromString(childUuid);
- // locations.add(Location.create(childPath, uuid));
- //
- // }
- // return locations;
- // }
-
- /**
- * Get the list of references that are owned by nodes within the subgraph and that
point to other nodes <i>in this same
- * subgraph</i>. This set of references is important in copying a subgraph,
since all intra-subgraph references in the
- * original subgraph must also be intra-subgraph references in the copy.
- *
- * @return the list of references completely contained by this subgraphs
- */
- @SuppressWarnings( "unchecked" )
- public List<ReferenceEntity> getInternalReferences() {
- Query references =
manager.createNamedQuery("SubgraphNodeEntity.getInternalReferences");
- references.setParameter("queryId", query.getId());
- references.setParameter("workspaceId", workspaceId);
- return references.getResultList();
- }
-
- /**
- * Get the list of references that are owned by nodes within the subgraph and that
point to nodes <i>not in this same
- * subgraph</i>. This set of references is important in copying a subgraph.
- *
- * @return the list of references that are owned by the subgraph but that point to
nodes outside of the subgraph
- */
- @SuppressWarnings( "unchecked" )
- public List<ReferenceEntity> getOutwardReferences() {
- Query references =
manager.createNamedQuery("SubgraphNodeEntity.getOutwardReferences");
- references.setParameter("queryId", query.getId());
- references.setParameter("workspaceId", workspaceId);
- return references.getResultList();
- }
-
- /**
- * Get the list of references that are owned by nodes <i>outside</i> of
the subgraph that point to nodes <i>in this
- * subgraph</i>. This set of references is important in deleting nodes, since
such references prevent the deletion of the
- * subgraph.
- *
- * @return the list of references that are no longer valid
- */
- @SuppressWarnings( "unchecked" )
- public List<ReferenceEntity> getInwardReferences() {
- // Verify referential integrity: that none of the deleted nodes are referenced by
nodes not being deleted.
- Query references =
manager.createNamedQuery("SubgraphNodeEntity.getInwardReferences");
- references.setParameter("queryId", query.getId());
- references.setParameter("workspaceId", workspaceId);
- return references.getResultList();
- }
-
- /**
- * Delete the nodes in the subgraph. This method first does not check for referential
integrity (see
- * {@link #getInwardReferences()}).
- *
* @param includeRoot true if the root node should also be deleted
*/
@SuppressWarnings( "unchecked" )
@@ -353,13 +216,6 @@
delete.setParameter("workspaceId", workspaceId);
delete.executeUpdate();
- // Delete references ...
- // delete =
manager.createNamedQuery("SubgraphNodeEntity.deleteReferences");
- // delete.setParameter("queryId", query.getId());
- // delete.setParameter("depth", includeRoot ? 0 : 1);
- // delete.setParameter("workspaceId", workspaceId);
- // delete.executeUpdate();
-
// Delete unused large values ...
LargeValueEntity.deleteUnused(manager);
Modified:
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/package-info.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/package-info.java 2009-12-04
20:38:39 UTC (rev 1406)
+++
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/simple/package-info.java 2009-12-05
02:53:36 UTC (rev 1407)
@@ -22,7 +22,7 @@
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*/
/**
- * The classes that define the "basic" storage model for the JPA connector.
+ * The classes that define the "simple" storage model for the JPA connector.
*/
package org.jboss.dna.connector.store.jpa.model.simple;
Modified:
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/basic/BasicCreateWorkspacesTest.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/basic/BasicCreateWorkspacesTest.java 2009-12-04
20:38:39 UTC (rev 1406)
+++
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/basic/BasicCreateWorkspacesTest.java 2009-12-05
02:53:36 UTC (rev 1407)
@@ -1,3 +1,26 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you 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.
+ *
+ * JBoss DNA 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.model.basic;
import org.jboss.dna.connector.store.jpa.JpaConnectorCreateWorkspacesTest;
Modified:
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/basic/BasicNoCreateWorkspaceTest.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/basic/BasicNoCreateWorkspaceTest.java 2009-12-04
20:38:39 UTC (rev 1406)
+++
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/basic/BasicNoCreateWorkspaceTest.java 2009-12-05
02:53:36 UTC (rev 1407)
@@ -1,3 +1,26 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you 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.
+ *
+ * JBoss DNA 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.model.basic;
import org.jboss.dna.connector.store.jpa.JpaConnectorNoCreateWorkspaceTest;
Modified:
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/NodeEntityTest.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/NodeEntityTest.java 2009-12-04
20:38:39 UTC (rev 1406)
+++
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/NodeEntityTest.java 2009-12-05
02:53:36 UTC (rev 1407)
@@ -1,3 +1,26 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you 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.
+ *
+ * JBoss DNA 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.model.simple;
import static org.hamcrest.core.Is.is;
@@ -9,7 +32,6 @@
import javax.persistence.Query;
import org.hibernate.ejb.Ejb3Configuration;
import org.jboss.dna.connector.store.jpa.model.common.NamespaceEntity;
-import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.property.PropertyType;
import org.junit.After;
import org.junit.Before;
@@ -20,7 +42,6 @@
private static final Boolean SHOW_SQL = false;
private static final Boolean USE_CACHE = false;
- private ExecutionContext context;
private EntityManagerFactory factory;
private EntityManager manager;
private SimpleModel model;
@@ -48,7 +69,6 @@
factory = configurator.buildEntityManagerFactory();
manager = factory.createEntityManager();
- context = new ExecutionContext();
}
@After
@@ -147,14 +167,12 @@
manager = factory.createEntityManager();
manager.getTransaction().begin();
- SubgraphQuery subgraph = SubgraphQuery.create(context,
- manager,
+ SubgraphQuery subgraph = SubgraphQuery.create(manager,
workspaceId,
UUID.fromString(rootUuid),
-
context.getValueFactories().getPathFactory().createRootPath(),
0);
- assertThat(subgraph.getNodeCount(false), is(10));
+ // assertThat(subgraph.getNodeCount(false), is(10));
subgraph.deleteSubgraph(true);
subgraph.close();
Modified:
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleCreateWorkspacesTest.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleCreateWorkspacesTest.java 2009-12-04
20:38:39 UTC (rev 1406)
+++
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleCreateWorkspacesTest.java 2009-12-05
02:53:36 UTC (rev 1407)
@@ -1,4 +1,26 @@
-package org.jboss.dna.connector.store.jpa.model.simple;
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you 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.
+ *
+ * JBoss DNA 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.model.simple;
import org.jboss.dna.connector.store.jpa.JpaConnectorCreateWorkspacesTest;
import org.jboss.dna.connector.store.jpa.JpaSource;
Modified:
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaConnectorReadableTest.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaConnectorReadableTest.java 2009-12-04
20:38:39 UTC (rev 1406)
+++
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaConnectorReadableTest.java 2009-12-05
02:53:36 UTC (rev 1407)
@@ -1,3 +1,26 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you 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.
+ *
+ * JBoss DNA 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.model.simple;
import org.jboss.dna.common.statistic.Stopwatch;
Modified:
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaConnectorWritableTest.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaConnectorWritableTest.java 2009-12-04
20:38:39 UTC (rev 1406)
+++
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaConnectorWritableTest.java 2009-12-05
02:53:36 UTC (rev 1407)
@@ -1,3 +1,26 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you 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.
+ *
+ * JBoss DNA 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.model.simple;
import org.jboss.dna.connector.store.jpa.JpaSource;
@@ -31,6 +54,7 @@
source.setUrl("jdbc:hsqldb:mem:test");
source.setShowSql(false);
source.setAutoGenerateSchema("create");
+ source.setReferentialIntegrityEnforced(false);
source.initialize(new RepositoryContext() {
@@ -57,11 +81,6 @@
return source;
}
- @Override
- public void shouldCopyNodeWithChildren() {
-
- }
-
/**
* {@inheritDoc}
*
Modified:
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaSourceTest.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaSourceTest.java 2009-12-04
20:38:39 UTC (rev 1406)
+++
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleJpaSourceTest.java 2009-12-05
02:53:36 UTC (rev 1407)
@@ -1,3 +1,26 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you 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.
+ *
+ * JBoss DNA 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.model.simple;
import java.util.concurrent.TimeUnit;
Modified:
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleNoCreateWorkspaceTest.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleNoCreateWorkspaceTest.java 2009-12-04
20:38:39 UTC (rev 1406)
+++
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/simple/SimpleNoCreateWorkspaceTest.java 2009-12-05
02:53:36 UTC (rev 1407)
@@ -1,3 +1,26 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you 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.
+ *
+ * JBoss DNA 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.model.simple;
import org.jboss.dna.connector.store.jpa.JpaConnectorNoCreateWorkspaceTest;