Update of
/var/cvs/contributions/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository
In directory
james.mmbase.org:/tmp/cvs-serv18004/contentrepository/src/java/com/finalist/cmsc/repository
Modified Files:
RepositoryUtil.java
Log Message:
CMSC-1298 Clone channel feature
See also:
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository
See also: http://www.mmbase.org/jira/browse/CMSC-1298
Index: RepositoryUtil.java
===================================================================
RCS file:
/var/cvs/contributions/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/RepositoryUtil.java,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- RepositoryUtil.java 20 Mar 2009 10:13:20 -0000 1.43
+++ RepositoryUtil.java 25 Mar 2009 08:57:36 -0000 1.44
@@ -566,8 +566,19 @@
* - Content Node
* @return true if the node has a related creation channel
*/
+ public static boolean hasCreationChannel(Node content) {
+ int count = content
+
.countRelatedNodes(content.getCloud().getNodeManager(CONTENTCHANNEL),
CREATIONREL, DESTINATION);
+ return count > 0;
+ }
+ /**
+ * Check if a contentnode has a creationchannel
+ *
+ * @param content
+ * - Content Node
+ * @return true if the node has a related creation channel
+ */
public static boolean hasCreationChannel(Node content,Node channel) {
-
if(!isChannel(channel)) {
return false;
}
@@ -582,18 +593,6 @@
return false;
}
/**
- * Check if a contentnode has a creationchannel
- *
- * @param content
- * - Content Node
- * @return true if the node has a related creation channel
- */
- public static boolean hasCreationChannel(Node content) {
- int count = content
-
.countRelatedNodes(content.getCloud().getNodeManager(CONTENTCHANNEL),
CREATIONREL, DESTINATION);
- return count > 0;
- }
- /**
* Get creation channel
*
* @param content
@@ -1246,14 +1245,34 @@
if(log.isDebugEnabled()) {
log.debug("#################:"+output.toString());
}
+ String cloneCopy = PropertiesUtil.getProperty("clonecopy");
+ if("true".equalsIgnoreCase(cloneCopy)) {
+
copyContentElements(sourceChannel,destChannel,channelList,copiedNodes,output);
+ }
return newNode;
}
+ public static Node copyContentElements(Node sourceChannel, Node
destChannel, List<Integer> channelList,Map<Integer, Integer> copiedNodes
,StringBuilder output) {
+ if (!isParent(sourceChannel, destChannel)) {
+ Object newChannelNumber = copiedNodes.get(sourceChannel.getNumber());
+
+ if( newChannelNumber != null) {
+ Node newChannel =
sourceChannel.getCloud().getNode((Integer)newChannelNumber);
+ cloneRelatedNodes(sourceChannel,
newChannel,copiedNodes,output,channelList);
+ NodeList children = getOrderedChildren(sourceChannel);
+ for (Iterator<Node> iter = children.iterator(); iter.hasNext();) {
+ Node childChannel = iter.next();
+ copyContentElements(childChannel,
newChannel,channelList,copiedNodes,output);
+ }
+ }
+ }
+ return null;
+ }
public static Node copyChannel(Node sourceChannel, Node destChannel,
List<Integer> channelList,Map<Integer, Integer> copiedNodes ,StringBuilder
output) {
if (!isParent(sourceChannel, destChannel)) {
Node newChannel = CloneUtil.cloneNode(sourceChannel);
appendChild(destChannel, newChannel);
-
+ copiedNodes.put(sourceChannel.getNumber(), newChannel.getNumber());
NodeList children = getOrderedChildren(sourceChannel);
for (Iterator<Node> iter = children.iterator(); iter.hasNext();) {
Node childChannel = iter.next();
@@ -1262,7 +1281,6 @@
String cloneCopy = PropertiesUtil.getProperty("clonecopy");
if("true".equalsIgnoreCase(cloneCopy)) {
cloneAssetNodes(sourceChannel,newChannel,copiedNodes,output);
- cloneRelatedNodes(sourceChannel,
newChannel,copiedNodes,output,channelList);
}
else {
CloneUtil.cloneRelations(sourceChannel, newChannel, CONTENTREL,
CONTENTELEMENT);
@@ -1492,7 +1510,7 @@
continue; //Skip nodes not in the current channel tree.
}
else
- {
+ { output.append(" into main ");
//*** Start cloning the node from sourceChild -> destChild
//If the related node should be cloned, dive into the node and
deepcopy it
Node sourceChild = rel.getDestination();
@@ -1500,9 +1518,8 @@
//Only clone node, when it hasn't been cloned before.
Node destChild;
-
if (copiedNodes.get(sourceChild.getNumber()) == null) {
- destChild = cloneNode(sourceChild,copiedNodes,channels);
+ destChild = cloneNode(sourceChild,copiedNodes);
copiedNodes.put(Integer.valueOf(sourceChild.getNumber()),Integer.valueOf(destChild.getNumber()));
cloned = true;
//Logging
@@ -1518,6 +1535,7 @@
//*** End cloning node
//Create a new relation between the new node and its parent
+
if(!"imageinlinerel".equalsIgnoreCase(rel.getNodeManager().getName()) &&
!"inlinerel".equalsIgnoreCase(rel.getNodeManager().getName())) {
Relation destRel = destNode.createRelation(destChild, relManager);
String relName = destRel.getNodeManager().getName();
if (relName.equalsIgnoreCase("posrel") ||
@@ -1527,6 +1545,8 @@
destRel.setIntValue("pos", rel.getIntValue("pos"));
}
destRel.commit();
+ output.append("[newRel:" + destNode.getNumber() + "," + relName
+ "];");
+ }
@@ -1542,7 +1562,7 @@
destChild.setStringValue("title",
destChild.getStringValue("title") + "-North");
destChild.commit();
}
- output.append("[newRel:" + destNode.getNumber() + "," + relName
+ "];");
+
// if
(destChild.getNodeManager().getName().equalsIgnoreCase("subject")) {
//Now go deeper into the tree
@@ -1558,7 +1578,7 @@
* @param channels
* @return
*/
- public static Node cloneNode(Node localNode,Map<Integer, Integer>
copiedNodes,List<Integer> channels) {
+ public static Node cloneNode(Node localNode,Map<Integer, Integer>
copiedNodes) {
if (isRelation(localNode)) {
return CloneUtil.cloneRelation(localNode);
}
@@ -1566,7 +1586,7 @@
NodeManager localNodeManager = localNode.getNodeManager();
NodeManager nodeManager =
localNode.getCloud().getNodeManager(localNodeManager.getName());
Node newNode = nodeManager.createNode();
-
+ newNode.commit();
FieldIterator fields = localNodeManager.getFields().fieldIterator();
while (fields.hasNext()) {
Field field = fields.nextField();
@@ -1576,7 +1596,7 @@
if (!(fieldName.equals("owner") || fieldName.equals("number") ||
fieldName.equals("otype") ||
(fieldName.indexOf("_") == 0))) {
- cloneNodeField(localNode, newNode,
field,copiedNodes,channels);
+ cloneNodeField(localNode, newNode, field,copiedNodes);
}
}
}
@@ -1596,14 +1616,14 @@
* @param field
* the field to clone
*/
- public static void cloneNodeField(Node sourceNode, Node destinationNode,
Field field,Map<Integer, Integer> copiedNodes,List<Integer> channels) {
+ public static void cloneNodeField(Node sourceNode, Node destinationNode,
Field field,Map<Integer, Integer> copiedNodes) {
String fieldName = field.getName();
if (destinationNode.getNodeManager().hasField(fieldName) == true) {
Field sourceField = sourceNode.getNodeManager().getField(fieldName);
if (sourceField.getState() != Field.STATE_SYSTEM &&
!sourceField.isVirtual()) {
destinationNode.setValueWithoutProcess(fieldName,
- strip(sourceNode,field,copiedNodes,channels));
+ strip(sourceNode,destinationNode,field,copiedNodes));
}
}
}
@@ -1616,8 +1636,8 @@
* @param channels
* @return
*/
- public static Object strip(Node sourceNode,Field field,Map<Integer,
Integer> copiedNodes,List<Integer> channels) {
- return RichText.stripLinkAndImage(sourceNode, field, copiedNodes);
+ public static Object strip(Node sourceNode, Node destinationNode,Field
field,Map<Integer, Integer> copiedNodes) {
+ return RichText.stripLinkAndImage(sourceNode, destinationNode,field,
copiedNodes);
}
/**
* quick test to see if node is a relation by testing fieldnames
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs