com.rinoto.migramongo.MigraMongoStatus Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of migramongo-core Show documentation
Show all versions of migramongo-core Show documentation
Tool for migrating mongodb scripts
package com.rinoto.migramongo;
import java.util.ArrayList;
import java.util.List;
public class MigraMongoStatus {
public MigrationStatus status;
public String message;
public List migrationsApplied = new ArrayList<>();
public MigraMongoStatus(MigrationStatus status, String message) {
this.status = status;
this.message = message;
}
public static final MigraMongoStatus ok() {
return ok("Everything ok");
}
public static final MigraMongoStatus ok(String message) {
return new MigraMongoStatus(MigrationStatus.OK, message);
}
public static final MigraMongoStatus error(String errorMessage) {
return new MigraMongoStatus(MigrationStatus.ERROR, errorMessage);
}
public static final MigraMongoStatus inProgress(String message) {
return new MigraMongoStatus(MigrationStatus.IN_PROGRESS, message);
}
public MigraMongoStatus addEntry(MigrationEntry migEntry) {
migrationsApplied.add(migEntry);
return this;
}
public MigraMongoStatus withEntries(List entries) {
this.migrationsApplied = entries;
return this;
}
public enum MigrationStatus {
OK, LOCK_NOT_ACQUIRED, ERROR, IN_PROGRESS;
}
@Override
public String toString() {
return "[status=" + status + ", message=" + message + ", migrationsApplied=" + migrationsApplied + "]";
}
public static MigraMongoStatus lockNotAcquired() {
return new MigraMongoStatus(MigrationStatus.LOCK_NOT_ACQUIRED, "Couldn't obtain lock - doing nothing");
}
}