fromEntityPlus static method

Future<WorkflowActionModel?> fromEntityPlus(
  1. WorkflowActionEntity? entity, {
  2. String? appId,
})
override

Implementation

static Future<WorkflowActionModel?> fromEntityPlus(
    WorkflowActionEntity? entity,
    {String? appId}) async {
  if (entity == null) return null;
  if (entity.appID == null) {
    throw Exception('entity WorkflowActionModel.appID is null');
  }
  WorkflowModel? workFlowModel;
  if (entity.workflowId != null) {
    try {
      await workflowRepository(appId: entity.appID)!
          .get(entity.workflowId)
          .then((val) {
        workFlowModel = val;
      }).catchError((error) {});
    } catch (_) {}
  }

  var app = await appRepository()!.get(entity.appID);
  if (app != null) {
    return WorkflowActionModel(app,
        conditions:
            await DisplayConditionsModel.fromEntity(entity.conditions),
        workflow: workFlowModel);
  } else {
    throw Exception('App with ${entity.appID!} not found');
  }
}