@@ -108,6 +108,45 @@ export default class WorkPackagesService {
108108 return workPackageTransformer ( wp ) ;
109109 }
110110
111+ /**
112+ * Retrieve a subset of work packages.
113+ * @param wbsNums the WBS numbers of the work packages to retrieve
114+ * @returns the work packages with the given WBS numbers
115+ * @throws if any of the work packages are not found
116+ */
117+ static async getManyWorkPackages ( wbsNums : WbsNumber [ ] ) : Promise < WorkPackage [ ] > {
118+ for ( const wbsNum of wbsNums ) {
119+ if ( isProject ( wbsNum ) ) {
120+ throw new HttpException (
121+ 404 ,
122+ 'WBS Number ' +
123+ `${ wbsNum . carNumber } .${ wbsNum . projectNumber } .${ wbsNum . workPackageNumber } ` +
124+ ' is a project WBS#, not a Work Package WBS#'
125+ ) ;
126+ }
127+ }
128+
129+ const workPackages = await prisma . work_Package . findMany ( {
130+ where : {
131+ wbsElement : {
132+ dateDeleted : null ,
133+ OR : wbsNums . map ( ( wbsNum ) => ( {
134+ carNumber : wbsNum . carNumber ,
135+ projectNumber : wbsNum . projectNumber ,
136+ workPackageNumber : wbsNum . workPackageNumber
137+ } ) )
138+ }
139+ } ,
140+ ...workPackageQueryArgs
141+ } ) ;
142+
143+ if ( ! workPackages ) {
144+ throw new NotFoundException ( 'Work Package' , wbsNums . map ( ( wbsNum ) => wbsPipe ( wbsNum ) ) . join ( ', ' ) ) ;
145+ }
146+
147+ return workPackages . map ( workPackageTransformer ) ;
148+ }
149+
111150 /**
112151 * Creates a Work_Package in the database
113152 * @param user the user creating the work package
0 commit comments