@@ -3226,11 +3226,351 @@ private void normalizeMetadata(DOECodeMetadata md) {
32263226 * @param md the Metadata to normalize
32273227 */
32283228 private void performDataNormalization (DOECodeMetadata md ) {
3229+ trimMetadataObject (md );
32293230 normalizeMetadata (md );
32303231 normalizeRelatedIdentifiers (md );
32313232 normalizeAwards (md );
32323233 }
32333234
3235+ /**
3236+ * Clean string values.
3237+ *
3238+ * @return a clean string or null
3239+ */
3240+ private String cleanStr (String input ) {
3241+ if (StringUtils .isBlank (input ))
3242+ return input ;
3243+
3244+ return input .trim ();
3245+ }
3246+
3247+ /**
3248+ * Clean String List values.
3249+ *
3250+ * @return a clean List or null
3251+ */
3252+ private List <String > cleanStrList (List <String > input ) {
3253+ if (input == null || input .isEmpty ())
3254+ return input ;
3255+
3256+ int cnt = input .size ();
3257+ for (int i = 0 ; i < cnt ; i ++) {
3258+ input .set (i , cleanStr (input .get (i )));
3259+ }
3260+
3261+ return input ;
3262+ }
3263+
3264+ /**
3265+ * Clean Developer values.
3266+ *
3267+ * @return a clean Developer or null
3268+ */
3269+ private Developer cleanDev (Developer dev ) {
3270+ if (dev == null )
3271+ return dev ;
3272+
3273+ dev .setEmail (cleanStr (dev .getEmail ()));
3274+ dev .setOrcid (cleanStr (dev .getOrcid ()));
3275+ dev .setFirstName (cleanStr (dev .getFirstName ()));
3276+ dev .setMiddleName (cleanStr (dev .getMiddleName ()));
3277+ dev .setLastName (cleanStr (dev .getLastName ()));
3278+ dev .setAffiliations (cleanStrList (dev .getAffiliations ()));
3279+
3280+ return dev ;
3281+ }
3282+
3283+ /**
3284+ * Clean Developer List values.
3285+ *
3286+ * @return a clean List or null
3287+ */
3288+ private List <Developer > cleanDevList (List <Developer > input ) {
3289+ if (input == null || input .isEmpty ())
3290+ return input ;
3291+
3292+ int cnt = input .size ();
3293+ for (int i = 0 ; i < cnt ; i ++) {
3294+ input .set (i , cleanDev (input .get (i )));
3295+ }
3296+
3297+ return input ;
3298+ }
3299+
3300+ /**
3301+ * Clean Contributor values.
3302+ *
3303+ * @return a clean Contributor or null
3304+ */
3305+ private Contributor cleanCon (Contributor con ) {
3306+ if (con == null )
3307+ return con ;
3308+
3309+ con .setEmail (cleanStr (con .getEmail ()));
3310+ con .setOrcid (cleanStr (con .getOrcid ()));
3311+ con .setFirstName (cleanStr (con .getFirstName ()));
3312+ con .setMiddleName (cleanStr (con .getMiddleName ()));
3313+ con .setLastName (cleanStr (con .getLastName ()));
3314+ con .setAffiliations (cleanStrList (con .getAffiliations ()));
3315+
3316+ return con ;
3317+ }
3318+
3319+ /**
3320+ * Clean Contributor List values.
3321+ *
3322+ * @return a clean List or null
3323+ */
3324+ private List <Contributor > cleanConList (List <Contributor > input ) {
3325+ if (input == null || input .isEmpty ())
3326+ return input ;
3327+
3328+ int cnt = input .size ();
3329+ for (int i = 0 ; i < cnt ; i ++) {
3330+ input .set (i , cleanCon (input .get (i )));
3331+ }
3332+
3333+ return input ;
3334+ }
3335+
3336+ /**
3337+ * Clean ContributingOrganization values.
3338+ *
3339+ * @return a clean ContributorOrg or null
3340+ */
3341+ private ContributingOrganization cleanConOrg (ContributingOrganization con ) {
3342+ if (con == null )
3343+ return con ;
3344+
3345+ con .setOrganizationName (cleanStr (con .getOrganizationName ()));
3346+
3347+ return con ;
3348+ }
3349+
3350+ /**
3351+ * Clean ContributingOrganization List values.
3352+ *
3353+ * @return a clean List or null
3354+ */
3355+ private List <ContributingOrganization > cleanConOrgList (List <ContributingOrganization > input ) {
3356+ if (input == null || input .isEmpty ())
3357+ return input ;
3358+
3359+ int cnt = input .size ();
3360+ for (int i = 0 ; i < cnt ; i ++) {
3361+ input .set (i , cleanConOrg (input .get (i )));
3362+ }
3363+
3364+ return input ;
3365+ }
3366+
3367+ /**
3368+ * Clean FundingIdentifier values.
3369+ *
3370+ * @return a clean FundingIdentifier or null
3371+ */
3372+ private FundingIdentifier cleanFundIdent (FundingIdentifier fi ) {
3373+ if (fi == null )
3374+ return fi ;
3375+
3376+ fi .setIdentifierValue (cleanStr (fi .getIdentifierValue ()));
3377+
3378+ return fi ;
3379+ }
3380+
3381+ /**
3382+ * Clean FundingIdentifier List values.
3383+ *
3384+ * @return a clean List or null
3385+ */
3386+ private List <FundingIdentifier > cleanFundIdentList (List <FundingIdentifier > input ) {
3387+ if (input == null || input .isEmpty ())
3388+ return input ;
3389+
3390+ int cnt = input .size ();
3391+ for (int i = 0 ; i < cnt ; i ++) {
3392+ input .set (i , cleanFundIdent (input .get (i )));
3393+ }
3394+
3395+ return input ;
3396+ }
3397+
3398+ /**
3399+ * Clean SponsoringOrganization values.
3400+ *
3401+ * @return a clean SponsoringOrganization or null
3402+ */
3403+ private SponsoringOrganization cleanSponOrg (SponsoringOrganization con ) {
3404+ if (con == null )
3405+ return con ;
3406+
3407+ con .setOrganizationName (cleanStr (con .getOrganizationName ()));
3408+ con .setFundingIdentifiers (cleanFundIdentList (con .getFundingIdentifiers ()));
3409+ con .setPrimaryAward (cleanStr (con .getPrimaryAward ()));
3410+
3411+ return con ;
3412+ }
3413+
3414+ /**
3415+ * Clean SponsoringOrganization List values.
3416+ *
3417+ * @return a clean List or null
3418+ */
3419+ private List <SponsoringOrganization > cleanSponOrgList (List <SponsoringOrganization > input ) {
3420+ if (input == null || input .isEmpty ())
3421+ return input ;
3422+
3423+ int cnt = input .size ();
3424+ for (int i = 0 ; i < cnt ; i ++) {
3425+ input .set (i , cleanSponOrg (input .get (i )));
3426+ }
3427+
3428+ return input ;
3429+ }
3430+
3431+ /**
3432+ * Clean ResearchOrganization values.
3433+ *
3434+ * @return a clean ResearchOrganization or null
3435+ */
3436+ private ResearchOrganization cleanResOrg (ResearchOrganization con ) {
3437+ if (con == null )
3438+ return con ;
3439+
3440+ con .setOrganizationName (cleanStr (con .getOrganizationName ()));
3441+
3442+ return con ;
3443+ }
3444+
3445+ /**
3446+ * Clean ResearchOrganization List values.
3447+ *
3448+ * @return a clean List or null
3449+ */
3450+ private List <ResearchOrganization > cleanResOrgList (List <ResearchOrganization > input ) {
3451+ if (input == null || input .isEmpty ())
3452+ return input ;
3453+
3454+ int cnt = input .size ();
3455+ for (int i = 0 ; i < cnt ; i ++) {
3456+ input .set (i , cleanResOrg (input .get (i )));
3457+ }
3458+
3459+ return input ;
3460+ }
3461+
3462+ /**
3463+ * Clean RelatedIdentifier values.
3464+ *
3465+ * @return a clean RelatedIdentifier or null
3466+ */
3467+ private RelatedIdentifier cleanRelIdent (RelatedIdentifier ri ) {
3468+ if (ri == null )
3469+ return ri ;
3470+
3471+ ri .setIdentifierValue (cleanStr (ri .getIdentifierValue ()));
3472+
3473+ return ri ;
3474+ }
3475+
3476+ /**
3477+ * Clean RelatedIdentifier List values.
3478+ *
3479+ * @return a clean List or null
3480+ */
3481+ private List <RelatedIdentifier > cleanRelIdentList (List <RelatedIdentifier > input ) {
3482+ if (input == null || input .isEmpty ())
3483+ return input ;
3484+
3485+ int cnt = input .size ();
3486+ for (int i = 0 ; i < cnt ; i ++) {
3487+ input .set (i , cleanRelIdent (input .get (i )));
3488+ }
3489+
3490+ return input ;
3491+ }
3492+
3493+ /**
3494+ * Clean Award values.
3495+ *
3496+ * @return a clean Award or null
3497+ */
3498+ private Award cleanAward (Award a ) {
3499+ if (a == null )
3500+ return a ;
3501+
3502+ a .setAwardDoi (cleanStr (a .getAwardDoi ()));
3503+ a .setFunderName (cleanStr (a .getFunderName ()));
3504+
3505+ return a ;
3506+ }
3507+
3508+ /**
3509+ * Clean Award List values.
3510+ *
3511+ * @return a clean List or null
3512+ */
3513+ private List <Award > cleanAwardList (List <Award > input ) {
3514+ if (input == null || input .isEmpty ())
3515+ return input ;
3516+
3517+ int cnt = input .size ();
3518+ for (int i = 0 ; i < cnt ; i ++) {
3519+ input .set (i , cleanAward (input .get (i )));
3520+ }
3521+
3522+ return input ;
3523+ }
3524+
3525+ /**
3526+ * Clean metadata object values.
3527+ */
3528+ private void trimMetadataObject (DOECodeMetadata md ) {
3529+ md .setSiteOwnershipCode (cleanStr (md .getSiteOwnershipCode ()));
3530+ md .setRepositoryLink (cleanStr (md .getRepositoryLink ()));
3531+ md .setLandingPage (cleanStr (md .getLandingPage ()));
3532+ md .setAccessLimitations (cleanStrList (md .getAccessLimitations ()));
3533+ // clean OfficialUseOnly
3534+ OfficialUseOnly ouo = md .getOfficialUseOnly ();
3535+ if (ouo != null ) {
3536+ ouo .setExemptionNumber (cleanStr (ouo .getExemptionNumber ()));
3537+ ouo .setProtectionOther (cleanStr (ouo .getProtectionOther ()));
3538+ ouo .setProgramOffice (cleanStr (ouo .getProgramOffice ()));
3539+ ouo .setProtectionReason (cleanStr (ouo .getProtectionReason ()));
3540+ }
3541+ md .setDevelopers (cleanDevList (md .getDevelopers ()));
3542+ md .setContributors (cleanConList (md .getContributors ()));
3543+ md .setContributingOrganizations (cleanConOrgList (md .getContributingOrganizations ()));
3544+ md .setSponsoringOrganizations (cleanSponOrgList (md .getSponsoringOrganizations ()));
3545+ md .setResearchOrganizations (cleanResOrgList (md .getResearchOrganizations ()));
3546+ md .setRelatedIdentifiers (cleanRelIdentList (md .getRelatedIdentifiers ()));
3547+ md .setAwardDois (cleanAwardList (md .getAwardDois ()));
3548+ md .setSoftwareTitle (cleanStr (md .getSoftwareTitle ()));
3549+ md .setAcronym (cleanStr (md .getAcronym ()));
3550+ md .setDoi (cleanStr (md .getDoi ()));
3551+ md .setDescription (cleanStr (md .getDescription ()));
3552+ md .setProgrammingLanguages (cleanStrList (md .getProgrammingLanguages ()));
3553+ md .setVersionNumber (cleanStr (md .getVersionNumber ()));
3554+ md .setDocumentationUrl (cleanStr (md .getDocumentationUrl ()));
3555+ md .setCountryOfOrigin (cleanStr (md .getCountryOfOrigin ()));
3556+ md .setKeywords (cleanStr (md .getKeywords ()));
3557+ md .setProjectKeywords (cleanStrList (md .getProjectKeywords ()));
3558+ md .setDisclaimers (cleanStr (md .getDisclaimers ()));
3559+ md .setLicenses (cleanStrList (md .getLicenses ()));
3560+ md .setProprietaryUrl (cleanStr (md .getProprietaryUrl ()));
3561+ md .setLicenseContactEmail (cleanStr (md .getLicenseContactEmail ()));
3562+ md .setRecipientName (cleanStr (md .getRecipientName ()));
3563+ md .setRecipientEmail (cleanStr (md .getRecipientEmail ()));
3564+ md .setRecipientPhone (cleanStr (md .getRecipientPhone ()));
3565+ md .setRecipientOrg (cleanStr (md .getRecipientOrg ()));
3566+ md .setSiteAccessionNumber (cleanStr (md .getSiteAccessionNumber ()));
3567+ md .setOtherSpecialRequirements (cleanStr (md .getOtherSpecialRequirements ()));
3568+ md .setOwner (cleanStr (md .getOwner ()));
3569+ md .setFileName (cleanStr (md .getFileName ()));
3570+ md .setContainerName (cleanStr (md .getContainerName ()));
3571+ md .setLastEditor (cleanStr (md .getLastEditor ()));
3572+ }
3573+
32343574 /**
32353575 * Store a File to a specific directory location. All files associated with
32363576 * a CODEID are stored in the same folder.
0 commit comments