1 24 package org.ofbiz.entity.model; 25 26 import java.util.ArrayList ; 27 import java.util.HashMap ; 28 import java.util.Iterator ; 29 import java.util.List ; 30 import java.util.Map ; 31 32 import org.ofbiz.entity.GenericDelegator; 33 import org.ofbiz.entity.model.ModelViewEntity.ComplexAliasMember; 34 import org.ofbiz.entity.model.ModelViewEntity.ModelAlias; 35 import org.ofbiz.entity.model.ModelViewEntity.ModelAliasAll; 36 import org.ofbiz.entity.model.ModelViewEntity.ModelMemberEntity; 37 import org.ofbiz.entity.model.ModelViewEntity.ModelViewLink; 38 47 public class DynamicViewEntity { 48 public static final String module = DynamicViewEntity.class.getName(); 49 50 51 protected String entityName = "DynamicViewEntity"; 52 53 54 protected String packageName = "org.ofbiz.dynamicview"; 55 56 57 protected String defaultResourceName = ""; 58 59 60 protected String title = ""; 61 62 63 protected Map memberModelMemberEntities = new HashMap (); 64 65 66 protected List aliasAlls = new ArrayList (); 67 68 69 protected List aliases = new ArrayList (); 70 71 72 protected List viewLinks = new ArrayList (); 73 74 75 protected List relations = new ArrayList (); 76 77 public DynamicViewEntity() { 78 } 79 80 public ModelViewEntity makeModelViewEntity(GenericDelegator delegator) { 81 ModelViewEntity modelViewEntity = new ModelViewEntity(this, delegator.getModelReader()); 82 return modelViewEntity; 83 } 84 85 public String getOneRealEntityName() { 86 if (this.memberModelMemberEntities.size() == 0) { 88 return null; 89 } 90 91 ModelMemberEntity modelMemberEntity = (ModelMemberEntity) ((Map.Entry ) this.memberModelMemberEntities.entrySet().iterator().next()).getValue(); 92 return modelMemberEntity.getEntityName(); 93 } 94 95 99 public String getEntityName() { 100 return entityName; 101 } 102 103 107 public void setEntityName(String entityName) { 108 this.entityName = entityName; 109 } 110 111 115 public String getPackageName() { 116 return packageName; 117 } 118 119 123 public void setPackageName(String packageName) { 124 this.packageName = packageName; 125 } 126 127 131 public String getDefaultResourceName() { 132 return defaultResourceName; 133 } 134 135 139 public void setDefaultResourceName(String defaultResourceName) { 140 this.defaultResourceName = defaultResourceName; 141 } 142 143 147 public String getTitle() { 148 return title; 149 } 150 151 155 public void setTitle(String title) { 156 this.title = title; 157 } 158 159 public void addMemberEntity(String entityAlias, String entityName) { 160 ModelMemberEntity modelMemberEntity = new ModelMemberEntity(entityAlias, entityName); 161 this.memberModelMemberEntities.put(entityAlias, modelMemberEntity); 162 } 163 164 public Iterator getModelMemberEntitiesEntryIter() { 165 return this.memberModelMemberEntities.entrySet().iterator(); 166 } 167 168 public void addAliasAll(String entityAlias, String prefix) { 169 ModelAliasAll aliasAll = new ModelAliasAll(entityAlias, prefix); 170 this.aliasAlls.add(aliasAll); 171 } 172 173 public void addAllAliasAllsToList(List addList) { 174 addList.addAll(this.aliasAlls); 175 } 176 177 public void addAlias(String entityAlias, String name) { 178 this.addAlias(entityAlias, name, null, null, null, null, null); 179 } 180 181 182 public void addAlias(String entityAlias, String name, String field, String colAlias, Boolean primKey, Boolean groupBy, String function) { 183 addAlias(entityAlias, name, field, colAlias, primKey, groupBy, function, null); 184 } 185 186 public void addAlias(String entityAlias, String name, String field, String colAlias, Boolean primKey, Boolean groupBy, String function, ComplexAliasMember complexAliasMember) { 187 if (entityAlias == null && complexAliasMember == null) { 188 throw new IllegalArgumentException ("entityAlias cannot be null if this is not a complex alias in call to DynamicViewEntity.addAlias"); 189 } 190 if (name == null) { 191 throw new IllegalArgumentException ("name cannot be null in call to DynamicViewEntity.addAlias"); 192 } 193 194 ModelAlias alias = new ModelAlias(entityAlias, name, field, colAlias, primKey, groupBy, function); 195 if (complexAliasMember != null) { 196 alias.setComplexAliasMember(complexAliasMember); 197 } 198 this.aliases.add(alias); 199 } 200 201 public void addAllAliasesToList(List addList) { 202 addList.addAll(this.aliases); 203 } 204 205 public void addViewLink(String entityAlias, String relEntityAlias, Boolean relOptional, List modelKeyMaps) { 206 ModelViewLink modelViewLink = new ModelViewLink(entityAlias, relEntityAlias, relOptional, modelKeyMaps); 207 this.viewLinks.add(modelViewLink); 208 } 209 210 public void addAllViewLinksToList(List addList) { 211 addList.addAll(this.viewLinks); 212 } 213 214 public void addRelation(String type, String title, String relEntityName, List modelKeyMaps) { 215 ModelRelation relation = new ModelRelation(type, title, relEntityName, null, modelKeyMaps); 216 this.relations.add(relation); 217 } 218 219 public void addAllRelationsToList(List addList) { 220 addList.addAll(this.relations); 221 } 222 } 223 | Popular Tags |