net.navasoft.madcoin.backend.services.SpecificDateWorkRequestFilter.java Source code

Java tutorial

Introduction

Here is the source code for net.navasoft.madcoin.backend.services.SpecificDateWorkRequestFilter.java

Source

/*******************************************************************************
 * Copyright 2014 Juan Diego Navarre Gonzalez
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package net.navasoft.madcoin.backend.services;

import java.util.Date;

import net.navasoft.madcoin.backend.services.vo.FilterFieldsException;
import net.navasoft.madcoin.backend.services.vo.IFilteredFields;
import net.navasoft.madcoin.backend.services.vo.SingleDateFilteredFields;

import org.apache.commons.lang.ArrayUtils;

/**
 * net.navasoft.madcoin.backend.services Class class
 * SpecificDateWorkRequestFilter. Description:
 * 
 * @author Juan Diego Navarre Gonzalez - (<a
 *         href="mailto:jdnavarreg@outlook.com">{@literal jdnavarreg@outlook.com}
 *         </a>)
 * @version 1.0
 * @since 27/07/2014 06:48:18 PM
 */
public class SpecificDateWorkRequestFilter extends WorkRequestFilter {

    /**
     * properties.
     * 
     * @since 27/07/2014, 06:48:18 PM
     */
    private IFilteredFields<String, Date, String> properties = new SingleDateFilteredFields();

    /**
     * Instantiates a new specific date work request filter.
     * 
     * @since 27/07/2014, 06:48:18 PM
     */
    public SpecificDateWorkRequestFilter() {
    }

    /**
     * Instantiates a new specific date work request filter.
     * 
     * @param criteria
     *            the criteria
     * @since 27/07/2014, 06:48:18 PM
     */
    public SpecificDateWorkRequestFilter(EFilters criteria) {
        setDescriptors(criteria.getDescriptors());
    }

    /* (non-Javadoc)
     * @see net.navasoft.madcoin.backend.services.WorkRequestFilter#filter()
     */
    /**
     * Filter.
     * 
     * @return the i filtered fields
     * @since 27/07/2014, 06:48:18 PM
     */
    @Override
    public IFilteredFields<?, ?, ?> filter() {
        if (filteredValueObject.getSpecificCost() != null) {
            try {
                properties.updateMandatory(getDescriptors()[0], properties
                        .formatField(filteredValueObject.getSpecificDate(), ArrayUtils.EMPTY_OBJECT_ARRAY));
            } catch (FilterFieldsException e) {
                System.out.println("FUCK!!!");
                e.printStackTrace();
            }
        }
        if (filteredValueObject.getCurrency() != null) {
            properties.updateOptional(getDescriptors()[1], filteredValueObject.getTimeZone());
        }
        return properties;

    }

}