Package ch.hortis.sonar.model

Examples of ch.hortis.sonar.model.Snapshot


  private Map<MeasureKey, MetricMeasure> measuresByKey;
  private List<RuleFailure> ruleFailures;

  protected Module(List<File> files) {
    // for tests
    snapshot = new Snapshot();
    measuresByKey = new HashMap<MeasureKey, MetricMeasure>();
    ruleFailures = new ArrayList<RuleFailure>();
    snapshot.setFiles(files);
  }
View Full Code Here


  private EntityManager manager;

  protected Module(List<File> files, EntityManager manager) {
    // for tests
    this.manager = manager;
    snapshot = new Snapshot();
    measuresByKey = new HashMap<MeasureKey, MetricMeasure>(512);
    ruleFailures = new ArrayList<RuleFailure>(1024);
    snapshot.setFiles(files);
  }
View Full Code Here

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

  private EntityManager manager;

  protected Module(List<File> files, EntityManager manager) {
    // for tests
    this.manager = manager;
    snapshot = new Snapshot();
    measuresByKey = new HashMap<MeasureKey, MetricMeasure>(512);
    ruleFailures = new ArrayList<RuleFailure>(1024);
    snapshot.setFiles(files);
  }
View Full Code Here

      }
    }
  }

  private void collect(MavenProject sonarProject) throws MojoExecutionException {
    Snapshot snapshot = new Snapshot();
    snapshot.setCreatedAt(runDate);
    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) {
            throw new NoResultException();
          }
        } else {
          SnapshotGroupService service = new SnapshotGroupService(manager);
          MavenProject parent = sonarProject.getParent();
          int maxDept = 100;
          while (maxDept > 0) {
            if (parent.getParent() == null) {
              break;
            }
            parent = parent.getParent();
            maxDept--;
          }
          // look for the last snapshot group created within the last 60 mins
          snapshotGroup = service.getLastUnprocessedGroup(parent.getId(), (long) 60 * 60 * 1000, runDate.getTime());
        }
      }

    } catch (NoResultException e) {
      throw new MojoExecutionException("Unable to find the last snapshot group");
    }
    snapshot.setSnapshotGroup(snapshotGroup);
    manager.persist(snapshot);
    collectAndPersist(snapshot);
    manager.getTransaction().commit();
    triggerMeasureCalculation(snapshotGroup);
  }
View Full Code Here

      }
    }
  }

  private void collect(MavenProject sonarProject) throws MojoExecutionException {
    Snapshot snapshot = new Snapshot();
    snapshot.setCreatedAt(runDate);
    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) {
            throw new NoResultException();
          }
        } else {
          SnapshotGroupService service = new SnapshotGroupService(manager);
          MavenProject parent = sonarProject.getParent();
          int maxDept = 100;
          while (maxDept > 0) {
            if (parent.getParent() == null) {
              break;
            }
            parent = parent.getParent();
            maxDept--;
          }
          // look for the last snapshot group created within the last 60 mins
          snapshotGroup = service.getLastUnprocessedGroup(parent.getId(), (long) 60 * 60 * 1000, runDate.getTime());
        }
      }

    } catch (NoResultException e) {
      throw new MojoExecutionException("Unable to find the last snapshot group");
    }
    snapshot.setSnapshotGroup(snapshotGroup);
    manager.persist(snapshot);
    collectAndPersist(snapshot);
    manager.getTransaction().commit();
    triggerMeasureCalculation(snapshotGroup);
  }
View Full Code Here

    return collectables;
  }

  private void persistCollectables(List<Collectable> collectables,
                                   MavenProject sonarProject) throws MojoExecutionException {
    Snapshot snapshot = new Snapshot();
    snapshot.setCreatedAt(runDate);
    snapshot.setMavenProject(sonarProject);
    snapshot.setVersion(mavenProject.getVersion());

    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) {
            throw new NoResultException();
          }
        } else {
          SnapshotGroupService service = new SnapshotGroupService(manager);
          MavenProject parent = sonarProject.getParent();
          int maxDept = 100;
          while (maxDept > 0) {
            if (parent.getParent() == null) {
              break;
            }
            parent = parent.getParent();
            maxDept--;
          }
          // look for the last snapshot group created within the last 60 mins
          snapshotGroup = service.getLastUnprocessedGroup(parent.getId(), (long) 60 * 60 * 1000, runDate.getTime());
        }
      }

    } catch (NoResultException e) {
      throw new MojoExecutionException("Unable to find the last snapshot group");
    }
    snapshot.setSnapshotGroup(snapshotGroup);
    manager.persist(snapshot);

    CollectableService collectableService = new CollectableService(manager);
    collectableService.persistCollectables(snapshot, collectables);

View Full Code Here

TOP

Related Classes of ch.hortis.sonar.model.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.