Package org.ofbiz.entity.condition

Examples of org.ofbiz.entity.condition.EntityExpr


    int month = cal.get(Calendar.MONTH) + 1;
    int year = cal.get(Calendar.YEAR);
    int quarterNumbers[] = CalendarUtil.getQuarterMonthNumbers(month, fyStartMonth);

    ArrayList list = new ArrayList();
    list.add(new EntityExpr("ownerId", EntityOperator.EQUALS, userInfo.getPartyId()));
    list.add(new EntityExpr("dealStatusId", EntityOperator.EQUALS, "10"));
    list.add(new EntityExpr("actualCloseDate", EntityOperator.LESS_THAN_EQUAL_TO, new java.sql.Date( CalendarUtil.getMaximumQuarterDate(cal.get(Calendar.MONTH) + 1, cal.get(Calendar.YEAR), fyStartMonth).getTime())));
    list.add(new EntityExpr("actualCloseDate", EntityOperator.GREATER_THAN_EQUAL_TO, new java.sql.Date( CalendarUtil.getMinimumQuarterDate(cal.get(Calendar.MONTH) + 1, cal.get(Calendar.YEAR), fyStartMonth).getTime())));

    ArrayList order = new ArrayList();
    order.add("actualCloseDate");

    java.util.List dealList = delegator.findByAnd("Deal", list, order);
    GenericValue dealValues[] = (GenericValue[])dealList.toArray(new GenericValue[0]);
    GenericValue dealValue = null;

    String months[] = CalendarUtil.getQuarterMonthNames(cal.get(Calendar.MONTH) + 1, fyStartMonth);
    for(int iz=0;iz<months.length;iz++){
      xAxisLabels.add((String)months[iz]);
    }

    xAxisTitle = "Month";
    yAxisTitle = "Sales";

    legendLabels.add("Pipeline for Quarter");

    for(int iz=0;iz<dealValues.length;iz++) {
      dealValue = dealValues[iz];
      Calendar calendar = Calendar.getInstance();
      calendar.setTime(dealValue.getDate("actualCloseDate"));

      if((calendar.get(Calendar.MONTH)+1)==quarterNumbers[0] && calendar.get(Calendar.YEAR)==year){
        data[0] = data[0] + dealValue.getDouble("amount").doubleValue();
      }
      if((calendar.get(Calendar.MONTH)+1)==quarterNumbers[1] && calendar.get(Calendar.YEAR)==year){
        data[1] = data[1] + dealValue.getDouble("amount").doubleValue();
      }
      if((calendar.get(Calendar.MONTH)+1)==quarterNumbers[2] && calendar.get(Calendar.YEAR)==year){
        data[2] = data[2] + dealValue.getDouble("amount").doubleValue();
      }
    }

      try {
      BarChart barChart = new BarChart(
        new SingleDataSet(
        data,
        (String[])legendLabels.toArray(new String[0]),
        (String[])xAxisLabels.toArray(new String[0]),
        paints,
        xAxisTitle,
        yAxisTitle ),
      false, properties, axisProperties, width, height );

      response.reset();
      response.setContentType("image/jpeg");
           
      barChart.exportJPG( response.getOutputStream(), 1.0f);
      response.getOutputStream().flush();
      } catch( Throwable throwable ) { throwable.printStackTrace();
      }
    }

    if(request.getParameter("report").equals("leadsForQuarter")){
    double data[] = new double[3];
    Calendar cal = Calendar.getInstance();

    int month = cal.get(Calendar.MONTH) + 1;
    int year = cal.get(Calendar.YEAR);
    int quarterNumbers[] = CalendarUtil.getQuarterMonthNumbers(month, fyStartMonth);

    ArrayList list = new ArrayList();
    list.add(new EntityExpr("leadOwnerId", EntityOperator.EQUALS, userInfo.getPartyId()));
    list.add(new EntityExpr("statusId", EntityOperator.EQUALS, "50"));
    list.add(new EntityExpr("convertedDate", EntityOperator.LESS_THAN_EQUAL_TO, new java.sql.Date( CalendarUtil.getMaximumQuarterDate(cal.get(Calendar.MONTH) + 1, cal.get(Calendar.YEAR), fyStartMonth).getTime())));
    list.add(new EntityExpr("convertedDate", EntityOperator.GREATER_THAN_EQUAL_TO, new java.sql.Date( CalendarUtil.getMinimumQuarterDate(cal.get(Calendar.MONTH) + 1, cal.get(Calendar.YEAR), fyStartMonth).getTime())));

    ArrayList order = new ArrayList();
    order.add("convertedDate");

    java.util.List dealList = delegator.findByAnd("Lead", list, order);
    GenericValue leadValues[] = (GenericValue[])dealList.toArray(new GenericValue[0]);
    GenericValue leadValue = null;

    String months[] = CalendarUtil.getQuarterMonthNames(cal.get(Calendar.MONTH) + 1, fyStartMonth);
    for(int iz=0;iz<months.length;iz++){
      xAxisLabels.add((String)months[iz]);
    }
    xAxisTitle = "Month";
    yAxisTitle = "Leads";

    legendLabels.add("Leads for Quarter");

    for(int iz=0;iz<leadValues.length;iz++) {
      leadValue = leadValues[iz];
      Calendar calendar = Calendar.getInstance();
      calendar.setTime(leadValue.getTimestamp("convertedDate"));

      if((calendar.get(Calendar.MONTH)+1)==quarterNumbers[0] && calendar.get(Calendar.YEAR)==year){
        data[0] = data[0] + 1;
      }
      if((calendar.get(Calendar.MONTH)+1)==quarterNumbers[1] && calendar.get(Calendar.YEAR)==year){
        data[1] = data[1] + 1;
      }
      if((calendar.get(Calendar.MONTH)+1)==quarterNumbers[2] && calendar.get(Calendar.YEAR)==year){
        data[2] = data[2] + 1;
      }
    }

    axisProperties.setYAxisUseDollarSigns(false);
    axisProperties.setYAxisRoundValuesToNearest(0);
//      axisProperties.setXAxisVerticalScaleFlag(true);

    try {
      BarChart barChart = new BarChart(
        new SingleDataSet(
        data,
        (String[])legendLabels.toArray(new String[0]),
        (String[])xAxisLabels.toArray(new String[0]),
        paints,
        xAxisTitle,
        yAxisTitle ),
      false, properties, axisProperties, width, height );

      response.reset();
      response.setContentType("image/jpeg");
      barChart.exportJPG( response.getOutputStream(), 1.0f);
      response.getOutputStream().flush();
      } catch( Throwable throwable ) { throwable.printStackTrace();
      }
    }

    if(request.getParameter("report").equals("forecastedForQuarter")){
    double data[] = new double[3];
    Calendar cal = Calendar.getInstance();

    int month = cal.get(Calendar.MONTH) + 1;
    int year = cal.get(Calendar.YEAR);
    int quarterNumbers[] = CalendarUtil.getQuarterMonthNumbers(month, fyStartMonth);

    ArrayList list = new ArrayList();
    list.add(new EntityExpr("ownerId", EntityOperator.EQUALS, userInfo.getPartyId()));
    list.add(new EntityExpr("projectedCloseDate", EntityOperator.LESS_THAN_EQUAL_TO, new java.sql.Date( CalendarUtil.getMaximumQuarterDate(cal.get(Calendar.MONTH) + 1, cal.get(Calendar.YEAR), fyStartMonth).getTime())));
    list.add(new EntityExpr("projectedCloseDate", EntityOperator.GREATER_THAN_EQUAL_TO, new java.sql.Date( CalendarUtil.getMinimumQuarterDate(cal.get(Calendar.MONTH) + 1, cal.get(Calendar.YEAR), fyStartMonth).getTime())));

    ArrayList order = new ArrayList();
    order.add("projectedCloseDate");

    java.util.List dealList = delegator.findByAnd("Deal", list, order);
View Full Code Here


            return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                    "partyservices.required_parameter_email_cannot_be_empty", locale));
        }

        try {
            EntityExpr ee = EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"), EntityOperator.EQUALS, EntityFunction.UPPER(email.toUpperCase()));
            List<GenericValue> c = EntityUtil.filterByDate(delegator.findList("PartyAndContactMech", ee, null, UtilMisc.toList("infoString"), null, false), true);

            if (Debug.verboseOn()) Debug.logVerbose("List: " + c, module);
            if (Debug.infoOn()) Debug.logInfo("PartyFromEmail number found: " + c.size(), module);
            if (c != null) {
View Full Code Here

            return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                    "partyservices.required_parameter_email_cannot_be_empty", locale));
        }

        try {
            EntityExpr ee = EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"), EntityOperator.LIKE, EntityFunction.UPPER(("%" + email.toUpperCase()) + "%"));
            List<GenericValue> c = EntityUtil.filterByDate(delegator.findList("PartyAndContactMech", ee, null, UtilMisc.toList("infoString"), null, false), true);

            if (Debug.verboseOn()) Debug.logVerbose("List: " + c, module);
            if (Debug.infoOn()) Debug.logInfo("PartyFromEmail number found: " + c.size(), module);
            if (c != null) {
View Full Code Here

        if (userLoginId.length() == 0)
            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                    "PartyCannotGetUserLoginFromParty", locale));

        try {
            EntityExpr ee = EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("userLoginId"), EntityOperator.LIKE, EntityFunction.UPPER("%" + userLoginId.toUpperCase() + "%"));
            Collection<GenericValue> ulc = delegator.findList("PartyAndUserLogin", ee, null, UtilMisc.toList("userLoginId"), null, false);

            if (Debug.verboseOn()) Debug.logVerbose("Collection: " + ulc, module);
            if (Debug.infoOn()) Debug.logInfo("PartyFromUserLogin number found: " + ulc.size(), module);
            if (ulc != null) {
View Full Code Here

            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                    "PartyCannotGetPartyFromPartyGroup", locale));
        }

        try {
            EntityExpr ee = EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("groupName"), EntityOperator.LIKE, EntityFunction.UPPER("%" + groupName.toUpperCase() + "%"));
            Collection<GenericValue> pc = delegator.findList("PartyGroup", ee, null, UtilMisc.toList("groupName", "partyId"), null, false);

            if (Debug.infoOn()) Debug.logInfo("PartyFromGroup number found: " + pc.size(), module);
            if (pc != null) {
                for (GenericValue group: pc) {
View Full Code Here

    public List getDropDownValues(GenericDelegator delegator,
        UIDisplayObject uiDisplayObject, ArrayList orderDef,
        Vector entityDetailsVector, UIFieldInfo fieldInfo, UserInfo userInfo) {

        try {
          EntityConditionList condition = new EntityConditionList( UtilMisc.toList(new EntityExpr("codeId", EntityOperator.NOT_EQUAL, "base"),
                                         new EntityExpr("codeTypeId", EntityOperator.EQUALS, "ACCOUNT_TYPE")),EntityOperator.AND);
          return delegator.findByCondition("Code", condition, null, UtilMisc.toList("codeValue"));
        } catch (GenericEntityException e) {
            Debug.logError(
                "[UIAccountTypeDropDown.getDropDownValues] Error retrieving the dropdown values: ", module);
            Debug.logError(e.getLocalizedMessage(), module);
View Full Code Here

    dve.addViewLink("LeadQueue", "LeadQueueUser", Boolean.FALSE, UtilMisc.toList(new ModelKeyMap("leadQueueId", "leadQueueId")));
    dve.addAlias("LeadQueueUser", "contactId", null, null, null, null, null);
    dve.addAlias("LeadQueueUser", "activeFlag", null, null, null, null, null);
    
    EntityCondition condition = new EntityConditionList(UtilMisc.toList(
        new EntityExpr("contactId", EntityOperator.EQUALS, userInfo.getPartyId()),
        new EntityExpr("activeFlag", EntityOperator.EQUALS, "Y")),
        EntityOperator.AND);

        List leadQueueList = new ArrayList();

        try {
View Full Code Here

        String contentAssocViewName = "contentAssocView";
        if (linkDir != null && linkDir.equalsIgnoreCase("TO")) {
            contentIdName = contentIdName.concat("To");
            contentAssocViewName = contentAssocViewName.concat("To");
        }
        EntityExpr expr = EntityCondition.makeCondition(contentIdName, EntityOperator.EQUALS, origContentId);
        exprListAnd.add(expr);

        if (contentTypes.size() > 0) {
            exprListAnd.add(EntityCondition.makeCondition("contentTypeId", EntityOperator.IN, contentTypes));
        }
View Full Code Here

        return assocs;
    }

    public static List<GenericValue> getContentAssocsWithId(Delegator delegator, String contentId, Timestamp fromDate, Timestamp thruDate, String direction, List assocTypes) throws GenericEntityException {
        List exprList = FastList.newInstance();
        EntityExpr joinExpr = null;
        EntityExpr expr = null;
        if (direction != null && direction.equalsIgnoreCase("From")) {
            joinExpr = EntityCondition.makeCondition("contentIdTo", EntityOperator.EQUALS, contentId);
        } else {
            joinExpr = EntityCondition.makeCondition("contentId", EntityOperator.EQUALS, contentId);
        }
        exprList.add(joinExpr);
        if (UtilValidate.isNotEmpty(assocTypes)) {
            List exprListOr = FastList.newInstance();
            Iterator it = assocTypes.iterator();
            while (it.hasNext()) {
                String assocType = (String) it.next();
                expr = EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.EQUALS, assocType);
                exprListOr.add(expr);
            }
            EntityConditionList assocExprList = EntityCondition.makeCondition(exprListOr, EntityOperator.OR);
            exprList.add(assocExprList);
        }
        if (fromDate != null) {
            EntityExpr fromExpr = EntityCondition.makeCondition("fromDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate);
            exprList.add(fromExpr);
        }
        if (thruDate != null) {
            List thruList = FastList.newInstance();
            //thruDate = UtilDateTime.getDayStart(thruDate, daysLater);

            EntityExpr thruExpr = EntityCondition.makeCondition("thruDate", EntityOperator.LESS_THAN, thruDate);
            thruList.add(thruExpr);
            EntityExpr thruExpr2 = EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null);
            thruList.add(thruExpr2);
            EntityConditionList thruExprList = EntityCondition.makeCondition(thruList, EntityOperator.OR);
            exprList.add(thruExprList);
        } else if (fromDate != null) {
            List thruList = FastList.newInstance();

            EntityExpr thruExpr = EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN, fromDate);
            thruList.add(thruExpr);
            EntityExpr thruExpr2 = EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null);
            thruList.add(thruExpr2);
            EntityConditionList thruExprList = EntityCondition.makeCondition(thruList, EntityOperator.OR);
            exprList.add(thruExprList);
        } else {
            EntityExpr thruExpr2 = EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null);
            exprList.add(thruExpr2);
        }
        EntityConditionList assocExprList = EntityCondition.makeCondition(exprList, EntityOperator.AND);
        //if (Debug.infoOn()) Debug.logInfo(" assocExprList:" + assocExprList , "");
        List relatedAssocs = delegator.findList("ContentAssoc", assocExprList, null, UtilMisc.toList("-fromDate"), null, false);
View Full Code Here

    public static List getContentAssocViewList(Delegator delegator, String contentIdTo, String contentId, String contentAssocTypeId, String statusId, String privilegeEnumId) throws GenericEntityException {

        List exprListAnd = FastList.newInstance();

        if (UtilValidate.isNotEmpty(contentIdTo)) {
            EntityExpr expr = EntityCondition.makeCondition("caContentIdTo", EntityOperator.EQUALS, contentIdTo);
            exprListAnd.add(expr);
        }

        if (UtilValidate.isNotEmpty(contentId)) {
            EntityExpr expr = EntityCondition.makeCondition("contentId", EntityOperator.EQUALS, contentId);
            exprListAnd.add(expr);
        }

        if (UtilValidate.isNotEmpty(contentAssocTypeId)) {
            EntityExpr expr = EntityCondition.makeCondition("caContentAssocTypeId", EntityOperator.EQUALS, contentAssocTypeId);
            exprListAnd.add(expr);
        }

        if (UtilValidate.isNotEmpty(statusId)) {
            EntityExpr expr = EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, statusId);
            exprListAnd.add(expr);
        }

        if (UtilValidate.isNotEmpty(privilegeEnumId)) {
            EntityExpr expr = EntityCondition.makeCondition("privilegeEnumId", EntityOperator.EQUALS, privilegeEnumId);
            exprListAnd.add(expr);
        }

        EntityConditionList contentCondList = EntityCondition.makeCondition(exprListAnd, EntityOperator.AND);
        List contentList = delegator.findList("ContentAssocDataResourceViewFrom", contentCondList, null, null, null, false);
View Full Code Here

TOP

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

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.