commit 07a93b22c63b87a25ba3385204fcc3f4a681d1bd
Author: Hrabikv <hrabikv@students.zcu.cz>
Date:   Sun Oct 15 15:09:45 2023 +0200

    https://kivprogrammers.atlassian.net/browse/TSP2-29

diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/UserConfiguration.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/UserConfiguration.java
index b321241..a8b7fe2 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/UserConfiguration.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/UserConfiguration.java
@@ -7,29 +7,32 @@ package cz.zcu.fav.kiv.antipatterndetectionapp.v2.model;
  */
 public class UserConfiguration {
     private User user;
-    private Configuration configuration;
+    private ConfigurationDto configuration;
+    private String isDefault;
+    private String configurationName;
 
-
-    public UserConfiguration(User user, Configuration configuration){
+    public UserConfiguration(User user, ConfigurationDto configuration, String isDefault, String configurationName) {
         this.user = user;
         this.configuration = configuration;
+        this.isDefault = isDefault;
+        this.configurationName = configurationName;
     }
     public UserConfiguration(){}
 
 
     public User getUser() {
-        return user;
+        return this.user;
     }
 
-    public Configuration getConfiguration() {
-        return configuration;
+    public ConfigurationDto getConfiguration() {
+        return this.configuration;
     }
 
     public void setUser(User user) {
         this.user = user;
     }
 
-    public void setConfiguration(Configuration configuration) {
+    public void setConfiguration(ConfigurationDto configuration) {
         this.configuration = configuration;
     }
 
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/configuration/ConfigurationServiceImplementation.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/configuration/ConfigurationServiceImplementation.java
index 2b58190..f7c6417 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/configuration/ConfigurationServiceImplementation.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/configuration/ConfigurationServiceImplementation.java
@@ -59,17 +59,40 @@ public class ConfigurationServiceImplementation implements ConfigService {
         if (existingConfiguration == null) {
             configuration.setHash(configHash);
             //save the configuration itself
-            Configuration tmp = this.configurationRepository.save(configuration);
+            this.configurationRepository.save(configuration);
             //can only happen if db server fails or a constraint is breached
             if (configuration == null) {
                 return ConfigurationControllerStatusCodes.INSERT_FAILED;
             }
         }
+        //already exists, update pointer to instance with id
+        else {
+            configuration = existingConfiguration;
+        }
         //pair the configuration to the user
         pairConfigurationWithUser(user,configuration);
         return ConfigurationControllerStatusCodes.INSERT_SUCCESSFUL;
+    }
 
+    /**
+     * Parser for user request wrapped around configuration
+     * @param cfg UserConfiguration instance - wrapper around user request
+     * @return Configuration or Null - null if the request wrapper does not containt json defition of antipatterns
+     *         Instace of Configuration if the request is Okay
+     */
+    private Configuration parseUserConfiguration(UserConfiguration cfg){
+        ConfigurationDto configurationDto = cfg.getConfiguration();
+        String configurationDefinition = new Gson().toJson(configurationDto);
+        String userConfigurationName = cfg.getConfigurationName();
+        String defaultConfigName = null;
+        if (configurationDefinition == null) {
+            return null;
+        }
+        if (userConfigurationName == null) {
+            defaultConfigName = "ahoj_svete";
+        }
 
+        return new Configuration(configurationDefinition,null,cfg.getIsDefault(),userConfigurationName,defaultConfigName);
     }
 
     /**
