mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
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:
@@ -27,12 +27,8 @@
|
||||
<!-- This should really be not null, but I haven't figured out
|
||||
the right way to build the relation so that nullability constraints
|
||||
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"
|
||||
not-null="true"/>
|
||||
<property name="isNew" column="is_new" type="boolean"
|
||||
not-null="true"/>
|
||||
<component name="basicAttributes" class="BasicAttributesImpl">
|
||||
<property name="creator" 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"/>
|
||||
</composite-id>
|
||||
</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">
|
||||
<![CDATA[
|
||||
from ChildEntryImpl ce
|
||||
@@ -204,9 +206,8 @@
|
||||
</query>
|
||||
<query name="AVMNode.ByNewInRepo">
|
||||
<![CDATA[
|
||||
from AVMNodeImpl a
|
||||
where
|
||||
a.repository = :repo and a.isNew = true
|
||||
from NewInRepositoryImpl nie
|
||||
where nie.repository = :rep
|
||||
]]>
|
||||
</query>
|
||||
<query name="AVMNode.GetDescendents">
|
||||
|
@@ -53,26 +53,6 @@ public class AVMNodeDAOHibernate extends HibernateDaoSupport implements
|
||||
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.
|
||||
* @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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param node The node.
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user