1 16 19 20 package org.apache.pluto.portalImpl.om.entity.impl; 21 22 import java.util.ArrayList ; 23 import java.util.Collection ; 24 import java.util.Iterator ; 25 26 import org.apache.pluto.om.common.ObjectID; 27 import org.apache.pluto.om.entity.PortletApplicationEntity; 28 import org.apache.pluto.om.entity.PortletApplicationEntityList; 29 import org.apache.pluto.om.entity.PortletApplicationEntityListCtrl; 30 import org.apache.pluto.portalImpl.om.common.AbstractSupportSet; 31 import org.apache.pluto.util.StringUtils; 32 33 public class PortletApplicationEntityListImpl extends AbstractSupportSet 34 implements PortletApplicationEntityList, PortletApplicationEntityListCtrl, java.io.Serializable , 35 org.apache.pluto.portalImpl.om.common.Support { 36 37 39 public PortletApplicationEntity get(ObjectID objectId) 40 { 41 Iterator iterator = this.iterator(); 42 while (iterator.hasNext()) { 43 PortletApplicationEntity portletApplicationEntity = (PortletApplicationEntity)iterator.next(); 44 if (portletApplicationEntity.getId().equals(objectId)) { 45 return portletApplicationEntity; 46 } 47 } 48 return null; 49 } 50 51 53 public PortletApplicationEntity add(String definitionId) { 54 PortletApplicationEntityImpl entity = new PortletApplicationEntityImpl(); 55 56 int id = -1; 57 for (Iterator iter = iterator(); iter.hasNext();) { 58 PortletApplicationEntityImpl ent = (PortletApplicationEntityImpl)iter.next(); 59 try { 60 id = Math.max(id, Integer.parseInt(ent.getCastorId())); 61 } catch (NumberFormatException e) { 62 } 64 } 65 entity.setId(Integer.toString(++id)); 66 entity.setDefinitionId(definitionId); 67 68 add(entity); 69 70 return entity; 71 } 72 73 75 public void postLoad(Object parameter) throws Exception 76 { 77 this.clear(); 78 this.addAll(castorApplications); 79 } 80 81 public void preBuild(Object parameter) throws Exception 82 { 83 Iterator iterator = this.iterator(); 84 while (iterator.hasNext()) { 85 ((PortletApplicationEntityImpl)iterator.next()).preBuild(this); 86 } 87 } 88 89 public void postBuild(Object parameter) throws Exception 90 { 91 } 92 93 public void preStore(Object parameter) throws Exception 94 { 95 castorApplications.clear(); 96 castorApplications.addAll(this); 97 } 98 99 public void postStore(Object parameter) throws Exception 100 { 101 } 102 103 105 107 public PortletApplicationEntity get(String objectId) 108 { 109 Iterator iterator = this.iterator(); 110 while (iterator.hasNext()) { 111 PortletApplicationEntity portletApplicationEntity = (PortletApplicationEntity)iterator.next(); 112 if (portletApplicationEntity.getId().toString().equals(objectId)) { 113 return portletApplicationEntity; 114 } 115 } 116 return null; 117 } 118 119 121 public String toString() 122 { 123 return toString(0); 124 } 125 126 public String toString(int indent) 127 { 128 StringBuffer buffer = new StringBuffer (1000); 129 StringUtils.newLine(buffer,indent); 130 buffer.append(getClass().toString()); buffer.append(":"); 131 StringUtils.newLine(buffer,indent); 132 buffer.append("{"); 133 Iterator iterator = this.iterator(); 134 if (iterator.hasNext()) { 135 StringUtils.newLine(buffer,indent); 136 buffer.append("Portlet Application Entities:"); 137 } 138 while (iterator.hasNext()) { 139 buffer.append(((PortletApplicationEntityImpl)iterator.next()).toString(indent+2)); 140 } 141 StringUtils.newLine(buffer,indent); 142 buffer.append("}"); 143 return buffer.toString(); 144 } 145 146 148 private Collection castorApplications = new ArrayList (); 149 150 public Collection getCastorApplications() 151 { 152 return castorApplications; 153 } 154 } 155 | Popular Tags |