Package org.ofbiz.entity.condition

Examples of org.ofbiz.entity.condition.EntityComparisonOperator


                String entityAlias = "GI" + productSearchContext.index;
                String prefix = "gi" + productSearchContext.index;
                productSearchContext.index++;


                EntityComparisonOperator operator = EntityOperator.EQUALS;

                if (UtilValidate.isNotEmpty(include) && include == Boolean.FALSE) {
                    operator = EntityOperator.NOT_EQUAL;
                }
View Full Code Here


                                                .getAttribute("operator"));
                                String constraintValue = UtilFormatOut
                                        .checkNull(entityConstraintElem
                                                .getAttribute("value"));

                                EntityComparisonOperator operator = new EntityComparisonOperator(
                                        EntityOperator.ID_EQUALS, "=");
                                if ("between".equals(constraintValue)) {
                                    operator = new EntityComparisonOperator(
                                            EntityOperator.ID_BETWEEN,
                                            "BETWEEN");
                                } else if ("greater-equals"
                                        .equals(constraintValue)) {
                                    operator = new EntityComparisonOperator(
                                            EntityOperator.ID_GREATER_THAN_EQUAL_TO,
                                            ">=");
                                } else if ("greater".equals(constraintValue)) {
                                    operator = new EntityComparisonOperator(
                                            EntityOperator.ID_GREATER_THAN, ">");
                                } else if ("in".equals(constraintValue)) {
                                    operator = new EntityComparisonOperator(
                                            EntityOperator.ID_IN, "IN");
                                } else if ("less-equals"
                                        .equals(constraintValue)) {
                                    operator = new EntityComparisonOperator(
                                            EntityOperator.ID_LESS_THAN_EQUAL_TO,
                                            "<=");
                                } else if ("less".equals(constraintValue)) {
                                    operator = new EntityComparisonOperator(
                                            EntityOperator.ID_LESS_THAN, "<");
                                } else if ("like".equals(constraintValue)) {
                                    operator = new EntityComparisonOperator(
                                            EntityOperator.ID_LIKE, "LIKE");
                                } else if ("not-equals".equals(constraintValue)) {
                                    operator = new EntityComparisonOperator(
                                            EntityOperator.ID_NOT_EQUAL, "<>");
                                }

                                exprs.add(EntityCondition.makeCondition(
                                        constraintName, operator,
View Full Code Here

        String searchAttribValue = "";
        String searchEntityName = "";
        String searchAttribName = "";
        String queryName = "";
        String listName = "";
        EntityComparisonOperator entityOperator = null;
        List relatedSearchClauses = new LinkedList();
        List selectFields = new ArrayList();
       
        // Note that we only care about primary entity fields in the select at the moment.
        // TODO:  change the queries so that all related data is retrieved as part of the main retrieve
        //        which it is, but the original code was written before dynamicViewEntities were added
    int selectFieldListSize = uiWebScreenSection.getUiFieldList().size();
    for (int fieldNbr = 0; fieldNbr < selectFieldListSize; fieldNbr++) { 
      UIFieldInfo fieldInfo = uiWebScreenSection.getUiField(fieldNbr);
      String fieldName = fieldInfo.getUiAttribute().getAttributeName();
      String entityName = fieldInfo.getUiAttribute().getUiEntity().getEntityName();
      if ( entityName.equals(primaryEntityName) )
        selectFields.add(fieldName);

/*      if ( fieldInfo.getIsVisible() )
      {
        String fieldName = fieldInfo.getUiAttribute().getAttributeName();
        String entityName = fieldInfo.getUiAttribute().getUiEntity().getEntityName();
        String aliasName = fieldName;
        if ( ! entityName.equals(primaryEntityName))
          aliasName = entityName + "." + fieldName;
        selectFields.add(aliasName);
      }
*/
    }
    queryInfo.setSelectFields(selectFields);

        if (request.getParameter("queryName") != null) {
            queryName = request.getParameter("queryName");
        }

        if (request.getParameter("listName") != null) {
            listName = request.getParameter("listName");
            if ( queryName.length() < 1)
                queryName = listName;
        }

       
        //    HashMap querySaveMap = new HashMap();
        UIQuery uiQuery = null;


    // Specify how associated entities will be retrieved.
    Iterator uiScreenSectionEntityI = uiWebScreenSection.getUiScreenSectionEntityList()
                              .iterator();
    uiScreenSectionEntityI.next(); // Pass up the primary entity.

    while (uiScreenSectionEntityI.hasNext()) {
      UIScreenSectionEntity uiScreenSectionEntity = (UIScreenSectionEntity) uiScreenSectionEntityI.next();
     
      relatedSearchClauses.add(uiScreenSectionEntity);
    }

    uiScreenSectionEntityI = null; // Reset the iterator.




        switch (retrieveMethod) {
        case GenericEventProcessor.RETRIEVE_METHOD_ALL:

            // Find all entities of this type.
            // Don't need to populate the fields map.
            break;

        case GenericEventProcessor.RETRIEVE_METHOD_AND:

            // Find the main entity(ies) by building a WHERE clause using "=" and AND.
            throw new GenericEntityException(
                "RETRIEVE_METHOD_AND not implemented yet.");

        case GenericEventProcessor.RETRIEVE_METHOD_CLAUSE:

            if (TIMER) {
                timer.timerString(1,
                    "[GenericWebEventProcessor.processRetrieve] Start RETRIEVE_METHOD_CLAUSE");
            }

      HashMap joinedEntities = new HashMap();
     
      joinedEntities.put(primaryEntityName, "Y");
     
            // Find the main entity(ies) by building a WHERE clause using LIKE and AND, with one or more tables in the FROM clause.
            // First join all secondary screen section entities in the WHERE and FROM clauses in case
            // we are going to use query values from them.
            Iterator relatedClauseI = relatedSearchClauses.iterator();

            while (relatedClauseI.hasNext()) {
                UIScreenSectionEntity uiScreenSectionEntity = (UIScreenSectionEntity) relatedClauseI.next();
                String relationTitle = uiScreenSectionEntity.getRelationTitle();
                String relatedEntityName = uiScreenSectionEntity.getUiEntity().getEntityName();
        boolean isOuterJoin = uiScreenSectionEntity.getIsOuterJoined();
        String relatedAndFields = uiScreenSectionEntity.getRelationByAndFields();

                Debug.logVerbose("Adding relation clauses for " +
                        relationTitle + "/" + relatedEntityName, module);

                eventProcessor.addOneRelationClause(delegator, relationTitle, relatedAndFields,
                    relatedEntityName, primaryEntityName, primaryME, isOuterJoin,
                    queryInfo);
                   
                joinedEntities.put(relatedEntityName, "Y");
            }

            Debug.logVerbose(
                    "queryId at beginning of RETRIEVE_METHOD_CLAUSE section: " +
                    queryId, module);

            if (queryId.equalsIgnoreCase("NONE")) {
                // Don't retrieve any data. The calling link specified to use the last query, but there wasn't one.
                return STATUS_CONTINUE;
            } else if (!queryId.equals("")) {
                // User selected a saved query.  Get it from the data base.
                uiQuery = new UIQuery(queryId, delegator);

                if (!uiQuery.getQueryId().equals("")) {
                    // Query was found.
                    uiQuery.appendEntityClauses(delegator, queryInfo);

                    //            // Store the attribute ID and value in the query save map.
                    //            querySaveMap.put(attributeId, searchAttribValue);
                }

                // add extra clauses from the hidden query parameters in case this is a detail screen
                addUseQueryParameterClauses(uiWebScreenSection, queryInfo,
                    relatedSearchClauses, primaryEntityName, request);
            } else {
                // Brand new query. Process all the parameters coming in through the request object to get the values to search by.
                uiQuery = new UIQuery();

        String queryListMaxRows = request.getParameter("queryListMaxRows");
        // if queryListMaxRows is set, then we are using advanced query mode
        if ( (queryListMaxRows != null ) && ( queryListMaxRows.length() > 0) )
        {
          int maxRows = Integer.valueOf(queryListMaxRows).intValue();
          for ( int i=1; i <= maxRows; i++ )
          {
            String qlFieldInfo = request.getParameter("queryListField" + i);
            if ( ( qlFieldInfo != null ) && ( qlFieldInfo.length() > 0 ) )
            {
              StringTokenizer tokSemi = new StringTokenizer(qlFieldInfo,";");
              String qlFieldName = "";
              String qlAttributeId = "";
              String qlDisplayObjectId = "";
              String qlDisplayTypeId = "";
             
              if (tokSemi.countTokens() == 4) {
                  qlFieldName = tokSemi.nextToken();
                  qlAttributeId = tokSemi.nextToken();
                  qlDisplayTypeId = tokSemi.nextToken();
                  qlDisplayObjectId = tokSemi.nextToken();
              }
              else
              {
                qlFieldName = qlFieldInfo;
              }

              String qlOperator  = request.getParameter("queryListOperator" + i);
              String qlValue     = request.getParameter("queryListValue" + i);
             
              if ( qlOperator.equals("like"))
                qlValue =  "%" + qlValue.replace('*','%') + "%";
              else if ( qlOperator.equals("startsWith"))
              {
                qlValue =  qlValue.replace('*','%') + "%";
                qlOperator = "like";
              }
              else if ( qlOperator.equals("endsWith"))
              {
                qlValue =  "%" + qlValue.replace('*','%');
                qlOperator = "like";
              }

              searchEntityName = UIWebUtility.getEntityFromParamName(qlFieldName);
 
              String hasJoin = (String) joinedEntities.get(searchEntityName);
             
              if ( ( hasJoin == null ) || ( !hasJoin.equals("Y")) )
              {
                eventProcessor.addOneRelationClause(delegator, "", "",searchEntityName, primaryEntityName, primaryME, false, queryInfo);

                joinedEntities.put(searchEntityName, "Y");
              }
             
              if ((searchEntityName == null) ||
                  searchEntityName.equals("")) {
                searchEntityName = primaryEntityName;
              }
 
              searchAttribName = UIWebUtility.getAttribFromParamName(qlFieldName);
              entityOperator = EntityOperator.lookupComparison(qlOperator);
              Object searchValue = qlValue;
             
              // If this is a set operator, convert the String param into a comma separated List
              if ( (entityOperator.equals(EntityOperator.IN)) || (entityOperator.equals(EntityOperator.NOT_IN)) || (entityOperator.equals(EntityOperator.BETWEEN)))
              {
                List valueList = new ArrayList();
                StringTokenizer tokComma = new StringTokenizer(qlValue, ",");

                while (tokComma.hasMoreTokens()) {
View Full Code Here

      Enumeration params = null;
      String searchAttribValue = "";
      String searchEntityName = "";
      String searchAttribName = "";
      String queryName = "";
      EntityComparisonOperator entityOperator = null;
      List relatedSearchClauses = new LinkedList();
      List primaryPkFieldNames = uiScreenSection.getUiScreenSectionEntity(0).getUiEntity().getPrimaryKeyFieldNames();
     
      Map fields = primaryKey.getAllFields();
     
View Full Code Here

        for (int i = 0; i < entityExpressions.size(); i++) {
            entityExpr = (EntityExpr) entityExpressions.get(i);

            Object lhs = (Object) entityExpr.getLhs();
            Object rhs = (Object) entityExpr.getRhs();
      EntityComparisonOperator op = (EntityComparisonOperator) entityExpr.getOperator();

            if (lhs instanceof EntityAttribute &&
                    rhs instanceof EntityAttribute) {
                lhs = (EntityAttribute) lhs;
                rhs = (EntityAttribute) rhs;
               
                String firstEntity = ((EntityAttribute) lhs).getEntity();
                String secondEntity = ((EntityAttribute) rhs).getEntity();
                if ( !firstEntity.equals(secondEntity) )
                {
          if ( !op.equals( EntityOperator.EQUALS ))
            throw new IllegalArgumentException("Join operator must be EQUALS");
           
                  queryInfo.addJoin(firstEntity, secondEntity, Boolean.FALSE, ((EntityAttribute) lhs).getField(),
                        ((EntityAttribute) rhs).getField());
        }
View Full Code Here

    for (int i = 0; i < entityExpressions.size(); i++) {
      entityExpr = (EntityExpr) entityExpressions.get(i);

      Object lhs = entityExpr.getLhs();
      Object rhs = entityExpr.getRhs();
      EntityComparisonOperator op = (EntityComparisonOperator) entityExpr.getOperator();
      if ( !op.equals(EntityOperator.LIKE) && !op.equals(EntityOperator.EQUALS))
        throw new IllegalArgumentException("Join Operator must be LIKE or EQUALS");

      if (lhs instanceof EntityAttribute &&
          rhs instanceof EntityAttribute) {
        lhs = (EntityAttribute) lhs;
        rhs = (EntityAttribute) rhs;
               
        String firstEntity = ((EntityAttribute) lhs).getEntity();
        String secondEntity = ((EntityAttribute) rhs).getEntity();
        if ( !firstEntity.equals(secondEntity) )
        {
          if ( !op.equals( EntityOperator.EQUALS ))
            throw new IllegalArgumentException("Join operator must be EQUALS");
           
          queryInfo.addJoin(firstEntity, secondEntity, Boolean.FALSE, ((EntityAttribute) lhs).getField(),
                  ((EntityAttribute) rhs).getField());
        }
View Full Code Here

     * @param queryValue
     *
     * @return
     */
    public static EntityComparisonOperator getEntityOperator(StringBuffer queryValue) {
        EntityComparisonOperator operator = null;
        String queryValueString = queryValue.toString();
        long queryDateOffset = 0;

        if (queryValueString.indexOf(">=") >= 0) {
            operator = EntityOperator.GREATER_THAN_EQUAL_TO;
View Full Code Here

     *
     * @return
     */
    public static EntityComparisonOperator appendEntityClause(String searchEntityName,
        String searchAttribName, String searchAttribValue, QueryInfo queryInfo) {
        EntityComparisonOperator entityOperator = appendEntityClause(searchEntityName,
                searchAttribName, searchAttribValue, null, queryInfo);

        return entityOperator;
    }
View Full Code Here

            joinedEntities.put(searchEntityName, "Y");
          }

          String displayTypeId = uiQueryValue.getDisplayTypeId();
             
          EntityComparisonOperator entityOperator = uiQueryValue.getEntityOperator();
          String searchValueStr = uiQueryValue.getAttributeValue();
          Object searchValue = searchValueStr;
         
          // If this is a set operator, convert the String param into a comma separated List
          if ( (entityOperator.equals(EntityOperator.IN)) || (entityOperator.equals(EntityOperator.NOT_IN)) || (entityOperator.equals(EntityOperator.BETWEEN)))
          {
            List valueList = new ArrayList();
            StringTokenizer tokComma = new StringTokenizer(searchValueStr, ",");

            while (tokComma.hasMoreTokens()) {
View Full Code Here

     
      String primaryEntityName = primaryEntity.getUiEntity().getEntityName();
      String searchAttribValue = "";
      String searchEntityName = "";
      String searchAttribName = "";
      EntityComparisonOperator entityOperator = null;
      List relatedSearchClauses = new LinkedList();
      List selectFields = new ArrayList();
      List selectFieldLabels = new ArrayList();
      List sortFields = new ArrayList();
     
View Full Code Here

TOP

Related Classes of org.ofbiz.entity.condition.EntityComparisonOperator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.