use of org.motechproject.mds.web.domain.HistoryRecord in project motech by motech.
the class InstanceController method getPreviousInstance.
@RequestMapping(value = "/instances/{entityId}/{instanceId}/previousVersion/{historyId}", method = RequestMethod.GET)
@ResponseBody
public HistoryRecord getPreviousInstance(@PathVariable Long entityId, @PathVariable Long instanceId, @PathVariable Long historyId) {
HistoryRecord historyRecord = instanceService.getHistoryRecord(entityId, instanceId, historyId);
if (historyRecord == null) {
throw new EntityNotFoundException(entityId);
}
processFieldsForUIInHistoryRecord(historyRecord.getFields());
return historyRecord;
}
use of org.motechproject.mds.web.domain.HistoryRecord in project motech by motech.
the class InstanceServiceImpl method convertToHistoryRecord.
private HistoryRecord convertToHistoryRecord(Object object, EntityDto entity, Long instanceId, MotechDataService service) {
Long entityId = entity.getId();
List<FieldDto> fields = getEntityFields(entityId);
Map<String, List<FieldDto>> relatedEntitiesFields = getRelatedEntitiesFields(fields);
EntityRecord entityRecord = instanceToRecord(object, entity, entityService.getEntityFieldsForUI(entityId), service, EntityType.HISTORY, relatedEntitiesFields);
Long historyInstanceSchemaVersion = (Long) PropertyUtil.safeGetProperty(object, HistoryTrashClassHelper.historySchemaVersion(object.getClass()));
Long currentSchemaVersion = entityService.getCurrentSchemaVersion(entity.getClassName());
return new HistoryRecord(entityRecord.getId(), instanceId, historyInstanceSchemaVersion.equals(currentSchemaVersion), entityRecord.getFields());
}
Aggregations