UpdateModel.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.generic_project.beans;

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

  23. import org.openspcoop2.generic_project.exception.ServiceException;
  24. import org.openspcoop2.generic_project.expression.IExpression;

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

  33.     private IModel<?> model = null;
  34.     private List<UpdateField> updateFiels = new ArrayList<UpdateField>();
  35.     private IExpression condition = null;

  36.     public UpdateModel(IModel<?> model) throws ServiceException{
  37.         this(model, null, null);
  38.     }
  39.     public UpdateModel(IModel<?> model, List<UpdateField> updateFiels) throws ServiceException{
  40.         this(model, null, updateFiels);
  41.     }
  42.     public UpdateModel(IModel<?> model, IExpression condition,List<UpdateField> updateFiels) throws ServiceException{
  43.         if(model==null){
  44.             throw new ServiceException("Parameter model is null");
  45.         }
  46.         this.model = model;
  47.         if(updateFiels!=null && updateFiels.size()>0){
  48.             for (UpdateField updateField : updateFiels) {
  49.                 this.addUpdateField(updateField);
  50.             }
  51.         }
  52.         this.condition = condition;
  53.     }
  54.    
  55.     public IModel<?> getModel() {
  56.         return this.model;
  57.     }
  58.     public void setModel(IModel<?> model) throws ServiceException {
  59.         if(model==null){
  60.             throw new ServiceException("Parameter model is null");
  61.         }
  62.         this.model = model;
  63.     }
  64.    
  65.     public int sizeUpdateFields(){
  66.         return this.updateFiels.size();
  67.     }
  68.     public void addUpdateField(UpdateField updateField){
  69.         this.updateFiels.add(updateField);
  70.     }
  71.     public UpdateField getUpdateField(int index){
  72.         return this.updateFiels.get(index);
  73.     }
  74.     public UpdateField removeUpdateField(int index){
  75.         return this.updateFiels.get(index);
  76.     }  
  77.     public List<UpdateField> getUpdateFiels() {
  78.         return this.updateFiels;
  79.     }
  80.     public void setUpdateFiels(List<UpdateField> updateFiels) {
  81.         this.updateFiels = updateFiels;
  82.     }
  83.    
  84.     public IExpression getCondition() {
  85.         return this.condition;
  86.     }
  87.     public void setCondition(IExpression condition) {
  88.         this.condition = condition;
  89.     }
  90. }