Book a Demo

Author Topic: DAO Error on Adding Multiple Swimlanes  (Read 6354 times)

Rich Anderson

  • EA User
  • **
  • Posts: 142
  • Karma: +8/-0
    • View Profile
    • LinkedIn
DAO Error on Adding Multiple Swimlanes
« on: June 05, 2019, 10:32:57 am »
I'm attempting to programatically generate a diagram with a large number of swim lanes (long story), but EA is throwing an error as you see in the code below.  Sometimes it happens on the 20th swim lane and sometimes on the 17th.  (Your results may vary).  But even after this code crashes I'm able to add many more swim lanes with the GUI. Anyone have any ideas on what might be causing this or what a workaround may be? I've tried to get this down to the most basic code that reproduces this error.

Code: [Select]

        'This crashes on the 20th element with DAO Error:
        'DAO.Field [3163] The field Is too small To accept the amount Of data you attempted To add. 
        'Try inserting Or pasting less data.
        Dim objectDiagram As EA.Diagram
        objectDiagram = diagramsPackage.Diagrams.AddNew("Big Diagram", "Object")
        objectDiagram.HighlightImports = False
        objectDiagram.SwimlaneDef.Orientation = 1 'Horizontal
        objectDiagram.Update()
        For sw As Integer = 1 To 21
            objectDiagram.SwimlaneDef.Swimlanes.Add(CStr(sw), 30)
            objectDiagram.Update()
        Next

Rich Anderson
Urgnt Limited

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: DAO Error on Adding Multiple Swimlanes
« Reply #1 on: June 05, 2019, 08:38:30 pm »
IIRC t_diagram.swimlanes is limited to 256 chars. So you are using too many swimlanes.

q.

Rich Anderson

  • EA User
  • **
  • Posts: 142
  • Karma: +8/-0
    • View Profile
    • LinkedIn
Re: DAO Error on Adding Multiple Swimlanes
« Reply #2 on: June 06, 2019, 06:03:49 am »
Thanks for your help and narrowing down the problem!  The odd thing is that I'm able to keep adding swimlanes to the diagram manually using the GUI. (I added 8 more just to test it). So, somehow that restriction on the swimlanes does not seem to apply when using the GUI.   Any thoughts on that?
Rich Anderson
Urgnt Limited

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: DAO Error on Adding Multiple Swimlanes
« Reply #3 on: June 06, 2019, 09:48:36 am »
They often have crude tricks up their sleeve. I might have a look tomorrow.

q.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: DAO Error on Adding Multiple Swimlanes
« Reply #4 on: June 06, 2019, 11:24:00 am »
Thanks for your help and narrowing down the problem!  The odd thing is that I'm able to keep adding swimlanes to the diagram manually using the GUI. (I added 8 more just to test it). So, somehow that restriction on the swimlanes does not seem to apply when using the GUI.   Any thoughts on that?
EAUI!

Rich, as an experiment, try changing t_diagram.swimlanes to a memo field (>255 characters).  You may find that fixes the problem.

We've done that to a couple of fields in the repository "with no loss of generality".

HTH,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Rich Anderson

  • EA User
  • **
  • Posts: 142
  • Karma: +8/-0
    • View Profile
    • LinkedIn
Re: DAO Error on Adding Multiple Swimlanes
« Reply #5 on: June 06, 2019, 03:28:16 pm »
Thanks, Paolo!   That worked.  I had replication going on this repository, so I created a test with the replication removed, changed the data type in Access, and then tried it generating 100 swimlanes.  Then I reintroduced the replication and tested it again. It worked again.   This should do the trick, although I'm not wild about modifying the database schema.  Should I be worried about that?
Rich Anderson
Urgnt Limited

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: DAO Error on Adding Multiple Swimlanes
« Reply #6 on: June 06, 2019, 04:11:25 pm »
Thanks, Paolo!   That worked.  I had replication going on this repository, so I created a test with the replication removed, changed the data type in Access, and then tried it generating 100 swimlanes.  Then I reintroduced the replication and tested it again. It worked again.   This should do the trick, although I'm not wild about modifying the database schema.  Should I be worried about that?
From my experience, NO!

YMMVWFM (Of course). We run a more consistent schema set - where the SQL Server and MS Access schemas are better harmonised and made more self-consistent (we found one table where Sparx used 3 DIFFERENT representations for boolean fields). Wherever possible (subject to the vagarities of EAUI), we have only one representation for the same datatype.

We've been doing this for nearly a decade with almost no ill effects.

We can transfer project in both directions and we can develop one set of queries which work correctly regardless of the DB technology.

If you are feeling adventurous, you can even turn all the EA tables into write-through views and create your own DB tables underneath (for example with better footprinting etc.). I did that nearly a decade ago (must have been bored that week  ;) )  I haven't done it since, but I've recently started thinking about using state-episodic tables to deliver the ability to view an element in time   "tell me what this element will look like in 3 months time", "last year".

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: DAO Error on Adding Multiple Swimlanes
« Reply #7 on: June 06, 2019, 06:49:30 pm »
Hey, hey, hey. Row back please. It's t_xref that stores the swimlane information. I will dig into that in more detail, but what you did seems to be a coincidental fix :-/

q.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: DAO Error on Adding Multiple Swimlanes
« Reply #8 on: June 06, 2019, 08:29:11 pm »
I dug a little deeper. Obviously t_diagram.swimlanes is already larger than 256 bytes. And each swimlane definition gets a new entry in t_xref. So rather you should report that as bug if you still can reproduce the issue. Your code snippet did not work for me. Sorry, but I don't wan't to fall back to digging into VB after so many years...

q.

Rich Anderson

  • EA User
  • **
  • Posts: 142
  • Karma: +8/-0
    • View Profile
    • LinkedIn
Re: DAO Error on Adding Multiple Swimlanes
« Reply #9 on: June 07, 2019, 06:10:23 am »
I dug a little deeper. Obviously t_diagram.swimlanes is already larger than 256 bytes. And each swimlane definition gets a new entry in t_xref. So rather you should report that as bug if you still can reproduce the issue. Your code snippet did not work for me. Sorry, but I don't wan't to fall back to digging into VB after so many years...

q.

Hi qwerty,  Thanks for having a look for me and Paolo thanks for helping me understand this better.  I think I'm just going to try it this way for a while, given that it's working and there are no ill effects.  (Actually, I'm skeptical that this very large diagram is going to be very useful to the people who are asking for it, but sometimes you just have to give them what they want!)  But I have run the code through a C# converter if you care to give that a try (I never got around to C#).    ;)

Code: [Select]
    // This crashes on the 20th element with DAO Error:
    // DAO.Field [3163] The field Is too small To accept the amount Of data you attempted To add. 
    // Try inserting Or pasting less data.
    EA.Diagram objectDiagram;
    objectDiagram = diagramsPackage.Diagrams.AddNew("Big Diagram", "Object");
    objectDiagram.HighlightImports = false;
    objectDiagram.SwimlaneDef.Orientation = 1; // Horizontal
    objectDiagram.Update();
    for (int sw = 1; sw <= 75; sw++)
    {
        objectDiagram.SwimlaneDef.Swimlanes.Add(System.Convert.ToString(sw), 30);
        objectDiagram.Update();
    }
« Last Edit: June 07, 2019, 06:13:31 am by Rich Anderson »
Rich Anderson
Urgnt Limited

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: DAO Error on Adding Multiple Swimlanes
« Reply #10 on: June 07, 2019, 05:16:10 pm »
Well, me neither (C#). I tried it with my favorite scripting language but that didn't even add a single swim lane. Maybe later :-/

q.