BaseItemBean.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */
  20. package org.openspcoop2.web.lib.mvc.properties.beans;

  21. import java.util.Map;

  22. import org.openspcoop2.core.mvc.properties.Conditions;
  23. import org.openspcoop2.core.mvc.properties.Property;
  24. import org.openspcoop2.core.mvc.properties.constants.ItemType;
  25. import org.openspcoop2.core.mvc.properties.provider.ExternalResources;
  26. import org.openspcoop2.core.mvc.properties.provider.IProvider;
  27. import org.openspcoop2.core.mvc.properties.provider.ProviderException;
  28. import org.openspcoop2.web.lib.mvc.DataElement;
  29. import org.openspcoop2.web.lib.mvc.byok.LockUtilities;
  30. import org.openspcoop2.web.lib.mvc.properties.exception.UserInputValidationException;

  31. /***
  32.  *
  33.  * Classe astratta che definisce le informazioni relative alla grafica degli elementi della configurazione.
  34.  *
  35.  * @author Pintori Giuliano (pintori@link.it)
  36.  * @author $Author$
  37.  * @version $Rev$, $Date$
  38.  */
  39. public abstract class BaseItemBean<T> {
  40.    
  41.     // elemento corrispondente all'interno del config (Section/SubSection/Item)
  42.     protected IProvider provider = null;    
  43.     protected T item = null;
  44.     protected String name = null;
  45.     protected String value = null;
  46.     protected Boolean visible = null;
  47.     protected Boolean oldVisible = null;
  48.    
  49.     protected BaseItemBean(T item, String name, IProvider provider) {
  50.         this.item = item;
  51.         this.name = name;
  52.         this.provider = provider;
  53.     }

  54.     public abstract DataElement toDataElement(ConfigBean config, Map<String, String> mapNameValue, ExternalResources externalResources, LockUtilities lockUtilities) throws ProviderException;
  55.    
  56.     public abstract void setValueFromRequest(String parameterValue, ExternalResources externalResources, LockUtilities lockUtilities)  throws ProviderException;
  57.    
  58.     public abstract Property getSaveProperty();
  59.    
  60.     public abstract String getPropertyValue();
  61.    
  62.     public abstract void init(String value, ExternalResources externalResources) throws ProviderException;
  63.    
  64.     public abstract Conditions getConditions();
  65.    
  66.     public abstract ItemType getItemType();
  67.    
  68.     public abstract String getLabel();
  69.    
  70.     public abstract void validate(ExternalResources externalResources) throws UserInputValidationException;

  71.     public IProvider getProvider() {
  72.         return this.provider;
  73.     }
  74.    
  75.     public T getItem() {
  76.         return this.item;
  77.     }

  78.     public String getName() {
  79.         return this.name;
  80.     }
  81.    
  82.     public String getValue() {
  83.         return this.value;
  84.     }

  85.     public void setVisible(Boolean visible) {
  86.         this.visible = visible;
  87.     }

  88.     public Boolean getVisible() {
  89.         return this.visible;
  90.     }
  91.    
  92.     public boolean isVisible() {
  93.         return this.visible != null && this.visible.booleanValue();
  94.     }
  95.    
  96.     public void setOldVisible(Boolean oldVisible) {
  97.         this.oldVisible = oldVisible;
  98.     }
  99.    
  100.     public Boolean getOldVisible() {
  101.         return this.oldVisible;
  102.     }
  103.    
  104.     public boolean isOldVisible() {
  105.         return this.oldVisible != null && this.oldVisible.booleanValue();
  106.     }

  107. }