use of net.java.ao.DBParam in project stashbot by palantir.
the class ConfigurationPersistenceImpl method setRepositoryConfigurationForRepository.
/* (non-Javadoc)
* @see com.palantir.stash.stashbot.config.ConfigurationPersistenceService#setRepositoryConfigurationForRepository(com.atlassian.stash.repository.Repository, boolean, java.lang.String, java.lang.String, boolean, java.lang.String, java.lang.String, java.lang.String, boolean, java.lang.String, java.lang.String, java.lang.String, boolean, boolean, java.lang.String, boolean, java.lang.String, java.lang.Integer, com.palantir.stash.stashbot.config.EmailSettings, boolean, java.lang.Boolean)
*/
@Override
public void setRepositoryConfigurationForRepository(Repository repo, boolean isCiEnabled, String verifyBranchRegex, String verifyBuildCommand, boolean isVerifyPinned, String verifyLabel, String publishBranchRegex, String publishBuildCommand, boolean isPublishPinned, String publishLabel, String prebuildCommand, String jenkinsServerName, boolean rebuildOnUpdate, boolean isJunitEnabled, String junitPath, boolean artifactsEnabled, String artifactsPath, Integer maxVerifyChain, EmailSettings emailSettings, boolean strictVerifyMode, Boolean preserveJenkinsJobConfig) throws SQLException, IllegalArgumentException {
if (jenkinsServerName == null) {
jenkinsServerName = DEFAULT_JENKINS_SERVER_CONFIG_KEY;
}
validateNameExists(jenkinsServerName);
RepositoryConfiguration[] repos = ao.find(RepositoryConfiguration.class, Query.select().where("REPO_ID = ?", repo.getId()));
if (repos.length == 0) {
log.info("Creating repository configuration for id: " + repo.getId().toString());
RepositoryConfiguration rc = ao.create(RepositoryConfiguration.class, new DBParam("REPO_ID", repo.getId()), new DBParam("CI_ENABLED", isCiEnabled), new DBParam("VERIFY_BRANCH_REGEX", verifyBranchRegex), new DBParam("VERIFY_BUILD_COMMAND", verifyBuildCommand), new DBParam("VERIFY_PINNED", isVerifyPinned), new DBParam("VERIFY_LABEL", verifyLabel), new DBParam("PUBLISH_BRANCH_REGEX", publishBranchRegex), new DBParam("PUBLISH_BUILD_COMMAND", publishBuildCommand), new DBParam("PUBLISH_PINNED", isPublishPinned), new DBParam("PUBLISH_LABEL", publishLabel), new DBParam("PREBUILD_COMMAND", prebuildCommand), new DBParam("JENKINS_SERVER_NAME", jenkinsServerName), new DBParam("JUNIT_ENABLED", isJunitEnabled), new DBParam("JUNIT_PATH", junitPath), new DBParam("ARTIFACTS_ENABLED", artifactsEnabled), new DBParam("ARTIFACTS_PATH", artifactsPath), new DBParam("REBUILD_ON_TARGET_UPDATE", rebuildOnUpdate), new DBParam("EMAIL_NOTIFICATIONS_ENABLED", emailSettings.getEmailNotificationsEnabled()), new DBParam("EMAIL_FOR_EVERY_UNSTABLE_BUILD", emailSettings.getEmailForEveryUnstableBuild()), new DBParam("EMAIL_PER_MODULE_EMAIL", emailSettings.getEmailPerModuleEmail()), new DBParam("EMAIL_RECIPIENTS", emailSettings.getEmailRecipients()), new DBParam("EMAIL_SEND_TO_INDIVIDUALS", emailSettings.getEmailSendToIndividuals()), new DBParam("STRICT_VERIFY_MODE", strictVerifyMode), new DBParam("PRESERVE_JENKINS_JOB_CONFIG", preserveJenkinsJobConfig));
if (maxVerifyChain != null) {
rc.setMaxVerifyChain(maxVerifyChain);
}
rc.save();
// default the 3 base job types to enabled
setJobTypeStatusMapping(rc, JobType.VERIFY_COMMIT, true);
setJobTypeStatusMapping(rc, JobType.VERIFY_PR, true);
setJobTypeStatusMapping(rc, JobType.PUBLISH, true);
return;
}
RepositoryConfiguration foundRepo = repos[0];
foundRepo.setCiEnabled(isCiEnabled);
foundRepo.setVerifyBranchRegex(verifyBranchRegex);
foundRepo.setVerifyBuildCommand(verifyBuildCommand);
foundRepo.setVerifyPinned(isVerifyPinned);
foundRepo.setVerifyLabel(verifyLabel);
foundRepo.setPublishBranchRegex(publishBranchRegex);
foundRepo.setPublishBuildCommand(publishBuildCommand);
foundRepo.setPublishPinned(isPublishPinned);
foundRepo.setPublishLabel(publishLabel);
foundRepo.setPrebuildCommand(prebuildCommand);
foundRepo.setJenkinsServerName(jenkinsServerName);
foundRepo.setJunitEnabled(isJunitEnabled);
foundRepo.setJunitPath(junitPath);
foundRepo.setArtifactsEnabled(artifactsEnabled);
foundRepo.setArtifactsPath(artifactsPath);
foundRepo.setRebuildOnTargetUpdate(rebuildOnUpdate);
if (maxVerifyChain != null) {
foundRepo.setMaxVerifyChain(maxVerifyChain);
}
foundRepo.setEmailNotificationsEnabled(emailSettings.getEmailNotificationsEnabled());
foundRepo.setEmailForEveryUnstableBuild(emailSettings.getEmailForEveryUnstableBuild());
foundRepo.setEmailPerModuleEmail(emailSettings.getEmailPerModuleEmail());
foundRepo.setEmailRecipients(emailSettings.getEmailRecipients());
foundRepo.setEmailSendToIndividuals(emailSettings.getEmailSendToIndividuals());
foundRepo.setStrictVerifyMode(strictVerifyMode);
foundRepo.setPreserveJenkinsJobConfig(preserveJenkinsJobConfig);
foundRepo.save();
}
Aggregations