コード例 #1
0
  public void renameProfile(int profileId, String newName, UserSession userSession) {
    checkPermission(userSession);
    DbSession session = myBatis.openSession(false);
    try {
      QualityProfileDto profileDto = findNotNull(profileId, session);
      String oldName = profileDto.getName();

      QProfile profile = QProfile.from(profileDto);
      if (!oldName.equals(newName)) {
        checkNotAlreadyExists(newName, profile.language(), session);
      }
      profileDto.setName(newName);
      dao.update(session, profileDto);

      List<QProfile> children = profileLookup.children(profile, session);
      for (QProfile child : children) {
        dao.update(session, child.setParent(newName).toDto());
      }
      propertiesDao.updateProperties(
          PROFILE_PROPERTY_PREFIX + profile.language(), oldName, newName, session);

      session.commit();
    } finally {
      MyBatis.closeQuietly(session);
    }
  }
コード例 #2
0
 public QProfile newProfile(
     String name,
     String language,
     @Nullable String parent,
     boolean failIfAlreadyExists,
     UserSession userSession,
     DbSession session) {
   checkPermission(userSession);
   if (failIfAlreadyExists) {
     checkNotAlreadyExists(name, language, session);
   }
   QualityProfileDto dto =
       new QualityProfileDto()
           .setName(name)
           .setLanguage(language)
           .setParent(parent)
           .setVersion(1)
           .setUsed(false);
   dao.insert(session, dto);
   return QProfile.from(dto);
 }