revalidateComponentModels static method

void revalidateComponentModels(
  1. AppModel app,
  2. List<NewAppTask> tasks,
  3. List<ComponentSpec> createdComponents
)

Implementation

static void revalidateComponentModels(AppModel app, List<NewAppTask> tasks,
    List<ComponentSpec> createdComponents) {
  // now run all revalidateModel to make sure the documents are consistent, e.g. update html links
  tasks.add(() async {
    for (var createdComponent in createdComponents) {
      var componentSpecs = Apis.apis()
          .getRegistryApi()
          .getComponentSpecs(createdComponent.componentId);
      if (componentSpecs == null) {
        print(
            "Exception during retrieval of component ${createdComponent.componentId}");
      } else {
        var repository =
            componentSpecs.retrieveRepository(appId: app.documentID);
        var entity = await repository.getEntity(createdComponent.documentId);
        if (entity != null) {
          var newEntity =
              await componentSpecs.editor.revalidateEntity(app, entity);
          await repository.updateEntity(
              createdComponent.documentId, newEntity);
        } else {
          print(
              "Couldn't find model with id ${createdComponent.documentId} for componentSpecs with name ${componentSpecs.name}");
        }
      }
    }
  });
}