@@ -1546,6 +1546,11 @@ private Response doSubmit(String json, InputStream file, FormDataContentDisposit
15461546
15471547 // check validations for Submitted workflow
15481548 List <String > errors = validateSubmit (md );
1549+
1550+ // if BUSINESS, check Sponsor Orgs on SUBMIT
1551+ if (DOECodeMetadata .Type .B .equals (md .getSoftwareType ()))
1552+ errors .addAll (validateSponsorOrgs (md ));
1553+
15491554 if ( !errors .isEmpty () ) {
15501555 // generate a JSONAPI errors object
15511556 return ErrorResponse
@@ -2365,9 +2370,9 @@ else if (m.getLicenses().contains(DOECodeMetadata.License.Other.value()) && Stri
23652370 }
23662371 if (StringUtils .isBlank (contributor .getFirstName ()) || StringUtils .isBlank (contributor .getLastName ()) || (null == contributor .getContributorType ())) {
23672372 reasons .add ("Contributor must include first name, last name, and contributor type." );
2373+ }
23682374 }
23692375 }
2370- }
23712376 // if "OS" accessibility, a REPOSITORY LINK is REQUIRED
23722377 if (DOECodeMetadata .Accessibility .OS .equals (m .getAccessibility ())) {
23732378 if (StringUtils .isBlank (m .getRepositoryLink ()))
@@ -2388,27 +2393,18 @@ else if (m.getLicenses().contains(DOECodeMetadata.License.Other.value()) && Stri
23882393 * Perform ANNOUNCE validations on metadata.
23892394 *
23902395 * @param m the Metadata to check
2391- * @return a List of submission validation errors, empty if none
2396+ * @return a List of announcement validation errors, empty if none
23922397 */
23932398 protected static List <String > validateAnnounce (DOECodeMetadata m ) {
23942399 List <String > reasons = new ArrayList <>();
23952400 // get all the SUBMITTED reasons, if any
23962401 reasons .addAll (validateSubmit (m ));
2397- // add SUBMIT -specific validations
2402+ // add ANNOUNCE -specific validations
23982403 if (null ==m .getReleaseDate ())
23992404 reasons .add ("Release date is required." );
2400- if (null ==m .getSponsoringOrganizations () || m .getSponsoringOrganizations ().isEmpty ())
2401- reasons .add ("At least one sponsoring organization is required." );
2402- else {
2403- for ( SponsoringOrganization o : m .getSponsoringOrganizations () ) {
2404- if (StringUtils .isBlank (o .getOrganizationName ()))
2405- reasons .add ("Sponsoring organization name is required." );
2406- if (StringUtils .isBlank (o .getPrimaryAward ()) && o .isDOE ())
2407- reasons .add ("Primary award number is required." );
2408- else if (o .isDOE () && !Validation .isValidAwardNumber (o .getPrimaryAward ()))
2409- reasons .add ("Award Number " + o .getPrimaryAward () + " is not valid." );
2410- }
2411- }
2405+
2406+ reasons .addAll (validateSponsorOrgs (m ));
2407+
24122408 if (null ==m .getResearchOrganizations () || m .getResearchOrganizations ().isEmpty ())
24132409 reasons .add ("At least one research organization is required." );
24142410 else {
@@ -2441,6 +2437,38 @@ else if (o.isDOE() && !Validation.isValidAwardNumber(o.getPrimaryAward()))
24412437 return reasons ;
24422438 }
24432439
2440+ /**
2441+ * Check SPONSOR ORG validations on metadata.
2442+ *
2443+ * @param m the Metadata to check
2444+ * @return a List of sponsor org validation errors, empty if none
2445+ */
2446+ private static List <String > validateSponsorOrgs (DOECodeMetadata m ) {
2447+ List <String > reasons = new ArrayList <>();
2448+
2449+ int doeSponsorCount = 0 ;
2450+ if (null ==m .getSponsoringOrganizations () || m .getSponsoringOrganizations ().isEmpty ())
2451+ reasons .add ("At least one sponsoring organization is required." );
2452+ else {
2453+ for ( SponsoringOrganization o : m .getSponsoringOrganizations () ) {
2454+ if (StringUtils .isBlank (o .getOrganizationName ()))
2455+ reasons .add ("Sponsoring organization name is required." );
2456+ if (StringUtils .isBlank (o .getPrimaryAward ()) && o .isDOE ())
2457+ reasons .add ("Primary award number is required." );
2458+ else if (o .isDOE () && !Validation .isValidAwardNumber (o .getPrimaryAward ()))
2459+ reasons .add ("Award Number " + o .getPrimaryAward () + " is not valid." );
2460+
2461+ if (o .isDOE ())
2462+ doeSponsorCount ++;
2463+ }
2464+ }
2465+
2466+ if (doeSponsorCount == 0 )
2467+ reasons .add ("At least one DOE funded sponsoring organization is required." );
2468+
2469+ return reasons ;
2470+ }
2471+
24442472 /**
24452473 * Send a NOTIFICATION EMAIL (if configured) when a record is SUBMITTED or
24462474 * ANNOUNCED.
0 commit comments