Package net.sf.nfp.mini.data

Examples of net.sf.nfp.mini.data.Period


  public HistoryModel(NFPControler controler) {
    super(controler);
  }

  public void load(Object parameter) throws Exception {
    Period selected = (Period) parameter;
    int year = Calendar.getInstance().get(Calendar.YEAR);
    Vector periods = controler.getPeriodDAO().findByYear(year);
    view.setPeriods(periods);
    view.setSelectedPeriod(selected);
  }
View Full Code Here


    view.setExceptionListener(controler);

    view.addCommand(new ActionCommand("${view}", Command.SCREEN, 1) {
      public Navigation execute(Displayable d) throws Exception {
        HistoryView history = (HistoryView) d;
        Period period = history.getSelectedPeriod();
        return new Navigation("graph", period, null);
      }
    });
    view.addCommand(new NavigationCommand("graph", "${back}", Command.BACK, 1));
  }
View Full Code Here

      public Navigation execute(Displayable d) throws Exception {
        Calendar date = Calendar.getInstance();
        Random random = new Random();
        controler.progressListner.setMaxValue(30);
        Observation o = null;
        Period period = new Period(new Date());
        controler.getPeriodDAO().setObservationIds(period, new Vector());
        for(int i=1; i < 5; ++i) {
          date.set(Calendar.DAY_OF_MONTH, i);
          o = new Observation(date.getTime(),
              Observation.NO_TEMPERATURE,
View Full Code Here

  public static Observation addObservationToPeriod(Observation observation, Period[] periodRef, NFPControler controler) throws RecordStoreException, IOException {
    Log.log("SaveObservationModel.addObservationToPeriod("+observation+","+periodRef[0]);
    final PeriodDAO periodDAO = controler.getPeriodDAO();
    final ObservationDAO observationDAO = controler.getObservationDAO();
 
    Period period = periodRef[0];
    if(period.getStart() == null) {
      period.setStart(observation.getDate());
      period.setEnd(observation.getDate());
    }else{
      if (observation.getDate().getTime() < period.getStart().getTime())
        period.setStart(observation.getDate());
      if (observation.getDate().getTime() > period.getEnd().getTime())
        period.setEnd(observation.getDate());
      if (Utils.getDaysBetween(period.getStart(), period.getEnd()) > SaveObservationModel.MAX_PERIOD_DAYS)
        throw new IllegalArgumentException("${period.days.exceded} " + SaveObservationModel.MAX_PERIOD_DAYS);
    }
    period = periodDAO.persist(period);
    observation = observationDAO.persist(observation);
    Vector observationIds = periodDAO.getObservationIds(period);
View Full Code Here

    this.periods = periods;
  }

  public void setSelectedPeriod(Period selected) {
    for(int i=0;i<periods.size();++i) {
      Period period = (Period) periods.elementAt(i);
      if(period.equals(selected))
        this.selected = i;
    }     
  }
View Full Code Here

  }
 
  public void load(Object parameter) throws Exception {
    Log.log("SaveObservationModel.load()");
    Object[] params = (Object[]) parameter;
    Period period = (Period) params[0];
    Observation observation = (Observation) params[1];
    Log.log("period:"+period);
    Log.log("observ:"+observation);
    boolean newPeriodStarted = false;
    if (period == null) {
      period = new Period(observation.getDate());
      newPeriodStarted = true;
    } else if (observation.isBleeding()) {
      // only current period is "closed" when adding new bleeding
      // observations
      if (isCurrentPeriod(period) && !isBleeingContinuation(period, observation)) {
        period = new Period(observation.getDate());
        newPeriodStarted = true;
      }
    }
    Period[] ref = { period };
    observation = LogicDAO.addObservationToPeriod(observation, ref, controler);
View Full Code Here

    }
    return true;
  }

  private boolean isCurrentPeriod(Period period) throws RecordStoreException, IOException {
    Period current = controler.getPeriodDAO().getCurrent();
    if (current == null)
      return true;
    return current.equals(period);
 
View Full Code Here

  public Period persist(Period period) throws RecordStoreException, IOException {
    return (Period) super.persist(period);
  }
   
  public Period find(int id) throws RecordStoreException, IOException {
    return (Period) super.find(id, new Period());
  }
View Full Code Here

    Vector results = new Vector();
    Calendar cal = Calendar.getInstance();
    RecordEnumeration enumeration = getBaseRMS().enumerateRecords(null, null, false);
    boolean include = false;
    while (enumeration.hasNextElement()) {
      Period period = find(enumeration.nextRecordId());
      include = false;
      cal.setTime(period.getStart());
      if(year == cal.get(Calendar.YEAR))
        include = true;
      cal.setTime(period.getEnd());
      if(year == cal.get(Calendar.YEAR))
        include = true;
      if(include)
        results.addElement(period);
    }
View Full Code Here

TOP

Related Classes of net.sf.nfp.mini.data.Period

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.