Create publication combinations within a package

In this example I want to describe how to update publication packages after introducing a new project variant. This is the jRQL automation for the dialog Edit Publication Package on a publication package.

The main method here is PublicationPackage.addSetting(). Similar as the Dialog in SmartTree you can create a new combination by copy the values from another project variant. jRQL assumes you want to use the same language variant.

Follow these lines with the explanation below:

String logonGuid = "8009AB61D06844F48077A9E4D4880A20";
String sessionKey = "C63373D9DB394B94BBAD66106540A123";
String projectGuid = "73671509FA5C43ED8FC4171AD0298AD2";

CmsClient client = new CmsClient(logonGuid);
Project project = client.getProject(sessionKey, projectGuid);

// 1. for these packages do
String[] packages = {“publ_pages_to_languages_root”, “publ_pages_to_newsletter”};
for (int i = 0; i < packages.length; i++) {
String name = packages[i];
PublicationPackage publPackage = project.getPublicationPackageByName(name);

for (PublicationSetting combination : publPackage.getPublicationSettings()) {
// 2. skip all page config
if (combination.getProjectVariantName().contains(“page_config_xml”)) {
continue;
}
System.out.println(”  ” + combination.getName());

// 3. get setting’s values
LanguageVariant lv = combination.getLanguageVariant();
ProjectVariant pv = combination.getProjectVariant();

// 4. determine new project variant
String stage = StringHelper.split(pv.getName(), “_”)[0];
ProjectVariant newPv = project.getProjectVariantByName(stage + “_viewlabels_and_messages_xml”);

// 5. create new setting
PublicationSetting newCombination = publPackage.addSetting(newPv, lv, pv);
// 6. further action with newCombination
} // end for combinations
} // end for packages

In step 1 I define which publication packages I needed to add combination for the new project variant and loop through all of them.

Step 2 in this example skips all combinations (jRQL name a publication combination publication setting) for the  project variants for the page config XMLs.

Step 3 get the language and project variant from the current publication combination.

Step 4 extracts from the project variant the stage (like WORK, DEVE, TEST, PROD) and builds the name of the new viewlabels_and_messages project variant.

Step 5 last but not least create the new setting by copying all settings from the project variant pv to the newPv – all for the same language variant lv.

Step 6 in my example is empty. If you need you can here adjust the newCombination with new publishing targets or a new published pages publication folder.

Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: