Added carConnectorData to rest service
MODIFY
src/authorization/AuthorizationsDefinition.ts
src/authorization/AuthorizationsDefinition.ts
@@ -283,7 +283,7 @@ const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
'carCatalog.chargeStandardPower', 'carCatalog.chargeStandardPhaseAmp', 'carCatalog.chargeStandardPhase',
'carCatalog.chargeAlternativePower', 'carCatalog.chargeAlternativePhaseAmp', 'carCatalog.chargeAlternativePhase',
'carCatalog.chargeOptionPower', 'carCatalog.chargeOptionPhaseAmp', 'carCatalog.chargeOptionPhase',
- 'user.id', 'user.name', 'user.firstName', 'userID',
+ 'user.id', 'user.name', 'user.firstName', 'userID', 'carConnectorData.carConnectorID', 'carConnectorData.carConnectorMeterID'
]
},
{
@@ -386,7 +386,7 @@ const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
'carCatalog.chargeStandardPower', 'carCatalog.chargeStandardPhaseAmp', 'carCatalog.chargeStandardPhase',
'carCatalog.chargeAlternativePower', 'carCatalog.chargeAlternativePhaseAmp', 'carCatalog.chargeAlternativePhase',
'carCatalog.chargeOptionPower', 'carCatalog.chargeOptionPhaseAmp', 'carCatalog.chargeOptionPhase',
- 'user.id', 'user.name', 'user.firstName', 'userID',
+ 'user.id', 'user.name', 'user.firstName', 'userID', 'carConnectorData.carConnectorID', 'carConnectorData.carConnectorMeterID'
],
},
{
@@ -805,7 +805,7 @@ const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
'carCatalogID', 'carCatalog.vehicleMake', 'carCatalog.vehicleModel', 'carCatalog.vehicleModelVersion', 'carCatalog.image',
'carCatalog.chargeStandardPower', 'carCatalog.chargeStandardPhaseAmp', 'carCatalog.chargeStandardPhase',
'carCatalog.chargeAlternativePower', 'carCatalog.chargeAlternativePhaseAmp', 'carCatalog.chargeAlternativePhase',
- 'carCatalog.chargeOptionPower', 'carCatalog.chargeOptionPhaseAmp', 'carCatalog.chargeOptionPhase'
+ 'carCatalog.chargeOptionPower', 'carCatalog.chargeOptionPhaseAmp', 'carCatalog.chargeOptionPhase', 'carConnectorData.carConnectorID', 'carConnectorData.carConnectorMeterID'
],
},
{

MODIFY
src/server/rest/v1/service/CarService.ts
src/server/rest/v1/service/CarService.ts
@@ -3,6 +3,7 @@ import { AsyncTaskType, AsyncTasks } from '../../../../types/AsyncTask';
import { CarCatalogDataResult, CarDataResult } from '../../../../types/DataResult';
import { HTTPAuthError, HTTPError } from '../../../../types/HTTPError';
import { NextFunction, Request, Response } from 'express';
+import Tenant, { TenantComponents } from '../../../../types/Tenant';
import AppAuthError from '../../../../exception/AppAuthError';
import AppError from '../../../../exception/AppError';
@@ -17,8 +18,6 @@ import LockingHelper from '../../../../locking/LockingHelper';
import LockingManager from '../../../../locking/LockingManager';
import Logging from '../../../../utils/Logging';
import { ServerAction } from '../../../../types/Server';
-import Tenant from '../../../../types/Tenant';
-import { TenantComponents } from '../../../../types/Tenant';
import Utils from '../../../../utils/Utils';
import UtilsService from './UtilsService';
@@ -265,6 +264,7 @@ export default class CarService {
userID: filteredRequest.userID,
default: filteredRequest.default,
converter: filteredRequest.converter,
+ carConnectorData: filteredRequest.carConnectorData,
createdOn: new Date()
};
// Save
@@ -343,6 +343,7 @@ export default class CarService {
car.converter = filteredRequest.converter;
car.userID = filteredRequest.userID;
car.default = filteredRequest.default;
+ car.carConnectorData = filteredRequest.carConnectorData;
car.lastChangedBy = { 'id': req.user.id };
car.lastChangedOn = new Date();
// Save

MODIFY
src/server/rest/v1/service/security/CarSecurity.ts
src/server/rest/v1/service/security/CarSecurity.ts
@@ -55,8 +55,10 @@ export default class CarSecurity {
type: sanitize(request.converter.type),
powerWatts: sanitize(request.converter.powerWatts)
},
- carConnectorID: sanitize(request.carConnectorID),
- carConnectorMeterID: sanitize(request.carConnectorMeterID)
+ carConnectorData: {
+ carConnectorID: sanitize(request.carConnectorData.carConnectorID),
+ carConnectorMeterID: sanitize(request.carConnectorData.carConnectorMeterID)
+ }
};
}
@@ -75,8 +77,10 @@ export default class CarSecurity {
type: sanitize(request.converter.type),
powerWatts: sanitize(request.converter.powerWatts)
},
- carConnectorID: sanitize(request.carConnectorID),
- carConnectorMeterID: sanitize(request.carConnectorMeterID)
+ carConnectorData: {
+ carConnectorID: sanitize(request.carConnectorData.carConnectorID),
+ carConnectorMeterID: sanitize(request.carConnectorData.carConnectorMeterID)
+ }
};
return filteredRequest;
}
@@ -86,7 +90,8 @@ export default class CarSecurity {
Search: sanitize(request.Search),
CarMaker: sanitize(request.CarMaker),
WithUser: UtilsSecurity.filterBoolean(request.WithUser),
- UserID: sanitize(request.UserID)
+ UserID: sanitize(request.UserID),
+ WithCarConnector: UtilsSecurity.filterBoolean(request.WithCarConnector),
} as HttpCarsRequest;
UtilsSecurity.filterSkipAndLimit(request, filteredRequest);
UtilsSecurity.filterSort(request, filteredRequest);

MODIFY
src/storage/mongodb/CarStorage.ts
src/storage/mongodb/CarStorage.ts
@@ -497,6 +497,10 @@ export default class CarStorage {
amperagePerPhase: Utils.convertToInt(carToSave.converter.amperagePerPhase),
numberOfPhases: Utils.convertToFloat(carToSave.converter.numberOfPhases),
type: carToSave.converter.type
+ },
+ carConnectorData: {
+ carConnectorID: carToSave.carConnectorData.carConnectorID,
+ carConnectorMeterID: carToSave.carConnectorData.carConnectorMeterID
}
};
// Add Last Changed/Created props

MODIFY
src/storage/mongodb/DatabaseUtils.ts
src/storage/mongodb/DatabaseUtils.ts
@@ -158,7 +158,7 @@ export default class DatabaseUtils {
}
}
- public static pushCollectionLookupInAggregation(collection: string, lookupParams: DbLookup, additionalPipeline?: Record<string, any>[]): void {
+ public static pushCollectionLookupInAggregation(collection: string, lookupParams: Partial<DbLookup>, additionalPipeline?: Record<string, any>[]): void {
// Build Lookup's pipeline
if (!lookupParams.pipelineMatch) {
lookupParams.pipelineMatch = {};

MODIFY
src/types/Car.ts
src/types/Car.ts
import { AuthorizationActions } from './Authorization';
-import CreatedUpdatedProps from './CreatedUpdatedProps';
import { CarConnectorConnectionSetting } from './Setting';
+import CreatedUpdatedProps from './CreatedUpdatedProps';
export interface CarCatalog extends CreatedUpdatedProps, AuthorizationActions {
id: number;
@@ -139,9 +139,7 @@ export interface Car extends CreatedUpdatedProps, AuthorizationActions {
default: boolean;
type?: CarType;
converter?: CarConverter;
- carConnectorID?: string;
- carConnectorMeterID?: string;
- carConnector?: CarConnectorConnectionSetting
+ carConnectorData?: CarConnectorData;
}
export interface CarConverter {
@@ -197,3 +195,8 @@ export interface CarCatalogConverter {
chargeTime: number;
chargeSpeed: number;
}
+
+export interface CarConnectorData {
+ carConnectorID?: string;
+ carConnectorMeterID?: string;
+}

MODIFY
src/types/requests/HttpCarRequest.ts
src/types/requests/HttpCarRequest.ts
import { CarConverter, CarType } from '../Car';
-import { CarConnectorConnectionSetting } from '../Setting';
import HttpByIDRequest from './HttpByIDRequest';
import HttpDatabaseRequest from './HttpDatabaseRequest';
@@ -35,9 +34,11 @@ export interface HttpCarCreateRequest {
converter?: CarConverter;
userID: string;
default: boolean;
+ carConnectorData: {
carConnectorID: string;
carConnectorMeterID: string;
}
+}
export interface HttpCarUpdateRequest {
id?: string;
@@ -49,9 +50,11 @@ export interface HttpCarUpdateRequest {
converter?: CarConverter;
userID: string;
default: boolean;
+ carConnectorData: {
carConnectorID: string;
carConnectorMeterID: string;
}
+}
export interface HttpCarsRequest extends HttpDatabaseRequest {
Search: string;

Added carConnectorData to rest service