Examples of SbiKpiRel


Examples of it.eng.spagobi.kpi.config.metadata.SbiKpiRel

      Query hibQuery = session.createQuery(" from SbiKpiRel where kpiRelId = " + kpiRel.getKpiRelId());
      List hibList = hibQuery.list();
      if(!hibList.isEmpty()) {
        return;
      }
      SbiKpiRel hibRel = new SbiKpiRel();
      SbiKpi kpiChild=(SbiKpi)session.load(SbiKpi.class, kpiRel.getKpiChildId());

      try {
        kpiChild.getKpiId();
        logger.error("kpi child id= "+kpiChild.getKpiId());

        hibRel.setSbiKpiByKpiChildId(kpiChild);
        logger.error("set in try__ok: kpi child saved before");
      }catch(Throwable t){
        logger.error("set in try__ok: kpi child didn't exist");
      }

      SbiKpi kpiFather=(SbiKpi)session.load(SbiKpi.class, kpiRel.getKpiFatherId());

      // main attributes     

      hibRel.setParameter(kpiRel.getParameter());     
      hibRel.setSbiKpiByKpiFatherId(kpiFather);
      hibRel.setKpiRelId(kpiRel.getKpiRelId());
      Transaction tx = session.beginTransaction();
      session.save(hibRel);
      logger.error("saved rel");
      tx.commit();
View Full Code Here

Examples of it.eng.spagobi.kpi.config.metadata.SbiKpiRel

      Integer childId = (Integer) uniqueMap.get("childId");
      String parameter = (String) uniqueMap.get("parameter");
      hql = "from SbiKpiRel kr where kr.sbiKpiByKpiChildId.kpiId=" + childId + " and kr.sbiKpiByKpiFatherId.kpiId = " + fatherId
      + " and kr.parameter = '" + parameter+ "'";
      hqlQuery = sessionCurrDB.createQuery(hql);
      SbiKpiRel hibKpiRel = null;
      try{
        hibKpiRel = (SbiKpiRel) hqlQuery.uniqueResult();
      }
      catch (Exception e) {
        throw new EMFUserError(EMFErrorSeverity.ERROR, "9010", "component_impexp_messages");
View Full Code Here

Examples of it.eng.spagobi.kpi.config.metadata.SbiKpiRel

   *
   * @return the new hibernate parameter object
   */
  public static SbiKpiRel makeNewSbiKpiRel(SbiKpiRel kpirel,Session sessionCurrDB, MetadataAssociations metaAss, ImporterMetadata importer){
    logger.debug("IN");
    SbiKpiRel newSbiKpiRel = new SbiKpiRel();
    try{
      newSbiKpiRel.setParameter(kpirel.getParameter());

      // associations
      entitiesAssociationsSbiKpiRel(kpirel, newSbiKpiRel, sessionCurrDB, metaAss, importer);

      logger.debug("OUT");
    }
    catch (Exception e) {
      logger.error("Error in creating new kpi relation with exported id " + newSbiKpiRel.getKpiRelId());     
    }
    return newSbiKpiRel;
  }
View Full Code Here

Examples of it.eng.spagobi.kpi.config.metadata.SbiKpiRel

   *
   * @throws EMFUserError the EMF user error
   */
  public static SbiKpiRel modifyExistingKpiRel(SbiKpiRel exportedKpiRel, Session sessionCurrDB, Integer existingKpiRelId) throws EMFUserError {
    logger.debug("IN");
    SbiKpiRel existingKpiRel = null;
    try {
      existingKpiRel = (SbiKpiRel) sessionCurrDB.load(KpiRel.class, existingKpiRelId);
      existingKpiRel.setParameter(exportedKpiRel.getParameter());

    }

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

Examples of it.eng.spagobi.kpi.config.metadata.SbiKpiRel

    Transaction tx = null;
    try {
      aSession = getSession();
      tx = aSession.beginTransaction();

      SbiKpiRel kpiRelation = new SbiKpiRel();

      SbiKpi parentKpi = (SbiKpi)aSession.load(SbiKpi.class, kpiParentId);
      SbiKpi childKpi = (SbiKpi)aSession.load(SbiKpi.class, kpiChildId);

      kpiRelation.setParameter(parameter);
      kpiRelation.setSbiKpiByKpiChildId(childKpi);
      kpiRelation.setSbiKpiByKpiFatherId(parentKpi);

      idToReturn = (Integer)aSession.save(kpiRelation);

      tx.commit();
View Full Code Here

Examples of it.eng.spagobi.kpi.config.metadata.SbiKpiRel

      Query q = aSession.createQuery(query);
      q.setInteger("parentId", kpiParentId);
      List toTransform =  q.list();

      for (Iterator iterator = toTransform.iterator(); iterator.hasNext();) {
        SbiKpiRel sbiKpiRel = (SbiKpiRel) iterator.next();
        KpiRel rel = toKpiRel(sbiKpiRel);
        toReturn.add(rel);
      }

    } catch (HibernateException he) {
View Full Code Here

Examples of it.eng.spagobi.kpi.config.metadata.SbiKpiRel

  public boolean deleteKpiRel(Integer kpiRelId) throws EMFUserError {
    Session aSession = getSession();
    Transaction tx = null;
    try {
      tx = aSession.beginTransaction();
      SbiKpiRel akpirel = (SbiKpiRel) aSession.load(SbiKpiRel.class, kpiRelId);

      aSession.delete(akpirel);
      tx.commit();

    } catch (ConstraintViolationException cve) {
View Full Code Here

Examples of it.eng.spagobi.kpi.config.metadata.SbiKpiRel

    }
    // Kpi Relations
    List exportedKpiRelList = importer.getAllExportedSbiObjects(sessionExpDB, "SbiKpiRel", null);
    Iterator iterKpiRel = exportedKpiRelList.iterator();
    while (iterKpiRel.hasNext()) {
      SbiKpiRel kpirel = (SbiKpiRel) iterKpiRel.next();
      // check if the association already exist
      Map uniqueMap = new HashMap();
      Map kpiAss = metaAss.getKpiIDAssociation();
      if(kpirel.getSbiKpiByKpiFatherId() != null){
        Integer newFatherId = (Integer)kpiAss.get(kpirel.getSbiKpiByKpiFatherId().getKpiId());
        uniqueMap.put("fatherId", newFatherId);
        if(kpirel.getSbiKpiByKpiChildId()!= null){
          Integer newChildId = (Integer)kpiAss.get(kpirel.getSbiKpiByKpiChildId().getKpiId());
          uniqueMap.put("childId", newChildId);
          uniqueMap.put("parameter", kpirel.getParameter());
        }
      }
      Object existObj = importer.checkExistence(uniqueMap, sessionCurrDB, new SbiKpiRel());
      if (existObj != null) {
        SbiKpiRel dsCurr = (SbiKpiRel) existObj;
        metaAss.insertCoupleKpiRelAssociation(kpirel.getKpiRelId(), dsCurr.getKpiRelId());
        metaLog.log("Found an existing kpi Relation");
      }
    }
    // Udp

    List exportedUdpList = importer.getAllExportedSbiObjects(sessionExpDB, "SbiUdp", null);
    Iterator iterUdp = exportedUdpList.iterator();
    while (iterUdp.hasNext()) {
      SbiUdp udp = (SbiUdp) iterUdp.next();

      //logical unique key but table just looks for label
/*      Map uniqueMap = new HashMap();
      Map doaminAss = metaAss.getDomainIDAssociation();
      Integer newTypeId = (Integer)doaminAss.get(udp.getTypeId());
      uniqueMap.put("typeId", newTypeId);
      Integer newFamilyId = (Integer)doaminAss.get(udp.getFamilyId());
      uniqueMap.put("familyId", newFamilyId);
      uniqueMap.put("label", udp.getLabel());
      Object existObj = importer.checkExistence(uniqueMap, sessionCurrDB, new SbiUdp());*/
      String label = udp.getLabel();
      Object existObj = importer.checkExistence(label, sessionCurrDB, new SbiUdp());
      if (existObj != null) {
        SbiUdp dsCurr = (SbiUdp) existObj;
        metaAss.insertCoupleUdpAssociation(udp.getUdpId(), dsCurr.getUdpId());
        metaLog.log("Exported association between type id " + udp.getTypeId() + " "
            + " and family id " + udp.getFamilyId() + " with label "
            + udp.getLabel() + " not inserted"
            + " because already existing into the current database");
      }
    }
    // Udp Value

    List exportedUdpValList = importer.getAllExportedSbiObjects(sessionExpDB, "SbiUdpValue", null);
    Iterator iterUdpVal = exportedUdpValList.iterator();
    while (iterUdpVal.hasNext()) {
      SbiUdpValue udpVal = (SbiUdpValue) iterUdpVal.next();
      // check if the association already exist
      Map uniqueMap = new HashMap();
      Map kpiAss = metaAss.getKpiIDAssociation();
      Map modelAss = metaAss.getModelIDAssociation();
      Map udpAss = metaAss.getUdpAssociation();
     
      if(udpVal.getSbiUdp() != null){
        Integer newUdpId = (Integer)udpAss.get(udpVal.getSbiUdp().getUdpId());
        uniqueMap.put("udpId", newUdpId);
        Integer newRefId = null;
        if(udpVal.getFamily().equalsIgnoreCase("Kpi")){
          newRefId = (Integer)kpiAss.get(udpVal.getReferenceId());
        }else{
          newRefId = (Integer)modelAss.get(udpVal.getReferenceId());
        }
        uniqueMap.put("referenceId", newRefId);
        uniqueMap.put("family", udpVal.getFamily());
      }
 
      Object existObj = importer.checkExistence(uniqueMap, sessionCurrDB, new SbiUdpValue());
      if (existObj != null) {
        SbiUdpValue dsCurr = (SbiUdpValue) existObj;
        metaAss.insertCoupleUdpValueAssociation(udpVal.getUdpValueId(), dsCurr.getUdpValueId());
        metaLog.log("Exported association udp value between udp with label " + udpVal.getSbiUdp().getLabel() + " "
            + " and family " + udpVal.getFamily() + " with reference id "
            +  udpVal.getReferenceId() + " not inserted"
            + " because already existing into the current database");
      }
    }
    // OU  SbiOrgUnit
    List exportedSbiOrgUnitList = importer.getAllExportedSbiObjects(sessionExpDB, "SbiOrgUnit", null);
    Iterator iterOUVal = exportedSbiOrgUnitList.iterator();
    while (iterOUVal.hasNext()) {
      SbiOrgUnit ouVal = (SbiOrgUnit) iterOUVal.next();
      Map uniqueMap = new HashMap();
      String label = ouVal.getLabel();
      String name = ouVal.getName();
      uniqueMap.put("label", label);
      uniqueMap.put("name", name);
      Object existObj = importer.checkExistence(uniqueMap, sessionCurrDB, new SbiOrgUnit());
      if (existObj != null) {
        SbiOrgUnit dsCurr = (SbiOrgUnit) existObj;
        metaAss.insertCoupleIdOuAssociation(ouVal.getId(), dsCurr.getId());
        metaLog.log("Found an existing ou " + dsCurr.getName() + " with "
            + "the same label of one exported ou");
      }
    }// OU hierarchy SbiOrgUnitHierarchies
    List exportedSbiOuHierList = importer.getAllExportedSbiObjects(sessionExpDB, "SbiOrgUnitHierarchies", null);
    Iterator iterOUHierVal = exportedSbiOuHierList.iterator();
    while (iterOUHierVal.hasNext()) {
      SbiOrgUnitHierarchies ouHierVal = (SbiOrgUnitHierarchies) iterOUHierVal.next();
      // check if the association already exist
      Map uniqueMap = new HashMap();
      String label = ouHierVal.getLabel();
      String company = ouHierVal.getCompany();
      uniqueMap.put("label", label);
      uniqueMap.put("company", company);
      Object existObj = importer.checkExistence(uniqueMap, sessionCurrDB, new SbiOrgUnitHierarchies());
      if (existObj != null) {
        SbiOrgUnitHierarchies dsCurr = (SbiOrgUnitHierarchies) existObj;
        metaAss.insertCoupleIdOuHierarchyAssociation(ouHierVal.getId(), dsCurr.getId());
        metaLog.log("Found an existing ou hierarchy " + dsCurr.getName() + " with "
            + "the same label of one exported ou hierarchy");
      }
      /*
      String label = ouHierVal.getLabel();
      Object existObj = importer.checkExistence(label, sessionCurrDB, new SbiOrgUnitHierarchies());
      if (existObj != null) {
        SbiOrgUnitHierarchies dsCurr = (SbiOrgUnitHierarchies) existObj;
        metaAss.insertCoupleIdOuHierarchyAssociation(ouHierVal.getId(), dsCurr.getId());
        metaLog.log("Found an existing ou hierarchy " + dsCurr.getName() + " with "
            + "the same label of one exported ou hierarchy");
      }
      */
    }// OU node  SbiOrgUnitNodes
    List exportedSbiOrgUnitNodeList = importer.getAllExportedSbiObjects(sessionExpDB, "SbiOrgUnitNodes", null);
    Iterator iterOUNodeVal = exportedSbiOrgUnitNodeList.iterator();
    while (iterOUNodeVal.hasNext()) {
      SbiOrgUnitNodes ouVal = (SbiOrgUnitNodes) iterOUNodeVal.next();
      // check if the association already exist
      Map uniqueMap = new HashMap();
      Map ouAss = metaAss.getOuAssociation();
      Map hierAss = metaAss.getOuHierarchiesAssociation();
      if(ouVal.getSbiOrgUnit() != null){
        Integer newOuId = (Integer)ouAss.get(ouVal.getSbiOrgUnit().getId());
        uniqueMap.put("ouId", newOuId);
        Integer newHierId = (Integer)hierAss.get(ouVal.getSbiOrgUnitHierarchies().getId());
        uniqueMap.put("hierarchyId", newHierId);
      }
      Object existObj = importer.checkExistence(uniqueMap, sessionCurrDB, new SbiOrgUnitNodes());
      if (existObj != null) {
        SbiOrgUnitNodes dsCurr = (SbiOrgUnitNodes) existObj;
        metaAss.insertCoupleIdOuNodeAssociation(ouVal.getNodeId(), dsCurr.getNodeId());
        metaLog.log("Found an existing ou node " + dsCurr.getNodeId() + " with "
            + "the same organizational unit and hierarchy of one exported ou node");
      }
    }// OU grants  SbiOrgUnitGrant
    List exportedSbiOUGrantList = importer.getAllExportedSbiObjects(sessionExpDB, "SbiOrgUnitGrant", null);
    Iterator iterOUGrantVal = exportedSbiOUGrantList.iterator();
    while (iterOUGrantVal.hasNext()) {
      SbiOrgUnitGrant ouGrantVal = (SbiOrgUnitGrant) iterOUGrantVal.next();
      String label = ouGrantVal.getLabel();
      Object existObj = importer.checkExistence(label, sessionCurrDB, new SbiOrgUnitGrant());
      if (existObj != null) {
        SbiOrgUnitGrant dsCurr = (SbiOrgUnitGrant) existObj;
        metaAss.insertCoupleIdOuGrantAssociation(ouGrantVal.getId(), dsCurr.getId());
        metaLog.log("Found an existing ou grant " + dsCurr.getId() + " with "
            + "the same label of one exported ou grant");
      }
    }// OU grant nodes  SbiOrgUnitGrantNodes
    List exportedSbiOUGrantNodeList = importer.getAllExportedSbiObjects(sessionExpDB, "SbiOrgUnitGrantNodes", null);
    Iterator iterOUGrantNodesVal = exportedSbiOUGrantNodeList.iterator();
    while (iterOUGrantNodesVal.hasNext()) {
      SbiOrgUnitGrantNodes ouGrantNode = (SbiOrgUnitGrantNodes) iterOUGrantNodesVal.next();
      Map uniqueMap = new HashMap();   
      Map nodeAss = metaAss.getOuNodeAssociation();
      Map miAss = metaAss.getModelInstanceIDAssociation();
      Map grantAss = metaAss.getOuGrantAssociation();
      if(ouGrantNode.getId() != null){
        Integer newGrantId = (Integer)grantAss.get(ouGrantNode.getId().getGrantId());
        uniqueMap.put("grantId", newGrantId );
        Integer newNodeId = (Integer)nodeAss.get(ouGrantNode.getId().getNodeId());
        uniqueMap.put("nodeId", newNodeId);
        Integer newMiId = (Integer)miAss.get(ouGrantNode.getId().getKpiModelInstNodeId());
        uniqueMap.put("modelInstId", newMiId);
      }
      Object existObj = importer.checkExistence(uniqueMap, sessionCurrDB, new SbiOrgUnitGrantNodes());
      if (existObj != null) {
        SbiOrgUnitGrantNodes dsCurr = (SbiOrgUnitGrantNodes) existObj;
        metaAss.insertCoupleIdOuGrantNodesAssociation(ouGrantNode.getId(), dsCurr.getId());
        metaLog.log("Found an existing ou grant node with grant id " + dsCurr.getId().getGrantId() + " with "
            + "the same id of one exported ou grant node");
      }
    }
    logger.debug("OUT");
  }
View Full Code Here

Examples of it.eng.spagobi.kpi.config.metadata.SbiKpiRel

      List exportedKpiRel = importer.getFilteredExportedSbiObjects(sessionExpDB, "SbiKpiRel", "sbiKpiByKpiFatherId.kpiId", kpiParentId);
     
      Iterator iterSbiKpiRel = exportedKpiRel.iterator();

      while (iterSbiKpiRel.hasNext()) {
        SbiKpiRel kpirel = (SbiKpiRel) iterSbiKpiRel.next();
        SbiKpi child = kpirel.getSbiKpiByKpiChildId();
        SbiKpi father = kpirel.getSbiKpiByKpiFatherId();
        if(child != null && father != null){
         
          Map assKpiRel = metaAss.getKpiRelAssociation();
          Integer existingKpiRelId = null;
          Set assKpiRelSet = assKpiRel.keySet();
          if (assKpiRelSet.contains(kpirel.getKpiRelId()) && !overwrite) {
            metaLog.log("Exported association between object " + kpirel.getSbiKpiByKpiFatherId().getName() + " "
                + " and kpi " + kpirel.getSbiKpiByKpiChildId().getName() + " with parameter "
                + kpirel.getParameter() + " not inserted"
                + " because already existing into the current database");
            continue;
          } else {
            existingKpiRelId = (Integer) assKpiRel.get(kpirel.getKpiRelId());
          }
          if (existingKpiRelId != null) {
            metaLog.log("The relation between object " + kpirel.getSbiKpiByKpiFatherId().getName() + " "
                + " and kpi " + kpirel.getSbiKpiByKpiChildId().getName() + " with parameter "
                + kpirel.getParameter()+ "] will be updated.");
            SbiKpiRel existingKpiRel = ImportUtilities.modifyExistingKpiRel(kpirel, sessionCurrDB, existingKpiRelId);
            ImportUtilities.entitiesAssociationsSbiKpiRel(kpirel, existingKpiRel, sessionCurrDB, metaAss, importer);
            sessionCurrDB.update(existingKpiRel);
          } else {
            SbiKpiRel newRel = ImportUtilities.makeNewSbiKpiRel(kpirel, sessionCurrDB, metaAss, importer);
            sessionCurrDB.save(newRel);
            metaLog.log("Inserted new relation between object " + kpirel.getSbiKpiByKpiFatherId().getName() + " "
                + " and kpi " + kpirel.getSbiKpiByKpiChildId().getName() + " with parameter "
                + kpirel.getParameter());
            Integer newId = newRel.getKpiRelId();
            sessionExpDB.evict(kpirel);
            metaAss.insertCoupleKpiRelAssociation(kpirel.getKpiRelId(), newId);
          }

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