Clover coverage report - Maven Clover report
Coverage timestamp: Thu Oct 11 2007 08:41:48 CEST
file stats: LOC: 76   Methods: 3
NCLOC: 50   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
UpdateAction.java 100% 100% 100% 100%
coverage
 1    /*
 2    * Copyright (C) 2007 Eric MIGNOT - mignots.eric@free.fr
 3    *
 4    * This library is free software; you can redistribute it and/or
 5    * modify it under the terms of the GNU Lesser General Public
 6    * License as published by the Free Software Foundation; either
 7    * version 2.1 of the License, or (at your option) any later version.
 8    *
 9    * This library is distributed in the hope that it will be useful,
 10    * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12    * Lesser General Public License for more details.
 13    *
 14    * You should have received a copy of the GNU Lesser General Public
 15    * License along with this library; if not, write to the Free Software
 16    * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 17    */
 18    package org.ericmignot.modeler.action;
 19   
 20    import java.util.HashMap;
 21    import java.util.Iterator;
 22    import java.util.Map;
 23   
 24    import org.ericmignot.modeler.data.BusinessObject;
 25    import org.ericmignot.modeler.util.action.ActionException;
 26    import org.ericmignot.modeler.util.action.NotifyableAction;
 27   
 28    public class UpdateAction extends NotifyableAction
 29    {
 30    private BusinessObject businessObject;
 31    private Map oldValues;
 32    private Map newValues;
 33   
 34  2 public UpdateAction(BusinessObject businessObject, Map newValues)
 35    {
 36  2 this.businessObject = businessObject;
 37  2 this.newValues = newValues;
 38   
 39  2 this.oldValues = new HashMap();
 40  2 Iterator iterator = newValues.keySet().iterator();
 41  2 while (iterator.hasNext())
 42    {
 43  4 String fieldName = (String) iterator.next();
 44  4 String oldValue = (String) this.businessObject.getFieldValue(fieldName);
 45  4 this.oldValues.put(fieldName, oldValue);
 46    }
 47    }
 48   
 49  2 public Object execute(Object actionParameter) throws ActionException
 50    {
 51  2 Map source = this.newValues;
 52  2 Iterator iterator = source.keySet().iterator();
 53  2 while (iterator.hasNext())
 54    {
 55  4 String fieldName = (String) iterator.next();
 56  4 String fieldValue = (String) source.get(fieldName);
 57  4 this.businessObject.setFieldValue(fieldName, fieldValue);
 58    }
 59  2 return this.businessObject;
 60    }
 61   
 62  1 public Object cancel(Object actionParameter) throws ActionException
 63    {
 64  1 Map source = this.oldValues;
 65  1 Iterator iterator = source.keySet().iterator();
 66  1 while (iterator.hasNext())
 67    {
 68  2 String fieldName = (String) iterator.next();
 69  2 String fieldValue = (String) source.get(fieldName);
 70  2 this.businessObject.setFieldValue(fieldName, fieldValue);
 71    }
 72  1 return this.businessObject;
 73    }
 74   
 75   
 76    }