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;
}
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);
}
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);
}
}
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");
}
}
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());
}
}
Aggregations