public Component getEntityByCFCName(String cfcName, boolean unique) throws PageException { String name = cfcName; int pointIndex = cfcName.lastIndexOf('.'); if (pointIndex != -1) { name = cfcName.substring(pointIndex + 1); } else cfcName = null; ComponentPro cfc; String[] names = null; // search array (array exist when cfcs is in generation) if (arr != null) { names = new String[arr.size()]; int index = 0; Iterator<ComponentPro> it2 = arr.iterator(); while (it2.hasNext()) { cfc = it2.next(); names[index++] = cfc.getName(); if (isEntity(cfc, cfcName, name)) // if(cfc.equalTo(name)) return unique ? (Component) cfc.duplicate(false) : cfc; } } else { // search cfcs Iterator<Entry<String, CFCInfo>> it = cfcs.entrySet().iterator(); Entry<String, CFCInfo> entry; while (it.hasNext()) { entry = it.next(); cfc = entry.getValue().getCFC(); if (isEntity(cfc, cfcName, name)) // if(cfc.instanceOf(name)) return unique ? (Component) cfc.duplicate(false) : cfc; // if(name.equalsIgnoreCase(HibernateCaster.getEntityName(cfc))) // return cfc; } names = cfcs.keySet().toArray(new String[cfcs.size()]); } // search by entityname //TODO is this ok? CFCInfo info = cfcs.get(name.toLowerCase()); if (info != null) { cfc = info.getCFC(); return unique ? (Component) cfc.duplicate(false) : cfc; } throw new ORMException( this, "entity [" + name + "] " + (StringUtil.isEmpty(cfcName) ? "" : "with cfc name [" + cfcName + "] ") + "does not exist, existing entities are [" + railo.runtime.type.List.arrayToList(names, ", ") + "]"); }
public Component getEntityByEntityName(String entityName, boolean unique) throws PageException { ComponentPro cfc; CFCInfo info = cfcs.get(entityName.toLowerCase()); if (info != null) { cfc = info.getCFC(); return unique ? (Component) cfc.duplicate(false) : cfc; } if (arr != null) { Iterator<ComponentPro> it2 = arr.iterator(); while (it2.hasNext()) { cfc = it2.next(); if (HibernateCaster.getEntityName(cfc).equalsIgnoreCase(entityName)) return unique ? (Component) cfc.duplicate(false) : cfc; } } throw new ORMException(this, "entity [" + entityName + "] does not exist"); }
private ComponentPro _create(PageContext pc, String entityName, boolean unique) throws PageException { CFCInfo info = cfcs.get(id(entityName)); if (info != null) { ComponentPro cfc = info.getCFC(); if (unique) { cfc = (ComponentPro) cfc.duplicate(false); if (cfc.contains(pc, INIT)) cfc.call(pc, "init", new Object[] {}); } return cfc; } return null; }