@Deprecated public static TaskEntity convertBackEndToMiddleEnd(TaskService.State taskState){
  TaskEntity taskEntity=new TaskEntity();
  taskEntity.setId(ServiceUtils.getIDFromDocumentSelfLink(taskState.documentSelfLink));
  taskEntity.setEntityId(taskState.entityId);
  taskEntity.setEntityKind(taskState.entityKind);
  taskEntity.setQueuedTime(taskState.queuedTime);
  taskEntity.setStartedTime(taskState.startedTime);
  taskEntity.setEndTime(taskState.endTime);
  taskEntity.setProjectId(taskState.projectId);
  taskEntity.setOperation(Operation.parseOperation(taskState.operation));
  taskEntity.setResourceProperties(taskState.resourceProperties);
switch (taskState.state) {
case COMPLETED:
    taskEntity.setState(TaskEntity.State.COMPLETED);
  break;
case STARTED:
taskEntity.setState(TaskEntity.State.STARTED);
break;
case QUEUED:
taskEntity.setState(TaskEntity.State.QUEUED);
break;
case ERROR:
taskEntity.setState(TaskEntity.State.ERROR);
break;
default :
String errorMessage=String.format("Unknown task state {%s} found for task link {%s}",taskState.state,taskState.documentSelfLink);
throw new IllegalStateException(errorMessage);
}
taskEntity.setSteps(new ArrayList<>());
if (taskState.steps != null) {
for (TaskService.State.Step step : taskState.steps) {
StepEntity stepEntity=StepUtils.convertBackEndToMiddleEnd(taskEntity,step);
taskEntity.addStep(stepEntity);
}
}
return taskEntity;
}

@ Deprecated public static TaskEntity convertBackEndToMiddleEnd ( TaskService . State taskState ) { TaskEntity taskEntity = new TaskEntity ( ) ; taskEntity . setId ( ServiceUtils . getIDFromDocumentSelfLink ( taskState . documentSelfLink ) ) ; taskEntity . setEntityId ( taskState . entityId ) ; taskEntity . setEntityKind ( taskState . entityKind ) ; taskEntity . setQueuedTime ( taskState . queuedTime ) ; taskEntity . setStartedTime ( taskState . startedTime ) ; taskEntity . setEndTime ( taskState . endTime ) ; taskEntity . setProjectId ( taskState . projectId ) ; taskEntity . setOperation ( Operation . parseOperation ( taskState . operation ) ) ; taskEntity . setResourceProperties ( taskState . resourceProperties ) ; switch ( taskState . state ) { case COMPLETED : taskEntity . setState ( TaskEntity . State . COMPLETED ) ; break ; case STARTED : taskEntity . setState ( TaskEntity . State . STARTED ) ; break ; case QUEUED : taskEntity . setState ( TaskEntity . State . QUEUED ) ; break ; case ERROR : taskEntity . setState ( TaskEntity . State . ERROR ) ; break ; default : String errorMessage = String . format ( "Unknown task state {%s} found for task link {%s}" , taskState . state , taskState . documentSelfLink ) ; throw new IllegalStateException ( errorMessage ) ; } taskEntity . setSteps ( new ArrayList < > ( ) ) ; if ( taskState . steps != null ) { for ( TaskService . State . Step step : taskState . steps ) { StepEntity stepEntity = StepUtils . convertBackEndToMiddleEnd ( taskEntity , step ) ; taskEntity . addStep ( stepEntity ) ; } } return taskEntity ; }
converts task from back - end representation to middle - end representation . legacy code . this function is usually called by taskbackend . a task is created in back - end and returned in back - end representation . then the task object is converted to middle - end representation so that the legacy command execution scheduler can schedule commands . another case is when we poll task status . a task object is returned by back - end in back - end representation . then the task object is converted to middle - end representation . normally a second conversion from middle - end to front - end is involved .
