Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - jmad

Pages: [1]
1
Ok. Question 2.

I have a package which I would like to add to a repository, the package contains sub-packages of the same XML layout.

To add a package to a repository it seems as though I would create an element, copy over a few parameters from the XML. Then for sub-packages, I would create sub-elements and link them.

So, I pass the XML package to an element constructor, create a EA.Element copy a few parameters (name, guid etc.) and then attempt to add an element to it's Elements collection, it seems as if I should be able to set this up recursively so that all the subpackages would be included in the EA.Element.Elements

This does not seem to work. EA.Element.Elements seems to have only one method for adding a new EA.Element to it's collection, but the parameters for the EA.Element.AddNew(string, string) are incorrect.

How are Elements meant to be added in such a case?

Here's some code
Code: [Select]
namespace XMIMain
{
    class Element
    {
//element property
        private EA.Element _element;
        public EA.Element Element
        {
            get { return _element; }
        }

//constructor
        public Element(RegistryPackageType package)
        {
            _element = new EA.Element();
            _element.Name = package.Name;
            _element.ElementGUID = package.id;
            foreach (IdentifiableType id in package.RegistryObjectList)
            {
                if (id is RegistryPackageType)
                {
                     XMIMain.Element subElement = new XMIMain.Element((RegistryPackageType)id);
                    //in here we need to add this new element to the elements collection?
                    //_element.Elements.Add(subElement.Element)?
                }
            }

        }
    }
}

So, is there something that I can replace the comment with that will add this element to the elements collection?

2
So, a model can not be created programatically?

3
I did see that. So, I attepted to create an empty repository that I could load my XMI into using the following:

Code: [Select]
         if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                XmlDocument newDoc = new XmlDocument();
                newDoc.Load(openFileDialog1.FileName);
                EA.Repository rep = new EA.Repository();
                EA.Project newProj = rep.GetProjectInterface();
                newProj.ImportPackageXMI(newProj.GUIDtoXML(System.Guid.NewGuid().ToString()),newDoc.OuterXml,0,1);
            }

But that did not seem to help.

The thing is, I am trying to give it a file, in XMI format from which I am hoping, it can populate the necessary connection, element and diagram fields.

I'm not sure what else it requires. I think may have to initialize the repository in a different manner, but I am stumped on how to do so.

Maybe I should create a blank EA document and load it from a C# resource file. So that the repository has something to connect to.

Edit: Hm. That won't work if the function requires a filename in order to load. I'll try with just a blank file.

Edit2: Ok. If I populate the repository with a blank .eap file, it seems that the code functions. Now, I probably need to figure out if there is a method to create a repository without using a file, so that I can store initialization code in a resource file. Also, I need to determine if the loaded XMI file populated by stub file correctly.

-jmad

4
Starting with the "Alternatively" bit.

The following:
Code: [Select]
           if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                XmlDocument newDoc = new XmlDocument();
                newDoc.Load(openFileDialog1.FileName);
                EA.Project newProj = new EA.Project();
                newProj.ImportPackageXMI(newProj.GUIDtoXML(System.Guid.NewGuid().ToString()),newDoc.OuterXml,0,1);
            }

Produces the same error.

Looking for the UML_EA.DTD now.

Edit: It appears that UML_EA.DTD is on the desktop along with my XMI file.

-jmad

5
Hi,

I need to transform the XMI created from EA7.1 to a different format for storage in a EbXML registry/repository.

I noticed that there was an API that could allow me to transform the exported XMI to a EA.Project item in C#. Upon attempting to do this however, I get a message that states
RPC_E_SERVERFAULT

My code is like this:
Code: [Select]
if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                EA.Project newProj = new EA.Project();
                newProj.ImportPackageXMI(newProj.GUIDtoXML(System.Guid.NewGuid().ToString()),openFileDialog1.FileName,0,1);
            }
I have the Interop loaded and this seems to be a general COM error, so am a bit lost on how to proceed.

The XMI was created using UML2.1(XMI2.1), Enable Roundtrip, Format XMI output.

Does the ImportPackageFromXMI work with XMI2.1? Does anyone have any advice on what to do with the error message?

Is there another way to use C# to serialize the XML output of the XMI Export?

Failing the above, does anyone have any advice on a different tactic?

Thanks,
jmad

Pages: [1]