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

Create a screen with scriptrunner (clone a project)

Laurent Bierge
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 16, 2017

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

Comment

Log in or Sign up to comment
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 16, 2017

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. 

Laurent Bierge
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 16, 2017

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
Laurent Bierge
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 4, 2019

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
Joshua Reddish June 18, 2020

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!

Laurent Bierge
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 29, 2020

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

Kruno October 16, 2020

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

Laurent Bierge
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 16, 2020

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

Kruno October 16, 2020

OK, thx nevertheless. 

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

TAGS
AUG Leaders

Atlassian Community Events