Skip to content

Instantly share code, notes, and snippets.

View sonOfRa's full-sized avatar

Simon Levermann sonOfRa

View GitHub Profile
import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException;
import jakarta.annotation.Priority;
import jakarta.ws.rs.BadRequestException;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.ext.ExceptionMapper;
import jakarta.ws.rs.ext.Provider;
import org.keycloak.common.util.Resteasy;
import org.keycloak.models.KeycloakSession;
import org.keycloak.services.error.KeycloakErrorHandler;
package de.slevermann.cocktails.service;
import de.slevermann.cocktails.dao.UserDao;
import de.slevermann.cocktails.mapper.UserInfoMapper;
import de.slevermann.cocktails.model.db.DbUserInfo;
import org.junit.jupiter.api.Test;
import org.mockito.junit.jupiter.MockitoSettings;
import org.springframework.web.server.ResponseStatusException;
import java.util.UUID;
package de.slevermann.cocktails.models;
import java.util.Objects;
import io.swagger.annotations.ApiModel;
import java.util.HashMap;
import java.util.Map;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import javax.validation.constraints.*;
-- When support for new languages is added, this file needs to be updated to reflect the newly added language
-- Find the best suitable language for an entry
-- Returns the preferred input if it is present as a key, otherwise falls back through the list to different values
CREATE OR REPLACE FUNCTION find_language(store hstore, preferred varchar) RETURNS varchar AS
$$
SELECT CASE
WHEN store ? preferred THEN preferred
WHEN store ? 'en' THEN 'en'
WHEN store ? 'de' THEN 'de'
-- Find the best suitable language for an entry
-- Returns the preferred input if it is present as a key, otherwise falls back through the list to different values
CREATE OR REPLACE FUNCTION find_language(store hstore, preferred varchar) RETURNS varchar AS
$$
SELECT CASE
WHEN preferred = ANY (akeys(store)) THEN preferred
WHEN 'en' = ANY (akeys(store)) THEN 'en'
WHEN 'de' = ANY (akeys(store)) THEN 'de'
END
$$
SELECT id,
CASE
WHEN :language = ANY (keys) THEN :language
WHEN 'en' = ANY (keys) THEN 'en'
WHEN 'de' = ANY (keys) THEN 'de'
END AS locale,
name -> locale
FROM ingredient_type,
akeys(name) AS keys
SELECT *
FROM (SELECT DISTINCT ON (id) id.description AS description,
id.name AS name,
itn.name AS typename,
itn.ingredient_type_id AS typeid,
l.language AS language,
l.country AS country,
ingredient.id AS id
FROM ingredient
JOIN ingredient_data id ON ingredient.id = id.ingredient_id
package de.slevermann.cocktails.services;
import de.slevermann.cocktails.daos.IngredientDao;
import de.slevermann.cocktails.models.Ingredient;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
package de.slevermann.cocktails.config;
import de.slevermann.cocktails.daos.IngredientDao;
import de.slevermann.cocktails.daos.IngredientNameDao;
import org.jdbi.v3.core.Jdbi;
import org.jdbi.v3.core.enums.EnumStrategy;
import org.jdbi.v3.core.enums.Enums;
import org.jdbi.v3.core.mapper.RowMapper;
import org.jdbi.v3.core.spi.JdbiPlugin;
import org.jdbi.v3.sqlobject.SqlObjectPlugin;
04-08 03:36:02.487: E/CoverageListener(9390): Failed to generate Emma/JaCoCo coverage.
04-08 03:36:02.487: E/CoverageListener(9390): java.lang.reflect.InvocationTargetException
04-08 03:36:02.487: E/CoverageListener(9390): at java.lang.reflect.Method.invoke(Native Method)
04-08 03:36:02.487: E/CoverageListener(9390): at androidx.test.internal.runner.listener.CoverageListener.generateCoverageReport(CoverageListener.java:101)
04-08 03:36:02.487: E/CoverageListener(9390): at androidx.test.internal.runner.listener.CoverageListener.instrumentationRunFinished(CoverageListener.java:70)
04-08 03:36:02.487: E/CoverageListener(9390): at androidx.test.internal.runner.TestExecutor.reportRunEnded(TestExecutor.java:92)
04-08 03:36:02.487: E/CoverageListener(9390): at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:65)
04-08 03:36:02.487: E/CoverageListener(9390): at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:392)
04-08 03:36:02.487: E/CoverageListener(9390): at andr