예제 #1
0
 @Override
 public void setSource(Resource reference, String source) {
   Bucket bucket = checkIndexed(reference);
   if (bucket != null && !bucket.isExcluded()) {
     persistence.setSource(reference, source);
   }
 }
예제 #2
0
  void doStart(Project rootProject) {
    Bucket bucket = new Bucket(rootProject);
    buckets.put(rootProject, bucket);
    persistence.saveProject(rootProject, null);
    currentProject = rootProject;

    for (Project project : rootProject.getModules()) {
      addProject(project);
    }
  }
예제 #3
0
  @Override
  public Event addEvent(
      Resource resource, String name, String description, String category, Date date) {
    Event event = new Event(name, description, category);
    event.setDate(date);
    event.setCreatedAt(new Date());

    persistence.saveEvent(resource, event);
    return null;
  }
예제 #4
0
 @Override
 public Measure getMeasure(Resource resource, Metric metric) {
   Bucket bucket = buckets.get(resource);
   if (bucket != null) {
     Measure measure = bucket.getMeasures(MeasuresFilters.metric(metric));
     if (measure != null) {
       return persistence.reloadMeasure(measure);
     }
   }
   return null;
 }
예제 #5
0
  @Override
  public Dependency addDependency(Dependency dependency) {
    Dependency existingDep = getEdge(dependency.getFrom(), dependency.getTo());
    if (existingDep != null) {
      return existingDep;
    }

    Dependency parentDependency = dependency.getParent();
    if (parentDependency != null) {
      addDependency(parentDependency);
    }

    if (registerDependency(dependency)) {
      persistence.saveDependency(currentProject, dependency, parentDependency);
    }
    return dependency;
  }
예제 #6
0
  /** the measure is updated if it's already registered. */
  @Override
  public Measure addMeasure(Resource resource, Measure measure) {
    Bucket bucket = checkIndexed(resource);
    if (bucket != null && !bucket.isExcluded()) {
      Metric metric = metricFinder.findByKey(measure.getMetricKey());
      if (metric == null) {
        throw new SonarException("Unknown metric: " + measure.getMetricKey());
      }
      measure.setMetric(metric);
      bucket.addMeasure(measure);

      if (measure.getPersistenceMode().useDatabase()) {
        persistence.saveMeasure(resource, measure);
      }
    }
    return measure;
  }
예제 #7
0
  private Bucket doIndex(Resource resource, Resource parentReference) {
    Bucket bucket = buckets.get(resource);
    if (bucket != null) {
      return bucket;
    }

    checkLock(resource);

    Resource parent = null;
    if (!ResourceUtils.isLibrary(resource)) {
      // a library has no parent
      parent = (Resource) ObjectUtils.defaultIfNull(parentReference, currentProject);
    }

    Bucket parentBucket = getBucket(parent, true);
    if (parentBucket == null && parent != null) {
      LOG.warn("Resource ignored, parent is not indexed: " + resource);
      return null;
    }

    resource.setEffectiveKey(createUID(currentProject, resource));
    bucket = new Bucket(resource).setParent(parentBucket);
    buckets.put(resource, bucket);

    boolean excluded = checkExclusion(resource, parentBucket);
    if (!excluded) {
      Snapshot snapshot =
          persistence.saveResource(
              currentProject, resource, (parentBucket != null ? parentBucket.getResource() : null));
      if (ResourceUtils.isPersistable(resource)
          && !Qualifiers.LIBRARY.equals(resource.getQualifier())) {
        graph.addComponent(resource, snapshot);
      }
    }

    return bucket;
  }
예제 #8
0
 @Override
 public String getSource(Resource resource) {
   return persistence.getSource(resource);
 }
예제 #9
0
 @Override
 public void deleteEvent(Event event) {
   persistence.deleteEvent(event);
 }
예제 #10
0
 @Override
 public List<Event> getEvents(Resource resource) {
   // currently events are not cached in memory
   return persistence.getEvents(resource);
 }
예제 #11
0
 @Override
 public void deleteLink(String key) {
   persistence.deleteLink(currentProject, key);
 }
예제 #12
0
 @Override
 public void addLink(ProjectLink link) {
   persistence.saveLink(currentProject, link);
 }