use of org.apache.cayenne.map.MappingNamespace in project cayenne by apache.
the class ProjectUtil method setDbEntityName.
/**
* Renames a DbEntity and changes the name of all references.
*/
public static void setDbEntityName(DbEntity entity, String newName) {
String oldName = entity.getName();
// If name hasn't changed, just return
if (Util.nullSafeEquals(oldName, newName)) {
return;
}
entity.setName(newName);
DataMap map = entity.getDataMap();
if (map != null) {
map.removeDbEntity(oldName, false);
map.addDbEntity(entity);
// important - clear parent namespace:
MappingNamespace ns = map.getNamespace();
if (ns instanceof EntityResolver) {
((EntityResolver) ns).refreshMappingCache();
}
}
}
use of org.apache.cayenne.map.MappingNamespace in project cayenne by apache.
the class ProjectUtil method setObjEntityName.
public static void setObjEntityName(DataMap map, ObjEntity entity, String newName) {
String oldName = entity.getName();
// If name hasn't changed, just return
if (Util.nullSafeEquals(oldName, newName)) {
return;
}
entity.setName(newName);
map.removeObjEntity(oldName, false);
map.addObjEntity(entity);
// important - clear parent namespace:
MappingNamespace ns = map.getNamespace();
if (ns instanceof EntityResolver) {
((EntityResolver) ns).refreshMappingCache();
}
}
use of org.apache.cayenne.map.MappingNamespace in project cayenne by apache.
the class ProjectUtil method setQueryName.
public static void setQueryName(DataMap map, QueryDescriptor query, String newName) {
String oldName = query.getName();
// If name hasn't changed, just return
if (Util.nullSafeEquals(oldName, newName)) {
return;
}
query.setName(newName);
query.setDataMap(map);
map.removeQueryDescriptor(oldName);
map.addQueryDescriptor(query);
// important - clear parent namespace:
MappingNamespace ns = map.getNamespace();
if (ns instanceof EntityResolver) {
((EntityResolver) ns).refreshMappingCache();
}
}
use of org.apache.cayenne.map.MappingNamespace in project cayenne by apache.
the class ProjectUtil method setProcedureName.
public static void setProcedureName(DataMap map, Procedure procedure, String newName) {
String oldName = procedure.getName();
// If name hasn't changed, just return
if (Util.nullSafeEquals(oldName, newName)) {
return;
}
procedure.setName(newName);
map.removeProcedure(oldName);
map.addProcedure(procedure);
// important - clear parent namespace:
MappingNamespace ns = map.getNamespace();
if (ns instanceof EntityResolver) {
((EntityResolver) ns).refreshMappingCache();
}
}
Aggregations