Examples of SbiKpiModelInst


Examples of it.eng.spagobi.kpi.model.metadata.SbiKpiModelInst

      Integer newMiId=(Integer)modInstAss.get(oldMiId);
      if(newMiId==null) {
        logger.error("could not find association with modelinstance id with id " + oldMiId);       
      }
      else{
        SbiKpiModelInst newSbiMi = (SbiKpiModelInst) sessionCurrDB.load(SbiKpiModelInst.class, newMiId);
        existingGrant.setSbiKpiModelInst(newSbiMi);
      }
    }
    // hierarchy id
    Map ouHierAss = metaAss.getOuHierarchiesAssociation();
View Full Code Here

Examples of it.eng.spagobi.kpi.model.metadata.SbiKpiModelInst

      Integer newMiId=(Integer)modInstAss.get(oldMiId);
      if(newMiId==null) {
        logger.error("could not find association with modelinstance id with id " + oldMiId);       
      }
      else{
        SbiKpiModelInst newSbiMi = (SbiKpiModelInst) sessionCurrDB.load(SbiKpiModelInst.class, newMiId);
        exportedGrantNode.setSbiKpiModelInst(newSbiMi);
        id.setKpiModelInstNodeId(newSbiMi.getKpiModelInst());
      }
    }
    // grant id
    Map grantAss = metaAss.getOuGrantAssociation();
    //original value of exported object != null
View Full Code Here

Examples of it.eng.spagobi.kpi.model.metadata.SbiKpiModelInst

   *
   * @throws EMFUserError
   */
  private void importModelInstance(boolean overwrite) throws EMFUserError {
    logger.debug("IN");
    SbiKpiModelInst exportedModelInst = null;
    try {
      List exportedModelsInsts = importer.getAllExportedSbiObjects(sessionExpDB, "SbiKpiModelInst", null);
      Iterator iterSbiModelsInsts = exportedModelsInsts.iterator();
      while (iterSbiModelsInsts.hasNext()) {
        exportedModelInst = (SbiKpiModelInst) iterSbiModelsInsts.next();
        Integer oldId = exportedModelInst.getKpiModelInst();
        Integer existingModelInstId = null;
        Map modelInstIdAss = metaAss.getModelInstanceIDAssociation();
        Set modelInstIdAssSet = modelInstIdAss.keySet();
        if (modelInstIdAssSet.contains(oldId) && !overwrite) {
          metaLog.log("Exported model instance" + exportedModelInst.getLabel() + " not inserted"
              + " because it has the same label of an existing model instance");
          continue;
        } else {
          existingModelInstId = (Integer) modelInstIdAss.get(oldId);
        }
        if (existingModelInstId != null) {
          logger.info("The model instance with id:[" + exportedModelInst.getKpiModelInst() + "] is just present. It will be updated.");
          metaLog.log("The model instance with code = [" + exportedModelInst.getLabel() + "] will be updated.");
          SbiKpiModelInst existingModelInst = ImportUtilities.modifyExistingSbiModelInstance(exportedModelInst, sessionCurrDB, existingModelInstId, metaAss);
          sessionCurrDB.update(existingModelInst);
        } else {
          SbiKpiModelInst newModelInst = ImportUtilities.makeNewSbiModelInstance(exportedModelInst, sessionCurrDB, metaAss);
          sessionCurrDB.save(newModelInst);
          metaLog.log("Inserted new model instance " + newModelInst.getLabel());
          Integer newId = newModelInst.getKpiModelInst();
          metaAss.insertCoupleModelInstance(oldId, newId);
        }
      }
    } catch (Exception e) {
      if (exportedModelInst != null) {
View Full Code Here

Examples of it.eng.spagobi.kpi.model.metadata.SbiKpiModelInst

    Transaction tx = null;
    try {
      tx = aSession.beginTransaction();
      SbiKpiModelResources aModelResources = new SbiKpiModelResources();
     
      SbiKpiModelInst aModelInst = (SbiKpiModelInst) aSession.load(
          SbiKpiModelInst.class, modelId);
      SbiResources aResource = (SbiResources) aSession.load(
          SbiResources.class, resourceId);
      aModelResources.setSbiKpiModelInst(aModelInst);
      aModelResources.setSbiResources(aResource);
View Full Code Here

Examples of it.eng.spagobi.kpi.model.metadata.SbiKpiModelInst

    }
  }

  private List getModelResource(Session aSession, Integer modelId,
      Integer resourceId) {
    SbiKpiModelInst aModelInst = (SbiKpiModelInst) aSession.load(
        SbiKpiModelInst.class, modelId);
    SbiResources aResource = (SbiResources) aSession.load(
        SbiResources.class, resourceId);
    Criteria crit = aSession.createCriteria(SbiKpiModelResources.class);
    crit.add(Expression.eq("sbiKpiModelInst", aModelInst));
View Full Code Here

Examples of it.eng.spagobi.kpi.model.metadata.SbiKpiModelInst

    crit.add(Expression.eq("sbiResources", aResource));
    return crit.list()
  }
 
  private List getModelResource(Session aSession, Integer modelId) {
    SbiKpiModelInst aModelInst = (SbiKpiModelInst) aSession.load(
        SbiKpiModelInst.class, modelId);
    Criteria crit = aSession.createCriteria(SbiKpiModelResources.class);
    crit.add(Expression.eq("sbiKpiModelInst", aModelInst));
    return crit.list()
  }
View Full Code Here

Examples of it.eng.spagobi.kpi.model.metadata.SbiKpiModelInst

    }

    List exportedModelInst = importer.getAllExportedSbiObjects(sessionExpDB, "SbiKpiModelInst", null);
    Iterator iterSbiModelInst = exportedModelInst.iterator();
    while (iterSbiModelInst.hasNext()) {
      SbiKpiModelInst dsExp = (SbiKpiModelInst) iterSbiModelInst.next();
      String label = dsExp.getLabel();
      Object existObj = importer.checkExistence(label, sessionCurrDB, new SbiKpiModelInst());
      if (existObj != null) {
        SbiKpiModelInst dsCurr = (SbiKpiModelInst) existObj;
        metaAss.insertCoupleModelInstance(new Integer(dsExp.getKpiModelInst()), new Integer(dsCurr.getKpiModelInst()));
        metaLog.log("Found an existing model instance" + dsCurr.getLabel() + " with "
            + "the same label of one exported model instance");
      }
    }



    // Kpi Instance 
    // for each model instance get the kpi instance id; then take the kpiInstance of the corresponding model instance; map them

    List exportedModelInst2 = importer.getAllExportedSbiObjects(sessionExpDB, "SbiKpiModelInst", null);
    Iterator iterSbiModelInst2 = exportedModelInst.iterator();
    while (iterSbiModelInst2.hasNext()) {
      SbiKpiModelInst dsExp = (SbiKpiModelInst) iterSbiModelInst2.next();

      if(dsExp.getSbiKpiInstance()!=null){

        Integer idKpiInstance = dsExp.getSbiKpiInstance().getIdKpiInstance();
        String label = dsExp.getLabel();

        Object existObj = importer.checkExistence(label, sessionCurrDB, new SbiKpiModelInst());
        if (existObj != null) {
          SbiKpiModelInst dsCurr = (SbiKpiModelInst) existObj;
          if(dsCurr.getSbiKpiInstance()!=null){
            Integer correspondingIdKpiInstance=dsCurr.getSbiKpiInstance().getIdKpiInstance();
            metaAss.insertCoupleKpiInstance(idKpiInstance, correspondingIdKpiInstance);
            metaLog.log("Found an existing kpi instance that, as one of the exported kpi instances, is referred by model instance " + dsCurr.getLabel());
          }
        }
      }
    }

    // Resource

    List exportedResource = importer.getAllExportedSbiObjects(sessionExpDB, "SbiResources", null);
    Iterator iterSbiResources = exportedResource.iterator();
    while (iterSbiResources.hasNext()) {
      SbiResources dsExp = (SbiResources) iterSbiResources.next();
      String code = dsExp.getResourceCode();
      Object existObj = importer.checkExistence(code, sessionCurrDB, new SbiResources());
      if (existObj != null) {
        SbiResources dsCurr = (SbiResources) existObj;
        metaAss.insertCoupleResources(dsExp.getResourceId(), dsCurr.getResourceId());
        metaLog.log("Found an existing resource code " + dsCurr.getResourceCode() + " with "
            + "the same code of one exported resource");
      }
    }


    // Model Resources

    List exportedModResource = importer.getAllExportedSbiObjects(sessionExpDB, "SbiKpiModelResources", null);
    Iterator iterSbiModResources = exportedModResource.iterator();
    while (iterSbiModResources.hasNext()) {
      SbiKpiModelResources dsExp = (SbiKpiModelResources) iterSbiModResources.next();
      String resourceCode = dsExp.getSbiResources().getResourceCode();
      String modelInstLabel=dsExp.getSbiKpiModelInst().getLabel();
      Object existObj = importer.checkExistenceModelResource(modelInstLabel,resourceCode, sessionCurrDB, new SbiKpiModelResources());
      if (existObj != null) {
        SbiKpiModelResources dsCurr = (SbiKpiModelResources) existObj;
        metaAss.insertCoupleModelResources(dsExp.getKpiModelResourcesId(), dsCurr.getKpiModelResourcesId());
        metaLog.log("Found an existing model resource, with id "+dsCurr.getKpiModelResourcesId()+", referring to resource with name "+ dsCurr.getSbiResources().getResourceName() + " and model instance with label "+dsCurr.getSbiKpiModelInst().getLabel() +" ");
      }
    }



    // Periodicity

    List exportedPeriodicity = importer.getAllExportedSbiObjects(sessionExpDB, "SbiKpiPeriodicity", null);
    Iterator iterSbiPeriodicity = exportedPeriodicity.iterator();
    while (iterSbiPeriodicity.hasNext()) {
      SbiKpiPeriodicity dsPer = (SbiKpiPeriodicity) iterSbiPeriodicity.next();
      String name = dsPer.getName();
      Object existObj = importer.checkExistence(name, sessionCurrDB, new SbiKpiPeriodicity());
      if (existObj != null) {
        SbiKpiPeriodicity dsCurr = (SbiKpiPeriodicity) existObj;
        metaAss.insertCouplePeriodicity(dsPer.getIdKpiPeriodicity(), dsCurr.getIdKpiPeriodicity());
        metaLog.log("Found an existing periodicity " + dsCurr.getName() + " with "
            + "the same label of one exported periodicity");
      }
    }


    // kpi Instance Period

    List exportedKpiInstPeriod = importer.getAllExportedSbiObjects(sessionExpDB, "SbiKpiInstPeriod", null);
    Iterator iterSbiKpiInstPeriod = exportedKpiInstPeriod.iterator();
    while (iterSbiKpiInstPeriod.hasNext()) {
      SbiKpiInstPeriod dsInstPer = (SbiKpiInstPeriod) iterSbiKpiInstPeriod.next();
      String periodicityName=dsInstPer.getSbiKpiPeriodicity().getName();
      SbiKpiInstance kpiInst=dsInstPer.getSbiKpiInstance();
      Map kpiInstanceIDMap=metaAss.getKpiInstanceIDAssociation();

      Integer newKpiInstanceId=null;
      Object newKpiInstanceIdO=kpiInstanceIDMap.get(kpiInst.getIdKpiInstance());
      if(newKpiInstanceIdO!=null){
        newKpiInstanceId=(Integer)newKpiInstanceIdO;
      }
      Object existObj = null;
      if(newKpiInstanceId!=null){
        existObj=importer.checkExistenceKpiInstPeriod(newKpiInstanceId,periodicityName, sessionCurrDB, new SbiKpiModelResources());
      }

      if (existObj != null) {
        SbiKpiInstPeriod dsCurr = (SbiKpiInstPeriod) existObj;
        metaAss.insertCoupleKpiInstPeriod(dsInstPer.getKpiInstPeriodId(), dsCurr.getKpiInstPeriodId());
        metaLog.log("Found a kpiInstPeriod, with id "+dsCurr.getKpiInstPeriodId()+" referring to periodicity " + dsCurr.getSbiKpiPeriodicity().getName() + " and kpi instance with id "+dsCurr.getSbiKpiInstance().getIdKpiInstance());     
      }
    }



    List exportedDomains = importer.getAllExportedSbiObjects(sessionExpDB, "SbiDomains", null);
    Iterator iterSbiDomains = exportedDomains.iterator();
    while (iterSbiDomains.hasNext()) {
      SbiDomains dsExp = (SbiDomains) iterSbiDomains.next();
      String label = dsExp.getValueCd();
      Object existObj = importer.checkExistenceDomain(label, dsExp.getDomainCd(), sessionCurrDB, new SbiDomains());
      if (existObj != null) {
        SbiDomains dsCurr = (SbiDomains) existObj;
        metaAss.insertCoupleDomain(new Integer(dsExp.getValueId()), new Integer(dsCurr.getValueId()));
        metaLog.log("Found an existing domain" + dsCurr.getValueCd() + " with "
            + "the same label of one exported domain");
      }
    }


    // Alarm

    List exportedAlarms = importer.getAllExportedSbiObjects(sessionExpDB, "SbiAlarm", null);
    Iterator iterSbiAlarm = exportedAlarms.iterator();
    while (iterSbiAlarm.hasNext()) {
      SbiAlarm dsExp = (SbiAlarm) iterSbiAlarm.next();
      String label = dsExp.getLabel();
      Object existObj = importer.checkExistence(label, sessionCurrDB, new SbiAlarm());
      if (existObj != null) {
        SbiAlarm dsCurr = (SbiAlarm) existObj;
        metaAss.insertCoupleAlarm(dsExp.getId(), dsCurr.getId());
        metaLog.log("Found an existing alarm " + dsCurr.getLabel() + " with "
            + "the same label of one exported alarm");
      }
    }

    // Alarm Contact

    List exportedAlarmContacts = importer.getAllExportedSbiObjects(sessionExpDB, "SbiAlarmContact", null);
    Iterator iterSbiAlarmContacts = exportedAlarmContacts.iterator();
    while (iterSbiAlarmContacts.hasNext()) {
      SbiAlarmContact dsExp = (SbiAlarmContact) iterSbiAlarmContacts.next();
      String name = dsExp.getName();
      Object existObj = importer.checkExistence(name, sessionCurrDB, new SbiAlarmContact());
      if (existObj != null) {
        SbiAlarmContact dsCurr = (SbiAlarmContact) existObj;
        metaAss.insertCoupleAlarmContact(dsExp.getId(), dsCurr.getId());
        metaLog.log("Found an existing alarm contact " + dsCurr.getName() + " with "
            + "the same name of one exported alarm contact");
      }
    }

    // TODO cambiare con i nuovi UDP VAlues
/*
    List exportedKpiModelAttrs = importer.getAllExportedSbiObjects(sessionExpDB, "SbiKpiModelAttr", null);
    Iterator iterSbiKpiModelAttr = exportedKpiModelAttrs.iterator();
    while (iterSbiKpiModelAttr.hasNext()) {
      SbiKpiModelAttr attrExp = (SbiKpiModelAttr) iterSbiKpiModelAttr.next();
      SbiDomains sbiDomain  = attrExp.getSbiDomains();
      String kpiModelAttrCd  = attrExp.getKpiModelAttrCd();
      // get new sbi Domain ID
      Integer newIdDomain = (Integer)metaAss.getDomainIDAssociation().get(sbiDomain.getValueId());
      Object existObj = importer.checkExistenceKpiModelAttr(newIdDomain, kpiModelAttrCd, sessionCurrDB, new SbiKpiModelAttr());
      if (existObj != null) {
        SbiKpiModelAttr attrCurr = (SbiKpiModelAttr) existObj;
        metaAss.insertCoupleSbiKpiModelAttrID(attrExp.getKpiModelAttrId(), attrCurr.getKpiModelAttrId());
        metaLog.log("Found an existing model attr with code " + attrCurr.getKpiModelAttrCd() + " " +
            " and referring to domain "+ sbiDomain.getDomainCd()+" - "+ sbiDomain.getValueCd() +" with "
            + "the same name of one exported kpi model attr");
      }
    }


    // Model Attr Val

    List exportedKpiModelAttrVals = importer.getAllExportedSbiObjects(sessionExpDB, "SbiKpiModelAttrVal", null);
    Iterator iterSbiKpiModelAttrVal = exportedKpiModelAttrVals.iterator();
    while (iterSbiKpiModelAttrVal.hasNext()) {
      SbiKpiModelAttrVal attrValExp = (SbiKpiModelAttrVal) iterSbiKpiModelAttrVal.next();
      Integer kpiModelId = attrValExp.getSbiKpiModel().getKpiModelId();
      Integer kpiModelAttrId = attrValExp.getSbiKpiModelAttr().getKpiModelAttrId();

      // get the new Ids
      Integer newModelId = (Integer)metaAss.getModelIDAssociation().get(kpiModelId);
      Integer newModelAttrId = (Integer)metaAss.getSbiKpiModelAttrIDAssociation().get(kpiModelAttrId);

      // get new sbi Domain ID
      Object existObj = importer.checkExistenceKpiModelAttrVal(newModelAttrId, newModelId, sessionCurrDB, new SbiKpiModelAttrVal());
      if (existObj != null) {
        SbiKpiModelAttrVal attrValCurr = (SbiKpiModelAttrVal) existObj;
        metaAss.insertCoupleSbiKpiModelAttrValID(attrValExp.getKpiModelAttrValId(), attrValCurr.getKpiModelAttrValId());
        metaLog.log("Found an existing model attribute value referring to model" + attrValCurr.getSbiKpiModel().getKpiModelNm()+ " " +
            " and referring to attribute "+ attrValCurr.getSbiKpiModelAttr().getKpiModelAttrCd()+" with "
            + "the same name of one exported kpi model attr");
      }
    }
*/

    logger.debug("check existence of Object MetaContent, only for Objects!");
    List exportedMetaContent = importer.getAllExportedSbiObjects(sessionExpDB, "SbiObjMetacontents", null);
    Iterator iterSbiModMetaContent = exportedMetaContent.iterator();
    while (iterSbiModMetaContent.hasNext()) {
      SbiObjMetacontents contExp = (SbiObjMetacontents) iterSbiModMetaContent.next();
      String objectLabel = contExp.getSbiObjects().getLabel();
      // metacontent referring to subobjects not referred here because of a previous structure
      if( contExp.getSbiSubObjects() != null ){
        continue;
        //        SbiSubObjects sub = contExp.getSbiSubObjects();
        //        subObjectName = sub.getName();
      }
      Integer objMetaId = contExp.getObjmetaId();

      // I want metadata label
      String metaLabel = exportedMetadatasMap.get(objMetaId.toString());

      Object existObj = importer.checkExistenceObjMetacontent(objectLabel,metaLabel, sessionCurrDB, new SbiObjMetacontents());
      if (existObj != null) {
        SbiObjMetacontents contCurr = (SbiObjMetacontents) existObj;
        //metaAss.insertCoupleObjMeIDAssociation(metaExp.getKpiModelResourcesId(), metaCurr.getKpiModelResourcesId());       
        metaAss.insertCoupleObjMetacontentsIDAssociation(contExp.getObjMetacontentId(), contCurr.getObjMetacontentId());
        metaLog.log("Found an existing metacontents with id " + contCurr.getObjMetacontentId()+ "" +
            "referring to the same object label "+contCurr.getSbiObjects().getLabel()+", " +
            "referring to meta with id "+ contCurr.getObjmetaId()
        );
      }
    }
    // 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.model.metadata.SbiKpiModelInst

      String kpiModelInstanceLb = value.getLabel();
      Date kpiModelInstanceStartDate = value.getStartDate();
      Date kpiModelInDateEndDate = value.getEndDate();
      String modelUUID = value.getModelUUID();

      SbiKpiModelInst sbiKpiModelInst = (SbiKpiModelInst) aSession.load(
          SbiKpiModelInst.class, kpiModelInstanceId);
     
      sbiKpiModelInst.setDescription(kpiModelInstanceDesc);
      sbiKpiModelInst.setName(kpiModelInstanceNm);
      sbiKpiModelInst.setLabel(kpiModelInstanceLb);
      sbiKpiModelInst.setStartDate(kpiModelInstanceStartDate);
      sbiKpiModelInst.setEndDate(kpiModelInDateEndDate);
      sbiKpiModelInst.setModelUUID(modelUUID);

      SbiKpiInstance oldSbiKpiInstance = sbiKpiModelInst
      .getSbiKpiInstance();

      //default behaviour
      boolean newKpiInstanceHistory = true;
      boolean deleteOldHistory = false;
      boolean dontSaveKpiHistory = false;
      if(value.getKpiInstance() != null && !value.getKpiInstance().isSaveKpiHistory()){
        dontSaveKpiHistory = true;
      }

      // new kpiInstance is null
      if (value.getKpiInstance() == null) {
        newKpiInstanceHistory = false;
        deleteOldHistory = true;
      }

      if (value.getKpiInstance() != null
          && (!value.getKpiInstance().isSaveKpiHistory())) {
        newKpiInstanceHistory = false;
        dontSaveKpiHistory = true;
      }

      // old kpiInstance is null and new kpiInstance has a value
      if (oldSbiKpiInstance == null && value.getKpiInstance() != null) {
        newKpiInstanceHistory = false;
      }

      // old kpiId is different from new kpiId
      if (newKpiInstanceHistory
          && !(areBothNull(oldSbiKpiInstance.getSbiKpi(), value
              .getKpiInstance().getKpi()) || (oldSbiKpiInstance
                  .getSbiKpi() != null && areNullOrEquals(
                      oldSbiKpiInstance.getSbiKpi().getKpiId(), value
                      .getKpiInstance().getKpi())))) {
        newKpiInstanceHistory = false;
        deleteOldHistory = true;
        // create new sbiKpiInstance
      }

      // check if same value is changed
      if (newKpiInstanceHistory
          && !((areBothNull(oldSbiKpiInstance.getSbiThreshold(),
              value.getKpiInstance().getThresholdId()) || (oldSbiKpiInstance
                  .getSbiThreshold() != null && areNullOrEquals(
                      oldSbiKpiInstance.getSbiThreshold()
                      .getThresholdId(), value.getKpiInstance()
                      .getThresholdId())))
                      && (areBothNull(oldSbiKpiInstance.getChartType(),
                          value.getKpiInstance().getChartTypeId()) || (oldSbiKpiInstance
                              .getChartType() != null && areNullOrEquals(
                                  oldSbiKpiInstance.getChartType()
                                  .getValueId(), value
                                  .getKpiInstance().getChartTypeId())))
                                  /*
                                   * TODO && (areBothNull(oldSbiKpiInstance
                                   * .getSbiKpiPeriodicity(), value
                                   * .getKpiInstance().getPeriodicityId()) ||
                                   * (oldSbiKpiInstance .getSbiKpiPeriodicity() != null &&
                                   * areNullOrEquals( oldSbiKpiInstance.getSbiKpiPeriodicity()
                                   * .getIdKpiPeriodicity(), value .getKpiInstance()
                                   * .getPeriodicityId())))
                                   */
                                  && areNullOrEquals(oldSbiKpiInstance.getWeight(), value
                                      .getKpiInstance().getWeight()))) {
        // create new History
        Calendar now = Calendar.getInstance();
        SbiKpiInstanceHistory sbiKpiInstanceHistory = new SbiKpiInstanceHistory();
        sbiKpiInstanceHistory.setSbiKpiInstance(oldSbiKpiInstance);
        sbiKpiInstanceHistory.setSbiThreshold(oldSbiKpiInstance
            .getSbiThreshold());
        sbiKpiInstanceHistory.setSbiDomains(oldSbiKpiInstance
            .getChartType());
        sbiKpiInstanceHistory.setWeight(oldSbiKpiInstance.getWeight());
        sbiKpiInstanceHistory
        .setBeginDt(oldSbiKpiInstance.getBeginDt());
        sbiKpiInstanceHistory.setEndDt(now.getTime());
        updateSbiCommonInfo4Insert(sbiKpiInstanceHistory);
        aSession.save(sbiKpiInstanceHistory);
      }

      SbiKpiInstance kpiInstanceToCreate = null;



      if (value.getKpiInstance() != null) {
        if (newKpiInstanceHistory || dontSaveKpiHistory) {
          kpiInstanceToCreate = setSbiKpiInstanceFromModelInstance(
              aSession, value, oldSbiKpiInstance);
        } else {
          // create new kpiInstance
          kpiInstanceToCreate = new SbiKpiInstance();
          Calendar now = Calendar.getInstance();
          kpiInstanceToCreate.setBeginDt(now.getTime());
          kpiInstanceToCreate = setSbiKpiInstanceFromModelInstance(
              aSession, value, kpiInstanceToCreate);
        }
        updateSbiCommonInfo4Update(kpiInstanceToCreate);
        aSession.saveOrUpdate(kpiInstanceToCreate);
        sbiKpiModelInst.setSbiKpiInstance(kpiInstanceToCreate);
      } else {
        sbiKpiModelInst.setSbiKpiInstance(null);
      }
      updateSbiCommonInfo4Update(sbiKpiModelInst);
      aSession.update(sbiKpiModelInst);

      //adds or updates periodicity
View Full Code Here

Examples of it.eng.spagobi.kpi.model.metadata.SbiKpiModelInst

      aSession = getSession();
      tx = aSession.beginTransaction();

      Integer parentId = toCreate.getParentId();
      // set the sbiKpiModel
      SbiKpiModelInst sbiKpiModelInst = new SbiKpiModelInst();
      sbiKpiModelInst.setName(toCreate.getName());
      sbiKpiModelInst.setDescription(toCreate.getDescription());
      sbiKpiModelInst.setLabel(toCreate.getLabel());
      sbiKpiModelInst.setStartDate(toCreate.getStartDate());
      sbiKpiModelInst.setEndDate(toCreate.getEndDate());
      sbiKpiModelInst.setModelUUID(toCreate.getModelUUID());

      Model aModel = toCreate.getModel();
      if (aModel != null && aModel.getId() != null) {
        SbiKpiModel sbiKpiModel = (SbiKpiModel) aSession.load(
            SbiKpiModel.class, aModel.getId());
        sbiKpiModelInst.setSbiKpiModel(sbiKpiModel);

        // set the sbiKpiInstance
        KpiInstance kpiInst = toCreate.getKpiInstance();

        //if already present
        if(kpiInst != null){
          SbiKpiInstance sbiKpiInstance = new SbiKpiInstance();
          if(kpiInst.getKpi() != null){

            SbiKpi sbiKpi =  (SbiKpi) aSession.load(SbiKpi.class, kpiInst.getKpi());           
            sbiKpiInstance.setSbiKpi(sbiKpi);
            if(kpiInst.getThresholdId() != null){
              SbiThreshold sbiThr =  (SbiThreshold) aSession.load(SbiThreshold.class, kpiInst.getThresholdId());           
              sbiKpiInstance.setSbiThreshold(sbiThr);
            }
            sbiKpiInstance.setWeight(kpiInst.getWeight());

            sbiKpiInstance.setTarget(kpiInst.getTarget());           

            //if periodicity exists then set it
            if(kpiInst.getPeriodicityId() != null){
              Set periods = new HashSet<SbiKpiInstPeriod>();
              SbiKpiPeriodicity sbiPeriodicity =  (SbiKpiPeriodicity) aSession.load(SbiKpiPeriodicity.class, kpiInst.getPeriodicityId())
              if(sbiPeriodicity != null){
                periods.add(sbiPeriodicity);
                sbiKpiInstance.setSbiKpiInstPeriods(periods);
              }
            }
            if(kpiInst.getChartTypeId() != null){
              SbiDomains chartType =  (SbiDomains) aSession.load(SbiDomains.class, kpiInst.getChartTypeId())
              sbiKpiInstance.setChartType(chartType);
            }
            Calendar now = Calendar.getInstance();
            sbiKpiInstance.setBeginDt(now.getTime());
            updateSbiCommonInfo4Insert(sbiKpiInstance);
            aSession.save(sbiKpiInstance);
            sbiKpiModelInst.setSbiKpiInstance(sbiKpiInstance);
          }
        }
      }
      if (parentId != null) {
        SbiKpiModelInst sbiKpiModelInstParent = (SbiKpiModelInst) aSession
        .load(SbiKpiModelInst.class, parentId);
        sbiKpiModelInst.setSbiKpiModelInst(sbiKpiModelInstParent);
      }
      updateSbiCommonInfo4Insert(sbiKpiModelInst);
      idToReturn = (Integer) aSession.save(sbiKpiModelInst);
View Full Code Here

Examples of it.eng.spagobi.kpi.model.metadata.SbiKpiModelInst

      aSession = getSession();
      tx = aSession.beginTransaction();

      Integer parentId = toCreate.getParentId();
      // set the sbiKpiModel
      SbiKpiModelInst sbiKpiModelInst = new SbiKpiModelInst();
      sbiKpiModelInst.setName(toCreate.getName());
      sbiKpiModelInst.setDescription(toCreate.getDescription());
      sbiKpiModelInst.setLabel(toCreate.getLabel());
      sbiKpiModelInst.setStartDate(toCreate.getStartDate());
      sbiKpiModelInst.setEndDate(toCreate.getEndDate());
      sbiKpiModelInst.setModelUUID(toCreate.getModelUUID());

      Model aModel = toCreate.getModel();
      if (aModel != null && aModel.getId() != null) {
        SbiKpiModel sbiKpiModel = (SbiKpiModel) aSession.load(
            SbiKpiModel.class, aModel.getId());
        sbiKpiModelInst.setSbiKpiModel(sbiKpiModel);

        // set the sbiKpiInstance
        SbiKpi sbiKpi = sbiKpiModel.getSbiKpi();
        if (sbiKpi != null) {
          SbiKpiInstance sbiKpiInstance = new SbiKpiInstance();
          sbiKpiInstance.setSbiKpi(sbiKpi);
          sbiKpiInstance.setSbiThreshold(sbiKpi.getSbiThreshold());
          sbiKpiInstance.setWeight(sbiKpi.getWeight());
          Calendar now = Calendar.getInstance();
          sbiKpiInstance.setBeginDt(now.getTime());
          aSession.save(sbiKpiInstance);
          sbiKpiModelInst.setSbiKpiInstance(sbiKpiInstance);
        }

      }
      if (parentId != null) {
        SbiKpiModelInst sbiKpiModelInstParent = (SbiKpiModelInst) aSession
        .load(SbiKpiModelInst.class, parentId);
        sbiKpiModelInst.setSbiKpiModelInst(sbiKpiModelInstParent);
      }
      updateSbiCommonInfo4Insert(sbiKpiModelInst);
      idToReturn = (Integer) aSession.save(sbiKpiModelInst);
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.