Search in sources :

Example 16 with EntityNotFoundException

use of de.metas.ui.web.exceptions.EntityNotFoundException in project metasfresh-webui-api by metasfresh.

the class DocumentAttachments method getEntry.

public IDocumentAttachmentEntry getEntry(final DocumentId id) {
    final IPair<String, Integer> prefixAndId = toPrefixAndEntryId(id);
    final String idPrefix = prefixAndId.getLeft();
    final int entryId = prefixAndId.getRight();
    if (ID_PREFIX_Attachment.equals(idPrefix)) {
        final AttachmentEntry entry = attachmentsBL.getEntryById(recordRef, entryId);
        if (entry == null) {
            throw new EntityNotFoundException(id.toJson());
        }
        return DocumentAttachmentEntry.of(id, entry);
    } else if (ID_PREFIX_Archive.equals(idPrefix)) {
        final I_AD_Archive archive = Services.get(IArchiveDAO.class).retrieveArchiveOrNull(Env.getCtx(), recordRef, entryId);
        if (archive == null) {
            throw new EntityNotFoundException(id.toJson());
        }
        return DocumentArchiveEntry.of(id, archive);
    } else {
        throw new EntityNotFoundException(id.toJson());
    }
}
Also used : I_AD_Archive(org.compiere.model.I_AD_Archive) AttachmentEntry(de.metas.attachments.AttachmentEntry) I_AD_AttachmentEntry(org.compiere.model.I_AD_AttachmentEntry) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException)

Example 17 with EntityNotFoundException

use of de.metas.ui.web.exceptions.EntityNotFoundException in project metasfresh-webui-api by metasfresh.

the class ADProcessDescriptorsFactory method retrieveProcessDescriptor.

private ProcessDescriptor retrieveProcessDescriptor(final ProcessId processId) {
    final I_AD_Process adProcess = InterfaceWrapperHelper.create(Env.getCtx(), processId.getProcessIdAsInt(), I_AD_Process.class, ITrx.TRXNAME_None);
    if (adProcess == null) {
        throw new EntityNotFoundException("@NotFound@ @AD_Process_ID@ (" + processId + ")");
    }
    final WebuiProcessClassInfo webuiProcesClassInfo = WebuiProcessClassInfo.of(adProcess.getClassname());
    final IModelTranslationMap adProcessTrlsMap = InterfaceWrapperHelper.getModelTranslationMap(adProcess);
    // 
    // Parameters document descriptor
    final DocumentEntityDescriptor parametersDescriptor;
    {
        final DocumentEntityDescriptor.Builder parametersDescriptorBuilder = DocumentEntityDescriptor.builder().setDocumentType(DocumentType.Process, processId.toDocumentId()).setCaption(adProcessTrlsMap.getColumnTrl(I_AD_Process.COLUMNNAME_Name, adProcess.getName())).setDescription(adProcessTrlsMap.getColumnTrl(I_AD_Process.COLUMNNAME_Description, adProcess.getDescription())).setDataBinding(ProcessParametersDataBindingDescriptorBuilder.instance).disableDefaultTableCallouts();
        // Get AD_Process_Para(s) and populate the entity descriptor
        adProcessDAO.retrieveProcessParameters(adProcess).stream().map(adProcessParam -> createProcessParaDescriptor(webuiProcesClassInfo, adProcessParam)).forEach(processParaDescriptor -> parametersDescriptorBuilder.addField(processParaDescriptor));
        parametersDescriptor = parametersDescriptorBuilder.build();
    }
    // 
    // Parameters layout
    final ProcessLayout.Builder layout = ProcessLayout.builder().setProcessId(processId).setLayoutType(webuiProcesClassInfo.getLayoutType()).setCaption(parametersDescriptor.getCaption()).setDescription(parametersDescriptor.getDescription()).addElements(parametersDescriptor);
    // Process descriptor
    return ProcessDescriptor.builder().setProcessId(processId).setType(extractType(adProcess)).setProcessClassname(extractClassnameOrNull(adProcess)).setParametersDescriptor(parametersDescriptor).setLayout(layout.build()).build();
}
Also used : CCache(org.compiere.util.CCache) IExpression(org.adempiere.ad.expression.api.IExpression) ITrx(org.adempiere.ad.trx.api.ITrx) Env(org.compiere.util.Env) DefaultValueExpressionsFactory(de.metas.ui.web.window.descriptor.factory.standard.DefaultValueExpressionsFactory) InterfaceWrapperHelper(org.adempiere.model.InterfaceWrapperHelper) IRangeAwareParams(org.adempiere.util.api.IRangeAwareParams) ProcessDescriptor(de.metas.ui.web.process.descriptor.ProcessDescriptor) IExpressionFactory(org.adempiere.ad.expression.api.IExpressionFactory) DateRangeValue(de.metas.ui.web.window.datatypes.DateRangeValue) IProcessPrecondition(de.metas.process.IProcessPrecondition) NonNull(lombok.NonNull) RelatedProcessDescriptor(de.metas.process.RelatedProcessDescriptor) ConstantLogicExpression(org.adempiere.ad.expression.api.ConstantLogicExpression) JavaProcess(de.metas.process.JavaProcess) I_AD_Form(org.compiere.model.I_AD_Form) DocumentFieldDescriptor(de.metas.ui.web.window.descriptor.DocumentFieldDescriptor) Services(org.adempiere.util.Services) I_AD_Process(org.compiere.model.I_AD_Process) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException) List(java.util.List) Stream(java.util.stream.Stream) ProcessId(de.metas.ui.web.process.ProcessId) DocumentEntityDataBindingDescriptorBuilder(de.metas.ui.web.window.descriptor.DocumentEntityDataBindingDescriptor.DocumentEntityDataBindingDescriptorBuilder) Builder(lombok.Builder) IProcessPreconditionsContext(de.metas.process.IProcessPreconditionsContext) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) Optional(java.util.Optional) ProcessParams(de.metas.process.ProcessParams) DocumentType(de.metas.ui.web.window.datatypes.DocumentType) IADTableDAO(org.adempiere.ad.table.api.IADTableDAO) GuavaCollectors(org.adempiere.util.GuavaCollectors) LookupDescriptorProvider(de.metas.ui.web.window.descriptor.LookupDescriptorProvider) ILogicExpression(org.adempiere.ad.expression.api.ILogicExpression) SqlLookupDescriptor(de.metas.ui.web.window.descriptor.sql.SqlLookupDescriptor) I_AD_Process_Para(org.compiere.model.I_AD_Process_Para) Supplier(java.util.function.Supplier) ProcessDescriptorType(de.metas.ui.web.process.descriptor.ProcessDescriptor.ProcessDescriptorType) DescriptorsFactoryHelper(de.metas.ui.web.window.descriptor.factory.standard.DescriptorsFactoryHelper) LookupDescriptor(de.metas.ui.web.window.descriptor.LookupDescriptor) ImmutableList(com.google.common.collect.ImmutableList) Characteristic(de.metas.ui.web.window.descriptor.DocumentFieldDescriptor.Characteristic) ICalloutField(org.adempiere.ad.callout.api.ICalloutField) DocumentEntityDescriptor(de.metas.ui.web.window.descriptor.DocumentEntityDescriptor) IADProcessDAO(de.metas.process.IADProcessDAO) LookupValue(de.metas.ui.web.window.datatypes.LookupValue) DocumentsRepository(de.metas.ui.web.window.model.DocumentsRepository) IModelTranslationMap(de.metas.i18n.IModelTranslationMap) IUserRolePermissions(org.adempiere.ad.security.IUserRolePermissions) ProcessLayout(de.metas.ui.web.process.descriptor.ProcessLayout) WebuiRelatedProcessDescriptor(de.metas.ui.web.process.descriptor.WebuiRelatedProcessDescriptor) ProcessPreconditionsResolution(de.metas.process.ProcessPreconditionsResolution) DocumentEntityDataBindingDescriptor(de.metas.ui.web.window.descriptor.DocumentEntityDataBindingDescriptor) WebuiPreconditionsContext(de.metas.ui.web.process.WebuiPreconditionsContext) Check(org.adempiere.util.Check) IModelTranslationMap(de.metas.i18n.IModelTranslationMap) I_AD_Process(org.compiere.model.I_AD_Process) DocumentEntityDataBindingDescriptorBuilder(de.metas.ui.web.window.descriptor.DocumentEntityDataBindingDescriptor.DocumentEntityDataBindingDescriptorBuilder) Builder(lombok.Builder) ProcessLayout(de.metas.ui.web.process.descriptor.ProcessLayout) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException) DocumentEntityDescriptor(de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)

Example 18 with EntityNotFoundException

use of de.metas.ui.web.exceptions.EntityNotFoundException in project metasfresh-webui-api by metasfresh.

the class DebugRestController method getLoggersUpToRoot.

@GetMapping("/logger/{loggerName}/_getUpToRoot")
public List<Map<String, Object>> getLoggersUpToRoot(@PathVariable("loggerName") final String loggerName) {
    final Logger logger = LogManager.getLogger(loggerName);
    if (logger == null) {
        throw new EntityNotFoundException("No logger found for " + loggerName);
    }
    final List<Map<String, Object>> loggerInfos = new ArrayList<>();
    // 
    LogManager.forAllLevelsUpToRoot(logger, currentLogger -> {
        final Map<String, Object> info = new HashMap<>();
        info.put("name", currentLogger.getName());
        info.put("id", System.identityHashCode(currentLogger));
        if (currentLogger instanceof ch.qos.logback.classic.Logger) {
            final ch.qos.logback.classic.Logger logbackLogger = (ch.qos.logback.classic.Logger) currentLogger;
            final Level level = logbackLogger.getLevel();
            final Level effectiveLevel = logbackLogger.getEffectiveLevel();
            info.put("level", level == null ? null : level.toString());
            info.put("level-effective", effectiveLevel == null ? null : effectiveLevel.toString());
        } else {
            info.put("warning", "unknown level for logger object " + currentLogger + " (" + currentLogger.getClass() + ")");
        }
        loggerInfos.add(info);
    });
    // 
    return loggerInfos;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException) Logger(org.slf4j.Logger) IQueryStatisticsLogger(org.adempiere.ad.dao.IQueryStatisticsLogger) Level(ch.qos.logback.classic.Level) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 19 with EntityNotFoundException

use of de.metas.ui.web.exceptions.EntityNotFoundException in project metasfresh-webui-api by metasfresh.

the class ViewProcessInstancesRepository method getActionInstance.

private ViewActionInstance getActionInstance(final DocumentId pinstanceId) {
    final String viewId = ViewActionInstancesList.extractViewId(pinstanceId);
    final ViewActionInstancesList viewActionInstancesList = viewActionInstancesByViewId.get(viewId);
    if (viewActionInstancesList == null) {
        throw new EntityNotFoundException("No view action instance found for " + pinstanceId);
    }
    return viewActionInstancesList.getByInstanceId(pinstanceId);
}
Also used : ToString(lombok.ToString) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException)

Aggregations

EntityNotFoundException (de.metas.ui.web.exceptions.EntityNotFoundException)19 Logger (org.slf4j.Logger)4 ImmutableList (com.google.common.collect.ImmutableList)3 Level (ch.qos.logback.classic.Level)2 Preconditions (com.google.common.base.Preconditions)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 IModelTranslationMap (de.metas.i18n.IModelTranslationMap)2 LogManager (de.metas.logging.LogManager)2 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)2 DocumentType (de.metas.ui.web.window.datatypes.DocumentType)2 WindowId (de.metas.ui.web.window.datatypes.WindowId)2 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 LinkedHashSet (java.util.LinkedHashSet)2 List (java.util.List)2 Builder (lombok.Builder)2 NonNull (lombok.NonNull)2 ILogicExpression (org.adempiere.ad.expression.api.ILogicExpression)2