protected String prepareAttName(BudgetSubAwardsContract budgetSubAwards) {
        StringBuilder attachmentName = new StringBuilder();
        boolean hasSameFileName = false;
        boolean isAlreadyprinted = false;
        int attachmentCount=0;
        int suffix=1;
       
        int index =0;
        for(String budgetId : budgetIdList){
            
            if(budgetSubAwards.getBudgetId().toString().equals(budgetId)){
                if(budgetSubawardNumberList.get(index).equals(budgetSubAwards.getSubAwardNumber().toString())){
                    attachmentList.clear();
                    isAlreadyprinted = true;
                    break;
                }
            }
            index++;
        }
        if(isAlreadyprinted){
            budgetIdList.clear();
            budgetSubawardNumberList.clear();
        }
        
        //checking organization name and replacing invalid characters
        // with underscores.
        String cleanSubAwardOrganizationName = checkAndReplaceInvalidCharacters(budgetSubAwards.getOrganizationName());
        attachmentName.append(cleanSubAwardOrganizationName);
        BudgetContract budget = findBudgetFromProposal();
        List<? extends BudgetSubAwardsContract> budgetSubAwardsList = budget.getBudgetSubAwards();
        ArrayList<String> attachments = new ArrayList<>();
        for (BudgetSubAwardsContract budgetSubAward: budgetSubAwardsList) {
            StringBuilder existingAttachmentName = new StringBuilder();
            String subAward_OrganizationName = checkAndReplaceInvalidCharacters(budgetSubAward.getOrganizationName());
            existingAttachmentName.append(subAward_OrganizationName);
            attachments.add(existingAttachmentName.toString());                 
        }
        for (String attachment : attachments) {
            if (attachment.equals(attachmentName.toString())) {
                attachmentCount++;
            }
        }        
        if (attachmentCount>1 && !attachmentList.contains(attachmentName.toString())) {
            attachmentList.add(attachmentName.toString());
            if(attachmentName.length() > 49){
                attachmentName.delete(49, attachmentName.length());               
             }
            attachmentName.append(1);
            hasSameFileName = true;                
        } else {
            for (String attachment:attachmentList) {                  
                if (attachment.equals(attachmentName.toString())) {
                    suffix++;
                }                    
            }
        }            
        if (attachmentList.contains(attachmentName.toString()) && !hasSameFileName) {
            attachmentList.add(attachmentName.toString());
            if(attachmentName.length() > 49){
                attachmentName.delete(49, attachmentName.length());               
             }
            attachmentName.append(suffix);
        } else {
            attachmentList.add(attachmentName.toString());             
        }                           
        budgetIdList.add(budgetSubAwards.getBudgetId().toString());
        budgetSubawardNumberList.add(budgetSubAwards.getSubAwardNumber().toString());           
        return attachmentName.toString();
    }
protected String prepareAttName ( BudgetSubAwardsContract budgetSubAwards ) { StringBuilder attachmentName = new StringBuilder ( ) ; boolean hasSameFileName = false ; boolean isAlreadyprinted = false ; int attachmentCount = 0 ; int suffix = 1 ; int index = 0 ; for ( String budgetId : budgetIdList ) { if ( budgetSubAwards . getBudgetId ( ) . toString ( ) . equals ( budgetId ) ) { if ( budgetSubawardNumberList . get ( index ) . equals ( budgetSubAwards . getSubAwardNumber ( ) . toString ( ) ) ) { attachmentList . clear ( ) ; isAlreadyprinted = true ; break ; } } index ++ ; } if ( isAlreadyprinted ) { budgetIdList . clear ( ) ; budgetSubawardNumberList . clear ( ) ; } String cleanSubAwardOrganizationName = checkAndReplaceInvalidCharacters ( budgetSubAwards . getOrganizationName ( ) ) ; attachmentName . append ( cleanSubAwardOrganizationName ) ; BudgetContract budget = findBudgetFromProposal ( ) ; List < ? extends BudgetSubAwardsContract > budgetSubAwardsList = budget . getBudgetSubAwards ( ) ; ArrayList < String > attachments = new ArrayList < > ( ) ; for ( BudgetSubAwardsContract budgetSubAward : budgetSubAwardsList ) { StringBuilder existingAttachmentName = new StringBuilder ( ) ; String subAward_OrganizationName = checkAndReplaceInvalidCharacters ( budgetSubAward . getOrganizationName ( ) ) ; existingAttachmentName . append ( subAward_OrganizationName ) ; attachments . add ( existingAttachmentName . toString ( ) ) ; } for ( String attachment : attachments ) { if ( attachment . equals ( attachmentName . toString ( ) ) ) { attachmentCount ++ ; } } if ( attachmentCount > 1 && ! attachmentList . contains ( attachmentName . toString ( ) ) ) { attachmentList . add ( attachmentName . toString ( ) ) ; if ( attachmentName . length ( ) > 49 ) { attachmentName . delete ( 49 , attachmentName . length ( ) ) ; } attachmentName . append ( 1 ) ; hasSameFileName = true ; } else { for ( String attachment : attachmentList ) { if ( attachment . equals ( attachmentName . toString ( ) ) ) { suffix ++ ; } } } if ( attachmentList . contains ( attachmentName . toString ( ) ) && ! hasSameFileName ) { attachmentList . add ( attachmentName . toString ( ) ) ; if ( attachmentName . length ( ) > 49 ) { attachmentName . delete ( 49 , attachmentName . length ( ) ) ; } attachmentName . append ( suffix ) ; } else { attachmentList . add ( attachmentName . toString ( ) ) ; } budgetIdList . add ( budgetSubAwards . getBudgetId ( ) . toString ( ) ) ; budgetSubawardNumberList . add ( budgetSubAwards . getSubAwardNumber ( ) . toString ( ) ) ; return attachmentName . toString ( ) ; }
This method is used to return the attachment name which comes from BudgetSubawards

@param budgetSubAwards(BudgetSubAwards) budget sub award entry.
@return String attachment name for the budget sub awards.