Package it.eng.spagobi.analiticalmodel.document.dao

Examples of it.eng.spagobi.analiticalmodel.document.dao.ISnapshotDAO


        snapDesc = snapDesc.substring(0, 1000);
      }

      String historylengthStr = sInfo.getSnapshotHistoryLength();
      // store document as snapshot
      ISnapshotDAO snapDao = DAOFactory.getSnapshotDAO();
      snapDao.setUserProfile(profile);
      // get the list of snapshots
      List allsnapshots = snapDao.getSnapshots(biobj.getId());
      // get the list of the snapshot with the store name
      List snapshots = SchedulerUtilities.getSnapshotsByName(allsnapshots, snapName);
      // get the number of previous snapshot saved
      int numSnap = snapshots.size();
      // if the number of snapshot is greater or equal to the history length then
      // delete the unecessary snapshots
      if((historylengthStr!=null) && !historylengthStr.trim().equals("")){
        try{
          Integer histLenInt = new Integer(historylengthStr);
          int histLen = histLenInt.intValue();
          if(numSnap>=histLen){
            int delta = numSnap - histLen;
            for(int i=0; i<=delta; i++) {
              Snapshot snap = SchedulerUtilities.getNamedHistorySnapshot(allsnapshots, snapName, histLen-1);
              Integer snapId = snap.getId();
              snapDao.deleteSnapshot(snapId);
            }
          }
        } catch(Exception e) {
          logger.error("Error while deleting object snapshots", e);
        }
      }
      snapDao.saveSnapshot(response, biobj.getId(), snapName, snapDesc)
    } catch (Exception e) {
      logger.error("Error while saving schedule result as new snapshot", e);
    }finally{
      logger.debug("OUT");
    }
View Full Code Here


        List subObjectLis = subDao.getSubObjects(biobj.getId());
        if (subObjectLis != null && !subObjectLis.isEmpty())
          exporter.insertAllSubObject(biobj, subObjectLis, session);
      }
      if (exportSnapshots) {
        ISnapshotDAO subDao = DAOFactory.getSnapshotDAO();
        List snapshotLis = subDao.getSnapshots(biobj.getId());
        if (snapshotLis != null && !snapshotLis.isEmpty())
          exporter.insertAllSnapshot(biobj, snapshotLis, session);
      }

      // insert functionalities and association with object
View Full Code Here

  throws EMFUserError, SourceBeanException, NumberFormatException, EMFInternalError {
    logger.debug("IN");
    UserProfile profile = (UserProfile) this.getUserProfile();
    // only if user is administrator, he can erase snapshots
    if (profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_ADMIN)) {
      ISnapshotDAO snapdao = DAOFactory.getSnapshotDAO();
      List snapshotIdsList = request.getAttributeAsList(SpagoBIConstants.SNAPSHOT_ID);
      if (snapshotIdsList != null && !snapshotIdsList.isEmpty()) {
        Iterator it = snapshotIdsList.iterator();
        while (it.hasNext()) {
          String snapshotIdStr = (String) it.next();
          Integer snapId = new Integer(snapshotIdStr);
          logger.error("Deleting snaphost with id = " + snapId + " ...");
          snapdao.deleteSnapshot(snapId);
        }
      }
    } else {
      logger.error("Current user [" + profile.getUserId().toString() + "] CANNOT erase snapshots!!");
    }
View Full Code Here

   */
  private List getSnapshotList(BIObject obj) {
    logger.debug("IN");
    List snapshots = new ArrayList();
    try {
      ISnapshotDAO snapdao = DAOFactory.getSnapshotDAO();
      snapshots = snapdao.getSnapshots(obj.getId());
    } catch (Exception e) {
      logger.error("Error retriving the snapshot list", e);
    }
    logger.debug("OUT");
    return snapshots;
View Full Code Here

    try {
      // retrieving execution instance from session, no need to check if user is able to execute the current document
      ExecutionInstance executionInstance = getContext().getExecutionInstance( ExecutionInstance.class.getName() );
      BIObject obj = executionInstance.getBIObject();
      UserProfile userProfile = (UserProfile) this.getUserProfile();
      ISnapshotDAO dao = null;
      try {
        dao = DAOFactory.getSnapshotDAO();
      } catch (EMFUserError e) {
        logger.error("Error while istantiating DAO", e);
        throw new SpagoBIServiceException(SERVICE_NAME, "Cannot access database", e);
      }
      String ids = this.getAttributeAsString(SNAPSHOT_ID);
      // ids contains the id of the snapshots to be deleted separated by ,
      String[] idArray = ids.split(",");
      for (int i = 0; i < idArray.length; i++) {
        Integer id = new Integer(idArray[i]);
        Snapshot snapshot = null;
        try {
          snapshot = dao.loadSnapshot(id);
        } catch (EMFUserError e) {
          logger.error("Snapshot with id = " + id + " not found", e);
          throw new SpagoBIServiceException(SERVICE_NAME, "Scheduled execution not found", e);
        }
        if (snapshot.getBiobjId().equals(obj.getId())) {
          logger.info("User [id: " + userProfile.getUserUniqueIdentifier() + ", userId: " + userProfile.getUserId() + ", name: " + userProfile.getUserName() + "] " +
              "is deleting scheduled execution [id: " + snapshot.getId() + ", name: " + snapshot.getName() + "] ...");
          try {
            dao.deleteSnapshot(id);
          } catch (EMFUserError e) {
            throw new SpagoBIServiceException(SERVICE_NAME, "Error while deleting scheduled execution", e);
          }
          logger.debug("Scheduled execution [id: " + snapshot.getId() + ", name: " + snapshot.getName() + "] deleted.");
        } else {
View Full Code Here

  private JSONObject handleSnapshotExecution(Integer snapshotId) {
   
    JSONObject response= null;
   
    ISnapshotDAO dao;
    Snapshot snapshot;
    BIObject obj;
    String url;
    ExecutionInstance executionInstance;
   
    logger.debug("IN");
   
    try {
      executionInstance = getContext().getExecutionInstance( ExecutionInstance.class.getName() );
      Assert.assertNotNull(executionInstance, "Execution instance cannot be null in order to properly generate execution url");
     
     
      // we are not executing a subobject, so delete subobject if existing
      executionInstance.setSubObject(null);
     
      dao = null;
      try {
        dao = DAOFactory.getSnapshotDAO();
      } catch (EMFUserError e) {
        logger.error("Error while istantiating DAO", e);
        throw new SpagoBIServiceException(SERVICE_NAME, "Cannot access database", e);
      }
      Assert.assertNotNull(dao, "An internal error occurred while istantiating DAO. DAO cannot be null.");

      snapshot = null;
      try {
        snapshot = dao.loadSnapshot(snapshotId);
      } catch (EMFUserError e) {
        logger.error("Snapshot with id = " + snapshotId + " not found", e);
        throw new SpagoBIServiceException(SERVICE_NAME, "Scheduled execution not found", e);
      }
      Assert.assertNotNull(dao, "An internal error occurred while loading snapshot [" + snapshotId + "]. Snapshot cannot be null.");
View Full Code Here

    // check if the user is able to see the document
    // TODO check if the user is able to execute the document (even if it does no make sense to be able to see the document but not to execute it...)
    byte[] content = null;
    if (ObjectsAccessVerifier.canSee(obj, profile)) {
      logger.debug("Current user [" + ((UserProfile) profile).getUserId().toString() + "] can see snapshot with id = " + idSnap + " of document with id = " + objectId);
      ISnapshotDAO snapdao = DAOFactory.getSnapshotDAO();
      Snapshot snap = snapdao.loadSnapshot(idSnap);
      content = snap.getContent();
    } else {
      logger.error("Current user [" + ((UserProfile) profile).getUserId().toString() + "] CANNOT see snapshot with id = " + idSnap + " of document with id = " + objectId);
      //content = "You cannot see required snapshot.".getBytes();
      content = "You cannot see required snapshot.".getBytes("UTF-8");
View Full Code Here

TOP

Related Classes of it.eng.spagobi.analiticalmodel.document.dao.ISnapshotDAO

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.