  A category has the amalgamation property (AP) if every pushout diagram has a
cocone, and the joint embedding property (JEP) if every finite coproduct
diagram has a cocone. We show that for a finitely generated category $\mathbf
I$, the following are equivalent: (i) every $\mathbf I$-shaped diagram in a
category with the AP and the JEP has a cocone; (ii) every $\mathbf I$-shaped
diagram in the category of sets and injections has a cocone; (iii) a certain
canonically defined category $\mathcal{L}(\mathbf{I})$ of "paths" in $\mathbf
I$ has only idempotent endomorphisms. When $\mathbf I$ is a finite poset, these
are further equivalent to: (iv) every upward-closed subset of $\mathbf I$ is
simply-connected; (v) $\mathbf I$ can be built inductively via some simple
rules. Our proof also shows that these conditions are decidable for finite
$\mathbf I$.
