1 16 package com.blandware.atleap.model.core; 17 18 import java.util.ArrayList ; 19 import java.util.Collection ; 20 import java.util.HashMap ; 21 import java.util.Iterator ; 22 import java.util.List ; 23 import java.util.Map ; 24 25 40 public abstract class Localizable extends BaseObject { 41 42 44 47 protected Long id; 48 51 protected List contentFields = new ArrayList (); 52 55 protected List menuItems = new ArrayList (); 56 59 protected Long version; 60 61 64 protected String className = getClass().getName(); 65 66 68 76 public Long getId() { 77 return id; 78 } 79 80 85 public void setId(Long id) { 86 this.id = id; 87 } 88 89 97 public List getContentFields() { 98 return contentFields; 99 } 100 101 106 public void setContentFields(List contentFields) { 107 this.contentFields = contentFields; 108 } 109 110 115 public void addContentField(ContentField contentField) { 116 contentField.setOwner(this); 117 contentFields.add(contentField); 118 } 119 120 126 public ContentField updateContentField(ContentField contentField) { 127 ContentField oldContentField = null; 128 if ( !contentField.getOwner().equals(this) ) { 129 int index = contentField.getOwner().contentFields.indexOf(contentField); 130 if (index != -1) 131 oldContentField = (ContentField)contentField.getOwner().contentFields.remove(index); 132 contentFields.add(contentField); 133 contentField.setOwner(this); 134 } 135 return oldContentField; 136 } 137 138 143 public void removeContentField(ContentField contentField) { 144 contentFields.remove(contentField); 145 } 146 147 152 public Map getContentFieldsMap() { 153 Collection collection = getContentFields(); 154 Map map = new HashMap (); 155 for ( Iterator iterator = collection.iterator(); iterator.hasNext(); ) { 156 ContentField contentField = (ContentField) iterator.next(); 157 map.put(contentField.getIdentifier(), contentField); 158 } 159 return map; 160 } 161 162 170 protected List getMenuItems() { 171 return menuItems; 172 } 173 174 179 protected void setMenuItems(List menuItems) { 180 this.menuItems = menuItems; 181 } 182 183 189 public String getClassName() { 190 return className; 191 } 192 193 199 public void setClassName(String className) { 200 } 201 202 209 public Long getVersion() { 210 return version; 211 } 212 213 218 public void setVersion(Long version) { 219 this.version = version; 220 } 221 222 223 } 224 | Popular Tags |