Search in sources :

Example 1 with UpgradeStatusModel

use of com.infiniteautomation.mango.rest.latest.model.modules.UpgradeStatusModel in project ma-modules-public by infiniteautomation.

the class ModulesRestController method getUpgradeStatus.

@ApiOperation(value = "Get Current Upgrade Task Status", notes = "")
@RequestMapping(method = RequestMethod.GET, value = "/upgrade-status")
public UpgradeStatusModel getUpgradeStatus(@AuthenticationPrincipal PermissionHolder user) {
    permissionService.ensureAdminRole(user);
    UpgradeStatus status = service.monitorDownloads();
    UpgradeStatusModel model = new UpgradeStatusModel();
    if (status.getStage() == UpgradeState.IDLE) {
        // Not running
        model.setRunning(false);
    } else {
        List<ModuleModel> modules = new ArrayList<ModuleModel>();
        List<StringStringPair> results = status.getResults();
        for (StringStringPair r : results) modules.add(new ModuleModel(r.getKey(), r.getValue()));
        model.setResults(modules);
        model.setFinished(status.isFinished());
        model.setCancelled(status.isCancelled());
        model.setWillRestart(status.isRestart());
        model.setError(status.getError());
        model.setStage(status.getStage().name());
    }
    return model;
}
Also used : StringStringPair(com.serotonin.db.pair.StringStringPair) UpgradeStatus(com.infiniteautomation.mango.spring.service.ModulesService.UpgradeStatus) ArrayList(java.util.ArrayList) UpgradeStatusModel(com.infiniteautomation.mango.rest.latest.model.modules.UpgradeStatusModel) ModuleModel(com.infiniteautomation.mango.rest.latest.model.modules.ModuleModel) CoreModuleModel(com.infiniteautomation.mango.rest.latest.model.modules.CoreModuleModel) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

CoreModuleModel (com.infiniteautomation.mango.rest.latest.model.modules.CoreModuleModel)1 ModuleModel (com.infiniteautomation.mango.rest.latest.model.modules.ModuleModel)1 UpgradeStatusModel (com.infiniteautomation.mango.rest.latest.model.modules.UpgradeStatusModel)1 UpgradeStatus (com.infiniteautomation.mango.spring.service.ModulesService.UpgradeStatus)1 StringStringPair (com.serotonin.db.pair.StringStringPair)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ArrayList (java.util.ArrayList)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1