mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merge from HEAD to WCM-DEV2.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3659 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -31,8 +31,10 @@ import org.alfresco.repo.domain.Node;
|
||||
import org.alfresco.repo.domain.NodeKey;
|
||||
import org.alfresco.repo.domain.NodeStatus;
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.repo.domain.Server;
|
||||
import org.alfresco.repo.domain.Store;
|
||||
import org.alfresco.repo.domain.StoreKey;
|
||||
import org.alfresco.repo.domain.Transaction;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
@@ -53,8 +55,11 @@ import org.hibernate.exception.ConstraintViolationException;
|
||||
public class HibernateNodeTest extends BaseSpringTest
|
||||
{
|
||||
private static final String TEST_NAMESPACE = "http://www.alfresco.org/test/HibernateNodeTest";
|
||||
private static int i = 0;
|
||||
|
||||
private Store store;
|
||||
private Server server;
|
||||
private Transaction transaction;
|
||||
|
||||
public HibernateNodeTest()
|
||||
{
|
||||
@@ -68,6 +73,18 @@ public class HibernateNodeTest extends BaseSpringTest
|
||||
store.setKey(storeKey);
|
||||
// persist so that it is present in the hibernate cache
|
||||
getSession().save(store);
|
||||
|
||||
server = (Server) getSession().get(ServerImpl.class, new Long(1));
|
||||
if (server == null)
|
||||
{
|
||||
server = new ServerImpl();
|
||||
server.setIpAddress("" + "i_" + System.currentTimeMillis());
|
||||
getSession().save(server);
|
||||
}
|
||||
transaction = new TransactionImpl();
|
||||
transaction.setServer(server);
|
||||
transaction.setChangeTxnId(AlfrescoTransactionSupport.getTransactionId());
|
||||
getSession().save(transaction);
|
||||
}
|
||||
|
||||
protected void onTearDownInTransaction()
|
||||
@@ -108,7 +125,7 @@ public class HibernateNodeTest extends BaseSpringTest
|
||||
// create the node status
|
||||
NodeStatus nodeStatus = new NodeStatusImpl();
|
||||
nodeStatus.setKey(key);
|
||||
nodeStatus.setChangeTxnId("txn:123");
|
||||
nodeStatus.setTransaction(transaction);
|
||||
getSession().save(nodeStatus);
|
||||
|
||||
// create a new Node
|
||||
@@ -131,7 +148,7 @@ public class HibernateNodeTest extends BaseSpringTest
|
||||
node = nodeStatus.getNode();
|
||||
assertNotNull("Node was not attached to status", node);
|
||||
// change the values
|
||||
nodeStatus.setChangeTxnId("txn:456");
|
||||
transaction.setChangeTxnId("txn:456");
|
||||
// delete the node
|
||||
getSession().delete(node);
|
||||
|
||||
@@ -351,7 +368,7 @@ public class HibernateNodeTest extends BaseSpringTest
|
||||
NodeStatus containerNodeStatus = new NodeStatusImpl();
|
||||
containerNodeStatus.setKey(containerNodeKey);
|
||||
containerNodeStatus.setNode(containerNode);
|
||||
containerNodeStatus.setChangeTxnId(AlfrescoTransactionSupport.getTransactionId());
|
||||
containerNodeStatus.setTransaction(transaction);
|
||||
getSession().save(containerNodeStatus);
|
||||
// make content node 1
|
||||
Node contentNode1 = new NodeImpl();
|
||||
@@ -366,7 +383,7 @@ public class HibernateNodeTest extends BaseSpringTest
|
||||
NodeStatus contentNodeStatus1 = new NodeStatusImpl();
|
||||
contentNodeStatus1.setKey(contentNodeKey1);
|
||||
contentNodeStatus1.setNode(contentNode1);
|
||||
contentNodeStatus1.setChangeTxnId(AlfrescoTransactionSupport.getTransactionId());
|
||||
contentNodeStatus1.setTransaction(transaction);
|
||||
getSession().save(contentNodeStatus1);
|
||||
// make content node 2
|
||||
Node contentNode2 = new NodeImpl();
|
||||
@@ -381,7 +398,7 @@ public class HibernateNodeTest extends BaseSpringTest
|
||||
NodeStatus contentNodeStatus2 = new NodeStatusImpl();
|
||||
contentNodeStatus2.setKey(contentNodeKey2);
|
||||
contentNodeStatus2.setNode(contentNode2);
|
||||
contentNodeStatus2.setChangeTxnId(AlfrescoTransactionSupport.getTransactionId());
|
||||
contentNodeStatus2.setTransaction(transaction);
|
||||
getSession().save(contentNodeStatus2);
|
||||
// create an association to content 1
|
||||
ChildAssoc assoc1 = new ChildAssocImpl();
|
||||
|
@@ -113,6 +113,16 @@
|
||||
<key-property name="identifier" length="100" />
|
||||
<key-property name="guid" length="36" />
|
||||
</composite-id>
|
||||
<!-- forward assoc to transaction -->
|
||||
<many-to-one
|
||||
name="transaction"
|
||||
class="org.alfresco.repo.domain.hibernate.TransactionImpl"
|
||||
column="transaction_id"
|
||||
lazy="proxy"
|
||||
fetch="select"
|
||||
unique="false"
|
||||
not-null="true"
|
||||
cascade="none" />
|
||||
<!-- forward assoc to node (optional) -->
|
||||
<many-to-one
|
||||
name="node"
|
||||
@@ -122,7 +132,6 @@
|
||||
fetch="join"
|
||||
unique="false"
|
||||
not-null="false" />
|
||||
<property name="changeTxnId" column="change_txn_id" type="string" length="56" not-null="true" index="CHANGE_TXN_ID"/>
|
||||
</class>
|
||||
|
||||
<class
|
||||
@@ -137,33 +146,31 @@
|
||||
<id name="id" column="id" type="long" >
|
||||
<generator class="native" />
|
||||
</id>
|
||||
<natural-id mutable="true">
|
||||
<!-- forward assoc to parent node -->
|
||||
<many-to-one
|
||||
name="parent"
|
||||
class="org.alfresco.repo.domain.hibernate.NodeImpl"
|
||||
lazy="proxy"
|
||||
fetch="select"
|
||||
optimistic-lock="true"
|
||||
not-null="true"
|
||||
unique-key="UIDX_CHILD_NAME" >
|
||||
<column name="parent_node_id" />
|
||||
</many-to-one>
|
||||
<!-- forward assoc to child node -->
|
||||
<many-to-one
|
||||
name="child"
|
||||
lazy="proxy"
|
||||
fetch="select"
|
||||
class="org.alfresco.repo.domain.hibernate.NodeImpl"
|
||||
optimistic-lock="true"
|
||||
not-null="true" >
|
||||
<column name="child_node_id" />
|
||||
</many-to-one>
|
||||
<property name="typeQName" column="type_qname" type="QName" length="255" not-null="true" unique-key="UIDX_CHILD_NAME" />
|
||||
</natural-id>
|
||||
<!-- forward assoc to parent node -->
|
||||
<many-to-one
|
||||
name="parent"
|
||||
class="org.alfresco.repo.domain.hibernate.NodeImpl"
|
||||
lazy="proxy"
|
||||
fetch="select"
|
||||
optimistic-lock="true"
|
||||
not-null="true"
|
||||
unique-key="UIDX_CHILD_NAME" >
|
||||
<column name="parent_node_id" />
|
||||
</many-to-one>
|
||||
<!-- forward assoc to child node -->
|
||||
<many-to-one
|
||||
name="child"
|
||||
lazy="proxy"
|
||||
fetch="select"
|
||||
class="org.alfresco.repo.domain.hibernate.NodeImpl"
|
||||
optimistic-lock="true"
|
||||
not-null="true" >
|
||||
<column name="child_node_id" />
|
||||
</many-to-one>
|
||||
<property name="typeQName" column="type_qname" type="QName" length="255" not-null="true" unique-key="UIDX_CHILD_NAME" />
|
||||
<property name="qname" column="qname" type="QName" length="255" not-null="true" />
|
||||
<property name="childNodeName" column="child_node_name" type="string" length="50" not-null="true" unique-key="UIDX_CHILD_NAME" />
|
||||
<property name="childNodeNameCrc" column="child_node_name_crc" type="long" not-null="true" unique-key="UIDX_CHILD_NAME" />
|
||||
<property name="qname" column="qname" type="QName" length="255" not-null="true" />
|
||||
<property name="isPrimary" column="is_primary" />
|
||||
<property name="index" column="assoc_index" />
|
||||
</class>
|
||||
@@ -309,25 +316,26 @@
|
||||
|
||||
<query name="node.GetNextChangeTxnIds">
|
||||
select distinct
|
||||
status.changeTxnId
|
||||
transaction.changeTxnId
|
||||
from
|
||||
org.alfresco.repo.domain.hibernate.NodeStatusImpl as status
|
||||
org.alfresco.repo.domain.hibernate.TransactionImpl as transaction
|
||||
where
|
||||
status.changeTxnId > :currentTxnId
|
||||
transaction.changeTxnId > :currentTxnId
|
||||
order by
|
||||
status.changeTxnId
|
||||
transaction.changeTxnId
|
||||
</query>
|
||||
|
||||
<query name="node.GetChangedNodeStatusesCount">
|
||||
select
|
||||
count(status.changeTxnId)
|
||||
count(transaction.changeTxnId)
|
||||
from
|
||||
org.alfresco.repo.domain.hibernate.NodeStatusImpl as status
|
||||
join status.transaction as transaction
|
||||
where
|
||||
status.key.protocol = :storeProtocol and
|
||||
status.key.identifier = :storeIdentifier and
|
||||
status.node.id is not null and
|
||||
status.changeTxnId = :changeTxnId
|
||||
transaction.changeTxnId = :changeTxnId
|
||||
</query>
|
||||
|
||||
<query name="node.GetChangedNodeStatuses">
|
||||
@@ -335,11 +343,12 @@
|
||||
status
|
||||
from
|
||||
org.alfresco.repo.domain.hibernate.NodeStatusImpl as status
|
||||
join status.transaction as transaction
|
||||
where
|
||||
status.key.protocol = :storeProtocol and
|
||||
status.key.identifier = :storeIdentifier and
|
||||
status.node.id is not null and
|
||||
status.changeTxnId = :changeTxnId
|
||||
transaction.changeTxnId = :changeTxnId
|
||||
</query>
|
||||
|
||||
<query name="node.GetDeletedNodeStatuses">
|
||||
@@ -347,11 +356,12 @@
|
||||
status
|
||||
from
|
||||
org.alfresco.repo.domain.hibernate.NodeStatusImpl as status
|
||||
join status.transaction as transaction
|
||||
where
|
||||
status.key.protocol = :storeProtocol and
|
||||
status.key.identifier = :storeIdentifier and
|
||||
status.node.id is null and
|
||||
status.changeTxnId = :changeTxnId
|
||||
transaction.changeTxnId = :changeTxnId
|
||||
</query>
|
||||
|
||||
<query name="node.GetContentDataStrings">
|
||||
|
@@ -21,6 +21,7 @@ import java.io.Serializable;
|
||||
import org.alfresco.repo.domain.Node;
|
||||
import org.alfresco.repo.domain.NodeKey;
|
||||
import org.alfresco.repo.domain.NodeStatus;
|
||||
import org.alfresco.repo.domain.Transaction;
|
||||
import org.alfresco.util.EqualsHelper;
|
||||
|
||||
/**
|
||||
@@ -34,15 +35,16 @@ public class NodeStatusImpl implements NodeStatus, Serializable
|
||||
|
||||
private NodeKey key;
|
||||
private Node node;
|
||||
private String changeTxnId;
|
||||
private Transaction transaction;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(50);
|
||||
sb.append("NodeStatus")
|
||||
.append("[key=").append(key)
|
||||
.append(", node=").append(node == null ? null : node.getNodeRef())
|
||||
.append(", txn=").append(changeTxnId)
|
||||
.append(", txn=").append(transaction)
|
||||
.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -85,14 +87,14 @@ public class NodeStatusImpl implements NodeStatus, Serializable
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
public String getChangeTxnId()
|
||||
public Transaction getTransaction()
|
||||
{
|
||||
return changeTxnId;
|
||||
return transaction;
|
||||
}
|
||||
|
||||
public void setChangeTxnId(String txnId)
|
||||
public void setTransaction(Transaction transaction)
|
||||
{
|
||||
this.changeTxnId = txnId;
|
||||
this.transaction = transaction;
|
||||
}
|
||||
|
||||
public boolean isDeleted()
|
||||
|
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (C) 2005 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.domain.hibernate;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.alfresco.repo.domain.Server;
|
||||
|
||||
/**
|
||||
* Bean containing all the persistence data representing a <b>Server</b>.
|
||||
* <p>
|
||||
* This implementation of the {@link org.alfresco.repo.domain.Service Service} interface is
|
||||
* Hibernate specific.
|
||||
*
|
||||
* @author Derek Hulley
|
||||
*/
|
||||
public class ServerImpl extends LifecycleAdapter implements Server, Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 8063452519040344479L;
|
||||
|
||||
private Long id;
|
||||
private String ipAddress;
|
||||
|
||||
public ServerImpl()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(50);
|
||||
sb.append("Server")
|
||||
.append("[id=").append(id)
|
||||
.append(", ipAddress=").append(ipAddress)
|
||||
.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* For Hibernate use
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getIpAddress()
|
||||
{
|
||||
return ipAddress;
|
||||
}
|
||||
|
||||
public void setIpAddress(String ipAddress)
|
||||
{
|
||||
this.ipAddress = ipAddress;
|
||||
}
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
|
||||
<!DOCTYPE hibernate-mapping PUBLIC
|
||||
'-//Hibernate/Hibernate Mapping DTD 3.0//EN'
|
||||
'http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd'>
|
||||
|
||||
<hibernate-mapping>
|
||||
|
||||
<class
|
||||
name="org.alfresco.repo.domain.hibernate.TransactionImpl"
|
||||
proxy="org.alfresco.repo.domain.Transaction"
|
||||
table="alf_transaction"
|
||||
dynamic-update="false"
|
||||
dynamic-insert="false"
|
||||
select-before-update="false"
|
||||
lazy="true"
|
||||
optimistic-lock="version" >
|
||||
<!-- auto-generated ID -->
|
||||
<id name="id" column="id" type="long" >
|
||||
<generator class="native" />
|
||||
</id>
|
||||
<!-- forward assoc to server IP -->
|
||||
<many-to-one
|
||||
name="server"
|
||||
class="org.alfresco.repo.domain.hibernate.ServerImpl"
|
||||
column="server_id"
|
||||
lazy="proxy"
|
||||
fetch="select"
|
||||
unique="false"
|
||||
not-null="false"
|
||||
cascade="none" />
|
||||
<property name="changeTxnId" column="change_txn_id" type="string" length="56" not-null="true" index="CHANGE_TXN_ID"/>
|
||||
</class>
|
||||
|
||||
<class
|
||||
name="org.alfresco.repo.domain.hibernate.ServerImpl"
|
||||
proxy="org.alfresco.repo.domain.Server"
|
||||
table="alf_server"
|
||||
dynamic-update="false"
|
||||
dynamic-insert="false"
|
||||
select-before-update="false"
|
||||
lazy="true"
|
||||
optimistic-lock="version" >
|
||||
<!-- auto-generated ID -->
|
||||
<id name="id" column="id" type="long" >
|
||||
<generator class="native" />
|
||||
</id>
|
||||
<natural-id>
|
||||
<property name="ipAddress" column="ip_address" type="string" length="15" not-null="true" />
|
||||
</natural-id>
|
||||
</class>
|
||||
|
||||
<query name="server.getServerByIpAddress">
|
||||
select
|
||||
server
|
||||
from
|
||||
org.alfresco.repo.domain.hibernate.ServerImpl as server
|
||||
where
|
||||
server.ipAddress = :ipAddress
|
||||
</query>
|
||||
|
||||
</hibernate-mapping>
|
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (C) 2005 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.domain.hibernate;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.alfresco.repo.domain.Server;
|
||||
import org.alfresco.repo.domain.Transaction;
|
||||
|
||||
/**
|
||||
* Bean containing all the persistence data representing a <b>Transaction</b>.
|
||||
* <p>
|
||||
* This implementation of the {@link org.alfresco.repo.domain.Transaction Transaction} interface is
|
||||
* Hibernate specific.
|
||||
*
|
||||
* @author Derek Hulley
|
||||
*/
|
||||
public class TransactionImpl extends LifecycleAdapter implements Transaction, Serializable
|
||||
{
|
||||
private static final long serialVersionUID = -8264339795578077552L;
|
||||
|
||||
private Long id;
|
||||
private String changeTxnId;
|
||||
private Server server;
|
||||
|
||||
public TransactionImpl()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(50);
|
||||
sb.append("Transaction")
|
||||
.append("[id=").append(id)
|
||||
.append(", changeTxnId=").append(changeTxnId)
|
||||
.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* For Hibernate use
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getChangeTxnId()
|
||||
{
|
||||
return changeTxnId;
|
||||
}
|
||||
|
||||
public void setChangeTxnId(String changeTransactionId)
|
||||
{
|
||||
this.changeTxnId = changeTransactionId;
|
||||
}
|
||||
|
||||
public Server getServer()
|
||||
{
|
||||
return server;
|
||||
}
|
||||
|
||||
public void setServer(Server server)
|
||||
{
|
||||
this.server = server;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user