Download Blaze Trial
Close To access this section, please choose the Community Neighborhood in which you have the most interest.

» Business Rules Management
» Collections & Recovery
» Fraud Management
» Risk Management
» Scoring
Close To access this section, please choose the Community Neighborhood in which you have the most interest.

» Business Rules Management
» Collections & Recovery
» Fraud Management
» Risk Management
» Scoring
Reply
Visitor
tommymar
Posts: 1
Registered: 01-11-2012

Create NdRomEntry copy (API)

[ Edited ]

Hi,

 

in my application I want to copy some NdRomEntry from one project to another. I don't known what kind of source entry (function, ruleset, template, instance, provider, ...) is selected by user. Exists Download Free Programs the way, how realize this operation using NdPromItemContent from source object without creating new one, empty using correct factory like NdPromSrlConstructContentFactory for the functions.

 

My code:

NdPromItem sourcePromItem = (NdPromItem) sourceProject.lookupEntry(NdLocationFactory.createLocation(relativeLocation(element.getLocation().toString(), sourceProject)));

 

NdRomSchemaManager sourceSchemaManager = sourceProject.getRomConnectionContext().getSchemaManager(); NdRomSchemaElement sourceSchemaElement = sourceSchemaManager.lookupSchemaElement(sourcePromItem);

 

NdRomSchemaElementInfo info = sourceSchemaElement.getSchemaElementInfo(); NdRomSchemaManager targetSchemaManager = targetDir.getProject().getRomConnectionContext().getSchemaManager();

NdRomSchemaElement targetSchemaElement = targetSchemaManager.lookupSchemaElement(info.getType(), info.getSubType(), info.getContentType(), info.getTarget());

NdPromItemFactory factoryTarget = targetSchemaElement.getItemFactory();

 

NdPromItem newItem = factoryTarget.newItem(sourcePromItem.getItemContent(),targetDir.getProject()); targetDir.addItem(newItem);

newItem.save();

 

The first problem occures, when I try copy some function. FactoryTarget.newItem throws an exception:

com.blazesoft.template.engine.NdTemplateRuntimeException: Content element already has a parent

 

Is it possible in some way reset, delete sourcePromItem parent? How solve this issue? I dont want create blank object and set all the stuffs like: name, body, generic type, comment content, parameters, value holders, ...

 

Thanks for advice,