Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Moving Configration in QB version 6 #14

zaara1 ·

I want to device a script to rename a configuration if it does not exist.
If that configuration exists then I want to move some of its children.

eg:

A>B
b1 (children)
b2 (children)

I want to rename B to B_1 if it does not exist
If B_1 does not exist then I have to move its children also through script

Also let me know how to change the group name of them if currently the group is B and if renamed then it wll become B_1

  • replies 10
  • views 1336
  • stars 0
robinshen ADMIN ·

Try below script:

groovy:
def confB = system.configurationManager.get("A/B");
def confB_1 = system.configurationManager.get("A/B_1");
if (confB_1 != null) { // it already exists, so we only move b1 and b2
  def confB1 = system.configurationManager.get(A/B/b1");
  confB1.setParent(confB_1);
  system.configurationManager.save(confB1);
  def confB2 = system.configurationManager.get(A/B/b2");
  confB2.setParent(confB_1);
  system.configurationManager.save(confB2); 
} else { // otherwise rename B as B_1 (all children under B will be automatically under B_1 after the renaming)
  confB.setName("B_1");
  system.configurationManager.save(confB);
}
zaara1 ·

Thanks a lot for yr quick reply.
Can you tell me how to recursively move all children of a particular configuration into other
Currently you are moving them one by one.

Also let me know if old configuration will be deleted or its copy will be moved.

zaara1 ·

Also let me know if I update the name of parent configuration then I also have to update the workspace list setting of the required configuration.Field number 2 needs to be renamed from B to B_1.how do I write that script.

Like

A>B_1(new name changed)
b1(children)
b2(children)

robinshen ADMIN ·

To move all children recursively:

groovy:
def confB = system.configurationManager.get("A/B");
def confB_1 = system.configurationManager.get("A/B_1");
if (confB_1 != null) { // it already exists, so we move all its children
  for (eachChild in system.configurationManager.getChildren(confB)) {
    eachChild.setParent(confB_1);
    system.configurationManager.save(eachChild);
  }
} else { // otherwise rename B as B_1 (all children under B will be automatically under B_1 after the renaming)
  confB.setName("B_1");
  system.configurationManager.save(confB);
}

When changing the parent configuration, it is actually a move, the copy from old place will disappear. As to workspace setting, you normally does not need to do that, as workspace setting is generally using the configuration id instead of name (even if you are using the name, you should script it to use ${configuration.name} instead of hard-code it).

zaara1 ·

I have such a mechanism that there are various entries in workspace list corresponding to the ealier name in field 2.I have to change all those entries to new name which has been renamed.How to update all those entries.

robinshen ADMIN ·

To change workspace setting of a configuration:

groovy:
def workspaceSetting = new com.pmease.quickbuild.setting.configuration.workspace.UseSpecifiedWorkspace();
workspaceSetting.path = "some path";
someConf.setWorkspaceSetting(workspaceSetting );
system.configurationManager.save(someConf);
zaara1 ·

I did not get what do you mean to say

Suppose I have updated the name of the configuration at this path
A/B/old name to new name A/B/newname

Now all the workspace settings at the level A/B needs to be changed
Below is a sample workspace settings entries at level A/B
0 1 2 3
hi how old_name now
hello now old_name bye

I have to update all those entries at level A/B will be entries above to the below setting
 
 0     1     2         3
 hi    how   new_name  now
 hello now   new_name  bye
robinshen ADMIN ·

I am confused. What do you mean workspace here? Is it QB configuration workspace folder which is specified via workspace setting in advanced setting of the configuration? Then what does below mean? What is 0 1 2 3 and the hi hello things?
0 1 2 3
hi how new_name now
hello now new_name bye

zaara1 ·

groovy:
def confB = system.configurationManager.get("A/B");
def confB_1 = system.configurationManager.get("A/B_1");
if (confB_1 != null) { // it already exists, so we only move b1 and b2
def confB1 = system.configurationManager.get(A/B/b1");
confB1.setParent(confB_1);
system.configurationManager.save(confB1);
def confB2 = system.configurationManager.get(A/B/b2");
confB2.setParent(confB_1);
system.configurationManager.save(confB2);
} else { // otherwise rename B as B_1 (all children under B will be automatically under B_1 after the renaming)
confB.setName("B_1");
system.configurationManager.save(confB);
}

In this if the configuration does not exist and we want to create new and want to move only b1 under new configuration.How do we make new configuration without renaming older one.

robinshen ADMIN ·

To create a new configuration:

groovy:
import com.pmease.quickbuild.model.Configuration;
def newConfiguration = new Configuration(true);
newConfiguration.setParent(someOtherConf);
system.configurationManager.save(newConfiguration);

After creating the new configuration, you may move "b1" to be under the logic mentioned previously