Author Topic: Check project authors  (Read 1193 times)

1c3m4n

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Check project authors
« 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

1c3m4n

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: Check project authors
« Reply #1 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?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 7752
  • Karma: +165/-21
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Check project authors
« Reply #2 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

1c3m4n

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: Check project authors
« Reply #3 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

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 7752
  • Karma: +165/-21
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Check project authors
« Reply #4 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

1c3m4n

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: Check project authors
« Reply #5 on: October 20, 2010, 07:17:54 pm »
I have tried this, but it doesn't create a new author.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 7752
  • Karma: +165/-21
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Check project authors
« Reply #6 on: October 20, 2010, 07:20:01 pm »
Post the code snippet, there might be an update() missing or something like that.

Geert

1c3m4n

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: Check project authors
« Reply #7 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();

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 7752
  • Karma: +165/-21
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Check project authors
« Reply #8 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();

1c3m4n

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: Check project authors
« Reply #9 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();

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 7752
  • Karma: +165/-21
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Check project authors
« Reply #10 on: October 20, 2010, 07:35:45 pm »
Oh, yes sure, I forgot the cast to Author.

Geert

PS. I hate EA.Collection >:(

1c3m4n

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: Check project authors
« Reply #11 on: October 20, 2010, 08:08:17 pm »
Quote
PS. I hate EA.Collection >:(

I agree :)

Simon M

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 6200
  • Karma: +47/-5
    • View Profile
Re: Check project authors
« Reply #12 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();
« Last Edit: October 21, 2010, 08:45:08 am by simonm »
Simon

support@sparxsystems.com