use of de.metas.ui.web.exceptions.EntityNotFoundException in project metasfresh-webui-api by metasfresh.
the class WEBUI_PP_Order_IssueReceipt_BarcodeLauncher method doIt.
@Override
protected String doIt() throws Exception {
final int orderLineId = OrderCheckupBarcode.fromBarcodeString(p_Barcode).getC_OrderLine_ID();
final int ppOrderId = Services.get(IPPOrderDAO.class).retrievePPOrderIdByOrderLineId(orderLineId);
if (ppOrderId <= 0) {
throw new EntityNotFoundException("@NotFound@ @PP_Order_ID@");
}
final TableRecordReference ppOrderRef = TableRecordReference.of(org.eevolution.model.I_PP_Order.Table_Name, ppOrderId);
getResult().setRecordToOpen(ppOrderRef, PPOrderConstants.AD_WINDOW_ID_IssueReceipt.toInt(), OpenTarget.GridView);
return MSG_OK;
}
use of de.metas.ui.web.exceptions.EntityNotFoundException in project metasfresh-webui-api by metasfresh.
the class PickingSlotRowsCollection method getById.
public PickingSlotRow getById(@NonNull final PickingSlotRowId rowId) throws EntityNotFoundException {
if (rowId.getPickingSlotId() <= 0) {
return assertRowNotNull(rowId, getRowsIndex().getRow(rowId));
}
final PickingSlotRowId pickingSlotRowId = PickingSlotRowId.ofPickingSlotId(rowId.getPickingSlotId());
final PickingSlotRow pickingSlotRow = getRowsIndex().getRow(pickingSlotRowId);
if (java.util.Objects.equals(rowId, pickingSlotRowId)) {
return assertRowNotNull(pickingSlotRowId, pickingSlotRow);
}
return pickingSlotRow.findIncludedRowById(rowId).orElseThrow(() -> new EntityNotFoundException("Row not found").setParameter("pickingSlotRow", pickingSlotRow).setParameter("rowId", rowId));
}
use of de.metas.ui.web.exceptions.EntityNotFoundException in project metasfresh-webui-api by metasfresh.
the class BoardDescriptorRepository method createBoardDescriptor.
private BoardDescriptor createBoardDescriptor(final int boardId) {
//
// Retrieve the board PO
final IQueryBL queryBL = Services.get(IQueryBL.class);
final I_WEBUI_Board boardPO = queryBL.createQueryBuilderOutOfTrx(I_WEBUI_Board.class).addEqualsFilter(I_WEBUI_Board.COLUMN_WEBUI_Board_ID, boardId).addOnlyActiveRecordsFilter().create().firstOnly(I_WEBUI_Board.class);
if (boardPO == null) {
throw new EntityNotFoundException("No board found for ID=" + boardId);
}
//
// Board document mappings
final String tableName = Services.get(IADTableDAO.class).retrieveTableName(boardPO.getAD_Table_ID());
final String keyColumnName = InterfaceWrapperHelper.getKeyColumnName(tableName);
// TODO: hardcoded
final String userIdColumnName = "UpdatedBy";
//
// Board document info
// TODO boardPO.getAD_Window_ID();
int adWindowId = 0;
if (adWindowId <= 0) {
adWindowId = RecordZoomWindowFinder.findAD_Window_ID(tableName);
}
final WindowId documentWindowId = WindowId.of(adWindowId);
final DocumentEntityDescriptor documentEntityDescriptor = documentDescriptors.getDocumentEntityDescriptor(documentWindowId);
final SqlDocumentEntityDataBindingDescriptor documentBinding = documentEntityDescriptor.getDataBinding(SqlDocumentEntityDataBindingDescriptor.class);
final String tableAlias = documentBinding.getTableAlias();
//
// Board document lookup provider
final int adValRuleId = boardPO.getAD_Val_Rule_ID();
final LookupDescriptorProvider documentLookupDescriptorProvider = SqlLookupDescriptor.builder().setCtxTableName(null).setCtxColumnName(keyColumnName).setDisplayType(DisplayType.Search).setWidgetType(DocumentFieldWidgetType.Lookup).setAD_Val_Rule_ID(adValRuleId).buildProvider();
//
// Board descriptor
final IModelTranslationMap boardTrlMap = InterfaceWrapperHelper.getModelTranslationMap(boardPO);
final BoardDescriptorBuilder boardDescriptor = BoardDescriptor.builder().boardId(boardPO.getWEBUI_Board_ID()).caption(boardTrlMap.getColumnTrl(I_WEBUI_Board.COLUMNNAME_Name, boardPO.getName())).documentWindowId(documentWindowId).documentLookupDescriptorProvider(documentLookupDescriptorProvider).tableName(tableName).tableAlias(tableAlias).keyColumnName(keyColumnName).userIdColumnName(userIdColumnName).websocketEndpoint(WebSocketConfig.buildBoardTopicName(boardId));
// Source document filters: AD_Val_Rule_ID
if (adValRuleId > 0) {
final IValidationRule validationRule = Services.get(IValidationRuleFactory.class).create(tableName, adValRuleId, // ctx table name
null, // ctx column name
null);
final String sqlWhereClause = validationRule.getPrefilterWhereClause().evaluate(Evaluatees.ofCtx(Env.getCtx()), OnVariableNotFound.Fail);
final DocumentFilter adValRuleFilter = DocumentFilter.builder().setFilterId("AD_Val_Rule_" + adValRuleId).addParameter(DocumentFilterParam.ofSqlWhereClause(true, sqlWhereClause)).build();
boardDescriptor.documentFilter(adValRuleFilter);
}
//
// Lanes
{
queryBL.createQueryBuilderOutOfTrx(I_WEBUI_Board_Lane.class).addEqualsFilter(I_WEBUI_Board_Lane.COLUMN_WEBUI_Board_ID, boardId).addOnlyActiveRecordsFilter().orderBy().addColumn(I_WEBUI_Board_Lane.COLUMN_SeqNo).addColumn(// just have a predictable order
I_WEBUI_Board_Lane.COLUMN_WEBUI_Board_Lane_ID).endOrderBy().create().stream(I_WEBUI_Board_Lane.class).map(this::createBoardLaneDescriptor).forEach(lane -> boardDescriptor.lane(lane.getLaneId(), lane));
}
//
// Board card fields
{
queryBL.createQueryBuilderOutOfTrx(I_WEBUI_Board_CardField.class).addEqualsFilter(I_WEBUI_Board_CardField.COLUMN_WEBUI_Board_ID, boardId).addOnlyActiveRecordsFilter().orderBy().addColumn(I_WEBUI_Board_CardField.COLUMN_SeqNo).addColumn(I_WEBUI_Board_CardField.COLUMN_WEBUI_Board_CardField_ID).endOrderBy().create().stream(I_WEBUI_Board_CardField.class).map(cardFieldPO -> createBoardCardFieldDescriptor(cardFieldPO, documentEntityDescriptor)).forEach(cardField -> boardDescriptor.cardFieldByFieldName(cardField.getFieldName(), cardField));
}
//
return boardDescriptor.build();
}
use of de.metas.ui.web.exceptions.EntityNotFoundException in project metasfresh-webui-api by metasfresh.
the class WEBUI_KPI_TestQuery method doIt.
@Override
protected String doIt() throws JsonProcessingException {
final int kpiId = getRecord_ID();
if (kpiId <= 0) {
throw new EntityNotFoundException("@NotFound@ @" + I_WEBUI_KPI.COLUMNNAME_WEBUI_KPI_ID + "@");
}
kpisRepo.invalidateKPI(kpiId);
final KPI kpi = kpisRepo.getKPI(kpiId);
final TimeRange timeRange = kpi.getTimeRangeDefaults().createTimeRange(p_DateFrom, p_DateTo);
final KPIDataResult kpiData = KPIDataLoader.newInstance(elasticsearchClient, kpi).setTimeRange(timeRange).setFormatValues(true).assertESTypesExists().retrieveData();
final String jsonData = jsonObjectMapper.writeValueAsString(kpiData);
log.info("jsonData:\n {}", jsonData);
return jsonData;
}
use of de.metas.ui.web.exceptions.EntityNotFoundException in project metasfresh-webui-api by metasfresh.
the class DebugRestController method setLoggerLevel.
@GetMapping("/logger/_setLevel/{level}")
public Set<String> setLoggerLevel(//
@RequestParam(name = "module", required = false) final LoggingModule module, //
@RequestParam(name = "loggerName", required = false) final String loggerName, //
@PathVariable("level") final String levelStr) {
//
// Get Level to set
final Level level;
if (Check.isEmpty(levelStr, true)) {
level = null;
} else {
level = LogManager.asLogbackLevel(levelStr);
if (level == null) {
throw new IllegalArgumentException("level is not valid");
}
}
//
// Get logger names
final Set<String> loggerNamesEffective = new LinkedHashSet<>();
if (module != null) {
loggerNamesEffective.addAll(module.getLoggerNames());
}
if (!Check.isEmpty(loggerName, true)) {
loggerNamesEffective.add(loggerName.trim());
}
// Set level to effective logger names
for (final String loggerNameEffective : loggerNamesEffective) {
final Logger logger = LogManager.getLogger(loggerNameEffective);
if (logger == null) {
throw new EntityNotFoundException("No logger found for " + loggerNameEffective);
}
final boolean set = LogManager.setLoggerLevel(logger, level);
if (!set) {
throw new IllegalStateException("For some reason " + logger + " could not be set to level " + level);
}
}
return loggerNamesEffective;
}
Aggregations