Example usage for org.apache.commons.lang BooleanUtils toBoolean

List of usage examples for org.apache.commons.lang BooleanUtils toBoolean

Introduction

In this page you can find the example usage for org.apache.commons.lang BooleanUtils toBoolean.

Prototype

public static boolean toBoolean(String str, String trueString, String falseString) 

Source Link

Document

Converts a String to a Boolean throwing an exception if no match found.

null is returned if there is no match.

 BooleanUtils.toBoolean("true", "true", "false")  = true BooleanUtils.toBoolean("false", "true", "false") = false 

Usage

From source file:com.mg.merp.planning.support.ui.GenericItemBr.java

@Override
protected String createQueryText() {
    Set<TableEJBQLFieldDef> fieldDefs = ((DefaultMaintenanceEJBQLTableModel) table.getModel())
            .getFieldDefsSet();//w w  w.  j  a va  2s . c  o m
    String fieldsList = DatabaseUtils.generateEJBQLSelectClause(fieldDefs);
    String fromList = DatabaseUtils.generateEJBQLFromClause(fieldDefs);
    GenericItemRest restForm = (GenericItemRest) getRestrictionForm();
    paramsName.clear();
    paramsValue.clear();
    StringBuilder whereText = new StringBuilder(" where 0 = 0 ")
            .append(DatabaseUtils.formatEJBQLStringRestriction("gi.GenericItemCode",
                    restForm.getGenericItemCode(), "genericItemCode", paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLStringRestriction("gi.GenericItemName",
                    restForm.getGenericItemName(), "genericItemName", paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRangeRestriction("gi.PlanningShelfLife",
                    restForm.getPlanningShelfLifeFrom(), restForm.getPlanningShelfLifeTill(),
                    "planningShelfLifeFrom", "planningShelfLifeTill", paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLAddinFieldsRestriction(service, "gi.Id",
                    restForm.getAddinFieldsRestriction(), false));
    if (restForm.getPlanningItemFlag() != 0) {
        whereText = whereText.append(DatabaseUtils.formatEJBQLObjectRestriction("gi.PlanningItemFlag",
                BooleanUtils.toBoolean(restForm.getPlanningItemFlag(), 2, 1), "planningItemFlag", paramsName,
                paramsValue, false));
    }
    return String.format(INIT_QUERY_TEXT, fieldsList, fromList, whereText.toString());

}

From source file:com.redhat.rhn.frontend.dto.kickstart.KickstartDto.java

/**
 * @return Returns the isOrgDefault.// w  w w .  j  av a  2s. c  o  m
 */
public boolean isOrgDefault() {
    return !StringUtils.isBlank(isOrgDefault) && BooleanUtils.toBoolean(isOrgDefault, "Y", "N");
}

From source file:com.mg.merp.crm.support.ui.OperationBr.java

@Override
protected String createQueryText() {
    String whereText = "";
    Set<TableEJBQLFieldDef> fieldDefs = ((DefaultMaintenanceEJBQLTableModel) table.getModel())
            .getFieldDefsSet();/*from  w w w .j  ava  2  s. c o m*/
    String fieldsList = DatabaseUtils.generateEJBQLSelectClause(fieldDefs);
    String fromList = DatabaseUtils.generateEJBQLFromClause(fieldDefs);
    paramsName.clear();
    paramsValue.clear();
    OperationRest restForm = (OperationRest) getRestrictionForm();
    whereText = " where 0=0 "
            .concat(DatabaseUtils.formatEJBQLObjectRestriction("op.Relation", restForm.getRelationName(),
                    "relationName", paramsName, paramsValue, false))
            .concat(DatabaseUtils.formatEJBQLObjectRestriction("op.Contact", restForm.getContactCode(),
                    "contactCode", paramsName, paramsValue, false))
            .concat(DatabaseUtils.formatEJBQLObjectRestriction("op.Curator", restForm.getCurator(), "curator",
                    paramsName, paramsValue, false))
            .concat(DatabaseUtils.formatEJBQLObjectRestriction("op.Responsible", restForm.getResponsible(),
                    "responsible", paramsName, paramsValue, false))
            .concat(DatabaseUtils.formatEJBQLObjectRestriction("op.Status", restForm.getStatus(), "status",
                    paramsName, paramsValue, false))
            .concat(DatabaseUtils.formatEJBQLObjectRestriction("op.State", restForm.getState(), "state",
                    paramsName, paramsValue, false))
            .concat(DatabaseUtils.formatEJBQLObjectRangeRestriction("op.PlanDateFrom", restForm.getPlanFrom(),
                    restForm.getPlanTill(), "planFrom", "planTill", paramsName, paramsValue, false))
            .concat(DatabaseUtils.formatEJBQLObjectRangeRestriction("op.PlanDateTill", restForm.getPlanFrom(),
                    restForm.getPlanTill(), "planFrom", "planTill", paramsName, paramsValue, false))
            .concat(DatabaseUtils.formatEJBQLObjectRangeRestriction("op.FactDateFrom", restForm.getFactFrom(),
                    restForm.getFactTill(), "factFrom", "factTill", paramsName, paramsValue, false))
            .concat(DatabaseUtils.formatEJBQLObjectRangeRestriction("op.FactTill", restForm.getFactFrom(),
                    restForm.getFactTill(), "factFrom", "factTill", paramsName, paramsValue, false))
            .concat(DatabaseUtils.formatEJBQLObjectRangeRestriction("op.CreateDate", restForm.getCreateFrom(),
                    restForm.getCreateTill(), "createFrom", "createTill", paramsName, paramsValue, false))
            .concat(DatabaseUtils.formatEJBQLAddinFieldsRestriction(service, "op.Id",
                    restForm.getAddinFieldsRestriction(), false));
    if (restForm.getPlanState() != 0) {
        whereText = whereText.concat(DatabaseUtils.formatEJBQLObjectRestriction("op.IsPlan",
                BooleanUtils.toBoolean(restForm.getPlanState(), 2, 1), "planState", paramsName, paramsValue,
                false));
    }
    if (restForm.getOperationState() == 1) {
        whereText = whereText.concat(" and op.FactDateTill > op.PlanDateTill ");
    }
    if (restForm.getOperationState() == 2) {
        whereText = whereText.concat(" and op.FactDateTill < op.PlanDateTill ");
    }
    return String.format(INIT_QUERY_TEXT, fieldsList, fromList, whereText);

}

From source file:com.haulmont.cuba.gui.components.filter.condition.DynamicAttributesCondition.java

public DynamicAttributesCondition(Element element, String messagesPack, String filterComponentName,
        Datasource datasource) {//  w w  w. j a  va  2  s.c om
    super(element, messagesPack, filterComponentName, datasource);

    propertyPath = element.attributeValue("propertyPath");

    MessageTools messageTools = AppBeans.get(MessageTools.NAME);
    locCaption = isBlank(caption) ? element.attributeValue("locCaption")
            : messageTools.loadString(messagesPack, caption);

    entityAlias = element.attributeValue("entityAlias");
    text = element.getText();
    join = element.attributeValue("join");
    categoryId = UUID.fromString(element.attributeValue("category"));
    String categoryAttributeValue = element.attributeValue("categoryAttribute");
    if (!Strings.isNullOrEmpty(categoryAttributeValue)) {
        categoryAttributeId = UUID.fromString(categoryAttributeValue);
    } else {
        //for backward compatibility
        List<Element> paramElements = Dom4j.elements(element, "param");
        for (Element paramElement : paramElements) {
            if (BooleanUtils.toBoolean(paramElement.attributeValue("hidden", "false"), "true", "false")) {
                categoryAttributeId = UUID.fromString(paramElement.getText());
                String paramName = paramElement.attributeValue("name");
                text = text.replace(":" + paramName, "'" + categoryAttributeId + "'");
            }
        }
    }

    isCollection = Boolean.parseBoolean(element.attributeValue("isCollection"));
    resolveParam(element);
}

From source file:com.mg.merp.salary.support.ui.PersonalAccountBr.java

@Override
protected String createQueryText() {
    //String whereText = "";
    Set<TableEJBQLFieldDef> fieldDefs = ((DefaultMaintenanceEJBQLTableModel) table.getModel())
            .getFieldDefsSet();//  www.  jav  a2 s.c  o  m
    String fieldsList = DatabaseUtils.generateEJBQLSelectClause(fieldDefs);
    String fromList = DatabaseUtils.generateEJBQLFromClause(fieldDefs);
    paramsName.clear();
    paramsValue.clear();
    PersonalAccountRest restForm = (PersonalAccountRest) getRestrictionForm();
    StringBuilder whereText = new StringBuilder(" where 0=0 ")
            .append(DatabaseUtils.formatEJBQLObjectRangeRestriction("pa.BeginDate", restForm.getBeginDate(),
                    restForm.getEndDate(), "beginDate", "endDate", paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRangeRestriction("pa.EndDate", restForm.getBeginDate(),
                    restForm.getEndDate(), "beginDate", "endDate", paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRangeRestriction("pa.ANumber", restForm.getANumberFrom(),
                    restForm.getANumberTill(), "aNumberFrom", "aNumberTill", paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLStringRestriction("Personnel.Person.Surname",
                    restForm.getSurname(), "surname", paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLStringRestriction("Personnel.Person.Name", restForm.getName(),
                    "name", paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLStringRestriction("Personnel.Person.Patronymic",
                    restForm.getPatronymic(), "patronymic", paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLStringRestriction("Personnel.Person.Inn", restForm.getInn(), "inn",
                    paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRestriction("Personnel.InsuredClass",
                    restForm.getInsuredClass(), "insuredClass", paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRestriction("pf.Position", restForm.getPosition(),
                    "position", paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRestriction("pf.PositionFillKind",
                    restForm.getPositionFillKind(), "positionFillKind", paramsName, paramsValue, false))
            .

            append(DatabaseUtils.formatEJBQLAddinFieldsRestriction(service, "pa.Id",
                    restForm.getAddinFieldsRestriction(), false));
    if (whereText.toString().contains("pf.")) {
        whereText = whereText.append(" and pf.PersonalAccount = pa.Id");
        fromList = (", PositionFill pf ").concat(fromList);
    }
    if (restForm.getIsBasic() != 0) {
        whereText = whereText.append(DatabaseUtils.formatEJBQLObjectRestriction("pf.IsBasic",
                BooleanUtils.toBoolean(restForm.getIsBasic(), 1, 2), "isBasic", paramsName, paramsValue,
                false));
    }
    return String.format(INIT_QUERY_TEXT, fieldsList, fromList, whereText.toString());
}

From source file:com.mg.merp.account.support.ui.BuyBookBr.java

@Override
protected String createQueryText() {
    String whereText = "";
    Set<TableEJBQLFieldDef> fieldDefs = ((DefaultMaintenanceEJBQLTableModel) table.getModel())
            .getFieldDefsSet();//from w w w  . j a  va2s  .  c  o  m
    String fieldsList = DatabaseUtils.generateEJBQLSelectClause(fieldDefs);
    String fromList = DatabaseUtils.generateEJBQLFromClause(fieldDefs);
    paramsName.clear();
    paramsValue.clear();
    BuyBookRest restForm = (BuyBookRest) getRestrictionForm();

    whereText = " where "
            .concat(DatabaseUtils.formatEJBQLHierarchyRestriction(
                    ((HierarchyRestrictionSupport) restForm).isUseHierarchy(), "bb.Folder", 0, "folder",
                    folderEntity, paramsName, paramsValue, true))
            .concat(DatabaseUtils.formatEJBQLObjectRangeRestriction("bb.InsertDate", restForm.getInsertDate1(),
                    restForm.getInsertDate2(), "insertDate1", "insertDate1", paramsName, paramsValue, false))
            .concat(DatabaseUtils.formatEJBQLObjectRangeRestriction("bb.TotalSum", restForm.getTotalSum1(),
                    restForm.getTotalSum2(), "totalSum1", "totalSum2", paramsName, paramsValue, false))
            .concat(DatabaseUtils.formatEJBQLObjectRangeRestriction("bb.Nds1Sum", restForm.getNds1Sum1(),
                    restForm.getNds1Sum2(), "nds1Sum1", "nds1Sum2", paramsName, paramsValue, false))
            .concat(DatabaseUtils.formatEJBQLObjectRangeRestriction("bb.Nds2Sum", restForm.getNds2Sum1(),
                    restForm.getNds2Sum2(), "nds2Sum1", "nds2Sum2", paramsName, paramsValue, false))
            .concat(DatabaseUtils.formatEJBQLObjectRangeRestriction("bb.Nds3Sum", restForm.getNds3Sum1(),
                    restForm.getNds3Sum2(), "nds3Sum1", "nds3Sum2", paramsName, paramsValue, false))
            .concat(DatabaseUtils.formatEJBQLObjectRangeRestriction("bb.DocDate", restForm.getDocDate1(),
                    restForm.getDocDate2(), "docDate1", "docDate2", paramsName, paramsValue, false))
            .concat(DatabaseUtils.formatEJBQLStringRestriction("bb.DocNumber", restForm.getDocNumber(),
                    "docNumber", paramsName, paramsValue, false))
            .concat(DatabaseUtils.formatEJBQLObjectRestriction("bb.DocType", restForm.getDocType(), "docType",
                    paramsName, paramsValue, false))
            .concat(DatabaseUtils.formatEJBQLObjectRestriction("bb.Provider", restForm.getContractorCode(),
                    "contractorCode", paramsName, paramsValue, false))
            .concat(DatabaseUtils.formatEJBQLAddinFieldsRestriction(service, "bb.Id",
                    restForm.getAddinFieldsRestriction(), false));
    if (restForm.getApproved() != 0) {
        whereText = whereText.concat(DatabaseUtils.formatEJBQLObjectRestriction("bb.Approved",
                BooleanUtils.toBoolean(restForm.getApproved(), 1, 2), "approved", paramsName, paramsValue,
                false));
    }
    return String.format(INIT_QUERY_TEXT, fieldsList, fromList, whereText);
}

From source file:com.haulmont.cuba.gui.components.filter.condition.AbstractCondition.java

protected void resolveParam(Element element) {
    Scripting scripting = AppBeans.get(Scripting.NAME);
    String aclass = element.attributeValue("class");
    if (!isBlank(aclass)) {
        javaClass = scripting.loadClass(aclass);
    }//from w  ww  . j a  va 2s . c om

    String operatorName = element.attributeValue("operatorType", null);
    if (operatorName != null) {
        operator = Op.valueOf(operatorName);
    }

    List<Element> paramElements = Dom4j.elements(element, "param");
    if (!paramElements.isEmpty()) {
        Element paramElem = paramElements.iterator().next();

        if (BooleanUtils.toBoolean(paramElem.attributeValue("hidden", "false"), "true", "false")) {
            paramElem = paramElements.iterator().next();
        }
        paramName = paramElem.attributeValue("name");

        if (!isBlank(paramElem.attributeValue("javaClass"))) {
            paramClass = scripting.loadClass(paramElem.attributeValue("javaClass"));
        }

        ConditionParamBuilder paramBuilder = AppBeans.get(ConditionParamBuilder.class);
        if (Strings.isNullOrEmpty(paramName)) {
            paramName = paramBuilder.createParamName(this);
        }

        param = paramBuilder.createParam(this);
        param.setDateInterval(
                BooleanUtils.toBoolean(paramElem.attributeValue("isDateInterval", "false"), "true", "false"));
        param.parseValue(paramElem.getText());
        param.setDefaultValue(param.getValue());
    }

    if ("EMPTY".equals(operatorName)) {
        //for backward compatibility with old filters that still use EMPTY operator
        operatorName = "NOT_EMPTY";
        if (BooleanUtils.isTrue((Boolean) param.getValue()))
            param.setValue(false);
        param.setDefaultValue(false);
        operator = Op.valueOf(operatorName);
    }
}

From source file:com.mg.merp.finance.support.ui.FinOperBr.java

@Override
protected String createQueryText() {
    Set<TableEJBQLFieldDef> fieldDefs = ((DefaultMaintenanceEJBQLTableModel) table.getModel())
            .getFieldDefsSet();/*w w w  .  j av a2s .c  o m*/
    String fieldsList = DatabaseUtils.generateEJBQLSelectClause(fieldDefs);
    String fromList = DatabaseUtils.generateEJBQLFromClause(fieldDefs);
    paramsName.clear();
    paramsValue.clear();
    FinOperRest restForm = (FinOperRest) getRestrictionForm();
    StringBuilder whereText = new StringBuilder(" where ").append(DatabaseUtils.formatEJBQLHierarchyRestriction( //$NON-NLS-1$
            ((HierarchyRestrictionSupport) restForm).isUseHierarchy(), "fo.Folder", 0, "folder", folderEntity, //$NON-NLS-1$//$NON-NLS-2$
            paramsName, paramsValue, true)).append(DatabaseUtils.formatEJBQLObjectRangeRestriction("fo.KeepDate", restForm.getDateFrom(), //$NON-NLS-1$
                    restForm.getDateTill(), "dateFrom", "dateTo", paramsName, paramsValue, false)) //$NON-NLS-1$//$NON-NLS-2$
            .append(DatabaseUtils.formatEJBQLStringRestriction("fo.BaseDocNumber", restForm.getBaseDocNumber(), //$NON-NLS-1$
                    "baseDocNumber", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("fo.BaseDocType", restForm.getBaseDocType(), //$NON-NLS-1$
                    "baseDocType", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("fo.BaseDocDate", restForm.getBaseDocDate(), //$NON-NLS-1$
                    "baseDocDate", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLStringRestriction("fo.ConfirmDocNumber", restForm.getDocNumber(), //$NON-NLS-1$
                    "docNumber", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("fo.ConfirmDocType", restForm.getDocType(), //$NON-NLS-1$
                    "docType", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("fo.ConfirmDocDate", restForm.getDocDate(), //$NON-NLS-1$
                    "docDate", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLStringRestriction("fo.ContractNumber", restForm.getContractNumber(), //$NON-NLS-1$
                    "contractNumber", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("fo.ContractType", restForm.getContractType(), //$NON-NLS-1$
                    "contractType", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("fo.ContractDate", restForm.getContractDate(), //$NON-NLS-1$
                    "contractDate", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("fo.Currency", restForm.getCurCode(), "curCode", //$NON-NLS-1$//$NON-NLS-2$
                    paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRangeRestriction("fo.SumCur", restForm.getFromSumCur(), //$NON-NLS-1$
                    restForm.getToSumCur(), "fromSumCur", "toSumCur", paramsName, paramsValue, false)) //$NON-NLS-1$//$NON-NLS-2$
            .append(DatabaseUtils.formatEJBQLObjectRangeRestriction("fo.SumNat", restForm.getFromSumNat(), //$NON-NLS-1$
                    restForm.getToSumNat(), "fromSumNat", "toSumNat", paramsName, paramsValue, false)) //$NON-NLS-1$//$NON-NLS-2$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("fo.From", restForm.getFromCode(), "fromCode", //$NON-NLS-1$//$NON-NLS-2$
                    paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRestriction("fo.To", restForm.getToCode(), "toCode", //$NON-NLS-1$//$NON-NLS-2$
                    paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRestriction("fo.Responsible", restForm.getResponsibleCode(), //$NON-NLS-1$
                    "responsibleCode", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("fs.SrcAcc", restForm.getSrcAcc(), "srcAcc", //$NON-NLS-1$//$NON-NLS-2$
                    paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRestriction("fs.SrcAnl1", restForm.getAnlLevel1SrcId(), //$NON-NLS-1$
                    "anlLevel1SrcId", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("fs.SrcAnl2", restForm.getAnlLevel2SrcId(), //$NON-NLS-1$
                    "anlLevel2SrcId", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("fs.SrcAnl3", restForm.getAnlLevel3SrcId(), //$NON-NLS-1$
                    "anlLevel3SrcId", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("fs.SrcAnl4", restForm.getAnlLevel4SrcId(), //$NON-NLS-1$
                    "anlLevel4SrcId", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("fs.SrcAnl5", restForm.getAnlLevel5SrcId(), //$NON-NLS-1$
                    "anlLevel5SrcId", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("fs.DstAcc", restForm.getDstAcc(), "dstAcc", //$NON-NLS-1$//$NON-NLS-2$
                    paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRestriction("fs.DstAnl1", restForm.getAnlLevel1DstId(), //$NON-NLS-1$
                    "anlLevel1DstId", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("fs.DstAnl2", restForm.getAnlLevel2DstId(), //$NON-NLS-1$
                    "anlLevel2DstId", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("fs.DstAnl3", restForm.getAnlLevel3DstId(), //$NON-NLS-1$
                    "anlLevel3DstId", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("fs.DstAnl4", restForm.getAnlLevel4DstId(), //$NON-NLS-1$
                    "anlLevel4DstId", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("fs.DstAnl5", restForm.getAnlLevel5DstId(), //$NON-NLS-1$
                    "anlLevel5DstId", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLAddinFieldsRestriction(service, "fo.Id", //$NON-NLS-1$
                    restForm.getAddinFieldsRestriction(), false));
    if (restForm.getKind() != 0) {
        whereText = whereText.append(DatabaseUtils.formatEJBQLObjectRestriction("fo.Planned", //$NON-NLS-1$
                BooleanUtils.toBoolean(restForm.getKind(), 2, 1), "kind", paramsName, paramsValue, false)); //$NON-NLS-1$
    }
    if (restForm.getSrcAcc() != null || restForm.getDstAcc() != null || restForm.getFeatAcc() != null) {
        fromList = fromList.concat(", Specification fs "); //$NON-NLS-1$
        whereText = whereText.append(" and fs.FinOper = fo.Id"); //$NON-NLS-1$

    }
    if (restForm.getFeatAcc() != null) {
        whereText = whereText.append(" and fs.Parent is not null "). //$NON-NLS-1$
                append(DatabaseUtils.formatEJBQLObjectRestriction("fs.SrcAcc", restForm.getFeatAcc(), "featAcc", //$NON-NLS-1$//$NON-NLS-2$
                        paramsName, paramsValue, false))
                .append(DatabaseUtils.formatEJBQLObjectRestriction("fs.SrcAnl1", restForm.getAnlLevel1FeatId(), //$NON-NLS-1$
                        "anlLevel1FeatId", paramsName, paramsValue, false)) //$NON-NLS-1$
                .append(DatabaseUtils.formatEJBQLObjectRestriction("fs.SrcAnl2", restForm.getAnlLevel2FeatId(), //$NON-NLS-1$
                        "anlLevel2FeatId", paramsName, paramsValue, false)) //$NON-NLS-1$
                .append(DatabaseUtils.formatEJBQLObjectRestriction("fs.SrcAnl3", restForm.getAnlLevel3FeatId(), //$NON-NLS-1$
                        "anlLevel3FeatId", paramsName, paramsValue, false)) //$NON-NLS-1$
                .append(DatabaseUtils.formatEJBQLObjectRestriction("fs.SrcAnl4", restForm.getAnlLevel4FeatId(), //$NON-NLS-1$
                        "anlLevel4FeatId", paramsName, paramsValue, false)) //$NON-NLS-1$
                .append(DatabaseUtils.formatEJBQLObjectRestriction("fs.SrcAnl5", restForm.getAnlLevel5FeatId(), //$NON-NLS-1$
                        "anlLevel5FeatId", paramsName, paramsValue, false)); //$NON-NLS-1$
    }
    return String.format(INIT_QUERY_TEXT, fieldsList, fromList, whereText.toString());
}

From source file:com.mg.merp.mfreference.support.ui.BomBr.java

@Override
protected String createQueryText() {
    Set<TableEJBQLFieldDef> fieldDefs = ((DefaultMaintenanceEJBQLTableModel) table.getModel())
            .getFieldDefsSet();/*from   ww w . ja  va  2s .c o m*/
    String fieldsList = DatabaseUtils.generateEJBQLSelectClause(fieldDefs);
    String fromList = DatabaseUtils.generateEJBQLFromClause(fieldDefs);
    paramsName.clear();
    paramsValue.clear();
    BomRest restForm = (BomRest) getRestrictionForm();
    StringBuilder whereText = new StringBuilder(" where ")
            .append(DatabaseUtils.formatEJBQLHierarchyRestriction(
                    ((HierarchyRestrictionSupport) restForm).isUseHierarchy(), "b.Folder", 0, "folder",
                    folderEntity, paramsName, paramsValue, true))
            .append(DatabaseUtils.formatEJBQLObjectRestriction("b.BomType", restForm.getBomType(), "bomType",
                    paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRestriction("b.BomStatus", restForm.getBomStatus(),
                    "bomStatus", paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRangeRestriction("b.RevisionDateTime",
                    restForm.getRevisionDateFrom(), restForm.getRevisionDateTill(), "revisionDateFrom",
                    "revisionDateTill", paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRestriction("b.DefDstMol", restForm.getDstMol(), "dstMol",
                    paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRestriction("b.Catalog", restForm.getCatalogCode(),
                    "catalogCode", paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRestriction("b.DefSrcMol", restForm.getSrcMol(), "srcMol",
                    paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRestriction("b.DefSrcStock", restForm.getSrcStock(),
                    "srcStock", paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRestriction("b.DefDstStock", restForm.getDstStock(),
                    "dstStock", paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRestriction("b.SchedDirection", restForm.getSchedDirection(),
                    "schedDirection", paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRestriction("b.Cell", restForm.getCellCode(), "cellCode",
                    paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRestriction("br.WorkCenter", restForm.getWcCode(), "wcCode",
                    paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRestriction("bmat.Catalog", restForm.getMaterialCode(),
                    "materialCode", paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRestriction("bmat.ResourceGroup",
                    restForm.getResourceCodeMaterail(), "resourceCodeMaterail", paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRestriction("bmac.ResourceGroup",
                    restForm.getResourceCodeMachine(), "resourceCodeMachine", paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRestriction("bl.ResourceGroup",
                    restForm.getResourceCodeLabor(), "resourceCodeLabor", paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRestriction("bl.LaborClass", restForm.getLaborClass(),
                    "laborClass", paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLAddinFieldsRestriction(service, "b.Id",
                    restForm.getAddinFieldsRestriction(), false));

    if (restForm.getApproverFlag() != 0) {
        whereText = whereText.append(DatabaseUtils.formatEJBQLObjectRestriction("b.ApprovedFlag",
                BooleanUtils.toBoolean(restForm.getApproverFlag(), 2, 1), "approvedFlag", paramsName,
                paramsValue, false));
    }
    if (whereText.toString().contains("br.") || whereText.toString().contains("bmat.")
            || whereText.toString().contains("bmac.") || whereText.toString().contains("bl.")) {
        whereText = whereText.append(" and br.Bom = b.Id ");
        fromList = (", BomRoute br ").concat(fromList);
    }
    if (whereText.toString().contains("bmat.")) {
        whereText = whereText.append(" and bmat.BomRoute = br.Id ");
        fromList = (", BomMaterial bmat ").concat(fromList);
    }
    if (whereText.toString().contains("bmac.")) {
        whereText = whereText.append(" and bmac.BomRoute = br.Id ");
        fromList = (", BomMachine bmac ").concat(fromList);
    }
    if (whereText.toString().contains("bl.")) {
        whereText = whereText.append(" and bl.BomRoute = br.Id ");
        fromList = (", BomLabor bl ").concat(fromList);
    }
    return String.format(INIT_QUERY_TEXT, fieldsList, fromList, whereText.toString());
}

From source file:com.mg.merp.paymentalloc.support.ui.PaymentBr.java

@Override
protected String createQueryText() {
    StringBuilder whereText = new StringBuilder();
    Set<TableEJBQLFieldDef> fieldDefs = ((DefaultMaintenanceEJBQLTableModel) table.getModel())
            .getFieldDefsSet();//from   w w  w  .ja  v a2 s.co m
    String fieldsList = DatabaseUtils.generateEJBQLSelectClause(fieldDefs);
    String fromList = DatabaseUtils.generateEJBQLFromClause(fieldDefs);

    paramsName.clear();
    paramsValue.clear();
    PaymentRest restForm = (PaymentRest) this.getRestrictionForm();

    whereText.append(DatabaseUtils.formatEJBQLHierarchyRestriction(
            ((HierarchyRestrictionSupport) restForm).isUseHierarchy(), "p.Folder", 0, "folder", folderEntity, //$NON-NLS-1$//$NON-NLS-2$
            paramsName, paramsValue, false)).append(DatabaseUtils.formatEJBQLObjectRangeRestriction("p.PDate", restForm.getDate1(), //$NON-NLS-1$
                    restForm.getDate2(), "date1", "date2", paramsName, paramsValue, false)) //$NON-NLS-1$//$NON-NLS-2$
            .append(DatabaseUtils.formatEJBQLObjectRangeRestriction("p.SumNat", restForm.getSum1(), //$NON-NLS-1$
                    restForm.getSum2(), "sum1", "sum2", paramsName, paramsValue, false)) //$NON-NLS-1$//$NON-NLS-2$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("p.ContractorFrom", restForm.getFromCode(), //$NON-NLS-1$
                    "fromCode", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("p.ContractorTo", restForm.getToCode(), "toCode", //$NON-NLS-1$//$NON-NLS-2$
                    paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLStringRestriction("p.Description", restForm.getDescription(), //$NON-NLS-1$
                    "description", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLStringRestriction("p.Name", restForm.getName(), "name", paramsName, //$NON-NLS-1$//$NON-NLS-2$
                    paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRestriction("p.DocType", restForm.getDocType(), "docType", //$NON-NLS-1$//$NON-NLS-2$
                    paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLStringRestriction("p.DocNumber", restForm.getDocNumber(), //$NON-NLS-1$
                    "docNumber", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("p.DocDate", restForm.getDocDate(), "docDate", //$NON-NLS-1$//$NON-NLS-2$
                    paramsName, paramsValue, false))
            .append(DatabaseUtils.formatEJBQLObjectRestriction("p.ContractType", restForm.getContractType(), //$NON-NLS-1$
                    "contractType", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLStringRestriction("p.ContractNumber", restForm.getContractNumber(), //$NON-NLS-1$
                    "contractNumber", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("p.ContractDate", restForm.getContractDate(), //$NON-NLS-1$
                    "contractDate", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("p.BaseDocType", restForm.getBaseDocType(), //$NON-NLS-1$
                    "baseDocType", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLStringRestriction("p.BaseDocNumber", restForm.getBaseDocNumber(), //$NON-NLS-1$
                    "baseDocNumber", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("p.BaseDocDate", restForm.getBaseDocDate(), //$NON-NLS-1$
                    "baseDocDate", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("d.DocHead.DocType", restForm.getLinkedType(), //$NON-NLS-1$
                    "linkedType", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLStringRestriction("d.DocHead.DocNumber", restForm.getLinkedNumber(), //$NON-NLS-1$
                    "linkedNumber", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLObjectRestriction("d.DocHead.DocDate", restForm.getLinkedDate(), //$NON-NLS-1$
                    "linkedDate", paramsName, paramsValue, false)) //$NON-NLS-1$
            .append(DatabaseUtils.formatEJBQLAddinFieldsRestriction(service, "p.Id", //$NON-NLS-1$
                    restForm.getAddinFieldsRestriction(), false));

    if (restForm.getLinkedDate() != null || restForm.getLinkedType() != null
            || !StringUtils.stringNullOrEmpty(restForm.getLinkedNumber())) { //$NON-NLS-1$
        fromList = (", TransactHead as d ").concat(fromList); //$NON-NLS-1$
        whereText.append(" and d.Payment = p.Id "); //$NON-NLS-1$
    }
    if (restForm.getKind() != 0)
        whereText.append(DatabaseUtils.formatEJBQLObjectRestriction("p.Planned", //$NON-NLS-1$
                BooleanUtils.toBoolean(restForm.getKind(), 1, 2), "kind", paramsName, paramsValue, false)); //$NON-NLS-1$
    if (restForm.getAllocKind() != 0) {
        if (!fromList.contains("TransactHead")) { //$NON-NLS-1$
            fromList = (", TransactHead as d ").concat(fromList); //$NON-NLS-1$
            whereText.append(" and d.Payment = p.Id "); //$NON-NLS-1$
        }
        if (restForm.getAllocKind() == 1)
            whereText.append(" and d.AllocSumNat = d.TotalSumNat "); //$NON-NLS-1$
        if (restForm.getAllocKind() == 2)
            whereText.append(" and d.AllocSumNat <> d.TotalSumNat "); //$NON-NLS-1$
    }
    return String.format(INIT_QUERY_TEXT, fieldsList, fromList, whereText);
}