Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage
Highlighted

Create a screen with scriptrunner (clone a project)

Hi,

I'm trying to create a real clone of a project with Scriptrunner.

To do that, i need to copy every single element of a project (workflow scheme, workflow, issue type scheme,...)

I'm acutally trying to do that with issue type screen scheme.

There is a manager for this object, but the function to create a issue type screen scheme is odd:

voidcreateIssueTypeScreenScheme(IssueTypeScreenScheme issueTypeScreenScheme) 

And there is no further description.

I tried to dig this issue until the screen object. Even for the screen we have this kind of function:

voidcreateFieldScreen(FieldScreen fieldScreen)

Besides the architecture of the issue type screen scheme is a bit weird, i found this:

The goal is to create FieldScreens, then associate them to upper objects.

 

But there is no real function to create FieldScreenScheme or FieldScreen or 

FieldScreenSchemeItem.

There is still a possibility to create thos object since there are all kind of setters:

voidsetDescription(String description) 
voidsetGenericValue(org.ofbiz.core.entity.GenericValue genericValue) 
voidsetId(Long id) 
voidsetName(String name) 

But that doesn't seems "clean" at all to me. Besides i still need to generate a correct id and i'm not sure how to generate a correcte "GenericValue".

 

Any idea for all this matter ? :)

 

Regards,

 

Laurent Bierge

2 comments

Hello, 

There is already built-in script to do the same task. It is called Clone project. Go to cog item->add-ons find built-in scripts in the vertical menu. 

Actually i only have "copy". Besides "copy" don't clone project elements, it share them with the new project.

I want my new project to be independant.

Like jingjing likes this

A little update about this long lost journey.

Actually the FieldScreenSchemeItem is what makes the link between FieldScreenScheme and an issue operation.

The big improvement is that i managed to create a screen by scripting. I think there is a lot of safe way to do that and that the one i used may not be the safest one.

The interface FieldScreen actually has functions that allow you to create a screen. However, as it is an interface it doesn't have a constructor.

The class FieldScreenImpl which implement FieldScreen does have all those function and have a constructor. That constructor is very easy to use since it only requires the FieldScreenManager interface. (which you can obtain in componentAccessor)

So i created an FieldScreenImpl object and set the name, description, tab (important) and id (very important). The id is set by reading all screens ids and adding one to the bigger id. (if the id is already used, an error is thrown)

I used the store function to create the screen.

With this in mind, it should be possible to use this method to create every object until the issueTypeScreenScheme. 

Ps: Now that i've seen what's was in "xxxImpl" classes, i think that it's something that is obvious for most of devs that this class should be used to create object. It wasn't for me though !

Like # people like this

Hi Laurent,

 

Would you be able to post a snippet of code demonstrating how you were able to create the issue type screen scheme? We are similarly stuck. I will be looking into the impl classes you described above, just wanted to see if you had any examples that worked for you.

 

Thanks!

Hi Joshua,

No exemple left, I didn't kept an exemple of what I've tested ^^'.

However, if you follow what I said, i'm sure you can manage to build something.

Regards,

Laurent

Hey Laurent,

I have the same need as you did - full clone of a project with own Elements.

Unfortunately I'm a SR Noob fo could you post your complete script here? It would massively massively help me.

 

THX
Kruno

Hi Andie,

Unfortunately I'd never got the time to push forward my tests. When it's needed I still copy the project with SR and then clone manually each object that need it.

Regards,

Laurent

OK, thx nevertheless. 

If I get it working I will post it here. I still find all the manual steps needed too much :)

Comment

Log in or Sign up to comment
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you