use of com.devonfw.cobigen.impl.model.ContextVariableResolver in project cobigen by devonfw.
the class ConfigurationInterpreterImpl method resolveTemplateDestinationPath.
@Override
public Path resolveTemplateDestinationPath(Path targetRootPath, TemplateTo template, Object input) {
Trigger trigger = this.configurationHolder.readContextConfiguration().getTrigger(template.getTriggerId());
InputValidator.validateTrigger(trigger);
TriggerInterpreter triggerInterpreter = PluginRegistry.getTriggerInterpreter(trigger.getType());
// the GenerationReportTo won't be further processed
Variables variables = new ContextVariableResolver(input, trigger).resolveVariables(triggerInterpreter, new GenerationReportTo());
Template templateEty = this.configurationHolder.readTemplatesConfiguration(trigger).getTemplate(template.getId());
try {
String resolvedDestinationPath = new PathExpressionResolver(variables).evaluateExpressions(templateEty.getUnresolvedTargetPath());
return targetRootPath.resolve(resolvedDestinationPath).normalize();
} catch (UnknownContextVariableException e) {
throw new CobiGenRuntimeException("Could not resolve path '" + templateEty.getUnresolvedTargetPath() + "' for input '" + (input instanceof Object[] ? Arrays.toString((Object[]) input) : input.toString()) + "' and template '" + templateEty.getAbsoluteTemplatePath() + "'. Available variables: " + variables.toString());
}
}
Aggregations