All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.enonic.xp.lib.task.TaskMapper Maven / Gradle / Ivy

package com.enonic.xp.lib.task;

import com.enonic.xp.script.serializer.MapGenerator;
import com.enonic.xp.script.serializer.MapSerializable;
import com.enonic.xp.task.TaskInfo;
import com.enonic.xp.task.TaskProgress;

public final class TaskMapper
    implements MapSerializable
{
    private final TaskInfo taskInfo;

    public TaskMapper( final TaskInfo taskInfo )
    {
        this.taskInfo = taskInfo;
    }

    @Override
    public void serialize( final MapGenerator gen )
    {
        gen.value( "description", this.taskInfo.getDescription() );
        gen.value( "id", this.taskInfo.getId().toString() );
        gen.value( "name", this.taskInfo.getName() );
        gen.value( "state", this.taskInfo.getState().toString() );
        gen.value( "application", this.taskInfo.getApplication().toString() );
        gen.value( "user", this.taskInfo.getUser().toString() );
        gen.value( "startTime", this.taskInfo.getStartTime() );
        gen.value( "node", this.taskInfo.getNode() );

        final TaskProgress progress = this.taskInfo.getProgress();
        gen.map( "progress" );
        gen.value( "info", progress.getInfo() );
        gen.value( "current", progress.getCurrent() );
        gen.value( "total", progress.getTotal() );
        gen.end();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy