com.credibledoc.log.labelizer.github.GithubRepoRepository Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of log-labelizer Show documentation
Show all versions of log-labelizer Show documentation
This library is used for finding date - time and thread labels in log lines.
package com.credibledoc.log.labelizer.github;
import com.credibledoc.log.labelizer.datastore.DatastoreService;
import dev.morphia.Datastore;
import java.util.List;
/**
* Data Access Object for the {@link GithubRepo} records.
*
* @author Kyrylo Semenko
*/
public class GithubRepoRepository {
/** Refers to a {@link DatastoreService#getDatastore()} object */
private Datastore datastore;
/**
* Singleton.
*/
private static GithubRepoRepository instance;
/**
* @return The {@link GithubRepoRepository} singleton.
*/
public static GithubRepoRepository getInstance() {
if (instance == null) {
instance = new GithubRepoRepository();
instance.datastore = DatastoreService.getInstance().getDatastore();
}
return instance;
}
/**
* @return 'true' if the database contains a {@link GithubRepo} object with such {@link GithubRepo#getFullName()}.
* @param repoFullName the filter
*/
public boolean contains(String repoFullName) {
return datastore.createQuery(GithubRepo.class)
.field(GithubRepo.FULL_NAME)
.equal(repoFullName).count() > 0;
}
/**
* Save entities to the database.
* @param githubRepos entities to be saved
*/
public void save(List githubRepos) {
datastore.save(githubRepos);
}
/**
* @return All documents from the {@link GithubRepo} collection where {@link GithubRepo#getVisited()} is 'null'.
*/
public List selectNotVisited() {
return datastore.find(GithubRepo.class).filter(GithubRepo.VISITED, null).find().toList();
}
}