Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: 1c3m4n on October 19, 2010, 11:11:59 pm

Title: Check project authors
Post by: 1c3m4n on October 19, 2010, 11:11:59 pm
Hi,

i want to check, if the repository user equals in the project authors list. I successfully determined the rep. user, but i had some problems to check the project authors list.
I tried the repository.authors.... functions, but it didn't work.

Can you please give me a good solution?

Thanks.

Florian
Title: Re: Check project authors
Post by: 1c3m4n on October 20, 2010, 12:23:55 am
I have solved the problem. Now i want to create a new project author. How can i do this?
Title: Re: Check project authors
Post by: Geert Bellekens on October 20, 2010, 04:23:10 pm
From TFM:
Quote
Authors
 Collection
 Read only. The system Authors collection. Contains 0 or more Author objects, each of which can be associated with, for example, elements or diagrams as the item author or owner. Use AddNew, Delete and GetAt to manage Authors.
 

Geert
Title: Re: Check project authors
Post by: 1c3m4n on October 20, 2010, 06:53:18 pm
Hi Geert,

thank you, i have already tried this. The AddNew function has 2 arguments:

string name: The name of the new project athor?
string type: What does this mean?

Cheers,
Florian
Title: Re: Check project authors
Post by: Geert Bellekens on October 20, 2010, 06:58:20 pm
I think you'll have to use as such:
Code: [Select]
myRepository.Authors.AddNew("AuthorName","Author")
Geert
Title: Re: Check project authors
Post by: 1c3m4n on October 20, 2010, 07:17:54 pm
I have tried this, but it doesn't create a new author.
Title: Re: Check project authors
Post by: Geert Bellekens on October 20, 2010, 07:20:01 pm
Post the code snippet, there might be an update() missing or something like that.

Geert
Title: Re: Check project authors
Post by: 1c3m4n on October 20, 2010, 07:22:57 pm
Ok, here is the snippet which should create the new author:

Code: [Select]
// Author nicht vorhanden -> neu anlegen
Log = "Project Author nicht vorhanden";
oberflaeche.vSetMessage(Log);
repository.Authors.AddNew("Project Author", "Author");
repository.Authors.Refresh();
Title: Re: Check project authors
Post by: Geert Bellekens on October 20, 2010, 07:27:17 pm
try
Code: [Select]
// Author nicht vorhanden -> neu anlegen
Log = "Project Author nicht vorhanden";
oberflaeche.vSetMessage(Log);
EA.Author newAuthor = repository.Authors.AddNew("Project Author", "Author");
newAuthor.Update();
Title: Re: Check project authors
Post by: 1c3m4n on October 20, 2010, 07:32:58 pm
Thank you very much !!!

I got an error message with the use of your solution. I modified your code, now it works.

Here it is:

Code: [Select]
// Author nicht vorhanden -> neu anlegen
Log = "Project Author nicht vorhanden";
oberflaeche.vSetMessage(Log);
EA.Author newAuthor = repository.Authors.AddNew("Project Author", "Author") as EA.Author;
newAuthor.Update();
Title: Re: Check project authors
Post by: Geert Bellekens on October 20, 2010, 07:35:45 pm
Oh, yes sure, I forgot the cast to Author.

Geert

PS. I hate EA.Collection >:(
Title: Re: Check project authors
Post by: 1c3m4n on October 20, 2010, 08:08:17 pm
Quote
PS. I hate EA.Collection >:(

I agree :)
Title: Re: Check project authors
Post by: Eve on October 21, 2010, 08:43:01 am
Quote
PS. I hate EA.Collection >:(
Well, you could always use the Java interface.  It's slightly easier in that the collections are generics.  Here's a sample from the code samples directory in EA.

Code: [Select]
Collection<Author> authors = rep.GetAuthors();
String newAuthorName = "Author P. McAuthor";
Author newAuthor = authors.AddNew( newAuthorName, "Writer" );
newAuthor.Update();
authors.Refresh();