So, I'm trying to make a formal module merging tool right now, and everything is working so far, except link copy. Here's how we copy
(Yes, it's more of a destroy and rebuild tool, than merging, but still, end result is the same)
The problem is, for incoming links, I'm told the source object of the link is inaccessible, even though the formal module is loaded, and I can access and do whatever I want with it. Here's the code to copy Incoming Links
for o in entire PRBaseline do
{
//Once current PBS has been emptied, start recovering objects from baseline
print "Inside Object : " o."IE PUID" "\n" ""
//Once current PBS is emptied & reconstructed to this PBS baseline, do links.
Link incomingLink
Link outLink
Object sourceObject
Object targetObject
for incomingLink in all(o <- "*") do //Iterate on all incoming baselined links, and load source module
{
ModName_ srcModRef = source(incomingLink)
Module temp = edit(fullName(srcModRef),true)
sourceObject = source(incomingLink)
Object oPRCurr
print name srcModRef
print sourceObject."IE PUID" ""
for oPRCurr in modOldPR do
{
print "Currently on Object : " oPRCurr."IE PUID" " and object : " o."IE PUID" "\n" ""
if (oPRCurr."IE PUID" "" == o."IE PUID" "")
{
createLinkset(fullName(srcModRef), fullName(modOldPR), "Test")
print sourceObject."IE PUID" "\n" ""
sourceObject -> "/Test_Access/Test" -> oPRCurr
print "Creating link between source object : " sourceObject."IE PUID" " & target object : " oPRCurr."IE PUID" " from" name srcModRef "\n" ""
}
}
}
}
As for outgoing links I'm not even able to recover the target object of the link, even though I've loaded in edit mode the targeted module
// Continuation of preceding code block
for outLink in all(o -> "*") do
{
ModName_ srcModRef = target(outLink)
print name srcModRef " est la cible \n" ""
Module temp = read(fullName(srcModRef),true)
targetObject = target(outLink)
Object oPRCurr
print name srcModRef
for oPRCurr in modOldPR do
{
print "Currently on Object : " oPRCurr."IE PUID" " and object : " o."IE PUID" "\n" ""
if (oPRCurr."IE PUID" "" == o."IE PUID" "")
{
createLinkset(fullName(srcModRef), fullName(modOldPR), "Test")
oPRCurr -> "/Test_Access/Test" -> targetObject
print "Creating link between target object : " " " " & source object : " oPRCurr."IE PUID" " from" name srcModRef "\n" ""
}
}
}
I'm sorry if I'm already asking a question that's been asked before, but I can't figure out why it doesn't want to work, and I've tried a lot of solutions already.
So, I actually found the answer after a whole lot more of digging. I'll post it below to help people that need to do this.
So, first of all, regarding incoming links the problem to not having access to the link was actually that I recoverd the baseline object, and not the current version object, like that, I was therefore only able to recover info, not edit the object (As it should be !). Therefore the solutionn should be then to actually open the CURRENT module, and find the object via a comparaison key (I hope you have a way to find the object back). Afterwards, I just proceed as before, with the only difference being that I have the current object, and not it's baselined counterpart.
For outgoing links, the matter was a little trickier, I was able to recover my target module name BUT I couldn't load objects from it for the life of me. The problem was, that you have to actually open the baselined module, to recover the baselined object, to recreate the link. To do so, I loaded it like this (know, that I'm iterating on Baseline Sets in this code, that's what the bs variable is)
Module temp = load(test,baseline(major bs, minor bs, suffix bs), true)
and proceeded as before. Now the scripts works perfectly well, so if you need precisions on the way I do this, feel free to ask below, I'll answer to the best of my capacity.