Hi,

curios-one a écrit :
Hello,
I would like to know if it possible to migrate content from a portal type to another one.

Unfortunately you cannot change a document portal type even if you have common schemas: other issues need to be taken care of. But having common schemas would make your migration easier: a script could take your document datamodel, and use it to create a new document.
The datamodel is just a mapping between field names and values.

This is what I would like to accomplish:
I have a portal_type called football_match, the schemas used are: metadata common football_match flexible_content.
The football_match schema contains:
Team_A (CPS String List Field)
Team_B (CPS String List Field)
Date_and_time (CPS DateTime Field)
Place (CPS String List Field)
Result (CPS String Field)

The other portal_type is called match and uses the following schemas: metadata common match flexible_content
The match schema contains:
Team_A (CPS String List Field)
Team_B (CPS String List Field)
Date (CPS DateTime Field)
Location (CPS String Field)
Result (CPS String Field)

This should be the migration mapping between the schemas of the two portal types
Team_A = Team_A
Team_B = Team_B
Date_and_time --> Date
Place --> Location
Result = Result

Is it possible to do something like that? if yes, could you please suggest me some pointers, as existing scripts, where to start from?

Here is a suggestion (not tested), given "old_proxy", using your football_match portal type, and any "container" where you want to create the new proxy:

datamodel = old_proxy.getContent().getDataModel(proxy=old_proxy)
# change what's needed on the datamodel
datamodel.set('Date', datamodel.get('Date_and_time'))
datamodel.set('Location', datamodel.get('Place'))
# create a new document
new_proxy = container.invokeFactory('match', old_proxy.getId(), datamodel=datamodel)

If you'd like to do that for every document, you can query the catalog and search on your portal type.

Regards,

--
Anahide Tchertchian, Nuxeo
Mail: [EMAIL PROTECTED] - Tel: +33 (0)1 40 33 71 60
http://www.nuxeo.com - http://www.cps-project.org
_______________________________________________
cps-users mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/cps-users

Reply via email to