From be72706d8eee55d82883def0cb435448e256d89c Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 24 Jan 2024 15:38:01 +0100 Subject: [PATCH] Added rules-path option to configuration --- .../retriever/core/cli/RetrieverApplication.java | 12 ++++++++++++ .../RetrieverConfigurationImpl.java | 16 ++++++++++++++++ .../engine/RetrieverConfiguration.java | 4 ++++ 3 files changed, 32 insertions(+) diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/cli/RetrieverApplication.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/cli/RetrieverApplication.java index 715029f0..cecbb4c7 100644 --- a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/cli/RetrieverApplication.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/cli/RetrieverApplication.java @@ -36,6 +36,8 @@ private static Options createOptions(final Set availableRuleIDs) { .addRequiredOption("r", "rules", true, "Supported rules for reverse engineering: " + String.join(", ", availableRuleIDs)); + options.addOption("x", "rules-directory", true, "Path to the directory with additional project specific rules."); + options.addOption("h", "help", false, "Print this help message."); return options; @@ -99,6 +101,16 @@ public Object start(final IApplicationContext context) throws Exception { return -1; } + try { + configuration.setRulesFolder(URI.createFileURI(URI.decode(Paths.get(cmd.getOptionValue("x")) + .toAbsolutePath() + .normalize() + .toString()))); + } catch (final InvalidPathException e) { + System.err.println("Invalid rules path: " + e.getMessage()); + return -1; + } + // Enable all discoverers, in case a selected rule depends on them. // TODO: This is unnecessary once rule dependencies are in place final ServiceConfiguration discovererConfig = configuration.getConfig(Discoverer.class); diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/configuration/RetrieverConfigurationImpl.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/configuration/RetrieverConfigurationImpl.java index a2246e11..4020d461 100644 --- a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/configuration/RetrieverConfigurationImpl.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/configuration/RetrieverConfigurationImpl.java @@ -27,6 +27,7 @@ public class RetrieverConfigurationImpl extends AbstractComposedJobConfiguration private static final String CONFIG_PREFIX = "org.palladiosimulator.retriever.core.configuration."; public static final String RULE_ENGINE_INPUT_PATH = "input.path"; public static final String RULE_ENGINE_OUTPUT_PATH = CONFIG_PREFIX + "output.path"; + public static final String RULE_ENGINE_RULES_PATH = CONFIG_PREFIX + "rules.path"; public static final String RULE_ENGINE_SELECTED_RULES = CONFIG_PREFIX + "rules"; public static final String RULE_ENGINE_SELECTED_ANALYSTS = CONFIG_PREFIX + "analysts"; public static final String RULE_ENGINE_SELECTED_DISCOVERERS = CONFIG_PREFIX + "discoverers"; @@ -36,6 +37,7 @@ public class RetrieverConfigurationImpl extends AbstractComposedJobConfiguration private /* not final */ URI inputFolder; private /* not final */ URI outputFolder; + private /* not final */ URI rulesFolder; private final Map, ServiceConfiguration> serviceConfigs; @@ -99,6 +101,9 @@ public void applyAttributeMap(final Map attributeMap) { if (attributeMap.get(RULE_ENGINE_OUTPUT_PATH) != null) { this.setOutputFolder(URI.createURI((String) attributeMap.get(RULE_ENGINE_OUTPUT_PATH))); } + if (attributeMap.get(RULE_ENGINE_RULES_PATH) != null) { + this.setRulesFolder(URI.createURI((String) attributeMap.get(RULE_ENGINE_RULES_PATH))); + } for (final ServiceConfiguration serviceConfig : this.serviceConfigs.values()) { serviceConfig.applyAttributeMap(attributeMap); @@ -120,6 +125,11 @@ public URI getOutputFolder() { return this.outputFolder; } + @Override + public URI getRulesFolder() { + return this.rulesFolder; + } + @Override public void setInputFolder(final URI inputFolder) { this.inputFolder = inputFolder; @@ -130,6 +140,11 @@ public void setOutputFolder(final URI outputFolder) { this.outputFolder = outputFolder; } + @Override + public void setRulesFolder(final URI rulesFolder) { + this.rulesFolder = rulesFolder; + } + @Override public ServiceConfiguration getConfig(final Class serviceClass) { // serviceConfig only contains legal mappings @@ -143,6 +158,7 @@ public Map toMap() { result.put(RULE_ENGINE_INPUT_PATH, this.getInputFolder()); result.put(RULE_ENGINE_OUTPUT_PATH, this.getOutputFolder()); + result.put(RULE_ENGINE_RULES_PATH, this.getRulesFolder()); for (final ServiceConfiguration serviceConfig : this.serviceConfigs.values()) { result.putAll(serviceConfig.toMap()); diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/RetrieverConfiguration.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/RetrieverConfiguration.java index b61a4a0a..0f1d5a9a 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/RetrieverConfiguration.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/RetrieverConfiguration.java @@ -14,6 +14,10 @@ public interface RetrieverConfiguration extends ExtendableJobConfiguration { void setOutputFolder(URI createFileURI); + URI getRulesFolder(); + + void setRulesFolder(URI createFileURI); + ServiceConfiguration getConfig(Class serviceClass); }