return template;
}
- private warnTemplateKeysDeprecation(stationTemplate: ChargingStationTemplate) {
- const templateKeys: { key: string; deprecatedKey: string }[] = [
- { key: 'supervisionUrls', deprecatedKey: 'supervisionUrl' },
- { key: 'idTagsFile', deprecatedKey: 'authorizationFile' },
- ];
- for (const templateKey of templateKeys) {
- ChargingStationUtils.warnDeprecatedTemplateKey(
- stationTemplate,
- templateKey.deprecatedKey,
- this.templateFile,
- this.logPrefix(),
- `Use '${templateKey.key}' instead`
- );
- ChargingStationUtils.convertDeprecatedTemplateKey(
- stationTemplate,
- templateKey.deprecatedKey,
- templateKey.key
- );
- }
- }
-
private getStationInfoFromTemplate(): ChargingStationInfo {
const stationTemplate: ChargingStationTemplate | undefined = this.getTemplateFromFile();
if (Utils.isNullOrUndefined(stationTemplate)) {
logger.error(`${this.logPrefix()} ${errorMsg}`);
throw new BaseError(errorMsg);
}
- this.warnTemplateKeysDeprecation(stationTemplate);
+ ChargingStationUtils.warnTemplateKeysDeprecation(
+ this.templateFile,
+ stationTemplate,
+ this.logPrefix()
+ );
const stationInfo: ChargingStationInfo =
ChargingStationUtils.stationTemplateToStationInfo(stationTemplate);
stationInfo.hashId = ChargingStationUtils.getHashId(this.index, stationTemplate);
return Configuration.getWorker().processType === WorkerProcessType.dynamicPool;
}
- public static warnDeprecatedTemplateKey(
- template: ChargingStationTemplate,
- key: string,
+ public static warnTemplateKeysDeprecation(
templateFile: string,
- logPrefix: string,
- logMsgToAppend = ''
- ): void {
- if (!Utils.isUndefined(template[key])) {
- const logMsg = `Deprecated template key '${key}' usage in file '${templateFile}'${
- Utils.isNotEmptyString(logMsgToAppend) ? `. ${logMsgToAppend}` : ''
- }`;
- logger.warn(`${logPrefix} ${logMsg}`);
- console.warn(chalk.yellow(`${logMsg}`));
- }
- }
-
- public static convertDeprecatedTemplateKey(
- template: ChargingStationTemplate,
- deprecatedKey: string,
- key: string
- ): void {
- if (!Utils.isUndefined(template[deprecatedKey])) {
- template[key] = template[deprecatedKey] as unknown;
- delete template[deprecatedKey];
+ stationTemplate: ChargingStationTemplate,
+ logPrefix: string
+ ) {
+ const templateKeys: { key: string; deprecatedKey: string }[] = [
+ { key: 'supervisionUrls', deprecatedKey: 'supervisionUrl' },
+ { key: 'idTagsFile', deprecatedKey: 'authorizationFile' },
+ ];
+ for (const templateKey of templateKeys) {
+ ChargingStationUtils.warnDeprecatedTemplateKey(
+ stationTemplate,
+ templateKey.deprecatedKey,
+ templateFile,
+ logPrefix,
+ `Use '${templateKey.key}' instead`
+ );
+ ChargingStationUtils.convertDeprecatedTemplateKey(
+ stationTemplate,
+ templateKey.deprecatedKey,
+ templateKey.key
+ );
}
}
);
}
+ private static warnDeprecatedTemplateKey(
+ template: ChargingStationTemplate,
+ key: string,
+ templateFile: string,
+ logPrefix: string,
+ logMsgToAppend = ''
+ ): void {
+ if (!Utils.isUndefined(template[key])) {
+ const logMsg = `Deprecated template key '${key}' usage in file '${templateFile}'${
+ Utils.isNotEmptyString(logMsgToAppend) ? `. ${logMsgToAppend}` : ''
+ }`;
+ logger.warn(`${logPrefix} ${logMsg}`);
+ console.warn(chalk.yellow(`${logMsg}`));
+ }
+ }
+
+ private static convertDeprecatedTemplateKey(
+ template: ChargingStationTemplate,
+ deprecatedKey: string,
+ key: string
+ ): void {
+ if (!Utils.isUndefined(template[deprecatedKey])) {
+ template[key] = template[deprecatedKey] as unknown;
+ delete template[deprecatedKey];
+ }
+ }
+
/**
* Charging profiles should already be sorted by connectorId and stack level (highest stack level has priority)
*