use of org.ovirt.engine.api.model.Job in project ovirt-engine by oVirt.
the class BackendStepsResource method addParents.
@Override
protected Step addParents(Step model) {
model.setJob(new Job());
model.getJob().setId(jobId.toString());
return model;
}
use of org.ovirt.engine.api.model.Job in project ovirt-engine by oVirt.
the class StepMapper method map.
@Mapping(from = org.ovirt.engine.core.common.job.Step.class, to = Step.class)
public static Step map(org.ovirt.engine.core.common.job.Step entity, Step step) {
Step model = step != null ? step : new Step();
model.setId(entity.getId().toString());
if (entity.getParentStepId() != null) {
Step parentStep = new Step();
parentStep.setId(entity.getParentStepId().toString());
model.setParentStep(parentStep);
}
Job job = new Job();
job.setId(entity.getJobId().toString());
model.setJob(job);
model.setType(map(entity.getStepType()));
model.setDescription(entity.getDescription());
model.setNumber(entity.getStepNumber());
model.setStatus(mapStepStatus(entity.getStatus()));
model.setProgress(entity.getProgress());
model.setStartTime(DateMapper.map(entity.getStartTime(), null));
if (entity.getEndTime() != null) {
model.setEndTime(TypeConversionHelper.toXMLGregorianCalendar(entity.getEndTime(), null));
}
model.setExternal(entity.isExternal());
if (entity.getExternalSystem() != null && entity.getExternalSystem().getType() != null) {
model.setExternalType(map(entity.getExternalSystem().getType()));
}
mapStepSubjectEntities(entity, model);
return model;
}
use of org.ovirt.engine.api.model.Job in project ovirt-engine by oVirt.
the class BackendJobsResourceTest method getEntity.
@Override
protected org.ovirt.engine.core.common.job.Job getEntity(int index) {
org.ovirt.engine.core.common.job.Job job = new org.ovirt.engine.core.common.job.Job();
job.setId(GUIDS[index]);
job.setDescription(DESCRIPTIONS[index]);
job.setActionType(ActionType.AddExternalJob);
job.setStartTime(new Date());
job.setExternal(true);
job.setAutoCleared(true);
return job;
}
use of org.ovirt.engine.api.model.Job in project ovirt-engine by oVirt.
the class BackendStepsResourceTest method testAddStep.
@Test
public void testAddStep() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpCreationExpectations(ActionType.AddExternalStep, AddExternalStepParameters.class, new String[] { "Description", "ParentId" }, new Object[] { DESCRIPTIONS[0], GUIDS[1] }, true, true, GUIDS[0], QueryType.GetStepWithSubjectEntitiesByStepId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
Step model = new Step();
Job job = new Job();
job.setId(GUIDS[1].toString());
job.setDescription(DESCRIPTIONS[1]);
model.setJob(job);
model.setDescription(DESCRIPTIONS[0]);
model.setStatus(StepStatus.STARTED);
model.setType(StepEnum.EXECUTING);
Response response = collection.add(model);
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof Step);
verifyModel((Step) response.getEntity(), 0);
}
use of org.ovirt.engine.api.model.Job in project ovirt-engine by oVirt.
the class JobMapper method map.
@Mapping(from = org.ovirt.engine.core.common.job.Job.class, to = Job.class)
public static Job map(org.ovirt.engine.core.common.job.Job entity, Job job) {
Job model = job != null ? job : new Job();
model.setId(entity.getId().toString());
model.setDescription(entity.getDescription());
model.setStatus(mapJobStatus(entity.getStatus()));
if (entity.getOwnerId() != null) {
User user = new User();
user.setId(entity.getOwnerId().toString());
model.setOwner(user);
}
model.setStartTime(DateMapper.map(entity.getStartTime(), null));
if (entity.getEndTime() != null) {
model.setEndTime(DateMapper.map(entity.getEndTime(), null));
}
if (entity.getLastUpdateTime() != null) {
model.setLastUpdated(DateMapper.map(entity.getLastUpdateTime(), null));
}
model.setExternal(entity.isExternal());
model.setAutoCleared(entity.isAutoCleared());
return model;
}