Search in sources :

Example 11 with ProgressStatus

use of org.glassfish.api.admin.ProgressStatus in project Payara by payara.

the class ProgressStatusClient method mirror.

private void mirror(ProgressStatusDTO dto, ProgressStatus stat) {
    // TODO: copy-paste problem because of ProgressStatusDTO and ProgressStatusBase we have to create shared interface
    stat.setTotalStepCount(dto.getTotalStepCount());
    stat.setCurrentStepCount(dto.getCurrentStepCount());
    if (dto.isCompleted()) {
        stat.complete();
    }
    for (ProgressStatusDTO.ChildProgressStatusDTO chld : dto.getChildren()) {
        ProgressStatus dst = map.get(chld.getProgressStatus().getId());
        if (dst == null) {
            dst = stat.createChild(chld.getProgressStatus().getName(), chld.getAllocatedSteps());
            map.put(chld.getProgressStatus().getId(), dst);
        }
        mirror(chld.getProgressStatus(), dst);
    }
}
Also used : ProgressStatus(org.glassfish.api.admin.ProgressStatus) ProgressStatusDTO(org.glassfish.api.admin.progress.ProgressStatusDTO)

Example 12 with ProgressStatus

use of org.glassfish.api.admin.ProgressStatus in project Payara by payara.

the class ProgressStatusClient method mirror.

private void mirror(ProgressStatusBase source, ProgressStatus stat) {
    stat.setTotalStepCount(source.getTotalStepCount());
    stat.setCurrentStepCount(source.getCurrentStepCount());
    if (source.isComplete()) {
        stat.complete();
    }
    for (ProgressStatusBase.ChildProgressStatus chld : source.getChildProgressStatuses()) {
        ProgressStatus dst = map.get(chld.getProgressStatus().getId());
        if (dst == null) {
            dst = stat.createChild(chld.getProgressStatus().getName(), chld.getAllocatedSteps());
            map.put(chld.getProgressStatus().getId(), dst);
        }
        mirror(chld.getProgressStatus(), dst);
    }
}
Also used : ProgressStatus(org.glassfish.api.admin.ProgressStatus) ProgressStatusBase(org.glassfish.api.admin.progress.ProgressStatusBase)

Example 13 with ProgressStatus

use of org.glassfish.api.admin.ProgressStatus in project Payara by payara.

the class ProgressStepBackCommand method execute.

@Override
public void execute(AdminCommandContext context) {
    ProgressStatus ps = context.getProgressStatus();
    ps.progress("Parsing");
    doSomeLogic();
    ps.progress(1, "Working on main part");
    for (int i = 0; i < 3; i++) {
        doSomeLogic();
        ps.progress(1);
    }
    ps.progress("Error in processing - next try");
    ps.setCurrentStepCount(2);
    for (int i = 0; i < 2; i++) {
        doSomeLogic();
        ps.progress(1);
    }
    doSomeLogic();
    ps.progress(1);
    ps.complete("Finished");
    context.getActionReport().appendMessage("All done");
}
Also used : ProgressStatus(org.glassfish.api.admin.ProgressStatus)

Example 14 with ProgressStatus

use of org.glassfish.api.admin.ProgressStatus in project Payara by payara.

the class SupplementAfter method execute.

@Override
public void execute(AdminCommandContext context) {
    ProgressStatus ps = context.getProgressStatus();
    ps.progress("3 seconds supplemental");
    for (int i = 0; i < 6; i++) {
        try {
            Thread.sleep(500L);
        } catch (InterruptedException ex) {
        }
        ps.progress(1);
    }
    context.getActionReport().setActionExitCode(ActionReport.ExitCode.SUCCESS);
    ps.complete();
}
Also used : ProgressStatus(org.glassfish.api.admin.ProgressStatus)

Example 15 with ProgressStatus

use of org.glassfish.api.admin.ProgressStatus in project Payara by payara.

the class ProgressSimpleCommand method execute.

@Override
public void execute(AdminCommandContext context) {
    ProgressStatus ps = context.getProgressStatus();
    if (!noTotalSteps) {
        ps.setTotalStepCount(10);
    }
    ps.progress("Parsing");
    doSomeLogic();
    ps.progress(1, "Working on main part");
    for (int i = 0; i < 7; i++) {
        doSomeLogic();
        ps.progress(1);
    }
    ps.progress(1, "Cleaning");
    doSomeLogic();
    ps.complete("Finished");
    context.getActionReport().appendMessage("All done");
}
Also used : ProgressStatus(org.glassfish.api.admin.ProgressStatus)

Aggregations

ProgressStatus (org.glassfish.api.admin.ProgressStatus)20 Test (org.junit.Test)4 ActionReport (org.glassfish.api.ActionReport)3 File (java.io.File)1 IOException (java.io.IOException)1 CommandRunner (org.glassfish.api.admin.CommandRunner)1 Outbound (org.glassfish.api.admin.Payload.Outbound)1 ProgressStatusBase (org.glassfish.api.admin.progress.ProgressStatusBase)1 ProgressStatusDTO (org.glassfish.api.admin.progress.ProgressStatusDTO)1 ProgressStatusEventCreateChild (org.glassfish.api.admin.progress.ProgressStatusEventCreateChild)1 ProgressStatusImpl (org.glassfish.api.admin.progress.ProgressStatusImpl)1 ProgressStatusMirroringImpl (org.glassfish.api.admin.progress.ProgressStatusMirroringImpl)1