Migrate Smart Charging module
MODIFY
.gitmodules
.gitmodules
path = src/integration/refund/concur
url = ../../sap-labs-france/ev-sap-refund-concur.git
branch = master
-[submodule "src/integration/smart-charging/sap-smart-charging"]
- path = src/integration/smart-charging/sap-smart-charging
- url = ../../sap-labs-france/ev-sap-smart-charging.git
- branch = master
[submodule "src/assets/charging-station-templates"]
path = src/assets/charging-station-templates
url = ../../sap-labs-france/ev-sap-charging-station-templates.git

MODIFY
package.json
package.json
"git:supdate": "git submodule update --remote --recursive --merge",
"git:spush": "git push --recurse-submodules=on-demand",
"git:sreset": "git submodule foreach 'git reset --hard'",
- "components:export": "node src/componentsExport.js",
"start": "npm run start:prod",
"prestart": "npm run build:prod",
"config:batch": "ncp src/assets/configs-scp/e-Mobility-config/config_batch_server.json dist/assets/config.json",
"config:rest": "ncp src/assets/configs-scp/e-Mobility-config/config_rest_server.json dist/assets/config.json",
"config:chargebox-json": "ncp src/assets/configs-scp/e-Mobility-config/config_chargebox_json_server.json dist/assets/config.json",
"config:chargebox-soap": "ncp src/assets/configs-scp/e-Mobility-config/config_chargebox_soap_server.json dist/assets/config.json",
- "start:dev": "npm run components:export && cross-env NODE_ENV=development ts-node-dev --files --max-old-space-size=4096 -- src/start.ts",
- "start:dev:debug": "npm run components:export && cross-env NODE_ENV=development ts-node-dev --inspect --files --max-old-space-size=4096 -- src/start.ts",
- "start:dev:nodemon": "npm run components:export && nodemon --exec 'ts-node --files' src/start.ts",
- "start:dev:debug:nodemon": "npm run components:export && nodemon --exec 'ts-node --files' src/start.ts 9229",
+ "start:dev": "cross-env NODE_ENV=development ts-node-dev --files --max-old-space-size=4096 -- src/start.ts",
+ "start:dev:debug": "cross-env NODE_ENV=development ts-node-dev --inspect --files --max-old-space-size=4096 -- src/start.ts",
+ "start:dev:nodemon": "nodemon --exec 'ts-node --files' src/start.ts",
+ "start:dev:debug:nodemon": "nodemon --exec 'ts-node --files' src/start.ts 9229",
"start:dev:prof": "cross-env NODE_OPTIONS=\"--max-old-space-size=4096\" NODE_ENV=development node -r source-map-support/register --prof -- dist/start.js",
"start:dev:doctorprof": "cross-env NODE_OPTIONS=\"--max-old-space-size=4096\" NODE_ENV=development clinic doctor -- node -r source-map-support/register dist/start.js",
"start:dev:flameprof": "cross-env NODE_OPTIONS=\"--max-old-space-size=4096\" NODE_ENV=development clinic flame -- node -r source-map-support/register dist/start.js",

DELETE
src/componentsExport.js
-const fs = require('fs');
-
-class Components {
- static exportConcurRefundIntegrationImpl() {
- const indexModuleFile = __dirname + '/integration/refund/export/concur/index.ts';
- let exportModuleString
- if (fs.existsSync(__dirname + '/integration/refund/concur/index.ts')) {
- exportModuleString = 'export { default } from \'../../concur\';\n';
- } else {
- exportModuleString = 'export { default } from \'../../dummy/DummyRefundIntegration\';\n';
- }
- fs.writeFileSync(indexModuleFile, exportModuleString);
- }
-
- static exportSapSmartChargingIntegrationImpl() {
- const indexModuleFile = __dirname + '/integration/smart-charging/export/sap-smart-charging/index.ts';
- let exportModuleString
- if (fs.existsSync(__dirname + '/integration/smart-charging/sap-smart-charging/index.ts')) {
- exportModuleString = 'export { default } from \'../../sap-smart-charging\';\n';
- } else {
- exportModuleString = 'export { default } from \'../../dummy/DummySmartChargingIntegration\';\n';
- }
- fs.writeFileSync(indexModuleFile, exportModuleString);
- }
-
- static exportConvergentChargingIntegrationImpl() {
- const indexModuleFile = __dirname + '/integration/pricing/export/convergent-charging/index.ts';
- let exportModuleString
- if (fs.existsSync(__dirname + '/integration/pricing/convergent-charging/index.ts')) {
- exportModuleString = 'export { default } from \'../../convergent-charging\';\n';
- } else {
- exportModuleString = 'export { default } from \'../../dummy/DummyPricingIntegration\';\n';
- }
- fs.writeFileSync(indexModuleFile, exportModuleString);
- }
-
- static export() {
- this.exportConcurRefundIntegrationImpl()
- this.exportSapSmartChargingIntegrationImpl()
- this.exportConvergentChargingIntegrationImpl()
- }
-}
-
-Components.export()

MODIFY
src/integration/smart-charging/SmartChargingFactory.ts
src/integration/smart-charging/SmartChargingFactory.ts
import { SmartChargingSetting, SmartChargingSettingsType } from '../../types/Setting';
+import Tenant, { TenantComponents } from '../../types/Tenant';
-import DummySapSmartChargingIntegration from './dummy/DummySmartChargingIntegration';
-import SapSmartChargingIntegration from './export/sap-smart-charging';
+import SapSmartChargingIntegration from './sap-smart-charging/SapSmartChargingIntegration';
import SettingStorage from '../../storage/mongodb/SettingStorage';
import SmartChargingIntegration from './SmartChargingIntegration';
-import Tenant from '../../types/Tenant';
-import { TenantComponents } from '../../types/Tenant';
import Utils from '../../utils/Utils';
export default class SmartChargingFactory {
static async getSmartChargingImpl(tenant: Tenant): Promise<SmartChargingIntegration<SmartChargingSetting>> {
- // Check if the pricing is active
+ // Check if Smart Charging is active
if (Utils.isTenantComponentActive(tenant, TenantComponents.SMART_CHARGING)) {
// Get the Smart Charging's settings
const smartChargingSetting = await SettingStorage.getSmartChargingSettings(tenant);
@@ -22,15 +20,9 @@ export default class SmartChargingFactory {
smartChargingIntegrationImpl = new SapSmartChargingIntegration(tenant, smartChargingSetting.sapSmartCharging);
break;
}
- // Check if missing implementation
- if (smartChargingIntegrationImpl instanceof DummySapSmartChargingIntegration) {
- return null;
- }
- // Return the Smart Charging implementation
return smartChargingIntegrationImpl;
}
}
- // Smart Charging is not active
return null;
}
}

DELETE
src/integration/smart-charging/dummy/DummySmartChargingIntegration.ts
-/* eslint-disable @typescript-eslint/no-unused-vars */
-import { ChargingProfile } from '../../../types/ChargingProfile';
-import SiteArea from '../../../types/SiteArea';
-import SmartChargingIntegration from '../SmartChargingIntegration';
-import Tenant from '../../../types/Tenant';
-
-export default class DummySapSmartChargingIntegration<SmartChargingSetting> extends SmartChargingIntegration<SmartChargingSetting> {
- constructor(tenant: Tenant, setting: SmartChargingSetting) {
- super(tenant, setting);
- }
-
- public async buildChargingProfiles(siteArea: SiteArea): Promise<ChargingProfile[]> {
- return null;
- }
-
- public async checkConnection() {
- }
-}

DELETE
src/integration/smart-charging/export/sap-smart-charging/.gitkeep
src/integration/smart-charging/export/sap-smart-charging/.gitkeep
Migrate Smart Charging module