Example usage for org.apache.commons.collections CollectionUtils addAll

List of usage examples for org.apache.commons.collections CollectionUtils addAll

Introduction

In this page you can find the example usage for org.apache.commons.collections CollectionUtils addAll.

Prototype

public static void addAll(Collection collection, Object[] elements) 

Source Link

Document

Adds all elements in the array to the given collection.

Usage

From source file:org.jlibrary.core.axis.client.AxisRepositoryDelegate.java

public Collection findNodeChildren(Ticket ticket, String id)
        throws RepositoryException, NodeNotFoundException, SecurityException {

    try {//from  w w w . jav  a2  s .  c  om
        call.removeAllParameters();

        call.setTargetEndpointAddress(new java.net.URL(endpoint));
        call.setOperationName("findNodeChildren");
        call.addParameter("ticket", XMLType.XSD_ANY, ParameterMode.IN);
        call.addParameter("id", XMLType.XSD_STRING, ParameterMode.IN);

        call.setReturnType(XMLType.XSD_ANY);
        Object[] o = (Object[]) call.invoke(new Object[] { ticket, id });
        HashSet set = new HashSet();
        CollectionUtils.addAll(set, o);
        return set;
    } catch (Exception e) {
        AxisFault fault = (AxisFault) e;
        // I don't know if there is a better way to do this
        if (fault.getFaultString().indexOf("NodeNotFoundException") != -1) {
            throw new NodeNotFoundException(fault.getFaultString());
        }
        if (fault.getFaultString().indexOf("SecurityException") != -1) {
            throw new SecurityException(fault.getFaultString());
        } else {
            throw new RepositoryException(fault.getFaultString());
        }
    }
}

From source file:org.jlibrary.core.axis.client.AxisSearchDelegate.java

public Collection search(Ticket ticket, String phrase, String searchType) throws SearchException {

    try {//  w w w. ja v a  2 s .  co  m
        call.removeAllParameters();

        call.setTargetEndpointAddress(new java.net.URL(endpoint));
        call.setOperationName("search");
        call.addParameter("ticket", XMLType.XSD_ANY, ParameterMode.IN);
        call.addParameter("phrase", XMLType.XSD_STRING, ParameterMode.IN);
        call.addParameter("searchType", XMLType.XSD_STRING, ParameterMode.IN);

        call.setReturnType(XMLType.XSD_ANY);

        Object[] results = (Object[]) call.invoke(new Object[] { ticket, phrase, searchType });
        ArrayList list = new ArrayList();
        CollectionUtils.addAll(list, results);
        return list;

    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        throw new SearchException(e);
    }
}

From source file:org.jlibrary.core.axis.client.AxisSearchDelegate.java

public Collection search(Ticket ticket, String xpathQuery) throws SearchException {

    try {/*w ww  .  j av a2s .com*/
        call.removeAllParameters();

        call.setTargetEndpointAddress(new java.net.URL(endpoint));
        call.setOperationName("search");
        call.addParameter("ticket", XMLType.XSD_ANY, ParameterMode.IN);
        call.addParameter("xpathQuery", XMLType.XSD_STRING, ParameterMode.IN);

        call.setReturnType(XMLType.XSD_ANY);

        Object[] results = (Object[]) call.invoke(new Object[] { ticket, xpathQuery });
        ArrayList list = new ArrayList();
        CollectionUtils.addAll(list, results);
        return list;

    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        throw new SearchException(e);
    }
}

From source file:org.jlibrary.core.axis.client.AxisSecurityDelegate.java

public Collection findAllUsers(Ticket ticket) throws SecurityException {

    try {/*from www .  jav  a  2s.  c om*/
        call.removeAllParameters();

        call.setOperationName("findAllUsers");
        call.addParameter("ticket", XMLType.XSD_ANY, ParameterMode.IN);

        call.setReturnType(XMLType.SOAP_ARRAY);

        Object[] users = (Object[]) call.invoke(new Object[] { ticket });
        ArrayList list = new ArrayList();
        CollectionUtils.addAll(list, users);
        return list;
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        throw createSecurityException((AxisFault) e);
    }
}

From source file:org.jlibrary.core.axis.client.AxisSecurityDelegate.java

public Collection findAllRoles(Ticket ticket) throws SecurityException {

    try {//from  ww  w . j  av  a  2 s. com
        call.removeAllParameters();

        call.setOperationName("findAllRoles");
        call.addParameter("ticket", XMLType.XSD_ANY, ParameterMode.IN);

        call.setReturnType(XMLType.SOAP_ARRAY);

        Object[] roles = (Object[]) call.invoke(new Object[] { ticket });
        ArrayList list = new ArrayList();
        CollectionUtils.addAll(list, roles);
        return list;
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        throw createSecurityException((AxisFault) e);
    }
}

From source file:org.jlibrary.core.axis.client.AxisSecurityDelegate.java

public Collection findAllGroups(Ticket ticket) throws SecurityException {

    try {//from  w w w . ja v  a  2 s. c  o  m
        call.removeAllParameters();

        call.setOperationName("findAllGroups");
        call.addParameter("ticket", XMLType.XSD_ANY, ParameterMode.IN);

        call.setReturnType(XMLType.SOAP_ARRAY);

        Object[] groups = (Object[]) call.invoke(new Object[] { ticket });
        ArrayList list = new ArrayList();
        CollectionUtils.addAll(list, groups);
        return list;
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        throw createSecurityException((AxisFault) e);
    }
}

From source file:org.jlibrary.core.axis.client.AxisSecurityDelegate.java

public Collection findAllRestrictions(Ticket ticket, String nodeId) throws SecurityException {

    try {//w w  w .j a v  a  2s .  c  o m
        call.removeAllParameters();

        call.setOperationName("findAllRestrictions");
        call.addParameter("ticket", XMLType.XSD_ANY, ParameterMode.IN);
        call.addParameter("nodeId", XMLType.XSD_STRING, ParameterMode.IN);

        call.setReturnType(XMLType.XSD_ANY);

        Object[] restrictions = (Object[]) call.invoke(new Object[] { ticket, nodeId });

        ArrayList list = new ArrayList();
        CollectionUtils.addAll(list, restrictions);
        return list;
    } catch (Exception e) {
        throw createSecurityException((AxisFault) e);
    }
}

From source file:org.jumpmind.db.platform.AbstractDdlBuilder.java

/**
 * Searches in the given table for a corresponding foreign key. If the given
 * key has no name, then a foreign key to the same table with the same
 * columns in the same order is searched. If the given key has a name, then
 * the a corresponding key also needs to have the same name, or no name at
 * all, but not a different one.//www .ja  va  2  s.  c  om
 *
 * @param table
 *            The table to search in
 * @param fk
 *            The original foreign key
 * @return The corresponding foreign key if found
 */
protected ForeignKey findCorrespondingForeignKey(Table table, ForeignKey fk) {
    boolean caseMatters = delimitedIdentifierModeOn;
    boolean checkFkName = (fk.getName() != null) && (fk.getName().length() > 0);
    Reference[] refs = fk.getReferences();
    ArrayList<Reference> curRefs = new ArrayList<Reference>();

    for (int fkIdx = 0; fkIdx < table.getForeignKeyCount(); fkIdx++) {
        ForeignKey curFk = table.getForeignKey(fkIdx);
        boolean checkCurFkName = checkFkName && (curFk.getName() != null) && (curFk.getName().length() > 0);

        if ((!checkCurFkName || areEqual(fk.getName(), curFk.getName(), caseMatters))
                && areEqual(fk.getForeignTableName(), curFk.getForeignTableName(), caseMatters)) {
            curRefs.clear();
            CollectionUtils.addAll(curRefs, curFk.getReferences());

            // the order is not fixed, so we have to take this long way
            if (curRefs.size() == refs.length) {
                for (int refIdx = 0; refIdx < refs.length; refIdx++) {
                    boolean found = false;

                    for (int curRefIdx = 0; !found && (curRefIdx < curRefs.size()); curRefIdx++) {
                        Reference curRef = curRefs.get(curRefIdx);

                        if ((caseMatters && refs[refIdx].equals(curRef))
                                || (!caseMatters && refs[refIdx].equalsIgnoreCase(curRef))) {
                            curRefs.remove(curRefIdx);
                            found = true;
                        }
                    }
                }
                if (curRefs.isEmpty()) {
                    return curFk;
                }
            }
        }
    }
    return null;
}

From source file:org.kalypso.zml.ui.table.debug.DebugZmlModelContentProvider.java

@Override
public Object[] getChildren(final Object parentElement) {
    if (parentElement instanceof IZmlModelColumn) {
        final IZmlModelColumn column = (IZmlModelColumn) parentElement;

        final List<Object> children = new ArrayList<>();
        children.add(String.format("Acitve: %s", Boolean.valueOf(column.isActive()).toString())); //$NON-NLS-1$
        children.add(column.getDataColumn().getType());
        children.add(column.getIndexAxis());
        children.add(column.getValueAxis());
        CollectionUtils.addAll(children, column.getDataColumn().getColumnRules());
        CollectionUtils.addAll(children, column.getDataColumn().getCellRules());

        return children.toArray();
    } else if (parentElement instanceof ZmlCellRule) {
        final ZmlCellRule rule = (ZmlCellRule) parentElement;
        return rule.getInstructions();
    }//from ww w.  j a va 2 s .  c om

    return super.getChildren(parentElement);
}

From source file:org.kuali.rice.core.api.criteria.PredicateFactory.java

/**
 * Creates an and predicate that is used to "and" predicates together.
 *
 * <p>An "and" predicate will evaluate the truth value of of it's
 * internal predicates and, if all of them evaluate to true, then
 * the and predicate itself should evaluate to true.  The implementation
  * of an and predicate may short-circuit.
  */*  w w w  . j a  v  a 2  s . c om*/
  * <p>
  *     This factory method does automatic reductions.
  * </p>
 *
  * @param predicates to "and" together
  *
 * @return a predicate
 */
public static Predicate and(Predicate... predicates) {
    //reduce single item compound
    if (predicates != null && predicates.length == 1 && predicates[0] != null) {
        return predicates[0];
    }
    final Set<Predicate> predicateSet = new HashSet<Predicate>();
    CollectionUtils.addAll(predicateSet, predicates);
    return new AndPredicate(predicateSet);
}