Example usage for java.util LinkedHashSet add

List of usage examples for java.util LinkedHashSet add

Introduction

In this page you can find the example usage for java.util LinkedHashSet add.

Prototype

boolean add(E e);

Source Link

Document

Adds the specified element to this set if it is not already present (optional operation).

Usage

From source file:org.apache.ws.scout.registry.BusinessQueryManagerV3Impl.java

public BulkResponse getRegistryObjects(Collection objectKeys, String objectType) throws JAXRException {
    IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
    //Convert into a vector of strings
    String[] keys = new String[objectKeys.size()];
    int currLoc = 0;
    for (Key key : (Collection<Key>) objectKeys) {
        String keyString = key.getId();
        keys[currLoc++] = keyString;/*from w w w  . j av a2s  .c om*/
    }
    LinkedHashSet<RegistryObject> col = new LinkedHashSet<RegistryObject>();
    LifeCycleManager lcm = registryService.getLifeCycleManagerImpl();

    if (LifeCycleManager.CLASSIFICATION_SCHEME.equalsIgnoreCase(objectType)) {
        try {
            TModelDetail tmodeldetail = registry.getTModelDetail(keys);
            List<TModel> tmodelList = tmodeldetail.getTModel();

            for (TModel tModel : tmodelList) {
                col.add(ScoutUddiV3JaxrHelper.getConcept(tModel, lcm));
            }

        } catch (RegistryV3Exception e) {
            throw new JAXRException(e.getLocalizedMessage());
        }
    } else if (LifeCycleManager.ORGANIZATION.equalsIgnoreCase(objectType)) {
        ConnectionImpl con = ((RegistryServiceImpl) getRegistryService()).getConnection();
        AuthToken auth = this.getAuthToken(con, registry);

        try {
            RegisteredInfo ri = null;
            try {
                ri = registry.getRegisteredInfo(auth.getAuthInfo());
            } catch (RegistryV3Exception rve) {
                String username = getUsernameFromCredentials(con.getCredentials());
                if (AuthTokenV3Singleton.getToken(username) != null) {
                    AuthTokenV3Singleton.deleteAuthToken(username);
                }
                auth = getAuthToken(con, registry);
                ri = registry.getRegisteredInfo(auth.getAuthInfo());
            }

            if (ri != null) {
                BusinessInfos infos = ri.getBusinessInfos();
                if (infos != null) {
                    for (String key : keys) {
                        BusinessDetail detail = registry.getBusinessDetail(key);
                        col.add(((BusinessLifeCycleManagerV3Impl) registryService.getLifeCycleManagerImpl())
                                .createOrganization(detail));
                    }
                }
            }
        } catch (RegistryV3Exception e) {
            throw new JAXRException(e.getLocalizedMessage());
        }
    } else if (LifeCycleManager.CONCEPT.equalsIgnoreCase(objectType)) {
        try {
            TModelDetail tmodeldetail = registry.getTModelDetail(keys);
            List<TModel> tmodelList = tmodeldetail.getTModel();

            for (TModel tmodel : tmodelList) {
                col.add(ScoutUddiV3JaxrHelper.getConcept(tmodel, lcm));
            }

        } catch (RegistryV3Exception e) {
            throw new JAXRException(e.getLocalizedMessage());
        }
    } else if (LifeCycleManager.SERVICE.equalsIgnoreCase(objectType)) {

        try {
            ServiceDetail serviceDetail = registry.getServiceDetail(keys);

            if (serviceDetail != null) {
                List<BusinessService> bizServiceList = serviceDetail.getBusinessService();

                for (BusinessService businessService : bizServiceList) {

                    Service service = getServiceFromBusinessService(businessService, lcm);

                    col.add(service);
                }
            }
        } catch (RegistryV3Exception e) {
            throw new JAXRException(e);
        }
    } else {
        throw new JAXRException("Unsupported type " + objectType + " for getRegistryObjects() in Apache Scout");
    }

    return new BulkResponseImpl(col);

}

From source file:org.apache.tajo.plan.rewrite.rules.ProjectionPushDownRule.java

public LogicalNode visitWindowAgg(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block,
        WindowAggNode node, Stack<LogicalNode> stack) throws TajoException {
    Context newContext = new Context(context);

    if (node.hasPartitionKeys()) {
        for (Column c : node.getPartitionKeys()) {
            newContext.addNecessaryReferences(new FieldEval(c));
        }//from  www.j a  va 2  s. com
    }

    if (node.hasSortSpecs()) {
        for (SortSpec sortSpec : node.getSortSpecs()) {
            newContext.addNecessaryReferences(new FieldEval(sortSpec.getSortKey()));
        }
    }

    for (WindowFunctionEval winFunc : node.getWindowFunctions()) {
        if (winFunc.hasSortSpecs()) {
            for (SortSpec sortSpec : winFunc.getSortSpecs()) {
                newContext.addNecessaryReferences(new FieldEval(sortSpec.getSortKey()));
            }
        }
    }

    int nonFunctionColumnNum = node.getTargets().size() - node.getWindowFunctions().length;
    LinkedHashSet<String> nonFunctionColumns = Sets.newLinkedHashSet();
    for (int i = 0; i < nonFunctionColumnNum; i++) {
        FieldEval fieldEval = (new FieldEval(node.getTargets().get(i).getNamedColumn()));
        nonFunctionColumns.add(newContext.addExpr(fieldEval));
    }

    final String[] aggEvalNames;
    if (node.hasAggFunctions()) {
        final int evalNum = node.getWindowFunctions().length;
        aggEvalNames = new String[evalNum];
        for (int evalIdx = 0, targetIdx = nonFunctionColumnNum; targetIdx < node.getTargets()
                .size(); evalIdx++, targetIdx++) {
            Target target = node.getTargets().get(targetIdx);
            WindowFunctionEval winFunc = node.getWindowFunctions()[evalIdx];
            aggEvalNames[evalIdx] = newContext.addExpr(new Target(winFunc, target.getCanonicalName()));
        }
    } else {
        aggEvalNames = null;
    }

    // visit a child node
    LogicalNode child = super.visitWindowAgg(newContext, plan, block, node, stack);

    node.setInSchema(child.getOutSchema());

    List<Target> targets = Lists.newArrayList();
    if (nonFunctionColumnNum > 0) {
        for (String column : nonFunctionColumns) {
            Target target = context.targetListMgr.getTarget(column);

            // it rewrite grouping keys.
            // This rewrite sets right column names and eliminates duplicated grouping keys.
            if (context.targetListMgr.isEvaluated(column)) {
                targets.add(new Target(new FieldEval(target.getNamedColumn())));
            } else {
                if (target.getEvalTree().getType() == EvalType.FIELD) {
                    targets.add(target);
                }
            }
        }
    }

    // Getting projected targets
    if (node.hasAggFunctions() && aggEvalNames != null) {
        WindowFunctionEval[] aggEvals = new WindowFunctionEval[aggEvalNames.length];
        int i = 0;
        for (Iterator<String> it = getFilteredReferences(aggEvalNames, Arrays.asList(aggEvalNames)); it
                .hasNext();) {

            String referenceName = it.next();
            Target target = context.targetListMgr.getTarget(referenceName);

            if (LogicalPlanner.checkIfBeEvaluatedAtWindowAgg(target.getEvalTree(), node)) {
                aggEvals[i++] = target.getEvalTree();
                context.targetListMgr.markAsEvaluated(target);

                targets.add(new Target(new FieldEval(target.getNamedColumn())));
            }
        }
        if (aggEvals.length > 0) {
            node.setWindowFunctions(aggEvals);
        }
    }

    node.setTargets(targets);
    return node;
}

From source file:org.gbif.ipt.model.Resource.java

/**
 * @return a list of extensions that have been mapped to, starting with the extension that was mapped first (core
 * mapping), and ending with the extension that was mapped last. Elements in the list are unique.
 *///from  ww w.ja  va 2s  . c om
public List<Extension> getMappedExtensions() {
    LinkedHashSet<Extension> extensions = Sets.newLinkedHashSet();
    for (ExtensionMapping em : mappings) {
        if (em.getExtension() != null && em.getSource() != null) {
            extensions.add(em.getExtension());
        } else {
            log.error("ExtensionMapping referencing NULL Extension or Source for resource: " + getShortname());
        }
    }
    return Lists.newArrayList(extensions);
}

From source file:org.apache.ws.scout.registry.BusinessQueryManagerImpl.java

public BulkResponse getRegistryObjects(Collection objectKeys, String objectType) throws JAXRException {
    IRegistry registry = (IRegistry) registryService.getRegistry();
    //Convert into a vector of strings
    String[] keys = new String[objectKeys.size()];
    int currLoc = 0;
    for (Key key : (Collection<Key>) objectKeys) {
        keys[currLoc] = key.getId();//from w ww .  ja  v  a  2  s  .  co m
        currLoc++;
    }
    LinkedHashSet<RegistryObject> col = new LinkedHashSet<RegistryObject>();
    LifeCycleManager lcm = registryService.getLifeCycleManagerImpl();

    if (LifeCycleManager.CLASSIFICATION_SCHEME.equalsIgnoreCase(objectType)) {
        try {
            TModelDetail tmodeldetail = registry.getTModelDetail(keys);
            List<TModel> tmodelList = tmodeldetail.getTModel();

            for (TModel tModel : tmodelList) {
                col.add(ScoutUddiJaxrHelper.getConcept(tModel, lcm));
            }

        } catch (RegistryException e) {
            throw new JAXRException(e.getLocalizedMessage());
        }
    } else if (LifeCycleManager.ORGANIZATION.equalsIgnoreCase(objectType)) {
        ConnectionImpl con = ((RegistryServiceImpl) getRegistryService()).getConnection();
        AuthToken auth = this.getAuthToken(con, registry);

        try {
            RegisteredInfo ri = null;
            try {
                ri = registry.getRegisteredInfo(auth.getAuthInfo());
            } catch (RegistryException rve) {
                String username = getUsernameFromCredentials(con.getCredentials());
                if (AuthTokenSingleton.getToken(username) != null) {
                    AuthTokenSingleton.deleteAuthToken(username);
                }
                auth = getAuthToken(con, registry);
                ri = registry.getRegisteredInfo(auth.getAuthInfo());
            }

            if (ri != null) {
                for (String key : keys) {
                    BusinessDetail detail = registry.getBusinessDetail(key);
                    col.add(((BusinessLifeCycleManagerImpl) registryService.getLifeCycleManagerImpl())
                            .createOrganization(detail));
                }

            }
        } catch (RegistryException e) {
            throw new JAXRException(e.getLocalizedMessage());
        }
    } else if (LifeCycleManager.CONCEPT.equalsIgnoreCase(objectType)) {
        try {
            TModelDetail tmodeldetail = registry.getTModelDetail(keys);
            List<TModel> tmodelList = tmodeldetail.getTModel();

            for (TModel tmodel : tmodelList) {
                col.add(ScoutUddiJaxrHelper.getConcept(tmodel, lcm));
            }

        } catch (RegistryException e) {
            throw new JAXRException(e.getLocalizedMessage());
        }
    } else if (LifeCycleManager.SERVICE.equalsIgnoreCase(objectType)) {

        try {
            ServiceDetail serviceDetail = registry.getServiceDetail(keys);

            if (serviceDetail != null) {
                List<BusinessService> bizServiceList = serviceDetail.getBusinessService();

                for (BusinessService businessService : bizServiceList) {

                    Service service = getServiceFromBusinessService(businessService, lcm);

                    col.add(service);
                }
            }
        } catch (RegistryException e) {
            throw new JAXRException(e);
        }
    } else {
        throw new JAXRException("Unsupported type " + objectType + " for getRegistryObjects() in Apache Scout");
    }

    return new BulkResponseImpl(col);

}

From source file:org.apache.tajo.engine.planner.rewrite.ProjectionPushDownRule.java

public LogicalNode visitGroupBy(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block,
        GroupbyNode node, Stack<LogicalNode> stack) throws PlanningException {
    Context newContext = new Context(context);

    // Getting grouping key names
    final int groupingKeyNum = node.getGroupingColumns().length;
    LinkedHashSet<String> groupingKeyNames = null;
    if (groupingKeyNum > 0) {
        groupingKeyNames = Sets.newLinkedHashSet();
        for (int i = 0; i < groupingKeyNum; i++) {
            FieldEval fieldEval = new FieldEval(node.getGroupingColumns()[i]);
            groupingKeyNames.add(newContext.addExpr(fieldEval));
        }/*  w ww.  j  a  v  a 2 s.c  o  m*/
    }

    // Getting eval names

    final String[] aggEvalNames;
    if (node.hasAggFunctions()) {
        final int evalNum = node.getAggFunctions().length;
        aggEvalNames = new String[evalNum];
        for (int evalIdx = 0, targetIdx = groupingKeyNum; targetIdx < node
                .getTargets().length; evalIdx++, targetIdx++) {
            Target target = node.getTargets()[targetIdx];
            EvalNode evalNode = node.getAggFunctions()[evalIdx];
            aggEvalNames[evalIdx] = newContext.addExpr(new Target(evalNode, target.getCanonicalName()));
        }
    } else {
        aggEvalNames = null;
    }

    // visit a child node
    LogicalNode child = super.visitGroupBy(newContext, plan, block, node, stack);

    node.setInSchema(child.getOutSchema());

    List<Target> targets = Lists.newArrayList();
    if (groupingKeyNum > 0 && groupingKeyNames != null) {
        // Restoring grouping key columns
        final List<Column> groupingColumns = new ArrayList<Column>();
        for (String groupingKey : groupingKeyNames) {
            Target target = context.targetListMgr.getTarget(groupingKey);

            // it rewrite grouping keys.
            // This rewrite sets right column names and eliminates duplicated grouping keys.
            if (context.targetListMgr.isEvaluated(groupingKey)) {
                Column c = target.getNamedColumn();
                if (!groupingColumns.contains(c)) {
                    groupingColumns.add(c);
                    targets.add(new Target(new FieldEval(target.getNamedColumn())));
                }
            } else {
                if (target.getEvalTree().getType() == EvalType.FIELD) {
                    Column c = ((FieldEval) target.getEvalTree()).getColumnRef();
                    if (!groupingColumns.contains(c)) {
                        groupingColumns.add(c);
                        targets.add(target);
                        context.targetListMgr.markAsEvaluated(target);
                    }
                } else {
                    throw new PlanningException(
                            "Cannot evaluate this expression in grouping keys: " + target.getEvalTree());
                }
            }
        }

        node.setGroupingColumns(groupingColumns.toArray(new Column[groupingColumns.size()]));
    }

    // Getting projected targets
    if (node.hasAggFunctions() && aggEvalNames != null) {
        AggregationFunctionCallEval[] aggEvals = new AggregationFunctionCallEval[aggEvalNames.length];
        int i = 0;
        for (Iterator<String> it = getFilteredReferences(aggEvalNames, TUtil.newList(aggEvalNames)); it
                .hasNext();) {

            String referenceName = it.next();
            Target target = context.targetListMgr.getTarget(referenceName);

            if (LogicalPlanner.checkIfBeEvaluatedAtGroupBy(target.getEvalTree(), node)) {
                aggEvals[i++] = target.getEvalTree();
                context.targetListMgr.markAsEvaluated(target);
            }
        }
        if (aggEvals.length > 0) {
            node.setAggFunctions(aggEvals);
        }
    }
    Target[] finalTargets = buildGroupByTarget(node, targets, aggEvalNames);
    node.setTargets(finalTargets);

    LogicalPlanner.verifyProjectedFields(block, node);

    return node;
}

From source file:com.sonicle.webtop.core.app.WebTopSession.java

private Set<String> listAllowedPrivateServices(ServiceManager svcm) {
    LinkedHashSet<String> ids = new LinkedHashSet<>();
    if (RunContext.isSysAdmin()) {
        ids.add(CoreManifest.ID);
        ids.add(CoreAdminManifest.ID);/*  w ww. jav a 2  s  .  c o m*/
        ids.add("com.sonicle.webtop.vfs");

    } else {
        for (String id : svcm.listRegisteredServices()) {
            if (RunContext.isPermitted(true, CoreManifest.ID, "SERVICE", "ACCESS", id))
                ids.add(id);
        }
    }
    return ids;
}

From source file:org.pentaho.reporting.platform.plugin.ParameterXmlContentHandler.java

private Element createParameterElement(final ParameterDefinitionEntry parameter,
        final ParameterContext parameterContext, final Object selections)
        throws BeanException, ReportDataFactoryException {
    try {//  ww  w  .j a v a2  s .  com
        final Element parameterElement = document.createElement("parameter"); //$NON-NLS-1$
        parameterElement.setAttribute("name", parameter.getName()); //$NON-NLS-1$
        final Class<?> valueType = parameter.getValueType();
        parameterElement.setAttribute("type", valueType.getName()); //$NON-NLS-1$
        parameterElement.setAttribute("is-mandatory", String.valueOf(parameter.isMandatory())); //$NON-NLS-1$ //$NON-NLS-2$

        final String[] namespaces = parameter.getParameterAttributeNamespaces();
        for (int i = 0; i < namespaces.length; i++) {
            final String namespace = namespaces[i];
            final String[] attributeNames = parameter.getParameterAttributeNames(namespace);
            for (final String attributeName : attributeNames) {
                final String attributeValue = parameter.getParameterAttribute(namespace, attributeName,
                        parameterContext);
                // expecting: label, parameter-render-type, parameter-layout
                // but others possible as well, so we set them all
                final Element attributeElement = document.createElement("attribute"); // NON-NLS
                attributeElement.setAttribute("namespace", namespace); // NON-NLS
                attributeElement.setAttribute("name", attributeName); // NON-NLS
                attributeElement.setAttribute("value", attributeValue); // NON-NLS

                parameterElement.appendChild(attributeElement);
            }
        }

        final Class<?> elementValueType;
        if (valueType.isArray()) {
            elementValueType = valueType.getComponentType();
        } else {
            elementValueType = valueType;
        }

        if (Date.class.isAssignableFrom(elementValueType)) {
            parameterElement.setAttribute("timzone-hint", computeTimeZoneHint(parameter, parameterContext));//$NON-NLS-1$
        }

        final LinkedHashSet<Object> selectionSet = new LinkedHashSet<Object>();
        if (selections != null) {
            if (selections.getClass().isArray()) {
                final int length = Array.getLength(selections);
                for (int i = 0; i < length; i++) {
                    final Object value = Array.get(selections, i);
                    selectionSet.add(resolveSelectionValue(value));
                }
            } else {
                selectionSet.add(resolveSelectionValue(selections));
            }
        } else {
            final String type = parameter.getParameterAttribute(ParameterAttributeNames.Core.NAMESPACE,
                    ParameterAttributeNames.Core.TYPE, parameterContext);
            if (ParameterAttributeNames.Core.TYPE_DATEPICKER.equals(type)
                    && Date.class.isAssignableFrom(valueType)) {
                if (isGenerateDefaultDates()) {
                    selectionSet.add(new Date());
                }
            }
        }

        @SuppressWarnings("rawtypes")
        final LinkedHashSet handledValues = (LinkedHashSet) selectionSet.clone();

        if (parameter instanceof ListParameter) {
            final ListParameter asListParam = (ListParameter) parameter;
            parameterElement.setAttribute("is-multi-select", //$NON-NLS-1$
                    String.valueOf(asListParam.isAllowMultiSelection())); //$NON-NLS-2$
            parameterElement.setAttribute("is-strict", String.valueOf(asListParam.isStrictValueCheck())); //$NON-NLS-1$ //$NON-NLS-2$
            parameterElement.setAttribute("is-list", "true"); //$NON-NLS-1$ //$NON-NLS-2$

            final Element valuesElement = document.createElement("values"); //$NON-NLS-1$
            parameterElement.appendChild(valuesElement);

            final ParameterValues possibleValues = asListParam.getValues(parameterContext);
            for (int i = 0; i < possibleValues.getRowCount(); i++) {
                final Object key = possibleValues.getKeyValue(i);
                final Object value = possibleValues.getTextValue(i);

                final Element valueElement = document.createElement("value"); //$NON-NLS-1$
                valuesElement.appendChild(valueElement);

                valueElement.setAttribute("label", String.valueOf(value)); //$NON-NLS-1$ //$NON-NLS-2$
                valueElement.setAttribute("type", elementValueType.getName()); //$NON-NLS-1$

                if (key instanceof Number) {
                    final BigDecimal bd = new BigDecimal(String.valueOf(key));
                    valueElement.setAttribute("selected", String.valueOf(selectionSet.contains(bd)));//$NON-NLS-1$
                    handledValues.remove(bd);
                } else if (key == null) {
                    if (selections == null || selectionSet.contains(null)) {
                        valueElement.setAttribute("selected", "true");//$NON-NLS-1$
                        handledValues.remove(null);
                    }
                } else {
                    valueElement.setAttribute("selected", String.valueOf(selectionSet.contains(key)));//$NON-NLS-1$
                    handledValues.remove(key);
                }
                if (key == null) {
                    valueElement.setAttribute("null", "true"); //$NON-NLS-1$ //$NON-NLS-2$
                } else {
                    valueElement.setAttribute("null", "false"); //$NON-NLS-1$ //$NON-NLS-2$
                    valueElement.setAttribute("value",
                            convertParameterValueToString(parameter, parameterContext, key, elementValueType)); //$NON-NLS-1$ //$NON-NLS-2$
                }

            }

            // Only add invalid values to the selection list for non-strict parameters
            if (!asListParam.isStrictValueCheck()) {
                for (final Object key : handledValues) {
                    final Element valueElement = document.createElement("value"); //$NON-NLS-1$
                    valuesElement.appendChild(valueElement);

                    valueElement.setAttribute("label", Messages.getInstance() //$NON-NLS-1$
                            .getString("ReportPlugin.autoParameter", String.valueOf(key))); //$NON-NLS-1$
                    valueElement.setAttribute("type", elementValueType.getName()); //$NON-NLS-1$

                    if (key instanceof Number) {
                        BigDecimal bd = new BigDecimal(String.valueOf(key));
                        valueElement.setAttribute("selected", String.valueOf(selectionSet.contains(bd)));//$NON-NLS-1$
                    } else {
                        valueElement.setAttribute("selected", String.valueOf(selectionSet.contains(key)));//$NON-NLS-1$
                    }

                    if (key == null) {
                        valueElement.setAttribute("null", "true"); //$NON-NLS-1$ //$NON-NLS-2$
                    } else {
                        valueElement.setAttribute("null", "false"); //$NON-NLS-1$ //$NON-NLS-2$
                        valueElement.setAttribute("value", convertParameterValueToString(parameter,
                                parameterContext, key, elementValueType)); //$NON-NLS-1$ //$NON-NLS-2$
                    }

                }
            }
        } else if (parameter instanceof PlainParameter) {
            // apply defaults, this is the easy case
            parameterElement.setAttribute("is-multi-select", "false"); //$NON-NLS-1$ //$NON-NLS-2$
            parameterElement.setAttribute("is-strict", "false"); //$NON-NLS-1$ //$NON-NLS-2$
            parameterElement.setAttribute("is-list", "false"); //$NON-NLS-1$ //$NON-NLS-2$

            if (selections != null) {
                final Element valuesElement = document.createElement("values"); //$NON-NLS-1$
                parameterElement.appendChild(valuesElement);

                final Element valueElement = document.createElement("value"); //$NON-NLS-1$
                valuesElement.appendChild(valueElement);
                valueElement.setAttribute("type", valueType.getName()); //$NON-NLS-1$
                valueElement.setAttribute("selected", "true");//$NON-NLS-1$
                valueElement.setAttribute("null", "false"); //$NON-NLS-1$ //$NON-NLS-2$
                final String value = convertParameterValueToString(parameter, parameterContext, selections,
                        valueType);
                valueElement.setAttribute("value", value); //$NON-NLS-1$ //$NON-NLS-2$
                valueElement.setAttribute("label", value); //$NON-NLS-1$ //$NON-NLS-2$
            }
        }
        return parameterElement;
    } catch (BeanException be) {
        logger.error(Messages.getInstance().getString("ReportPlugin.errorFailedToGenerateParameter",
                parameter.getName(), String.valueOf(selections)), be);
        throw be;
    }
}

From source file:org.apache.ws.scout.registry.BusinessQueryManagerV3Impl.java

/**
 * Finds organizations in the registry that match the specified parameters
 *
 * @param findQualifiers//from  www  .jav  a2s.c o m
 * @param namePatterns
 * @param classifications
 * @param specifications
 * @param externalIdentifiers
 * @param externalLinks
 * @return BulkResponse
 * @throws JAXRException
 */
public BulkResponse findOrganizations(Collection findQualifiers, Collection namePatterns,
        Collection classifications, Collection specifications, Collection externalIdentifiers,
        Collection externalLinks) throws JAXRException {
    IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
    try {
        FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers);
        Name[] nameArray = mapNamePatterns(namePatterns);
        BusinessList result = registry.findBusiness(nameArray, null,
                ScoutJaxrUddiV3Helper.getIdentifierBagFromExternalIdentifiers(externalIdentifiers),
                ScoutJaxrUddiV3Helper.getCategoryBagFromClassifications(classifications),
                ScoutJaxrUddiV3Helper.getTModelBagFromSpecifications(specifications), juddiFindQualifiers,
                registryService.getMaxRows());

        BusinessInfo[] bizInfoArr = null;
        BusinessInfos bizInfos = result.getBusinessInfos();
        LinkedHashSet<Organization> orgs = new LinkedHashSet<Organization>();
        if (bizInfos != null) {
            List<BusinessInfo> bizInfoList = bizInfos.getBusinessInfo();
            for (BusinessInfo businessInfo : bizInfoList) {
                //Now get the details on the individual biz
                BusinessDetail detail = registry.getBusinessDetail(businessInfo.getBusinessKey());
                BusinessLifeCycleManagerV3Impl blcm = (BusinessLifeCycleManagerV3Impl) registryService
                        .getLifeCycleManagerImpl();
                orgs.add(blcm.createOrganization(detail));
            }
            bizInfoArr = new BusinessInfo[bizInfoList.size()];
            bizInfoList.toArray(bizInfoArr);
        }
        return new BulkResponseImpl(orgs);
    } catch (RegistryV3Exception e) {
        throw new JAXRException(e);
    }
}

From source file:org.apache.maven.plugin.resources.remote.ProcessRemoteResourcesMojo.java

private MavenFileFilterRequest setupRequest(Resource resource, File source, File file) {
    MavenFileFilterRequest req = new MavenFileFilterRequest();
    req.setFrom(source);// ww  w . jav a 2  s .  com
    req.setTo(file);
    req.setFiltering(resource.isFiltering());

    req.setMavenProject(project);
    req.setMavenSession(mavenSession);
    req.setInjectProjectBuildFilters(true);

    if (encoding != null) {
        req.setEncoding(encoding);
    }

    if (filterDelimiters != null && !filterDelimiters.isEmpty()) {
        LinkedHashSet<String> delims = new LinkedHashSet<String>();
        if (useDefaultFilterDelimiters) {
            delims.addAll(req.getDelimiters());
        }

        for (String delim : filterDelimiters) {
            if (delim == null) {
                delims.add("${*}");
            } else {
                delims.add(delim);
            }
        }

        req.setDelimiters(delims);
    }

    return req;
}

From source file:xyz.openmodloader.gradle.task.MergeJarsTask.java

private void processMethods(ClassNode cClass, ClassNode sClass) {
    List<MethodNode> cMethods = cClass.methods;
    List<MethodNode> sMethods = sClass.methods;
    LinkedHashSet<MethodWrapper> allMethods = Sets.newLinkedHashSet();

    int cPos = 0;
    int sPos = 0;
    int cLen = cMethods.size();
    int sLen = sMethods.size();
    String clientName = "";
    String lastName = clientName;
    String serverName = "";
    while (cPos < cLen || sPos < sLen) {
        do {//from   w  w w .j av a 2 s. c  o  m
            if (sPos >= sLen) {
                break;
            }
            MethodNode sM = sMethods.get(sPos);
            serverName = sM.name;
            if (!serverName.equals(lastName) && cPos != cLen) {
                if (DEBUG) {
                    System.out.printf("Server -skip : %s %s %d (%s %d) %d [%s]\n", sClass.name, clientName,
                            cLen - cPos, serverName, sLen - sPos, allMethods.size(), lastName);
                }
                break;
            }
            MethodWrapper mw = new MethodWrapper(sM);
            mw.server = true;
            allMethods.add(mw);
            if (DEBUG) {
                System.out.printf("Server *add* : %s %s %d (%s %d) %d [%s]\n", sClass.name, clientName,
                        cLen - cPos, serverName, sLen - sPos, allMethods.size(), lastName);
            }
            sPos++;
        } while (sPos < sLen);
        do {
            if (cPos >= cLen) {
                break;
            }
            MethodNode cM = cMethods.get(cPos);
            lastName = clientName;
            clientName = cM.name;
            if (!clientName.equals(lastName) && sPos != sLen) {
                if (DEBUG) {
                    System.out.printf("Client -skip : %s %s %d (%s %d) %d [%s]\n", cClass.name, clientName,
                            cLen - cPos, serverName, sLen - sPos, allMethods.size(), lastName);
                }
                break;
            }
            MethodWrapper mw = new MethodWrapper(cM);
            mw.client = true;
            allMethods.add(mw);
            if (DEBUG) {
                System.out.printf("Client *add* : %s %s %d (%s %d) %d [%s]\n", cClass.name, clientName,
                        cLen - cPos, serverName, sLen - sPos, allMethods.size(), lastName);
            }
            cPos++;
        } while (cPos < cLen);
    }

    cMethods.clear();
    sMethods.clear();

    for (MethodWrapper mw : allMethods) {
        if (DEBUG) {
            System.out.println(mw);
        }
        cMethods.add(mw.node);
        sMethods.add(mw.node);
        if (mw.server && mw.client) {
            // no op
        } else {
            if (mw.node.visibleAnnotations == null) {
                mw.node.visibleAnnotations = Lists.newArrayListWithExpectedSize(1);
            }

            mw.node.visibleAnnotations.add(getSideAnn(mw.client));
        }
    }
}