Package org.sonar.api.resources

Examples of org.sonar.api.resources.ProjectLink


  private void updateLink(SensorContext context, String key, String name, String url) {
    if (StringUtils.isBlank(url)) {
      context.deleteLink(key);
    } else {
      context.saveLink(new ProjectLink(key, name, url));
    }
  }
View Full Code Here


      this.url = url;
    }

    @Override
    public boolean matches(Object o) {
      ProjectLink link = (ProjectLink) o;
      return StringUtils.equals(link.getHref(), url) && StringUtils.equals(link.getKey(), key) && StringUtils.equals(link.getName(), name);
    }
View Full Code Here

  }

  public void saveLink(Project project, ProjectLink link) {
    Snapshot snapshot = resourcePersister.getSnapshotOrFail(project);
    ResourceModel projectDao = session.reattach(ResourceModel.class, snapshot.getResourceId());
    ProjectLink dbLink = projectDao.getProjectLink(link.getKey());
    if (dbLink == null) {
      link.setResource(projectDao);
      projectDao.getProjectLinks().add(link);
      session.save(link);

    } else {
      dbLink.copyFieldsFrom(link);
      session.save(dbLink);
    }
    session.commit();

  }
View Full Code Here

  public void deleteLink(Project project, String linkKey) {
    Snapshot snapshot = resourcePersister.getSnapshot(project);
    if (snapshot != null) {
      ResourceModel model = session.reattach(ResourceModel.class, snapshot.getResourceId());
      ProjectLink dbLink = model.getProjectLink(linkKey);
      if (dbLink != null) {
        session.remove(dbLink);
        model.getProjectLinks().remove(dbLink);
        session.commit();
      }
View Full Code Here

TOP

Related Classes of org.sonar.api.resources.ProjectLink

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.