Package ch.hortis.sonar.model

Examples of ch.hortis.sonar.model.SnapshotGroup


    Collection<SnapshotGroup> groups = getGroupsToProcess();
    int processed = 0;
    MavenProjectService projectService = new MavenProjectService(getEntityManager());
    SnapshotGroupService snapshotGroupService = new SnapshotGroupService(getEntityManager());
    for (Iterator<SnapshotGroup> i = groups.iterator(); i.hasNext();) {
      SnapshotGroup group = i.next();
      if (!snapshotGroupService.isReadyToCalculateMeasures(group, projectService)) {
        i.remove();
      }
    }
    // removing all references to snaphsots from the entitymanager VERY important to clean memory
    createNewEntityManager();
    LOG.info(groups.size() + " snapshots to process");
    for (Iterator<SnapshotGroup> i = groups.iterator(); i.hasNext(); ) {
      SnapshotGroup group = i.next();
      // since SnapshotGroup are now detached must reload them to put them under the entitymanager control
      LOG.info("Reloading snapshot group " + group.getId());
      group = getEntityManager().find(SnapshotGroup.class, group.getId());
      try {
        long snapshotGroupStartTime = System.currentTimeMillis();
        MDC.put("group", group.getId().toString());
        LOG.info("Process snapshot group");
        processGroup(group);
        long timeTaken = System.currentTimeMillis() - snapshotGroupStartTime;
        LOG.info("Processed snapshot group in " + (timeTaken) + " ms");
        processed++;
View Full Code Here


    Collection<SnapshotGroup> groups = getGroupsToProcess();
    int processed = 0;
    MavenProjectService projectService = new MavenProjectService(getEntityManager());
    SnapshotGroupService snapshotGroupService = new SnapshotGroupService(getEntityManager());
    for (Iterator<SnapshotGroup> i = groups.iterator(); i.hasNext();) {
      SnapshotGroup group = i.next();
      if (!snapshotGroupService.isReadyToCalculateMeasures(group, projectService)) {
        i.remove();
      }
    }
    // removing all references to snaphsots from the entitymanager VERY important to clean memory
    createNewEntityManager();
    LOG.info(groups.size() + " snapshots to process");
    for (Iterator<SnapshotGroup> i = groups.iterator(); i.hasNext(); ) {
      SnapshotGroup group = i.next();
      // since SnapshotGroup are now detached must reload them to put them under the entitymanager control
      LOG.info("Reloading snapshot group " + group.getId());
      group = getEntityManager().find(SnapshotGroup.class, group.getId());
      try {
        long snapshotGroupStartTime = System.currentTimeMillis();
        MDC.put("group", group.getId().toString());
        LOG.info("Process snapshot group");
        processGroup(group);
        long timeTaken = System.currentTimeMillis() - snapshotGroupStartTime;
        LOG.info("Processed snapshot group in " + (timeTaken) + " ms");
        processed++;
View Full Code Here

    query.setFlushMode(FlushModeType.COMMIT);
    List<SnapshotGroup> groups = query.getResultList();

    createNewEntityManager();
    for (Iterator<SnapshotGroup> i = groups.iterator(); i.hasNext();) {
      SnapshotGroup group = i.next();

      for (Iterator<Snapshot> is = group.getSnapshots().iterator(); is.hasNext();) {
        Snapshot snapshot = is.next();
        LOG.info("purging group=" + group.getId() + ", snapshot=" + snapshot.getId());

        snapshot = getEntityManager().find(Snapshot.class, snapshot.getId());

        getEntityManager().getTransaction().begin();
        purgeFileMeasures(snapshot);
        purgeRuleFailures(snapshot);
        purgeFiles(snapshot);
        purgeTendencies(snapshot);
        getEntityManager().merge(snapshot);
        getEntityManager().getTransaction().commit();

        is.remove();
        createNewEntityManager();
      }

      getEntityManager().getTransaction().begin();
      // since SnapshotGroup are now detached must reload them to put them under the entitymanager control
      group = getEntityManager().find(SnapshotGroup.class, group.getId());
      group.setPurged(true);
      getEntityManager().merge(group);
      getEntityManager().getTransaction().commit();
      i.remove();
      createNewEntityManager();
    }
View Full Code Here

    Query query = getEntityManager().createNamedQuery(SnapshotGroup.SQL_SELECT_GROUPS_FOR_DATE);
    query.setFlushMode(FlushModeType.COMMIT);
    query.setParameter("createdAt", delay, TemporalType.TIMESTAMP);
    List<SnapshotGroup> groups = query.getResultList();
    for (Iterator<SnapshotGroup> it = groups.iterator() ; it.hasNext() ; ) {
        SnapshotGroup group = it.next();
    createNewEntityManager();
        group = getEntityManager().find(SnapshotGroup.class, group.getId());
    getEntityManager().getTransaction().begin();
      getEntityManager().remove(group);
    getEntityManager().getTransaction().commit();
  }
  }
View Full Code Here

    snapshot.setMavenProject(sonarProject);
    snapshot.setVersion(mavenProject.getVersion());
    manager.setFlushMode(FlushModeType.COMMIT);

    manager.getTransaction().begin();
    SnapshotGroup snapshotGroup;
    try {
      if (sonarProject.getParent() == null) {
        snapshotGroup = new SnapshotGroup();
        snapshotGroup.setCreatedAt(runDate);
        snapshotGroup.setMavenProject(sonarProject);
        manager.persist(snapshotGroup);
        setCurrentSnapshotGroupId(snapshotGroup.getId());
      } else {
        Integer groupId = getCurrentSnapshotGroupId();
        if (groupId != null) {
          snapshotGroup = manager.find(SnapshotGroup.class, groupId);
          if (snapshotGroup == null) {
View Full Code Here

  }

  public SnapshotGroup getLastProcessedSnapshotGroup(Integer projectId) throws NoResultException {
    Query query = manager.createNamedQuery( SnapshotGroup.SQL_SELECT_LAST_PROCESSED );
    query.setParameter("idProject", projectId);
    SnapshotGroup snapshot = (SnapshotGroup) query.getSingleResult();
    log.debug("Found last snapshot group db row " + snapshot.getId() );
    return snapshot;
  }
View Full Code Here

    query.setParameter("idProject", projectId);
    List snapshot = query.getResultList();
    if ( snapshot.size() == 0 ) throw new NoResultException();
    roofTime = roofTime + delayInMs;
    for (Object aSnapshot : snapshot) {
      SnapshotGroup grp = (SnapshotGroup) aSnapshot;
      if ( grp.getCreatedAt().getTime() < roofTime ) {
        return grp;
      }
    }
    throw new NoResultException();
  }
View Full Code Here

    if (snapshot.isEmpty()) {
      throw new NoResultException();
    }
    roofTime += delayInMs;
    for (Object aSnapshot : snapshot) {
      SnapshotGroup grp = (SnapshotGroup) aSnapshot;
      if ( grp.getCreatedAt().getTime() < roofTime ) {
        return grp;
      }
    }
    throw new NoResultException();
  }
View Full Code Here

  }

  public SnapshotGroup getLastProcessedSnapshotGroup(Integer projectId) throws NoResultException {
    Query query = manager.createNamedQuery( SnapshotGroup.SQL_SELECT_LAST_PROCESSED );
    query.setParameter("idProject", projectId);
    SnapshotGroup snapshot = (SnapshotGroup) query.getSingleResult();
    log.debug("Found last snapshot group db row " + snapshot.getId() );
    return snapshot;
  }
View Full Code Here

    query.setParameter("idProject", projectId);
    List snapshot = query.getResultList();
    if ( snapshot.size() == 0 ) throw new NoResultException();
    roofTime = roofTime + delayInMs;
    for ( Iterator i = snapshot.iterator(); i.hasNext(); ) {
      SnapshotGroup grp = (SnapshotGroup)i.next();
      if ( grp.getDate().getTime() < roofTime ) {
        return grp;
      }
    }

    throw new NoResultException();
View Full Code Here

TOP

Related Classes of ch.hortis.sonar.model.SnapshotGroup

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.