Example usage for java.util List toString

List of usage examples for java.util List toString

Introduction

In this page you can find the example usage for java.util List toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:hudson.plugins.emailext.plugins.recipients.FailingTestSuspectsRecipientProviderTest.java

private static void checkRecipients(final Build build, final String... inAuthors) throws AddressException {
    ExtendedEmailPublisherContext context = new ExtendedEmailPublisherContext(null, build,
            new Launcher.LocalLauncher(StreamTaskListener.fromStdout()),
            new StreamBuildListener(System.out, Charset.defaultCharset()));
    EnvVars envVars = new EnvVars();
    Set<InternetAddress> to = new HashSet<InternetAddress>();
    Set<InternetAddress> cc = new HashSet<InternetAddress>();
    Set<InternetAddress> bcc = new HashSet<InternetAddress>();
    FailingTestSuspectsRecipientProvider provider = new FailingTestSuspectsRecipientProvider();
    provider.addRecipients(context, envVars, to, cc, bcc);
    final List<InternetAddress> authors = new ArrayList<InternetAddress>();
    for (final String author : inAuthors) {
        authors.add(new InternetAddress(author + AT_DOMAIN));
    }/*from ww  w  .  j  a v a2  s.  co  m*/
    // All of the authors should have received an email, so the list should be empty.
    authors.removeAll(to);
    assertTrue("Authors not receiving mail: " + authors.toString(), authors.isEmpty());
    assertTrue(cc.isEmpty());
    assertTrue(bcc.isEmpty());
}

From source file:org.wte4j.impl.format.FormatterRegistry.java

static Formatter createFormatter(Class<? extends Formatter> formatterClass, List<String> args) {
    try {//from  ww w  .j  av a 2s  .c om
        String springExpression = createSpringExpression(formatterClass, args);
        ExpressionParser parser = new SpelExpressionParser();
        Expression exp = parser.parseExpression(springExpression);
        return exp.getValue(Formatter.class);
    } catch (Exception e) {
        throw new FormatterInstantiationException(
                "Can not create new Instance of " + formatterClass.getName() + "with args " + args.toString(),
                e);
    }
}

From source file:com.dell.asm.asmcore.asmmanager.util.DeviceGroupUtil.java

/**
 * Validate Devices/*from   w  ww .  j a  va  2  s  . c om*/
 * 
 * @param entity - device group entity to be validated
 * 
 * @throws AsmManagerCheckedException
 */
public static void validateDeviceObject(DeviceGroupEntity entity) throws AsmManagerCheckedException {

    if (null == entity.getDeviceInventories())
        return;

    List<String> device_Ids = getDeviceIds(entity.getDeviceInventories());
    List<DeviceInventoryEntity> deviceInvList = DEVICE_INVENTORY_DAO.getDevicesByIds(device_Ids);
    Map<String, DeviceInventoryEntity> deviceIdInventoryMap = getDeviceIdInventoryMap(deviceInvList);

    List<String> invalidDeviceIds = new ArrayList<>();
    for (String str : device_Ids) {
        if (!deviceIdInventoryMap.keySet().contains(str)) {
            invalidDeviceIds.add(str);
        }
    }

    if (invalidDeviceIds.size() > 0) {
        throw new AsmManagerCheckedException(AsmManagerCheckedException.REASON_CODE.INVALID_ID,
                AsmManagerMessages.deviceIdsNotFound(invalidDeviceIds.toString()));
    }
    entity.setDeviceInventories(deviceInvList);

}

From source file:com.github.lucapino.sheetmaker.renderer.TemplateFilter.java

public static Map<String, String> createTokenMap(Movie movie, MovieInfo movieInfo, Episode episode) {
    Map<String, String> result = new HashMap<>();
    result.put("%TITLEPATH%", movieInfo.getTitlePath());
    //    %MOVIEFILENAME%    Current movie filename    Spread.2009.mkv (for c,\movies\spread\spread.2009.mkv)
    result.put("%MOVIEFILENAME%", movieInfo.getMovieFileName());

    //    %MOVIEFILENAMEWITHOUTEXT%    Current movie filename without extension    Spread.2009 (for c,\Movies\Spread\Spread.2009.mkv)
    result.put("%MOVIEFILENAMEWITHOUTEXT%", FilenameUtils.getBaseName(movieInfo.getMovieFileName()));

    //    %MOVIEFOLDER%    Current movie folder name    Spread (for c,\Movies\Spread\Spread.2009.mkv)
    result.put("%MOVIEFOLDER%", movieInfo.getMovieFolder());

    //    %MOVIEPARENTFOLDER%    Current movie parent folder name    Movies (for c,\Movies\Spread\Spread.2009.mkv)
    result.put("%MOVIEPARENTFOLDER%", movieInfo.getParentMovieFolder());

    result.put("%TITLE%", movie.getTitle());

    //    %ORIGINALTITLE%    Original movie title    Inglourious Basterds
    result.put("%ORIGINALTITLE%", movie.getOriginalTitle());

    //    %PLOT%    Synopsis    Some description of the movie.
    result.put("%PLOT%", movie.getPlot());

    //    %TAGLINE%    The Tagline    Some tagline
    result.put("%TAGLINE%", movie.getTagline());

    //    %COMMENTS%    Free "joker" field for the user own data    Some free test the user can place on the sheet
    //TODO/*from   w  w  w . ja v  a  2s.  c o m*/
    result.put("%COMMENTS%", "");

    result.put("%YEAR%", movie.getYear());

    result.put("%RUNTIME%", movie.getRuntime());

    String actors = movie.getActors().toString();
    result.put("%ACTORS%", actors.substring(1, actors.length() - 1));

    String genres = movie.getGenres().toString();
    result.put("%GENRES%", genres.substring(1, genres.length() - 1));

    String directors = movie.getDirectors().toString();
    result.put("%DIRECTORS%", directors.substring(1, directors.length() - 1));

    result.put("%CERTIFICATION%", movie.getCertification());

    result.put("%RELEASEDATE%", movie.getReleaseDate());

    result.put("%MPAA%", movie.getMPAA());

    //    %IMDBID%    IMDb Id of the movie    tt1186370
    result.put("%IMDBID%", movie.getImdbId());

    result.put("%CERTIFICATIONTEXT%", movie.getCertification());
    String countries = movie.getCountries().toString();
    result.put("%COUNTRIES%", countries.substring(1, countries.length() - 1));

    String studios = movie.getStudios().toString();
    result.put("%STUDIOS%", studios.substring(1, studios.length() - 1));

    //    %ALLSUBTITLES%    List of distinct embedded/external subtitles (English names)    English, Spanish,German *
    String allSubtitles = movieInfo.getAllSubtitles().toString();
    result.put("%ALLSUBTITLES%", allSubtitles.substring(1, allSubtitles.length() - 1));

    //    %ALLSUBTITLESTEXT%    List of distinct embedded/external subtitles (native names)    English, Espanol,Deutsch *
    String allLocalizedSubtitles = movieInfo.getAllLocalizedSubtitles().toString();
    result.put("%ALLSUBTITLESTEXT%", allLocalizedSubtitles.substring(1, allLocalizedSubtitles.length() - 1));

    String embeddedSubtitles = movieInfo.getEmbeddedSubtitles().toString();
    result.put("%SUBTITLES%", embeddedSubtitles.substring(1, embeddedSubtitles.length() - 1));

    //    %SUBTITLES1%  %SUBTITLES5%    Individual embedded subtitles (English names)    English
    //    %SUBTITLESTEXT%    List of embedded subtitles (Native names)    English, Francais, Deutsch *
    String embeddedLocalizedSubtitles = movieInfo.getEmbeddedLocalizedSubtitles().toString();
    result.put("%SUBTITLESTEXT%",
            embeddedLocalizedSubtitles.substring(1, embeddedLocalizedSubtitles.length() - 1));

    //    %EXTERNALSUBTITLESTEXT%    List of external subtitles (Native names)    English, Francais, Deutsch *
    String externalLocalizedSubtitles = movieInfo.getExternalLocalizedSubtitles().toString();
    result.put("%EXTERNALSUBTITLESTEXT%",
            externalLocalizedSubtitles.substring(1, externalLocalizedSubtitles.length() - 1));

    //    %EXTERNALSUBTITLES%    List of external subtitles (English names)    English, French *
    String externalSubtitles = movieInfo.getExternalSubtitles().toString();
    result.put("%EXTERNALSUBTITLES%", externalSubtitles.substring(1, externalSubtitles.length() - 1));

    //    %EXTERNALSUBTITLES1%  %EXTERNALSUBTITLES5%    Individual external subtitles (English names)    English
    // TODO
    //    %RATING%    The rating of the movie (x of 10)    6.8/10
    result.put("%RATING%", (Double.valueOf(movie.getRatingPercent()) / 10) + "/10");

    //    %RATINGPERCENT%    The rating as percent   68
    result.put("%RATINGPERCENT%", movie.getRatingPercent());

    if (episode != null) {
        /**
         * ************** Start TV Shows ********************
         */
        //    %SEASON%    The autodetected season number for the current movie   4
        result.put("%SEASON%", "" + episode.getSeason().getNumber());

        //    %EPISODE%    The autodetected episode (or CD) number for the current movie   2
        result.put("%EPISODE%", "" + episode.getNumber());

        //    %EPISODETITLE%    The current episode name    Fire + Water
        result.put("%EPISODETITLE%", episode.getTitle());

        //    %EPISODEPLOT%    Synopsis of the current episode    Some description of the episode.
        result.put("%EPISODEPLOT%", episode.getOverview());

        //    %EPISODERELEASEDATE%    Release date of the current episode    12.03.2010 (formatted using collector's format)
        // TODO
        result.put("%EPISODERELEASEDATE%", "");

        //    %EPISODELIST%    List of episodes for the current season    1, 2, 3 *
        List<Episode> episodes = episode.getSeason().getEpisodes();
        List<String> episodeList = new ArrayList<>();
        for (Episode currentEpisode : episodes) {
            episodeList.add("" + currentEpisode.getNumber());
        }
        String res = episodeList.toString();
        result.put("%EPISODELIST%", res.substring(1, res.length() - 1));

        //    %EPISODENAMESLIST%    List of episodes titles for the current season    Title One, Title Two *
        episodes = episode.getSeason().getEpisodes();
        List<String> episodeNameList = new ArrayList<>();
        for (Episode currentEpisode : episodes) {
            episodeNameList.add(currentEpisode.getTitle());
        }
        res = episodeNameList.toString();
        result.put("%EPISODENAMESLIST%", res.substring(1, res.length() - 1));

        //    %EPISODEGUESTSTARS%    List of guest stars for the current episode    John B, John C *
        List<String> episodeGuestsList = episode.getGuestStars();
        String episodeGuests = episodeGuestsList.toString();
        result.put("%EPISODEGUESTSTARS%", episodeGuests.substring(1, episodeGuests.length() - 1));

        //    %EPISODEWRITERS%    List of writers for the current episode    John B, John C *
        // TODO
        result.put("%EPISODEWRITERS%", "");
    }
    /**
     * ************** End TV Shows ********************
     */
    //    %MEDIAFORMATTEXT%    See below list of media values supported. Loaded from /Template/MediaFormats/MediaFormat/@Name Returns value from @Text attribute    MKV
    result.put("%MEDIAFORMATTEXT%", movieInfo.getMediaformat());

    //    %SOUNDFORMATTEXT%    See below list of sound values supported. /Template/SoundFormats/SoundFormat/@Name Returns value from @Text attribute    MP3
    result.put("%SOUNDFORMATTEXT%", movieInfo.getSoundFormat());

    //    %RESOLUTIONTEXT%    See below list of resolution values supported. /Template/Resolutions/Resolution/@Name Returns value from @Text attribute    1080P
    result.put("%RESOLUTIONTEXT%", movieInfo.getResolution());

    //    %VIDEOFORMATTEXT%    See below list of video values supported. /Template/VideoFormats/VideoFormat/@Name Returns value from @Text attribute    AVC
    result.put("%VIDEOFORMATTEXT%", movieInfo.getVideoFormat());

    result.put("%FRAMERATETEXT%", movieInfo.getFrameRate());

    //    %FRAMERATE%    Formatted frame rate of the movie (to allow mapping to filenames). The . character is replaced by the _ character.    23_976
    result.put("%FRAMERATE%", movieInfo.getFrameRate().replace(".", "_"));

    result.put("%ASPECTRATIOTEXT%", movieInfo.getAspectRatio());

    //    %ASPECTRATIO%    Formatted aspect ration (to allow mapping to filenames). The . character is replaced by the _ character and the , character is replaced by -.    16-9 or 2_35-1 or 4-3
    result.put("%ASPECTRATIO%", movieInfo.getAspectRatio().replace(":", "-"));

    result.put("%VIDEORESOLUTION%", movieInfo.getVideoResolution());

    //    %VIDEORESOLUTIONTEXT%    The movie resolution    1920x1080
    result.put("%VIDEORESOLUTIONTEXT%", movieInfo.getVideoResolution());

    // TODO
    result.put("%VIDEOCODECTEXT%", "");
    result.put("%VIDEOBITRATETEXT%", movieInfo.getVideoBitrate());

    result.put("%AUDIOCODECTEXT%", movieInfo.getAllAudioInfo().get(0).getAudioCodec());

    result.put("%AUDIOCHANNELSTEXT%", movieInfo.getAudioChannels());

    result.put("%AUDIOBITRATETEXT%", movieInfo.getAudioBitrate());

    // TODO, convert in minutes
    result.put("%DURATIONTEXT%", movieInfo.getDuration());

    //    %DURATION%    The detected (mediainfo) duration of the movie (minutes)   98
    result.put("%DURATION%", movieInfo.getDuration());

    //    %DURATIONSEC%    The detected (mediainfo) duration of the movie (seconds)   5880
    result.put("%DURATIONSEC%", "" + (Integer.valueOf(movieInfo.getDuration()) * 60));

    // TODO, convert in human kB, MB, GB
    result.put("%FILESIZETEXT%", movieInfo.getFileSize());

    //    %CONTAINERTEXT%    The detected (mediainfo) container format (as it comes from MediaInfo)    Matroska
    result.put("%CONTAINERTEXT%", movieInfo.getContainer());

    //    %LANGUAGECODE%    The two letter ISO code of the language of the first audio stream    en
    result.put("%LANGUAGECODE%", movieInfo.getLanguageCode());

    //    %LANGUAGE%    The language of the first audio stream (always the English name)    Spanish
    result.put("%LANGUAGE%", movieInfo.getLanguage());

    //    %LANGUAGES%    The languages of all audio streams (always the English names)    Spanish/English/Italian *
    List<String> languages = new ArrayList<>();
    for (AudioInfo audioInfo : movieInfo.getAllAudioInfo()) {
        languages.add(audioInfo.getLanguage());
    }
    String languagesString = languages.toString();
    result.put("%LANGUAGES%", languagesString.substring(1, languagesString.length() - 1));

    //    %LANGUAGECODES%    The two letter ISO code of the languages of all audio streams    es/en/it *
    List<String> languagesCodes = new ArrayList<>();

    for (AudioInfo audioInfo : movieInfo.getAllAudioInfo()) {
        languagesCodes.add(audioInfo.getLanguageCode().toLowerCase());
    }
    String languagesCodesString = languagesCodes.toString();
    result.put("%LANGUAGECODES%", languagesCodesString.substring(1, languagesCodesString.length() - 1));

    //    %CERTIFICATIONCOUNTRYCODE%    The two letter code of the country selected in Options/IMDB as Certification Country (default value, us)    es
    result.put("%CERTIFICATIONCOUNTRYCODE%", "us");

    //    %LANGUAGES1%  %LANGUAGES5%    Individual audio languages (English names)    English                
    // TODO
    result.put("%LANGUAGES1%", "");
    return result;
}

From source file:com.clustercontrol.winevent.dialog.WinEventDialog.java

private static String listToCommaSeparatedString(List<?> list) {
    if (list != null) {
        String string = list.toString();
        string = string.replace("[", "");
        string = string.replace("]", "");
        return string;
    } else {//  w w w.ja  v a 2 s.c  o  m
        return null;
    }
}

From source file:com.gst.integrationtests.common.GroupHelper.java

public static void verifyGroupDeleted(final RequestSpecification requestSpec,
        final ResponseSpecification responseSpec, final Integer generatedGroupID) {
    List<String> list = new ArrayList<>();
    System.out/*  w  w w .ja  v a2  s.  co m*/
            .println("------------------------------CHECK GROUP DELETED------------------------------------\n");
    final String GROUP_URL = "/fineract-provider/api/v1/groups/?" + Utils.TENANT_IDENTIFIER;
    list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "pageItems");

    assertFalse("GROUP NOT DELETED", list.toString().contains("id=" + generatedGroupID.toString()));
}

From source file:jeeves.server.sources.JeevletServiceRequestFactory.java

/**
 * Builds the request with data supplied by tomcat. A request is in the
 * form: srv/<language>/<service>[!]<parameters>
 *//*from   ww  w.ja  v  a 2 s . co m*/

public static JeevletServiceRequest create(Request req, Response res, String uploadDir, int maxUploadSize)
        throws Exception {
    // String url = req.getPathInfo();
    String url = req.getResourceRef().getPath();

    // FIXME jeeves : if request character encoding is undefined set it to UTF-8
    if (req.getEntity() != null && req.getEntity().getCharacterSet() == null)
        req.getEntity().setCharacterSet(CharacterSet.UTF_8);

    // --- extract basic info

    JeevletServiceRequest srvReq = new JeevletServiceRequest(res);

    srvReq.setDebug(extractDebug(url));
    srvReq.setLanguage(extractLanguage(url));
    srvReq.setService(extractService(url));
    srvReq.setAddress(req.getClientInfo().getAddress()); // getRemoteAddr());
    //      srvReq.setOutputStream(res.getOutputStream());

    // --- discover the input/output methods

    // Output content type negociation 
    List<Preference<MediaType>> accept = req.getClientInfo().getAcceptedMediaTypes();

    if (accept != null) {
        // TODO Use MediaType content negociation instead ? ( at least, needs MediaType for "application/soap+xml" )
        int soapNDX = accept.toString().indexOf("application/soap+xml");
        int xmlNDX = accept.toString().indexOf("application/xml");
        int htmlNDX = accept.toString().indexOf("html"); // peut tre xhtml ...

        if (soapNDX != -1)
            srvReq.setOutputMethod(jeeves.server.sources.ServiceRequest.OutputMethod.SOAP);

        else if (xmlNDX != -1 && htmlNDX == -1)
            srvReq.setOutputMethod(jeeves.server.sources.ServiceRequest.OutputMethod.XML);
    }

    // Input POST request processing
    if ("POST".equals(req.getMethod().getName())) {
        srvReq.setInputMethod(jeeves.server.sources.ServiceRequest.InputMethod.POST);

        // FIXME posted entity[mediatype] can be null
        String contType = req.getEntity().getMediaType().getName(); // getContentType();

        if (contType != null) {
            if (contType.indexOf("application/soap+xml") != -1) {
                srvReq.setInputMethod(jeeves.server.sources.ServiceRequest.InputMethod.SOAP);
                srvReq.setOutputMethod(jeeves.server.sources.ServiceRequest.OutputMethod.SOAP);
            }

            else if (contType.indexOf("application/xml") != -1 || contType.indexOf("text/xml") != -1) {
                srvReq.setInputMethod(jeeves.server.sources.ServiceRequest.InputMethod.XML);
            }
        }
    }

    // --- retrieve input parameters

    jeeves.server.sources.ServiceRequest.InputMethod input = srvReq.getInputMethod();

    if ((input == jeeves.server.sources.ServiceRequest.InputMethod.XML)
            || (input == jeeves.server.sources.ServiceRequest.InputMethod.SOAP)) {

        if ("GET".equals(req.getMethod().getName()))
            srvReq.setParams(extractParameters(req, uploadDir, maxUploadSize));
        else {
            Element params = extractXmlParameters(req);
            srvReq.setParams(params);
        }
    } else {
        // --- GET or POST
        Element params = extractParameters(req, uploadDir, maxUploadSize);
        srvReq.setParams(params);
    }

    srvReq.setHeaders(extractHeaders(req));

    return srvReq;
}

From source file:dk.netarkivet.archive.webinterface.BitpreserveFileState.java

/**
 * Present a list of checksums in a human-readable form. If size of list is 0, it returns "No checksum". If size of
 * list is 1, it returns the one available checksum. Otherwise, it returns toString of the list.
 *
 * @param csum List of checksum strings// ww  w  .  j ava 2  s.c  om
 * @param locale The given locale.
 * @return String presenting the checksums.
 */
public static String presentChecksum(List<String> csum, Locale locale) {
    ArgumentNotValid.checkNotNull(csum, "List<String> csum");
    ArgumentNotValid.checkNotNull(locale, "Locale locale");
    String csumString = csum.toString();
    if (csum.isEmpty()) {
        csumString = I18N.getString(locale, "no.checksum");
    } else if (csum.size() == 1) {
        csumString = csum.get(0);
    }
    return csumString;
}

From source file:org.openmrs.module.spreadsheetimport.SpreadsheetImportUtil.java

public static File importTemplate(SpreadsheetImportTemplate template, MultipartFile file, String sheetName,
        List<String> messages, boolean rollbackTransaction) throws Exception {

    if (file.isEmpty()) {
        messages.add("file must not be empty");
        return null;
    }//from   w  ww .jav  a  2  s.c  om

    // Open file
    Workbook wb = WorkbookFactory.create(file.getInputStream());
    Sheet sheet;
    if (!StringUtils.hasText(sheetName)) {
        sheet = wb.getSheetAt(0);
    } else {
        sheet = wb.getSheet(sheetName);
    }

    // Header row
    Row firstRow = sheet.getRow(0);
    if (firstRow == null) {
        messages.add("Spreadsheet header row must not be null");
        return null;
    }

    List<String> columnNames = new Vector<String>();
    for (Cell cell : firstRow) {
        columnNames.add(cell.getStringCellValue());
    }
    if (log.isDebugEnabled()) {
        log.debug("Column names: " + columnNames.toString());
    }

    // Required column names
    List<String> columnNamesOnlyInTemplate = new Vector<String>();
    columnNamesOnlyInTemplate.addAll(template.getColumnNamesAsList());
    columnNamesOnlyInTemplate.removeAll(columnNames);
    if (columnNamesOnlyInTemplate.isEmpty() == false) {
        messages.add("required column names not present: " + toString(columnNamesOnlyInTemplate));
        return null;
    }

    // Extra column names?
    List<String> columnNamesOnlyInSheet = new Vector<String>();
    columnNamesOnlyInSheet.addAll(columnNames);
    columnNamesOnlyInSheet.removeAll(template.getColumnNamesAsList());
    if (columnNamesOnlyInSheet.isEmpty() == false) {
        messages.add(
                "Extra column names present, these will not be processed: " + toString(columnNamesOnlyInSheet));
    }

    // Process rows
    boolean skipThisRow = true;
    for (Row row : sheet) {
        if (skipThisRow == true) {
            skipThisRow = false;
        } else {
            boolean rowHasData = false;
            Map<UniqueImport, Set<SpreadsheetImportTemplateColumn>> rowData = template
                    .getMapOfUniqueImportToColumnSetSortedByImportIdx();

            for (UniqueImport uniqueImport : rowData.keySet()) {
                Set<SpreadsheetImportTemplateColumn> columnSet = rowData.get(uniqueImport);
                for (SpreadsheetImportTemplateColumn column : columnSet) {

                    int idx = columnNames.indexOf(column.getName());
                    Cell cell = row.getCell(idx);

                    Object value = null;
                    // check for empty cell (new Encounter)
                    if (cell == null) {
                        rowHasData = true;
                        column.setValue("");
                        continue;
                    }

                    switch (cell.getCellType()) {
                    case Cell.CELL_TYPE_BOOLEAN:
                        value = new Boolean(cell.getBooleanCellValue());
                        break;
                    case Cell.CELL_TYPE_ERROR:
                        value = new Byte(cell.getErrorCellValue());
                        break;
                    case Cell.CELL_TYPE_FORMULA:
                    case Cell.CELL_TYPE_NUMERIC:
                        if (DateUtil.isCellDateFormatted(cell)) {
                            java.util.Date date = cell.getDateCellValue();
                            value = "'" + new java.sql.Timestamp(date.getTime()).toString() + "'";
                        } else {
                            value = cell.getNumericCellValue();
                        }
                        break;
                    case Cell.CELL_TYPE_STRING:
                        // Escape for SQL
                        value = "'" + cell.getRichStringCellValue() + "'";
                        break;
                    }
                    if (value != null) {
                        rowHasData = true;
                        column.setValue(value);
                    } else
                        column.setValue("");
                }
            }

            for (UniqueImport uniqueImport : rowData.keySet()) {
                Set<SpreadsheetImportTemplateColumn> columnSet = rowData.get(uniqueImport);
                boolean isFirst = true;
                for (SpreadsheetImportTemplateColumn column : columnSet) {

                    if (isFirst) {
                        // Should be same for all columns in unique import
                        //                     System.out.println("SpreadsheetImportUtil.importTemplate: column.getColumnPrespecifiedValues(): " + column.getColumnPrespecifiedValues().size());
                        if (column.getColumnPrespecifiedValues().size() > 0) {
                            Set<SpreadsheetImportTemplateColumnPrespecifiedValue> columnPrespecifiedValueSet = column
                                    .getColumnPrespecifiedValues();
                            for (SpreadsheetImportTemplateColumnPrespecifiedValue columnPrespecifiedValue : columnPrespecifiedValueSet) {
                                //                           System.out.println(columnPrespecifiedValue.getPrespecifiedValue().getValue());
                            }
                        }
                    }
                }
            }

            if (rowHasData) {
                Exception exception = null;
                try {
                    DatabaseBackend.validateData(rowData);
                    String encounterId = DatabaseBackend.importData(rowData, rollbackTransaction);
                    if (encounterId != null) {
                        for (UniqueImport uniqueImport : rowData.keySet()) {
                            Set<SpreadsheetImportTemplateColumn> columnSet = rowData.get(uniqueImport);
                            for (SpreadsheetImportTemplateColumn column : columnSet) {
                                if ("encounter".equals(column.getTableName())) {
                                    int idx = columnNames.indexOf(column.getName());
                                    Cell cell = row.getCell(idx);
                                    if (cell == null)
                                        cell = row.createCell(idx);
                                    cell.setCellValue(encounterId);
                                }
                            }
                        }
                    }
                } catch (SpreadsheetImportTemplateValidationException e) {
                    messages.add("Validation failed: " + e.getMessage());
                    return null;
                } catch (SpreadsheetImportDuplicateValueException e) {
                    messages.add("found duplicate value for column " + e.getColumn().getName() + " with value "
                            + e.getColumn().getValue());
                    return null;
                } catch (SpreadsheetImportSQLSyntaxException e) {
                    messages.add("SQL syntax error: \"" + e.getSqlErrorMessage()
                            + "\".<br/>Attempted SQL Statement: \"" + e.getSqlStatement() + "\"");
                    return null;
                } catch (Exception e) {
                    exception = e;
                }
                if (exception != null) {
                    throw exception;
                }
            }
        }
    }

    // write back Excel file to a temp location
    File returnFile = File.createTempFile("sim", ".xls");
    FileOutputStream fos = new FileOutputStream(returnFile);
    wb.write(fos);
    fos.close();

    return returnFile;
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController.java

public static IndividualListResults getResultsForVClassIntersections(List<String> vclassURIs, int page,
        int pageSize, String alpha, IndividualDao indDao) {
    try {/*from ww w  .  j  a  v  a  2s.c om*/
        IndividualListQueryResults results = buildAndExecuteVClassQuery(vclassURIs, alpha, page, pageSize,
                indDao);
        return getResultsForVClassQuery(results, page, pageSize, alpha);
    } catch (Throwable th) {
        log.error("Error retrieving individuals corresponding to intersection multiple classes."
                + vclassURIs.toString(), th);
        return IndividualListResults.EMPTY;
    }
}