Topic
  • 8 replies
  • Latest Post - ‏2014-03-19T15:10:12Z by M_vdLaan
MyDeveloerWorks
MyDeveloerWorks
41 Posts

Pinned topic Filters and External links

‏2014-03-11T21:48:50Z |

Hello again Dxlers,

I have a dxl script that generates views and looks for missing links. Just before finishing I ran a test that did not work with requirements with external links. 

How is the filter set up to detect external links?

best regards

Colm

  • MyDeveloerWorks
    MyDeveloerWorks
    41 Posts
    ACCEPTED ANSWER

    Re: Filters and External links

    ‏2014-03-13T10:13:55Z  
    • llandale
    • ‏2014-03-12T15:15:37Z

    Don't recall if you can do it directly.  But you can certainly:

    • "HasExternalLink" - boolean Attr-DXL, true if the object has an external link
      • bool Has = false
      • for every external link; Has = true
      • obj.attrDXLName = Has
    • Filter on that attribute.

    -Louie

    Hello Louie,.

    I tried going the iteration as follows, but all my attributes stayed at false, despite some having external links
    bool Has= false
    Object o = current
    ExternalLink el 
    //Iterate over outward links 
    for el in o->"" do  
     Has = true
    }
    o.attrDXLName = Has
  • sekrbo
    sekrbo
    44 Posts
    ACCEPTED ANSWER

    Re: Filters and External links

    ‏2014-03-13T14:37:55Z  

    In the end I got this to work.  

    I also forgot to execute the menu item "refresh dxl Attributes"

    bool Has= false
    Object o = current
    ExternalLink el 
    //Iterate over outward links 
    for el in o->"" do  
     Has = true
    }
    for el in o<-"" do  
     Has = true
    }
    o.attrDXLName = Has

    Well since it's a DXL attribute you're working on you can skip the Object o = current, as the variable obj is already defined as the current object... thus giving you:

    bool Has= false
    ExternalLink el
    //Iterate over outward links
    for el in obj->"" do
    {
        Has = true
    }
    for el in obj<-"" do
    {
        Has = true
    }
    obj.attrDXLName = Has

    /sekrbo

  • llandale
    llandale
    3035 Posts

    Re: Filters and External links

    ‏2014-03-12T15:15:37Z  

    Don't recall if you can do it directly.  But you can certainly:

    • "HasExternalLink" - boolean Attr-DXL, true if the object has an external link
      • bool Has = false
      • for every external link; Has = true
      • obj.attrDXLName = Has
    • Filter on that attribute.

    -Louie

  • MyDeveloerWorks
    MyDeveloerWorks
    41 Posts

    Re: Filters and External links

    ‏2014-03-13T10:13:55Z  
    • llandale
    • ‏2014-03-12T15:15:37Z

    Don't recall if you can do it directly.  But you can certainly:

    • "HasExternalLink" - boolean Attr-DXL, true if the object has an external link
      • bool Has = false
      • for every external link; Has = true
      • obj.attrDXLName = Has
    • Filter on that attribute.

    -Louie

    Hello Louie,.

    I tried going the iteration as follows, but all my attributes stayed at false, despite some having external links
    bool Has= false
    Object o = current
    ExternalLink el 
    //Iterate over outward links 
    for el in o->"" do  
     Has = true
    }
    o.attrDXLName = Has
  • sekrbo
    sekrbo
    44 Posts

    Re: Filters and External links

    ‏2014-03-13T12:16:28Z  

    Hello Louie,.

    I tried going the iteration as follows, but all my attributes stayed at false, despite some having external links
    bool Has= false
    Object o = current
    ExternalLink el 
    //Iterate over outward links 
    for el in o->"" do  
     Has = true
    }
    o.attrDXLName = Has

    Well the DXL Help says:

    for all outgoing external links
    Declaration
    for extLink in (Object o) -> string ""
    where:
    extLink is a variable of type ExternalLink

    ExternalLink el
    Object o
    bool bHas

    for o in current Module do {
        bHas = false
        for el in o -> "" do {
            bHas = true
        }
        print identifier (o) ": " bHas "\n"
    }

    That works for me...

    /sekrbo

  • MyDeveloerWorks
    MyDeveloerWorks
    41 Posts

    Re: Filters and External links

    ‏2014-03-13T14:07:21Z  

    Hello Louie,.

    I tried going the iteration as follows, but all my attributes stayed at false, despite some having external links
    bool Has= false
    Object o = current
    ExternalLink el 
    //Iterate over outward links 
    for el in o->"" do  
     Has = true
    }
    o.attrDXLName = Has

    In the end I got this to work.  

    I also forgot to execute the menu item "refresh dxl Attributes"

    bool Has= false
    Object o = current
    ExternalLink el 
    //Iterate over outward links 
    for el in o->"" do  
     Has = true
    }
    for el in o<-"" do  
     Has = true
    }
    o.attrDXLName = Has
  • MyDeveloerWorks
    MyDeveloerWorks
    41 Posts

    Re: Filters and External links

    ‏2014-03-13T14:10:05Z  
    • sekrbo
    • ‏2014-03-13T12:16:28Z

    Well the DXL Help says:

    for all outgoing external links
    Declaration
    for extLink in (Object o) -> string ""
    where:
    extLink is a variable of type ExternalLink

    ExternalLink el
    Object o
    bool bHas

    for o in current Module do {
        bHas = false
        for el in o -> "" do {
            bHas = true
        }
        print identifier (o) ": " bHas "\n"
    }

    That works for me...

    /sekrbo

    Thanks for the contribution Sekrbo. That code was useful for testing in the dxl editor.

     

     

  • sekrbo
    sekrbo
    44 Posts

    Re: Filters and External links

    ‏2014-03-13T14:37:55Z  

    In the end I got this to work.  

    I also forgot to execute the menu item "refresh dxl Attributes"

    bool Has= false
    Object o = current
    ExternalLink el 
    //Iterate over outward links 
    for el in o->"" do  
     Has = true
    }
    for el in o<-"" do  
     Has = true
    }
    o.attrDXLName = Has

    Well since it's a DXL attribute you're working on you can skip the Object o = current, as the variable obj is already defined as the current object... thus giving you:

    bool Has= false
    ExternalLink el
    //Iterate over outward links
    for el in obj->"" do
    {
        Has = true
    }
    for el in obj<-"" do
    {
        Has = true
    }
    obj.attrDXLName = Has

    /sekrbo

  • llandale
    llandale
    3035 Posts

    Re: Filters and External links

    ‏2014-03-13T20:41:47Z  
    • sekrbo
    • ‏2014-03-13T14:37:55Z

    Well since it's a DXL attribute you're working on you can skip the Object o = current, as the variable obj is already defined as the current object... thus giving you:

    bool Has= false
    ExternalLink el
    //Iterate over outward links
    for el in obj->"" do
    {
        Has = true
    }
    for el in obj<-"" do
    {
        Has = true
    }
    obj.attrDXLName = Has

    /sekrbo

    In fact, Object o = current is incorrect, not just "can be skipped".

    I point out that the attribute needs to be defined as Boolean.

    -Louie

  • M_vdLaan
    M_vdLaan
    28 Posts

    Re: Filters and External links

    ‏2014-03-19T15:10:12Z  
    • sekrbo
    • ‏2014-03-13T14:37:55Z

    Well since it's a DXL attribute you're working on you can skip the Object o = current, as the variable obj is already defined as the current object... thus giving you:

    bool Has= false
    ExternalLink el
    //Iterate over outward links
    for el in obj->"" do
    {
        Has = true
    }
    for el in obj<-"" do
    {
        Has = true
    }
    obj.attrDXLName = Has

    /sekrbo

    A minor point, perhaps, but there's an optimization possible here, certainly if objects can have multiple links: 

    bool Has= false
    ExternalLink el
    //Iterate over outward links
    for el in obj->"" do
    {
        Has = true
        break // Stop looking, we've found one...
    }
    if (!Has) { // Don't bother if we already found an outgoing link
        for el in obj<-"" do
        {
            Has = true
            break // Stop looking, we've found one...
        }    
    }
    obj.attrDXLName = Has
    

     

    Just one thing (cannot check it now): should the obj->"" and obj<-"" include the asterisk, i.e. obj->"*" and obj<-"*"?

     

    Regards,

    Marcel