Search in sources :

Example 6 with JSONLookupValue

use of de.metas.ui.web.window.datatypes.json.JSONLookupValue in project metasfresh-webui-api by metasfresh.

the class PurchaseRowFactory method createGroupRow.

public PurchaseRow createGroupRow(final I_C_OrderLine salesOrderLine, final List<PurchaseRow> rows) {
    final JSONLookupValue product = createProductLookupValue(salesOrderLine.getM_Product_ID());
    final BigDecimal qtyToDeliver = salesOrderLine.getQtyOrdered().subtract(salesOrderLine.getQtyDelivered());
    final String uom = createUOMLookupValueForProductId(product.getKeyAsInt());
    final PurchaseRow groupRow = PurchaseRow.builder().rowId(PurchaseRowId.groupId(salesOrderLine.getC_OrderLine_ID())).salesOrderId(salesOrderLine.getC_Order_ID()).rowType(PurchaseRowType.GROUP).product(product).uomOrAvailablility(uom).qtyToDeliver(qtyToDeliver).datePromised(salesOrderLine.getDatePromised()).orgId(salesOrderLine.getAD_Org_ID()).warehouseId(salesOrderLine.getM_Warehouse_ID()).includedRows(rows).readonly(// grouping lines are always readonly
    true).build();
    return groupRow;
}
Also used : JSONLookupValue(de.metas.ui.web.window.datatypes.json.JSONLookupValue) BigDecimal(java.math.BigDecimal)

Example 7 with JSONLookupValue

use of de.metas.ui.web.window.datatypes.json.JSONLookupValue in project metasfresh-webui-api by metasfresh.

the class PickingTerminalByOrderViewCustomizer method customizeViewRow.

@Override
public void customizeViewRow(final ViewRow.Builder rowBuilder) {
    final JSONLookupValue orderOrBPLocationLV = createOrderOrBPLocation(rowBuilder);
    rowBuilder.putFieldValue(FIELDNAME_OrderOrBPLocation, orderOrBPLocationLV);
}
Also used : JSONLookupValue(de.metas.ui.web.window.datatypes.json.JSONLookupValue)

Example 8 with JSONLookupValue

use of de.metas.ui.web.window.datatypes.json.JSONLookupValue in project metasfresh-webui-api by metasfresh.

the class PickingTerminalByWarehouseAndProductViewCustomizer method createProductOrBPartnerFieldValue.

private JSONLookupValue createProductOrBPartnerFieldValue(final ViewRow.Builder rowBuilder) {
    // Grouping row
    if (rowBuilder.isRootRow()) {
        final JSONLookupValue productLV = (JSONLookupValue) rowBuilder.getFieldValue(I_M_Packageable_V.COLUMNNAME_M_Product_ID);
        return productLV;
    } else // Detail/included row
    {
        final JSONLookupValue bpartnerLV = (JSONLookupValue) rowBuilder.getFieldValue(I_M_Packageable_V.COLUMNNAME_C_BPartner_ID);
        final JSONLookupValue bpLocationLV = (JSONLookupValue) rowBuilder.getFieldValue(I_M_Packageable_V.COLUMNNAME_C_BPartner_Location_ID);
        return JSONLookupValue.concat(bpartnerLV, bpLocationLV);
    }
}
Also used : JSONLookupValue(de.metas.ui.web.window.datatypes.json.JSONLookupValue)

Example 9 with JSONLookupValue

use of de.metas.ui.web.window.datatypes.json.JSONLookupValue in project metasfresh-webui-api by metasfresh.

the class SqlViewDataRepository method retrieveRowId_SingleKey.

private DocumentId retrieveRowId_SingleKey(final ResultSet rs, final String adLanguage) throws SQLException {
    final String keyColumnName = keyColumnNamesMap.getSingleKeyColumnName();
    final SqlViewRowFieldLoader fieldLoader = rowFieldLoaders.get(keyColumnName);
    final Object jsonRowIdObj = fieldLoader.retrieveValueAsJson(rs, adLanguage);
    if (JSONNullValue.isNull(jsonRowIdObj)) {
        return null;
    } else if (jsonRowIdObj instanceof DocumentId) {
        return (DocumentId) jsonRowIdObj;
    } else if (jsonRowIdObj instanceof Integer) {
        return DocumentId.of((Integer) jsonRowIdObj);
    } else if (jsonRowIdObj instanceof String) {
        return DocumentId.of(jsonRowIdObj.toString());
    } else if (jsonRowIdObj instanceof JSONLookupValue) {
        // case: usually this is happening when a view's column which is Lookup is also marked as KEY.
        final JSONLookupValue jsonLookupValue = (JSONLookupValue) jsonRowIdObj;
        return DocumentId.of(jsonLookupValue.getKey());
    } else {
        throw new IllegalArgumentException("Cannot convert id '" + jsonRowIdObj + "' (" + jsonRowIdObj.getClass() + ") to integer");
    }
}
Also used : JSONLookupValue(de.metas.ui.web.window.datatypes.json.JSONLookupValue) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) SqlViewRowFieldLoader(de.metas.ui.web.view.descriptor.SqlViewRowFieldBinding.SqlViewRowFieldLoader)

Example 10 with JSONLookupValue

use of de.metas.ui.web.window.datatypes.json.JSONLookupValue in project metasfresh-webui-api by metasfresh.

the class ViewExcelExporter method getValueAt.

@Override
public CellValue getValueAt(final int rowIndex, final int columnIndex) {
    final String fieldName = getFieldName(columnIndex);
    final IViewRow row = getRow(rowIndex);
    if (row == null) {
        return null;
    }
    final Object value = row.getFieldNameAndJsonValues().get(fieldName);
    if (value == null) {
        return null;
    }
    final DocumentFieldWidgetType widgetType = getWidgetType(columnIndex);
    if (widgetType.isDateOrTime()) {
        return CellValue.ofDate(JSONDate.fromJson(value.toString(), widgetType));
    } else if (value instanceof JSONLookupValue) {
        final String valueStr = ((JSONLookupValue) value).getCaption();
        return CellValues.toCellValue(valueStr, widgetType.getDisplayType());
    } else {
        return CellValues.toCellValue(value, widgetType.getDisplayType());
    }
}
Also used : JSONLookupValue(de.metas.ui.web.window.datatypes.json.JSONLookupValue) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType)

Aggregations

JSONLookupValue (de.metas.ui.web.window.datatypes.json.JSONLookupValue)10 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)3 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 IHUQueryBuilder (de.metas.handlingunits.IHUQueryBuilder)1 IHandlingUnitsBL (de.metas.handlingunits.IHandlingUnitsBL)1 IHandlingUnitsDAO (de.metas.handlingunits.IHandlingUnitsDAO)1 HUException (de.metas.handlingunits.exceptions.HUException)1 I_M_HU (de.metas.handlingunits.model.I_M_HU)1 I_M_Locator (de.metas.handlingunits.model.I_M_Locator)1 I_M_Warehouse (de.metas.handlingunits.model.I_M_Warehouse)1 X_M_HU_PI_Version (de.metas.handlingunits.model.X_M_HU_PI_Version)1 IHUProductStorage (de.metas.handlingunits.storage.IHUProductStorage)1 IHUStorage (de.metas.handlingunits.storage.IHUStorage)1 IHUStorageFactory (de.metas.handlingunits.storage.IHUStorageFactory)1 LogManager (de.metas.logging.LogManager)1 DocumentFilter (de.metas.ui.web.document.filter.DocumentFilter)1 SqlDocumentFilterConverter (de.metas.ui.web.document.filter.sql.SqlDocumentFilterConverter)1 SqlDocumentFilterConverters (de.metas.ui.web.document.filter.sql.SqlDocumentFilterConverters)1 HUIdsFilterData (de.metas.ui.web.handlingunits.HUIdsFilterHelper.HUIdsFilterData)1