Documentation ¶
Overview ¶
Package db provides an interface to mgo which allows us to store and retrieve Impendulo data from mongodb.
Index ¶
- Constants
- Variables
- func Add(n string, i interface{}) error
- func AddFileResult(fid bson.ObjectId, n string, v interface{}) error
- func AddGridFile(id, data interface{}) error
- func AddJPFConfig(cfg *jpf.Config) error
- func AddJUnitTest(t *junit.Test) error
- func AddMakefile(mf *mk.Makefile) error
- func AddPMDRules(r *pmd.Rules) error
- func AddResult(r result.Tooler, n string) error
- func AddUsers(users ...*user.User) error
- func Charter(m, sl bson.M) (result.Charter, error)
- func Charters(fid bson.ObjectId) ([]result.Charter, error)
- func CheckstyleResult(m, sl bson.M) (*checkstyle.Result, error)
- func CloneCollection(o, c string) error
- func CloneData(o string) error
- func Close()
- func Coder(m, sl bson.M) (result.Coder, error)
- func Collections(db string) ([]string, error)
- func Contains(n string, m interface{}) bool
- func CopyDB(f, t string) error
- func Count(n string, m interface{}) (int, error)
- func Databases() ([]string, error)
- func DeleteDB(db string) error
- func Displayer(m, sl bson.M) (result.Displayer, error)
- func File(m, sl interface{}) (*project.File, error)
- func FileCount(sid bson.ObjectId, t project.Type) (int, error)
- func FileNames(m interface{}) ([]string, error)
- func FileResultId(sid bson.ObjectId, fname, rtipe, rname string) (bson.ObjectId, error)
- func Files(m, sl interface{}, limit int, sort ...string) ([]*project.File, error)
- func FindbugsResult(m, sl bson.M) (*findbugs.Result, error)
- func FirstFile(m, sl interface{}) (*project.File, error)
- func GCCResult(m, sl bson.M) (*gcc.Result, error)
- func GridFile(id, ret interface{}) error
- func HasGridFile(r result.Tooler, sl bson.M) bool
- func JPFConfig(m, sl interface{}) (*jpf.Config, error)
- func JPFResult(m, sl bson.M) (*jpf.Result, error)
- func JUnitResult(m, sl bson.M) (*junit.Result, error)
- func JUnitTest(m, sl interface{}) (*junit.Test, error)
- func JUnitTests(m, sl interface{}) ([]*junit.Test, error)
- func JacocoResult(m, sl bson.M) (*jacoco.Result, error)
- func JavacResult(m, sl bson.M) (*javac.Result, error)
- func LastFile(m, sl interface{}) (*project.File, error)
- func Makefile(m, sl interface{}) (*mk.Makefile, error)
- func PMDResult(m, sl bson.M) (*pmd.Result, error)
- func PMDRules(m, sl interface{}) (*pmd.Rules, error)
- func Project(m, sl interface{}) (*project.Project, error)
- func ProjectFileNames(id bson.ObjectId) ([]string, error)
- func ProjectName(i interface{}) (string, error)
- func ProjectResults(pid bson.ObjectId) []string
- func ProjectUsernames(pid bson.ObjectId) ([]string, error)
- func Projects(m, sl interface{}, sort ...string) ([]*project.Project, error)
- func RemoveById(n string, id interface{}) error
- func RemoveFileById(id interface{}) error
- func RemoveProjectById(id interface{}) error
- func RemoveSubmissionById(id interface{}) error
- func RemoveUserById(id string) error
- func RenameUser(o, n string) error
- func ResultNames(sid bson.ObjectId, fname string) (map[string]map[string][]interface{}, error)
- func Session() (*mgo.Session, error)
- func Setup(c string) error
- func Skeleton(m, sl interface{}) (*project.Skeleton, error)
- func Skeletons(m, sl interface{}, sort ...string) ([]*project.Skeleton, error)
- func Snapshots(sid bson.ObjectId, n string) ([]*project.File, error)
- func Submission(m, sl interface{}) (*project.Submission, error)
- func Submissions(m, sl interface{}, sort ...string) ([]*project.Submission, error)
- func Tooler(m, sl bson.M) (result.Tooler, error)
- func TypeCounts(id interface{}) []int
- func Update(n string, m, c interface{}) error
- func UpdateAll(n string, m, c interface{}) error
- func UpdateTime(sub *project.Submission) error
- func User(id string) (*user.User, error)
- func UserResults(u string) []string
- func Usernames(m interface{}) ([]string, error)
- func Users(m interface{}, sort ...string) ([]*user.User, error)
- type AddError
- type FileInfo
- type GetError
- type RemoveError
- type TypeHolder
Constants ¶
const ( //Mongodb collection name. USERS = "users" SUBMISSIONS = "submissions" FILES = "files" RESULTS = "results" TESTS = "tests" PROJECTS = "projects" SKELETONS = "skeletons" JPF = "jpf" PMD = "pmd" MAKE = "make" //Mongodb command SET = "$set" OR = "$or" AND = "$and" NOT = "$not" NOR = "$nor" LT = "$lt" LTE = "$lte" GT = "$gt" GTE = "$gte" IN = "$in" NE = "$ne" NIN = "$nin" EXISTS = "$exists" ISTYPE = "$type" //Mongodb connection and db names ADDRESS = "mongodb://localhost/" DEFAULT_DB = "impendulo" DEBUG_DB = "impendulo_debug" TEST_DB = "impendulo_test" BACKUP_DB = "impendulo_backup" DEFAULT_CONN = ADDRESS + DEFAULT_DB DEBUG_CONN = "mongodb://localhost/impendulo_debug" TEST_CONN = "mongodb://localhost/impendulo_test" //Field names TARGET = "target" ID = "_id" PROJECTID = "projectid" PROJECT = "project" USER = "user" TIME = "time" TYPE = "type" TEST = "test" NAME = "name" PKG = "package" LANG = "lang" SUBID = "subid" INFO = "info" DATA = "data" FILEID = "fileid" TESTID = "testid" SKELETON = "skeleton" REPORT = "report" STATUS = "status" PWORD = "password" SALT = "salt" ACCESS = "access" DESCRIPTION = "description" COMMENTS = "comments" )
const (
GRIDFS_NAME = "fs"
)
Variables ¶
var (
DuplicateFile = errors.New("db already contains this file")
)
Functions ¶
func AddFileResult ¶
AddFileResult adds or updates a result in a file's results.
func AddGridFile ¶
func AddGridFile(id, data interface{}) error
AddGridFile creates a new GridFile and stores the provided data structure in it via gob.
func AddJPFConfig ¶
AddJPF overwrites a project's JPF configuration with the provided configuration.
func AddJUnitTest ¶
AddJUnitTest overwrites one of a project's JUnit tests with the new JUnit test if it has the same name as the new test. Otherwise the new test is just added to the project's tests.
func AddMakefile ¶
func AddPMDRules ¶
AddPMDRules overwrites a project's current PMD rules with the provided rules.
func CheckstyleResult ¶
func CheckstyleResult(m, sl bson.M) (*checkstyle.Result, error)
CheckstyleResult retrieves a Result matching the given interface from the active database.
func Collections ¶
func FileNames ¶
FileNames retrieves names of files matching the given interface from the active database.
func FileResultId ¶
func FindbugsResult ¶
FindbugsResult retrieves a Result matching the given interface from the active database.
func GridFile ¶
func GridFile(id, ret interface{}) error
GridFile loads a GridFile matching id into a provided data structure from GridFS.
func HasGridFile ¶
HasGridFile checks whether this query needs to get data from GridFS
func JPFResult ¶
JPFResult retrieves a Result matching the given interface from the active database.
func JUnitResult ¶
JUnitResult retrieves aResult matching the given interface from the active database.
func JUnitTests ¶
JUnitTests retrieves all tests matching m from the active database.
func JavacResult ¶
JavacResult retrieves a JavacResult matching the given interface from the active database.
func PMDResult ¶
PMDResult retrieves a Result matching the given interface from the active database.
func ProjectName ¶
func ProjectResults ¶
func RemoveById ¶
RemoveById removes a document matching the given id in collection n from the active database.
func RemoveFileById ¶
func RemoveFileById(id interface{}) error
RemoveFileById removes a file matching the given id from the active database.
func RemoveProjectById ¶
func RemoveProjectById(id interface{}) error
RemoveProjectById removes a project matching the given id from the active database.
func RemoveSubmissionById ¶
func RemoveSubmissionById(id interface{}) error
RemoveSubmissionById removes a submission matching the given id from the active database.
func RemoveUserById ¶
RemoveUserById removes a user matching the given id from the active database.
func RenameUser ¶
func ResultNames ¶
AllResultNames retrieves all result names for a given project.
func Setup ¶
Setup creates a mongodb session. This must be called before using any other db functions.
func Submission ¶
func Submission(m, sl interface{}) (*project.Submission, error)
Submission retrieves a submission matching m from the active database.
func Submissions ¶
func Submissions(m, sl interface{}, sort ...string) ([]*project.Submission, error)
Submissions retrieves submissions matching m from the active database.
func TypeCounts ¶
func TypeCounts(id interface{}) []int
func Update ¶
Update updates documents from the collection n matching m with the changes specified by c.
func UpdateTime ¶
func UpdateTime(sub *project.Submission) error
func UserResults ¶
Types ¶
type AddError ¶
type AddError struct {
// contains filtered or unexported fields
}
AddError represents errors encountered when adding data.
type GetError ¶
type GetError struct {
// contains filtered or unexported fields
}
GetError represents errors encountered when retrieving data.
type RemoveError ¶
type RemoveError struct {
// contains filtered or unexported fields
}
RemoveError represents errors encountered when removing data.
type TypeHolder ¶
type TypeHolder struct {
Type string `bson:"type"`
}