fromEntityPlus static method
Future<AssignmentModel?>
fromEntityPlus(
- String documentID,
- AssignmentEntity? entity, {
- String? appId,
Implementation
static Future<AssignmentModel?> fromEntityPlus(
String documentID, AssignmentEntity? entity,
{String? appId}) async {
if (entity == null) return null;
WorkflowModel? workflowHolder;
if (entity.workflowId != null) {
try {
workflowHolder =
await workflowRepository(appId: appId)!.get(entity.workflowId);
} on Exception catch (e) {
print('Error whilst trying to initialise workflow');
print('Error whilst retrieving workflow with id ${entity.workflowId}');
print('Exception: $e');
}
}
var counter = 0;
return AssignmentModel(
documentID: documentID,
appId: entity.appId ?? '',
reporterId: entity.reporterId ?? '',
assigneeId: entity.assigneeId,
task: await TaskModel.fromEntityPlus(entity.task, appId: appId),
workflow: workflowHolder,
workflowTaskSeqNumber: entity.workflowTaskSeqNumber,
timestamp: entity.timestamp == null
? null
: DateTime.fromMillisecondsSinceEpoch((entity.timestamp as int)),
status: toAssignmentStatus(entity.status),
resultsCurrent: entity.resultsCurrent == null
? null
: List<AssignmentResultModel>.from(
await Future.wait(entity.resultsCurrent!.map((item) {
counter++;
return AssignmentResultModel.fromEntityPlus(
counter.toString(), item,
appId: appId);
}).toList())),
resultsPrevious: entity.resultsPrevious == null
? null
: List<AssignmentResultModel>.from(
await Future.wait(entity.resultsPrevious!.map((item) {
counter++;
return AssignmentResultModel.fromEntityPlus(
counter.toString(), item,
appId: appId);
}).toList())),
triggeredById: entity.triggeredById,
confirmMessage: await WorkflowNotificationModel.fromEntityPlus(
entity.confirmMessage,
appId: appId),
rejectMessage: await WorkflowNotificationModel.fromEntityPlus(
entity.rejectMessage,
appId: appId),
);
}