Source:
protected UserResourceProfileEntity saveUserResourceProfile(UserResourceProfile userResourceProfile) throws AppCatalogException { String userId = userResourceProfile.getUserId(); String gatewayId = userResourceProfile.getGatewayID(); Mapper mapper = ObjectMapperSingleton.getInstance(); UserResourceProfileEntity userResourceProfileEntity = mapper.map(userResourceProfile, UserResourceProfileEntity.class); if (userResourceProfileEntity.getUserComputeResourcePreferences() != null) { logger.debug("Populating the Primary Key UserComputeResourcePreferences objects for the User Resource Profile"); userResourceProfileEntity.getUserComputeResourcePreferences().forEach(userComputeResourcePreferenceEntity -> userComputeResourcePreferenceEntity.setUserId(userId)); userResourceProfileEntity.getUserComputeResourcePreferences().forEach(userComputeResourcePreferenceEntity -> userComputeResourcePreferenceEntity.setGatewayId(gatewayId)); } if (userResourceProfileEntity.getUserStoragePreferences() != null) { logger.debug("Populating the Primary Key UserStoragePreferences objects for the User Resource Profile"); userResourceProfileEntity.getUserStoragePreferences().forEach(userStoragePreferenceEntity -> userStoragePreferenceEntity.setUserId(userId)); userResourceProfileEntity.getUserStoragePreferences().forEach(userStoragePreferenceEntity -> userStoragePreferenceEntity.setGatewayId(gatewayId)); } if (!isUserResourceProfileExists(userId, gatewayId)) { logger.debug("Checking if the User Resource Profile already exists"); userResourceProfileEntity.setCreationTime(new Timestamp(System.currentTimeMillis())); } userResourceProfileEntity.setUpdateTime(new Timestamp(System.currentTimeMillis())); return execute(entityManager -> entityManager.merge(userResourceProfileEntity)); }

Target:
protected UserResourceProfileEntity saveUserResourceProfile(UserResourceProfile userResourceProfile) throws AppCatalogException { String userId = userResourceProfile.getUserId(); String gatewayId = userResourceProfile.getGatewayID(); Mapper mapper = ObjectMapperSingleton.getInstance(); UserResourceProfileEntity userResourceProfileEntity = mapper.map(userResourceProfile, UserResourceProfileEntity.class); if (userResourceProfileEntity.getUserComputeResourcePreferences() != null) { logger.debug("Populating the Primary Key UserComputeResourcePreferences objects for the User Resource Profile"); userResourceProfileEntity.getUserComputeResourcePreferences().forEach(userComputeResourcePreferenceEntity -> { userComputeResourcePreferenceEntity.setUserId(userId); userComputeResourcePreferenceEntity.setGatewayId(gatewayId); }); } if (userResourceProfileEntity.getUserStoragePreferences() != null) { logger.debug("Populating the Primary Key UserStoragePreferences objects for the User Resource Profile"); userResourceProfileEntity.getUserStoragePreferences().forEach(userStoragePreferenceEntity -> { userStoragePreferenceEntity.setUserId(userId); userStoragePreferenceEntity.setGatewayId(gatewayId); }); } if (!isUserResourceProfileExists(userId, gatewayId)) { logger.debug("Checking if the User Resource Profile already exists"); userResourceProfileEntity.setCreationTime(new Timestamp(System.currentTimeMillis())); } userResourceProfileEntity.setUpdateTime(new Timestamp(System.currentTimeMillis())); return execute(entityManager -> entityManager.merge(userResourceProfileEntity)); }