Search in sources :

Example 11 with DBParam

use of net.java.ao.DBParam in project stashbot by palantir.

the class JobTemplateManager method getDefaultVerifyJob.

public JobTemplate getDefaultVerifyJob() {
    JobTemplate[] jobs = ao.find(JobTemplate.class, Query.select().where("NAME = ?", DEFAULT_VERIFY_JOB_NAME));
    if (jobs.length == 1) {
        return jobs[0];
    }
    // Create the default verify job
    JobTemplate jjt = ao.create(JobTemplate.class, new DBParam("NAME", DEFAULT_VERIFY_JOB_NAME), new DBParam("TEMPLATE_FILE", DEFAULT_VERIFY_JOB_FILE), new DBParam("JOB_TYPE", JobType.VERIFY_COMMIT));
    jjt.save();
    return jjt;
}
Also used : DBParam(net.java.ao.DBParam) JobTemplate(com.palantir.stash.stashbot.persistence.JobTemplate)

Example 12 with DBParam

use of net.java.ao.DBParam in project stashbot by palantir.

the class ConfigurationTest method testFixesUrlEndingInSlash.

@Test
public void testFixesUrlEndingInSlash() throws Exception {
    String url = "http://url.that.ends.in";
    ao.create(JenkinsServerConfiguration.class, new DBParam("NAME", "sometest"), new DBParam("URL", url + "/"), new DBParam("USERNAME", "someuser"), new DBParam("PASSWORD", "somepw"), new DBParam("STASH_USERNAME", "someuser"), new DBParam("STASH_PASSWORD", "somepw"), new DBParam("MAX_VERIFY_CHAIN", 1));
    JenkinsServerConfiguration jsc = cpm.getJenkinsServerConfiguration("sometest");
    Assert.assertEquals(url, jsc.getUrl());
}
Also used : DBParam(net.java.ao.DBParam) JenkinsServerConfiguration(com.palantir.stash.stashbot.persistence.JenkinsServerConfiguration) Test(org.junit.Test)

Example 13 with DBParam

use of net.java.ao.DBParam in project stashbot by palantir.

the class ConfigurationPersistenceImpl method getJenkinsServerConfiguration.

/* (non-Javadoc)
     * @see com.palantir.stash.stashbot.config.ConfigurationPersistenceService#getJenkinsServerConfiguration(java.lang.String)
     */
@Override
public JenkinsServerConfiguration getJenkinsServerConfiguration(String name) throws SQLException {
    if (name == null) {
        name = DEFAULT_JENKINS_SERVER_CONFIG_KEY;
    }
    JenkinsServerConfiguration[] configs = ao.find(JenkinsServerConfiguration.class, Query.select().where("NAME = ?", name));
    if (configs.length == 0) {
        // just use the defaults
        return ao.create(JenkinsServerConfiguration.class, new DBParam("NAME", name));
    }
    String url = configs[0].getUrl();
    if (url.endsWith("/")) {
        url = url.substring(0, url.length() - 1);
        configs[0].setUrl(url);
        configs[0].save();
    }
    return configs[0];
}
Also used : DBParam(net.java.ao.DBParam) JenkinsServerConfiguration(com.palantir.stash.stashbot.persistence.JenkinsServerConfiguration)

Example 14 with DBParam

use of net.java.ao.DBParam in project stash-codesearch-plugin by palantir.

the class SettingsManagerImpl method setRepositorySettings.

@Override
public RepositorySettings setRepositorySettings(Repository repository, String refRegex) {
    String repoId = repository.getProject().getKey() + "^" + repository.getSlug();
    RepositorySettings[] settings;
    synchronized (ao) {
        settings = ao.find(RepositorySettings.class, Query.select().where("REPOSITORY_ID = ?", repoId));
    }
    if (settings.length > 0) {
        settings[0].setRefRegex(refRegex);
        settings[0].save();
        return settings[0];
    }
    synchronized (ao) {
        return ao.create(RepositorySettings.class, new DBParam("REPOSITORY_ID", repoId), new DBParam("REF_REGEX", refRegex));
    }
}
Also used : DBParam(net.java.ao.DBParam)

Example 15 with DBParam

use of net.java.ao.DBParam in project stash-codesearch-plugin by palantir.

the class SettingsManagerImpl method setGlobalSettings.

@Override
public GlobalSettings setGlobalSettings(boolean indexingEnabled, int maxConcurrentIndexing, int maxFileSize, int searchTimeout, String noHighlightExtensions, int maxPreviewLines, int maxMatchLines, int maxFragments, int pageSize, double commitHashBoost, double commitSubjectBoost, double commitBodyBoost, double fileNameBoost) {
    GlobalSettings[] settings;
    synchronized (ao) {
        settings = ao.find(GlobalSettings.class, Query.select().where("GLOBAL_SETTINGS_ID = ?", ID));
    }
    if (settings.length > 0) {
        settings[0].setIndexingEnabled(indexingEnabled);
        settings[0].setMaxConcurrentIndexing(maxConcurrentIndexing);
        settings[0].setMaxFileSize(maxFileSize);
        settings[0].setSearchTimeout(searchTimeout);
        settings[0].setNoHighlightExtensions(noHighlightExtensions);
        settings[0].setMaxPreviewLines(maxPreviewLines);
        settings[0].setMaxMatchLines(maxMatchLines);
        settings[0].setMaxFragments(maxFragments);
        settings[0].setPageSize(pageSize);
        settings[0].setCommitHashBoost(commitHashBoost);
        settings[0].setCommitSubjectBoost(commitSubjectBoost);
        settings[0].setCommitBodyBoost(commitBodyBoost);
        settings[0].setFileNameBoost(fileNameBoost);
        settings[0].save();
        for (SearchUpdater updater : searchUpdaters) {
            updater.refreshConcurrencyLimit();
        }
        return settings[0];
    }
    synchronized (ao) {
        return ao.create(GlobalSettings.class, new DBParam("GLOBAL_SETTINGS_ID", ID), new DBParam("INDEXING_ENABLED", indexingEnabled), new DBParam("MAX_CONCURRENT_INDEXING", maxConcurrentIndexing), new DBParam("MAX_FILE_SIZE", maxFileSize), new DBParam("SEARCH_TIMEOUT", searchTimeout), new DBParam("NO_HIGHLIGHT_EXTENSIONS", noHighlightExtensions), new DBParam("MAX_PREVIEW_LINES", maxPreviewLines), new DBParam("MAX_MATCH_LINES", maxMatchLines), new DBParam("MAX_FRAGMENTS", maxFragments), new DBParam("PAGE_SIZE", pageSize), new DBParam("COMMIT_HASH_BOOST", commitHashBoost), new DBParam("COMMIT_SUBJECT_BOOST", commitSubjectBoost), new DBParam("COMMIT_BODY_BOOST", commitBodyBoost), new DBParam("FILE_NAME_BOOST", fileNameBoost));
    }
}
Also used : DBParam(net.java.ao.DBParam) SearchUpdater(com.palantir.stash.codesearch.updater.SearchUpdater)

Aggregations

DBParam (net.java.ao.DBParam)16 JobTemplate (com.palantir.stash.stashbot.persistence.JobTemplate)4 JenkinsServerConfiguration (com.palantir.stash.stashbot.persistence.JenkinsServerConfiguration)3 RepositoryConfiguration (com.palantir.stash.stashbot.persistence.RepositoryConfiguration)3 PullRequestMetadata (com.palantir.stash.stashbot.persistence.PullRequestMetadata)2 SearchUpdater (com.palantir.stash.codesearch.updater.SearchUpdater)1 JobType (com.palantir.stash.stashbot.jobtemplate.JobType)1 JobMapping (com.palantir.stash.stashbot.persistence.JobMapping)1 Test (org.junit.Test)1