Package action

Source Code of action.RezultateActionBean

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package action;

import java.util.ArrayList;
import java.util.List;
import auxiliar.Rezultate;
import auxiliar.MetodaCernerii;
import auxiliar.MetodaSedimentarii;
import bo.Proba;
import dao.ProbaDao;
import daoI.IProbaDao;
import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.Resolution;

public class RezultateActionBean extends BaseActionBean {

    private Rezultate rezultate;

    @DefaultHandler
    public Resolution view() {
        rezultate = new Rezultate();
        MetodaCernerii metCernerii = (MetodaCernerii) (getContext().getRequest().getSession().getAttribute("metC"));
        MetodaSedimentarii metSedimentarii = (MetodaSedimentarii) (getContext().getRequest().getSession().getAttribute("metS"));
        List<Float> col8TabelMetSedimentarii = metSedimentarii.getMp();
        List<Float> col4TabelMetCernerii = metCernerii.getFractiuni();
        rezultate.setProcente(formulaRezultateCol2(col8TabelMetSedimentarii, col4TabelMetCernerii));
        Float argila = (Float) zecimale(rezultate.getProcente().get(0) + rezultate.getProcente().get(1), 2);
        Float praf = (Float) zecimale(rezultate.getProcente().get(2), 2);
        Float nisip = (Float) zecimale(rezultate.getProcente().get(3) + rezultate.getProcente().get(4) + rezultate.getProcente().get(5), 2);
        Float pietris = (Float) zecimale(rezultate.getProcente().get(6) + rezultate.getProcente().get(7), 2);
        Float bolovanis = (Float) zecimale(rezultate.getProcente().get(8) + rezultate.getProcente().get(9), 2);
        rezultate.setArgila(argila);
        rezultate.setPraf(praf);
        rezultate.setNisip(nisip);
        rezultate.setPietris(pietris);
        rezultate.setBolovanis(bolovanis);

        IProbaDao probaDao = new ProbaDao();
        Proba proba = probaDao.geProbaByID(Integer.parseInt(getContext().getRequest().getSession().getAttribute("idProba").toString()));
        proba.setArgila(argila);
        proba.setPraf(praf);
        proba.setNisip(nisip);
        proba.setPietris(pietris);
        proba.setBolovanis(bolovanis);
        probaDao.saveOrUpdate(proba);
        getContext().getRequest().getSession(true).setAttribute("rezultate", rezultate);
        return new ForwardResolution("/WEB-INF/jsp/rezultate.jsp");
    }

    private List<Float> formulaRezultateCol2(List<Float> dateIn1, List<Float> dateIn2) {
        List<Float> dateOut = new ArrayList<Float>();
        Float formula = (float) 0;
      
        formula = dateIn1.get(11);
        dateOut.add((Float)zecimale(formula,5));

        formula = dateIn1.get(8) - dateIn1.get(11);
        dateOut.add((Float)zecimale(formula,5));

        formula = dateIn1.get(1) - dateIn1.get(8);
        dateOut.add((Float)zecimale(formula,5));

        formula = dateIn2.get(12) - dateIn1.get(1);
        dateOut.add((Float)zecimale(formula,5));

        formula = dateIn2.get(11) - dateIn2.get(12);
        dateOut.add((Float)zecimale(formula,5));

        formula = dateIn2.get(9) - dateIn2.get(11);
        dateOut.add((Float)zecimale(formula,5));

        formula = dateIn2.get(5) - dateIn2.get(9);
        dateOut.add((Float)zecimale(formula,5));

        formula = dateIn2.get(2) - dateIn2.get(5);
        dateOut.add((Float)zecimale(formula,5));

        formula = dateIn2.get(0) - dateIn2.get(2);
        dateOut.add((Float)zecimale(formula,5));

        formula = 100 - dateIn2.get(0);
        dateOut.add((Float)zecimale(formula,5));

        return dateOut;
    }
}
TOP

Related Classes of action.RezultateActionBean

TOP
Copyright © 2018 www.massapi.com. 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.