Book a Demo

Author Topic: How to programatically create connector tags?  (Read 6392 times)

danm

  • EA User
  • **
  • Posts: 88
  • Karma: +0/-0
    • View Profile
How to programatically create connector tags?
« on: December 28, 2007, 04:12:57 pm »
Hi,
  There's a bug in EA that connector tags are ignored if they are created from a template (via the usual Tag{name="" value=""} syntax). Darn, OK I hope this will get fixed soon. In the meantime I've been trying to find a way to do it via an add in, but I can't find any method. Only query methods, no set methods. Any ideas?



danm

  • EA User
  • **
  • Posts: 88
  • Karma: +0/-0
    • View Profile
Re: How to programatically create connector tags?
« Reply #1 on: December 29, 2007, 07:41:36 am »
Code: [Select]

       public object EXEC_connectorAddTag(EA.Repository repository, object argsObject)
       {
           string[] args = (string[])argsObject;
           string connectorGUID = args[0];
           string tagName = args[1];
           string tagValue = args[2];
           object aTag;

           EA.Connector connector = repository.GetConnectorByGuid(connectorGUID);
           
           aTag = connector.TaggedValues.AddNew(tagName,tagValue);
           connector.TaggedValues.Refresh();
           connector.Update();
   
           return "";
       }


This code doesn't work. I can't continue until I can add a tag to a connector but nothing works ....  :(

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: How to programatically create connector tags?
« Reply #2 on: December 29, 2007, 08:20:20 am »
aTag.Update()
No, you can't have it!

danm

  • EA User
  • **
  • Posts: 88
  • Karma: +0/-0
    • View Profile
Re: How to programatically create connector tags?
« Reply #3 on: December 29, 2007, 09:52:20 am »
Thanks - tried that, but aTag doesn't contain ".Update()" because it's an object. I tried casting it to various types, EA.TaggedValue for instance, but those raise a com exception. brrrrrr



«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
No, you can't have it!

danm

  • EA User
  • **
  • Posts: 88
  • Karma: +0/-0
    • View Profile
Re: How to programatically create connector tags?
« Reply #5 on: December 29, 2007, 07:19:08 pm »
Awesome! That worked.

Last problem - the tags are being applied to the OLD connector, not the new transformed connector. I'm using as my GUID connectorGUID which is the old one as it turns out (I thought the same GUID would be used for both.) Do you have any tips on how to get a handle to the transformed GUID, from within the transformation?

Thanks!!!!!!!

jeshaw2

  • EA User
  • **
  • Posts: 701
  • Karma: +0/-0
  • I'm a Singleton, what pattern are you?
    • View Profile
Re: How to programatically create connector tags?
« Reply #6 on: December 29, 2007, 10:09:32 pm »
Quote
Awesome! That worked.  
 Sorry, but what worked?  Can you post the full line of code for the update?

Thanks
Verbal Use Cases aren't worth the paper they are written upon.

danm

  • EA User
  • **
  • Posts: 88
  • Karma: +0/-0
    • View Profile
Re: How to programatically create connector tags?
« Reply #7 on: December 30, 2007, 07:33:47 am »
Code: [Select]

public object EXEC_connectorAddTag(EA.Repository repository, object argsObject) {
           string[] args = (string[])argsObject;
           string connectorGUID = args[0];
           string tagName = args[1];
           string tagValue = args[2];
           EA.ConnectorTag aTag;

           EA.Connector connector = repository.GetConnectorByGuid(connectorGUID);
           EA.ConnectorEnd clientEnd = connector.ClientEnd;
         
           aTag = (EA.ConnectorTag) connector.TaggedValues.AddNew(tagName,tagValue);
           aTag.Update();

           connector.TaggedValues.Refresh();
           connector.Update();
           return "";
}


This function takes a connector GUID and a tag name and value, and creates the tag on the connector. Presently as far as I can tell, EA ignores all attempts to create connector tags from within a transformation, so you need to do it via an add-in.

The final Refresh() and Update() are probably unnecessary.
« Last Edit: December 30, 2007, 07:34:13 am by danm »