Moved the tracking of newly introduced nodes into its own table. Simplifies things a bit.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3320 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-07-13 15:48:10 +00:00
parent fae76d7896
commit 6ac87efa5a
20 changed files with 342 additions and 129 deletions

View File

@@ -146,6 +146,12 @@
</property> </property>
</bean> </bean>
<bean id="newInRepositoryDAO" class="org.alfresco.repo.avm.hibernate.NewInRepositoryDAOHibernate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="avmContext" class="org.alfresco.repo.avm.AVMContext"> <bean id="avmContext" class="org.alfresco.repo.avm.AVMContext">
<property name="issuerDAO"> <property name="issuerDAO">
<ref bean="issuerDAO"/> <ref bean="issuerDAO"/>
@@ -174,6 +180,9 @@
<property name="deletedChildDAO"> <property name="deletedChildDAO">
<ref bean="deletedChildDAO"/> <ref bean="deletedChildDAO"/>
</property> </property>
<property name="newInRepositoryDAO">
<ref bean="newInRepositoryDAO"/>
</property>
</bean> </bean>
<!-- The HibernateTransactionManager --> <!-- The HibernateTransactionManager -->

View File

@@ -118,6 +118,12 @@
</property> </property>
</bean> </bean>
<bean id="newInRepositoryDAO" class="org.alfresco.repo.avm.hibernate.NewInRepositoryDAOHibernate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="avmContext" class="org.alfresco.repo.avm.AVMContext"> <bean id="avmContext" class="org.alfresco.repo.avm.AVMContext">
<property name="issuerDAO"> <property name="issuerDAO">
<ref bean="issuerDAO"/> <ref bean="issuerDAO"/>
@@ -146,6 +152,9 @@
<property name="deletedChildDAO"> <property name="deletedChildDAO">
<ref bean="deletedChildDAO"/> <ref bean="deletedChildDAO"/>
</property> </property>
<property name="newInRepositoryDAO">
<ref bean="newInRepositoryDAO"/>
</property>
</bean> </bean>
<!-- The HibernateTransactionManager --> <!-- The HibernateTransactionManager -->

View File

@@ -65,6 +65,11 @@ public class AVMContext
*/ */
public DeletedChildDAO fDeletedChildDAO; public DeletedChildDAO fDeletedChildDAO;
/**
* The NewInRepositoryDAO
*/
public NewInRepositoryDAO fNewInRepositoryDAO;
/** /**
* @param nodeDAO the fAVMNodeDAO to set * @param nodeDAO the fAVMNodeDAO to set
*/ */
@@ -136,4 +141,12 @@ public class AVMContext
{ {
fIssuerDAO = issuerDAO; fIssuerDAO = issuerDAO;
} }
/**
* @param newInRepositoryDAO The DAO to set.
*/
public void setNewInRepositoryDAO(NewInRepositoryDAO newInRepositoryDAO)
{
fNewInRepositoryDAO = newInRepositoryDAO;
}
} }

View File

@@ -65,12 +65,6 @@ public interface AVMNode
*/ */
public AVMNode copy(Lookup lPath); public AVMNode copy(Lookup lPath);
/**
* Set the repository for a node.
* @param repo The Repository to set.
*/
public void setRepository(Repository repo);
/** /**
* Get the type of this node. * Get the type of this node.
*/ */
@@ -106,12 +100,6 @@ public interface AVMNode
*/ */
public long getId(); public long getId();
/**
* Set this node's newness.
* @param isNew The newness.
*/
public void setIsNew(boolean isNew);
/** /**
* Get the newnews. * Get the newnews.
* @return Whether the node is new. * @return Whether the node is new.

View File

@@ -30,13 +30,6 @@ public interface AVMNodeDAO
*/ */
public void save(AVMNode node); public void save(AVMNode node);
/**
* Make all the nodes owned by a repository no longer
* point to that repository.
* @param rep The Repository.
*/
public void unreferenceRepository(Repository rep);
/** /**
* Delete a single node. * Delete a single node.
* @param node The node to delete. * @param node The node to delete.
@@ -57,13 +50,6 @@ public interface AVMNodeDAO
*/ */
public DirectoryNode getRepositoryRoot(Repository rep, int version); public DirectoryNode getRepositoryRoot(Repository rep, int version);
/**
* Get those nodes which are new in the given repository.
* @param repo The repository.
* @return A List of AVMNodes.
*/
public List<AVMNode> getNewInRepo(Repository repo);
/** /**
* Update a node that has been dirtied. * Update a node that has been dirtied.
* @param node The node. * @param node The node.

View File

@@ -35,21 +35,11 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
*/ */
private int fVersionID; private int fVersionID;
/**
* The Repository that owns this.
*/
private Repository fRepository;
/** /**
* The basic attributes of this. Owner, creator, mod time, etc. * The basic attributes of this. Owner, creator, mod time, etc.
*/ */
private BasicAttributes fBasicAttributes; private BasicAttributes fBasicAttributes;
/**
* Whether this node is new (and should therefore not be COWed).
*/
private boolean fIsNew;
/** /**
* The version number (for concurrency control). * The version number (for concurrency control).
*/ */
@@ -77,7 +67,6 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
{ {
fID = id; fID = id;
fVersionID = -1; fVersionID = -1;
fRepository = repo;
fIsRoot = false; fIsRoot = false;
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
fBasicAttributes = new BasicAttributesImpl("britt", fBasicAttributes = new BasicAttributesImpl("britt",
@@ -86,7 +75,6 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
time, time,
time, time,
time); time);
fIsNew = true;
} }
/** /**
@@ -139,24 +127,6 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
return AVMContext.fgInstance.fAVMNodeDAO.getMergedFrom(this); return AVMContext.fgInstance.fAVMNodeDAO.getMergedFrom(this);
} }
/**
* Set the owning repository for this.
* @param repo The owning repository.
*/
public void setRepository(Repository repo)
{
fRepository = repo;
}
/**
* Get the repository that owns this.
* @return The repository.
*/
public Repository getRepository()
{
return fRepository;
}
/** /**
* Equality based on object ids. * Equality based on object ids.
* @param obj The thing to compare against. * @param obj The thing to compare against.
@@ -241,22 +211,13 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
return fBasicAttributes; return fBasicAttributes;
} }
/**
* Set whether this is new.
* @param isNew Whether this is new.
*/
public void setIsNew(boolean isNew)
{
fIsNew = isNew;
}
/** /**
* Get whether this is a new node. * Get whether this is a new node.
* @return Whether this is new. * @return Whether this is new.
*/ */
public boolean getIsNew() public boolean getIsNew()
{ {
return fIsNew; return AVMContext.fgInstance.fNewInRepositoryDAO.getByNode(this) != null;
} }
/** /**

View File

@@ -75,6 +75,8 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
fPrimaryIndirection = true; fPrimaryIndirection = true;
fOpacity = false; fOpacity = false;
AVMContext.fgInstance.fAVMNodeDAO.save(this); AVMContext.fgInstance.fAVMNodeDAO.save(this);
AVMContext.fgInstance.fAVMNodeDAO.flush();
AVMContext.fgInstance.fNewInRepositoryDAO.save(new NewInRepositoryImpl(repos, this));
} }
/** /**
@@ -105,6 +107,8 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
this); this);
AVMContext.fgInstance.fDeletedChildDAO.save(newDel); AVMContext.fgInstance.fDeletedChildDAO.save(newDel);
} }
AVMContext.fgInstance.fAVMNodeDAO.flush();
AVMContext.fgInstance.fNewInRepositoryDAO.save(new NewInRepositoryImpl(repos, this));
} }
/** /**
@@ -136,6 +140,8 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
AVMContext.fgInstance.fChildEntryDAO.save(newChild); AVMContext.fgInstance.fChildEntryDAO.save(newChild);
} }
} }
AVMContext.fgInstance.fAVMNodeDAO.flush();
AVMContext.fgInstance.fNewInRepositoryDAO.save(new NewInRepositoryImpl(repos, this));
} }
/** /**
@@ -157,6 +163,8 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
fLayerID = -1; fLayerID = -1;
fOpacity = false; fOpacity = false;
AVMContext.fgInstance.fAVMNodeDAO.save(this); AVMContext.fgInstance.fAVMNodeDAO.save(this);
AVMContext.fgInstance.fAVMNodeDAO.flush();
AVMContext.fgInstance.fNewInRepositoryDAO.save(new NewInRepositoryImpl(repo, this));
} }
/** /**

View File

@@ -48,6 +48,8 @@ class LayeredFileNodeImpl extends FileNodeImpl implements LayeredFileNode
super(repo.getSuperRepository().issueID(), repo); super(repo.getSuperRepository().issueID(), repo);
fIndirection = other.getIndirection(); fIndirection = other.getIndirection();
AVMContext.fgInstance.fAVMNodeDAO.save(this); AVMContext.fgInstance.fAVMNodeDAO.save(this);
AVMContext.fgInstance.fAVMNodeDAO.flush();
AVMContext.fgInstance.fNewInRepositoryDAO.save(new NewInRepositoryImpl(repo, this));
} }
/** /**
@@ -60,6 +62,8 @@ class LayeredFileNodeImpl extends FileNodeImpl implements LayeredFileNode
super(repo.getSuperRepository().issueID(), repo); super(repo.getSuperRepository().issueID(), repo);
fIndirection = indirection; fIndirection = indirection;
AVMContext.fgInstance.fAVMNodeDAO.save(this); AVMContext.fgInstance.fAVMNodeDAO.save(this);
AVMContext.fgInstance.fAVMNodeDAO.flush();
AVMContext.fgInstance.fNewInRepositoryDAO.save(new NewInRepositoryImpl(repo, this));
} }
/** /**

View File

@@ -0,0 +1,37 @@
/*
* Copyright (C) 2006 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.repo.avm;
/**
* Eensy-weensy interface for tracking nodes that are new in a repository.
* @author britt
*/
public interface NewInRepository
{
/**
* Get the Repository part.
* @return The Repository
*/
public Repository getRepository();
/**
* Get the node part.
* @return The AVMNode.
*/
public AVMNode getNode();
}

View File

@@ -0,0 +1,53 @@
/*
* Copyright (C) 2006 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.repo.avm;
import java.util.List;
/**
* DAO for NewInRepository markers.
* @author britt
*/
public interface NewInRepositoryDAO
{
/**
* Save one.
* @param newEntry The item to save.
*/
public void save(NewInRepository newEntry);
/**
* Get one by Node.
* @param node The node to lookup with.
* @return The Entry or null if not found.
*/
public NewInRepository getByNode(AVMNode node);
/**
* Get all that are in the given repository.
* @param repository The Repository.
* @return A List of NewInRepositorys.
*/
public List<NewInRepository> getByRepository(Repository repository);
/**
* Delete the given entry.
* @param newEntry The entry to delete.
*/
public void delete(NewInRepository newEntry);
}

View File

@@ -0,0 +1,90 @@
/*
* Copyright (C) 2006 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.repo.avm;
import java.io.Serializable;
/**
* A record of a node that is new and in which repository it resides.
* @author britt
*/
public class NewInRepositoryImpl implements NewInRepository, Serializable
{
private static final long serialVersionUID = 1905996612150732182L;
/**
* The Repository.
*/
private Repository fRepository;
/**
* The Node.
*/
private AVMNode fNode;
/**
* Default constructor.
*/
public NewInRepositoryImpl()
{
}
/**
* Make a new one.
* @param repository The repository.
* @param node The AVMNode that is new.
*/
public NewInRepositoryImpl(Repository repository, AVMNode node)
{
fRepository = repository;
fNode = node;
}
/**
* @return the fNode
*/
public AVMNode getNode()
{
return fNode;
}
/**
* @param node the fNode to set
*/
public void setNode(AVMNode node)
{
fNode = node;
}
/**
* @return the fRepository
*/
public Repository getRepository()
{
return fRepository;
}
/**
* @param repository the fRepository to set
*/
public void setRepository(Repository repository)
{
fRepository = repository;
}
}

View File

@@ -209,6 +209,7 @@ public class OrphanReaper implements Runnable
mergedFrom = mlink.getMfrom(); mergedFrom = mlink.getMfrom();
AVMContext.fgInstance.fMergeLinkDAO.delete(mlink); AVMContext.fgInstance.fMergeLinkDAO.delete(mlink);
} }
AVMContext.fgInstance.fAVMNodeDAO.flush();
// Get all the nodes that have this node as ancestor. // Get all the nodes that have this node as ancestor.
List<HistoryLink> links = AVMContext.fgInstance.fHistoryLinkDAO.getByAncestor(node); List<HistoryLink> links = AVMContext.fgInstance.fHistoryLinkDAO.getByAncestor(node);
for (HistoryLink link : links) for (HistoryLink link : links)
@@ -228,6 +229,11 @@ public class OrphanReaper implements Runnable
link.getMto().setMergedFrom(ancestor); link.getMto().setMergedFrom(ancestor);
AVMContext.fgInstance.fMergeLinkDAO.delete(link); AVMContext.fgInstance.fMergeLinkDAO.delete(link);
} }
NewInRepository newInRep = AVMContext.fgInstance.fNewInRepositoryDAO.getByNode(node);
if (newInRep != null)
{
AVMContext.fgInstance.fNewInRepositoryDAO.delete(newInRep);
}
// TODO What to do about such Hibernate wackiness: session.flush(); // TODO What to do about such Hibernate wackiness: session.flush();
// TODO More of the same: node = AVMNodeUnwrapper.Unwrap(node); // TODO More of the same: node = AVMNodeUnwrapper.Unwrap(node);
// Extra work for directories. // Extra work for directories.

View File

@@ -38,6 +38,8 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
{ {
super(repo.getSuperRepository().issueID(), repo); super(repo.getSuperRepository().issueID(), repo);
AVMContext.fgInstance.fAVMNodeDAO.save(this); AVMContext.fgInstance.fAVMNodeDAO.save(this);
AVMContext.fgInstance.fAVMNodeDAO.flush();
AVMContext.fgInstance.fNewInRepositoryDAO.save(new NewInRepositoryImpl(repo, this));
} }
/** /**
@@ -58,15 +60,15 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
{ {
super(repos.getSuperRepository().issueID(), repos); super(repos.getSuperRepository().issueID(), repos);
AVMContext.fgInstance.fAVMNodeDAO.save(this); AVMContext.fgInstance.fAVMNodeDAO.save(this);
// TODO Something about this. sess.flush();
for (ChildEntry child : AVMContext.fgInstance.fChildEntryDAO.getByParent(other)) for (ChildEntry child : AVMContext.fgInstance.fChildEntryDAO.getByParent(other))
{ {
ChildEntry newChild = new ChildEntryImpl(child.getName(), ChildEntry newChild = new ChildEntryImpl(child.getName(),
this, this,
child.getChild()); child.getChild());
AVMContext.fgInstance.fChildEntryDAO.save(newChild); AVMContext.fgInstance.fChildEntryDAO.save(newChild);
// TODO Something about this: sess.flush();
} }
AVMContext.fgInstance.fAVMNodeDAO.flush();
AVMContext.fgInstance.fNewInRepositoryDAO.save(new NewInRepositoryImpl(repos, this));
} }
/** /**

View File

@@ -50,6 +50,8 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
super(repos.getSuperRepository().issueID(), repos); super(repos.getSuperRepository().issueID(), repos);
fContent = new FileContentImpl(SuperRepository.GetInstance().issueContentID()); fContent = new FileContentImpl(SuperRepository.GetInstance().issueContentID());
AVMContext.fgInstance.fAVMNodeDAO.save(this); AVMContext.fgInstance.fAVMNodeDAO.save(this);
AVMContext.fgInstance.fAVMNodeDAO.flush();
AVMContext.fgInstance.fNewInRepositoryDAO.save(new NewInRepositoryImpl(repos, this));
} }
/** /**
@@ -62,6 +64,8 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
super(repos.getSuperRepository().issueID(), repos); super(repos.getSuperRepository().issueID(), repos);
fContent = new FileContentImpl(SuperRepository.GetInstance().issueContentID(), content); fContent = new FileContentImpl(SuperRepository.GetInstance().issueContentID(), content);
AVMContext.fgInstance.fAVMNodeDAO.save(this); AVMContext.fgInstance.fAVMNodeDAO.save(this);
AVMContext.fgInstance.fAVMNodeDAO.flush();
AVMContext.fgInstance.fNewInRepositoryDAO.save(new NewInRepositoryImpl(repos, this));
} }
/** /**
@@ -76,6 +80,8 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
fContent = other.getContent(); fContent = other.getContent();
fContent.setRefCount(fContent.getRefCount() + 1); fContent.setRefCount(fContent.getRefCount() + 1);
AVMContext.fgInstance.fAVMNodeDAO.save(this); AVMContext.fgInstance.fAVMNodeDAO.save(this);
AVMContext.fgInstance.fAVMNodeDAO.flush();
AVMContext.fgInstance.fNewInRepositoryDAO.save(new NewInRepositoryImpl(repos, this));
} }
/** /**
@@ -91,6 +97,8 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
fContent = content; fContent = content;
fContent.setRefCount(fContent.getRefCount() + 1); fContent.setRefCount(fContent.getRefCount() + 1);
AVMContext.fgInstance.fAVMNodeDAO.save(this); AVMContext.fgInstance.fAVMNodeDAO.save(this);
AVMContext.fgInstance.fAVMNodeDAO.flush();
AVMContext.fgInstance.fNewInRepositoryDAO.save(new NewInRepositoryImpl(repos, this));
} }
/** /**

View File

@@ -100,7 +100,6 @@ public class RepositoryImpl implements Repository, Serializable
// Make up the initial version record and save. // Make up the initial version record and save.
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
fRoot = new PlainDirectoryNodeImpl(this); fRoot = new PlainDirectoryNodeImpl(this);
fRoot.setIsNew(false);
fRoot.setIsRoot(true); fRoot.setIsRoot(true);
AVMContext.fgInstance.fAVMNodeDAO.save(fRoot); AVMContext.fgInstance.fAVMNodeDAO.save(fRoot);
VersionRoot versionRoot = new VersionRootImpl(this, VersionRoot versionRoot = new VersionRootImpl(this,
@@ -135,13 +134,11 @@ public class RepositoryImpl implements Repository, Serializable
throw new AVMExistsException("Already snapshotted."); throw new AVMExistsException("Already snapshotted.");
} }
// Clear out the new nodes. // Clear out the new nodes.
AVMNodeDAO anDAO = AVMContext.fgInstance.fAVMNodeDAO; List<NewInRepository> newInRep = AVMContext.fgInstance.fNewInRepositoryDAO.getByRepository(this);
for (AVMNode newNode : anDAO.getNewInRepo(this)) for (NewInRepository newGuy : newInRep)
{ {
newNode.setIsNew(false); AVMContext.fgInstance.fNewInRepositoryDAO.delete(newGuy);
} }
// TODO: This is a grotesque hack to deal with hibernate.
anDAO.flush();
// Make up a new version record. // Make up a new version record.
VersionRoot versionRoot = new VersionRootImpl(this, VersionRoot versionRoot = new VersionRootImpl(this,
fRoot, fRoot,

View File

@@ -33,7 +33,7 @@ public class SimultaneousLoadTest extends AVMServiceTestBase
try try
{ {
int n = 8; int n = 8;
int m = 2; int m = 1;
fReaper.setInactiveBaseSleep(60000); fReaper.setInactiveBaseSleep(60000);
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
{ {

View File

@@ -23,7 +23,6 @@ import java.io.OutputStream;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.SortedMap; import java.util.SortedMap;
@@ -178,8 +177,8 @@ class SuperRepository
@SuppressWarnings("unused") @SuppressWarnings("unused")
Repository rep = new RepositoryImpl(this, name); Repository rep = new RepositoryImpl(this, name);
// Special handling for repository creation. // Special handling for repository creation.
// TODO is this needed. NewInRepository newInRep = AVMContext.fgInstance.fNewInRepositoryDAO.getByNode(rep.getRoot());
rep.getRoot().setIsNew(false); AVMContext.fgInstance.fNewInRepositoryDAO.delete(newInRep);
} }
/** /**
@@ -456,12 +455,10 @@ class SuperRepository
node.setIsRoot(false); node.setIsRoot(false);
vrDAO.delete(vr); vrDAO.delete(vr);
} }
Iterator<AVMNode> iter = AVMContext.fgInstance.fAVMNodeDAO.getByRepository(rep); List<NewInRepository> newGuys = AVMContext.fgInstance.fNewInRepositoryDAO.getByRepository(rep);
while (iter.hasNext()) for (NewInRepository newGuy : newGuys)
{ {
AVMNode node = iter.next(); AVMContext.fgInstance.fNewInRepositoryDAO.delete(newGuy);
node.setRepository(null);
AVMContext.fgInstance.fAVMNodeDAO.update(node);
} }
AVMContext.fgInstance.fRepositoryDAO.delete(rep); AVMContext.fgInstance.fRepositoryDAO.delete(rep);
} }

View File

@@ -27,12 +27,8 @@
<!-- This should really be not null, but I haven't figured out <!-- This should really be not null, but I haven't figured out
the right way to build the relation so that nullability constraints the right way to build the relation so that nullability constraints
won't cause violations in the db during saves. --> won't cause violations in the db during saves. -->
<many-to-one name="repository" column="repository"
class="RepositoryImpl"/>
<property name="versionID" type="int" column="version_id" <property name="versionID" type="int" column="version_id"
not-null="true"/> not-null="true"/>
<property name="isNew" column="is_new" type="boolean"
not-null="true"/>
<component name="basicAttributes" class="BasicAttributesImpl"> <component name="basicAttributes" class="BasicAttributesImpl">
<property name="creator" type="string" not-null="true"/> <property name="creator" type="string" not-null="true"/>
<property name="owner" type="string" not-null="true"/> <property name="owner" type="string" not-null="true"/>
@@ -175,6 +171,12 @@
<key-many-to-one name="mto" class="AVMNodeImpl" column="mto"/> <key-many-to-one name="mto" class="AVMNodeImpl" column="mto"/>
</composite-id> </composite-id>
</class> </class>
<class name="NewInRepositoryImpl" proxy="NewInRepository" table="new_in_repository_nodes">
<composite-id>
<key-many-to-one name="repository" class="RepositoryImpl" column="repository_id"/>
<key-many-to-one name="node" class="AVMNodeImpl" column="node_id"/>
</composite-id>
</class>
<query name="ChildEntry.ByNameParent"> <query name="ChildEntry.ByNameParent">
<![CDATA[ <![CDATA[
from ChildEntryImpl ce from ChildEntryImpl ce
@@ -204,9 +206,8 @@
</query> </query>
<query name="AVMNode.ByNewInRepo"> <query name="AVMNode.ByNewInRepo">
<![CDATA[ <![CDATA[
from AVMNodeImpl a from NewInRepositoryImpl nie
where where nie.repository = :rep
a.repository = :repo and a.isNew = true
]]> ]]>
</query> </query>
<query name="AVMNode.GetDescendents"> <query name="AVMNode.GetDescendents">

View File

@@ -53,26 +53,6 @@ public class AVMNodeDAOHibernate extends HibernateDaoSupport implements
getSession().save(node); getSession().save(node);
} }
/**
* Get all the nodes owned by a Repository and make
* them no longer point at that Repository.
* @param rep The Repository.
*/
@SuppressWarnings("unchecked")
public void unreferenceRepository(Repository rep)
{
Session sess = getSession();
Query query = sess.createQuery("from AVMNodeImpl an where an.repository = :rep");
query.setEntity("rep", rep);
Iterator<AVMNode> iter = (Iterator<AVMNode>)query.iterate();
while (iter.hasNext())
{
AVMNode node = iter.next();
node.setRepository(null);
}
sess.flush();
}
/** /**
* Delete a single node. * Delete a single node.
* @param node The node to delete. * @param node The node to delete.
@@ -91,20 +71,6 @@ public class AVMNodeDAOHibernate extends HibernateDaoSupport implements
return AVMNodeUnwrapper.Unwrap((AVMNode)getSession().get(AVMNodeImpl.class, id)); return AVMNodeUnwrapper.Unwrap((AVMNode)getSession().get(AVMNodeImpl.class, id));
} }
/**
* Get those nodes which are new in the given repository.
* @param repo The repository.
* @return A List of AVMNodes.
*/
@SuppressWarnings("unchecked")
public List<AVMNode> getNewInRepo(Repository repo)
{
Query query =
getSession().getNamedQuery("AVMNode.ByNewInRepo");
query.setEntity("repo", repo);
return (List<AVMNode>)query.list();
}
/** /**
* Update a node that has been dirtied. * Update a node that has been dirtied.
* @param node The node. * @param node The node.

View File

@@ -0,0 +1,78 @@
/*
* Copyright (C) 2006 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.repo.avm.hibernate;
import java.util.List;
import org.alfresco.repo.avm.AVMNode;
import org.alfresco.repo.avm.NewInRepository;
import org.alfresco.repo.avm.NewInRepositoryDAO;
import org.alfresco.repo.avm.Repository;
import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
/**
* Hibernate implementation of NewInRepository DAO.
* @author britt
*/
public class NewInRepositoryDAOHibernate extends HibernateDaoSupport implements
NewInRepositoryDAO
{
/**
* Save one.
* @param newEntry The item to save.
*/
public void save(NewInRepository newEntry)
{
getSession().save(newEntry);
}
/**
* Get one by Node.
* @param node The node to lookup with.
* @return The Entry or null if not found.
*/
public NewInRepository getByNode(AVMNode node)
{
Query query = getSession().createQuery("from NewInRepositoryImpl nie where nie.node = :node");
query.setEntity("node", node);
return (NewInRepository)query.uniqueResult();
}
/**
* Get all that are in the given repository.
* @param repository The Repository.
* @return A List of NewInRepositorys.
*/
@SuppressWarnings("unchecked")
public List<NewInRepository> getByRepository(Repository repository)
{
Query query = getSession().createQuery("from NewInRepositoryImpl nie where nie.repository = :rep");
query.setEntity("rep", repository);
return (List<NewInRepository>)query.list();
}
/**
* Delete the given entry.
* @param newEntry The entry to delete.
*/
public void delete(NewInRepository newEntry)
{
getSession().delete(newEntry);
}
}