/*
 * Wegas
 * http://wegas.albasim.ch
 *
 * Copyright (c) 2013-2017 School of Business and Engineering Vaud, Comem
 * Licensed under the MIT License
 */
package com.wegas.core.persistence;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.wegas.core.exception.client.WegasErrorMessage;
import com.wegas.core.persistence.variable.ModelScoped.Visibility;

/**
 *
 * @author maxence
 */
public interface Mergeable {

    /**
     * Get entity cross-gamemodel identifier
     *
     * @return
     */
    String getRefId();

    void setRefId(String refId);

    @JsonIgnore
        default boolean belongsToProtectedGameModel() {
        Mergeable p = this.getMergeableParent();
        if (p != null) {
            return p.belongsToProtectedGameModel();
        } else {
            throw WegasErrorMessage.error("Not yet implemented (" + this.toString() + ")");
        }
    }

    @JsonIgnore
    default Visibility getInheritedVisibility() {
        Mergeable p = this.getMergeableParent();
        if (p != null) {
            return p.getInheritedVisibility();
        } else {
            throw WegasErrorMessage.error("Not yet implemented (" + this.toString() + ")");
        }
    }

    @JsonIgnore
    <T extends Mergeable> T getMergeableParent();
}

@@ -294,16 +294,72 @@
 essage;%0A
+import com.wegas.core.persistence.variable.ModelScoped;%0A
 import c
@@ -417,16 +417,16 @@
 bility;%0A
-
 %0A/**%0A *%0A
@@ -635,20 +635,16 @@
 nIgnore%0A
-    
     defa
@@ -683,24 +683,24 @@
 meModel() %7B%0A
+
         Merg
@@ -1071,32 +1071,159 @@
 f (p != null) %7B%0A
+            if (p instanceof ModelScoped) %7B%0A                return ((ModelScoped) p).getVisibility();%0A            %7D else %7B%0A    
             retu
@@ -1245,32 +1245,46 @@
 edVisibility();%0A
+            %7D%0A
         %7D else %7B

fix get inherited visibility