Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started 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
-
I have solved the problem. Now i want to create a new project author. How can i do this?
-
From TFM:
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
-
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
-
I think you'll have to use as such:
myRepository.Authors.AddNew("AuthorName","Author")
Geert
-
I have tried this, but it doesn't create a new author.
-
Post the code snippet, there might be an update() missing or something like that.
Geert
-
Ok, here is the snippet which should create the new author:
// Author nicht vorhanden -> neu anlegen
Log = "Project Author nicht vorhanden";
oberflaeche.vSetMessage(Log);
repository.Authors.AddNew("Project Author", "Author");
repository.Authors.Refresh();
-
try
// Author nicht vorhanden -> neu anlegen
Log = "Project Author nicht vorhanden";
oberflaeche.vSetMessage(Log);
EA.Author newAuthor = repository.Authors.AddNew("Project Author", "Author");
newAuthor.Update();
-
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:
// 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();
-
Oh, yes sure, I forgot the cast to Author.
Geert
PS. I hate EA.Collection >:(
-
PS. I hate EA.Collection >:(
I agree :)
-
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.
Collection<Author> authors = rep.GetAuthors();
String newAuthorName = "Author P. McAuthor";
Author newAuthor = authors.AddNew( newAuthorName, "Writer" );
newAuthor.Update();
authors.Refresh();