Class ItemModelContextImpl

    • Method Detail

      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • isDynamicAttribute

        public boolean isDynamicAttribute​(java.lang.String attributeName)
        Description copied from interface: ItemModelInternalContext
        Returns information whether given attribute is dynamic or not
        Specified by:
        isDynamicAttribute in interface ItemModelInternalContext
        Parameters:
        attributeName - attribute name
        Returns:
        true if attribute is dynamic, false otherwise
      • getSource

        public java.lang.Object getSource()
        Description copied from interface: ItemModelContext
        Retrieves the item of the model.
        Specified by:
        getSource in interface ItemModelContext
        Returns:
        the behind scene jalo item.
      • isDirty

        public boolean isDirty()
        Description copied from interface: ItemModelContext
        Checks if the model has been modified.
        Specified by:
        isDirty in interface ItemModelContext
        Returns:
        true if the model has been modified, false otherwise
      • exists

        public boolean exists()
        Description copied from interface: ItemModelContext
        Checks if the model is still valid. NOTE: if the model is a new one, this method must return false, because it is not persisted in the database yet.
        Specified by:
        exists in interface ItemModelContext
        Returns:
        true if it is valid, false otherwise.
      • isRemoved

        public boolean isRemoved()
        Description copied from interface: ItemModelContext
        Checks if the model has been removed from the database. NOTE: if the model is a new one, this method must return false, because a new model cannot be removed.
        Specified by:
        isRemoved in interface ItemModelContext
        Returns:
        true if removed, false otherwise.
      • isUpToDate

        public boolean isUpToDate()
        Description copied from interface: ItemModelContext
        Checks if the model is still up to date with.
          This method must return false under one of these situations:
        • the model is new,
        • the model has been removed,
        • the model has been modified, or
        • there is newer version persisted in the database.
        Specified by:
        isUpToDate in interface ItemModelContext
        Returns:
        true if it is up to date, false otherwise.
      • isNew

        public boolean isNew()
        Description copied from interface: ItemModelContext
        Checks if the model is a new model. That means it is not persisted in the database.
        Specified by:
        isNew in interface ItemModelContext
        Returns:
        true if it is new, false otherwise.
      • getValue

        public <T> T getValue​(java.lang.String key,
                              T currentValue)
        Retrieves the value of the key. NOTE: the value will be fetched only if it is neither set nor loaded. For example, the method getCode() won't fetch the "code" attribute from the database if the setCode() has been called before.
        Specified by:
        getValue in interface ItemModelInternalContext
        Returns:
        the current value.
      • getPropertyValue

        public <T> T getPropertyValue​(java.lang.String attribute)
        Description copied from interface: ItemModelInternalContext
        Returns a value of a property with given name.
        Specified by:
        getPropertyValue in interface ItemModelInternalContext
        Parameters:
        attribute - name
        Returns:
        value of property with given name
      • setPropertyValue

        public <T> void setPropertyValue​(java.lang.String attribute,
                                         T value)
        Description copied from interface: ItemModelInternalContext
        Allows to set a value of a property with given name.
        Specified by:
        setPropertyValue in interface ItemModelInternalContext
        Parameters:
        attribute - name
        value - value to set
      • getRawPropertyValue

        public java.lang.Object getRawPropertyValue​(java.lang.String qualifier)
      • setRawPropertyValue

        public void setRawPropertyValue​(java.lang.String qualifier,
                                        java.lang.Object value)
      • loadUnlocalizedAttribute

        protected java.lang.Object loadUnlocalizedAttribute​(java.lang.String key,
                                                            boolean keepAsOriginalValue,
                                                            boolean resetDirty)
      • setValue

        public <T> T setValue​(java.lang.String key,
                              T newValue)
        Description copied from interface: ItemModelInternalContext
        Sets the new value for the specific attribute.
        Specified by:
        setValue in interface ItemModelInternalContext
        Returns:
        the new value of the attribute.
      • getDirtyAttributes

        public java.util.Set<java.lang.String> getDirtyAttributes()
        Description copied from interface: ItemModelContext
        Returns all changed attributes.
        Specified by:
        getDirtyAttributes in interface ItemModelContext
        Returns:
        the set of all changed attributes.
      • isDirty

        public boolean isDirty​(java.lang.String attribute)
        Description copied from interface: ItemModelContext
        Checks if the specific attribute has been changed.
        Specified by:
        isDirty in interface ItemModelContext
        Returns:
        true if changed, false otherwise.
      • isLoaded

        public boolean isLoaded​(java.lang.String attribute)
        Description copied from interface: ItemModelContext
        Checks if the specific attribute has been loaded from the database.
        Specified by:
        isLoaded in interface ItemModelContext
        Returns:
        true if loaded, false otherwise.
      • getOriginalValue

        public <T> T getOriginalValue​(java.lang.String key)
        Description copied from interface: ItemModelContext
        Retrieves the original loaded value of the attribute.
        Specified by:
        getOriginalValue in interface ItemModelContext
        Returns:
        the original value.
      • loadOriginalValue

        public java.lang.Object loadOriginalValue​(java.lang.String attribute)
        Description copied from interface: ItemModelInternalContext
        Returns the original value for the given attribute
        Specified by:
        loadOriginalValue in interface ItemModelInternalContext
        Parameters:
        attribute - attribute name
        Returns:
        original value of the given attribute
      • loadOriginalValue

        public java.lang.Object loadOriginalValue​(java.lang.String attribute,
                                                  java.util.Locale locale)
        Description copied from interface: ItemModelInternalContext
        Returns the original localized value for the given attribute
        Specified by:
        loadOriginalValue in interface ItemModelInternalContext
        Parameters:
        attribute - attribute name
        locale - locale name
        Returns:
        original value of the given attribute
      • getLocalizedValue

        public <T> T getLocalizedValue​(java.lang.String key,
                                       java.util.Locale locale)
        Retrieves the localized value of the key. NOTE: the value will be fetched only if it is neither set nor loaded. For example, the method getName(Locale.GERMANY) won't fetch the German "name" attribute from the database if the setName("German_name", Locale.GERMANY) has been called before.
        Specified by:
        getLocalizedValue in interface ItemModelInternalContext
        Returns:
        the current value with the locale.
      • getLocalizedRelationValue

        public <T> T getLocalizedRelationValue​(java.lang.String key,
                                               java.util.Locale locale)
        Description copied from interface: ItemModelInternalContext
        Retrieves the current value of the specific attribute with the locale.
        Specified by:
        getLocalizedRelationValue in interface ItemModelInternalContext
        Returns:
        the current value with the locale.
      • getLocalizedWithFallback

        protected java.lang.Object getLocalizedWithFallback​(java.util.Map<java.util.Locale,​java.lang.Object> attrLocMap,
                                                            java.lang.String qualifier,
                                                            java.util.Locale dataLocale,
                                                            boolean keepOriginals,
                                                            boolean isRelationAttribute)
                                                     throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • getOrLoadLocalized

        protected <T> T getOrLoadLocalized​(java.util.Map<java.util.Locale,​java.lang.Object> locMap,
                                           java.lang.String qualifier,
                                           java.util.Locale dataLoc,
                                           boolean keepAsOriginal)
      • loadLocalized

        protected <T> T loadLocalized​(java.util.Map<java.util.Locale,​java.lang.Object> locMap,
                                      java.lang.String qualifier,
                                      java.util.Locale dataLoc,
                                      boolean keepAsOriginal)
      • loadLocalized

        protected <T> T loadLocalized​(java.util.Map<java.util.Locale,​java.lang.Object> locMap,
                                      java.lang.String qualifier,
                                      java.util.Locale dataLoc,
                                      boolean keepAsOriginal,
                                      boolean resetDirty)
      • toDataLocale

        protected java.util.Locale toDataLocale​(java.util.Locale locale)
                                         throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • isDirty

        public boolean isDirty​(java.lang.String attribute,
                               java.util.Locale loc)
        Description copied from interface: ItemModelContext
        Checks if the specific localized attribute has been changed with the locale.
        Specified by:
        isDirty in interface ItemModelContext
        Returns:
        true if changed, false otherwise.
      • isLoaded

        public boolean isLoaded​(java.lang.String attribute,
                                java.util.Locale loc)
        Description copied from interface: ItemModelContext
        Checks if the specific localized attribute has been loaded with the locale from the database.
        Specified by:
        isLoaded in interface ItemModelContext
        Returns:
        true if loaded, false otherwise.
      • getOriginalValue

        public <T> T getOriginalValue​(java.lang.String key,
                                      java.util.Locale loc)
        Description copied from interface: ItemModelContext
        Retrieves the original loaded value of the localized attribute with the locale.
        Specified by:
        getOriginalValue in interface ItemModelContext
        Returns:
        the original localized value with the locale.
      • getDirtyLocalizedAttributes

        public java.util.Map<java.util.Locale,​java.util.Set<java.lang.String>> getDirtyLocalizedAttributes()
        Description copied from interface: ItemModelContext
        Returns all changed localized attributes with the locale.
        Specified by:
        getDirtyLocalizedAttributes in interface ItemModelContext
        Returns:
        the set of all changed localized attributes with the locale.
      • throwLoadingError

        protected void throwLoadingError​(java.lang.String qualifier)
      • throwLoadingError

        protected void throwLoadingError​(java.lang.String qualifier,
                                         java.util.Locale dataLocale)
      • markDirty

        protected void markDirty​(java.lang.String attribute)
      • markDirty

        protected void markDirty​(java.lang.String attribute,
                                 java.util.Locale dataLocale)
      • getCurrentLocale

        protected java.util.Locale getCurrentLocale()
                                             throws java.lang.IllegalStateException
        Throws:
        java.lang.IllegalStateException
      • getLocaleProvider

        public LocaleProvider getLocaleProvider​(boolean required)
      • setLocaleProvider

        public void setLocaleProvider​(LocaleProvider localeProvider)
      • getCombinedLocalizedValuesMap

        public java.util.Map<java.lang.String,​LocMap<java.util.Locale,​java.lang.Object>> getCombinedLocalizedValuesMap()
      • beforeAttach

        public void beforeAttach​(LocaleProvider localeProvider)
      • setAttributeProvider

        public void setAttributeProvider​(AttributeProvider attributeProvider)
      • afterUpdate

        public void afterUpdate​(long persistenceVersion)
      • afterReload

        public void afterReload​(long persistenceVersion)
      • setFetchStrategy

        public void setFetchStrategy​(FetchStrategy fetchStrategy)
      • generateNewPK

        public PK generateNewPK()
        Description copied from interface: ItemModelInternalContext
        Generate the new PK and assigns it to the current model. Will be generated only for new models if the new PK has not been generated yet
        Specified by:
        generateNewPK in interface ItemModelInternalContext
        Returns:
        new generated PK for the not saved model