Package java.util

Examples of java.util.LinkedHashMap$LinkedEntryIterator


     * @param moduleList the list of modules to execute.
     * @return the list of module poms
     */
    private Map getModulePoms(final String moduleList)
    {
        final Map poms = new LinkedHashMap();
        final String[] modules = moduleList != null ? moduleList.split(",") : null;

        final String goalPrefix = ":";
        if (modules != null)
        {
            final int numberOfModules = modules.length;
            for (int ctr = 0; ctr < numberOfModules; ctr++)
            {
                String module = modules[ctr].trim();
                final List goalsList = new ArrayList();
                if (module.indexOf(goalPrefix) != -1)
                {
                    final String[] goals = module.replaceAll(
                            ".*(:\\[)|(\\])",
                            "").split("\\+");
                    if (goals != null)
                    {
                        final int numberOfGoals = goals.length;
                        for (int ctr2 = 0; ctr2 < numberOfGoals; ctr2++)
                        {
                            final String goal = goals[ctr2].trim();
                            goalsList.add(goal);
                        }
                    }
                }
                module = module.replaceAll(
                        goalPrefix + "\\[.*\\]",
                        "");
                final File pom = new File(this.baseDirectory, module + "/pom.xml");
                if (pom.isFile())
                {
                    poms.put(
                        pom,
                        goalsList);
                }
            }
        }
View Full Code Here


     * @return a collection of collections
     */
    private Map collectProjectCompileSourceRoots()
        throws Exception
    {
        final Map sourceRoots = new LinkedHashMap();
        for (final Iterator iterator = this.collectProjects().iterator(); iterator.hasNext();)
        {
            final MavenProject project = (MavenProject)iterator.next();
            sourceRoots.put(project, new ArrayList(project.getCompileSourceRoots()));
        }
        return sourceRoots;
    }
View Full Code Here

        // reorder the logical mappings so that they can safely be loaded
        // (top-level mappings first)

        final Map unprocessedMappings = new HashMap(logicalMappings);
        final Map processedMappings = new LinkedHashMap(); // these will be in the good order

        // keep looping until there are no more unprocessed mappings
        // if nothing more can be processed but there are unprocessed mappings left
        // then we have an error (cyclic dependency or unknown parent mappings) which cannot be solved
        boolean processed = true;
        while (processed)
        {
            // we need to have at least one entry processed before the routine qualifies for the next iteration
            processed = false;

            // we only process mappings if they have parents that have already been processed
            for (final Iterator iterator = unprocessedMappings.entrySet().iterator(); iterator.hasNext();)
            {
                final Map.Entry logicalMapping = (Map.Entry)iterator.next();
                final String name = (String)logicalMapping.getKey();
                final Mappings mappings = (Mappings)logicalMapping.getValue();

                if (mappings.extendsUri == null)
                {
                    // no parent mappings are always safe to add

                    // move to the map of processed mappings
                    processedMappings.put(name, mappings);
                    // remove from the map of unprocessed mappings
                    iterator.remove();
                    // set the flag
                    processed = true;
                }
                else if (processedMappings.containsKey(mappings.extendsUri))
                {
                    final Mappings parentMappings = (Mappings)processedMappings.get(mappings.extendsUri);
                    if (parentMappings != null)
                    {
                        mergeWithoutOverriding(parentMappings, mappings);
                    }

                    // move to the map of processed mappings
                    processedMappings.put(name, mappings);
                    // remove from the map of unprocessed mappings
                    iterator.remove();
                    // set the flag
                    processed = true;
                }
View Full Code Here

     * @param sourceMappings the mappings from which to read possible new entries
     * @param targetMappings the mappings to which to store possible new entries from the sourceMappings
     */
    private static void mergeWithoutOverriding(Mappings sourceMappings, Mappings targetMappings)
    {
        final Map allMappings = new LinkedHashMap(targetMappings.mappings.size() + sourceMappings.mappings.size());
        allMappings.putAll(sourceMappings.mappings);
        allMappings.putAll(targetMappings.mappings);
        targetMappings.mappings.clear();
        targetMappings.mappings.putAll(allMappings);
    }
View Full Code Here

    /**
     * @see org.andromda.metafacades.uml.FrontEndControllerOperation#getFormFields()
     */
    protected java.util.List handleGetFormFields()
    {
        final Map formFieldsMap = new LinkedHashMap();

        // for quick lookup we use a hashset for the argument names, we only
        // consider parameters with a name
        // which is also present in this set
        final Set argumentNames = new LinkedHashSet();
        final Collection arguments = this.getArguments();
        for (final Iterator argumentIterator = arguments.iterator(); argumentIterator.hasNext();)
        {
            final ModelElementFacade element = (ModelElementFacade)argumentIterator.next();
            argumentNames.add(element.getName());
        }

        // - get all actions deferring to this operation
        final List deferringActions = this.getDeferringActions();
        for (final Iterator iterator = deferringActions.iterator(); iterator.hasNext();)
        {
            final FrontEndAction action = (FrontEndAction)iterator.next();

            // store the action parameters
            final List actionFormFields = action.getFormFields();
            for (final Iterator fieldIterator = actionFormFields.iterator(); fieldIterator.hasNext();)
            {
                final FrontEndParameter parameter = (FrontEndParameter)fieldIterator.next();
                final String name = parameter.getName();

                // - only add if the parameter is an action parameter and its an
                // argument of this operation
                if (parameter.getAction() != null && argumentNames.contains(name))
                {
                    formFieldsMap.put(
                        name,
                        parameter);
                }
            }

            // get all forwards and overwrite when we find a table (or add when
            // not yet present)
            final List forwards = action.getActionForwards();
            for (final Iterator forwardIterator = forwards.iterator(); forwardIterator.hasNext();)
            {
                final FrontEndForward forward = (FrontEndForward)forwardIterator.next();

                // - only consider forwards directly entering a view
                if (forward.isEnteringView())
                {
                    final List viewVariables = forward.getForwardParameters();
                    for (final Iterator variableIterator = viewVariables.iterator(); variableIterator.hasNext();)
                    {
                        final FrontEndParameter viewVariable = (FrontEndParameter)variableIterator.next();
                        final String name = viewVariable.getName();
                        if (argumentNames.contains(name))
                        {
                            if (!formFieldsMap.containsKey(name) || viewVariable.isTable())
                            {
                                formFieldsMap.put(
                                    name,
                                    viewVariable);
                            }
                        }
                    }
                }
            }
        }

        // since all arguments need to be present we add those that haven't yet
        // been stored in the map
        for (final Iterator argumentIterator = arguments.iterator(); argumentIterator.hasNext();)
        {
            final FrontEndParameter argument = (FrontEndParameter)argumentIterator.next();
            final String name = argument.getName();
            if (!formFieldsMap.containsKey(name))
            {
                formFieldsMap.put(
                    name,
                    argument);
            }
        }
        return new ArrayList(formFieldsMap.values());
    }
View Full Code Here

     * @param elements the elements to remove duplicates and copy tagged values to.
     * @return the elements with duplicates removed.
     */
    public static List removeDuplicatesAndCopyTaggedValues(final Collection elements)
    {
        final Map map = new LinkedHashMap();
        if (elements != null)
        {
            for (final Iterator iterator = elements.iterator(); iterator.hasNext();)
            {
                ModelElementFacade element = (ModelElementFacade)iterator.next();
                final String name = element.getName();
                final ModelElementFacade existingVariable = (ModelElementFacade)map.get(name);
                // - copy over any tagged values from the existing variable to the new one.
                if (existingVariable != null)
                {
                    element.copyTaggedValues(existingVariable);
                }
                map.put(
                    name,
                    element);
            }  
        }
        return new ArrayList(map.values());
    }
View Full Code Here

    /**
     * @see org.andromda.metafacades.uml.FrontEndUseCase#getViewVariables()
     */
    protected List handleGetViewVariables()
    {
        final Map pageVariableMap = new LinkedHashMap();

        // - page variables can occur twice or more in the usecase if their
        // names are the same for different forms, storing them in a map
        // solves this issue because those names do not have the action-name
        // prefix
        final Collection views = this.getViews();
        for (final Iterator pageIterator = views.iterator(); pageIterator.hasNext();)
        {
            final FrontEndView view = (FrontEndView)pageIterator.next();
            final Collection variables = view.getVariables();
            for (final Iterator variableIterator = variables.iterator(); variableIterator.hasNext();)
            {
                FrontEndParameter variable = (FrontEndParameter)variableIterator.next();
                final String name = variable.getName();
                if (name != null && name.trim().length() > 0)
                {
                    final FrontEndParameter existingVariable = (FrontEndParameter)pageVariableMap.get(name);
                    if (existingVariable != null)
                    {
                        if (existingVariable.isTable())
                        {
                            variable = existingVariable;
                        }
                    }
                    pageVariableMap.put(
                        name,
                        variable);
                }
            }
        }
        return new ArrayList(pageVariableMap.values());
    }
View Full Code Here

     * later on.
     */
    private void initializeCollections()
    {
        this.actionStates = new LinkedHashSet();
        this.actionForwards = new LinkedHashMap();
        this.decisionTransitions = new LinkedHashSet();
        this.transitions = new LinkedHashSet();
        this.collectTransitions(
            (TransitionFacade)this.THIS(),
            this.transitions);
View Full Code Here

    /**
     * @see org.andromda.metafacades.uml.FrontEndAction#getFormFields()
     */
    protected List handleGetFormFields()
    {
        final Map formFieldMap = new LinkedHashMap();

        // - For an action that starts the use case, we need to detect all
        // usecases forwarding to the one
        // belonging to this action if there are any parameters in those
        // transitions we need to have
        // them included in this action's form
        if (this.isUseCaseStart())
        {
            final FrontEndUseCase useCase = this.getUseCase();
            if (useCase != null)
            {
                final Collection finalStates = useCase.getReferencingFinalStates();
                for (final Iterator finalStateIterator = finalStates.iterator(); finalStateIterator.hasNext();)
                {
                    final Object finalStateObject = finalStateIterator.next();

                    // we need to test for the type because a non
                    // struts-use-case final state might accidently
                    // we linking to this use-case (for example: the user
                    // temporarily wants to disable code generation
                    // for a specific use-case and is not removing the
                    // final-state to use-case link(s))
                    if (finalStateObject instanceof FrontEndFinalState)
                    {
                        final FrontEndFinalState finalState = (FrontEndFinalState)finalStateObject;
                        final Collection parameters = finalState.getInterUseCaseParameters();
                        for (final Iterator parameterIterator = parameters.iterator(); parameterIterator.hasNext();)
                        {
                            final ParameterFacade parameter = (ParameterFacade)parameterIterator.next();
                            formFieldMap.put(
                                parameter.getName(),
                                parameter);
                        }
                    }
                }
            }
        }

        // if any action encountered by the execution of the complete
        // action-graph path emits a forward
        // containing one or more parameters they need to be included as a form
        // field too
        final Collection actionStates = this.getActionStates();
        for (final Iterator iterator = actionStates.iterator(); iterator.hasNext();)
        {
            final FrontEndActionState actionState = (FrontEndActionState)iterator.next();
            final FrontEndForward forward = actionState.getForward();
            if (forward != null)
            {
                final Collection forwardParameters = forward.getForwardParameters();
                for (final Iterator parameterIterator = forwardParameters.iterator(); parameterIterator.hasNext();)
                {
                    final ModelElementFacade forwardParameter = (ModelElementFacade)parameterIterator.next();
                    formFieldMap.put(
                        forwardParameter.getName(),
                        forwardParameter);
                }
            }
        }

        // add page variables for all pages/final-states targetted
        // also add the fields of the target page's actions (for preloading)
        final Collection forwards = this.getActionForwards();
        for (final Iterator iterator = forwards.iterator(); iterator.hasNext();)
        {
            final FrontEndForward forward = (FrontEndForward)iterator.next();
            final StateVertexFacade target = forward.getTarget();
            if (target instanceof FrontEndView)
            {
                final FrontEndView view = (FrontEndView)target;
                final Collection viewVariables = view.getVariables();
                for (final Iterator pageVariableIterator = viewVariables.iterator(); pageVariableIterator.hasNext();)
                {
                    final ModelElementFacade facade = (ModelElementFacade)pageVariableIterator.next();
                    formFieldMap.put(
                        facade.getName(),
                        facade);
                }
                final Collection allActionParameters = view.getAllFormFields();
                for (final Iterator actionParameterIterator = allActionParameters.iterator();
                    actionParameterIterator.hasNext();)
                {
                    // - don't allow existing parameters that are tables be
                    // overwritten (since they take
                    // precedence
                    final Object parameter = actionParameterIterator.next();
                    if (parameter instanceof FrontEndParameter)
                    {
                        FrontEndParameter variable = (FrontEndParameter)parameter;
                        final String name = variable.getName();
                        final Object existingParameter = formFieldMap.get(name);
                        if (existingParameter instanceof FrontEndParameter)
                        {
                            final FrontEndParameter existingVariable = (FrontEndParameter)existingParameter;
                            if (existingVariable != null)
                            {
                                if (existingVariable.isTable())
                                {
                                    variable = existingVariable;
                                }
                            }
                        }
                        formFieldMap.put(
                            name,
                            variable);
                    }
                }
            }
            else if (target instanceof FrontEndFinalState)
            {
                // only add these if there is no parameter recorded yet with the
                // same name
                final Collection forwardParameters = forward.getForwardParameters();
                for (final Iterator parameterIterator = forwardParameters.iterator(); parameterIterator.hasNext();)
                {
                    final ModelElementFacade facade = (ModelElementFacade)parameterIterator.next();
                    if (!formFieldMap.containsKey(facade.getName()))
                    {
                        formFieldMap.put(
                            facade.getName(),
                            facade);
                    }
                }
            }
        }

        // we do the action parameters in the end because they are allowed to
        // overwrite existing properties
        final Collection actionParameters = this.getParameters();
        for (final Iterator parameterIterator = actionParameters.iterator(); parameterIterator.hasNext();)
        {
            final Object parameter = parameterIterator.next();
            if (parameter instanceof FrontEndParameter)
            {
                final FrontEndParameter variable = (FrontEndParameter)parameter;
                formFieldMap.put(
                    variable.getName(),
                    variable);
            }
        }

        // - if we don't have any fields defined on this action and there are no
        // action forwards,
        // take the parameters from the deferred operations (since we would want
        // to stay on the same view)
        if (formFieldMap.isEmpty() && this.getActionForwards().isEmpty())
        {
            for (final Iterator iterator = this.getDeferredOperations().iterator(); iterator.hasNext();)
            {
                final OperationFacade operation = (OperationFacade)iterator.next();
                for (final Iterator parameterIterator = operation.getArguments().iterator();
                    parameterIterator.hasNext();)
                {
                    final ParameterFacade parameter = (ParameterFacade)parameterIterator.next();
                    formFieldMap.put(
                        parameter.getName(),
                        parameter);
                }
            }
        }
        return new ArrayList(formFieldMap.values());
    }
View Full Code Here

    /**
     * @see org.andromda.metafacades.uml.FrontEndControllerOperation#getFormFields()
     */
    protected java.util.List handleGetFormFields()
    {
        final Map formFieldsMap = new LinkedHashMap();

        // for quick lookup we use a hashset for the argument names, we only consider parameters with a name
        // which is also present in this set
        final Set argumentNames = new LinkedHashSet();
        final Collection arguments = this.getArguments();
        for (final Iterator argumentIterator = arguments.iterator(); argumentIterator.hasNext();)
        {
            final ModelElementFacade element = (ModelElementFacade)argumentIterator.next();
            argumentNames.add(element.getName());
        }

        // - get all actions deferring to this operation
        final List deferringActions = this.getDeferringActions();
        for (final Iterator iterator = deferringActions.iterator(); iterator.hasNext();)
        {
            final FrontEndAction action = (FrontEndAction)iterator.next();
            // store the action parameters
            final List actionFormFields = action.getFormFields();
            for (final Iterator fieldIterator = actionFormFields.iterator(); fieldIterator.hasNext();)
            {
                final FrontEndParameter parameter = (FrontEndParameter)fieldIterator.next();
                final String name = parameter.getName();
                // - only add if the parameter is an action parameter and its an argument of this operation
                if (parameter.getAction() != null && argumentNames.contains(name))
                {
                    formFieldsMap.put(name, parameter);
                }
            }
            // get all forwards and overwrite when we find a table (or add when not yet present)
            final List forwards = action.getActionForwards();
            for (final Iterator forwardIterator = forwards.iterator(); forwardIterator.hasNext();)
            {
                final FrontEndForward forward = (FrontEndForward)forwardIterator.next();
                // - only consider forwards directly entering a view
                if (forward.isEnteringView())
                {
                    final List viewVariables = forward.getForwardParameters();
                    for (final Iterator variableIterator = viewVariables.iterator(); variableIterator.hasNext();)
                    {
                        final FrontEndParameter viewVariable = (FrontEndParameter)variableIterator.next();
                        final String name = viewVariable.getName();
                        if (argumentNames.contains(name))
                        {
                            if (!formFieldsMap.containsKey(name) || viewVariable.isTable())
                            {
                                formFieldsMap.put(name, viewVariable);
                            }
                        }
                    }
                }
            }
        }

        // since all arguments need to be present we add those that haven't yet been stored in the map
        for (final Iterator argumentIterator = arguments.iterator(); argumentIterator.hasNext();)
        {
            final FrontEndParameter argument = (FrontEndParameter)argumentIterator.next();
            final String name = argument.getName();
            if (!formFieldsMap.containsKey(name))
            {
                formFieldsMap.put(name, argument);
            }
        }
        return new ArrayList(formFieldsMap.values());
    }
View Full Code Here

TOP

Related Classes of java.util.LinkedHashMap$LinkedEntryIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.