}
// copied from https://github.com/elastic/elasticsearch/blob/v2.3.3/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java
- private void initBootstrap() {
+ private static void initBootstrap() {
// init lucene random seed. it will use /dev/urandom where available:
StringHelper.randomId();
}
* @param toInclusive starts from 1, must be greater than or equal param {@code from}
*/
public Optional<Iterable<DbFileSources.Line>> getLines(DbSession dbSession, String fileUuid, int from, int toInclusive) {
- return getLines(dbSession, fileUuid, from, toInclusive, Functions.<DbFileSources.Line>identity());
+ return getLines(dbSession, fileUuid, from, toInclusive, Functions.identity());
}
/**
return Optional.absent();
}
DbFileSources.Data data = dto.getSourceData();
- return Optional.of((Iterable<E>) FluentIterable.from(data.getLinesList())
+ return Optional.of(FluentIterable.from(data.getLinesList())
.filter(new IsGreaterOrEqualThanLine(from))
.limit(toInclusive - from + 1)
.transform(function));
}
private Function<DbFileSources.Line, String> lineToHtml() {
- return new Function<DbFileSources.Line, String>() {
- @Override
- public String apply(@Nonnull DbFileSources.Line line) {
- return htmlDecorator.getDecoratedSourceAsHtml(line.getSource(), line.getHighlighting(), line.getSymbols());
- }
- };
+ return line -> htmlDecorator.getDecoratedSourceAsHtml(line.getSource(), line.getHighlighting(), line.getSymbols());
}
private enum LineToRaw implements Function<DbFileSources.Line, String> {
*/
package org.sonar.server.test.index;
+import static org.sonar.server.test.index.TestIndexDefinition.FIELD_FILE_UUID;
+import static org.sonar.server.test.index.TestIndexDefinition.FIELD_UPDATED_AT;
+import static org.sonar.server.test.index.TestIndexDefinition.INDEX;
+import static org.sonar.server.test.index.TestIndexDefinition.TYPE;
+
import java.util.Iterator;
import javax.annotation.Nullable;
import org.elasticsearch.action.search.SearchRequestBuilder;
-import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.index.query.QueryBuilders;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.server.es.EsClient;
import org.sonar.server.source.index.FileSourcesUpdaterHelper;
-import static org.sonar.server.test.index.TestIndexDefinition.FIELD_FILE_UUID;
-import static org.sonar.server.test.index.TestIndexDefinition.FIELD_UPDATED_AT;
-import static org.sonar.server.test.index.TestIndexDefinition.INDEX;
-import static org.sonar.server.test.index.TestIndexDefinition.TYPE;
-
/**
* Add to Elasticsearch index {@link TestIndexDefinition} the rows of
* db table FILE_SOURCES of type TEST that are not indexed yet
public void index(final String projectUuid) {
deleteByProject(projectUuid);
- super.index(new IndexerTask() {
- @Override
- public long index(long lastUpdatedAt) {
- return doIndex(lastUpdatedAt, projectUuid);
- }
- });
+ super.index(lastUpdatedAt -> doIndex(lastUpdatedAt, projectUuid));
}
public long index(Iterator<FileSourcesUpdaterHelper.Row> dbRows) {
bulk.start();
while (dbRows.hasNext()) {
FileSourcesUpdaterHelper.Row row = dbRows.next();
- for (UpdateRequest updateRequest : row.getUpdateRequests()) {
- bulk.add(updateRequest);
- }
+ row.getUpdateRequests().forEach(bulk::add);
maxUpdatedAt = Math.max(maxUpdatedAt, row.getUpdatedAt());
}
bulk.stop();
import javax.annotation.Nullable;
import org.sonar.db.Dao;
import org.sonar.db.DbSession;
-import org.sonar.db.MyBatis;
import org.sonar.db.RowNotFoundException;
import static com.google.common.collect.FluentIterable.from;
public class IssueDao implements Dao {
- private final MyBatis mybatis;
-
- public IssueDao(MyBatis mybatis) {
- this.mybatis = mybatis;
- }
-
public Optional<IssueDto> selectByKey(DbSession session, String key) {
return Optional.fromNullable(mapper(session).selectByKey(key));
}