SemaphoreMapping.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.utils.semaphore;

  21. import java.util.ArrayList;
  22. import java.util.List;

  23. /**
  24.  * SemaphoreMapping
  25.  *
  26.  * @author Andrea Poli (apoli@link.it)
  27.  * @author $Author$
  28.  * @version $Rev$, $Date$
  29.  */
  30. public class SemaphoreMapping {

  31.     public static SemaphoreMapping newInstance(String applicativeId) {
  32.         SemaphoreMapping mapping = new SemaphoreMapping();
  33.         mapping.setTable("OP2_SEMAPHORE");
  34.         mapping.setIdNode("node_id");
  35.         mapping.setLockDate("creation_time");
  36.         mapping.setUpdateDate("update_time");
  37.         mapping.setDetails("details");
  38.         mapping.addUniqueConditionValue("applicative_id", applicativeId, String.class);
  39.         return mapping;
  40.     }
  41.    
  42.     private String table;
  43.     private String idNode;
  44.     private String lockDate;
  45.     private String updateDate;
  46.     private String details;
  47.     private List<String> uniqueConditions = new ArrayList<>();
  48.     private List<Object> uniqueConditionsValues = new ArrayList<>();
  49.     private List<Class<?>> uniqueConditionsTypes = new ArrayList<Class<?>>();
  50.    
  51.     public String getTable() {
  52.         return this.table;
  53.     }
  54.     public void setTable(String table) {
  55.         this.table = table;
  56.     }
  57.     public String getIdNode() {
  58.         return this.idNode;
  59.     }
  60.     public void setIdNode(String idNode) {
  61.         this.idNode = idNode;
  62.     }
  63.     public String getLockDate() {
  64.         return this.lockDate;
  65.     }
  66.     public void setLockDate(String lockDate) {
  67.         this.lockDate = lockDate;
  68.     }
  69.     public String getUpdateDate() {
  70.         return this.updateDate;
  71.     }
  72.     public void setUpdateDate(String updateDate) {
  73.         this.updateDate = updateDate;
  74.     }
  75.     public String getDetails() {
  76.         return this.details;
  77.     }
  78.     public void setDetails(String details) {
  79.         this.details = details;
  80.     }

  81.     public void addUniqueConditionValue(String columnName, Object value,Class<?> classType) {
  82.         this.uniqueConditions.add(columnName);
  83.         this.uniqueConditionsValues.add(value);
  84.         this.uniqueConditionsTypes.add(classType);
  85.     }
  86.     public int sizeUniqueConditionValues() {
  87.         return this.uniqueConditionsValues.size();
  88.     }
  89.     public String getUniqueConditionColumnName(int index) {
  90.         return this.uniqueConditions.get(index);
  91.     }
  92.     public Object getUniqueConditionValue(int index) {
  93.         return this.uniqueConditionsValues.get(index);
  94.     }
  95.     public Class<?> getUniqueConditionType(int index) {
  96.         return this.uniqueConditionsTypes.get(index);
  97.     }
  98.     public void removeUniqueConditionValue(int index) {
  99.         this.uniqueConditions.remove(index);
  100.         this.uniqueConditionsValues.remove(index);
  101.         this.uniqueConditionsTypes.remove(index);
  102.     }
  103.     public void clearUniqueConditionValues() {
  104.         this.uniqueConditions.clear();
  105.         this.uniqueConditionsValues.clear();
  106.         this.uniqueConditionsTypes.clear();
  107.     }
  108. }