Search in sources :

Example 1 with Data

use of com.searchcode.app.dao.Data in project searchcode-server by boyter.

the class CommonRouteService method getMaxLineDepth.

public static double getMaxLineDepth() {
    if (App.ISCOMMUNITY) {
        return Double.parseDouble(Values.DEFAULTMAXLINEDEPTH);
    }
    Data data = Singleton.getData();
    String matchLines = data.getDataByName(Values.MAXLINEDEPTH);
    if (matchLines == null) {
        data.saveData(Values.MAXLINEDEPTH, Values.DEFAULTMAXLINEDEPTH);
        matchLines = Values.DEFAULTMAXLINEDEPTH;
    }
    return Double.parseDouble(matchLines);
}
Also used : Data(com.searchcode.app.dao.Data)

Example 2 with Data

use of com.searchcode.app.dao.Data in project searchcode-server by boyter.

the class CommonRouteService method owaspAdvisoriesEnabled.

public static boolean owaspAdvisoriesEnabled() {
    if (App.ISCOMMUNITY) {
        return false;
    }
    Data data = Singleton.getData();
    Boolean owaspEnabled = Boolean.parseBoolean(data.getDataByName(Values.OWASPENABLED));
    if (owaspEnabled == null) {
        data.saveData(Values.OWASPENABLED, "false");
        owaspEnabled = false;
    }
    return owaspEnabled;
}
Also used : Data(com.searchcode.app.dao.Data)

Example 3 with Data

use of com.searchcode.app.dao.Data in project searchcode-server by boyter.

the class CommonRouteService method getAverageSalary.

public static double getAverageSalary() {
    if (App.ISCOMMUNITY) {
        return Double.parseDouble(Values.DEFAULTAVERAGESALARY);
    }
    Data data = Singleton.getData();
    String salary = data.getDataByName(Values.AVERAGESALARY);
    if (salary == null) {
        data.saveData(Values.AVERAGESALARY, Values.DEFAULTAVERAGESALARY);
        salary = Values.DEFAULTAVERAGESALARY;
    }
    return Double.parseDouble(salary);
}
Also used : Data(com.searchcode.app.dao.Data)

Example 4 with Data

use of com.searchcode.app.dao.Data in project searchcode-server by boyter.

the class DataServiceTest method testTestRemoveFromPersistent.

public void testTestRemoveFromPersistent() {
    Data mockData = Mockito.mock(Data.class);
    DataService dataService = new DataService(mockData);
    when(mockData.getDataByName(Values.PERSISTENT_DELETE_QUEUE, "[]")).thenReturn("[]");
    dataService.removeFromPersistentDelete("test");
    verify(mockData, times(1)).saveData(any(), any());
}
Also used : Data(com.searchcode.app.dao.Data)

Example 5 with Data

use of com.searchcode.app.dao.Data in project searchcode-server by boyter.

the class StatsServiceTest method testIncrementSearchCount.

public void testIncrementSearchCount() {
    Data dataMock = Mockito.mock(Data.class);
    when(dataMock.getDataByName(Values.CACHE_TOTAL_SEARCH, "0")).thenReturn(null);
    StatsService statsService = new StatsService(dataMock);
    statsService.incrementSearchCount();
    verify(dataMock, times(1)).saveData(Values.CACHE_TOTAL_SEARCH, "1");
}
Also used : Data(com.searchcode.app.dao.Data)

Aggregations

Data (com.searchcode.app.dao.Data)22 Repo (com.searchcode.app.dao.Repo)4 CodeMatcher (com.searchcode.app.service.CodeMatcher)3 RepoResult (com.searchcode.app.model.RepoResult)2 CodeSearcher (com.searchcode.app.service.CodeSearcher)2 ModelAndView (spark.ModelAndView)2 Request (spark.Request)2 Gson (com.google.gson.Gson)1 App (com.searchcode.app.App)1 Values (com.searchcode.app.config.Values)1 Api (com.searchcode.app.dao.Api)1 com.searchcode.app.dto (com.searchcode.app.dto)1 CodeResult (com.searchcode.app.dto.CodeResult)1 SearchResult (com.searchcode.app.dto.SearchResult)1 Singleton (com.searchcode.app.service.Singleton)1 TimeCodeSearcher (com.searchcode.app.service.TimeCodeSearcher)1 CodeRouteService (com.searchcode.app.service.route.CodeRouteService)1 CommonRouteService (com.searchcode.app.service.route.CommonRouteService)1 com.searchcode.app.util (com.searchcode.app.util)1 Properties (com.searchcode.app.util.Properties)1