1 23 24 package org.infoglue.cms.treeservice.ss; 25 26 import java.util.ArrayList ; 27 import java.util.Collection ; 28 import java.util.Iterator ; 29 import java.util.List ; 30 31 import org.infoglue.cms.controllers.kernel.impl.simple.ContentController; 32 import org.infoglue.cms.controllers.kernel.impl.simple.ContentControllerProxy; 33 import org.infoglue.cms.controllers.kernel.impl.simple.ContentVersionController; 34 import org.infoglue.cms.entities.content.ContentVO; 35 import org.infoglue.cms.entities.content.ContentVersionVO; 36 import org.infoglue.cms.exception.ConstraintException; 37 import org.infoglue.cms.exception.SystemException; 38 39 import com.frovi.ss.Tree.BaseNode; 40 import com.frovi.ss.Tree.BaseNodeSupplier; 41 42 48 public class ContentNodeVersionSupplier extends BaseNodeSupplier 49 { 50 51 private ArrayList cacheLeafs; 53 54 55 public ContentNodeVersionSupplier(Integer repositoryId, String userName) throws SystemException 56 { 57 ContentVO vo =null; 58 try 59 { 60 vo = ContentControllerProxy.getController().getRootContentVO(repositoryId, userName); 61 BaseNode rootNode = new ContentNodeImpl(); 62 rootNode.setChildren(true); 63 rootNode.setId(vo.getId()); 64 rootNode.setTitle(vo.getName()); 65 rootNode.setContainer(vo.getIsBranch().booleanValue()); 66 setRootNode(rootNode); 67 } 68 catch (ConstraintException e) 69 { 70 } 71 catch (SystemException e) 72 { 73 } 74 75 } 76 79 public boolean hasChildren() 80 { 81 return false; 82 } 83 84 87 public Collection getChildContainerNodes(Integer parentNode) 88 { 89 ArrayList ret = new ArrayList (); 90 cacheLeafs = new ArrayList (); 91 92 if (parentNode.intValue() < 0 ) 93 { 94 return ret; 95 } 96 97 List l = null; 98 try 99 { 100 l = ContentController.getContentController().getContentChildrenVOList(parentNode); 101 } 102 catch (ConstraintException e) 103 { 104 } 105 catch (SystemException e) 106 { 107 } 108 109 Iterator i = l.iterator(); 111 while(i.hasNext()) 112 { 113 ContentVO vo = (ContentVO) i.next(); 114 if (vo.getIsBranch().booleanValue()) 115 { 116 BaseNode node = new ContentNodeImpl(); 117 node.setId(vo.getId()); 118 node.setContainer(true); 119 120 node.setChildren((vo.getChildCount().intValue() > 0)); 122 node.setTitle(vo.getName()); 123 124 ret.add(node); 125 } 126 } 127 i = l.iterator(); 128 while(i.hasNext()) 129 { 130 ContentVO vo = (ContentVO) i.next(); 131 if (!vo.getIsBranch().booleanValue()) 132 { 133 135 BaseNode node = new ContentNodeImpl(); 136 node.setId( new Integer (- vo.getId().intValue()) ); 137 node.setContainer(true); 138 node.setTitle(vo.getName()); 139 node.setChildren((vo.getChildCount().intValue() > 0)); 140 ret.add(node); 141 } 142 } 143 144 return ret; 145 } 146 147 150 public Collection getChildLeafNodes(Integer parentNode) 151 { 152 ArrayList ret = new ArrayList (); 153 if (parentNode.intValue() >= 0) 154 return ret; 155 156 List l = null; 157 try 158 { 159 l = ContentVersionController.getContentVersionController().getContentVersionVOWithParent(new Integer (- parentNode.intValue())); 160 } 161 catch (SystemException e) 162 { 163 } 164 165 Iterator i = l.iterator(); 166 while(i.hasNext()) 167 { 168 ContentVersionVO vo = (ContentVersionVO) i.next(); 169 ContentNodeImpl node = new ContentNodeImpl(); 170 node.setId(vo.getId()); 171 node.setState(vo.getStateId()); 172 node.setContainer(false); 173 node.setTitle(vo.getVersionComment() + " (" + vo.getModifiedDateTime() + ")"); 174 node.getParameters().put("languageId", vo.getLanguageId()); 175 node.getParameters().put("languageName", vo.getLanguageName()); 176 177 ret.add(node); 178 179 } 180 181 return ret; 182 } 183 184 } 185 | Popular Tags |