gradebookng/tool/src/java/org/sakaiproject/gradebookng/business/util/ImportGradesHelper.java
private static ImportedRow mapLine(final String[] line, final Map<Integer, ImportedColumn> mapping, final Map<String, String> userMap) {

		final ImportedRow row = new ImportedRow();

		for (final Map.Entry<Integer, ImportedColumn> entry : mapping.entrySet()) {

			final int i = entry.getKey();
			final ImportedColumn column = entry.getValue();

			// In case there aren't enough data fields in the line to match up with the number of columns needed
			String lineVal = null;
			if (i < line.length) {
				lineVal = trim(line[i]);
			}

			final String columnTitle = column.getColumnTitle();

			ImportedCell cell = row.getCellMap().get(columnTitle);
			if (cell == null) {
				cell = new ImportedCell();
			}

			if (column.getType() == ImportedColumn.Type.USER_ID) {

				//skip blank lines
				if(StringUtils.isBlank(lineVal)) {
					log.debug("Skipping empty row");
					return null;
				}

				// check user is in the map (ie in the site)
				final String studentUuid = userMap.get(lineVal);
				if(StringUtils.isBlank(studentUuid)){
					log.debug("Student was found in file but not in site: " + lineVal);
					throw new GbImportExportUnknownStudentException("Student was found in file but not in site: " + lineVal);
				}
				row.setStudentEid(lineVal);
				row.setStudentUuid(studentUuid);

			} else if (column.getType() == ImportedColumn.Type.USER_NAME) {
				row.setStudentName(lineVal);

			} else if (column.getType() == ImportedColumn.Type.GB_ITEM_WITH_POINTS) {
				cell.setScore(lineVal);
				row.getCellMap().put(columnTitle, cell);

			} else if (column.getType() == ImportedColumn.Type.GB_ITEM_WITHOUT_POINTS) {
				cell.setScore(lineVal);
				row.getCellMap().put(columnTitle, cell);

			} else if (column.getType() == ImportedColumn.Type.COMMENTS) {
				cell.setComment(lineVal);
				row.getCellMap().put(columnTitle, cell);
			}

		}

		return row;
	}
/**
	 * Takes a row of data and maps it into the appropriate {@link ImportedRow} pieces
	 *
	 * @param line
	 * @param mapping
	 * @return
	 * @throws GbImportExportUnknownStudentException if a row for a student is found that does not exist in the userMap
	 */
Takes a row of data and maps it into the appropriate  ImportedRow pieces
@param line
@param mapping
@return
@throws GbImportExportUnknownStudentException if a row for a student is found that does not exist in the userMap
Takes a row of data and maps it into the appropriate ImportedRow pieces @param line @param mapping @return @throws GbImportExportUnknownStudentException if a row for a student is found that does not exist in the userMap
private static ImportedRow mapLine(final String[] line, final Map<Integer, ImportedColumn> mapping, final Map<String, String> userMap) {
		final ImportedRow row = new ImportedRow();
		for (final Map.Entry<Integer, ImportedColumn> entry : mapping.entrySet()) {
			final int i = entry.getKey();
			final ImportedColumn column = entry.getValue();
			String lineVal = null;
			if (i < line.length) {
				lineVal = trim(line[i]);
			}
			final String columnTitle = column.getColumnTitle();
			ImportedCell cell = row.getCellMap().get(columnTitle);
			if (cell == null) {
				cell = new ImportedCell();
			}
			if (column.getType() == ImportedColumn.Type.USER_ID) {
				if(StringUtils.isBlank(lineVal)) {
					log.debug("Skipping empty row");
					return null;
				}
				final String studentUuid = userMap.get(lineVal);
				if(StringUtils.isBlank(studentUuid)){
					log.debug("Student was found in file but not in site: " + lineVal);
					throw new GbImportExportUnknownStudentException("Student was found in file but not in site: " + lineVal);
				}
				row.setStudentEid(lineVal);
				row.setStudentUuid(studentUuid);
			} else if (column.getType() == ImportedColumn.Type.USER_NAME) {
				row.setStudentName(lineVal);
			} else if (column.getType() == ImportedColumn.Type.GB_ITEM_WITH_POINTS) {
				cell.setScore(lineVal);
				row.getCellMap().put(columnTitle, cell);
			} else if (column.getType() == ImportedColumn.Type.GB_ITEM_WITHOUT_POINTS) {
				cell.setScore(lineVal);
				row.getCellMap().put(columnTitle, cell);
			} else if (column.getType() == ImportedColumn.Type.COMMENTS) {
				cell.setComment(lineVal);
				row.getCellMap().put(columnTitle, cell);
			}
		}
		return row;
	}
private static ImportedRow mapLine ( final String [ ] line , final Map < Integer , ImportedColumn > mapping , final Map < String , String > userMap ) { final ImportedRow row = new ImportedRow ( ) ; for ( final Map . Entry < Integer , ImportedColumn > entry : mapping . entrySet ( ) ) { final int i = entry . getKey ( ) ; final ImportedColumn column = entry . getValue ( ) ; String lineVal = null ; if ( i < line . length ) { lineVal = trim ( line [ i ] ) ; } final String columnTitle = column . getColumnTitle ( ) ; ImportedCell cell = row . getCellMap ( ) . get ( columnTitle ) ; if ( cell == null ) { cell = new ImportedCell ( ) ; } if ( column . getType ( ) == ImportedColumn . Type . USER_ID ) { if ( StringUtils . isBlank ( lineVal ) ) { log . debug ( "Skipping empty row" ) ; return null ; } final String studentUuid = userMap . get ( lineVal ) ; if ( StringUtils . isBlank ( studentUuid ) ) { log . debug ( "Student was found in file but not in site: " + lineVal ) ; throw new GbImportExportUnknownStudentException ( "Student was found in file but not in site: " + lineVal ) ; } row . setStudentEid ( lineVal ) ; row . setStudentUuid ( studentUuid ) ; } else if ( column . getType ( ) == ImportedColumn . Type . USER_NAME ) { row . setStudentName ( lineVal ) ; } else if ( column . getType ( ) == ImportedColumn . Type . GB_ITEM_WITH_POINTS ) { cell . setScore ( lineVal ) ; row . getCellMap ( ) . put ( columnTitle , cell ) ; } else if ( column . getType ( ) == ImportedColumn . Type . GB_ITEM_WITHOUT_POINTS ) { cell . setScore ( lineVal ) ; row . getCellMap ( ) . put ( columnTitle , cell ) ; } else if ( column . getType ( ) == ImportedColumn . Type . COMMENTS ) { cell . setComment ( lineVal ) ; row . getCellMap ( ) . put ( columnTitle , cell ) ; } } return row ; }
Takes a row of data and maps it into the appropriate {@link ImportedRow} pieces
 @param line
 @param mapping
 @return
 @throws GbImportExportUnknownStudentException if a row for a student is found that does not exist in the userMap
Takes a row of data and maps it into the appropriate { @link ImportedRow } pieces @param line @param mapping @return @throws GbImportExportUnknownStudentException if a row for a student is found that does not exist in the userMap
// In case there aren't enough data fields in the line to match up with the number of columns needed //skip blank lines // check user is in the map (ie in the site)