logic.EntityCar.java Source code

Java tutorial

Introduction

Here is the source code for logic.EntityCar.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package logic;

import data.entity.BaseParam;
import data.entity.Car;
import data.entity.CarColorValue;
import data.entity.CarCompletionOption;
import data.entity.CarOptionValue;
import data.entity.Color;
import data.entity.Feature;
import data.entity.FreeOption;
import data.services.BaseParamService;
import data.support.ConvertSupport;
import data.support.RenderSupport;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import org.springframework.beans.factory.annotation.Autowired;
import support.StringAdapter;

/**
 *
 * @author 
 */
public class EntityCar {

    @Autowired
    private BaseParamService baseParamService;

    //public final String id;
    public final String markTitle;
    public final String modelTitle;
    public final String carTitle;
    public final BigDecimal basePrice;
    public final IdealEntity ie;
    public final AStrategy1 a1;
    public final AStrategy2 a2;
    public final BStrategy1 b1;
    public final BStrategy2 b2;
    public final Car car;
    public final String radCore;
    public final String radColor;
    public final ResourceProfitability resPropf;
    public final ResourceStaticType resStatType;
    private final List<BaseParam> allParams;
    private final Set<String> staticUids;

    public BigDecimal fullPrice = BigDecimal.valueOf(Long.valueOf(0));
    public BigDecimal moneyFound = BigDecimal.valueOf(Long.valueOf(0));
    //public BigDecimal dinamicRate = BigDecimal.valueOf(0);
    public BigDecimal dinamicRateA = BigDecimal.valueOf(0);
    public BigDecimal dinamicRateB = BigDecimal.valueOf(0);
    public BigDecimal staticRate = BigDecimal.valueOf(0);
    //public BigDecimal monetaryStaticRate = BigDecimal.valueOf(0);

    public String log = "";
    public String cutLog = "";
    public Integer cutNum = 0;
    public String cutVal = "";
    public boolean isCut = false;

    public Integer aCount1 = 0;
    public Integer aCount2 = 0;
    public Integer bCount1 = 0;
    public Integer bCount2 = 0;
    public BigDecimal aFund1 = BigDecimal.valueOf(0);
    public BigDecimal bFund1 = BigDecimal.valueOf(0);
    public BigDecimal aFund2 = BigDecimal.valueOf(0);
    public BigDecimal bFund2 = BigDecimal.valueOf(0);

    public BigDecimal staticFund1 = BigDecimal.valueOf(0);
    public Integer payStaticCount1 = 0;
    public BigDecimal monetaryStaticRate1 = BigDecimal.valueOf(0);
    public BigDecimal baseStaticRate1 = BigDecimal.valueOf(0);
    public BigDecimal freeStaticRate1 = BigDecimal.valueOf(0);
    public BigDecimal staticFund2 = BigDecimal.valueOf(0);
    public Integer payStaticCount2 = 0;
    public BigDecimal monetaryStaticRate2 = BigDecimal.valueOf(0);
    public BigDecimal baseStaticRate2 = BigDecimal.valueOf(0);
    public BigDecimal freeStaticRate2 = BigDecimal.valueOf(0);

    public String staticFund1Str = "";
    public String payStaticCount1Str = "";
    public String monetaryStaticRate1Str = "";
    public String baseStaticRate1Str = "";
    public String freeStaticRate1Str = "";
    public String staticFund2Str = "";
    public String payStaticCount2Str = "";
    public String monetaryStaticRate2Str = "";
    public String baseStaticRate2Str = "";
    public String freeStaticRate2Str = "";

    public BigDecimal minParamToxic1;
    public BigDecimal minParamToxic2;
    public BigDecimal minValueToxic1 = BigDecimal.valueOf(1);
    public BigDecimal minValueToxic2;
    public Perception percType;

    public String suplog = "";

    //public HashMap<String, List<EntityProperty>> allStaticOptions = new HashMap();
    public Map<String, List<EntityProperty>> staticProps = new TreeMap();

    public Map<String, EntityPropertyHolder> aprops = new TreeMap();
    public Map<String, EntityPropertyHolder> bprops = new TreeMap();

    public EntityCar(List<BaseParam> bpList, Set<String> staticUids, String radCore, String radColor, Car car,
            String markTitle, String modelTitle, String carTitle, BigDecimal carPrice, IdealEntity ie,
            BigDecimal moneyFound, AStrategy1 a1, AStrategy2 a2, BStrategy1 b1, BStrategy2 b2,
            ToxicParamType paramTox1, ToxicParamType paramTox2, ToxicValueType valueTox1, ToxicValueType valueTox2,
            ResourceProfitability resPropf, ResourceStaticType resStatType, Perception percType) {
        this.car = car;
        this.markTitle = markTitle;
        this.modelTitle = modelTitle;
        this.carTitle = carTitle;
        this.basePrice = carPrice;
        if (moneyFound == null) {
            this.moneyFound = BigDecimal.valueOf(0);
        } else {
            this.moneyFound = moneyFound;
        }
        this.moneyFound = moneyFound.subtract(basePrice);
        fullPrice = basePrice;
        this.ie = ie;
        this.a1 = a1;
        this.a2 = a2;
        this.b1 = b1;
        this.b2 = b2;
        this.radCore = radCore;
        this.radColor = radColor;
        /*suplog+=" pt1="+paramTox1+"; ";
         suplog+=" pv1="+valueTox1+"; ";
         suplog+=" pt2="+paramTox2+"; ";
         suplog+=" pv2="+valueTox2+"; ";*/
        /*if (paramTox1 != null && !ToxicParamType.NOSTRATEGY.equals(paramTox1)) {
         //this.minParamToxic1 = BigDecimal.valueOf(getMinToxParam(paramTox1));
         } else {
         this.minParamToxic1 = null;
         }*/
        //this.minParamToxic2=BigDecimal.valueOf(getMinToxParam(paramTox2));
        //this.minValueToxic1 = BigDecimal.valueOf(getMinToxVal(ToxicValueType.CLEAR));

        /*if (valueTox1 != null && !ToxicValueType.NOSTRATEGY.equals(valueTox1)) {
         //this.minValueToxic1 = BigDecimal.valueOf(getMinToxVal(valueTox1));
         } else {
         this.minValueToxic1 = null;
         }*/
        //this.minValueToxic2=BigDecimal.valueOf(getMinToxVal(valueTox2));
        if (paramTox1 != null && !ToxicParamType.NOSTRATEGY.equals(paramTox1)) {
            this.minParamToxic1 = BigDecimal.valueOf(getMinToxParam(paramTox1));
        } else {
            this.minParamToxic1 = null;
        }
        if (valueTox1 != null && !ToxicValueType.NOSTRATEGY.equals(valueTox1)) {
            this.minValueToxic1 = BigDecimal.valueOf(getMinToxVal(valueTox1));
        } else {
            this.minValueToxic1 = null;
        }
        if (paramTox2 != null && !ToxicParamType.NOSTRATEGY.equals(paramTox2)) {
            this.minParamToxic2 = BigDecimal.valueOf(getMinToxParam(paramTox2));
        } else {
            this.minParamToxic2 = null;
        }
        if (valueTox2 != null && !ToxicValueType.NOSTRATEGY.equals(valueTox2)) {
            this.minValueToxic2 = BigDecimal.valueOf(getMinToxVal(valueTox2));
        } else {
            this.minValueToxic2 = null;
        }
        this.percType = percType;
        this.allParams = bpList;
        this.staticUids = staticUids;
        this.resPropf = resPropf;
        this.resStatType = resStatType;
    }

    public void addProp(EntityProperty ep, Rank rank) throws Exception {
        if (Rank.A.equals(rank)) {
            if (aprops.get(ep.uid) == null) {
                aprops.put(ep.uid, new EntityPropertyHolder());
            }
            aprops.get(ep.uid).addProp(ep);
        } else if (Rank.B.equals(rank)) {
            if (bprops.get(ep.uid) == null) {
                bprops.put(ep.uid, new EntityPropertyHolder());
            }
            bprops.get(ep.uid).addProp(ep);
        }
        /*if (props.get(ep.uid) == null) {
         props.put(ep.uid, new EntityPropertyHolder());
         }
         props.get(ep.uid).addProp(ep, defaultVal);*/
    }

    public void count() throws Exception {
        log += "Amount=" + moneyFound + "; ";
        if (isCut != true) {
            log += "?  1";
            firstDinamicCount();
            countFirstDinamicParamsForLog();
        }
        if (isCut != true) {
            //loadAllStaticOptions();
            log += "? ? 0: ";
            //suplog += "n1=" + StringAdapter.getString(minParamToxic1) + "; n2=" + StringAdapter.getString(minValueToxic1) + "strat=" + resStatType.getName() + "; ";
            //suplog+=" rst1="+resStatType+"; ";
            /*if ((minParamToxic1 != null && minValueToxic1 != null && !resStatType.equals(ResourceStaticType.BOTH))||
             (resStatType.equals(ResourceStaticType.BOTH)&&(minParamToxic2==null||minValueToxic2==null))){*/
            //suplog+=" rst1="+resStatType.getName()+"; ";
            freeStaticCount();
            if (minParamToxic1 != null && minValueToxic1 != null
                    && !resStatType.equals(ResourceStaticType.FREEONLY)) {
                log += "? ? 1: ";
                monetaryStaticCount(true);
            }
            countStaticParamsForLog1();
            //}
            /* else {
             log += "?  ? ; ";
             }*/
        }
        if (isCut != true) {
            log += "?  2";
            secondDinamicCount();
            countSecondDinamicParamsForLog();
        }
        if (isCut != true) {

            if (minParamToxic2 != null && minValueToxic2 != null
                    && !resStatType.equals(ResourceStaticType.FREEONLY)) {
                log += "? ? 2: ";
                //suplog+=" mpt="+minParamToxic2+" mvt="+minValueToxic2+" rst2="+resStatType+"; ";

                //suplog+=" rst2="+resStatType.getName()+"; ";
                monetaryStaticCount(false);
                countStaticParamsForLog2();
            }

        }
        if (isCut != true) {
            log += "? ";
            estimate();

        }
        //renderPrepare();
    }

    private void estimate() {
        //BigDecimal pq = BigDecimal.valueOf(ie.params.size());
        //BigDecimal pq = BigDecimal.valueOf(0);
        for (EntityPropertyHolder eph : aprops.values()) {
            //pq = pq.add(BigDecimal.valueOf(1));
            dinamicRateA = dinamicRateA.add(eph.dinamicRate);
            //staticRate = staticRate.add(eph.staticRate);
            //suplog+="--"+eph.supLog+"--";
        }
        for (EntityPropertyHolder eph : bprops.values()) {
            //pq = pq.add(BigDecimal.valueOf(1));
            dinamicRateB = dinamicRateB.add(eph.dinamicRate);
            //staticRate = staticRate.add(eph.staticRate);
            //suplog += "=--" + eph.supLog + "--;";
            if (!eph.activeProperty.isEmpty()) {
                suplog += eph.activeProperty.get(0).uid + "-" + eph.activeProperty.get(0).price + ";";
            }

        }

        if (staticProps.keySet().size() > 0) {
            BigDecimal supsr = BigDecimal.valueOf(0);
            //BigDecimal divisor = BigDecimal.valueOf(staticProps.keySet().size());
            for (String uid : staticProps.keySet()) {
                if (!staticProps.get(uid).isEmpty()) {
                    supsr = supsr.add(staticProps.get(uid).get(0).value);
                }
            }
            staticRate = supsr;
            ///staticRate = supsr.divide(divisor, 2, RoundingMode.HALF_UP);
        } else {
            staticRate = BigDecimal.valueOf(0);
        }
        fullPrice = fullPrice.add(aFund2).add(bFund2);
        //suplog+="!stats: "+staticProps.keySet().size();
        //staticRate = pq;
        //dinamicRate = dinamicRate.divide(pq,2, RoundingMode.HALF_UP);
        //staticRate = staticRate.divide(pq,2, RoundingMode.HALF_UP);
    }

    private void firstDinamicCount() throws Exception {
        for (IdealEntityParam iep : ie.getParamsArad()) {
            if (aprops.get(iep.baseParam.getUid()) == null) {
                aprops.put(iep.baseParam.getUid(), new EntityPropertyHolder());
            }
            EntityPropertyHolder hd = aprops.get(iep.baseParam.getUid());
            hd.acount(iep, moneyFound, iep.aimBefore, true);

            if (hd.isCut == true) {
                isCut = true;
                cutLog = " " + markTitle + "-" + modelTitle + "-" + carTitle
                        + "   : " + iep.number + " - "
                        + iep.baseParam.getUid() + " - ? :" + hd.holderLog
                        + ", totalMax=" + iep.tmax + ", totalMin=" + iep.tmin + "; ";
                cutNum = iep.number;
                cutVal = hd.closestValue;
                break;
            }
            ;
            aFund1.add(hd.activeProperty.get(0).price);
            //aFund1.add(hd.price);
            //fullPrice = fullPrice.add(hd.price);
            moneyFound = moneyFound.subtract(hd.price);
        }
        for (IdealEntityParam iep : ie.getParamsAnorad()) {
            if (aprops.get(iep.baseParam.getUid()) == null) {
                aprops.put(iep.baseParam.getUid(), new EntityPropertyHolder());
            }
            EntityPropertyHolder hd = aprops.get(iep.baseParam.getUid());
            hd.acount(iep, moneyFound, iep.aimBefore, true);

            if (hd.isCut == true) {
                isCut = true;
                cutLog = " " + markTitle + "-" + modelTitle + "-" + carTitle
                        + "   : " + iep.number + " - "
                        + iep.baseParam.getUid() + " - ? :" + hd.holderLog
                        + ", totalMax=" + iep.tmax + ", totalMin=" + iep.tmin + "; ";
                cutNum = iep.number;
                cutVal = StringAdapter.getString(hd.holderLog);
                break;
            }
            aFund1.add(hd.activeProperty.get(0).price);
            //aFund1.add(hd.price);
            //fullPrice = fullPrice.add(hd.price);
            moneyFound = moneyFound.subtract(hd.price);
        }
        if (!b1.equals(BStrategy1.NONE)) {
            for (IdealEntityParam iep : ie.getParamsBrad()) {
                if (bprops.get(iep.baseParam.getUid()) == null) {
                    bprops.put(iep.baseParam.getUid(), new EntityPropertyHolder());
                }
                EntityPropertyHolder hd = bprops.get(iep.baseParam.getUid());
                hd.bcount(iep, moneyFound, b1, aFund1, bFund1);
                if (!hd.activeProperty.isEmpty() && hd.activeProperty.get(0) != null) {
                    bFund1.add(hd.activeProperty.get(0).price);
                }
                //bFund1.add(hd.price);
                //fullPrice = fullPrice.add(hd.price);
                moneyFound = moneyFound.subtract(hd.price);
            }
            for (IdealEntityParam iep : ie.getParamsBnorad()) {
                if (bprops.get(iep.baseParam.getUid()) == null) {
                    bprops.put(iep.baseParam.getUid(), new EntityPropertyHolder());
                }
                EntityPropertyHolder hd = bprops.get(iep.baseParam.getUid());
                hd.bcount(iep, moneyFound, b1, aFund1, bFund1);
                if (!hd.activeProperty.isEmpty() && hd.activeProperty.get(0) != null) {
                    bFund1.add(hd.activeProperty.get(0).price);
                }
                //bFund1.add(hd.price);
                //fullPrice = fullPrice.add(hd.price);
                moneyFound = moneyFound.subtract(hd.price);
            }
        } else {
            for (IdealEntityParam iep : ie.getParamsBrad()) {
                if (bprops.get(iep.baseParam.getUid()) == null) {
                    bprops.put(iep.baseParam.getUid(), new EntityPropertyHolder());
                }
                EntityPropertyHolder hd = bprops.get(iep.baseParam.getUid());
                hd.activeProperty = new ArrayList();
            }
            for (IdealEntityParam iep : ie.getParamsBnorad()) {
                if (bprops.get(iep.baseParam.getUid()) == null) {
                    bprops.put(iep.baseParam.getUid(), new EntityPropertyHolder());
                }
                EntityPropertyHolder hd = bprops.get(iep.baseParam.getUid());
                hd.activeProperty = new ArrayList();
            }
        }
    }

    private void secondDinamicCount() throws Exception {
        //aFund2 = aFund1;
        //bFund2 = bFund1;
        if (!a2.equals(AStrategy2.NONE)) {
            if ((a1.equals(AStrategy1.AMAX) && a2.equals(AStrategy2.AMIN))
                    || (a1.equals(AStrategy1.AMIN) && a2.equals(AStrategy2.AMAX))) {
                for (IdealEntityParam iep : ie.getParamsArad()) {
                    EntityPropertyHolder hd = aprops.get(iep.baseParam.getUid());
                    //BigDecimal supPrice = hd.price;
                    hd.acount(iep, moneyFound, iep.aimAfter, false);
                    //aFund2.add(hd.price);
                    aFund2.add(hd.activeProperty.get(0).price);
                    //aFund2.subtract(supPrice);
                    //moneyFound = moneyFound.add(supPrice);

                    //fullPrice = fullPrice.add(hd.price);
                    moneyFound = moneyFound.subtract(hd.price);
                }
                for (IdealEntityParam iep : ie.getParamsAnorad()) {
                    EntityPropertyHolder hd = aprops.get(iep.baseParam.getUid());
                    //BigDecimal supPrice = hd.price;
                    hd.acount(iep, moneyFound, iep.aimAfter, false);
                    aFund2.add(hd.activeProperty.get(0).price);
                    /*aFund2.add(hd.price);
                        
                     aFund2.subtract(supPrice);
                     moneyFound = moneyFound.add(supPrice);*/

                    //fullPrice = fullPrice.add(hd.price);
                    moneyFound = moneyFound.subtract(hd.price);
                }
                if (!b2.equals(BStrategy2.NONE)) {
                    for (IdealEntityParam iep : ie.getParamsBrad()) {
                        if (bprops.get(iep.baseParam.getUid()) == null) {
                            bprops.put(iep.baseParam.getUid(), new EntityPropertyHolder());
                        }
                        EntityPropertyHolder hd = bprops.get(iep.baseParam.getUid());
                        //BigDecimal supPrice = hd.price;
                        hd.bcount(iep, moneyFound, b2, aFund2, bFund2);
                        if (!hd.activeProperty.isEmpty() && hd.activeProperty.get(0) != null) {
                            bFund2.add(hd.activeProperty.get(0).price);
                        }
                        /*bFund2.add(hd.price);
                            
                         bFund2.subtract(supPrice);
                         moneyFound = moneyFound.add(supPrice);*/

                        //fullPrice = fullPrice.add(hd.price);
                        moneyFound = moneyFound.subtract(hd.price);
                    }
                    for (IdealEntityParam iep : ie.getParamsBnorad()) {
                        if (bprops.get(iep.baseParam.getUid()) == null) {
                            bprops.put(iep.baseParam.getUid(), new EntityPropertyHolder());
                        }
                        EntityPropertyHolder hd = bprops.get(iep.baseParam.getUid());
                        //BigDecimal supPrice = hd.price;
                        hd.bcount(iep, moneyFound, b2, aFund2, bFund2);
                        if (!hd.activeProperty.isEmpty() && hd.activeProperty.get(0) != null) {
                            bFund2.add(hd.activeProperty.get(0).price);
                        }
                        /*bFund2.add(hd.price);
                            
                         bFund2.subtract(supPrice);
                         moneyFound = moneyFound.add(supPrice);*/

                        //fullPrice = fullPrice.add(hd.price);
                        moneyFound = moneyFound.subtract(hd.price);
                    }
                } else {
                    for (IdealEntityParam iep : ie.getParamsBrad()) {
                        if (bprops.get(iep.baseParam.getUid()) == null) {
                            bprops.put(iep.baseParam.getUid(), new EntityPropertyHolder());
                        }
                        EntityPropertyHolder hd = bprops.get(iep.baseParam.getUid());
                        hd.activeProperty = new ArrayList();
                    }
                    for (IdealEntityParam iep : ie.getParamsBnorad()) {
                        if (bprops.get(iep.baseParam.getUid()) == null) {
                            bprops.put(iep.baseParam.getUid(), new EntityPropertyHolder());
                        }
                        EntityPropertyHolder hd = bprops.get(iep.baseParam.getUid());
                        hd.activeProperty = new ArrayList();
                    }

                }
            }
        }
    }

    private void freeStaticCount() throws Exception {

        //getAllStaticOptions();
        BigDecimal bestRel = BigDecimal.valueOf(0);
        BigDecimal one = BigDecimal.valueOf(1);
        //
        int k = 0;
        //suplog+="; bplistS="+bpList.size()+"; ";
        //suplog += "stat1: cols=" + car.getCarColorValues().size() + "; ";
        for (CarColorValue ccv : car.getCarColorValues()) {
            k++;
            Color col = ccv.getColor();
            String suid = col.getUid().trim();
            //suplog+="!! suid="+suid.trim()+"; ";
            BaseParam bp = getBaseParam(allParams, suid);
            //suplog+=""+k+"."+ccv.getTitle()+" - "+ccv.getColor().getName()+"; ";
            if (bp != null && StaticType.STATIC.equals(bp.getStaticType())) {
                List<String> colorRadList = ConvertSupport.getRadicalList(col.getRadical());
                if (!colorRadList.isEmpty()) {
                    String attrToxRad = "";
                    BigDecimal attrToxRate = BigDecimal.valueOf(-100);
                    for (String colorRad : colorRadList) {
                        BigDecimal ToxRate = BigDecimal
                                .valueOf(getToxicRate(radCore.trim(), radColor.trim(), colorRad));
                        if (ToxRate.compareTo(attrToxRate) > 0) {
                            attrToxRate = ToxRate;
                            attrToxRad = colorRad;
                        }
                    }
                    if (attrToxRad != null && !attrToxRad.equals("")) {
                        BigDecimal attrModalRate = BigDecimal.valueOf(0);
                        if (percType.equals(Perception.AUDIAL)) {
                            if (col.getAudial() != null) {
                                attrModalRate = BigDecimal.valueOf(col.getAudial());
                            }
                        } else if (percType.equals(Perception.KINESTETIC)) {
                            if (col.getKinestet() != null) {
                                attrModalRate = BigDecimal.valueOf(col.getKinestet());
                            }
                        } else if (percType.equals(Perception.VISUAL)) {
                            if (col.getVisual() != null) {
                                attrModalRate = BigDecimal.valueOf(col.getVisual());
                            }
                        }
                        //BigDecimal rel = attrToxRate.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
                        if (attrToxRate.compareTo(one) >= 0) {
                            EntityProperty ep = new EntityProperty("", ccv.getTitle(), suid, attrToxRate,
                                    attrToxRad, attrModalRate, (double) 0, PropertyType.OPTION,
                                    " ??");
                            List<EntityProperty> availEps = staticProps.get(suid);
                            if (availEps == null || availEps.isEmpty()) {
                                availEps = new ArrayList();
                                availEps.add(ep);
                                staticProps.put(suid, availEps);
                            } else {
                                EntityProperty availEp = availEps.get(0);
                                if (attrToxRate.compareTo(availEp.value) == 0) {
                                    BigDecimal availModVal = availEp.modalValue;
                                    if (attrModalRate.compareTo(availModVal) > 0) {
                                        availEps = new ArrayList();
                                        availEps.add(ep);
                                        staticProps.put(suid, availEps);
                                    } else if (attrModalRate.compareTo(availModVal) == 0) {
                                        availEps.add(ep);
                                        staticProps.put(suid, availEps);
                                    }
                                } else if (attrToxRate.compareTo(availEp.getValue()) > 0) {
                                    availEps = new ArrayList();
                                    availEps.add(ep);
                                    staticProps.put(suid, availEps);
                                }
                            }
                            //suplog+="COLOR: atr="+attrToxRate+"; am="+attrModalRate+"; etr="+essToxRate+"; statrate="+rel.toString()+"; ";
                        }
                    }
                }
            }
        }
        //suplog+="statics: "+staticProps.keySet().size()+"; ";

        int i = 0;
        int m = 0;
        int n = 0;
        //suplog += "stat1: covs=" + car.getCarOptionValues().size() + "; ";
        for (CarOptionValue cov : car.getCarOptionValues()) {
            i++;
            CarCompletionOption cco = cov.getCCO();
            String suid = cco.getUid().trim();
            //BaseParam bp = baseParamService.getBaseParam(suid.trim());
            BaseParam bp = getBaseParam(allParams, suid);
            if (bp != null && StaticType.STATIC.equals(bp.getStaticType())
                    && cov.getPrice().compareTo(Double.valueOf(0)) == 0) {
                m++;
                //String colorRad = cco.getRadical();
                //suplog+="rc:"+radCore.trim()+"; rad:"+colorRad.toString().trim()+"; ";

                List<String> colorRadList = ConvertSupport.getRadicalList(cov.getRadical());
                if (!colorRadList.isEmpty()) {
                    n++;
                    String attrToxRad = "";
                    BigDecimal attrToxRate = BigDecimal.valueOf(-100);
                    for (String colorRad : colorRadList) {
                        BigDecimal ToxRate = BigDecimal
                                .valueOf(getToxicRate(radCore.trim(), radColor.trim(), colorRad));
                        if (ToxRate.compareTo(attrToxRate) > 0) {
                            attrToxRate = ToxRate;
                            attrToxRad = colorRad;
                        }
                    }
                    if (attrToxRad != null && !attrToxRad.equals("")) {
                        //String essRad = bp.getRadical().trim();

                        //BigDecimal essModalRate = BigDecimal.valueOf(0);
                        BigDecimal attrModalRate = BigDecimal.valueOf(0);
                        if (percType.equals(Perception.AUDIAL)) {
                            if (cov.getAudial() != null) {
                                attrModalRate = BigDecimal.valueOf(cov.getAudial());
                            }
                        } else if (percType.equals(Perception.KINESTETIC)) {
                            if (cov.getKinestet() != null) {
                                attrModalRate = BigDecimal.valueOf(cov.getKinestet());
                            }
                        } else if (percType.equals(Perception.VISUAL)) {
                            if (cov.getVisual() != null) {
                                attrModalRate = BigDecimal.valueOf(cov.getVisual());
                            }
                        }

                        if (attrToxRate.compareTo(one) >= 0) {
                            EntityProperty ep = new EntityProperty(bp.getName(), cco.getTitle(),
                                    cov.getDescription(), suid, attrToxRate, attrToxRad, attrModalRate, (double) 0,
                                    PropertyType.OPTION, " ??");
                            List<EntityProperty> availEps = staticProps.get(suid);
                            if (availEps == null || availEps.isEmpty()) {
                                availEps = new ArrayList();
                                availEps.add(ep);
                                staticProps.put(suid, availEps);
                            } else {
                                EntityProperty availEp = availEps.get(0);
                                if (attrToxRate.compareTo(availEp.value) == 0) {
                                    BigDecimal availModVal = availEp.modalValue;
                                    if (attrModalRate.compareTo(availModVal) > 0) {
                                        availEps = new ArrayList();
                                        availEps.add(ep);
                                        staticProps.put(suid, availEps);
                                    } else if (attrModalRate.compareTo(availModVal) == 0) {
                                        availEps.add(ep);
                                        staticProps.put(suid, availEps);
                                    }
                                } else if (attrToxRate.compareTo(availEp.getValue()) > 0) {
                                    availEps = new ArrayList();
                                    availEps.add(ep);
                                    staticProps.put(suid, availEps);
                                }
                            }
                        }

                        /*if (attrToxRate.compareTo(one) >= 0) {
                         EntityProperty availEp = staticProps.get(suid);
                         if (availEp == null) {
                         staticProps.put(suid, new EntityProperty(bp.getName(), cco.getTitle(), cov.getDescription(), suid, attrToxRate, attrToxRad, attrModalRate, (double) 0, PropertyType.OPTION));
                         } else {
                         if (attrToxRate.compareTo(availEp.getValue()) == 0) {
                         BigDecimal availModVal = staticProps.get(suid).modalValue;
                         if (attrModalRate.compareTo(availModVal) > 0) {
                         staticProps.put(suid, new EntityProperty(bp.getName(), cco.getTitle(), cov.getDescription(), suid, attrToxRate, attrToxRad, attrModalRate, (double) 0, PropertyType.OPTION));
                         }
                         } else if (attrToxRate.compareTo(availEp.getValue()) > 0) {
                         staticProps.put(suid, new EntityProperty(bp.getName(), cco.getTitle(), cov.getDescription(), suid, attrToxRate, attrToxRad, attrModalRate, (double) 0, PropertyType.OPTION));
                         }
                         }
                         //suplog+="COLOR: atr="+attrToxRate+"; am="+attrModalRate+"; etr="+essToxRate+"; statrate="+rel.toString()+"; ";
                         }*/
                    }
                }
            }

        }

        //suplog += "? ?.: " + i + ", ?  : " + m + " ? ? : " + n + "; " + "minToxLvl=" + minParamToxic1 + "; ";
        for (FreeOption fo : car.getFreeOptions()) {
            String suid = fo.getUid().trim();
            Boolean pricep = PropertyType.STATICBASIS.equals(fo.getType());

            //suplog+="!! suid="+suid.trim()+"; ";
            BaseParam bp = getBaseParam(allParams, suid);
            //suplog+=""+k+"."+ccv.getTitle()+" - "+ccv.getColor().getName()+"; ";
            if (bp != null && StaticType.STATIC.equals(bp.getStaticType())
                    && fo.getPrice().compareTo(Double.valueOf(0)) == 0) {
                List<String> colorRadList = ConvertSupport.getRadicalList(fo.getRadical());

                if (!colorRadList.isEmpty()) {
                    String attrToxRad = "";
                    BigDecimal attrToxRate = BigDecimal.valueOf(-100);
                    for (String colorRad : colorRadList) {
                        BigDecimal ToxRate = BigDecimal
                                .valueOf(getToxicRate(radCore.trim(), radColor.trim(), colorRad));
                        if (ToxRate.compareTo(attrToxRate) >= 0) {
                            attrToxRate = ToxRate;
                            attrToxRad = colorRad;
                        }
                    }
                    if (attrToxRad != null && !attrToxRad.equals("")) {
                        BigDecimal attrModalRate = BigDecimal.valueOf(0);
                        if (percType.equals(Perception.AUDIAL)) {
                            if (fo.getAudial() != null) {
                                attrModalRate = BigDecimal.valueOf(fo.getAudial());
                            }
                        } else if (percType.equals(Perception.KINESTETIC)) {
                            if (fo.getKinestetic() != null) {
                                attrModalRate = BigDecimal.valueOf(fo.getKinestetic());
                            }
                        } else if (percType.equals(Perception.VISUAL)) {
                            if (fo.getVisual() != null) {
                                attrModalRate = BigDecimal.valueOf(fo.getVisual());
                            }
                        }

                        if ((attrToxRate.compareTo(one) >= 0 && !pricep) || (pricep)) {
                            String statType = " ??";
                            if (pricep) {
                                statType = " ";
                            }
                            EntityProperty ep = new EntityProperty(bp.getName(), fo.getTitle(), suid, attrToxRate,
                                    attrToxRad, attrModalRate, fo.getPrice(), fo.getType(), statType);
                            List<EntityProperty> availEps = staticProps.get(suid);
                            if (availEps == null || availEps.isEmpty()) {
                                availEps = new ArrayList();
                                availEps.add(ep);
                                staticProps.put(suid, availEps);
                            } else {
                                EntityProperty availEp = availEps.get(0);
                                if ((!PropertyType.STATICBASIS.equals(availEp.type))
                                        || (PropertyType.STATICBASIS.equals(availEp.type) && pricep)) {
                                    if (attrToxRate.compareTo(availEp.value) == 0) {
                                        BigDecimal availModVal = availEp.modalValue;
                                        if (attrModalRate.compareTo(availModVal) > 0) {
                                            availEps = new ArrayList();
                                            availEps.add(ep);
                                            staticProps.put(suid, availEps);
                                        } else if (attrModalRate.compareTo(availModVal) == 0) {
                                            availEps.add(ep);
                                            staticProps.put(suid, availEps);
                                        }
                                    } else if (attrToxRate.compareTo(availEp.getValue()) > 0) {
                                        availEps = new ArrayList();
                                        availEps.add(ep);
                                        staticProps.put(suid, availEps);
                                    }
                                } else if (pricep) {
                                    availEps = new ArrayList();
                                    availEps.add(ep);
                                    staticProps.put(suid, availEps);
                                }
                            }
                        }

                        /* if (attrToxRate.compareTo(one) >= 0) {
                         EntityProperty availEp = staticProps.get(suid);
                         if (availEp == null) {
                         staticProps.put(suid, new EntityProperty(bp.getName(), fo.getTitle(), suid, attrToxRate, attrToxRad, attrModalRate, fo.getPrice(), fo.getType()));
                         } else {
                         if (attrToxRate.compareTo(availEp.getValue()) == 0) {
                         BigDecimal availModVal = availEp.modalValue;
                         if (attrModalRate.compareTo(availModVal) > 0) {
                         staticProps.put(suid, new EntityProperty(bp.getName(), fo.getTitle(), suid, attrToxRate, attrToxRad, attrModalRate, fo.getPrice(), fo.getType()));
                         }
                         } else if (attrToxRate.compareTo(availEp.getValue()) > 0) {
                         staticProps.put(suid, new EntityProperty(bp.getName(), fo.getTitle(), suid, attrToxRate, attrToxRad, attrModalRate, fo.getPrice(), fo.getType()));
                         }
                         }
                         //suplog+="COLOR: atr="+attrToxRate+"; am="+attrModalRate+"; etr="+essToxRate+"; statrate="+rel.toString()+"; ";
                         }*/
                    }
                }
            }
        }
        for (Feature f : car.getFeatures()) {
            String suid = f.getUid().trim();
            //suplog+="!! suid="+suid.trim()+"; ";
            BaseParam bp = getBaseParam(allParams, suid);
            //suplog+=""+k+"."+ccv.getTitle()+" - "+ccv.getColor().getName()+"; ";
            if (bp != null && StaticType.STATIC.equals(bp.getStaticType())) {
                List<String> colorRadList = ConvertSupport.getRadicalList(f.getRadical());
                if (!colorRadList.isEmpty()) {
                    String attrToxRad = "";
                    BigDecimal attrToxRate = BigDecimal.valueOf(-100);
                    for (String colorRad : colorRadList) {
                        BigDecimal ToxRate = BigDecimal
                                .valueOf(getToxicRate(radCore.trim(), radColor.trim(), colorRad));
                        if (ToxRate.compareTo(attrToxRate) > 0) {
                            attrToxRate = ToxRate;
                            attrToxRad = colorRad;
                        }
                    }
                    if (attrToxRad != null && !attrToxRad.equals("")) {
                        BigDecimal attrModalRate = BigDecimal.valueOf(0);
                        if (percType.equals(Perception.AUDIAL)) {
                            if (f.getAudial() != null) {
                                attrModalRate = BigDecimal.valueOf(f.getAudial());
                            }
                        } else if (percType.equals(Perception.KINESTETIC)) {
                            if (f.getKinestet() != null) {
                                attrModalRate = BigDecimal.valueOf(f.getKinestet());
                            }
                        } else if (percType.equals(Perception.VISUAL)) {
                            if (f.getVisual() != null) {
                                attrModalRate = BigDecimal.valueOf(f.getVisual());
                            }
                        }

                        if (attrToxRate.compareTo(one) >= 0) {
                            EntityProperty ep = new EntityProperty(bp.getName(), f.getTitle(), suid, attrToxRate,
                                    attrToxRad, attrModalRate, (double) 0, PropertyType.FEATURE,
                                    " ??");
                            List<EntityProperty> availEps = staticProps.get(suid);
                            if (availEps == null || availEps.isEmpty()) {
                                availEps = new ArrayList();
                                availEps.add(ep);
                                staticProps.put(suid, availEps);
                            } else {
                                EntityProperty availEp = availEps.get(0);
                                if (attrToxRate.compareTo(availEp.value) == 0) {
                                    BigDecimal availModVal = availEp.modalValue;
                                    if (attrModalRate.compareTo(availModVal) > 0) {
                                        availEps = new ArrayList();
                                        availEps.add(ep);
                                        staticProps.put(suid, availEps);
                                    } else if (attrModalRate.compareTo(availModVal) == 0) {
                                        availEps.add(ep);
                                        staticProps.put(suid, availEps);
                                    }
                                } else if (attrToxRate.compareTo(availEp.getValue()) > 0) {
                                    availEps = new ArrayList();
                                    availEps.add(ep);
                                    staticProps.put(suid, availEps);
                                }
                            }
                        }

                        /*if (attrToxRate.compareTo(one) >= 0) {
                         EntityProperty availEp = staticProps.get(suid);
                         if (availEp == null) {
                         staticProps.put(suid, new EntityProperty(bp.getName(), f.getTitle(), suid, attrToxRate, attrToxRad, attrModalRate, (double) 0, PropertyType.FEATURE));
                         } else {
                         if (attrToxRate.compareTo(availEp.getValue()) == 0) {
                         BigDecimal availModVal = staticProps.get(suid).modalValue;
                         if (attrModalRate.compareTo(availModVal) > 0) {
                         staticProps.put(suid, new EntityProperty(bp.getName(), f.getTitle(), suid, attrToxRate, attrToxRad, attrModalRate, (double) 0, PropertyType.FEATURE));
                         }
                         } else if (attrToxRate.compareTo(availEp.getValue()) > 0) {
                         staticProps.put(suid, new EntityProperty(bp.getName(), f.getTitle(), suid, attrToxRate, attrToxRad, attrModalRate, (double) 0, PropertyType.FEATURE));
                         }
                         }
                         //suplog+="COLOR: atr="+attrToxRate+"; am="+attrModalRate+"; etr="+essToxRate+"; statrate="+rel.toString()+"; ";
                         }*/
                    }
                }
            }
        }

    }

    private void monetaryStaticCount(boolean first) throws Exception {
        BigDecimal minParamTox = BigDecimal.valueOf(1);
        BigDecimal minValueTox = BigDecimal.valueOf(1);
        if (first) {
            minParamTox = minParamToxic1;
            minValueTox = minValueToxic1;
        } else {
            minParamTox = minParamToxic2;
            minValueTox = minValueToxic2;
        }
        //suplog+=" secCount: "+resStatType+"; ";
        if (resStatType.equals(ResourceStaticType.BOTH)) {
            if (minValueTox.compareTo(BigDecimal.valueOf(1)) < 0) {
                for (CarColorValue ccv : car.getCarColorValues()) {
                    //k++;
                    Color col = ccv.getColor();
                    String suid = col.getUid().trim();
                    //suplog+="!! suid="+suid.trim()+"; ";
                    BaseParam bp = getBaseParam(allParams, suid);
                    //suplog+=""+k+"."+ccv.getTitle()+" - "+ccv.getColor().getName()+"; ";
                    if (bp != null && StaticType.STATIC.equals(bp.getStaticType())) {
                        List<String> colorRadList = ConvertSupport.getRadicalList(col.getRadical());
                        if (!colorRadList.isEmpty()) {
                            String attrToxRad = "";
                            BigDecimal attrToxRate = BigDecimal.valueOf(-100);
                            for (String colorRad : colorRadList) {
                                BigDecimal ToxRate = BigDecimal
                                        .valueOf(getToxicRate(radCore.trim(), radColor.trim(), colorRad));
                                if (ToxRate.compareTo(attrToxRate) > 0) {
                                    attrToxRate = ToxRate;
                                    attrToxRad = colorRad;
                                }
                            }
                            if (attrToxRad != null && !attrToxRad.equals("")) {
                                BigDecimal attrModalRate = BigDecimal.valueOf(0);
                                if (percType.equals(Perception.AUDIAL)) {
                                    if (col.getAudial() != null) {
                                        attrModalRate = BigDecimal.valueOf(col.getAudial());
                                    }
                                } else if (percType.equals(Perception.KINESTETIC)) {
                                    if (col.getKinestet() != null) {
                                        attrModalRate = BigDecimal.valueOf(col.getKinestet());
                                    }
                                } else if (percType.equals(Perception.VISUAL)) {
                                    if (col.getVisual() != null) {
                                        attrModalRate = BigDecimal.valueOf(col.getVisual());
                                    }
                                }

                                if (attrToxRate.compareTo(minValueTox) >= 0) {
                                    String statType = " 1";
                                    if (!first) {
                                        statType = " 2";
                                    }
                                    EntityProperty ep = new EntityProperty(bp.getName(), ccv.getTitle(), suid,
                                            attrToxRate, attrToxRad, attrModalRate, (double) 0, PropertyType.OPTION,
                                            statType);
                                    List<EntityProperty> availEps = staticProps.get(suid);
                                    if (availEps == null || availEps.isEmpty()) {
                                        availEps = new ArrayList();
                                        availEps.add(ep);
                                        staticProps.put(suid, availEps);
                                    } else {
                                        EntityProperty availEp = availEps.get(0);
                                        Boolean diffrentOption = (availEp.getValue().compareTo(attrToxRate) != 0)
                                                || (!availEp.title.equals(ccv.getTitle()))
                                                || (!availEp.type.equals(PropertyType.OPTION))
                                                || (!availEp.name.equals(bp.getName()))
                                                || (availEp.price.compareTo(BigDecimal.valueOf(0))) != 0;
                                        if (diffrentOption) {
                                            if (attrToxRate.compareTo(availEp.value) == 0) {
                                                BigDecimal availModVal = availEp.modalValue;
                                                if (attrModalRate.compareTo(availModVal) > 0) {
                                                    availEps = new ArrayList();
                                                    availEps.add(ep);
                                                    staticProps.put(suid, availEps);
                                                } else if (attrModalRate.compareTo(availModVal) == 0) {
                                                    availEps.add(ep);
                                                    staticProps.put(suid, availEps);
                                                }
                                            } else if (attrToxRate.compareTo(availEp.getValue()) > 0) {
                                                availEps = new ArrayList();
                                                availEps.add(ep);
                                                staticProps.put(suid, availEps);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                //suplog+=" fs: "+car.getFeatures().size()+"; ";
                for (Feature f : car.getFeatures()) {
                    String suid = f.getUid().trim();
                    //suplog+="!! suid="+suid.trim()+"; ";
                    BaseParam bp = getBaseParam(allParams, suid);
                    //suplog+=""+k+"."+ccv.getTitle()+" - "+ccv.getColor().getName()+"; ";
                    if (bp != null && StaticType.STATIC.equals(bp.getStaticType())) {
                        List<String> colorRadList = ConvertSupport.getRadicalList(f.getRadical());
                        if (!colorRadList.isEmpty()) {
                            String attrToxRad = "";
                            BigDecimal attrToxRate = BigDecimal.valueOf(-100);
                            for (String colorRad : colorRadList) {
                                BigDecimal ToxRate = BigDecimal
                                        .valueOf(getToxicRate(radCore.trim(), radColor.trim(), colorRad));
                                if (ToxRate.compareTo(attrToxRate) > 0) {
                                    attrToxRate = ToxRate;
                                    attrToxRad = colorRad;
                                }
                            }
                            if (attrToxRad != null && !attrToxRad.equals("")) {
                                BigDecimal attrModalRate = BigDecimal.valueOf(0);
                                if (percType.equals(Perception.AUDIAL)) {
                                    if (f.getAudial() != null) {
                                        attrModalRate = BigDecimal.valueOf(f.getAudial());
                                    }
                                } else if (percType.equals(Perception.KINESTETIC)) {
                                    if (f.getKinestet() != null) {
                                        attrModalRate = BigDecimal.valueOf(f.getKinestet());
                                    }
                                } else if (percType.equals(Perception.VISUAL)) {
                                    if (f.getVisual() != null) {
                                        attrModalRate = BigDecimal.valueOf(f.getVisual());
                                    }
                                }

                                if (attrToxRate.compareTo(minValueTox) >= 0) {
                                    String statType = " 1";
                                    if (!first) {
                                        statType = " 2";
                                    }
                                    EntityProperty ep = new EntityProperty(bp.getName(), f.getTitle(), suid,
                                            attrToxRate, attrToxRad, attrModalRate, (double) 0,
                                            PropertyType.FEATURE, statType);
                                    List<EntityProperty> availEps = staticProps.get(suid);
                                    if (availEps == null || availEps.isEmpty()) {
                                        availEps = new ArrayList();
                                        availEps.add(ep);
                                        staticProps.put(suid, availEps);
                                    } else {
                                        EntityProperty availEp = availEps.get(0);

                                        Boolean diffrentOption = (availEp.getValue().compareTo(attrToxRate) != 0)
                                                || (!availEp.title.equals(f.getTitle()))
                                                || (!availEp.type.equals(PropertyType.FEATURE))
                                                || (!availEp.name.equals(bp.getName()))
                                                || (availEp.price.compareTo(BigDecimal.valueOf(0))) != 0;
                                        if (diffrentOption) {
                                            if (attrToxRate.compareTo(availEp.value) == 0) {
                                                BigDecimal availModVal = availEp.modalValue;
                                                if (attrModalRate.compareTo(availModVal) > 0) {
                                                    availEps = new ArrayList();
                                                    availEps.add(ep);
                                                    staticProps.put(suid, availEps);
                                                } else if (attrModalRate.compareTo(availModVal) == 0) {
                                                    availEps.add(ep);
                                                    staticProps.put(suid, availEps);
                                                }
                                            } else if (attrToxRate.compareTo(availEp.getValue()) > 0) {
                                                availEps = new ArrayList();
                                                availEps.add(ep);
                                                staticProps.put(suid, availEps);
                                            }
                                        }
                                    }
                                }

                                /*if (attrToxRate.compareTo(minValueTox) >= 0) {
                                 EntityProperty availEp = staticProps.get(suid);
                                 if (availEp == null) {
                                 staticProps.put(suid, new EntityProperty(bp.getName(), f.getTitle(), suid, attrToxRate, attrToxRad, attrModalRate, (double) 0, PropertyType.FEATURE));
                                 } else {
                                 if (attrToxRate.compareTo(availEp.value) == 0) {
                                 BigDecimal availModVal = staticProps.get(suid).modalValue;
                                 if (attrModalRate.compareTo(availModVal) > 0) {
                                 staticProps.put(suid, new EntityProperty(bp.getName(), f.getTitle(), suid, attrToxRate, attrToxRad, attrModalRate, (double) 0, PropertyType.FEATURE));
                                 }
                                 } else if (attrToxRate.compareTo(availEp.value) > 0) {
                                 staticProps.put(suid, new EntityProperty(bp.getName(), f.getTitle(), suid, attrToxRate, attrToxRad, attrModalRate, (double) 0, PropertyType.FEATURE));
                                 }
                                 }
                                 //suplog+="COLOR: atr="+attrToxRate+"; am="+attrModalRate+"; etr="+essToxRate+"; statrate="+rel.toString()+"; ";
                                 }*/
                            }
                        }
                    }
                }
            }
            int i = 0;
            int m = 0;
            int n = 0;
            //suplog+=" covs: "+car.getCarOptionValues().size()+"; ";
            for (CarOptionValue cov : car.getCarOptionValues()) {
                CarCompletionOption cco = cov.getCCO();
                String suid = cco.getUid().trim();
                BaseParam bp = getBaseParam(allParams, suid);
                if (bp != null && StaticType.STATIC.equals(bp.getStaticType())
                        && BigDecimal.valueOf(cov.getPrice()).compareTo(moneyFound) <= 0) {
                    i++;
                    //suplog += " radseqs=" + cov.getRadical() + "; ";
                    List<String> colorRadList = ConvertSupport.getRadicalList(cov.getRadical());
                    if (!colorRadList.isEmpty()) {
                        m++;

                        String attrToxRad = "";
                        BigDecimal attrToxRate = BigDecimal.valueOf(-100);
                        for (String colorRad : colorRadList) {
                            BigDecimal ToxRate = BigDecimal
                                    .valueOf(getToxicRate(radCore.trim(), radColor.trim(), colorRad));
                            if (ToxRate.compareTo(attrToxRate) > 0) {
                                attrToxRate = ToxRate;
                                attrToxRad = colorRad;
                            }
                        }
                        //suplog += " atr=" + attrToxRate + "; atrad=" + attrToxRad + "; ";
                        if (attrToxRad != null && !attrToxRad.equals("")) {
                            BigDecimal attrModalRate = BigDecimal.valueOf(0);
                            if (percType.equals(Perception.AUDIAL)) {
                                if (cov.getAudial() != null) {
                                    attrModalRate = BigDecimal.valueOf(cov.getAudial());
                                }
                            } else if (percType.equals(Perception.KINESTETIC)) {
                                if (cov.getKinestet() != null) {
                                    attrModalRate = BigDecimal.valueOf(cov.getKinestet());
                                }
                            } else if (percType.equals(Perception.VISUAL)) {
                                if (cov.getVisual() != null) {
                                    attrModalRate = BigDecimal.valueOf(cov.getVisual());
                                }
                            }
                            //suplog += " amr=" + attrModalRate + "; ";

                            if (attrToxRate.compareTo(minValueTox) >= 0) {
                                String statType = " 1";
                                if (!first) {
                                    statType = " 2";
                                }
                                EntityProperty ep = new EntityProperty(bp.getName(), cco.getTitle(),
                                        cov.getDescription(), suid, attrToxRate, attrToxRad, attrModalRate,
                                        cov.getPrice(), PropertyType.OPTION, statType);
                                List<EntityProperty> availEps = staticProps.get(suid);
                                if (availEps == null || availEps.isEmpty()) {
                                    availEps = new ArrayList();
                                    availEps.add(ep);
                                    staticProps.put(suid, availEps);
                                    moneyFound = moneyFound.subtract(ep.price);
                                } else {
                                    EntityProperty availEp = availEps.get(0);

                                    Boolean diffrentOption = (availEp.getValue().compareTo(attrToxRate) != 0)
                                            || (!availEp.title.equals(cco.getTitle()))
                                            || (!availEp.type.equals(PropertyType.OPTION))
                                            || (!availEp.name.equals(bp.getName()))
                                            || (availEp.price.compareTo(BigDecimal.valueOf(cov.getPrice()))) != 0;
                                    if (diffrentOption) {
                                        if (attrToxRate.compareTo(availEp.value) == 0) {
                                            BigDecimal availModVal = availEp.modalValue;
                                            if (attrModalRate.compareTo(availModVal) > 0) {
                                                moneyFound = moneyFound.add(availEp.price);
                                                availEps = new ArrayList();
                                                availEps.add(ep);
                                                staticProps.put(suid, availEps);
                                                moneyFound = moneyFound.subtract(ep.price);
                                            } else if (attrModalRate.compareTo(availModVal) == 0) {
                                                if (ep.price.compareTo(availEp.price) == 0) {
                                                    availEps.add(ep);
                                                    staticProps.put(suid, availEps);
                                                } else if (ep.price.compareTo(availEp.price) < 0) {
                                                    moneyFound = moneyFound.add(availEp.price);
                                                    availEps = new ArrayList();
                                                    availEps.add(ep);
                                                    staticProps.put(suid, availEps);
                                                    moneyFound = moneyFound.subtract(ep.price);
                                                }
                                            }
                                        } else if (attrToxRate.compareTo(availEp.getValue()) > 0) {
                                            moneyFound = moneyFound.add(availEp.price);
                                            availEps = new ArrayList();
                                            availEps.add(ep);
                                            staticProps.put(suid, availEps);
                                            moneyFound = moneyFound.subtract(ep.price);
                                        }
                                    }
                                }
                            }

                            /*if (attrToxRate.compareTo(minValueTox) >= 0) {
                             EntityProperty availEp = staticProps.get(suid);
                             n++;
                             if (availEp == null) {
                             staticProps.put(suid, new EntityProperty(bp.getName(), cco.getTitle(), cov.getDescription(), suid, attrToxRate, attrToxRad, attrModalRate, cov.getPrice(), PropertyType.OPTION));
                             } else {
                             if (attrToxRate.compareTo(availEp.value) == 0) {
                             BigDecimal availModVal = staticProps.get(suid).modalValue;
                             if (attrModalRate.compareTo(availModVal) > 0) {
                             staticProps.put(suid, new EntityProperty(bp.getName(), cco.getTitle(), cov.getDescription(), suid, attrToxRate, attrToxRad, attrModalRate, cov.getPrice(), PropertyType.OPTION));
                             }
                             } else if (attrToxRate.compareTo(availEp.value) > 0) {
                             staticProps.put(suid, new EntityProperty(bp.getName(), cco.getTitle(), cov.getDescription(), suid, attrToxRate, attrToxRad, attrModalRate, cov.getPrice(), PropertyType.OPTION));
                             }
                             }
                             }*/
                        }
                    }
                }
            }
            //suplog += "? ?. ?  : " + i + " ? ? : " + m + ", :"+n+"; minToxLv2=" + minParamToxic2 + "; ";
            //suplog+=" fos: "+car.getFreeOptions().size()+"; ";
            for (FreeOption fo : car.getFreeOptions()) {
                String suid = fo.getUid().trim();
                BaseParam bp = getBaseParam(allParams, suid);
                if (bp != null && StaticType.STATIC.equals(bp.getStaticType())
                        && BigDecimal.valueOf(fo.getPrice()).compareTo(moneyFound) <= 0) {
                    List<String> colorRadList = ConvertSupport.getRadicalList(fo.getRadical());
                    if (!colorRadList.isEmpty()) {
                        String attrToxRad = "";
                        BigDecimal attrToxRate = BigDecimal.valueOf(-100);
                        for (String colorRad : colorRadList) {
                            BigDecimal ToxRate = BigDecimal
                                    .valueOf(getToxicRate(radCore.trim(), radColor.trim(), colorRad));
                            if (ToxRate.compareTo(attrToxRate) > 0) {
                                attrToxRate = ToxRate;
                                attrToxRad = colorRad;
                            }
                        }
                        if (attrToxRad != null && !attrToxRad.equals("")) {
                            BigDecimal attrModalRate = BigDecimal.valueOf(0);
                            if (percType.equals(Perception.AUDIAL)) {
                                if (fo.getAudial() != null) {
                                    attrModalRate = BigDecimal.valueOf(fo.getAudial());
                                }
                            } else if (percType.equals(Perception.KINESTETIC)) {
                                if (fo.getKinestetic() != null) {
                                    attrModalRate = BigDecimal.valueOf(fo.getKinestetic());
                                }
                            } else if (percType.equals(Perception.VISUAL)) {
                                if (fo.getVisual() != null) {
                                    attrModalRate = BigDecimal.valueOf(fo.getVisual());
                                }
                            }

                            if (attrToxRate.compareTo(minValueTox) >= 0) {
                                String statType = " 1";
                                if (!first) {
                                    statType = " 2";
                                }
                                EntityProperty ep = new EntityProperty(bp.getName(), fo.getTitle(), suid,
                                        attrToxRate, attrToxRad, attrModalRate, fo.getPrice(), fo.getType(),
                                        statType);
                                List<EntityProperty> availEps = staticProps.get(suid);

                                if (availEps == null || availEps.isEmpty()) {
                                    availEps = new ArrayList();
                                    availEps.add(ep);
                                    staticProps.put(suid, availEps);
                                    moneyFound = moneyFound.subtract(ep.price);
                                } else {
                                    EntityProperty availEp = availEps.get(0);

                                    Boolean diffrentOption = (availEp.getValue().compareTo(attrToxRate) != 0)
                                            || (!availEp.title.equals(fo.getTitle()))
                                            || (!availEp.type.equals(fo.getType()))
                                            || (!availEp.name.equals(bp.getName()))
                                            || (availEp.price.compareTo(BigDecimal.valueOf(fo.getPrice()))) != 0;
                                    if (diffrentOption) {
                                        if (attrToxRate.compareTo(availEp.value) == 0) {
                                            BigDecimal availModVal = availEp.modalValue;
                                            if (attrModalRate.compareTo(availModVal) > 0) {
                                                moneyFound = moneyFound.add(availEp.price);
                                                availEps = new ArrayList();
                                                availEps.add(ep);
                                                staticProps.put(suid, availEps);
                                                moneyFound = moneyFound.subtract(ep.price);
                                            } else if (attrModalRate.compareTo(availModVal) == 0) {
                                                if (ep.price.compareTo(availEp.price) == 0) {
                                                    availEps.add(ep);
                                                    staticProps.put(suid, availEps);
                                                } else if (ep.price.compareTo(availEp.price) < 0) {
                                                    moneyFound = moneyFound.add(availEp.price);
                                                    availEps = new ArrayList();
                                                    availEps.add(ep);
                                                    staticProps.put(suid, availEps);
                                                    moneyFound = moneyFound.subtract(ep.price);
                                                }
                                            }
                                        } else if (attrToxRate.compareTo(availEp.getValue()) > 0) {
                                            moneyFound = moneyFound.add(availEp.price);
                                            availEps = new ArrayList();
                                            availEps.add(ep);
                                            staticProps.put(suid, availEps);
                                            moneyFound = moneyFound.subtract(ep.price);
                                        }
                                    }
                                }
                            }

                            /*if (attrToxRate.compareTo(minValueTox) >= 0) {
                             EntityProperty availEp = staticProps.get(suid);
                             if (availEp == null) {
                             staticProps.put(suid, new EntityProperty(bp.getName(), fo.getTitle(), suid, attrToxRate, attrToxRad, attrModalRate, fo.getPrice(), fo.getType()));
                             } else {
                             if (attrToxRate.compareTo(availEp.value) == 0) {
                             BigDecimal availModVal = staticProps.get(suid).modalValue;
                             if (attrModalRate.compareTo(availModVal) > 0) {
                             staticProps.put(suid, new EntityProperty(bp.getName(), fo.getTitle(), suid, attrToxRate, attrToxRad, attrModalRate, fo.getPrice(), fo.getType()));
                             }
                             } else if (attrToxRate.compareTo(availEp.value) > 0) {
                             staticProps.put(suid, new EntityProperty(bp.getName(), fo.getTitle(), suid, attrToxRate, attrToxRad, attrModalRate, fo.getPrice(), fo.getType()));
                             }
                             }
                             }*/
                        }
                    }
                }
            }
        } else {
            //suplog += " covs2: " + car.getCarOptionValues().size() + "; ";
            for (CarOptionValue cov : car.getCarOptionValues()) {
                CarCompletionOption cco = cov.getCCO();
                String suid = cco.getUid().trim();
                BaseParam bp = getBaseParam(allParams, suid);
                if (bp != null && StaticType.STATIC.equals(bp.getStaticType())
                        && cov.getPrice().compareTo(Double.valueOf(0)) > 0
                        && BigDecimal.valueOf(cov.getPrice()).compareTo(moneyFound) <= 0) {
                    List<String> colorRadList = ConvertSupport.getRadicalList(cov.getRadical());
                    if (!colorRadList.isEmpty()) {
                        String attrToxRad = "";
                        BigDecimal attrToxRate = BigDecimal.valueOf(-100);
                        for (String colorRad : colorRadList) {
                            BigDecimal ToxRate = BigDecimal
                                    .valueOf(getToxicRate(radCore.trim(), radColor.trim(), colorRad));
                            if (ToxRate.compareTo(attrToxRate) > 0) {
                                attrToxRate = ToxRate;
                                attrToxRad = colorRad;
                            }
                        }
                        if (attrToxRad != null && !attrToxRad.equals("")) {
                            BigDecimal attrModalRate = BigDecimal.valueOf(0);
                            if (percType.equals(Perception.AUDIAL)) {
                                if (cov.getAudial() != null) {
                                    attrModalRate = BigDecimal.valueOf(cov.getAudial());
                                }
                            } else if (percType.equals(Perception.KINESTETIC)) {
                                if (cov.getKinestet() != null) {
                                    attrModalRate = BigDecimal.valueOf(cov.getKinestet());
                                }
                            } else if (percType.equals(Perception.VISUAL)) {
                                if (cov.getVisual() != null) {
                                    attrModalRate = BigDecimal.valueOf(cov.getVisual());
                                }
                            }

                            if (attrToxRate.compareTo(minValueTox) >= 0) {
                                String statType = " 1";
                                if (!first) {
                                    statType = " 2";
                                }
                                EntityProperty ep = new EntityProperty(bp.getName(), cco.getTitle(),
                                        cov.getDescription(), suid, attrToxRate, attrToxRad, attrModalRate,
                                        cov.getPrice(), PropertyType.OPTION, statType);
                                List<EntityProperty> availEps = staticProps.get(suid);
                                if (availEps == null || availEps.isEmpty()) {
                                    availEps = new ArrayList();
                                    availEps.add(ep);
                                    staticProps.put(suid, availEps);
                                    moneyFound = moneyFound.subtract(ep.price);
                                } else {
                                    EntityProperty availEp = availEps.get(0);
                                    Boolean diffrentOption = (availEp.getValue().compareTo(attrToxRate) != 0)
                                            || (!availEp.title.equals(cco.getTitle()))
                                            || (!availEp.type.equals(PropertyType.OPTION))
                                            || (!availEp.name.equals(bp.getName()))
                                            || (availEp.price.compareTo(BigDecimal.valueOf(cov.getPrice()))) != 0;
                                    if (diffrentOption) {
                                        if (availEp.price.compareTo(BigDecimal.valueOf(0)) > 0) {
                                            if (attrToxRate.compareTo(availEp.value) == 0) {
                                                BigDecimal availModVal = availEp.modalValue;
                                                if (attrModalRate.compareTo(availModVal) > 0) {
                                                    moneyFound = moneyFound.add(availEp.price);
                                                    availEps = new ArrayList();
                                                    availEps.add(ep);
                                                    staticProps.put(suid, availEps);
                                                    moneyFound = moneyFound.subtract(ep.price);
                                                } else if (attrModalRate.compareTo(availModVal) == 0) {
                                                    if (ep.price.compareTo(availEp.price) == 0) {
                                                        availEps.add(ep);
                                                        staticProps.put(suid, availEps);
                                                    } else if (ep.price.compareTo(availEp.price) < 0) {
                                                        moneyFound = moneyFound.add(availEp.price);
                                                        availEps = new ArrayList();
                                                        availEps.add(ep);
                                                        staticProps.put(suid, availEps);
                                                        moneyFound = moneyFound.subtract(ep.price);
                                                    }
                                                }
                                            } else if (attrToxRate.compareTo(availEp.getValue()) > 0) {
                                                moneyFound = moneyFound.add(availEp.price);
                                                availEps = new ArrayList();
                                                availEps.add(ep);
                                                staticProps.put(suid, availEps);
                                                moneyFound = moneyFound.subtract(ep.price);
                                            }
                                        }
                                    }
                                }
                            }

                            /*if (attrToxRate.compareTo(minValueTox) >= 0) {
                             EntityProperty availEp = staticProps.get(suid);
                             if (availEp == null) {
                             staticProps.put(suid, new EntityProperty(bp.getName(), cco.getTitle(), cov.getDescription(), suid, attrToxRate, attrToxRad, attrModalRate, cov.getPrice(), PropertyType.OPTION));
                             } else {
                             if (attrToxRate.compareTo(availEp.value) == 0) {
                             BigDecimal availModVal = staticProps.get(suid).modalValue;
                             if (attrModalRate.compareTo(availModVal) > 0) {
                             staticProps.put(suid, new EntityProperty(bp.getName(), cco.getTitle(), cov.getDescription(), suid, attrToxRate, attrToxRad, attrModalRate, cov.getPrice(), PropertyType.OPTION));
                             }
                             } else if (attrToxRate.compareTo(availEp.value) > 0) {
                             staticProps.put(suid, new EntityProperty(bp.getName(), cco.getTitle(), cov.getDescription(), suid, attrToxRate, attrToxRad, attrModalRate, cov.getPrice(), PropertyType.OPTION));
                             }
                             }
                             }*/
                        }
                    }
                }
            }
            //suplog += " fos2: " + car.getFreeOptions().size() + "; ";
            for (FreeOption fo : car.getFreeOptions()) {
                String suid = fo.getUid().trim();
                BaseParam bp = getBaseParam(allParams, suid);
                if (bp != null && StaticType.STATIC.equals(bp.getStaticType())
                        && fo.getPrice().compareTo(Double.valueOf(0)) > 0
                        && BigDecimal.valueOf(fo.getPrice()).compareTo(moneyFound) <= 0) {
                    List<String> colorRadList = ConvertSupport.getRadicalList(fo.getRadical());
                    if (!colorRadList.isEmpty()) {
                        String attrToxRad = "";
                        BigDecimal attrToxRate = BigDecimal.valueOf(-100);
                        for (String colorRad : colorRadList) {
                            BigDecimal ToxRate = BigDecimal
                                    .valueOf(getToxicRate(radCore.trim(), radColor.trim(), colorRad));
                            if (ToxRate.compareTo(attrToxRate) > 0) {
                                attrToxRate = ToxRate;
                                attrToxRad = colorRad;
                            }
                        }
                        if (attrToxRad != null && !attrToxRad.equals("")) {
                            BigDecimal attrModalRate = BigDecimal.valueOf(0);
                            if (percType.equals(Perception.AUDIAL)) {
                                if (fo.getAudial() != null) {
                                    attrModalRate = BigDecimal.valueOf(fo.getAudial());
                                }
                            } else if (percType.equals(Perception.KINESTETIC)) {
                                if (fo.getKinestetic() != null) {
                                    attrModalRate = BigDecimal.valueOf(fo.getKinestetic());
                                }
                            } else if (percType.equals(Perception.VISUAL)) {
                                if (fo.getVisual() != null) {
                                    attrModalRate = BigDecimal.valueOf(fo.getVisual());
                                }
                            }

                            if (attrToxRate.compareTo(minValueTox) >= 0) {
                                String statType = " 1";
                                if (!first) {
                                    statType = " 2";
                                }
                                EntityProperty ep = new EntityProperty(bp.getName(), fo.getTitle(), suid,
                                        attrToxRate, attrToxRad, attrModalRate, fo.getPrice(), fo.getType(),
                                        statType);
                                List<EntityProperty> availEps = staticProps.get(suid);
                                if (availEps == null || availEps.isEmpty()) {
                                    availEps = new ArrayList();
                                    availEps.add(ep);
                                    staticProps.put(suid, availEps);
                                    moneyFound = moneyFound.subtract(ep.price);
                                } else {
                                    EntityProperty availEp = availEps.get(0);

                                    Boolean diffrentOption = (availEp.getValue().compareTo(attrToxRate) != 0)
                                            || (!availEp.title.equals(fo.getTitle()))
                                            || (!availEp.type.equals(fo.getType()))
                                            || (!availEp.name.equals(bp.getName()))
                                            || (availEp.price.compareTo(BigDecimal.valueOf(fo.getPrice()))) != 0;
                                    if (diffrentOption) {
                                        if (availEp.price.compareTo(BigDecimal.valueOf(0)) > 0) {
                                            if (attrToxRate.compareTo(availEp.value) == 0) {
                                                BigDecimal availModVal = availEp.modalValue;
                                                if (attrModalRate.compareTo(availModVal) > 0) {
                                                    moneyFound = moneyFound.add(availEp.price);
                                                    availEps = new ArrayList();
                                                    availEps.add(ep);
                                                    staticProps.put(suid, availEps);
                                                    moneyFound = moneyFound.subtract(ep.price);
                                                } else if (attrModalRate.compareTo(availModVal) == 0) {
                                                    if (ep.price.compareTo(availEp.price) == 0) {
                                                        availEps.add(ep);
                                                        staticProps.put(suid, availEps);
                                                    } else if (ep.price.compareTo(availEp.price) < 0) {
                                                        moneyFound = moneyFound.add(availEp.price);
                                                        availEps = new ArrayList();
                                                        availEps.add(ep);
                                                        staticProps.put(suid, availEps);
                                                        moneyFound = moneyFound.subtract(ep.price);
                                                    }
                                                }
                                            } else if (attrToxRate.compareTo(availEp.getValue()) > 0) {
                                                moneyFound = moneyFound.add(availEp.price);
                                                availEps = new ArrayList();
                                                availEps.add(ep);
                                                staticProps.put(suid, availEps);
                                                moneyFound = moneyFound.subtract(ep.price);
                                            }
                                        }
                                    }
                                }
                            }

                            /*if (attrToxRate.compareTo(minValueTox) >= 0) {
                             EntityProperty availEp = staticProps.get(suid);
                             if (availEp == null) {
                             staticProps.put(suid, new EntityProperty(bp.getName(), fo.getTitle(), suid, attrToxRate, attrToxRad, attrModalRate, fo.getPrice(), fo.getType()));
                             } else {
                             if (attrToxRate.compareTo(availEp.value) == 0) {
                             BigDecimal availModVal = staticProps.get(suid).modalValue;
                             if (attrModalRate.compareTo(availModVal) > 0) {
                             staticProps.put(suid, new EntityProperty(bp.getName(), fo.getTitle(), suid, attrToxRate, attrToxRad, attrModalRate, fo.getPrice(), fo.getType()));
                             }
                             } else if (attrToxRate.compareTo(availEp.value) > 0) {
                             staticProps.put(suid, new EntityProperty(bp.getName(), fo.getTitle(), suid, attrToxRate, attrToxRad, attrModalRate, fo.getPrice(), fo.getType()));
                             }
                             }
                             }*/
                        }
                    }
                }
            }
        }
    }

    public String getMarkTitle() {
        return markTitle;
    }

    public String getModelTitle() {
        return modelTitle;
    }

    public String getCarTitle() {
        return carTitle;
    }

    public BigDecimal getPrice() {
        return basePrice;
    }

    public BigDecimal getStaticRate() {
        return staticRate;
    }

    public BigDecimal getFixPrice() {
        return fullPrice;
    }

    public void setFixPrice(BigDecimal fixPrice) {
        this.fullPrice = fixPrice;
    }

    public void setStaticRate(BigDecimal staticRate) {
        this.staticRate = staticRate;
    }

    public BigDecimal getDinamicRateA() {
        return dinamicRateA;
    }

    public void setDinamicRateA(BigDecimal dinamicRateA) {
        this.dinamicRateA = dinamicRateA;
    }

    public BigDecimal getDinamicRateB() {
        return dinamicRateB;
    }

    public void setDinamicRateB(BigDecimal dinamicRateB) {
        this.dinamicRateB = dinamicRateB;
    }

    public String getLog() {
        return log;
    }

    public void setLog(String log) {
        this.log = log;
    }

    public Map<String, EntityPropertyHolder> getAprops() {
        return aprops;
    }

    public void setAprops(Map<String, EntityPropertyHolder> aprops) {
        this.aprops = aprops;
    }

    public Map<String, EntityPropertyHolder> getBprops() {
        return bprops;
    }

    public void setBprops(Map<String, EntityPropertyHolder> bprops) {
        this.bprops = bprops;
    }

    /*public void renderPrepare() {
     this.fixPriceForRender = renderDecimal(this.fixPrice);
     this.basePriceForRender = renderDecimal(this.basePrice);
     this.aFundForRender = renderDecimal(this.aFund);
     this.bFundForRender = renderDecimal(this.bFund);
     this.totalFundForRender = renderDecimal(this.aFund.add(this.bFund));
     this.staticFundForRender = renderDecimal();
     }*/

    /*public String getStringPrice() {
     return basePriceForRender;
     }
        
     public void setStringPrice(String stringPrice) {
     this.basePriceForRender = stringPrice;
     }
        
     public String getStringFixPrice() {
     return fixPriceForRender;
     }
        
     public void setStringFixPrice(String stringFixPrice) {
     this.fixPriceForRender = stringFixPrice;
     }*/

    /*public String getId() {
     return id;
     }*/
    public String getCutLog() {
        return cutLog;
    }

    public void setCutLog(String cutLog) {
        this.cutLog = cutLog;
    }

    public Integer getCutNum() {
        return cutNum;
    }

    public void setCutNum(Integer cutNum) {
        this.cutNum = cutNum;
    }

    public String getCutVal() {
        return cutVal;
    }

    public void setCutVal(String cutVal) {
        this.cutVal = cutVal;
    }

    public boolean isIsCut() {
        return isCut;
    }

    public void setIsCut(boolean isCut) {
        this.isCut = isCut;
    }

    public BigDecimal getaFund1() {
        return aFund1;
    }

    public void setaFund1(BigDecimal aFund1) {
        this.aFund1 = aFund1;
    }

    public BigDecimal getbFund1() {
        return bFund1;
    }

    public void setbFund1(BigDecimal bFund1) {
        this.bFund1 = bFund1;
    }

    public BigDecimal getaFund2() {
        return aFund2;
    }

    public void setaFund2(BigDecimal aFund2) {
        this.aFund2 = aFund2;
    }

    public BigDecimal getbFund2() {
        return bFund2;
    }

    public void setbFund2(BigDecimal bFund2) {
        this.bFund2 = bFund2;
    }

    public BigDecimal getMoneyFound() {
        return moneyFound;
    }

    public void setMoneyFound(BigDecimal moneyFound) {
        this.moneyFound = moneyFound;
    }

    public IdealEntity getIe() {
        return ie;
    }

    public BStrategy1 getB1() {
        return b1;
    }

    public BStrategy2 getB2() {
        return b2;
    }

    public Car getCar() {
        return car;
    }

    private Long getToxicRate(String radCore, String radColor, String radSeq) throws Exception {
        String R1 = radCore.substring(0, 1);
        boolean outOfProfile = containsOutOfProfile(radCore + radColor, radSeq);
        boolean color = containsRad(radColor, radSeq);

        if (radSeq.contains(R1)) {
            String Rs1 = radSeq.substring(0, 1);
            if (Rs1.equals(R1)) {
                if (radSeq.length() > 1) {
                    String Rs2 = radSeq.substring(1, 2);
                    if (radCore.length() > 1) {
                        String R2 = radCore.substring(1, 2);
                        if (Rs2.equals(R2)) {
                            if (outOfProfile) {
                                return (long) 40;
                            } else {
                                if (radColor.length() > 0) {
                                    if (color) {
                                        return (long) 95;
                                    } else {
                                        return (long) 85;
                                    }
                                } else {
                                    return (long) 100;
                                }
                            }
                        } else {
                            if (radCore.contains(Rs2)) {
                                if (outOfProfile) {
                                    return (long) 35;
                                } else {
                                    if (containsOutOfProfile(radCore, radSeq)) {
                                        return (long) 55;
                                    } else {
                                        if (color) {
                                            return (long) 65;
                                        } else {
                                            return (long) 75;
                                        }
                                    }
                                }
                            } else if (radColor.contains(Rs2)) {
                                if (outOfProfile) {
                                    return (long) 10;
                                } else {
                                    if (radSeq.length() > 2) {
                                        String tail = radSeq.substring(2, radSeq.length());
                                        if (containsOutOfProfile(radColor, tail)) {
                                            return (long) 15;
                                        } else {
                                            if (containsRad(radCore, tail)) {
                                                return (long) 20;
                                            } else {
                                                return (long) 25;
                                            }
                                        }
                                    } else {
                                        if (radColor.length() > 1) {
                                            return (long) 15;
                                        } else {
                                            return (long) 25;
                                        }
                                    }
                                }
                            } else {
                                return (long) 1;
                            }
                        }
                    } else {
                        if (radColor.length() > 0) {
                            if (radColor.contains(Rs2)) {
                                if (outOfProfile) {
                                    return (long) 10;
                                } else {
                                    return (long) 95;
                                }
                            } else {
                                return (long) 1;
                            }
                        } else {
                            return (long) 1;
                        }
                    }
                } else {
                    if (radCore.length() > 1) {
                        return (long) 5;
                    } else {
                        return (long) 100;
                    }
                }
            } else {
                String Rs2 = radSeq.substring(1, 2);
                if (Rs2.equals(R1)) {
                    if (radCore.length() > 1) {
                        String R2 = radCore.substring(1, 2);
                        if (Rs1.equals(R2)) {
                            return (long) -15;
                        } else if (radCore.contains(R2)) {
                            return (long) -30;
                        } else if (radColor.contains(R2)) {
                            return (long) -45;
                        }
                    }
                }
            }
        }
        return (long) -100;
    }

    /*private Long getToxicRate(String radCore, String radColor, String strRad) throws Exception {
     //Long rate = (long) -100;
        
     String R1 = radCore.substring(0, 1);
     //Radical rc1 = Radical.getFromString(radCore.substring(0, 1));
     if (strRad != null && !strRad.equals("")) {
     //String strRad = StringAdapter.getString(optRad);
     //Radical optr1 = Radical.getFromString(strRad.substring(0, 1));
     String optR1 = strRad.substring(0, 1);
     if (radCore.contains(optR1)) {
     //suplog+=strRad+"::";
     if (optR1.equals(R1)) {
     //suplog+=" oR1="+optR1+"--";
     if (strRad.length() > 1) {
     String optR2 = strRad.substring(1, 2);
        
     //Radical optr2 = Radical.getFromString(stroptr2);
     if (radCore.length() > 1) {
     //suplog+=" oR2="+optR2+"; +rc>1; ";
     //Radical rc2 = Radical.getFromString(radCore.substring(1, 2));
     String R2 = radCore.substring(1, 2);
     //12=12
     if (optR2.equals(R2)) {
     //suplog+="_!R1R2=oR1oR2!_";
     if (strRad.length() > 2) {
     String stroptr3 = strRad.substring(2, 3);
     if (radCore.length() > 2) {
     if (radCore.contains(stroptr3)) {
     return (long) 100;
     } else {
     if (radColor.contains(stroptr3)) {
     return (long) 95;
     } else {
     return (long) 85;
     }
     }
     } else {
     if (radColor != null && !radColor.equals("")) {
     if (radColor.contains(stroptr3)) {
     //to do ?!
     return (long) 95;
     } else {
     //r1r2 vs or1or2or3+
     //to do ?!
     return (long) 40;
     }
     } else {
     return (long) 40;
     }
     }
     } else {
     //>2 radicala v opt
     if (radCore.length() > 2) {
     return (long) 85;
     } else {
     //r1r2=or1or2
     return (long) 100;
     }
     }
     //12!=12
     } else {
     if (strRad.length() > 2) {
     //to do rework!
     return (long) 35;
     } else {
     if (radCore.contains(optR2)) {
     if (radCore.length() > 3) {
     return (long) 55;
     } else {
     return (long) 75;
     }
     } else if (radColor.contains(optR2)) {
     if (radColor.length() > 1) {
     return (long) 15;
     } else {
     return (long) 25;
     }
     } else {
     return (long) 1;
     }
     }
     }
     } else {
     //suplog+=optr2+"; +rc<1; ";
     if (radColor != null && !radColor.equals("")) {
     if (radColor.contains(optR2)) {
     //to do!! vse ne tak!
     return (long) 10;
     //if()
     } else {
     //to do!! vse ne tak!
     return (long) 1;
     }
     } else {
     //or=12; rc=1;
     //UTO4NIT:!
     return (long) 1;
     }
     }
     } else {
     if (radCore.length() > 1) {
     return (long) 5;
     } else {
     return (long) 100;
     }
     }
     } else {
     //suplog+=optr1+"-+";
     if (strRad.length() > 1) {
     String optR2 = strRad.substring(1, 2);
     if (optR2.equals(R1)) {
     String R2 = radCore.substring(1, 2);
     if (optR1.equals(R2)) {
     return (long) -15;
     } else {
     return (long) -30;
     }
     }
     }
     }
     //return (long) -45;
     }
     }
     return (long) -100;
     }*/
    private boolean containsOutOfProfile(String profileSeq, String radSeq) {
        int i = 0;
        while (i < radSeq.length()) {
            String rad = radSeq.substring(i, i + 1);
            if (!profileSeq.contains(rad)) {
                return true;
            }
            i++;
        }
        return false;
    }

    private boolean containsRad(String radSeq, String radStr) {
        if (radSeq.length() > 0) {
            int i = 0;
            while (i < radSeq.length()) {
                String rad = radSeq.substring(i, i + 1);
                if (radStr.contains(rad)) {
                    return true;
                }
                i++;
            }
            /*for(int i=0;i<=radSeq.length();i++){
             String rad = radSeq.substring(i, i+1);
             if(radStr.contains(rad)){
             return true;
             }
             }*/
        }
        return false;
    }

    private Long getMinToxParam(ToxicParamType tpt) {
        Long res = (long) -100;
        switch (tpt) {
        case NOSTRATEGY:
            return null;
        case MAXTOXIC:
            return (long) -100;
        case MEDTOXIC:
            return (long) -45;
        case MINTOXIC:
            return (long) -30;
        case CLEAR:
            return (long) 1;
        case PURECLEAR:
            return (long) 55;
        case EXTRACLEAR:
            return (long) 85;
        }
        return res;
    }

    private Long getMinToxVal(ToxicValueType tvt) {
        Long res = (long) -100;
        switch (tvt) {
        case NOSTRATEGY:
            return null;
        case MAXTOXIC:
            return (long) -100;
        case MEDTOXIC:
            return (long) -45;
        case MINTOXIC:
            return (long) -30;
        case CLEAR:
            return (long) 1;
        case PURECLEAR:
            return (long) 55;
        case EXTRACLEAR:
            return (long) 85;
        }
        return res;
    }

    private BaseParam getBaseParam(List<BaseParam> bpList, String uid) {
        if (uid != null) {
            for (BaseParam bp : bpList) {
                if (bp.getUid().equals(uid)) {
                    return bp;
                }
            }
        }
        return null;
    }

    /*public List<String> getRadicalList(String radStr) {
     List<String> res = new ArrayList();
     if (radStr != null && !radStr.equals("")) {
     if (radStr.contains(";")) {
     String[] radArr = radStr.split(";");
     for (String rad : radArr) {
     if (!rad.equals("")) {
     res.add(rad.trim());
     }
     }
     } else {
     res.add(radStr.trim());
     }
     }
     return res;
     }*/
    public String getPriceForRender() {
        return RenderSupport.renderDecimal(basePrice);
    }

    public String getFixPriceForRender() {
        return RenderSupport.renderDecimal(fullPrice);
    }

    private void countStaticParamsForLog1() {
        if (!staticProps.isEmpty()) {
            for (String uid : staticProps.keySet()) {
                if (staticProps.get(uid) != null && !staticProps.get(uid).isEmpty()) {
                    EntityProperty epForCount = staticProps.get(uid).get(0);
                    if (PropertyType.STATICBASIS.equals(epForCount.type)) {
                        baseStaticRate1 = baseStaticRate1.add(epForCount.value);
                    } else if (epForCount.price.compareTo(BigDecimal.valueOf(0)) > 0) {
                        payStaticCount1++;
                        staticFund1 = staticFund1.add(epForCount.price);
                        monetaryStaticRate1 = monetaryStaticRate1.add(epForCount.value);
                    } else {
                        freeStaticRate1 = freeStaticRate1.add(epForCount.value);
                    }
                }
            }
            baseStaticRate1Str = RenderSupport.renderDecimalNoPoint(baseStaticRate1);
            freeStaticRate1Str = RenderSupport.renderDecimalNoPoint(freeStaticRate1);
            //staticFund2Str=resStatType.getName()+";"+minParamToxic1+";"+minValueToxic1;
            if (!resStatType.equals(ResourceStaticType.FREEONLY) && minParamToxic1 != null
                    && minValueToxic1 != null) {
                payStaticCount1Str = StringAdapter.getString(payStaticCount1);
                staticFund1Str = RenderSupport.renderDecimalNoPoint(staticFund1);
                monetaryStaticRate1Str = RenderSupport.renderDecimalNoPoint(monetaryStaticRate1);
            }
        }
    }

    private void countStaticParamsForLog2() {
        if (!staticProps.isEmpty()) {
            for (String uid : staticProps.keySet()) {
                if (staticProps.get(uid) != null && !staticProps.get(uid).isEmpty()) {
                    EntityProperty epForCount = staticProps.get(uid).get(0);
                    if (PropertyType.STATICBASIS.equals(epForCount.type)) {
                        baseStaticRate2 = baseStaticRate2.add(epForCount.value);
                    } else if (epForCount.price.compareTo(BigDecimal.valueOf(0)) > 0) {
                        payStaticCount2++;
                        staticFund2 = staticFund2.add(epForCount.price);
                        monetaryStaticRate2 = monetaryStaticRate2.add(epForCount.value);
                    } else {
                        freeStaticRate2 = freeStaticRate2.add(epForCount.value);
                    }
                }
            }
            baseStaticRate2Str = RenderSupport.renderDecimal(baseStaticRate2);
            freeStaticRate2Str = RenderSupport.renderDecimal(freeStaticRate2);
            if (!resStatType.equals(ResourceStaticType.FREEONLY) && minParamToxic2 != null
                    && minValueToxic2 != null) {
                payStaticCount2Str = StringAdapter.getString(payStaticCount2);
                staticFund2Str = RenderSupport.renderDecimal(staticFund2);
                monetaryStaticRate2Str = RenderSupport.renderDecimal(monetaryStaticRate2);
            }
        }
    }

    /*private void loadAllStaticOptions() throws Exception {
     HashMap<String, List<EntityProperty>> statMap = new HashMap();
        
     for (FreeOption fo : car.getFreeOptions()) {
     BaseParam bp = baseParamService.getBaseParam(allParams, fo.getUid());
     if (staticUids.contains(fo.getUid()) && !fo.getRadical().equals("")) {
     List<EntityProperty> supList = statMap.get(fo.getUid());
     if (supList == null) {
     supList = new ArrayList();
     }
     String bestSeq = "";
     Long bestRadVal = (long) -100;
     for (String rad : ConvertSupport.getRadicalList(fo.getRadical())) {
     Long radVal = getToxicRate(radCore, radColor, rad);
     if (radVal.compareTo(bestRadVal) > 0) {
     bestRadVal = radVal;
     bestSeq = rad;
     }
     }
     BigDecimal modalVal = BigDecimal.valueOf(0);
        
     if (Perception.AUDIAL.equals(percType)) {
     modalVal = BigDecimal.valueOf(fo.getAudial());
     } else if (Perception.KINESTETIC.equals(percType)) {
     modalVal = BigDecimal.valueOf(fo.getKinestetic());
     } else if (Perception.VISUAL.equals(percType)) {
     modalVal = BigDecimal.valueOf(fo.getVisual());
     }
        
     supList.add(new EntityProperty(bp.getName(), fo.getTitle(), fo.getUid(), BigDecimal.valueOf(bestRadVal), bestSeq, modalVal, fo.getPrice(), fo.getType()));
     statMap.put(fo.getUid(), supList);
     }
     }
        
     for (Feature fo : car.getFeatures()) {
     BaseParam bp = baseParamService.getBaseParam(allParams, fo.getUid());
     if (staticUids.contains(fo.getUid()) && !fo.getRadical().equals("")) {
     List<EntityProperty> supList = statMap.get(fo.getUid());
     if (supList == null) {
     supList = new ArrayList();
     }
     String bestSeq = "";
     Long bestRadVal = (long) -100;
     for (String rad : ConvertSupport.getRadicalList(fo.getRadical())) {
     Long radVal = getToxicRate(radCore, radColor, rad);
     if (radVal.compareTo(bestRadVal) > 0) {
     bestRadVal = radVal;
     bestSeq = rad;
     }
     }
     BigDecimal modalVal = BigDecimal.valueOf(0);
        
     if (Perception.AUDIAL.equals(percType)) {
     modalVal = BigDecimal.valueOf(fo.getAudial());
     } else if (Perception.KINESTETIC.equals(percType)) {
     modalVal = BigDecimal.valueOf(fo.getKinestet());
     } else if (Perception.VISUAL.equals(percType)) {
     modalVal = BigDecimal.valueOf(fo.getVisual());
     }
        
     supList.add(new EntityProperty(bp.getName(), fo.getTitle(), fo.getUid(), BigDecimal.valueOf(bestRadVal), bestSeq, modalVal, (double) 0, PropertyType.FEATURE));
     statMap.put(fo.getUid(), supList);
     }
     }
        
     for (CarOptionValue cov : car.getCarOptionValues()) {
     CarCompletionOption cco = cov.getCCO();
     BaseParam bp = baseParamService.getBaseParam(allParams, cco.getUid());
     if (staticUids.contains(cco.getUid()) && !cov.getRadical().equals("") && bp != null) {
     List<EntityProperty> supList = statMap.get(cco.getUid());
     if (supList == null) {
     supList = new ArrayList();
     }
     String bestSeq = "";
     Long bestRadVal = (long) -100;
     for (String rad : ConvertSupport.getRadicalList(cov.getRadical())) {
     Long radVal = getToxicRate(radCore, radColor, rad);
     if (radVal.compareTo(bestRadVal) > 0) {
     bestRadVal = radVal;
     bestSeq = rad;
     }
     }
     BigDecimal modalVal = BigDecimal.valueOf(0);
        
     if (Perception.AUDIAL.equals(percType)) {
     modalVal = BigDecimal.valueOf(cov.getAudial());
     } else if (Perception.KINESTETIC.equals(percType)) {
     modalVal = BigDecimal.valueOf(cov.getKinestet());
     } else if (Perception.VISUAL.equals(percType)) {
     modalVal = BigDecimal.valueOf(cov.getVisual());
     }
        
     supList.add(new EntityProperty(bp.getName(), cov.getTitle(), cco.getUid(), BigDecimal.valueOf(bestRadVal), bestSeq, modalVal, cov.getPrice(), PropertyType.OPTION));
     statMap.put(cco.getUid(), supList);
     }
     }
     }*/
    private void countFirstDinamicParamsForLog() {
        for (String uid : aprops.keySet()) {
            if (!aprops.get(uid).getActiveProperty().isEmpty()) {
                aCount1++;
                aFund1 = aFund1.add(aprops.get(uid).price);
                //aFund1.add(aprops.get(uid).activeProperty.get(0).price);
            }
        }
        for (String uid : bprops.keySet()) {
            if (!bprops.get(uid).getActiveProperty().isEmpty()) {
                bCount1++;
                bFund1 = bFund1.add(bprops.get(uid).price);
                //bFund1.add(bprops.get(uid).activeProperty.get(0).price);
            }
        }
    }

    private void countSecondDinamicParamsForLog() {
        for (String uid : aprops.keySet()) {
            if (!aprops.get(uid).getActiveProperty().isEmpty()) {
                aCount2++;
                aFund2 = aFund2.add(aprops.get(uid).price);
                //aFund2.add(aprops.get(uid).activeProperty.get(0).price);
            }
        }
        for (String uid : bprops.keySet()) {
            if (!bprops.get(uid).getActiveProperty().isEmpty()) {
                bCount2++;
                bFund2 = bFund2.add(bprops.get(uid).price);
                //bFund2.add(bprops.get(uid).activeProperty.get(0).price);
            }
        }
    }

}