Example usage for java.util List listIterator

List of usage examples for java.util List listIterator

Introduction

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

Prototype

ListIterator<E> listIterator();

Source Link

Document

Returns a list iterator over the elements in this list (in proper sequence).

Usage

From source file:com.alibaba.citrus.maven.eclipse.base.eclipse.EclipsePlugin.java

/**
 * Convert any Strings in the <code>commands</code> List to <code>BuildCommand</code>s. The conversion happens in
 * situ.//  w  w  w .  ja  va 2 s  .  c  o  m
 *
 * @param commands a list of commands to convert into <code>BuildCommand</code>
 */
protected final void convertBuildCommandList(List commands) {
    if (commands != null) {
        for (ListIterator i = commands.listIterator(); i.hasNext();) {
            Object command = i.next();

            if (command instanceof String) {
                command = new BuildCommand((String) command);
                i.set(command);
            }
        }
    }
}

From source file:org.apache.gobblin.salesforce.SalesforceExtractor.java

@Override
public List<Command> getCountMetadata(String schema, String entity, WorkUnit workUnit,
        List<Predicate> predicateList) throws RecordCountException {
    log.debug("Build url to retrieve source record count");
    String existingPredicate = "";
    if (this.updatedQuery != null) {
        String queryLowerCase = this.updatedQuery.toLowerCase();
        int startIndex = queryLowerCase.indexOf(" where ");
        if (startIndex > 0) {
            existingPredicate = this.updatedQuery.substring(startIndex);
        }//from w  ww.  ja  v a2 s.co  m
    }

    String query = "SELECT COUNT() FROM " + entity + existingPredicate;
    String limitString = getLimitFromInputQuery(query);
    query = query.replace(limitString, "");

    try {
        if (isNullPredicate(predicateList)) {
            log.info("QUERY with null predicate: " + query);
            return constructGetCommand(this.sfConnector.getFullUri(getSoqlUrl(query)));
        }
        Iterator<Predicate> i = predicateList.listIterator();
        while (i.hasNext()) {
            Predicate predicate = i.next();
            query = SqlQueryUtils.addPredicate(query, predicate.getCondition());
        }

        query = query + getLimitFromInputQuery(this.updatedQuery);
        log.info("QUERY: " + query);
        return constructGetCommand(this.sfConnector.getFullUri(getSoqlUrl(query)));
    } catch (Exception e) {
        throw new RecordCountException(
                "Failed to get salesforce url for record count; error - " + e.getMessage(), e);
    }
}

From source file:it.eng.spagobi.commons.presentation.tags.ListTag.java

/**
 * Starting from the module <code>buttonsSB</code> object, 
 * creates all buttons for the jsp list. These buttons are next to colums names 
 * @param buttons The list of the buttons 
 * //from ww  w  .j  a  va2  s.  c  om
 * @throws JspException If any exception occurs.
 */

protected StringBuffer makeTitleButton(List buttons) throws JspException {

    StringBuffer htmlStream = new StringBuffer();
    try {
        Iterator iter = buttons.listIterator();
        boolean buttonYes = false;
        if (iter.hasNext()) {
            buttonYes = true;
            htmlStream.append("<td class=\"portlet-section-header\" style=\"width: 32px;\">\n");

        }

        while (iter.hasNext()) {
            SourceBeanAttribute buttonSBA = (SourceBeanAttribute) iter.next();
            SourceBean buttonSB = (SourceBean) buttonSBA.getValue();

            String buttonName = buttonSB.getName();

            SourceBean conditionsSB = (SourceBean) buttonSB.getAttribute("CONDITIONS");
            SourceBean row;
            row = new SourceBean("ROWS");
            boolean conditionsVerified = verifyConditions(conditionsSB, row);

            if (ChannelUtilities.isWebRunning()) {
                String onlyPort = (String) buttonSB.getAttribute("onlyPortletRunning");
                if ((onlyPort != null) && onlyPort.equalsIgnoreCase("true")) {
                    continue;
                }
            }
            if (!conditionsVerified) {
                // if conditions are not verified puts an empty column
                _htmlStream
                        .append(" <td class='header-button-column-portlet-section' width='40px'>&nbsp;</td>\n");
                continue;
            }

            List parameters = buttonSB.getAttributeAsList("PARAMETER");
            HashMap paramsMap = getParametersMap(parameters, null);

            String img = (String) buttonSB.getAttribute("image");
            String labelCode = (String) buttonSB.getAttribute("label");

            //String label = PortletUtilities.getMessage(labelCode, "messages");
            String label = msgBuilder.getMessage(labelCode, _bundle, httpRequest);
            //String buttonUrl = createUrl(paramsMap);

            // if there is some javascript: onclick function
            SourceBean onClickSB = (SourceBean) buttonSB.getAttribute("ONCLICK");

            boolean onClick = false;
            if (onClickSB != null)
                onClick = true;

            if (onClick == true) {
                String onClickFunction = onClickSB != null ? onClickSB.getCharacters() : null;

                String functionName = onClickSB != null ? buttonSB.getName() : "";

                String onClickFunctionName = onClickSB != null ? buttonSB.getName() + requestIdentity : null;

                if (onClickFunction != null) {
                    _htmlStream.append("   <script type='text/javascript'>\n");
                    _htmlStream.append("   function " + onClickFunctionName + "() {\n");
                    _htmlStream.append(onClickFunction + "\n");
                    _htmlStream.append("   }\n");
                    _htmlStream.append("   </script>\n");
                }

                //String immagine=urlBuilder.getResourceLink(httpRequest, img);
                //htmlStream.append("<td class=\"portlet-section-header\">\n");
                //htmlStream.append("<td class=\"header-button-column-portlet-section\">\n");
                htmlStream.append("<div style=\"float: left;\">");
                htmlStream.append("<a href='javascript:" + onClickFunctionName
                        + "()'><img class=\"header-button-image-portlet-section\" title=\"" + label
                        + "\" alt=\"" + label + "\" style='height: 95%;width: 95%;' src='"
                        + urlBuilder.getResourceLinkByTheme(httpRequest, img, currTheme) + "' /></a>\n");
                htmlStream.append("</div>");
                //htmlStream.append("</td>\n");

            }

            if (onClick != true) {
                String buttonUrl = createUrl(paramsMap);

                htmlStream.append("<td class=\"header-button-column-portlet-section\">\n");
                htmlStream.append("<a href='" + buttonUrl
                        + "'><img class=\"header-button-image-portlet-section\" title=\"" + label + "\" alt=\""
                        + label + "\" src='" + urlBuilder.getResourceLinkByTheme(httpRequest, img, currTheme)
                        + "' /></a>\n");
                htmlStream.append("</td>\n");
            }

        }
        if (buttonYes)
            htmlStream.append("</td>\n");
    } catch (SourceBeanException e) {
        logger.error("Error");
        e.printStackTrace();
    }
    return htmlStream;
}

From source file:de.unijena.bioinf.FragmentationTreeConstruction.computation.FragmentationPatternAnalysis.java

/**
 * Step 6: Decomposition/*ww  w.  j a  v a  2s . co m*/
 * Decompose each peak as well as the parent peak
 */
public ProcessedInput performDecomposition(ProcessedInput input) {
    final FormulaConstraints constraints = input.getMeasurementProfile().getFormulaConstraints();
    final Ms2Experiment experiment = input.getExperimentInformation();
    final Deviation parentDeviation = input.getMeasurementProfile().getAllowedMassDeviation();
    // sort again...
    final ArrayList<ProcessedPeak> processedPeaks = new ArrayList<ProcessedPeak>(input.getMergedPeaks());
    Collections.sort(processedPeaks, new ProcessedPeak.MassComparator());
    final ProcessedPeak parentPeak = processedPeaks.get(processedPeaks.size() - 1);
    // decompose peaks
    final PeakAnnotation<DecompositionList> decompositionList = input
            .getOrCreatePeakAnnotation(DecompositionList.class);
    final MassToFormulaDecomposer decomposer = decomposers.getDecomposer(constraints.getChemicalAlphabet());
    final Ionization ion = experiment.getPrecursorIonType().getIonization();
    final Deviation fragmentDeviation = input.getMeasurementProfile().getAllowedMassDeviation();
    final List<MolecularFormula> pmds = decomposer.decomposeToFormulas(
            experiment.getPrecursorIonType().subtractIonAndAdduct(parentPeak.getOriginalMz()), parentDeviation,
            constraints);
    // add adduct to molecular formula of the ion - because the adduct might get lost during fragmentation
    {
        final MolecularFormula adduct = experiment.getPrecursorIonType().getAdduct();
        final ListIterator<MolecularFormula> iter = pmds.listIterator();
        while (iter.hasNext()) {
            final MolecularFormula f = iter.next();
            iter.set(f.add(adduct));
        }
    }
    decompositionList.set(parentPeak, DecompositionList.fromFormulas(pmds));
    int j = 0;
    for (ProcessedPeak peak : processedPeaks.subList(0, processedPeaks.size() - 1)) {
        peak.setIndex(j++);
        decompositionList.set(peak, DecompositionList.fromFormulas(
                decomposer.decomposeToFormulas(peak.getUnmodifiedMass(), fragmentDeviation, constraints)));
    }
    parentPeak.setIndex(processedPeaks.size() - 1);
    assert parentPeak == processedPeaks.get(processedPeaks.size() - 1);
    // important: for each two peaks which are within 2*massrange:
    //  => make decomposition list disjoint
    final Deviation window = fragmentDeviation.multiply(2);
    for (int i = 1; i < processedPeaks.size() - 1; ++i) {
        if (window.inErrorWindow(processedPeaks.get(i).getMz(), processedPeaks.get(i - 1).getMz())) {
            final HashSet<MolecularFormula> right = new HashSet<MolecularFormula>(
                    decompositionList.get(processedPeaks.get(i)).getFormulas());
            final ArrayList<MolecularFormula> left = new ArrayList<MolecularFormula>(
                    decompositionList.get(processedPeaks.get(i - 1)).getFormulas());
            final double leftMass = ion.subtractFromMass(processedPeaks.get(i - 1).getMass());
            final double rightMass = ion.subtractFromMass(processedPeaks.get(i).getMass());
            final Iterator<MolecularFormula> leftIter = left.iterator();
            while (leftIter.hasNext()) {
                final MolecularFormula leftFormula = leftIter.next();
                if (right.contains(leftFormula)) {
                    if (Math.abs(leftFormula.getMass() - leftMass) < Math
                            .abs(leftFormula.getMass() - rightMass)) {
                        right.remove(leftFormula);
                    } else {
                        leftIter.remove();
                    }
                }
            }
            decompositionList.set(processedPeaks.get(i - 1), DecompositionList.fromFormulas(left));
            decompositionList.set(processedPeaks.get(i), DecompositionList.fromFormulas(right));
        }
    }

    return postProcess(PostProcessor.Stage.AFTER_DECOMPOSING, input);
}

From source file:org.cloudifysource.usm.launcher.DefaultProcessLauncher.java

private void modifyWindowsCommandLine(final List<String> commandLineParams, final File workingDir) {
    final String firstParam = commandLineParams.get(0);
    if (firstParam.endsWith(".bat") || firstParam.endsWith(".cmd")) {
        for (int i = 0; i < WINDOWS_BATCH_FILE_PREFIX_PARAMS.length; i++) {
            commandLineParams.add(i, WINDOWS_BATCH_FILE_PREFIX_PARAMS[i]);
        }/*from  ww w  .  j a v a2s  .c o m*/
    }

    // if the file does not exist, this is probably an operating system
    // command
    File file = new File(firstParam);
    if (!file.isAbsolute()) {
        file = new File(workingDir, firstParam);
    }

    if (!file.exists()) {
        // this is not an executable file, so add the cmd interpreter
        // prefix
        for (int i = 0; i < WINDOWS_BATCH_FILE_PREFIX_PARAMS.length; i++) {
            commandLineParams.add(i, WINDOWS_BATCH_FILE_PREFIX_PARAMS[i]);
        }
    }

    // remove quotes
    final ListIterator<String> commandIterator = commandLineParams.listIterator();
    while (commandIterator.hasNext()) {
        final String param = commandIterator.next();
        commandIterator.remove();
        commandIterator.add(StringUtils.replace(param, "\"", ""));
    }

}

From source file:org.apache.fop.layoutmgr.inline.LineLayoutManager.java

/**
 * Add a line with block content/*from   w w w  . j ava2s. co  m*/
 * @param context the context for adding areas
 * @param pos the position for which the line is generated
 * @param isLastPosition true if this is the last position of this LM
 */
private void addBlockArea(LayoutContext context, Position pos, boolean isLastPosition) {
    /* Nested block-level content;
     * go down the LM stack again;
     * "unwrap" the positions and put the child positions in a new list.
     * The positionList must contain one area-generating position,
     * which creates one line area.
     */
    List positionList = new ArrayList(1);
    Position innerPosition = pos.getPosition();
    positionList.add(innerPosition);

    // do we have the last LM?
    LayoutManager lastLM = null;
    if (isLastPosition) {
        lastLM = innerPosition.getLM();
    }

    LineArea lineArea = new LineArea();
    setCurrentArea(lineArea);
    LayoutContext lc = new LayoutContext(0);
    lc.setAlignmentContext(alignmentContext);
    setChildContext(lc);

    PositionIterator childPosIter = new PositionIterator(positionList.listIterator());
    LayoutContext blocklc = new LayoutContext(0);
    blocklc.setLeadingSpace(new SpaceSpecifier(true));
    blocklc.setTrailingSpace(new SpaceSpecifier(false));
    blocklc.setFlags(LayoutContext.RESOLVE_LEADING_SPACE, true);
    LayoutManager childLM;
    while ((childLM = childPosIter.getNextChildLM()) != null) {
        // set last area flag
        blocklc.setFlags(LayoutContext.LAST_AREA, (context.isLastArea() && childLM == lastLM));
        blocklc.setStackLimitBP(context.getStackLimitBP());
        // Add the line areas to Area
        childLM.addAreas(childPosIter, blocklc);
        blocklc.setLeadingSpace(blocklc.getTrailingSpace());
        blocklc.setTrailingSpace(new SpaceSpecifier(false));
    }
    lineArea.updateExtentsFromChildren();
    if (lineArea.getBidiLevel() >= 0) {
        BidiResolver.reorder(lineArea);
    }
    parentLayoutManager.addChildArea(lineArea);
}

From source file:cz.cesnet.shongo.connector.device.CiscoMCUConnector.java

/**
 * Populates the results list - puts the original objects instead of item stubs.
 * <p/>/*  w w  w .  ja  v a2s . c o m*/
 * If there was a previous call to the same command, the changed items are just stubs in the new result set. To use
 * the results, this method populates all the stubs and puts the objects from the previous call in their place.
 *
 * @param results         list of results, some of which may be stubs; gets modified so that it contains no stubs
 * @param currentRevision the revision of this results
 * @param lastRevision    the revision of the previous call of the same command
 * @param command         the command called to get the supplied results
 * @param enumField       the field name from which the supplied results where taken within the command result
 */
private void populateResultsFromCache(List<Map<String, Object>> results, Integer currentRevision,
        Integer lastRevision, Command command, String enumField) throws CommandException {
    // we got just the difference since lastRevision (or full set if this is the first issue of the command)
    final String cacheId = getCommandCacheId(command);

    if (lastRevision != null) {
        // fill the values that have not changed since lastRevision
        ListIterator<Map<String, Object>> iterator = results.listIterator();
        while (iterator.hasNext()) {
            Map<String, Object> item = iterator.next();

            if (isItemDead(item)) {
                // from the MCU API: "The device will also never return a dead record if listAll is set to true."
                // unfortunately, the buggy MCU still reports some items as dead even though listAll = true, so we
                //   must remove them by ourselves (according to the API, a dead item should not have been ever
                //   listed when listAll = true)
                iterator.remove();
            } else if (!hasItemChanged(item)) {
                ResultsCache cache = resultsCache.get(cacheId);
                Map<String, Object> it = cache.getItem(item);
                if (it == null) {
                    throw new CommandException(
                            "Item reported as not changed by the device, but was not found in the cache: "
                                    + item);
                }
                iterator.set(it);
            }
        }
    }

    // store the results and the revision number for the next time
    ResultsCache rc = resultsCache.get(cacheId);
    if (rc == null) {
        rc = new ResultsCache();
        resultsCache.put(cacheId, rc);
    }
    rc.store(currentRevision, results);
}

From source file:de.uhh.l2g.dao.VideoDao.java

/**
 * Fill video list with properties./*from   ww w.j  a va2  s  .c  o m*/
 *
 * @param videoList the video list
 * @return the list
 * @throws IOException Signals that an I/O exception has occurred.
 */
public List<Video> fillVideoListWithProperties(List<Video> videoList) throws IOException {
    ListIterator<Video> it = videoList.listIterator();
    while (it.hasNext()) {
        Video objectVideo = it.next();
        Host objectHost = hostDao.getById(objectVideo.getHostId()).iterator().next();
        Producer objectProducer = producerDao.getByUserId(objectVideo.getProducerId()).iterator().next();
        try {
            Lectureseries lectureseries = lectureseriesDao.getById(objectVideo.getLectureseriesId()).iterator()
                    .next();
            objectVideo.setObjectLectureseries(lectureseries);
        } catch (NoSuchElementException nse) {
        }
        Metadata metadata = metadataDao.getById(objectVideo.getMetadataId()).iterator().next();

        // prepare video short name
        String video_shortname = objectVideo.getShortTitle();
        if (video_shortname.length() > 45)
            video_shortname = video_shortname.substring(0, 45) + "...";
        objectVideo.setShortTitle(video_shortname);
        objectVideo.setShortName(metadata.getCreator().split(" ")[metadata.getCreator().split(" ").length - 1]);

        objectVideo.setObjectHost(objectHost);
        objectVideo.setObjectProducer(objectProducer);
        objectVideo.setObjectMetadata(metadata);

        List<Mark> segmentList = segmentDao.getMarkByVideoId(objectVideo.getId());
        //segments
        if (segmentList.size() != 0)
            objectVideo.setSegmentList(segmentList);
        else
            objectVideo.setSegmentList(null);

        try {
            // images
            String image = "";
            String imageSmall = "";
            String imageMedium = "";
            String videoPfad = "";

            if (objectVideo.isOpenaccess()) {
                videoPfad = L2goPropsUtil.get("lecture2go.media.repository") + "/" + objectHost.getServerRoot()
                        + "/" + objectProducer.getHomeDir() + "/" + objectVideo.getFilename();
                image = objectVideo.getPreffix() + ".jpg";
                imageSmall = objectVideo.getPreffix() + "_s.jpg";
                imageMedium = objectVideo.getPreffix() + "_m.jpg";
            } else {
                videoPfad = L2goPropsUtil.get("lecture2go.media.repository") + "/" + objectHost.getServerRoot()
                        + "/" + objectProducer.getHomeDir() + "/" + objectVideo.getSecureFilename();
                image = objectVideo.getSPreffix() + ".jpg";
                imageSmall = objectVideo.getSPreffix() + "_s.jpg";
                imageMedium = objectVideo.getSPreffix() + "_m.jpg";
            }

            //thumbnails
            // set thumbnail
            //if audio file
            if (objectVideo.getUploadType().equals("audio")) {
                objectVideo.setImage(L2goPropsUtil.get("lecture2go.web.root")
                        + L2goPropsUtil.get("lecture2go.theme.root.path") + "/images/l2go/audio_only_big.png");
                objectVideo.setImageSmall(L2goPropsUtil.get("lecture2go.web.root")
                        + L2goPropsUtil.get("lecture2go.theme.root.path")
                        + "/images/l2go/audio_only_small.png");
                objectVideo.setImageMedium(L2goPropsUtil.get("lecture2go.web.root")
                        + L2goPropsUtil.get("lecture2go.theme.root.path")
                        + "/images/l2go/audio_only_medium.png");
            }

            //is video
            if (objectVideo.getUploadType().equals("video")) {
                File videoFile = new File(videoPfad);
                if (videoFile.isFile()) {
                    if (!((FFmpegManager) getUtilityBeanFactory().getBean("ffmgepManager"))
                            .thumbnailsExists(objectVideo)) {
                        // create thumbnail
                        String thumbnailLocation = L2goPropsUtil.get("lecture2go.images.system.path") + "/"
                                + image;
                        ((FFmpegManager) getUtilityBeanFactory().getBean("ffmgepManager"))
                                .createThumbnail(videoPfad, thumbnailLocation);
                    }
                    objectVideo.setImage(L2goPropsUtil.get("lecture2go.web.root") + "/images/" + image);
                    objectVideo
                            .setImageSmall(L2goPropsUtil.get("lecture2go.web.root") + "/images/" + imageSmall);
                    objectVideo.setImageMedium(
                            L2goPropsUtil.get("lecture2go.web.root") + "/images/" + imageMedium);
                } else {
                    String img = L2goPropsUtil.get("lecture2go.web.root")
                            + L2goPropsUtil.get("lecture2go.theme.root.path") + "/images/l2go/noimage.jpg";
                    objectVideo.setImage(img);
                    objectVideo.setImageSmall(img);
                    objectVideo.setImageMedium(img);
                }
            }

            // date
            // extract time and date from the originalFileName
            String[] parameter = objectVideo.getGenerationDate().split("\\_");
            // check parameter 3 - this is the date
            String l2gDate = parameter[0];
            String l2gTime = parameter[1];
            objectVideo.setDate(
                    l2gDate.split("\\-")[2] + "." + l2gDate.split("\\-")[1] + "." + l2gDate.split("\\-")[0]
                            + " - " + l2gTime.split("\\-")[0] + ":" + l2gTime.split("\\-")[1]);
            objectVideo.setSimpleDate(
                    l2gDate.split("\\-")[2] + "." + l2gDate.split("\\-")[1] + "." + l2gDate.split("\\-")[0]);

            // set preffix and filename
            String preffix = "";
            String filename = "";
            if (objectVideo.isOpenaccess()) {
                preffix = objectVideo.getPreffix();
                filename = objectVideo.getFilename();
            } else {
                preffix = objectVideo.getSPreffix();
                filename = objectVideo.getSecureFilename();
            }

            String homedirPath = "";
            homedirPath = L2goPropsUtil.get("lecture2go.media.repository") + "/" + objectHost.getServerRoot()
                    + "/" + objectProducer.getHomeDir() + "/" + preffix;

            //additional files
            try {
                File mp4File = new File(homedirPath + ".mp4");
                File mp3File = new File(homedirPath + ".mp3");
                File m4vFile = new File(homedirPath + ".m4v");
                File pdfFile = new File(homedirPath + ".pdf");
                File m4aFile = new File(homedirPath + ".m4a");
                //
                if (mp4File.isFile())
                    objectVideo.setMp4File(mp4File);
                if (mp3File.isFile())
                    objectVideo.setMp3File(mp3File);
                if (m4vFile.isFile())
                    objectVideo.setM4vFile(m4vFile);
                if (pdfFile.isFile())
                    objectVideo.setPdfFile(pdfFile);
                if (m4aFile.isFile())
                    objectVideo.setM4aFile(m4aFile);
            } catch (Exception e) {
                //
            }

            //URL
            String webhome = L2goPropsUtil.get("lecture2go.web.home");
            try {
                if (webhome.contains("localhost"))
                    webhome += "/web/lecture2go";
                if ((facilityDao.getByVideoId(objectVideo.getId()).iterator().next()).getTyp().equals("tree1"))
                    objectVideo.setUrl(webhome + "/l2go/-/v/" + objectVideo.getId());
            } catch (NoSuchElementException nseex) {
            }

            //SURL
            if (!objectVideo.isOpenaccess())
                objectVideo.setSecureUrl(webhome + "/lecture/-/sv/" + objectVideo.getSPreffix());

            //Streaming-URL
            String streamUrl = "";
            String streamIosUrl = "";
            String streamAndroidUrl = "";

            //base url
            String url = "";

            //wowza stream 
            if (objectVideo.getStreamType().equals("wowza")) {//TODO stream type into context.xml
                if (objectVideo.getUploadType().equals("audio"))
                    url = objectHost.getProtokoll() + "://" + objectHost.getStreamer() + "/vod/_definst_/mp3:"
                            + objectVideo.getFacilityId() + "l2g" + objectProducer.getHomeDir() + "/"
                            + filename;
                else
                    url = objectHost.getProtokoll() + "://" + objectHost.getStreamer() + "/vod/_definst_/mp4:"
                            + objectVideo.getFacilityId() + "l2g" + objectProducer.getHomeDir() + "/"
                            + filename;

                streamUrl = url + "/manifest.f4m"; //normal
                streamIosUrl = url + "/playlist.m3u8"; //iOS   
                streamAndroidUrl = url + "/playlist.m3u8"; //android
            }
            objectVideo.setStreamUrl(streamUrl); //normal
            objectVideo.setStreamIosUrl(streamIosUrl); //normal
            objectVideo.setStreamAndroidUrl(streamAndroidUrl); //normal

            //has chapters
            if (segmentDao.getChapterByVideoId(objectVideo.getId()).size() > 0)
                objectVideo.setHasChapters(true);

            //has comments
            if (segmentDao.getCommentsByVideoId(objectVideo.getId()).size() > 0)
                objectVideo.setHasComments(true);

            //set office
            objectVideo.setOffice(officeDao.getByFacilityId(objectVideo.getFacilityId()).iterator().next());

        } catch (Exception e) {
        }
    }
    return videoList;
}

From source file:it.doqui.index.ecmengine.business.personalization.multirepository.index.lucene.RepositoryAwareADMLuceneSearcherImpl.java

private String parameterise(String unparameterised, Map<QName, QueryParameterDefinition> map,
        QueryParameter[] queryParameters, NamespacePrefixResolver nspr) throws QueryParameterisationException {

    Map<QName, List<Serializable>> valueMap = new HashMap<QName, List<Serializable>>();

    if (queryParameters != null) {
        for (QueryParameter parameter : queryParameters) {
            List<Serializable> list = valueMap.get(parameter.getQName());
            if (list == null) {
                list = new ArrayList<Serializable>();
                valueMap.put(parameter.getQName(), list);
            }/*w  ww .  java2 s.  com*/
            list.add(parameter.getValue());
        }
    }

    Map<QName, ListIterator<Serializable>> iteratorMap = new HashMap<QName, ListIterator<Serializable>>();

    List<QName> missing = new ArrayList<QName>(1);
    StringBuilder buffer = new StringBuilder(unparameterised);
    int index = 0;
    while ((index = buffer.indexOf("${", index)) != -1) {
        int endIndex = buffer.indexOf("}", index);
        String qNameString = buffer.substring(index + 2, endIndex);
        QName key = QName.createQName(qNameString, nspr);
        QueryParameterDefinition parameterDefinition = map.get(key);
        if (parameterDefinition == null) {
            missing.add(key);
            buffer.replace(index, endIndex + 1, "");
        } else {
            ListIterator<Serializable> it = iteratorMap.get(key);
            if ((it == null) || (!it.hasNext())) {
                List<Serializable> list = valueMap.get(key);
                if ((list != null) && (list.size() > 0)) {
                    it = list.listIterator();
                }
                if (it != null) {
                    iteratorMap.put(key, it);
                }
            }
            String value;
            if (it == null) {
                value = parameterDefinition.getDefault();
            } else {
                value = DefaultTypeConverter.INSTANCE.convert(String.class, it.next());
            }
            buffer.replace(index, endIndex + 1, value);
        }
    }
    if (missing.size() > 0) {
        StringBuilder error = new StringBuilder();
        error.append("The query uses the following parameters which are not defined: ");
        for (QName qName : missing) {
            error.append(qName);
            error.append(", ");
        }
        error.delete(error.length() - 1, error.length() - 1);
        error.delete(error.length() - 1, error.length() - 1);
        throw new QueryParameterisationException(error.toString());
    }
    return buffer.toString();
}