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:org.grails.datastore.mapping.query.Query.java

/**
 * Executes the query returning zero or many results as a list.
 *
 * @return The results/*from w  w w. java 2  s.co  m*/
 */
public List list() {
    uniqueResult = false;
    flushBeforeQuery();

    List results = executeQuery(entity, criteria);

    if (session instanceof SessionImplementor) {
        SessionImplementor sessionImplementor = (SessionImplementor) session;
        for (ListIterator iter = results.listIterator(); iter.hasNext();) {
            Object instance = iter.next();
            EntityPersister ep = (EntityPersister) session.getPersister(instance);
            if (ep == null) {
                // not persistent, could be a count() or report query
                continue;
            }

            Serializable id = findInstanceId(instance);
            if (sessionImplementor.isCached(instance.getClass(), id)) {
                iter.set(sessionImplementor.getCachedInstance(instance.getClass(), id));
            } else {
                sessionImplementor.cacheInstance(instance.getClass(), id, instance);
            }
        }
    }

    return results;
}

From source file:com.liferay.maven.arquillian.internal.tasks.ToolsClasspathTask.java

@Override
public URLClassLoader execute(MavenWorkingSession session) {

    final Logger log = LoggerFactory.getLogger(ToolsClasspathTask.class);

    final ParsedPomFile pomFile = session.getParsedPomFile();

    LiferayPluginConfiguration configuration = new LiferayPluginConfiguration(pomFile);

    System.setProperty("liferayVersion", configuration.getLiferayVersion());

    File appServerLibGlobalDir = new File(configuration.getAppServerLibGlobalDir());

    File appServerLibPortalDir = new File(configuration.getAppServerLibPortalDir());

    List<URI> liferayToolArchives = new ArrayList<URI>();

    if (appServerLibGlobalDir != null && appServerLibGlobalDir.exists()) {

        // app server global libraries
        Collection<File> appServerLibs = FileUtils.listFiles(appServerLibGlobalDir, new String[] { "jar" },
                true);//from  w  w w. j  a v a2 s  . c  o m

        for (File file : appServerLibs) {
            liferayToolArchives.add(file.toURI());
        }

        // All Liferay Portal Lib jars
        Collection<File> liferayPortalLibs = FileUtils.listFiles(appServerLibPortalDir, new String[] { "jar" },
                true);

        for (File file : liferayPortalLibs) {
            liferayToolArchives.add(file.toURI());
        }

        // Util jars
        File[] utilJars = Maven.resolver().loadPomFromClassLoaderResource("liferay-tool-deps.xml")
                .importCompileAndRuntimeDependencies().resolve().using(AcceptAllStrategy.INSTANCE).asFile();

        for (int i = 0; i < utilJars.length; i++) {
            liferayToolArchives.add(utilJars[i].toURI());
        }

    }

    log.trace("Jars count in Tools classpath Archive:" + liferayToolArchives.size());

    List<URL> classpathUrls = new ArrayList<URL>();

    try {
        if (!liferayToolArchives.isEmpty()) {

            ListIterator<URI> toolsJarItr = liferayToolArchives.listIterator();
            while (toolsJarItr.hasNext()) {
                URI jarURI = toolsJarItr.next();
                classpathUrls.add(jarURI.toURL());
            }

        }
    } catch (MalformedURLException e) {
        log.error("Error building Tools classpath", e);
    }

    return new URLClassLoader(classpathUrls.toArray(new URL[classpathUrls.size()]), null);
}

From source file:com.mirth.connect.client.ui.editors.transformer.TransformerPane.java

/**
 * load( Transformer t ) now that the components have been initialized...
 *///from w  ww. jav a  2s .c  om
public boolean load(Connector c, Transformer t, boolean channelHasBeenChanged, boolean isResponse) {
    if (alertUnsupportedStepTypes(t)) {
        return false;
    }

    switchTab = false;
    lastSelectedIndex = 0;
    tabbedPane.setSelectedIndex(0);

    this.isResponse = isResponse;
    prevSelRow = -1;
    connector = c;
    transformer = t;
    channel = PlatformUI.MIRTH_FRAME.channelEditPanel.currentChannel;

    makeTransformerTable();

    // add any existing steps to the model
    List<Step> list = transformer.getSteps();
    ListIterator<Step> li = list.listIterator();
    while (li.hasNext()) {
        Step s = li.next();
        setRowData(s, s.getSequenceNumber(), false);
    }

    parent.setCurrentContentPage((JPanel) this);
    parent.setFocus(new JXTaskPane[] { viewTasks, transformerTasks }, false, true);

    tabTemplatePanel.setTransformerView();

    // select the first row if there is one
    int rowCount = transformerTableModel.getRowCount();
    if (rowCount > 0) {
        transformerTable.setRowSelectionInterval(0, 0);
        prevSelRow = 0;
    } else {
        transformerTable.getSelectionModel().clearSelection();
        stepPanel.showCard(BLANK_TYPE);

        for (TransformerStepPlugin plugin : LoadedExtensions.getInstance().getTransformerStepPlugins()
                .values()) {
            plugin.getPanel().setData(null);
        }
        loadData(-1);
    }

    if (connector.getMode() == Connector.Mode.SOURCE) {
        tabTemplatePanel.setSourceView();
    } else if (connector.getMode() == Connector.Mode.DESTINATION) {
        tabTemplatePanel.setDestinationView(isResponse);
    }

    tabTemplatePanel.setDefaultComponent();

    tabTemplatePanel.setIncomingDataType(
            (String) PlatformUI.MIRTH_FRAME.dataTypeToDisplayName.get(transformer.getInboundDataType()));
    tabTemplatePanel.setOutgoingDataType(
            ((String) PlatformUI.MIRTH_FRAME.dataTypeToDisplayName.get(transformer.getOutboundDataType())));

    tabTemplatePanel.setIncomingDataProperties(transformer.getInboundProperties());
    tabTemplatePanel.setOutgoingDataProperties(transformer.getOutboundProperties());

    tabTemplatePanel.setIncomingMessage(transformer.getInboundTemplate());
    tabTemplatePanel.setOutgoingMessage(transformer.getOutboundTemplate());

    transformerTable.setBorder(BorderFactory.createEmptyBorder());

    updateStepNumbers();
    if (transformerTableModel.getRowCount() > 0) {
        updateTaskPane((String) transformerTableModel.getValueAt(0, STEP_TYPE_COL));
    }

    if (channelHasBeenChanged) {
        modified = true;
    } else {
        modified = false;
    }

    updateCodePanel(null);

    return true;
}

From source file:org.shareok.data.dspacemanager.DspaceApiHandlerImpl.java

@Override
public String[] getMetadataValuesByKey(String itemId, String key) {
    List<String> values = new ArrayList<>();
    try {/*from  w  w w  . j  a  v  a2  s.  c o m*/
        List<Map<String, Object>> metadata = getItemMetadataById(itemId);
        ListIterator it = metadata.listIterator();
        while (it.hasNext()) {
            Map itemMap = (HashMap) it.next();
            if (key.equals((String) itemMap.get("key"))) {
                values.add((String) itemMap.get("value"));
            }
        }
    } catch (Exception ex) {
        logger.error("Cannot get the item metadata values by key!", ex);
    }
    return (values.toArray(new String[values.size()]));
}

From source file:gobblin.salesforce.SalesforceExtractor.java

@Override
public List<Command> getDataMetadata(String schema, String entity, WorkUnit workUnit,
        List<Predicate> predicateList) throws DataRecordException {
    this.log.debug("Build url to retrieve data records");
    String query = this.updatedQuery;
    String url = null;// w  w w .  j  a  v a 2s .c  o m
    try {
        if (this.getNextUrl() != null && this.pullStatus == true) {
            url = this.getNextUrl();
        } else {
            if (isNullPredicate(predicateList)) {
                this.log.info("QUERY:" + query);
                return constructGetCommand(this.getFullUri(this.getSoqlUrl(query)));
            }

            String limitString = this.getLimitFromInputQuery(query);
            query = query.replace(limitString, "");

            Iterator<Predicate> i = predicateList.listIterator();
            while (i.hasNext()) {
                Predicate predicate = i.next();
                query = SqlQueryUtils.addPredicate(query, predicate.getCondition());
            }

            if (Boolean.valueOf(
                    this.workUnit.getProp(ConfigurationKeys.SOURCE_QUERYBASED_IS_SPECIFIC_API_ACTIVE))) {
                query = SqlQueryUtils.addPredicate(query, "IsDeleted = true");
            }

            query = query + limitString;
            this.log.info("QUERY: " + query);
            url = this.getFullUri(this.getSoqlUrl(query));
        }
        return constructGetCommand(url);
    } catch (Exception e) {
        throw new DataRecordException(
                "Failed to get salesforce url for data records; error - " + e.getMessage(), e);
    }
}

From source file:com.net2plan.cli.tools.CLITrafficDesign.java

@Override
public void executeFromCommandLine(String[] args) throws ParseException {
    long init = System.nanoTime();

    final CommandLineParser parser = new CommandLineParser();
    final CommandLine cli = parser.parse(OPTIONS, args);

    int numNodes;
    NetPlan netPlan;/*  ww  w . j a va 2s  . com*/

    if (cli.hasOption("num-nodes") && cli.hasOption("input-file"))
        throw new ParseException("'num-nodes' and 'input-file' are mutually exclusive");

    if (cli.hasOption("num-nodes")) {
        numNodes = ((Number) cli.getParsedOptionValue("num-nodes")).intValue();
        if (numNodes < 2)
            throw new Net2PlanException("Traffic matrix requires at least 2 nodes");

        netPlan = new NetPlan();
        for (int n = 0; n < numNodes; n++)
            netPlan.addNode(0, 0, null, null);
    } else {
        netPlan = new NetPlan((File) cli.getParsedOptionValue("input-file"));
        numNodes = netPlan.getNumberOfNodes();
    }

    int numMatrices = 1;
    String trafficPattern = null;

    DoubleMatrix2D[] trafficMatrices;
    if (cli.hasOption("variation-pattern")) {
        if (!cli.hasOption("num-matrices"))
            throw new Net2PlanException("'num-matrices' parameters must be specified");

        numMatrices = ((Number) cli.getParsedOptionValue("num-matrices")).intValue();
        if (numMatrices < 1)
            throw new Net2PlanException("Number of traffic matrices must be positive");

        DoubleMatrix2D trafficMatrix = netPlan.getMatrixNode2NodeOfferedTraffic();
        List<DoubleMatrix2D> newMatrices;
        String variationPattern = (String) cli.getParsedOptionValue("variation-pattern");
        switch (variationPattern) {
        case "cagr": {
            double cagr = ((Number) cli.getParsedOptionValue("variation-pattern-cagr")).doubleValue();
            if (cagr <= 0)
                throw new Net2PlanException("Compound annual growth rate must be greater than zero");
            newMatrices = TrafficMatrixGenerationModels.computeMatricesCAGR(trafficMatrix, cagr, numMatrices);

            break;
        }

        case "randomGaussian": {
            double cv = ((Number) cli.getParsedOptionValue("variation-pattern-cv")).doubleValue();
            double maxRelativeVariation = ((Number) cli
                    .getParsedOptionValue("variation-pattern-maxRelativeVariation")).doubleValue();
            if (cv <= 0)
                throw new Net2PlanException("Coefficient of variation must be greater than zero");
            if (maxRelativeVariation <= 0)
                throw new Net2PlanException("Maximum relative variation must be greater than zero");
            newMatrices = TrafficMatrixGenerationModels.computeMatricesRandomGaussianVariation(trafficMatrix,
                    cv, maxRelativeVariation, numMatrices);

            break;
        }

        case "randomUniform": {
            double maxRelativeVariation = ((Number) cli
                    .getParsedOptionValue("variation-pattern-maxRelativeVariation")).doubleValue();
            if (maxRelativeVariation <= 0)
                throw new Net2PlanException("Maximum relative variation must be greater than zero");
            newMatrices = TrafficMatrixGenerationModels.computeMatricesRandomUniformVariation(trafficMatrix,
                    maxRelativeVariation, numMatrices);

            break;
        }

        default:
            throw new RuntimeException("Bad - Unknown variation pattern '" + variationPattern + "'");
        }

        trafficMatrices = new DoubleMatrix2D[numMatrices];
        int i = 0;
        for (DoubleMatrix2D trafficMatrix1 : newMatrices)
            trafficMatrices[i++] = trafficMatrix1;
    } else {
        if (cli.hasOption("traffic-pattern")) {
            trafficPattern = cli.getOptionValue("traffic-pattern");
            if (!TRAFFIC_PATTERNS.containsKey(trafficPattern))
                throw new Net2PlanException("Unknown traffic pattern");

            if (cli.hasOption("num-matrices")) {
                numMatrices = ((Number) cli.getParsedOptionValue("num-matrices")).intValue();
                if (numMatrices < 1)
                    throw new Net2PlanException("Number of traffic matrices must be positive");
            }
        }

        trafficMatrices = new DoubleMatrix2D[numMatrices];
        if (trafficPattern != null) {
            switch (trafficPattern) {
            case "uniform-random-10":
                for (int tmId = 0; tmId < numMatrices; tmId++)
                    trafficMatrices[tmId] = TrafficMatrixGenerationModels.uniformRandom(numNodes, 0, 10);
                break;

            case "uniform-random-100":
                for (int tmId = 0; tmId < numMatrices; tmId++)
                    trafficMatrices[tmId] = TrafficMatrixGenerationModels.uniformRandom(numNodes, 0, 100);
                break;

            case "uniform-random-bimodal-50-50":
                for (int tmId = 0; tmId < numMatrices; tmId++)
                    trafficMatrices[tmId] = TrafficMatrixGenerationModels.bimodalUniformRandom(numNodes, 0.5, 0,
                            100, 0, 10);
                break;

            case "uniform-random-bimodal-25-75":
                for (int tmId = 0; tmId < numMatrices; tmId++)
                    trafficMatrices[tmId] = TrafficMatrixGenerationModels.bimodalUniformRandom(numNodes, 0.25,
                            0, 100, 0, 10);
                break;

            case "population-distance-model":
                double randomFactor = 0;
                double populationOffset = 0;
                double populationPower = 1;
                double distanceOffset = 0;
                double distancePower = 1;
                boolean normalizePopulation = true;
                boolean normalizeDistance = true;

                if (cli.hasOption("random-factor"))
                    randomFactor = ((Number) cli.getParsedOptionValue("random-factor")).doubleValue();
                if (cli.hasOption("population-offset"))
                    populationOffset = ((Number) cli.getParsedOptionValue("population-offset")).doubleValue();
                if (cli.hasOption("population-power"))
                    populationPower = ((Number) cli.getParsedOptionValue("population-power")).doubleValue();
                if (cli.hasOption("distance-offset"))
                    distanceOffset = ((Number) cli.getParsedOptionValue("distance-offset")).doubleValue();
                if (cli.hasOption("distance-power"))
                    distancePower = ((Number) cli.getParsedOptionValue("distance-power")).doubleValue();
                if (cli.hasOption("normalize-population"))
                    normalizePopulation = Boolean.parseBoolean(cli.getOptionValue("normalize-population"));
                if (cli.hasOption("normalize-distance"))
                    normalizeDistance = Boolean.parseBoolean(cli.getOptionValue("normalize-distance"));

                if (!cli.hasOption("level-matrix-file"))
                    throw new Net2PlanException("The level-matrix file is required");
                DoubleMatrix2D levelMatrix = DoubleUtils
                        .read2DMatrixFromFile((File) cli.getParsedOptionValue("level-matrix-file"));

                DoubleMatrix2D distanceMatrix = netPlan.getMatrixNode2NodeEuclideanDistance();
                int[] populationVector = StringUtils
                        .toIntArray(netPlan.getAttributes(netPlan.getNodes(), "population").values(), 0);
                int[] levelVector = StringUtils
                        .toIntArray(netPlan.getAttributes(netPlan.getNodes(), "level").values(), 1);

                for (int tmId = 0; tmId < numMatrices; tmId++)
                    trafficMatrices[tmId] = TrafficMatrixGenerationModels.populationDistanceModel(
                            distanceMatrix, populationVector, levelVector, levelMatrix, randomFactor,
                            populationOffset, populationPower, distanceOffset, distancePower,
                            normalizePopulation, normalizeDistance);

                break;

            case "gravity-model":
                if (cli.hasOption("gravity-model-file")) {
                    File gravityModelFile = (File) cli.getParsedOptionValue("gravity-model-file");
                    DoubleMatrix2D gravityModelMatrix = DoubleUtils.read2DMatrixFromFile(gravityModelFile);

                    if (gravityModelMatrix.rows() != numNodes || gravityModelMatrix.columns() != 2)
                        throw new Net2PlanException(
                                "'gravity-model-file' requires " + numNodes + " rows and two columns");

                    numMatrices = 1;
                    trafficMatrices[0] = TrafficMatrixGenerationModels.gravityModel(
                            gravityModelMatrix.viewColumn(0).toArray(),
                            gravityModelMatrix.viewColumn(1).toArray());
                } else {
                    throw new Net2PlanException("Parameter 'gravity-model-file' should be specified");
                }

                break;

            default:
                throw new RuntimeException("Bad - Unknown traffic pattern '" + trafficPattern + "'");
            }
        } else {
            trafficMatrices[0] = netPlan.getMatrixNode2NodeOfferedTraffic();
        }

        if (cli.hasOption("normalization-pattern")) {
            String normalizationPattern = (String) cli.getParsedOptionValue("normalization-pattern");
            switch (normalizationPattern) {
            case "total-normalization":
            case "row-normalization":
            case "column-normalization":
                if (cli.hasOption("normalization-pattern-file")) {
                    double[] normalizationPatternVector;
                    int patternId;

                    File normalizationPatternFile = (File) cli
                            .getParsedOptionValue("normalization-pattern-file");
                    DoubleMatrix2D normalizationPatternMatrix = DoubleUtils
                            .read2DMatrixFromFile(normalizationPatternFile);
                    if (normalizationPatternMatrix.rows() == 1 && normalizationPatternMatrix.columns() == 1) {
                        patternId = 0;
                        normalizationPatternVector = new double[] { normalizationPatternMatrix.getQuick(0, 0) };
                    } else if (normalizationPatternMatrix.rows() == 1
                            && normalizationPatternMatrix.columns() > 1) {
                        patternId = 1;
                        normalizationPatternVector = normalizationPatternMatrix.viewRow(0).toArray();
                    } else if (normalizationPatternMatrix.rows() > 1
                            && normalizationPatternMatrix.columns() == 1) {
                        patternId = 2;
                        normalizationPatternVector = normalizationPatternMatrix.viewColumn(0).toArray();
                    } else {
                        throw new Net2PlanException(
                                "Bad normalization pattern - Neither a scalar (for total normalization), nor row vector (for row normalization) nor a column vector (for column normalization) was provided");
                    }

                    for (int tmId = 0; tmId < numMatrices; tmId++) {
                        switch (patternId) {
                        case 0:
                            trafficMatrices[tmId] = TrafficMatrixGenerationModels
                                    .normalizationPattern_totalTraffic(trafficMatrices[tmId],
                                            normalizationPatternVector[0]);
                            break;

                        case 1:
                            trafficMatrices[tmId] = TrafficMatrixGenerationModels
                                    .normalizationPattern_incomingTraffic(trafficMatrices[tmId],
                                            normalizationPatternVector);
                            break;

                        case 2:
                            trafficMatrices[tmId] = TrafficMatrixGenerationModels
                                    .normalizationPattern_outgoingTraffic(trafficMatrices[tmId],
                                            normalizationPatternVector);
                            break;

                        default:
                            throw new RuntimeException("Bad");
                        }
                    }
                } else {
                    throw new Net2PlanException("Parameter 'normalization-pattern-file' should be specified");
                }

                break;

            case "max-traffic-estimated-minHop":
                for (int tmId = 0; tmId < numMatrices; tmId++) {
                    netPlan.setTrafficMatrix(trafficMatrices[tmId]);
                    netPlan.setVectorDemandOfferedTraffic(
                            TrafficMatrixGenerationModels.normalizeTraffic_networkCapacity(netPlan));
                    trafficMatrices[tmId] = netPlan.getMatrixNode2NodeOfferedTraffic();
                }
                break;

            case "max-traffic-exact":
                String solverName = Configuration.getOption("defaultILPSolver");
                String solverLibraryName = Configuration.getDefaultSolverLibraryName(solverName);
                //                        if (solverName.equalsIgnoreCase("glpk")) solverLibraryName = Configuration.getOption("glpkSolverLibraryName");
                //                        else if (solverName.equalsIgnoreCase("ipopt")) solverLibraryName = Configuration.getOption("ipoptSolverLibraryName");
                //                        else if (solverName.equalsIgnoreCase("cplex")) solverLibraryName = Configuration.getOption("cplexSolverLibraryName");
                //                        else if (solverName.equalsIgnoreCase("xpress")) solverLibraryName = Configuration.getOption("xpressSolverLicenseFileName");
                //
                for (int tmId = 0; tmId < numMatrices; tmId++) {
                    netPlan.setTrafficMatrix(trafficMatrices[tmId]);
                    netPlan.setVectorDemandOfferedTraffic(TrafficMatrixGenerationModels
                            .normalizeTraffic_linkCapacity_xde(netPlan, solverName, solverLibraryName));
                    trafficMatrices[tmId] = netPlan.getMatrixNode2NodeOfferedTraffic();
                }
                break;

            default:
                throw new RuntimeException(
                        "Bad - Unknown normalization pattern '" + normalizationPattern + "'");
            }
        }
    }

    List<NetPlan> outputDemandSets = new LinkedList<NetPlan>();
    for (int tmId = 0; tmId < numMatrices; tmId++) {
        NetPlan aux = new NetPlan();

        aux.setTrafficMatrix(trafficMatrices[tmId]);
        outputDemandSets.add(aux);

        trafficMatrices[tmId] = null;
    }

    File outputFile = (File) cli.getParsedOptionValue("output-file");

    if (outputDemandSets.size() == 1) {
        outputDemandSets.get(0).saveToFile(outputFile);
    } else {
        String templateFileName = outputFile.getAbsoluteFile().toString();
        if (templateFileName.endsWith(".n2p"))
            templateFileName = templateFileName.substring(0, templateFileName.lastIndexOf('.'));

        ListIterator<NetPlan> netPlanIt = outputDemandSets.listIterator();
        while (netPlanIt.hasNext())
            netPlanIt.next().saveToFile(new File(templateFileName + "_tm" + netPlanIt.nextIndex() + ".n2p"));
    }

    long end = System.nanoTime();

    System.out.println(String.format("%n%nTraffic matrix generation finished successfully in %f seconds",
            (end - init) / 1e9));
}

From source file:com.liferay.arquillian.maven.internal.tasks.ToolsClasspathTask.java

/**
 * (non-Javadoc)/*from w  ww .  ja v a2  s .c om*/
 * @see
 * org.jboss.shrinkwrap.resolver.impl.maven.task.MavenWorkingSessionTask
 * #execute(org.jboss.shrinkwrap.resolver.api.maven.MavenWorkingSession)
 */
@Override
public URLClassLoader execute(MavenWorkingSession session) {
    final ParsedPomFile pomFile = session.getParsedPomFile();

    LiferayPluginConfiguration configuration = new LiferayPluginConfiguration(pomFile);

    System.setProperty("liferayVersion", configuration.getLiferayVersion());

    File appServerLibGlobalDir = new File(configuration.getAppServerLibGlobalDir());

    File appServerLibPortalDir = new File(configuration.getAppServerLibPortalDir());

    List<URI> liferayToolArchives = new ArrayList<>();

    if ((appServerLibGlobalDir != null) && appServerLibGlobalDir.exists()) {

        // app server global libraries

        Collection<File> appServerLibs = FileUtils.listFiles(appServerLibGlobalDir, new String[] { "jar" },
                true);

        for (File file : appServerLibs) {
            liferayToolArchives.add(file.toURI());
        }

        // All Liferay Portal Lib jars

        Collection<File> liferayPortalLibs = FileUtils.listFiles(appServerLibPortalDir, new String[] { "jar" },
                true);

        for (File file : liferayPortalLibs) {
            liferayToolArchives.add(file.toURI());
        }

        // Util jars

        File[] utilJars = Maven.resolver().loadPomFromClassLoaderResource("liferay-tool-deps.xml")
                .importCompileAndRuntimeDependencies().resolve().using(AcceptAllStrategy.INSTANCE).asFile();

        for (int i = 0; i < utilJars.length; i++) {
            liferayToolArchives.add(utilJars[i].toURI());
        }
    }

    if (_log.isTraceEnabled()) {
        _log.trace("Jars count in Tools classpath Archive:" + liferayToolArchives.size());
    }

    List<URL> classpathUrls = new ArrayList<>();

    try {
        if (!liferayToolArchives.isEmpty()) {
            ListIterator<URI> toolsJarItr = liferayToolArchives.listIterator();
            while (toolsJarItr.hasNext()) {
                URI jarURI = toolsJarItr.next();
                classpathUrls.add(jarURI.toURL());
            }
        }
    } catch (MalformedURLException e) {
        _log.error("Error building Tools classpath", e);
    }

    return new URLClassLoader(classpathUrls.toArray(new URL[classpathUrls.size()]), null);
}

From source file:org.shareok.data.dspacemanager.DspaceApiHandlerImpl.java

@Override
public String[] getMetadataValuesByKey(String itemId, String key, String dspaceApiUrl) {
    List<String> values = new ArrayList<>();
    try {/* w w  w. j av  a 2s  .  c o m*/
        List<Map<String, Object>> metadata = getItemMetadataById(itemId, dspaceApiUrl);
        ListIterator it = metadata.listIterator();
        while (it.hasNext()) {
            Map itemMap = (HashMap) it.next();
            if (key.equals((String) itemMap.get("key"))) {
                values.add((String) itemMap.get("value"));
            }
        }
    } catch (Exception ex) {
        logger.error("Cannot get the item metadata values by key!", ex);
    }
    return (values.toArray(new String[values.size()]));
}

From source file:org.ambraproject.article.service.BrowseServiceImpl.java

/**
 *
 *//*from   w ww  .j  a v a2s .  c o  m*/
public List<TOCArticleGroup> buildArticleGroups(Issue issue, List<TOCArticleGroup> articleGroups,
        String authId) {
    List<ArticleInfo> articlesInIssue = getArticleInfosForIssue(issue.getId(), authId);
    /*
     * For every article that is of the same ArticleType as a TOCArticleGroup, add it to that group.
     * Articles can appear in multiple TOCArticleGroups.
     */
    for (ArticleInfo ai : articlesInIssue)
        for (TOCArticleGroup ag : articleGroups)
            for (ArticleType articleType : ai.getArticleTypes())
                if (ag.getArticleType().equals(articleType)) {
                    ag.addArticle(ai);
                    break;
                }

    Iterator iter = articleGroups.listIterator();
    Integer i = 0;

    while (iter.hasNext()) {
        TOCArticleGroup ag = (TOCArticleGroup) iter.next();
        // remove the group if it has no articles
        if (ag.articles.size() == 0) {
            iter.remove();
            continue;
        }
        // If we respect order then don't sort.
        if (!issue.getRespectOrder()) {
            ag.setId("tocGrp_" + (i++));
            ag.sortArticles();
        }
    }
    return articleGroups;
}

From source file:org.dresdenocl.pivotmodel.impl.OperationImpl.java

/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * /*from   w  ww. ja v a 2 s.  c om*/
 * @generated NOT
 */
@Override
public boolean hasMatchingSignature(List<Type> paramTypes) {

    if (logger.isDebugEnabled()) {
        logger.debug("hasMatchingSignature(paramTypes=" + paramTypes //$NON-NLS-1$
                + ") - enter"); //$NON-NLS-1$
    }

    boolean match;
    List<Parameter> inputParameters;

    // the signatures match if none of the conditions below fails
    match = true;

    // cache the list of input parameters
    inputParameters = getInputParameter();

    // check whether the paramTypes list has the correct size
    if (inputParameters.size() != paramTypes.size()) {
        match = false;
    }

    // check type conformance of each parameter
    else {

        for (ListIterator<Type> it = paramTypes.listIterator(); it.hasNext();) {
            Type type = it.next();

            // get the next input parameter of this operation
            Parameter parameter = inputParameters.get(it.previousIndex());

            // if input parameter has no type, check conformance with
            // generic type
            if (parameter.getType() == null) {

                if (parameter.getGenericType() != null) {
                    match = parameter.getGenericType().isConformant(type);
                }

            }

            // else check for conformance with the type
            else {
                match = type.conformsTo(parameter.getType());
            }

            // no need for continuing the search if two parameters did not
            // match
            if (match == false) {
                break;
            }
        }
    }

    if (logger.isDebugEnabled()) {
        logger.debug("hasMatchingSignature() - exit - return value=" + match); //$NON-NLS-1$
    }

    return match;
}