com.webbfontaine.valuewebb.irms.impl.function.TtRuleFunctions.java Source code

Java tutorial

Introduction

Here is the source code for com.webbfontaine.valuewebb.irms.impl.function.TtRuleFunctions.java

Source

/*
 * Copyrights 2002-2011 Webb Fontaine
 * Developer: Sargis Harutyunyan
 * Date: 25 nov. 2011
 * This software is the proprietary information of Webb Fontaine.
 * Its use is subject to License terms.
 */
package com.webbfontaine.valuewebb.irms.impl.function;

import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.webbfontaine.valuewebb.irms.core.RuleContext;
import com.webbfontaine.valuewebb.irms.impl.bean.TTSourceBean;
import com.webbfontaine.valuewebb.model.TtDoc;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

@Name("ttRuleFunctions")
@Scope(ScopeType.APPLICATION)
public class TtRuleFunctions {

    private static final Logger LOGGER = LoggerFactory.getLogger(TtRuleFunctions.class);

    public boolean isDocumentAttached(TTSourceBean sourceBean, final String docType) {
        LOGGER.debug("Searching for match for docType: {}", docType);

        List<TtDoc> ttDocs = sourceBean.getTtGen().getTtDocs();
        return Iterables.any(ttDocs, new Predicate<TtDoc>() {
            @Override
            public boolean apply(TtDoc input) {
                return docType.equals(input.getType());
            }
        });
    }

    public String getOperation(RuleContext ruleContext) {
        return ruleContext.getOperation();
    }

}