From 7c757a273453b3d82f0e24a29861b37ab4e960f5 Mon Sep 17 00:00:00 2001 From: Marino Missiroli Date: Tue, 5 Mar 2024 23:06:37 +0100 Subject: [PATCH] hack to improve "Output Module Inserter" (plugin names with ::) --- src/confdb/gui/ConfigurationTreeActions.java | 25 +++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/confdb/gui/ConfigurationTreeActions.java b/src/confdb/gui/ConfigurationTreeActions.java index 57f12a2b5..69e660e27 100644 --- a/src/confdb/gui/ConfigurationTreeActions.java +++ b/src/confdb/gui/ConfigurationTreeActions.java @@ -282,7 +282,7 @@ public static boolean insertESSource(JTree tree, String templateName) { ConfigurationTreeModel model = (ConfigurationTreeModel) tree.getModel(); Configuration config = (Configuration) model.getRoot(); - if (templateName.indexOf(':') >= 0) { + if (templateName.indexOf(":") >= 0) { String[] s = templateName.split(":"); Template template = config.release().essourceTemplate(s[1]); Instance original = null; @@ -326,7 +326,7 @@ public static boolean insertESModule(JTree tree, String templateName) { ConfigurationTreeModel model = (ConfigurationTreeModel) tree.getModel(); Configuration config = (Configuration) model.getRoot(); - if (templateName.indexOf(':') > 0) { + if (templateName.indexOf(":") > 0) { String[] s = templateName.split(":"); Template template = config.release().esmoduleTemplate(s[1]); Instance original = null; @@ -2011,8 +2011,7 @@ private static Configuration getConfigurationCopy(Configuration sourceConf) { index = 0; while (ESMit.hasNext()) { ESModuleInstance esmodule = ESMit.next(); - ESModuleInstance NewModule = configurationCopy.insertESModule(index, esmodule.template().name(), - esmodule.name()); + ESModuleInstance NewModule = configurationCopy.insertESModule(index, esmodule.template().name(), esmodule.name()); index++; Iterator itP = esmodule.parameterIterator(); while (itP.hasNext()) { @@ -3068,7 +3067,19 @@ public static boolean insertReference(JTree tree, String type, String name) { return false; reference = config.insertOutputModuleReference(parent, index, referencedOutput); } else if (type.equalsIgnoreCase("Module")) { - String[] s = name.split(":"); + // The "unlikely string" hack. + // Here, the variable "name" can presumably take values of the form + // "pluginType", "pluginType:moduleLabel", or "copy:pluginType:moduleLabel". + // Unfortunately, this convention does not take into account the fact that + // pluginType itself can contain the substring "::" (e.g. plugin types with namespace specification, + // or Alpaka plugins with explicit backend selection). + // The hack below consists in replacing "::" in "name" with + // a very unlikely string without colons, before "name" is split by ":". + // After that, the replacement of "::" with this unlikely string is undone in "templateName". + // NOTE. + // This hack assumes that plugin types in CMSSW will never have "##" in their name. + String unlikelyStr = "##"; + String[] s = name.replaceAll("::", unlikelyStr).split(":"); String templateName = ""; String instanceName = ""; boolean copy = false; @@ -3083,7 +3094,9 @@ public static boolean insertReference(JTree tree, String type, String name) { templateName = s[1]; instanceName = s[2]; } - + + templateName = templateName.replaceAll(unlikelyStr, "::"); + ModuleTemplate template = config.release().moduleTemplate(templateName); if (!copy) {