Search in sources :

Example 1 with HUTraceEventQuery

use of de.metas.handlingunits.trace.HUTraceEventQuery in project metasfresh-webui-api by metasfresh.

the class HUTraceResultExtender method getSql.

@Override
public String getSql(@NonNull final SqlParamsCollector sqlParamsOut, @NonNull final DocumentFilter filter, @NonNull final SqlOptions sqlOpts) {
    if (filter.getParameters() == null || filter.getParameters().isEmpty()) {
        // do whatever the system usually does
        return converter.getSql(sqlParamsOut, filter, sqlOpts);
    }
    final HUTraceEventQuery huTraceQuery = HuTraceQueryCreator.createTraceQueryFromDocumentFilter(filter);
    final int selectionId = huTraceRepository.queryToSelection(huTraceQuery);
    final String sqlPlaceHolder = sqlParamsOut.placeholder(selectionId);
    return String.format(WHERE_IN_T_SELECTION, sqlPlaceHolder);
}
Also used : HUTraceEventQuery(de.metas.handlingunits.trace.HUTraceEventQuery)

Example 2 with HUTraceEventQuery

use of de.metas.handlingunits.trace.HUTraceEventQuery in project metasfresh-webui-api by metasfresh.

the class DocumentFilterToHuTraceQueryTest method createTraceQueryFromDocumentFilter.

@Test
public void createTraceQueryFromDocumentFilter() {
    final DocumentFilter emptyFilter = DocumentFilter.builder().setFilterId("simple-M_InOut_ID-filter").addParameter(DocumentFilterParam.ofNameOperatorValue(I_M_HU_Trace.COLUMNNAME_M_InOut_ID, Operator.EQUAL, IntegerLookupValue.of(20, "test-inout-id"))).build();
    final HUTraceEventQuery huTraceQuery = HuTraceQueryCreator.createTraceQueryFromDocumentFilter(emptyFilter);
    assertThat(huTraceQuery).isNotNull();
    assertThat(huTraceQuery.getRecursionMode()).isEqualTo(RecursionMode.BOTH);
    assertThat(huTraceQuery.getInOutId()).isEqualTo(20);
}
Also used : HUTraceEventQuery(de.metas.handlingunits.trace.HUTraceEventQuery) DocumentFilter(de.metas.ui.web.document.filter.DocumentFilter) Test(org.junit.Test)

Example 3 with HUTraceEventQuery

use of de.metas.handlingunits.trace.HUTraceEventQuery in project metasfresh-webui-api by metasfresh.

the class DocumentFilterToHuTraceQueryTest method createTraceQueryFromDocumentFilter_all_equal_params.

@Test
public void createTraceQueryFromDocumentFilter_all_equal_params() {
    final DocumentFilter filter = DocumentFilter.builder().setFilterId("filter").addParameter(DocumentFilterParam.ofNameOperatorValue(I_M_HU_Trace.COLUMNNAME_AD_Org_ID, Operator.EQUAL, IntegerLookupValue.of(20, "test-AD_Org_ID"))).addParameter(DocumentFilterParam.ofNameOperatorValue(I_M_HU_Trace.COLUMNNAME_C_DocType_ID, Operator.EQUAL, IntegerLookupValue.of(30, "test-C_DocType_ID"))).addParameter(DocumentFilterParam.ofNameOperatorValue(I_M_HU_Trace.COLUMNNAME_DocStatus, Operator.EQUAL, StringLookupValue.of("CO", "test-DocStatus"))).addParameter(DocumentFilterParam.ofNameOperatorValue(I_M_HU_Trace.COLUMNNAME_HUTraceType, Operator.EQUAL, StringLookupValue.of(X_M_HU_Trace.HUTRACETYPE_MATERIAL_PICKING, "test-HUTraceType"))).addParameter(DocumentFilterParam.ofNameOperatorValue(I_M_HU_Trace.COLUMNNAME_M_HU_ID, Operator.EQUAL, IntegerLookupValue.of(60, "test-M_HU_ID"))).addParameter(DocumentFilterParam.ofNameOperatorValue(I_M_HU_Trace.COLUMNNAME_M_HU_Trace_ID, Operator.EQUAL, IntegerLookupValue.of(70, "test-M_HU_Trace_ID"))).addParameter(DocumentFilterParam.ofNameOperatorValue(I_M_HU_Trace.COLUMNNAME_M_HU_Trx_Line_ID, Operator.EQUAL, IntegerLookupValue.of(80, "test-M_HU_Trx_Line_ID"))).addParameter(DocumentFilterParam.ofNameOperatorValue(I_M_HU_Trace.COLUMNNAME_M_InOut_ID, Operator.EQUAL, IntegerLookupValue.of(90, "test-M_InOut_ID"))).addParameter(DocumentFilterParam.ofNameOperatorValue(I_M_HU_Trace.COLUMNNAME_M_Movement_ID, Operator.EQUAL, IntegerLookupValue.of(100, "test-M_Movement_ID"))).addParameter(DocumentFilterParam.ofNameOperatorValue(I_M_HU_Trace.COLUMNNAME_M_Product_ID, Operator.EQUAL, IntegerLookupValue.of(110, "test-M_Product_ID"))).addParameter(DocumentFilterParam.ofNameOperatorValue(I_M_HU_Trace.COLUMNNAME_M_ShipmentSchedule_ID, Operator.EQUAL, IntegerLookupValue.of(120, "test-M_ShipmentSchedule_ID"))).addParameter(DocumentFilterParam.ofNameOperatorValue(I_M_HU_Trace.COLUMNNAME_PP_Cost_Collector_ID, Operator.EQUAL, IntegerLookupValue.of(130, "test-PP_Cost_Collector_ID"))).addParameter(DocumentFilterParam.ofNameOperatorValue(I_M_HU_Trace.COLUMNNAME_PP_Order_ID, Operator.EQUAL, IntegerLookupValue.of(140, "test-PP_Order_ID"))).addParameter(DocumentFilterParam.ofNameOperatorValue(I_M_HU_Trace.COLUMNNAME_EventTime, Operator.EQUAL, TimeUtil.parseTimestamp("2017-10-13"))).addParameter(DocumentFilterParam.ofNameOperatorValue(I_M_HU_Trace.COLUMNNAME_VHU_ID, Operator.EQUAL, IntegerLookupValue.of(160, "test-VHU_ID"))).addParameter(DocumentFilterParam.ofNameOperatorValue(I_M_HU_Trace.COLUMNNAME_VHU_Source_ID, Operator.EQUAL, IntegerLookupValue.of(170, "test-VHU_Source_ID"))).addParameter(DocumentFilterParam.ofNameOperatorValue(I_M_HU_Trace.COLUMNNAME_VHUStatus, Operator.EQUAL, StringLookupValue.of(X_M_HU_Trace.VHUSTATUS_Active, "test-VHUStatus"))).build();
    final HUTraceEventQuery huTraceQuery = HuTraceQueryCreator.createTraceQueryFromDocumentFilter(filter);
    assertThat(huTraceQuery).isNotNull();
    assertThat(huTraceQuery.getRecursionMode()).isEqualTo(RecursionMode.BOTH);
    assertThat(huTraceQuery.getOrgId()).isEqualTo(20);
    assertThat(huTraceQuery.getDocTypeId().getAsInt()).isEqualTo(30);
    assertThat(huTraceQuery.getDocStatus()).isEqualTo("CO");
    assertThat(huTraceQuery.getType().toString()).isEqualTo(X_M_HU_Trace.HUTRACETYPE_MATERIAL_PICKING);
    assertThat(huTraceQuery.getTopLevelHuId()).isEqualTo(60);
    assertThat(huTraceQuery.getHuTraceEventId().getAsInt()).isEqualTo(70);
    assertThat(huTraceQuery.getHuTrxLineId()).isEqualTo(80);
    assertThat(huTraceQuery.getInOutId()).isEqualTo(90);
    assertThat(huTraceQuery.getMovementId()).isEqualTo(100);
    assertThat(huTraceQuery.getProductId()).isEqualTo(110);
    assertThat(huTraceQuery.getShipmentScheduleId()).isEqualTo(120);
    assertThat(huTraceQuery.getPpCostCollectorId()).isEqualTo(130);
    assertThat(huTraceQuery.getPpOrderId()).isEqualTo(140);
    assertThat(huTraceQuery.getVhuId()).isEqualTo(160);
    assertThat(huTraceQuery.getVhuSourceId()).isEqualTo(170);
    assertThat(huTraceQuery.getVhuStatus()).isEqualTo(X_M_HU_Trace.VHUSTATUS_Active);
    assertThat(huTraceQuery.getEventTime()).isEqualTo(TimeUtil.parseTimestamp("2017-10-13").toInstant());
}
Also used : HUTraceEventQuery(de.metas.handlingunits.trace.HUTraceEventQuery) DocumentFilter(de.metas.ui.web.document.filter.DocumentFilter) Test(org.junit.Test)

Example 4 with HUTraceEventQuery

use of de.metas.handlingunits.trace.HUTraceEventQuery in project metasfresh-webui-api by metasfresh.

the class HuTraceQueryCreator method getUpdateMethodForParameterOrThrowException.

private static BiFunction<HUTraceEventQuery, DocumentFilterParam, HUTraceEventQuery> getUpdateMethodForParameterOrThrowException(@NonNull final DocumentFilterParam parameter) {
    final String paramName = parameter.getFieldName();
    final // 
    BiFunction<HUTraceEventQuery, DocumentFilterParam, HUTraceEventQuery> queryUpdateFunction = FIELD_NAME_2_UPDATE_METHOD.get(paramName);
    if (queryUpdateFunction == null) {
        final String message = StringUtils.formatMessage("The given filterparam has an unexpected fieldName={}", paramName);
        throw new AdempiereException(message).setParameter("documentFilterParam", parameter);
    }
    return queryUpdateFunction;
}
Also used : DocumentFilterParam(de.metas.ui.web.document.filter.DocumentFilterParam) HUTraceEventQuery(de.metas.handlingunits.trace.HUTraceEventQuery) AdempiereException(org.adempiere.exceptions.AdempiereException)

Example 5 with HUTraceEventQuery

use of de.metas.handlingunits.trace.HUTraceEventQuery in project metasfresh-webui-api by metasfresh.

the class DocumentFilterToHuTraceQueryTest method createTraceQueryFromDocumentFilter_empty.

@Test
public void createTraceQueryFromDocumentFilter_empty() {
    final DocumentFilter emptyFilter = DocumentFilter.builder().setFilterId("emptyFilter").build();
    final HUTraceEventQuery huTraceQuery = HuTraceQueryCreator.createTraceQueryFromDocumentFilter(emptyFilter);
    assertThat(huTraceQuery).isNotNull();
}
Also used : HUTraceEventQuery(de.metas.handlingunits.trace.HUTraceEventQuery) DocumentFilter(de.metas.ui.web.document.filter.DocumentFilter) Test(org.junit.Test)

Aggregations

HUTraceEventQuery (de.metas.handlingunits.trace.HUTraceEventQuery)6 DocumentFilter (de.metas.ui.web.document.filter.DocumentFilter)4 Test (org.junit.Test)4 DocumentFilterParam (de.metas.ui.web.document.filter.DocumentFilterParam)1 Date (java.util.Date)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1