net.nemerosa.ontrack.model.structure.Branch.id()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(11.6k)|赞(0)|评价(0)|浏览(128)

本文整理了Java中net.nemerosa.ontrack.model.structure.Branch.id()方法的一些代码示例,展示了Branch.id()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Branch.id()方法的具体详情如下:
包路径:net.nemerosa.ontrack.model.structure.Branch
类名称:Branch
方法名:id

Branch.id介绍

暂无

代码示例

代码示例来源:origin: net.nemerosa.ontrack/ontrack-service

@Override
public Branch copy(Branch targetBranch, Branch sourceBranch, Function<String, String> replacementFn, SyncPolicy syncPolicy) {
  // If same branch, rejects
  if (sourceBranch.id() == targetBranch.id()) {
    throw new CannotCopyItselfException();
  }
  // Checks the rights on the target branch
  securityService.checkProjectFunction(targetBranch, BranchEdit.class);
  // Now, we can work in a secure context
  securityService.asAdmin(() -> doCopy(sourceBranch, targetBranch, replacementFn, syncPolicy));
  // OK
  return targetBranch;
}

代码示例来源:origin: net.nemerosa.ontrack/ontrack-extension-scm

@JsonIgnore
public boolean isSameBranch() {
  return getFrom().getBuild().getBranch().id() == getTo().getBuild().getBranch().id();
}

代码示例来源:origin: net.nemerosa.ontrack/ontrack-repository-impl

@Override
public int getBuildCount(Branch branch) {
  return getNamedParameterJdbcTemplate().queryForObject(
      "SELECT COUNT(ID) FROM BUILDS WHERE BRANCHID = :branchId",
      params("branchId", branch.id()),
      Integer.class
  );
}

代码示例来源:origin: net.nemerosa.ontrack/ontrack-repository-impl

@Override
public Build getLastBuildForBranch(Branch branch) {
  return getFirstItem(
      "SELECT * FROM BUILDS WHERE BRANCHID = :branch ORDER BY ID DESC LIMIT 1",
      params("branch", branch.id()),
      (rs, num) -> toBuild(rs, (id) -> branch)
  );
}

代码示例来源:origin: net.nemerosa.ontrack/ontrack-repository-impl

@Override
public void builds(Branch branch, Predicate<Build> buildPredicate, BuildSortDirection sortDirection) {
  String order = sortDirection == BuildSortDirection.FROM_NEWEST ? "DESC" : "ASC";
  getNamedParameterJdbcTemplate().execute(
      "SELECT * FROM BUILDS WHERE BRANCHID = :branchId ORDER BY ID " + order,
      params("branchId", branch.id()),
      ps -> {
        ResultSet rs = ps.executeQuery();
        boolean goingOn = true;
        while (rs.next() && goingOn) {
          // Gets the builds
          Build build = toBuild(
              rs,
              id -> branch
          );
          // Dealing with this build
          goingOn = buildPredicate.test(build);
        }
        return null;
      }
  );
}

代码示例来源:origin: net.nemerosa.ontrack/ontrack-repository-impl

@Override
public Optional<Build> getBuildByName(String project, String branch, String build) {
  return getBranchByName(project, branch).map(b -> getFirstItem(
      "SELECT * FROM BUILDS WHERE NAME = :name AND BRANCHID = :branchId",
      params("name", build).addValue("branchId", b.id()),
      (rs, rowNum) -> toBuild(rs, this::getBranch)
  ));
}

代码示例来源:origin: net.nemerosa.ontrack/ontrack-repository-impl

@Override
public Optional<ValidationStamp> getValidationStampByName(Branch branch, String validationStamp) {
  return getOptional(
      "SELECT * FROM VALIDATION_STAMPS WHERE NAME = :name AND BRANCHID = :branch",
      params("name", validationStamp).addValue("branch", branch.id()),
      (rs, rowNum) -> toValidationStamp(rs, id -> branch)
  );
}

代码示例来源:origin: net.nemerosa.ontrack/ontrack-repository-impl

@Override
public Optional<PromotionLevel> getPromotionLevelByName(Branch branch, String promotionLevel) {
  return getOptional(
      "SELECT * FROM PROMOTION_LEVELS WHERE BRANCHID = :branch AND NAME = :name",
      params("name", promotionLevel).addValue("branch", branch.id()),
      (rs, rowNum) -> toPromotionLevel(rs, id -> branch)
  );
}

代码示例来源:origin: net.nemerosa.ontrack/ontrack-repository-impl

@Override
public List<ValidationStampFilter> getBranchValidationStampFilters(Branch branch) {
  return getNamedParameterJdbcTemplate().query(
      "SELECT * FROM VALIDATION_STAMP_FILTERS WHERE PROJECT IS NULL AND BRANCH = :branch",
      params("branch", branch.id()),
      (ResultSet rs, int rowNum) -> toValidationStampFilter(rs, pid -> null, bid -> branch)
  );
}

代码示例来源:origin: net.nemerosa.ontrack/ontrack-extension-artifactory

throw new IllegalStateException(String.format("Cannot find sync. property on branch %d", branch.id()));

代码示例来源:origin: net.nemerosa.ontrack/ontrack-repository-impl

@Override
public Optional<Build> getPreviousBuild(Build build) {
  return getOptional(
      "SELECT * FROM BUILDS WHERE BRANCHID = :branch AND ID < :id ORDER BY ID DESC LIMIT 1",
      params("branch", build.getBranch().id()).addValue("id", build.id()),
      (rs, rowNum) -> toBuild(rs, this::getBranch)
  );
}

代码示例来源:origin: net.nemerosa.ontrack/ontrack-repository-impl

@Override
public Optional<Build> getNextBuild(Build build) {
  return getOptional(
      "SELECT * FROM BUILDS WHERE BRANCHID = :branch AND ID > :id ORDER BY ID ASC LIMIT 1",
      params("branch", build.getBranch().id()).addValue("id", build.id()),
      (rs, rowNum) -> toBuild(rs, this::getBranch)
  );
}

代码示例来源:origin: net.nemerosa.ontrack/ontrack-extension-svn

@Override
@Transactional
public SVNChangeLog changeLog(BuildDiffRequest request) {
  try (Transaction ignored = transactionService.start()) {
    // Gets the two builds
    Build buildFrom = structureService.getBuild(request.getFrom());
    Build buildTo = structureService.getBuild(request.getTo());
    // Ordering of builds
    if (buildFrom.id() > buildTo.id()) {
      Build t = buildFrom;
      buildFrom = buildTo;
      buildTo = t;
    }
    // Gets the two branches, for each build
    Branch branchFrom = buildFrom.getBranch();
    Branch branchTo = buildTo.getBranch();
    // Checks the branch is the same
    if (branchFrom.id() != branchTo.id()) {
      throw new SVNChangeLogDifferentBranchException();
    }
    SVNRepository svnRepository = getSVNRepository(branchFrom);
    return new SVNChangeLog(
        UUID.randomUUID().toString(),
        branchFrom.getProject(),
        svnRepository,
        getSCMBuildView(svnRepository, buildFrom.getId()),
        getSCMBuildView(svnRepository, buildTo.getId())
    );
  }
}

代码示例来源:origin: net.nemerosa.ontrack/ontrack-repository-impl

@Override
public Optional<ValidationStampFilter> getValidationStampFilterByName(Branch branch, String name) {
  // Branch first
  Optional<ValidationStampFilter> o = getOptional(
      "SELECT * FROM VALIDATION_STAMP_FILTERS WHERE PROJECT IS NULL AND BRANCH = :branch AND NAME = :name",
      params("branch", branch.id()).addValue("name", name),
      (ResultSet rs, int rowNum) -> toValidationStampFilter(rs, pid -> null, bid -> branch)
  );
  // ... then project
  if (!o.isPresent()) {
    o = getOptional(
        "SELECT * FROM VALIDATION_STAMP_FILTERS WHERE PROJECT = :project AND BRANCH IS NULL AND NAME = :name",
        params("project", branch.getProject().id()).addValue("name", name),
        (ResultSet rs, int rowNum) -> toValidationStampFilter(rs, pid -> branch.getProject(), bid -> null)
    );
  }
  // ... the global
  if (!o.isPresent()) {
    o = getOptional(
        "SELECT * FROM VALIDATION_STAMP_FILTERS WHERE PROJECT IS NULL AND BRANCH IS NULL AND NAME = :name",
        params("name", name),
        (ResultSet rs, int rowNum) -> toValidationStampFilter(rs, pid -> null, bid -> null)
    );
  }
  // OK
  return o;
}

代码示例来源:origin: net.nemerosa.ontrack/ontrack-repository-impl

@Override
public void saveBranch(Branch branch) {
  // Update
  try {
    getNamedParameterJdbcTemplate().update(
        "UPDATE BRANCHES SET NAME = :name, DESCRIPTION = :description, DISABLED = :disabled WHERE ID = :id",
        params("name", branch.getName())
            .addValue("description", branch.getDescription())
            .addValue("disabled", branch.isDisabled())
            .addValue("id", branch.id())
    );
  } catch (DuplicateKeyException ex) {
    throw new BranchNameAlreadyDefinedException(branch.getName());
  }
}

代码示例来源:origin: net.nemerosa.ontrack/ontrack-repository-impl

@Override
public PromotionLevel newPromotionLevel(PromotionLevel promotionLevel) {
  // Creation
  try {
    // Order nb = max + 1
    Integer orderNbValue = getFirstItem(
        "SELECT MAX(ORDERNB) FROM promotion_levels WHERE BRANCHID = :branchId",
        params("branchId", promotionLevel.getBranch().id()),
        Integer.class
    );
    int orderNb = orderNbValue != null ? orderNbValue + 1 : 0;
    // Insertion
    int id = dbCreate(
        "INSERT INTO PROMOTION_LEVELS(BRANCHID, NAME, DESCRIPTION, ORDERNB, CREATION, CREATOR) VALUES (:branchId, :name, :description, :orderNb, :creation, :creator)",
        params("name", promotionLevel.getName())
            .addValue("description", promotionLevel.getDescription())
            .addValue("branchId", promotionLevel.getBranch().id())
            .addValue("orderNb", orderNb)
            .addValue("creation", dateTimeForDB(promotionLevel.getSignature().getTime()))
            .addValue("creator", promotionLevel.getSignature().getUser().getName())
    );
    return promotionLevel.withId(id(id));
  } catch (DuplicateKeyException ex) {
    throw new PromotionLevelNameAlreadyDefinedException(promotionLevel.getName());
  }
}

代码示例来源:origin: net.nemerosa.ontrack/ontrack-repository-impl

@Override
public void saveValidationStampFilter(ValidationStampFilter filter) {
  checkUnicity(filter);
  getNamedParameterJdbcTemplate().update(
      "UPDATE VALIDATION_STAMP_FILTERS SET NAME = :name, PROJECT = :project, BRANCH = :branch, VSNAMES = :vsNames WHERE ID = :id",
      params("name", filter.getName())
          .addValue("project", filter.getProject() != null ? filter.getProject().id() : null)
          .addValue("branch", filter.getBranch() != null ? filter.getBranch().id() : null)
          .addValue("vsNames", saveVsNames(filter.getVsNames()))
          .addValue("id", filter.id())
  );
}

代码示例来源:origin: net.nemerosa.ontrack/ontrack-repository-impl

@Override
public ValidationStampFilter newValidationStampFilter(ValidationStampFilter filter) {
  // Check unicity
  checkUnicity(filter);
  // Creation
  int id = dbCreate(
      "INSERT INTO VALIDATION_STAMP_FILTERS(NAME, PROJECT, BRANCH, VSNAMES) VALUES (:name, :project, :branch, :vsNames)",
      params("name", filter.getName())
          .addValue("project", filter.getProject() != null ? filter.getProject().id() : null)
          .addValue("branch", filter.getBranch() != null ? filter.getBranch().id() : null)
          .addValue("vsNames", saveVsNames(filter.getVsNames()))
  );
  // Returns with ID
  return filter.withId(id(id));
}

代码示例来源:origin: net.nemerosa.ontrack/ontrack-repository-impl

@Override
public Build newBuild(Build build) {
  // Creation
  try {
    int id = dbCreate(
        "INSERT INTO BUILDS(BRANCHID, NAME, DESCRIPTION, CREATION, CREATOR) VALUES (:branchId, :name, :description, :creation, :creator)",
        params("name", build.getName())
            .addValue("description", build.getDescription())
            .addValue("branchId", build.getBranch().id())
            .addValue("creation", dateTimeForDB(build.getSignature().getTime()))
            .addValue("creator", build.getSignature().getUser().getName())
    );
    return build.withId(id(id));
  } catch (DuplicateKeyException ex) {
    throw new BuildNameAlreadyDefinedException(build.getName());
  }
}

代码示例来源:origin: net.nemerosa.ontrack/ontrack-repository-impl

@Override
public ValidationStamp newValidationStamp(ValidationStamp validationStamp) {
  // Creation
  try {
    // Order nb = max + 1
    Integer orderNbValue = getFirstItem(
        "SELECT MAX(ORDERNB) FROM VALIDATION_STAMPS WHERE BRANCHID = :branchId",
        params("branchId", validationStamp.getBranch().id()),
        Integer.class
    );
    int orderNb = orderNbValue != null ? orderNbValue + 1 : 0;
    // Insertion
    int id = dbCreate(
        "INSERT INTO VALIDATION_STAMPS(BRANCHID, NAME, DESCRIPTION, ORDERNB, CREATION, CREATOR, DATA_TYPE_ID, DATA_TYPE_CONFIG) VALUES (:branchId, :name, :description, :orderNb, :creation, :creator, :dataTypeId, CAST(:dataTypeConfig AS JSONB))",
        params("name", validationStamp.getName())
            .addValue("description", validationStamp.getDescription())
            .addValue("branchId", validationStamp.getBranch().id())
            .addValue("orderNb", orderNb)
            .addValue("creation", dateTimeForDB(validationStamp.getSignature().getTime()))
            .addValue("creator", validationStamp.getSignature().getUser().getName())
            .addValue("dataTypeId", validationStamp.getDataType() != null ? validationStamp.getDataType().getDescriptor().getId() : null)
            .addValue("dataTypeConfig", validationStamp.getDataType() != null ? writeJson(validationStamp.getDataType().getConfig()) : null)
    );
    return validationStamp.withId(id(id));
  } catch (DuplicateKeyException ex) {
    throw new ValidationStampNameAlreadyDefinedException(validationStamp.getName());
  }
}

相关文章