Package it.eng.spagobi.tools.udp.metadata

Examples of it.eng.spagobi.tools.udp.metadata.SbiUdpValue


  }

  @SuppressWarnings("unchecked")
  public SbiUdpValue findById(Integer id) {
    logger.debug("IN");
    SbiUdpValue propValue = null;
    Session session = getSession();
    Transaction tx = null;
    try {
      tx = session.beginTransaction();
      propValue = (SbiUdpValue)session.get(SbiUdpValue.class, id);
View Full Code Here


      " order by s.label asc";
      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

    Session session = getSession();
    UdpValue udpValue = null;
    Transaction tx = null;
    try {
      tx = session.beginTransaction();
      SbiUdpValue prop = (SbiUdpValue)session.get(SbiUdpValue.class, id);
      tx.commit();
      udpValue=toUdpValue(prop);

    } catch (HibernateException e) {
      if( tx != null && tx.isActive() ){
View Full Code Here

      criteria.add(labelCriterrion3)
      // take not closed ones!
      Criterion labelCriterrion4 = Expression.isNull("endTs");
      criteria.add(labelCriterrion4)

      SbiUdpValue hibValueUDP = (SbiUdpValue) criteria.uniqueResult();
      if (hibValueUDP == null) return null;
      toReturn = toUdpValue(hibValueUDP);       

      //tx.commit();
View Full Code Here

        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());
View Full Code Here

   *
   * @return the new hibernate parameter object
   */
  public static SbiUdpValue makeNewSbiUdpValue(SbiUdpValue udpValue ,Session sessionCurrDB, MetadataAssociations metaAss, ImporterMetadata importer){
    logger.debug("IN");
    SbiUdpValue newUdpValue = new SbiUdpValue();
    try{
      newUdpValue.setBeginTs(udpValue.getBeginTs());
      newUdpValue.setEndTs(udpValue.getEndTs());
      newUdpValue.setFamily(udpValue.getFamily());
      newUdpValue.setLabel(udpValue.getLabel());
      newUdpValue.setName(udpValue.getName());
      newUdpValue.setProg(udpValue.getProg());
      newUdpValue.setFamily(udpValue.getFamily());
      newUdpValue.setValue(udpValue.getValue());
      // associations
      entitiesAssociationsSbiUdpValue(udpValue, newUdpValue, sessionCurrDB, metaAss, importer);

      logger.debug("OUT");
    }
    catch (Exception e) {
      logger.error("Error in creating new udp value with exported id " + newUdpValue.getUdpValueId());     
    }
    return newUdpValue;
  }
View Full Code Here

   *
   * @throws EMFUserError the EMF user error
   */
  public static SbiUdpValue modifyExistingSbiUdpValue(SbiUdpValue exportedUdpValue, Session sessionCurrDB, Integer existingUdpValueId) throws EMFUserError {
    logger.debug("IN");
    SbiUdpValue existingSbiUdpValue = null;
    try {
      existingSbiUdpValue = (SbiUdpValue) sessionCurrDB.load(SbiUdpValue.class, existingUdpValueId);
      existingSbiUdpValue.setBeginTs(exportedUdpValue.getBeginTs());
      existingSbiUdpValue.setEndTs(exportedUdpValue.getEndTs());
      existingSbiUdpValue.setFamily(exportedUdpValue.getFamily());
      existingSbiUdpValue.setLabel(exportedUdpValue.getLabel());
      existingSbiUdpValue.setName(exportedUdpValue.getName());
      existingSbiUdpValue.setProg(exportedUdpValue.getProg());
      existingSbiUdpValue.setFamily(exportedUdpValue.getFamily());
      existingSbiUdpValue.setValue(exportedUdpValue.getValue());
    }

    finally {
      logger.debug("OUT");
    }
View Full Code Here

      }

      SbiUdp udp =(SbiUdp)session.load(SbiUdp.class, udpValue.getUdpId());

      // main attributes     
      SbiUdpValue hibUdpValue = new SbiUdpValue();
      hibUdpValue.setBeginTs(udpValue.getBeginTs());
      hibUdpValue.setEndTs(udpValue.getEndTs());
      hibUdpValue.setFamily(udpValue.getFamily());
      hibUdpValue.setLabel(udpValue.getLabel());
      hibUdpValue.setName(udpValue.getName());
      hibUdpValue.setProg(udpValue.getProg());
      hibUdpValue.setReferenceId(udpValue.getReferenceId());
      hibUdpValue.setSbiUdp(udp);
      hibUdpValue.setUdpValueId(udpValue.getUdpValueId());
      hibUdpValue.setValue(udpValue.getValue());

      Transaction tx = session.beginTransaction();     
      session.save(hibUdpValue);
      tx.commit();
    } catch (Exception e) {
View Full Code Here

      Integer udpId = (Integer) uniqueMap.get("udpId");
      Integer referenceId = (Integer) uniqueMap.get("referenceId");
      hql = "from SbiUdpValue u where u.sbiUdp.udpId = " + udpId + " and u.referenceId ="+referenceId +" and u.family ='"+family+"'";
      hqlQuery = sessionCurrDB.createQuery(hql);
      List<SbiUdpValue> udpValues = (List<SbiUdpValue>)hqlQuery.list();
      SbiUdpValue hibUdpVal = null;
      //TODO to control why there is a list of udpValues and not only one
      if(udpValues!=null && !udpValues.isEmpty()){
        hibUdpVal = udpValues.get(0);
      }
      return hibUdpVal;   
View Full Code Here

     
      List exportedUdpValue = (List<SbiUdpValue>) hibQuery.list();
      Iterator iterSbiUdpValue = exportedUdpValue.iterator();

      while (iterSbiUdpValue.hasNext()) {
        SbiUdpValue udpvalue = (SbiUdpValue) iterSbiUdpValue.next();
        Integer oldId = udpvalue.getUdpValueId();
        //import udp first
        importUdp(udpvalue.getSbiUdp().getUdpId(), overwrite);
       
        //then udp values

        Map assUdpValue = metaAss.getUdpValueAssociation();
        Integer existingUdpValueId = null;
        Set assUdpValueSet = assUdpValue.keySet();
        if (assUdpValueSet.contains(oldId) && !overwrite) {
          metaLog.log("Exported association udp value with udp with label " + udpvalue.getSbiUdp().getLabel() + " "
              + " and family " + udpvalue.getFamily() + " with reference id "
              +  udpvalue.getReferenceId() + " not inserted"
              + " because already existing into the current database");
          continue;
        } else {
          existingUdpValueId = (Integer) assUdpValue.get(oldId);
        }
        if (existingUdpValueId != null) {

          metaLog.log("The udp value with udp with label " + udpvalue.getSbiUdp().getLabel() + " "
              + " and family " + udpvalue.getFamily() + " with reference id "
              +  udpvalue.getReferenceId()+ "] will be updated.");
          SbiUdpValue existingUdpValue = ImportUtilities.modifyExistingSbiUdpValue(udpvalue, sessionCurrDB, existingUdpValueId);
          ImportUtilities.entitiesAssociationsSbiUdpValue(udpvalue, existingUdpValue, sessionCurrDB, metaAss, importer);
          sessionCurrDB.update(existingUdpValue);
        } else {
          SbiUdpValue newUdpValue = ImportUtilities.makeNewSbiUdpValue(udpvalue, sessionCurrDB, metaAss, importer);
          sessionCurrDB.save(newUdpValue);
          metaLog.log("The udp value with udp with label " + udpvalue.getSbiUdp().getLabel() + " "
              + " and family " + udpvalue.getFamily() + " with reference id "
              +  udpvalue.getReferenceId()+" is inserted");
          Integer newId = newUdpValue.getUdpValueId();
          sessionExpDB.evict(udpvalue);
          metaAss.insertCoupleUdpValueAssociation(udpvalue.getUdpValueId(), newId);
        }

      }
View Full Code Here

TOP

Related Classes of it.eng.spagobi.tools.udp.metadata.SbiUdpValue

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.