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

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

Introduction

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

Prototype

public static void transform(Collection collection, Transformer transformer) 

Source Link

Document

Transform the collection by applying a Transformer to each element.

Usage

From source file:nl.strohalm.cyclos.controls.accounts.accounttypes.SearchAccountTypesAjaxAction.java

@Override
@SuppressWarnings("unchecked")
protected void renderContent(final ActionContext context) throws Exception {
    final SearchAccountTypesAjaxForm form = context.getForm();
    final MemberAccountTypeQuery query = getQueryBinder().readFromString(form);
    final List<MemberAccountType> accountTypes = (List<MemberAccountType>) accountTypeService.search(query);
    DataBinder<?> collectionBinder;
    if (form.isScheduling()) {
        final AccountTypesWithScheduling transformer = new AccountTypesWithScheduling(query.getCanPay(),
                query.getOwner());//  www .j  a v a  2 s .co m
        CollectionUtils.transform(accountTypes, transformer);
        collectionBinder = getAccountTypeBinderWithScheduling();
    } else {
        collectionBinder = getAccountTypeBinder();
    }
    final String json = collectionBinder.readAsString(accountTypes);
    responseHelper.writeJSON(context.getResponse(), json);
}

From source file:org.accada.epcis.repository.query.QueryOperationsModule.java

/**
 * Create an SQL query string from the given query parameters.
 * <p>//from   ww  w .ja v  a  2  s .co m
 * Note: the CXF framework always returns an instance of org.w3c.dom.Element
 * for the query parameter value given in the <code>queryParams</code>
 * argument, because the spec defines this value to be of type
 * <code>anyType</code>. CXF <i>does not</i> resolve the type of the
 * query parameter value from the query name as Axis does! However, if the
 * user specifies the XML type in the request, then CXF returns an instance
 * of the corresponding type.
 * <p>
 * Consider the following example of a query parameter:
 * 
 * <pre>
 * &lt;param&gt;
 *   &lt;name&gt;GE_eventTime&lt;/name&gt;
 *   &lt;value&gt;2007-07-07T07:07:07+02:00&lt;/value&gt;
 * &lt;/param&gt;
 * </pre>
 * 
 * For the query parameter value, CXF will return an instance of
 * org.w3c.dom.Element containing the text value
 * "2007-07-07T07:07:07+02:00". However, if the user provides the following
 * instead, CXF will return an instance of
 * javax.xml.datatype.XMLGregorianCalendar.
 * 
 * <pre>
 * &lt;param&gt;
 *   &lt;name&gt;GE_eventTime&lt;/name&gt;
 *   &lt;value
 *       xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
 *       xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;
 *       xsi:type=&quot;xs:dateTime&quot;&gt;
 *     2007-07-07T07:07:07+02:00
 *   &lt;/value&gt;
 * &lt;/param&gt;
 * </pre>
 * 
 * As a consequence, we always first need to check if the value is an
 * instance of Element, and if so, we need to parse it manually according to
 * the semantics of the parameter name.
 * 
 * @param queryParams
 *            The query parameters.
 * @param eventType
 *            Has to be one of the four basic event types "ObjectEvent",
 *            "AggregationEvent", "QuantityEvent", "TransactionEvent".
 * @return The prepared sql statement.
 * @throws SQLException
 *             Whenever something goes wrong when querying the db.
 * @throws QueryParameterException
 *             If one of the given QueryParam is invalid.
 * @throws ImplementationException
 *             If an error in the implementation occurred.
 */
private List<SimpleEventQueryDTO> constructSimpleEventQueries(final QueryParams queryParams)
        throws SQLException, QueryParameterExceptionResponse {
    SimpleEventQueryDTO aggrEventQuery = new SimpleEventQueryDTO(EpcisConstants.AGGREGATION_EVENT);
    SimpleEventQueryDTO objEventQuery = new SimpleEventQueryDTO(EpcisConstants.OBJECT_EVENT);
    SimpleEventQueryDTO quantEventQuery = new SimpleEventQueryDTO(EpcisConstants.QUANTITY_EVENT);
    SimpleEventQueryDTO transEventQuery = new SimpleEventQueryDTO(EpcisConstants.TRANSACTION_EVENT);

    boolean includeAggrEvents = true;
    boolean includeObjEvents = true;
    boolean includeQuantEvents = true;
    boolean includeTransEvents = true;

    String orderBy = null;
    OrderDirection orderDirection = null;
    int eventCountLimit = -1;
    int maxEventCount = -1;

    // a sorted List of query parameter names - keeps track of the processed
    // names in order to cope with duplicates
    List<String> sortedParamNames = new ArrayList<String>();

    for (QueryParam param : queryParams.getParam()) {
        String paramName = param.getName();
        Object paramValue = param.getValue();

        // check for null values
        if (paramName == null || "".equals(paramName)) {
            String msg = "Missing name for a query parameter";
            throw queryParameterException(msg, null);
        }
        if (paramValue == null) {
            String msg = "Missing value for query parameter '" + paramName + "'";
            throw queryParameterException(msg, null);
        }
        // check if the current query parameter has already been provided
        int index = Collections.binarySearch(sortedParamNames, paramName);
        if (index < 0) {
            // we have not yet seen this query parameter name - ok
            sortedParamNames.add(-index - 1, paramName);
        } else {
            // we have already handled this query parameter name - not ok
            String msg = "Query parameter '" + paramName + "' provided more than once";
            throw queryParameterException(msg, null);
        }

        if (LOG.isDebugEnabled()) {
            LOG.debug("Handling query parameter: " + paramName);
        }
        try {
            if (paramName.equals("eventType")) {
                // by default all event types will be included
                List<String> eventTypes = parseAsArrayOfString(paramValue).getString();
                if (!eventTypes.isEmpty()) {
                    // check if valid event types are provided
                    checkEventTypes(eventTypes);

                    // check for excluded event types
                    if (!eventTypes.contains(EpcisConstants.AGGREGATION_EVENT)) {
                        includeAggrEvents = false;
                    }
                    if (!eventTypes.contains(EpcisConstants.OBJECT_EVENT)) {
                        includeObjEvents = false;
                    }
                    if (!eventTypes.contains(EpcisConstants.QUANTITY_EVENT)) {
                        includeQuantEvents = false;
                    }
                    if (!eventTypes.contains(EpcisConstants.TRANSACTION_EVENT)) {
                        includeTransEvents = false;
                    }
                }
            } else if (paramName.equals("GE_eventTime") || paramName.equals("LT_eventTime")
                    || paramName.equals("GE_recordTime") || paramName.equals("LT_recordTime")) {
                Timestamp ts = parseAsTimestamp(paramValue, paramName);
                Operation op = Operation.valueOf(paramName.substring(0, 2));
                String eventField = paramName.substring(3, paramName.length());
                aggrEventQuery.addEventQueryParam(eventField, op, ts);
                objEventQuery.addEventQueryParam(eventField, op, ts);
                quantEventQuery.addEventQueryParam(eventField, op, ts);
                transEventQuery.addEventQueryParam(eventField, op, ts);

            } else if (paramName.equals("EQ_action")) {
                // QuantityEvents have no "action" field, thus exclude them
                includeQuantEvents = false;
                ArrayOfString aos = parseAsArrayOfString(paramValue);
                if (!aos.getString().isEmpty()) {
                    checkActionValues(aos.getString());
                    aggrEventQuery.addEventQueryParam("action", Operation.EQ, aos.getString());
                    objEventQuery.addEventQueryParam("action", Operation.EQ, aos.getString());
                    transEventQuery.addEventQueryParam("action", Operation.EQ, aos.getString());
                }

            } else if (paramName.equals("EQ_bizStep") || paramName.equals("EQ_disposition")
                    || paramName.equals("EQ_readPoint") || paramName.equals("EQ_bizLocation")) {
                ArrayOfString aos = parseAsArrayOfString(paramValue);
                if (!aos.getString().isEmpty()) {
                    String eventField = paramName.substring(3, paramName.length());
                    aggrEventQuery.addEventQueryParam(eventField, Operation.EQ, aos.getString());
                    objEventQuery.addEventQueryParam(eventField, Operation.EQ, aos.getString());
                    quantEventQuery.addEventQueryParam(eventField, Operation.EQ, aos.getString());
                    transEventQuery.addEventQueryParam(eventField, Operation.EQ, aos.getString());
                }

            } else if (paramName.equals("WD_readPoint") || paramName.equals("WD_bizLocation")) {
                ArrayOfString aos = parseAsArrayOfString(paramValue);
                if (!aos.getString().isEmpty()) {
                    // append a "*" to each of the parameter values - this
                    // should implement the semantics of "With Descendant"
                    // TODO: should???
                    CollectionUtils.transform(aos.getString(), new StringTransformer());
                    String eventField = paramName.substring(3, paramName.length());
                    aggrEventQuery.addEventQueryParam(eventField, Operation.WD, aos.getString());
                    objEventQuery.addEventQueryParam(eventField, Operation.WD, aos.getString());
                    quantEventQuery.addEventQueryParam(eventField, Operation.WD, aos.getString());
                    transEventQuery.addEventQueryParam(eventField, Operation.WD, aos.getString());
                }

            } else if (paramName.startsWith("EQ_bizTransaction_")) {
                // type extracted from parameter name
                String bizTransType = paramName.substring(18);
                ArrayOfString aos = parseAsArrayOfString(paramValue);
                if (!aos.getString().isEmpty()) {
                    aggrEventQuery.addEventQueryParam("bizTransList.type", Operation.EQ, bizTransType);
                    objEventQuery.addEventQueryParam("bizTransList.type", Operation.EQ, bizTransType);
                    quantEventQuery.addEventQueryParam("bizTransList.type", Operation.EQ, bizTransType);
                    transEventQuery.addEventQueryParam("bizTransList.type", Operation.EQ, bizTransType);
                    aggrEventQuery.addEventQueryParam("bizTransList.bizTrans", Operation.EQ, aos.getString());
                    objEventQuery.addEventQueryParam("bizTransList.bizTrans", Operation.EQ, aos.getString());
                    quantEventQuery.addEventQueryParam("bizTransList.bizTrans", Operation.EQ, aos.getString());
                    transEventQuery.addEventQueryParam("bizTransList.bizTrans", Operation.EQ, aos.getString());
                }

            } else if (paramName.equals("MATCH_epc") || paramName.equals("MATCH_anyEPC")) {
                // QuantityEvents have no field for EPCs, thus exclude them
                includeQuantEvents = false;
                ArrayOfString aos = parseAsArrayOfString(paramValue);
                if (!aos.getString().isEmpty()) {
                    aggrEventQuery.addEventQueryParam("childEPCs", Operation.MATCH, aos.getString());
                    objEventQuery.addEventQueryParam("epcList", Operation.MATCH, aos.getString());
                    transEventQuery.addEventQueryParam("epcList", Operation.MATCH, aos.getString());
                    if (paramName.equals("MATCH_anyEPC")) {
                        // AggregationEvent and TransactionEvent need
                        // special treatment ("parentID" field)
                        aggrEventQuery.setIsAnyEpc(true);
                        transEventQuery.setIsAnyEpc(true);
                    }
                }

            } else if (paramName.equals("MATCH_parentID")) {
                includeQuantEvents = false;
                includeObjEvents = false;
                ArrayOfString aos = parseAsArrayOfString(paramValue);
                if (!aos.getString().isEmpty()) {
                    aggrEventQuery.addEventQueryParam("parentID", Operation.MATCH, aos.getString());
                    transEventQuery.addEventQueryParam("parentID", Operation.MATCH, aos.getString());
                }

            } else if (paramName.equals("MATCH_epcClass")) {
                includeAggrEvents = false;
                includeObjEvents = false;
                includeTransEvents = false;
                ArrayOfString aos = parseAsArrayOfString(paramValue);
                if (!aos.getString().isEmpty()) {
                    quantEventQuery.addEventQueryParam("epcClass", Operation.MATCH, aos.getString());
                }

            } else if (paramName.endsWith("_quantity")) {
                includeAggrEvents = false;
                includeObjEvents = false;
                includeTransEvents = false;
                Operation op = Operation.valueOf(paramName.substring(0, paramName.indexOf('_')));
                quantEventQuery.addEventQueryParam("quantity", op, parseAsInteger(paramValue));

            } else if (paramName.startsWith("GT_") || paramName.startsWith("GE_") || paramName.startsWith("EQ_")
                    || paramName.startsWith("LE_") || paramName.startsWith("LT_")) {
                // must be an event field extension
                String fieldname = paramName.substring(3);
                String[] parts = fieldname.split("#");
                if (parts.length != 2) {
                    String msg = "Invalid parameter " + paramName;
                    throw queryParameterException(msg, null);
                }
                Operation op = Operation.valueOf(paramName.substring(0, 2));
                String eventField;
                Object value;
                try {
                    value = parseAsInteger(paramValue);
                    eventField = "extension.intValue";
                } catch (NumberFormatException e1) {
                    try {
                        value = parseAsFloat(paramValue);
                        eventField = "extension.floatValue";
                    } catch (NumberFormatException e2) {
                        try {
                            value = parseAsTimestamp(paramValue, paramName);
                            eventField = "extension.dateValue";
                        } catch (QueryParameterExceptionResponse e) {
                            value = parseAsString(paramValue);
                            eventField = "extension.strValue";
                        }
                    }
                }
                aggrEventQuery.addEventQueryParam(eventField, op, value);
                objEventQuery.addEventQueryParam(eventField, op, value);
                quantEventQuery.addEventQueryParam(eventField, op, value);
                transEventQuery.addEventQueryParam(eventField, op, value);
                aggrEventQuery.addEventQueryParam("extension.fieldname", Operation.EQ, fieldname);
                objEventQuery.addEventQueryParam("extension.fieldname", Operation.EQ, fieldname);
                quantEventQuery.addEventQueryParam("extension.fieldname", Operation.EQ, fieldname);
                transEventQuery.addEventQueryParam("extension.fieldname", Operation.EQ, fieldname);

            } else if (paramName.startsWith("EXISTS_")) {
                String fieldname = paramName.substring(7);
                if (fieldname.equals("childEPCs")) {
                    includeObjEvents = false;
                    includeQuantEvents = false;
                    includeTransEvents = false;
                    aggrEventQuery.addEventQueryParam("childEPCs", Operation.EXISTS, null);
                } else if (fieldname.equals("epcList")) {
                    includeAggrEvents = false;
                    includeQuantEvents = false;
                    objEventQuery.addEventQueryParam("epcList", Operation.EXISTS, null);
                    transEventQuery.addEventQueryParam("epcList", Operation.EXISTS, null);
                } else if (fieldname.equals("action")) {
                    includeQuantEvents = false;
                    aggrEventQuery.addEventQueryParam("action", Operation.EXISTS, null);
                    objEventQuery.addEventQueryParam("action", Operation.EXISTS, null);
                    transEventQuery.addEventQueryParam("action", Operation.EXISTS, null);
                } else if (fieldname.equals("parentID")) {
                    includeObjEvents = false;
                    includeQuantEvents = false;
                    aggrEventQuery.addEventQueryParam("parentID", Operation.EXISTS, null);
                    transEventQuery.addEventQueryParam("parentID", Operation.EXISTS, null);
                } else if (fieldname.equals("quantity") || fieldname.equals("epcClass")) {
                    includeAggrEvents = false;
                    includeObjEvents = false;
                    includeTransEvents = false;
                    quantEventQuery.addEventQueryParam(fieldname, Operation.EXISTS, null);
                } else if (fieldname.equals("eventTime") || fieldname.equals("recordTime")
                        || fieldname.equals("eventTimeZoneOffset") || fieldname.equals("bizStep")
                        || fieldname.equals("disposition") || fieldname.equals("readPoint")
                        || fieldname.equals("bizLocation") || fieldname.equals("bizTransList")) {
                    aggrEventQuery.addEventQueryParam(fieldname, Operation.EXISTS, null);
                    objEventQuery.addEventQueryParam(fieldname, Operation.EXISTS, null);
                    quantEventQuery.addEventQueryParam(fieldname, Operation.EXISTS, null);
                    transEventQuery.addEventQueryParam(fieldname, Operation.EXISTS, null);
                } else {
                    // lets see if we have an extension fieldname
                    String[] parts = fieldname.split("#");
                    if (parts.length != 2) {
                        String msg = "Invalid parameter " + paramName;
                        throw queryParameterException(msg, null);
                    }
                    aggrEventQuery.addEventQueryParam("extension.fieldname", Operation.EQ, fieldname);
                    objEventQuery.addEventQueryParam("extension.fieldname", Operation.EQ, fieldname);
                    quantEventQuery.addEventQueryParam("extension.fieldname", Operation.EQ, fieldname);
                    transEventQuery.addEventQueryParam("extension.fieldname", Operation.EQ, fieldname);
                }

            } else if (paramName.startsWith("HASATTR_")) {
                // restrict by attribute name
                String fieldname = paramName.substring(8);
                ArrayOfString aos = parseAsArrayOfString(paramValue);
                String eventField = fieldname + ".attribute";
                aggrEventQuery.addEventQueryParam(eventField, Operation.EQ, aos.getString());
                objEventQuery.addEventQueryParam(eventField, Operation.EQ, aos.getString());
                quantEventQuery.addEventQueryParam(eventField, Operation.EQ, aos.getString());
                transEventQuery.addEventQueryParam(eventField, Operation.EQ, aos.getString());

            } else if (paramName.startsWith("EQATTR_")) {
                String fieldname = paramName.substring(7);
                String attrname = null;
                String[] parts = fieldname.split("_");
                if (parts.length > 2) {
                    String msg = "Query parameter has invalid format: " + paramName
                            + ". Expected: EQATTR_fieldname_attrname";
                    throw queryParameterException(msg, null);
                } else if (parts.length == 2) {
                    fieldname = parts[0];
                    attrname = parts[1];
                }
                // restrict by attribute name
                String eventField = fieldname + ".attribute";
                aggrEventQuery.addEventQueryParam(eventField, Operation.EQ, attrname);
                objEventQuery.addEventQueryParam(eventField, Operation.EQ, attrname);
                quantEventQuery.addEventQueryParam(eventField, Operation.EQ, attrname);
                transEventQuery.addEventQueryParam(eventField, Operation.EQ, attrname);
                // restrict by attribute value
                ArrayOfString aos = parseAsArrayOfString(paramValue);
                eventField = eventField + ".value";
                aggrEventQuery.addEventQueryParam(eventField, Operation.EQ, aos.getString());
                objEventQuery.addEventQueryParam(eventField, Operation.EQ, aos.getString());
                quantEventQuery.addEventQueryParam(eventField, Operation.EQ, aos.getString());
                transEventQuery.addEventQueryParam(eventField, Operation.EQ, aos.getString());

            } else if (paramName.equals("orderBy")) {
                orderBy = parseAsString(paramValue);
                if (!"eventTime".equals(orderBy) && !"recordTime".equals(orderBy)
                        && !"quantity".equals(orderBy)) {
                    String[] parts = orderBy.split("#");
                    if (parts.length != 2) {
                        String msg = "orderBy must be one of eventTime, recordTime, quantity, or an extension field";
                        throw queryParameterException(msg, null);
                    }
                }

            } else if (paramName.equals("orderDirection")) {
                orderDirection = OrderDirection.valueOf(parseAsString(paramValue));

            } else if (paramName.equals("eventCountLimit")) {
                eventCountLimit = parseAsInteger(paramValue).intValue();

            } else if (paramName.equals("maxEventCount")) {
                maxEventCount = parseAsInteger(paramValue).intValue();

            } else {
                String msg = "Unknown query parameter: " + paramName;
                throw queryParameterException(msg, null);
            }
        } catch (ClassCastException e) {
            String msg = "Type of value invalid for query parameter '" + paramName + "': " + paramValue;
            throw queryParameterException(msg, e);
        } catch (IllegalArgumentException e) {
            String msg = "Unparseable value for query parameter '" + paramName + "'. " + e.getMessage();
            throw queryParameterException(msg, e);
        }
    }

    // some more user input checks
    if (maxEventCount > -1 && eventCountLimit > -1) {
        String msg = "Paramters 'maxEventCount' and 'eventCountLimit' are mutually exclusive";
        throw queryParameterException(msg, null);
    }
    if (orderBy == null && eventCountLimit > -1) {
        String msg = "'eventCountLimit' may only be used when 'orderBy' is specified";
        throw queryParameterException(msg, null);
    }
    if (orderBy == null && orderDirection != null) {
        String msg = "'orderDirection' may only be used when 'orderBy' is specified";
        throw queryParameterException(msg, null);
    }
    if (orderBy != null) {
        aggrEventQuery.setOrderBy(orderBy);
        objEventQuery.setOrderBy(orderBy);
        quantEventQuery.setOrderBy(orderBy);
        transEventQuery.setOrderBy(orderBy);
        if (orderDirection != null) {
            aggrEventQuery.setOrderDirection(orderDirection);
            objEventQuery.setOrderDirection(orderDirection);
            quantEventQuery.setOrderDirection(orderDirection);
            transEventQuery.setOrderDirection(orderDirection);
        }
    }
    if (eventCountLimit > -1) {
        aggrEventQuery.setLimit(eventCountLimit);
        objEventQuery.setLimit(eventCountLimit);
        quantEventQuery.setLimit(eventCountLimit);
        transEventQuery.setLimit(eventCountLimit);
    }
    if (maxEventCount > -1) {
        aggrEventQuery.setMaxEventCount(maxEventCount);
        objEventQuery.setMaxEventCount(maxEventCount);
        quantEventQuery.setMaxEventCount(maxEventCount);
        transEventQuery.setMaxEventCount(maxEventCount);
    }

    List<SimpleEventQueryDTO> eventQueries = new ArrayList<SimpleEventQueryDTO>(4);
    if (includeAggrEvents) {
        eventQueries.add(aggrEventQuery);
    }
    if (includeObjEvents) {
        eventQueries.add(objEventQuery);
    }
    if (includeQuantEvents) {
        eventQueries.add(quantEventQuery);
    }
    if (includeTransEvents) {
        eventQueries.add(transEventQuery);
    }
    return eventQueries;
}

From source file:org.andromda.cartridges.gui.metafacades.GuiManageableEntityLogicImpl.java

/**
 * @return allRoles/*from  ww w. java  2s  .c o m*/
 * @see org.andromda.cartridges.gui.metafacades.GuiManageableEntity#getRoles()
 */
@Override
protected Collection<Role> handleGetRoles() {

    // copied form the Service <<Metafacade>>
    final Collection roles = new ArrayList(this.getTargetDependencies());

    CollectionUtils.filter(roles, new Predicate() {

        @Override
        public boolean evaluate(final Object object) {

            final DependencyFacade dependency = (DependencyFacade) object;

            return (dependency != null) && (dependency.getSourceElement() instanceof Role);

        }

    });
    CollectionUtils.transform(roles, new Transformer() {

        @Override
        public Object transform(final Object object) {

            return ((DependencyFacade) object).getSourceElement();

        }

    });

    final Collection allRoles = new LinkedHashSet(roles);

    // add all roles which are generalizations of this one
    CollectionUtils.forAllDo(roles, new Closure() {

        @Override
        public void execute(final Object object) {

            allRoles.addAll(((Role) object).getAllSpecializations());

        }

    });

    return allRoles;

}

From source file:org.andromda.timetracker.domain.TaskDaoBase.java

/**
 * {@inheritDoc}//from  ww w  . ja  v  a 2s  .  co m
 */
@Override
@SuppressWarnings({ "unchecked" })
public final Collection<TaskVO> toTaskVOCollection(Collection<?> entities) {
    Collection<TaskVO> result = new ArrayList<TaskVO>();
    if (entities != null) {
        CollectionUtils.transform(entities, this.TASKVO_TRANSFORMER);
        result.addAll((Collection<? extends TaskVO>) entities);
    }
    return result;
}

From source file:org.andromda.timetracker.domain.TaskDaoBase.java

/**
 * {@inheritDoc}// www.j  av  a2s. c  om
 */
@Override
public final void taskVOToEntityCollection(Collection<?> instances) {
    if (instances != null) {
        for (final Iterator<?> iterator = instances.iterator(); iterator.hasNext();) {
            // - remove an objects that are null or not of the correct instance
            if (!(iterator.next() instanceof TaskVO)) {
                iterator.remove();
            }
        }
        CollectionUtils.transform(instances, this.TaskVOToEntityTransformer);
    }
}

From source file:org.andromda.timetracker.domain.TimeAllocationDaoBase.java

/**
 * {@inheritDoc}/*from w w w  .j  a va 2 s.  c  o  m*/
 */
@Override
@SuppressWarnings({ "unchecked" })
public final Collection<TimeAllocationVO> toTimeAllocationVOCollection(Collection<?> entities) {
    Collection<TimeAllocationVO> result = new ArrayList<TimeAllocationVO>();
    if (entities != null) {
        CollectionUtils.transform(entities, this.TIMEALLOCATIONVO_TRANSFORMER);
        result.addAll((Collection<? extends TimeAllocationVO>) entities);
    }
    return result;
}

From source file:org.andromda.timetracker.domain.TimeAllocationDaoBase.java

/**
 * {@inheritDoc}//from  w ww .  j a  v a2 s  . com
 */
@Override
public final void timeAllocationVOToEntityCollection(Collection<?> instances) {
    if (instances != null) {
        for (final Iterator<?> iterator = instances.iterator(); iterator.hasNext();) {
            // - remove an objects that are null or not of the correct instance
            if (!(iterator.next() instanceof TimeAllocationVO)) {
                iterator.remove();
            }
        }
        CollectionUtils.transform(instances, this.TimeAllocationVOToEntityTransformer);
    }
}

From source file:org.andromda.timetracker.domain.TimecardDaoBase.java

/**
 * {@inheritDoc}// w  w w .  j  a v a  2 s .co m
 */
@Override
@SuppressWarnings({ "unchecked" })
public final Collection<TimecardSummaryVO> toTimecardSummaryVOCollection(Collection<?> entities) {
    Collection<TimecardSummaryVO> result = new ArrayList<TimecardSummaryVO>();
    if (entities != null) {
        CollectionUtils.transform(entities, this.TIMECARDSUMMARYVO_TRANSFORMER);
        result.addAll((Collection<? extends TimecardSummaryVO>) entities);
    }
    return result;
}

From source file:org.andromda.timetracker.domain.TimecardDaoBase.java

/**
 * {@inheritDoc}/*from w w w  .j a  v a 2  s .  com*/
 */
@Override
public final void timecardSummaryVOToEntityCollection(Collection<?> instances) {
    if (instances != null) {
        for (final Iterator<?> iterator = instances.iterator(); iterator.hasNext();) {
            // - remove an objects that are null or not of the correct instance
            if (!(iterator.next() instanceof TimecardSummaryVO)) {
                iterator.remove();
            }
        }
        CollectionUtils.transform(instances, this.TimecardSummaryVOToEntityTransformer);
    }
}

From source file:org.andromda.timetracker.domain.TimecardDaoBase.java

/**
 * {@inheritDoc}// w  ww .  j a v  a 2  s. c  om
 */
@Override
@SuppressWarnings({ "unchecked" })
public final Collection<TimecardVO> toTimecardVOCollection(Collection<?> entities) {
    Collection<TimecardVO> result = new ArrayList<TimecardVO>();
    if (entities != null) {
        CollectionUtils.transform(entities, this.TIMECARDVO_TRANSFORMER);
        result.addAll((Collection<? extends TimecardVO>) entities);
    }
    return result;
}