Author Topic: Diagram not being added to QEA repository and creating a journal file  (Read 578 times)

ea0921

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
Diagram is not getting created in QEA repository and creating a journal file. However, elements are getting created and saved as well.
However, this works with QEAX repositories.

internal class Class1
    {
        public static void Main()
        {
            // connect to user1
            var path = "path";
            var repository = new EA.Repository();
            repository.SuppressSecurityDialog = true;
            repository.SuppressEADialogs = true;
            var isOpened = repository.OpenFile2(path, "username", "password");

            //create
            string packagePath = "path";

            Package package = getpackage(repository, packagePath);

            //create diagram syncuser
            Diagram diagram = package.Diagrams.AddNew(EAConstants.OH_CREATE_TEMPLATE, "Use Case");
            diagram.Name = "hello";
            diagram.Update();

            repository.ReloadDiagram(diagram.DiagramID);
            repository.OpenDiagram(diagram.DiagramID);
            repository.SaveDiagram(diagram.DiagramID);
            repository.CloseDiagram(diagram.DiagramID);
        }

        private static Package getpackage(Repository repository, string packagePath)
        {
            //get packages
            Dictionary<string, string> packageStructure = new Dictionary<string, string>();
            foreach (Package model in repository.Models)
            {
                //Getting all the packages under a particular module.
                EAUtility.ConstructHierarchy(model, "", packageStructure, false);
            }
            //find package id
            string packageGUID = null;
            foreach (KeyValuePair<string, string> pair in packageStructure)
            {
                if (packagePath.Equals(pair.Value))
                {
                    packageGUID = pair.Key;
                    break;
                }
            }
            Package package = repository.GetPackageByGuid(packageGUID);
            return package;
        }
    }



Geert Bellekens

  • EA Guru
  • *****
  • Posts: 12258
  • Karma: +484/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Diagram not being added to QEA repository and creating a journal file
« Reply #1 on: November 19, 2022, 01:50:22 am »
You'll have to debug step by step to figure out where exactly it goes wrong I guess.

Do you get any errors?
What if you trim it down to the basics (so only creating a diagram) do you still see a difference between the two repository types?

According to the manual: https://sparxsystems.com/enterprise_architect_user_guide/16.1/the_model_repository/createamodeloverview.html both repository types (.qea and .qeax) are in fact exactly the same format. They only differ in a file sharing property that is turned on/off by EA.

Would be interesting to see if that really makes a difference.

Geert

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 12258
  • Karma: +484/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Diagram not being added to QEA repository and creating a journal file
« Reply #2 on: November 19, 2022, 02:03:35 am »
I'm not sure what you are doing wrong, but it looks to me like you are arriving at the wrong conclusions.

I executed this little console app on both a .qea and .qeax model, but both worked exactly the same.
In both cases the package and diagram were created.

Code: [Select]
namespace EA_console_app
{
    internal class Program
    {
        static void Main(string[] args)
        {
            // connect to user1
            var path = @"C:\temp\test project.qea";
            var repository =  new EA.Repository();
            repository.SuppressSecurityDialog = true;
            repository.SuppressEADialogs = true;
            var isOpened = repository.OpenFile2(path, "user1", "user1");

            foreach (EA.Package rootpackage in repository.Models)
            {
                //create package
                EA.Package newPackage = rootpackage.Packages.AddNew("newPackage", "");
                newPackage.Update();
                //create diagram
                EA.Diagram newDiagram = newPackage.Diagrams.AddNew("newDiagram", "Logical");
                newDiagram.Update();
            }

            //close EA
            repository.Exit();
        }
    }
}

Geert

ea0921

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
Re: Diagram not being added to QEA repository and creating a journal file
« Reply #3 on: November 21, 2022, 09:09:05 pm »
The only difference in my code is that I am not exiting the repository. If you would not close the repository and persist the connection then there would be a .journal file created for the repository. I have tried all other ways to save the diagram details:

repository.ReloadDiagram(diagram.DiagramID);
repository.OpenDiagram(diagram.DiagramID);
repository.SaveDiagram(diagram.DiagramID);
repository.CloseDiagram(diagram.DiagramID);
repository.RefreshOpenDiagrams(true);
repository.SaveAllDiagrams();
repository.SaveDiagram(diagram.DiagramID);
repository.ReloadPackage(package.PackageID);
repository.Models.Refresh();
repository.RefreshModelView(package.PackageID);
           
I need to reuse the same connection, and have the diagram details updated in the meanwhile.
Is there any way to save the diagram details without closing the connection(exiting the repository).

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 12258
  • Karma: +484/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Diagram not being added to QEA repository and creating a journal file
« Reply #4 on: November 21, 2022, 09:18:40 pm »
The diagram details are save to the database the moment you do Diagram.Update()

All the operations you mentioned are only useful for the GUI that is open, but since you don't open a GUI, they won't be of any use for you. Feels like you are throwing stuff at the wall to see what sticks.

I'm still nog getting your actual problem. Can you explain what you are doing, and where exactly it behaves differently from what you are expecting.

Geert


ea0921

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
Re: Diagram not being added to QEA repository and creating a journal file
« Reply #5 on: November 21, 2022, 09:33:01 pm »
However, even after doing diagram.update(), it is still not visible on the UI and also journal file is created up until the connection is closed.
You can test this main program which would work for QEAX file repository and not for QEA repositories. Can you check this code ay your end once?
Code: [Select]
namespace EA_console_app
{
    internal class Program
    {
        static void Main(string[] args)
        {
            // connect to user1
            var path = @"C:\temp\test project.qea";
            var repository =  new EA.Repository();
            repository.SuppressSecurityDialog = true;
            repository.SuppressEADialogs = true;
            var isOpened = repository.OpenFile2(path, "user1", "user1");

            foreach (EA.Package rootpackage in repository.Models)
            {
                //create package
                EA.Package newPackage = rootpackage.Packages.AddNew("newPackage", "");
                newPackage.Update();
                //create diagram
                EA.Diagram newDiagram = newPackage.Diagrams.AddNew("newDiagram", "Logical");
                newDiagram.Update();
            }
        }
    }
}

We have a set of operations being performed, and in between opening and closing of a repository after every operation seems a bit heavy operation.
After every operation closing and reopening the repository is a costly operation.
« Last Edit: November 21, 2022, 11:07:11 pm by ea0921 »

ea0921

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
Re: Diagram not being added to QEA repository and creating a journal file
« Reply #6 on: November 22, 2022, 09:54:34 pm »
Hi Geert,

Did you check this piece of code, wherein repository is not being closed with diagram creation in QEA file repository.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 12258
  • Karma: +484/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Diagram not being added to QEA repository and creating a journal file
« Reply #7 on: November 22, 2022, 10:02:04 pm »
Hi Geert,

Did you check this piece of code, wherein repository is not being closed with diagram creation in QEA file repository.
Closing the repository has no impact on diagrams being created or not.

.qea repositories are not meant for multi-user scenarios, you have to use .qeax for that.
But if you want you can connect to a running instance of EA as well.

If you describe exactly what you want to do, the exact steps you are taking, and what exactly is going wrong we could help you.
Now it's just guessing on all fronts.

Geert

ea0921

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
Re: Diagram not being added to QEA repository and creating a journal file
« Reply #8 on: November 22, 2022, 11:57:18 pm »
Yes, closing the repository is not related to diagrams being created or not. However, it is impacting EA UI in case when connection is still open.
This provides improper picture.
However, until that repository is closed, the diagram is not visible on EA application interface
We are aware of the single user scenario, however, EA interface is not providing correct picture when a diagram has been added to QEA repository and the connection is still open.

If you execute this code, then diagram would not be visible on EA UI when the connection is still open. Even if same user is used or another user this is happening.
Code: [Select]
namespace EA_console_app
{
    internal class Program
    {
        static void Main(string[] args)
        {
            // connect to user1
            var path = @"C:\temp\test project.qea";
            var repository =  new EA.Repository();
            repository.SuppressSecurityDialog = true;
            repository.SuppressEADialogs = true;
            var isOpened = repository.OpenFile2(path, "user1", "user1");

            foreach (EA.Package rootpackage in repository.Models)
            {
                //create package
                EA.Package newPackage = rootpackage.Packages.AddNew("newPackage", "");
                newPackage.Update();
                //create diagram
                EA.Diagram newDiagram = newPackage.Diagrams.AddNew("newDiagram", "Logical");
                newDiagram.Update();
            }
        }
    }
}


UseCase:
We are performing a set of operations through a service wherein we are creating and updating multiple diagrams based on user operations.
In between we donot open and close connection, we reuse the same connection to maintain efficiency.
However, if a diagram is created it is not visible on EA UI until the collection has been closed for QEA repository.
This is not the case with elements.

Steps:

1. Open a connection
2. Perform a set of operations reusing the same connection
3. Have correct information state displayed on the EA user interface in between the set of operations

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 12258
  • Karma: +484/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Diagram not being added to QEA repository and creating a journal file
« Reply #9 on: November 23, 2022, 12:11:54 am »
Ah, the mistake you are making is thinking that, since you login with the same user, you are not in a multi-user situation.
You are. You have two instances of EA.exe running, one for the user, and one for the automation.

As indicated, if you want to change something that should be immediately visible for the user, you can connect your script to the running instance of EA.exe, instead of creating a new instance.

Also, I did some tests, without closing the connection, and the diagram were created. All the users needs to do is reload package.
This is because you are using a different instance of EA, and the EA client caches most stuff. It doesn't know immediately about changes in the database; regardless of which user you use to log in.

So the most probable solution to your problem is to connect your script to the running instance of EA, or write your automation as an add-in.

Geert

ea0921

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
Re: Diagram not being added to QEA repository and creating a journal file
« Reply #10 on: November 25, 2022, 02:42:05 am »
Can you elaborate the exact scenario you reproduced wherein without closing the connection you are able to see the created diagram by reloading the package.

This is the scenario that is not working for me:
1. Created a diagram from main program on .qea repository and do not close the connection
2. Open EA .QEA repository from either same or different user
3. Diagram is not visible
4. Reload the package still the diagram is not visible.
Even after opening EA application after creation of diagram it is not visible on UI.

If it is possible can we have a call to discuss the issue and the scenario as well?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 12258
  • Karma: +484/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Diagram not being added to QEA repository and creating a journal file
« Reply #11 on: November 25, 2022, 08:01:32 pm »
This is what I see:

1. Created a diagram from main program on .qea repository and do not close the connection
2. Open EA .QEA repository from either same or different user
3. Diagram is visible


I also tested what happens when I have the .qea repository already open:

1. Open EA .QEA repository from either same or different user
2. Created a diagram from main program on .qea repository and do not close the connection
3. Diagram is not visible
4. Reload package makes diagram visible.

For me the behavior is exactly the same regardless of exiting EA in the code.

If you would like personal support you can email me at geert@bellekens.com so I can send you a quote.

Geert

ea0921

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
Re: Diagram not being added to QEA repository and creating a journal file
« Reply #12 on: November 28, 2022, 05:43:05 pm »
Can you mention the build version of EA application on which you are testing this?
I was using build 1605 and this issue can be found there.
However, I updated to build 1622 and it does not create this problem.
Are there any changes between these two builds which can affect this scenario?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 12258
  • Karma: +484/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Diagram not being added to QEA repository and creating a journal file
« Reply #13 on: November 28, 2022, 06:21:59 pm »
Can you mention the build version of EA application on which you are testing this?
I was using build 1605 and this issue can be found there.
However, I updated to build 1622 and it does not create this problem.
Are there any changes between these two builds which can affect this scenario?

I was using the latest 16.1.1622.
If that was the only thing you changed, I guess they changed something.
I hadn't noticed anything in the release notes, but those can be pretty cryptic at times.

Geert