src/main/java/edu/ucla/library/bucketeer/Job.java
public Job updateMetadata() throws ProcessingException {
        final List<Item> items = getItems();

        final String[] newHeader;
        final String[] additionalHeaders;

        final int newHeaderLength;
        final int additionalHeadersCount;

        // Find the index position of our two columns: Bucketeer State and Access URL
        int bucketeerStateIndex = findHeader(Metadata.BUCKETEER_STATE);
        int accessUrlIndex = findHeader(Metadata.IIIF_ACCESS_URL);

        // Check which headers already exist in the metadata
        final boolean bucketeerStateMissing = bucketeerStateIndex == -1;
        final boolean accessUrlMissing = accessUrlIndex == -1;

        // If both headers are missing, we need to expand our headers array by two
        if (bucketeerStateMissing && accessUrlMissing) {
            additionalHeadersCount = 2;
            additionalHeaders = new String[additionalHeadersCount];
            additionalHeaders[0] = Metadata.BUCKETEER_STATE;
            additionalHeaders[1] = Metadata.IIIF_ACCESS_URL;

            bucketeerStateIndex = myMetadataHeader.length;
            accessUrlIndex = myMetadataHeader.length + 1;
        } else if (bucketeerStateMissing) {
            // If only one header is missing, we need to expand our headers array by one
            additionalHeadersCount = 1;
            additionalHeaders = new String[additionalHeadersCount];
            additionalHeaders[0] = Metadata.BUCKETEER_STATE;

            bucketeerStateIndex = myMetadataHeader.length;
        } else if (accessUrlMissing) {
            // Expand by one
            additionalHeadersCount = 1;
            additionalHeaders = new String[additionalHeadersCount];
            additionalHeaders[0] = Metadata.IIIF_ACCESS_URL;

            accessUrlIndex = myMetadataHeader.length;
        } else {
            // No change
            additionalHeadersCount = 0;
            additionalHeaders = new String[additionalHeadersCount];
        }

        LOGGER.debug(MessageCodes.BUCKETEER_155, additionalHeadersCount);
        newHeaderLength = myMetadataHeader.length + additionalHeadersCount;

        // Update the headers if there are changes
        if (bucketeerStateMissing || accessUrlMissing) {
            newHeader = new String[newHeaderLength];

            System.arraycopy(myMetadataHeader, 0, newHeader, 0, myMetadataHeader.length);
            System.arraycopy(additionalHeaders, 0, newHeader, myMetadataHeader.length, additionalHeadersCount);

            setMetadataHeader(newHeader);
        }

        // Then let's loop through the metadata and add or update columns as needed
        for (int index = 0; index < myMetadata.size(); index++) {
            final Item item = items.get(index);

            String[] row = myMetadata.get(index);

            // If the number of columns has changed, increase our metadata row array size
            if (bucketeerStateMissing || accessUrlMissing) {
                final String[] newRow = new String[newHeaderLength];

                System.arraycopy(row, 0, newRow, 0, row.length);
                row = newRow;
            }

            // We mark structural rows with empty statuses before outputting the CSV data
            if (WorkflowState.STRUCTURAL.equals(item.getWorkflowState())) {
                row[bucketeerStateIndex] = WorkflowState.EMPTY.toString();
            } else {
                row[bucketeerStateIndex] = item.getWorkflowState().toString();
            }

            row[accessUrlIndex] = item.getAccessURL();
            myMetadata.set(index, row);
        }

        return this;
    }
/**
     * Update the job's metadata with Bucketeer State and IIIF Access URL.
     *
     * @return The job
     * @throws ProcessingException when there is trouble parsing the metadata
     */
Update the job's metadata with Bucketeer State and IIIF Access URL.
@return The job
@throws ProcessingException when there is trouble parsing the metadata
Update the job ' s metadata with Bucketeer State and IIIF Access URL . @return The job @throws ProcessingException when there is trouble parsing the metadata
public Job updateMetadata() throws ProcessingException {
        final List<Item> items = getItems();
        final String[] newHeader;
        final String[] additionalHeaders;
        final int newHeaderLength;
        final int additionalHeadersCount;
        int bucketeerStateIndex = findHeader(Metadata.BUCKETEER_STATE);
        int accessUrlIndex = findHeader(Metadata.IIIF_ACCESS_URL);
        final boolean bucketeerStateMissing = bucketeerStateIndex == -1;
        final boolean accessUrlMissing = accessUrlIndex == -1;
        if (bucketeerStateMissing && accessUrlMissing) {
            additionalHeadersCount = 2;
            additionalHeaders = new String[additionalHeadersCount];
            additionalHeaders[0] = Metadata.BUCKETEER_STATE;
            additionalHeaders[1] = Metadata.IIIF_ACCESS_URL;
            bucketeerStateIndex = myMetadataHeader.length;
            accessUrlIndex = myMetadataHeader.length + 1;
        } else if (bucketeerStateMissing) {
            additionalHeadersCount = 1;
            additionalHeaders = new String[additionalHeadersCount];
            additionalHeaders[0] = Metadata.BUCKETEER_STATE;
            bucketeerStateIndex = myMetadataHeader.length;
        } else if (accessUrlMissing) {
            additionalHeadersCount = 1;
            additionalHeaders = new String[additionalHeadersCount];
            additionalHeaders[0] = Metadata.IIIF_ACCESS_URL;
            accessUrlIndex = myMetadataHeader.length;
        } else {
            additionalHeadersCount = 0;
            additionalHeaders = new String[additionalHeadersCount];
        }
        LOGGER.debug(MessageCodes.BUCKETEER_155, additionalHeadersCount);
        newHeaderLength = myMetadataHeader.length + additionalHeadersCount;
        if (bucketeerStateMissing || accessUrlMissing) {
            newHeader = new String[newHeaderLength];
            System.arraycopy(myMetadataHeader, 0, newHeader, 0, myMetadataHeader.length);
            System.arraycopy(additionalHeaders, 0, newHeader, myMetadataHeader.length, additionalHeadersCount);
            setMetadataHeader(newHeader);
        }
        for (int index = 0; index < myMetadata.size(); index++) {
            final Item item = items.get(index);
            String[] row = myMetadata.get(index);
            if (bucketeerStateMissing || accessUrlMissing) {
                final String[] newRow = new String[newHeaderLength];
                System.arraycopy(row, 0, newRow, 0, row.length);
                row = newRow;
            }
            if (WorkflowState.STRUCTURAL.equals(item.getWorkflowState())) {
                row[bucketeerStateIndex] = WorkflowState.EMPTY.toString();
            } else {
                row[bucketeerStateIndex] = item.getWorkflowState().toString();
            }
            row[accessUrlIndex] = item.getAccessURL();
            myMetadata.set(index, row);
        }
        return this;
    }
public Job updateMetadata ( ) throws ProcessingException { final List < Item > items = getItems ( ) ; final String [ ] newHeader ; final String [ ] additionalHeaders ; final int newHeaderLength ; final int additionalHeadersCount ; int bucketeerStateIndex = findHeader ( Metadata . BUCKETEER_STATE ) ; int accessUrlIndex = findHeader ( Metadata . IIIF_ACCESS_URL ) ; final boolean bucketeerStateMissing = bucketeerStateIndex == - 1 ; final boolean accessUrlMissing = accessUrlIndex == - 1 ; if ( bucketeerStateMissing && accessUrlMissing ) { additionalHeadersCount = 2 ; additionalHeaders = new String [ additionalHeadersCount ] ; additionalHeaders [ 0 ] = Metadata . BUCKETEER_STATE ; additionalHeaders [ 1 ] = Metadata . IIIF_ACCESS_URL ; bucketeerStateIndex = myMetadataHeader . length ; accessUrlIndex = myMetadataHeader . length + 1 ; } else if ( bucketeerStateMissing ) { additionalHeadersCount = 1 ; additionalHeaders = new String [ additionalHeadersCount ] ; additionalHeaders [ 0 ] = Metadata . BUCKETEER_STATE ; bucketeerStateIndex = myMetadataHeader . length ; } else if ( accessUrlMissing ) { additionalHeadersCount = 1 ; additionalHeaders = new String [ additionalHeadersCount ] ; additionalHeaders [ 0 ] = Metadata . IIIF_ACCESS_URL ; accessUrlIndex = myMetadataHeader . length ; } else { additionalHeadersCount = 0 ; additionalHeaders = new String [ additionalHeadersCount ] ; } LOGGER . debug ( MessageCodes . BUCKETEER_155 , additionalHeadersCount ) ; newHeaderLength = myMetadataHeader . length + additionalHeadersCount ; if ( bucketeerStateMissing || accessUrlMissing ) { newHeader = new String [ newHeaderLength ] ; System . arraycopy ( myMetadataHeader , 0 , newHeader , 0 , myMetadataHeader . length ) ; System . arraycopy ( additionalHeaders , 0 , newHeader , myMetadataHeader . length , additionalHeadersCount ) ; setMetadataHeader ( newHeader ) ; } for ( int index = 0 ; index < myMetadata . size ( ) ; index ++ ) { final Item item = items . get ( index ) ; String [ ] row = myMetadata . get ( index ) ; if ( bucketeerStateMissing || accessUrlMissing ) { final String [ ] newRow = new String [ newHeaderLength ] ; System . arraycopy ( row , 0 , newRow , 0 , row . length ) ; row = newRow ; } if ( WorkflowState . STRUCTURAL . equals ( item . getWorkflowState ( ) ) ) { row [ bucketeerStateIndex ] = WorkflowState . EMPTY . toString ( ) ; } else { row [ bucketeerStateIndex ] = item . getWorkflowState ( ) . toString ( ) ; } row [ accessUrlIndex ] = item . getAccessURL ( ) ; myMetadata . set ( index , row ) ; } return this ; }
Update the job's metadata with Bucketeer State and IIIF Access URL.
Update the job ' s metadata with Bucketeer State and IIIF Access URL .
// Find the index position of our two columns: Bucketeer State and Access URL // Check which headers already exist in the metadata // If both headers are missing, we need to expand our headers array by two // If only one header is missing, we need to expand our headers array by one // Expand by one // No change // Update the headers if there are changes // Then let's loop through the metadata and add or update columns as needed // If the number of columns has changed, increase our metadata row array size // We mark structural rows with empty statuses before outputting the CSV data