cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrey Razumovsky <razumovsky.and...@gmail.com>
Subject Re: Creating multiple datamaps on the fly
Date Thu, 04 Jun 2009 11:21:54 GMT
Hi,

I'm not sure that I correctly understood your problem, but cloning datamap
is definitely possible. Alas, I don't know about any ready methods for that.
You can either clone DataMap manually (i.e. create new map with new name,
copy properties from original map, put there entities etc. with new names
and then attach it to domain) or clone whole datamap via serialization and
then change names of its "entries". Sort of second way is implemented in
modeler's PasteAction.paste(...). Note that entity names must be unique in
whole DataDomain.

Andrey

2009/6/4 Lawrence Gerstley <lawgers@gmail.com>

> Hello,
>
> I'm trying to create multiple DataMaps and attach them to my DataDomain on
> the fly in an application. The DataMap itself that I created with the
> modeler is fine, but I want to be able to create new ones on demand to point
> to a new table set in my db. So, my DataMap might consist of DbEntities
> whose prefixes all start with "lba1_". I can iterate through the map
> attached to the domain loaded up like so:
> ================================================================
> for (DbEntity entity : currentMap.getDbEntities()) {
>  if (entity.getName().indexOf("_") > 0) {
>    entity.setName(entity.getName().replaceFirst(".*_", instancePrefix +
> "_"));
>  }
> }
> ================================================================
> I'd like to clone the DataMap and then iterate through it with the code
> above, and then add that DataMap to the DataDomain. Is that possible?
>
> Thanks,
>
> Lawrence
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message