Skip to main content

create_with_basis

Function create_with_basis 

Source
pub async fn create_with_basis(
    pool: &PgPool,
    actor: &Actor,
    input: NewItemFor<'_>,
) -> AppResult<Revision>
Expand description

Creates a simulation item together with its first files and its basis link – the one-step counterpart of items::create_with_files followed by add_basis.

§Invariants

  • Permission: as items::create (editor, member of the project group); basis must be a revision the caller already resolved with the actor’s rights (resolve_basis, revisions::get), so a hidden basis never gets here. The item type must be simulation (400).
  • Defaults: an empty name / description becomes default_name / default_description of the basis.
  • Data: the new revision is checked out by the creator; the current version of the basis revision’s STEP (else first CAD) file is pinned (pick_basis_file); without a file the revision alone is linked.
  • Locks: as items::create_tx, the new revision (FOR UPDATE) and the basis item (FOR SHARE).
  • Audit: item.create and simulation.basis.add, same transaction.
  • Atomic: one transaction; a failing basis check (e.g. the basis item deleted meanwhile) or upload creates nothing, not even the item number.