use of ma.glasnost.orika.impl.ConfigurableMapper in project open-smart-grid-platform by OSGP.
the class ActionMapperService method mapAllActions.
public List<ActionRequest> mapAllActions(final List<? extends Action> actionList) throws FunctionalException {
final List<ActionRequest> actionRequestList = new ArrayList<>();
for (final Action action : actionList) {
final ConfigurableMapper mapper = CLASS_TO_MAPPER_MAP.get(action.getClass());
final Class<? extends ActionRequest> clazz = CLASS_MAP.get(action.getClass());
if (mapper != null) {
actionRequestList.add(this.getActionRequestWithDefaultMapper(action, mapper, clazz));
} else {
throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.DOMAIN_SMART_METERING, new AssertionError("No mapper defined for class: " + action.getClass().getName()));
}
}
return actionRequestList;
}
use of ma.glasnost.orika.impl.ConfigurableMapper in project open-smart-grid-platform by OSGP.
the class ActionMapperResponseService method mapAllActions.
public BundleResponse mapAllActions(final Serializable actionList) throws FunctionalException {
final BundleMessagesResponse bundleResponseMessageDataContainer = (BundleMessagesResponse) actionList;
final AllResponses allResponses = new ObjectFactory().createAllResponses();
final List<? extends ActionResponse> actionValueList = bundleResponseMessageDataContainer.getBundleList();
for (final ActionResponse actionValueResponseObject : actionValueList) {
final ConfigurableMapper mapper = this.getMapper(actionValueResponseObject);
final Class<?> clazz = this.getClazz(actionValueResponseObject);
final Response response = this.doMap(actionValueResponseObject, mapper, clazz);
allResponses.getResponseList().add(response);
}
final BundleResponse bundleResponse = new ObjectFactory().createBundleResponse();
bundleResponse.setAllResponses(allResponses);
return bundleResponse;
}
use of ma.glasnost.orika.impl.ConfigurableMapper in project open-smart-grid-platform by OSGP.
the class ActionMapperService method mapActionWithoutConverter.
private ActionDto mapActionWithoutConverter(final SmartMeter smartMeter, final ActionRequest action) throws FunctionalException {
final Class<? extends ActionRequestDto> clazz = CLASS_MAP.get(action.getClass());
final ConfigurableMapper mapper = CLASS_TO_MAPPER_MAP.get(action.getClass());
if (mapper != null) {
return this.mapActionWithMapper(smartMeter, action, clazz, mapper);
} else {
throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.DOMAIN_SMART_METERING, new AssertionError(String.format("No mapper defined for class: %s", clazz.getName())));
}
}
use of ma.glasnost.orika.impl.ConfigurableMapper in project open-smart-grid-platform by OSGP.
the class ActionMapperResponseService method mapAllActions.
public BundleMessagesResponse mapAllActions(final BundleMessagesRequestDto bundleMessageResponseDto) throws FunctionalException {
final List<ActionResponse> actionResponseList = new ArrayList<>();
for (final ActionResponseDto action : bundleMessageResponseDto.getAllResponses()) {
final ConfigurableMapper mapper = this.getMapper(action);
final Class<? extends ActionResponse> clazz = this.getClazz(action);
// mapper is monitoring mapper
final ActionResponse actionValueResponseObject = this.doMap(action, mapper, clazz);
actionResponseList.add(actionValueResponseObject);
}
return new BundleMessagesResponse(actionResponseList);
}
Aggregations