Package it.eng.spagobi.tools.udp.bo

Examples of it.eng.spagobi.tools.udp.bo.UdpValue


      Query hqlQuery = aSession.createQuery(hql);
      hqlQuery.setInteger(0, kpiId);
      List toConvert = hqlQuery.list();
      for (Iterator iterator = toConvert.iterator(); iterator.hasNext();) {
        SbiUdpValue sbiUdpValue = (SbiUdpValue) iterator.next();
        UdpValue udpValue = toUdpValue(sbiUdpValue);
        if(toReturn == null) toReturn = new ArrayList<UdpValue>();
        toReturn.add(udpValue);
      }

View Full Code Here


   */

  public UdpValue loadById(Integer id) {
    logger.debug("IN");
    Session session = getSession();
    UdpValue udpValue = null;
    Transaction tx = null;
    try {
      tx = session.beginTransaction();
      SbiUdpValue prop = (SbiUdpValue)session.get(SbiUdpValue.class, id);
      tx.commit();
View Full Code Here

   *  Load a UdpValue by refrence Id, udpId, family
   */

  public UdpValue loadByReferenceIdAndUdpId(Integer referenceId, Integer udpId, String family) {
    logger.debug("IN");
    UdpValue toReturn = null;
    Session tmpSession = getSession();
    Transaction tx = null;
    try {
      tx = tmpSession.beginTransaction();
      Criterion labelCriterrion = Expression.eq("referenceId", referenceId);
View Full Code Here

 


  public UdpValue toUdpValue(SbiUdpValue sbiUdpValue){
    logger.debug("IN");
    UdpValue toReturn=new UdpValue();

    toReturn.setUdpValueId(sbiUdpValue.getUdpValueId());
    toReturn.setUdpId(sbiUdpValue.getSbiUdp().getUdpId());
    toReturn.setReferenceId(sbiUdpValue.getReferenceId());
    toReturn.setLabel(sbiUdpValue.getSbiUdp().getLabel()); //denormilized
    toReturn.setName(sbiUdpValue.getSbiUdp().getName())//denormilized   

    try{
      IDomainDAO aDomainDAO = DAOFactory.getDomainDAO();
      Domain familyDomain = aDomainDAO.loadDomainById(sbiUdpValue.getSbiUdp().getFamilyId());
      toReturn.setFamily(familyDomain.getValueCd()); //denormilized
    } catch (Exception he) {
      logger.error(he);
    }

    Integer typeId = sbiUdpValue.getSbiUdp().getTypeId();
    if(typeId != null){
      try{
        IDomainDAO aDomainDAO = DAOFactory.getDomainDAO();
        Domain typeDomain = aDomainDAO.loadDomainById(typeId);
        toReturn.setTypeLabel(typeDomain.getValueCd()); //denormilized
      } catch (Exception he) {
        logger.error(he);
      }
    }


    toReturn.setValue(sbiUdpValue.getValue());
    toReturn.setProg(sbiUdpValue.getProg());
    toReturn.setBeginTs(sbiUdpValue.getBeginTs());
    toReturn.setEndTs(sbiUdpValue.getEndTs());

    logger.debug("OUT");
    return toReturn;
  }
View Full Code Here

    }   
    if(udpValues != null){
      // an udp value is never erased for a kpi once memorized, that is because by user interface integer have no null value and boolean too
      // these are current UdpValues; for each:
      for (Iterator iterator = udpValues.iterator(); iterator.hasNext();) {
        UdpValue udpValue = (UdpValue) iterator.next();
        // the tow ids of relationship; Kpi / Model and Udp       
        Integer udpId = udpValue.getUdpId();

        // search if KpiValue is already present, in that case update otherwise insert
        SbiUdpValue sbiUdpValue  = null;
        SbiUdpValue sbiUdpValueToClose  = null;

        UdpValue already = DAOFactory.getUdpDAOValue().loadByReferenceIdAndUdpId(idObject, udpValue.getUdpId(), family.toUpperCase());           
        boolean inserting = true;
        boolean openNewOne = true;

        if(already == null){
          sbiUdpValue = new SbiUdpValue();         
        }
        else{
          inserting = false;
          // check if value has changed, if not so don't open a new one
          SbiUdpValue sbiUdpValueRetrieved = (SbiUdpValue) aSession.load(SbiUdpValue.class,already.getUdpValueId());                       

          if(udpValue.getValue() != null &&  udpValue.getValue().equals(already.getValue())){
            // same value as before, simple update
            openNewOne = false;
            sbiUdpValue = sbiUdpValueRetrieved;
          }
          else{
            // new value, close preceding open a new one
            sbiUdpValueToClose = sbiUdpValueRetrieved;
            sbiUdpValue = new SbiUdpValue();
          }
        }

        // fill SbiUdpValue values
        sbiUdpValue.setLabel(udpValue.getLabel());
        sbiUdpValue.setName(udpValue.getName());
        sbiUdpValue.setProg(udpValue.getProg());
        sbiUdpValue.setFamily(udpValue.getFamily());

        sbiUdpValue.setReferenceId(idObject);
        SbiUdp hibUdp = (SbiUdp) aSession.load(SbiUdp.class,
            udpId);
        sbiUdpValue.setSbiUdp(hibUdp);
        sbiUdpValue.setValue(udpValue.getValue());

        if(inserting){
          logger.debug("Inserting Udp association between udp "+udpValue.getLabel() + " referencing family " + udpValue.getFamily() +
              " with id "+ udpValue.getReferenceId() + "with value "+sbiUdpValue.getValue());
          sbiUdpValue.setBeginTs(new Date());
          DAOFactory.getUdpDAOValue().insert(aSession, sbiUdpValue);         
          logger.debug("value to Udp "+hibUdp.getLabel()+ " has been inserted");
        }
        else{
          // the update must close the previous record and open a new one, but only if value has changed
          if(openNewOne){
            logger.debug("Close previous udp value and open Udp association between udp "+udpValue.getLabel() + " referencing family " + udpValue.getFamily() +
                " with id "+ udpValue.getReferenceId() + "with value "+sbiUdpValue.getValue());
            // close previous one
            sbiUdpValueToClose.setBeginTs(already.getBeginTs());
            sbiUdpValueToClose.setEndTs(new Date());
            DAOFactory.getUdpDAOValue().update(aSession, sbiUdpValueToClose);
            // insert new one
            sbiUdpValue.setBeginTs(new Date());
            DAOFactory.getUdpDAOValue().insert(aSession, sbiUdpValue);
          }
          else{
            logger.debug("Update without closing Udp association between udp "+udpValue.getLabel() + " referencing family " + udpValue.getFamily() +
                " with id "+ udpValue.getReferenceId() + "with value "+sbiUdpValue.getValue());           
            // just update fields no new opening
            sbiUdpValue.setBeginTs(already.getBeginTs());
            DAOFactory.getUdpDAOValue().update(aSession, sbiUdpValue);           
          }

          logger.debug("value to Udp "+hibUdp.getLabel()+ " has been updated; associated to a "+family);
        }
View Full Code Here

            JSONObject obj = (JSONObject)udpValuesArrayJSon.get(i);
            // only label and value information are retrieved by JSON object
            String label = obj.getString("name")
            String value = obj.getString("value")

            UdpValue udpValue = new UdpValue();

            // reference id is the kpi id
            Integer kpiId = k.getKpiId();

            //udpValue.setLabel(label);
            udpValue.setValue(value);
            udpValue.setReferenceId(kpiId);

            // get the UDP to get ID (otherwise could be taken in js page)
            Udp udp = DAOFactory.getUdpDAO().loadByLabelAndFamily(label, "KPI");
            Domain familyDomain = DAOFactory.getDomainDAO().loadDomainById(udp.getFamilyId());

            Integer idUdp = udp.getUdpId();

            udpValue.setLabel(udp.getLabel());
            udpValue.setName(udp.getName());
            udpValue.setFamily(familyDomain != null ? familyDomain.getValueCd() : null);
            udpValue.setUdpId(udp.getUdpId());

            udpValues.add(udpValue);
          }

          k.setUdpValues(udpValues);
View Full Code Here

      //manage insert of udp values

      List udpValues = DAOFactory.getUdpDAOValue().findByReferenceId(mod.getId(), "Model");
      if(udpValues != null && !udpValues.isEmpty()){
        for (Iterator iterator = udpValues.iterator(); iterator.hasNext();) {
          UdpValue udpValue = (UdpValue) iterator.next();
          insertUdpValue(udpValue, session);

        }
      }
View Full Code Here

      //manage insert of udp values

      List udpValues = DAOFactory.getUdpDAOValue().findByReferenceId(kpiId, "Kpi");
      if(udpValues != null && !udpValues.isEmpty()){
        for (Iterator iterator = udpValues.iterator(); iterator.hasNext();) {
          UdpValue udpValue = (UdpValue) iterator.next();
          insertUdpValue(udpValue, session);

        }
      }
    } catch (Exception e) {
View Full Code Here

      //manage insert of udp values

      List udpValues = DAOFactory.getUdpDAOValue().findByReferenceId(kpiId, "KPI");
      if(udpValues != null && !udpValues.isEmpty()){
        for (Iterator iterator = udpValues.iterator(); iterator.hasNext();) {
          UdpValue udpValue = (UdpValue) iterator.next();
          insertUdpValue(udpValue, session);

        }
      }
    } catch (Exception e) {
View Full Code Here

      JSONArray udpValuesJSON = new JSONArray();

      if(udpValues != null){
        Iterator itUdpValues = udpValues.iterator();
        while(itUdpValues.hasNext()){
          UdpValue udpValue = (UdpValue)itUdpValues.next();
          if(udpValue != null){
            JSONObject jsonVal = new JSONObject();
            //jsonVal.put("family", udpValue.getFamily());
            jsonVal.put("label", udpValue.getLabel());
            jsonVal.put("value", udpValue.getValue());
            jsonVal.put("family", udpValue.getFamily());
            jsonVal.put("type", udpValue.getTypeLabel());
            udpValuesJSON.put(jsonVal);
          }       
        } 
      }
      result.put(UDP_VALUES, udpValuesJSON);
View Full Code Here

TOP

Related Classes of it.eng.spagobi.tools.udp.bo.UdpValue

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