<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">/*
 * Copyright 2005-2008 Pentaho Corporation.  All rights reserved. 
 * This program is free software; you can redistribute it and/or modify it under the 
 * terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software 
 * Foundation.
 *
 * You should have received a copy of the GNU Lesser General Public License along with this 
 * program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html 
 * or from the Free Software Foundation, Inc., 
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * Copyright 2008 - 2009 Pentaho Corporation.  All rights reserved.
 *
 * Created  
 * @author Steven Barkdull
 */
package org.pentaho.pac.client.scheduler.model;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.pentaho.gwt.widgets.client.utils.TimeUtil;
import org.pentaho.pac.client.i18n.Messages;

/**
 * 
 * @author Steven Barkdull
 *
 */
public class SchedulesModel {

  //private DoubleKeyMap&lt;String, String, Schedule&gt; scheduleMap = new DoubleKeyMap&lt;String, String, Schedule&gt;();
  private Map&lt;String, Schedule&gt; scheduleMap = new HashMap&lt;String, Schedule&gt;();
  
  public SchedulesModel() {
  }
  
  public void add( List&lt;Schedule&gt; l ) {
    for ( Schedule schedule : l ) {
      add( schedule.getJobName(), schedule );
    }
  }
  
  // TODO sbarkdull, need to do something in case client tries to add some key-pair more than once, exception?
  public void add( String name, Schedule schedule ) {
    scheduleMap.put( name, schedule );
  }
  
  public void remove( String name ) {
    scheduleMap.remove( name );
  }
  
  public void remove( List&lt;Schedule&gt; l ) {
    for ( Schedule s : l ) {
      remove( s.getJobName() );
    }
  }
  
  public Schedule get( String name ) {
    return scheduleMap.get( name );
  }
  
  public List&lt;Schedule&gt; getScheduleList() {
    return new ArrayList&lt;Schedule&gt;( scheduleMap.values() );
  }
}
</pre></body></html>