1 56 package org.objectstyle.cayenne.wocompat; 57 58 import java.util.ArrayList ; 59 import java.util.Collection ; 60 import java.util.Collections ; 61 import java.util.Map ; 62 63 import org.objectstyle.cayenne.exp.Expression; 64 import org.objectstyle.cayenne.map.ObjEntity; 65 import org.objectstyle.cayenne.query.Query; 66 67 74 public class EOObjEntity extends ObjEntity { 75 76 protected boolean isClientEntity; 78 protected boolean hasSuperClass; 80 protected boolean isAbstractEntity; 82 83 private Collection filteredQueries; 84 85 public EOObjEntity() { 86 super(); 87 } 88 89 90 public EOObjEntity(String s) { 91 super(s); 92 } 93 94 99 public void setHasSuperClass(boolean value) { 100 hasSuperClass = value; 101 } 102 103 108 public boolean getHasSuperClass() { 109 return hasSuperClass; 110 } 111 112 117 public void setIsClientEntity(boolean value) { 118 isClientEntity = value; 119 } 120 121 126 public boolean getIsClientEntity() { 127 return isClientEntity; 128 } 129 130 135 public void setIsAbstractEntity(boolean value) { 136 isAbstractEntity = value; 137 } 138 139 144 public boolean getIsAbstractEntity() { 145 return isAbstractEntity; 146 } 147 148 155 public String qualifiedQueryName(String queryName) { 156 return getName() + "_" + queryName; 157 } 158 159 162 public String localQueryName(String qualifiedQueryName) { 163 return (qualifiedQueryName != null && qualifiedQueryName.startsWith(getName() 164 + "_")) 165 ? qualifiedQueryName.substring(getName().length() + 1) 166 : qualifiedQueryName; 167 } 168 169 174 public EOQuery getEOQuery(String queryName) { 175 Query query = getDataMap().getQuery(qualifiedQueryName(queryName)); 176 if (query instanceof EOQuery) { 177 return (EOQuery) query; 178 } 179 180 return null; 181 } 182 183 188 public Collection getEOQueries() { 189 if (filteredQueries == null) { 190 Collection queries = getDataMap().getQueries(); 191 if (queries.isEmpty()) { 192 filteredQueries = Collections.EMPTY_LIST; 193 } else { 194 Map params = Collections.singletonMap("root", EOObjEntity.this); 195 Expression filter = Expression 196 .fromString("root = $root") 197 .expWithParameters(params); 198 199 filteredQueries = filter.filter(queries, new ArrayList ()); 200 } 201 } 202 203 return filteredQueries; 204 } 205 206 } | Popular Tags |