How to override EMail sub classes (NodeCreateSubclassPost)

Hi

CS23.4

I have inherited a module that overrides some functions when you drag and drop a document into classic view, so it can perform some additional checks before deciding if it needs to write into an additional table for later.

Part of the module is this code:

override function Void __Init()

Object	lliApi		= 	$LLIAPI
List initObjs = lliApi.f__InitObjs
Object obj
Dynamic result

//Checking OS Name
for obj in initObjs
if ( obj.OSName == "Document" )

this.fDocument = obj
break
end
end

//
//Over ridding Post call back scripts for document copy, create and move
//

if ( IsDefined(.fDocument) )

List overrideFeatures = {'NodeCreateSubclassPost','NodeCopySubclassPost','NodeMoveSubclassPost','NodeDeleteSubclassPost','NodeDeleteSubclassPre'}
String featureName = ""

for featureName in overrideFeatures

if OS.IsFeature(.fDocument,featureName)

String previousFeatureName = featureName + "_OLD"

if OS.ISFeature(.fDocument,previousFeatureName)

continue
else
//Adding Feature with _OLD having old definition of the Feature.
OS.AddFeature(.fDocument,previousFeatureName)
.fDocument.(previousFeatureName) = .fDocument.(featureName)
end

end

//override
.fDocument.(featureName) = .(featureName)

end
end

end

And from that I can see there is a NodeCreateSubclassPost_OLD for example in LLIAPI::LLNode::Document, and the NodeCreateSubclassPost is now the new code version.

Now the complaint is that it doesn't work for Emails.

I noticed that it does use the overridden functions if you move or copy or delete an Email, but not if you are creating a new one. So an email is a document unless it is created so to speak.

I then found OTEmail module, which has OTEMAIL::LLNode_Document_::EMail.

so I thought, I'll just do what the init function does now, and add email specific bit that I need. So I've added:


object otemail = $OTEMAIL
List initObjs2 = otemail.f__InitObjs


//Checking OS Name
for obj in initObjs2
if ( obj.OSName == "EMail" && obj.OSParent.OSName == "LLNode (Document)" )

this.fEmail = obj
break
end
end

//
if ( IsDefined(.fEmail) )

List overrideFeatures = {'NodeCreateSubclassPost'}
String featureName = ""
String newFeatureName = ""

for featureName in overrideFeatures

if OS.IsFeature(.fEmail,featureName)

String previousFeatureName = featureName + "_OLD"

newFeatureName = featureName + "_NEW"

if OS.ISFeature(.fEmail,previousFeatureName)

//continue
else
//Adding Feature with _OLD having old definition of the Feature.
OS.AddFeature(.fEmail,previousFeatureName)
.fEmail.(previousFeatureName) = .fEmail.(featureName)
end

//override
.fEmail.(featureName) = this.(newFeatureName)

end

end
end

and I created a new NodeCreateClassSubclassPost_NEW function in the module.

Now though, when I start CS or run my new init function in Eclipse, I get a NodeCreateSubclassPost_OLD ok:

but the original NodeCreateSubclassPost hasn't change to my new function, and I can't work out why.

Any pointers please?

thanks Guy.

Best Answer

  • Guy Walker
    #2 Answer ✓

    Hi appuq, thanks for the responses.

    Yes, I had a feeling it wasn't the way forward, but it was what was done already for Documents so I tried to copy it.

    In the end I found a AddVersionPost callback I could use and that seems to have solved it.

    Guy.

Answers

  • appuq
    appuq Member

    What you are running into is an overriding technique practiced by great stalwarts of OT (Chris Wester, Hans Stoop of CustomizationsRT).I cannot go into much detail here but what you are seeing I think is, how do I explain this…

    OT Developers wrote pretty clean code on lliapi::Node

    Then someone added lliapi::Node:Document so Document inherits everything in Node

    Then OT wants to add a new subtype called Email so if you look in your screencap Email is in a different Ospace (hence the red color) and they are at run time "PUSHING" the Document's feature called NodeCreateSubClassPost using the Chris Webster way with an indication to other developers like you (CW was pretty good at at that)

    If you have access to the old Documentation discussions of yesterday year you will actually see Chris Webster's posting on this technique(HTML map,otoverride are all utility modules that were used by oscripters at one point)

    So this line is what is pushing it

    if ( IsDefined(.fEmail) )
    	List overrideFeatures = {'NodeCreateSubclassPost'}
      
    so theoretically if you subclass(orphan Email) you get to do what you need.
    
    
    Please wait and see if any other Oscripters in this forum gives you a hand,for it is an adavnced topic and not officially supported:)
    Do try to read the topics I mentioned as well.
    
    
    

  • appuq
    appuq Member

    BTW today I looked at a CS server and I don't see that CW implementation.I think that technique fell out of favor. Is there not a node callback that can capture what needs to be done at a later point?

  • Guy Walker
    #5 Answer ✓

    Hi appuq, thanks for the responses.

    Yes, I had a feeling it wasn't the way forward, but it was what was done already for Documents so I tried to copy it.

    In the end I found a AddVersionPost callback I could use and that seems to have solved it.

    Guy.

  • appuq
    appuq Member

    BTW in case you or someone is interested take a look at CW on these threads

    https://knowledge.opentext.com/knowledge/cs.dll?func=ll&objId=17342512&objAction=viewincontainer&ShowReplyEntry=17345935&_ga=2.155091000.104260785.1711368660-312173633.1710423905#forum_topic_17345935