Bring a large pot of salted water to a boil and cook the pasta according to the package directions. Drain, toss with 1 tablespoon olive oil, and set aside.
Heat the remaining 2 tablespoons of olive oil in a large skillet over medium-high heat. Add the onion and cook until tender and translucent, about 4 minutes. Add the garlic and cook, stirring, for 30 seconds. Add the mushrooms with 1 teaspoon salt and ½ teaspoon pepper and cook, stirring occasionally, until the mushrooms are tender and any liquid they have released has evaporated, about 8 minutes. Add the ham and peas and remove from the heat.
In another large skillet, melt the butter over medium heat. Add the flour and cook, stirring, for 2 minutes. Add the milk and cook, stirring occasionally until the sauce starts to thicken, about 5 minutes. Add the Gruyere cheese and cook, stirring until the cheese has melted, about 2 minutes.
Preheat the oven to 350 degrees. Spray a 9-inch springform pan generously with cooking spray.
Layer ½ of the pasta in the bottom of the pan. Dot with 1/3 of the cheese sauce then spread it into an even layer. Add half of the ham and vegetable mixture and then 1/3 of the mozzarella cheese. Add the rest of the pasta and dot on 1/3 of the cheese sauce and spread. Add the rest of the ham and vegetable mixture, dot the rest of the cheese sauce on top and spread into an even layer. Sprinkle on the rest of the mozzarella, then sprinkle the Parmesan over the top.
Bake for 30 minutes or until the top is nicely browned. Let cool to room temperature, remove the ring from the pan, and slice.