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

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