Package it.eng.spagobi.analiticalmodel.document.bo

Examples of it.eng.spagobi.analiticalmodel.document.bo.Snapshot


  public static Snapshot getNamedHistorySnapshot(List allsnapshots, String namesnap, int hist) throws Exception {
    Map snapshots = new HashMap();
    List snapDates = new ArrayList();
    Iterator iterAllSnap = allsnapshots.iterator();
    while(iterAllSnap.hasNext()) {
      Snapshot snap =  (Snapshot)iterAllSnap.next();
      if(snap.getName().equals(namesnap)){
        Date creationDate = snap.getDateCreation();
        Long creationLong = new Long(creationDate.getTime());
        snapDates.add(creationLong);
        snapshots.put(creationLong, snap);
      }
    }
    // check if history is out of range
    if( (hist<0) || (snapDates.size()-1 < hist) ) {
      SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, SchedulerUtilities.class.getName(),
                      "getNamedHistorySnapshot", "History step out of range");
      throw new Exception("History step out of range");
    }
    // get the right snapshot
    Collections.sort(snapDates);
    Collections.reverse(snapDates);
    Object key = snapDates.get(hist);
    Snapshot snap = (Snapshot)snapshots.get(key);
    return snap;
  }
View Full Code Here


   */
  public static List getSnapshotsByName(List allsnapshots, String namesnap) throws Exception {
    List snaps = new ArrayList();
    Iterator iterAllSnap = allsnapshots.iterator();
    while(iterAllSnap.hasNext()) {
      Snapshot snap =  (Snapshot)iterAllSnap.next();
      if(snap.getName().equals(namesnap)){
        snaps.add(snap);
      }
    }
    return snaps;
 
View Full Code Here

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

        Integer objId = request.getInteger(SpagoBIConstants.OBJECT_ID);
        List snapshotsList = DAOFactory.getSnapshotDAO().getSnapshots(objId);
        List evaluatedSnapshotsName = new ArrayList();
        Iterator it = snapshotsList.iterator();
        while (it.hasNext()) {
          Snapshot snapshot = (Snapshot) it.next();
          if (evaluatedSnapshotsName.contains(snapshot.getName())) {
            continue;
          } else {
            evaluatedSnapshotsName.add(snapshot.getName());
          }
          int historyLength = findHistoryLength(snapshotsList, snapshot.getName());
          output.append("{id: " + snapshot.getId().toString() + ", " +
                  "name: \"" + JavaScript.escapeText(snapshot.getName()) + "\", " +
                  "description: \"" + JavaScript.escapeText(snapshot.getDescription()) + "\", " +
                  "historyLength: " + new Integer(historyLength).toString() + "}");
          if (it.hasNext()) {
            output.append(";;");
          }
        }
View Full Code Here

  private int findHistoryLength(List snapshotsList, String name) {
    int count = 0;
    Iterator it = snapshotsList.iterator();
    while (it.hasNext()) {
      Snapshot snapshot = (Snapshot) it.next();
      if (snapshot.getName().equals(name)) {
        count++;
      }
    }
    return count;
  }
View Full Code Here

     
      List hibSnaps = query.list();
      Iterator iterHibSnaps = hibSnaps.iterator();
      while(iterHibSnaps.hasNext()) {
        SbiSnapshots hibSnap = (SbiSnapshots)iterHibSnaps.next();
        Snapshot snap = toSnapshot(hibSnap);
        snaps.add(snap);
      }
      tx.commit();
    } catch (HibernateException he) {
      logException(he);
View Full Code Here

  }


 
  private Snapshot toSnapshot(SbiSnapshots hibSnap) {
    Snapshot snap = new Snapshot();
    snap.setBiobjId(hibSnap.getSbiObject().getBiobjId());
    snap.setBinId(hibSnap.getSbiBinContents().getId());
    snap.setDateCreation(hibSnap.getCreationDate());
    snap.setDescription(hibSnap.getDescription());
    snap.setId(hibSnap.getSnapId());
    snap.setName(hibSnap.getName());
    return snap;
  }
View Full Code Here

  /* (non-Javadoc)
   * @see it.eng.spagobi.analiticalmodel.document.dao.ISnapshotDAO#loadSnapshot(java.lang.Integer)
   */
  public Snapshot loadSnapshot(Integer idSnap) throws EMFUserError {
    Snapshot snap = null;
    Session aSession = null;
    Transaction tx = null;
    try {
      aSession = getSession();
      tx = aSession.beginTransaction();
View Full Code Here

   * @param response
   *            The response SourceBean
   */
  private void execSnapshotHandler(SourceBean request, SourceBean response) throws Exception {
    logger.debug("IN");
    Snapshot snapshot = getRequiredSnapshot(request);
    if (snapshot!= null) {
      executeSnapshot(snapshot, response);
    }
    logger.debug("OUT");
  }
View Full Code Here

      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 {
          logger.error("Cannot delete scheduled execution with id = " + snapshot.getBiobjId() + ": " +
              "it is not relevant to the current document [id: " + obj.getId() + ", label: " + obj.getLabel() + ", name: " + obj.getName() + "]");
          throw new SpagoBIServiceException(SERVICE_NAME, "Cannot delete scheduled execution: it is not relevant to the current document");
        }
       
      }
View Full Code Here

TOP

Related Classes of it.eng.spagobi.analiticalmodel.document.bo.Snapshot

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.