Author Topic: How to create a new element using the JAVA API?  (Read 4250 times)

ddiazguerra

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
How to create a new element using the JAVA API?
« on: December 27, 2012, 10:54:58 pm »
Please, I can't create a new element using the JAVA API.

At least I need to obtain a new GUID in order to make the insert in BBDD or import CSV file.

Thanks in advance.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to create a new element using the JAVA API
« Reply #1 on: December 28, 2012, 06:23:14 pm »
You have to add it in a collection such as
Package.Element.AddNew()  or Element.Element.AddNew()

Geert

ddiazguerra

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: How to create a new element using the JAVA API
« Reply #2 on: December 28, 2012, 07:37:44 pm »
Thanks for you reply, but unfortunately in JAVA seem not to exist that method in Element Object.

Best regards.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to create a new element using the JAVA API
« Reply #3 on: December 28, 2012, 08:00:30 pm »
Yes sorry, typo:
Quote
You have to add it in a collection such as
Package.Element[highlight]s[/highlight].AddNew()  or Element.Element[highlight]s[/highlight].AddNew()

Geert

ddiazguerra

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: How to create a new element using the JAVA API
« Reply #4 on: December 28, 2012, 10:00:32 pm »
I found the answer, thanks for the clue.

org.sparx.Package paqDiego = null;
paqDiego = repositoryEA.GetModels().GetByName("Model name");
paqDiego = paqDiego.GetPackages().GetByName("package name 1"); (many times)
            
Collection cElements = paqDiego.GetElements();
cElements.AddNew("Element Diego", "Requirement");


Best regards