Search in sources :

Example 6 with IModelTranslationMap

use of de.metas.i18n.IModelTranslationMap in project metasfresh-webui-api by metasfresh.

the class KPIRepository method createKPI.

private KPI createKPI(final I_WEBUI_KPI kpiDef) {
    final IModelTranslationMap trls = InterfaceWrapperHelper.getModelTranslationMap(kpiDef);
    Duration compareOffset = null;
    if (kpiDef.isGenerateComparation()) {
        final String compareOffetStr = kpiDef.getCompareOffset();
        compareOffset = Duration.parse(compareOffetStr);
    }
    return KPI.builder().setId(kpiDef.getWEBUI_KPI_ID()).setCaption(trls.getColumnTrl(I_WEBUI_KPI.COLUMNNAME_Name, kpiDef.getName())).setDescription(trls.getColumnTrl(I_WEBUI_KPI.COLUMNNAME_Description, kpiDef.getDescription())).setChartType(KPIChartType.forCode(kpiDef.getChartType())).setFields(retrieveKPIFields(kpiDef.getWEBUI_KPI_ID(), kpiDef.isGenerateComparation())).setCompareOffset(compareOffset).setTimeRangeDefaults(KPITimeRangeDefaults.builder().defaultTimeRangeFromString(kpiDef.getES_TimeRange()).defaultTimeRangeEndOffsetFromString(kpiDef.getES_TimeRange_End()).build()).setPollIntervalSec(kpiDef.getPollIntervalSec()).setESSearchIndex(kpiDef.getES_Index()).setESSearchTypes(kpiDef.getES_Type()).setESQuery(kpiDef.getES_Query()).build();
}
Also used : IModelTranslationMap(de.metas.i18n.IModelTranslationMap) Duration(java.time.Duration) ITranslatableString(de.metas.i18n.ITranslatableString) ImmutableTranslatableString(de.metas.i18n.ImmutableTranslatableString)

Example 7 with IModelTranslationMap

use of de.metas.i18n.IModelTranslationMap in project metasfresh-webui-api by metasfresh.

the class HUReportProcessInstancesRepository method toWebuiHUProcessDescriptor.

private WebuiHUProcessDescriptor toWebuiHUProcessDescriptor(final HUProcessDescriptor huProcessDescriptor) {
    final int reportADProcessId = huProcessDescriptor.getProcessId();
    final ProcessId processId = ProcessId.of(PROCESS_HANDLER_TYPE, reportADProcessId);
    final I_AD_Process adProcess = Services.get(IADProcessDAO.class).retrieveProcessById(reportADProcessId);
    final IModelTranslationMap adProcessTrl = InterfaceWrapperHelper.getModelTranslationMap(adProcess);
    final ITranslatableString caption = adProcessTrl.getColumnTrl(I_AD_Process.COLUMNNAME_Name, adProcess.getName());
    final ITranslatableString description = adProcessTrl.getColumnTrl(I_AD_Process.COLUMNNAME_Description, adProcess.getDescription());
    final DocumentEntityDescriptor parametersDescriptor = DocumentEntityDescriptor.builder().setDocumentType(DocumentType.Process, processId.toDocumentId()).setCaption(caption).setDescription(description).disableDefaultTableCallouts().addField(DocumentFieldDescriptor.builder(HUReportProcessInstance.PARAM_Copies).setCaption(Services.get(IMsgBL.class).translatable(HUReportProcessInstance.PARAM_Copies)).setWidgetType(DocumentFieldWidgetType.Integer)).build();
    return WebuiHUProcessDescriptor.builder().huProcessDescriptor(huProcessDescriptor).processDescriptor(ProcessDescriptor.builder().setProcessId(processId).setType(ProcessDescriptorType.Report).setParametersDescriptor(parametersDescriptor).setLayout(ProcessLayout.builder().setProcessId(processId).setCaption(caption).setDescription(description).addElements(parametersDescriptor).build()).build()).build();
}
Also used : IModelTranslationMap(de.metas.i18n.IModelTranslationMap) I_AD_Process(org.compiere.model.I_AD_Process) IMsgBL(de.metas.i18n.IMsgBL) ITranslatableString(de.metas.i18n.ITranslatableString) ProcessId(de.metas.ui.web.process.ProcessId) DocumentEntityDescriptor(de.metas.ui.web.window.descriptor.DocumentEntityDescriptor) IADProcessDAO(de.metas.process.IADProcessDAO)

Example 8 with IModelTranslationMap

use of de.metas.i18n.IModelTranslationMap 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 9 with IModelTranslationMap

use of de.metas.i18n.IModelTranslationMap in project metasfresh-webui-api by metasfresh.

the class HUEditorRowAttributesHelper method createLayoutElement.

private static final DocumentLayoutElementDescriptor createLayoutElement(final IAttributeValue attributeValue, final int warehouseId) {
    final I_M_Attribute attribute = attributeValue.getM_Attribute();
    final IModelTranslationMap attributeTrlMap = InterfaceWrapperHelper.getModelTranslationMap(attribute);
    final ITranslatableString caption = attributeTrlMap.getColumnTrl(I_M_Attribute.COLUMNNAME_Name, attribute.getName());
    final ITranslatableString description = attributeTrlMap.getColumnTrl(I_M_Attribute.COLUMNNAME_Description, attribute.getDescription());
    final String attributeName = HUEditorRowAttributesHelper.extractAttributeName(attributeValue);
    final DocumentFieldWidgetType widgetType = HUEditorRowAttributesHelper.extractWidgetType(attributeValue);
    return DocumentLayoutElementDescriptor.builder().setCaption(caption).setDescription(description).setWidgetType(widgetType).addField(DocumentLayoutElementFieldDescriptor.builder(attributeName).setPublicField(true).addDevices(createDevices(attribute.getValue(), warehouseId))).build();
}
Also used : IModelTranslationMap(de.metas.i18n.IModelTranslationMap) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) ITranslatableString(de.metas.i18n.ITranslatableString) I_M_Attribute(org.compiere.model.I_M_Attribute) ITranslatableString(de.metas.i18n.ITranslatableString)

Example 10 with IModelTranslationMap

use of de.metas.i18n.IModelTranslationMap in project metasfresh-webui-api by metasfresh.

the class KPIRepository method createKPIField.

private static final KPIField createKPIField(final I_WEBUI_KPI_Field kpiFieldDef, final boolean isComputeOffset) {
    final I_AD_Element adElement = kpiFieldDef.getAD_Element();
    final String elementColumnName = adElement.getColumnName();
    Check.assumeNotNull(elementColumnName, "The element {} does not have a column name set", adElement);
    final String fieldName = elementColumnName;
    // 
    // Extract field caption and description
    final IModelTranslationMap kpiFieldDefTrl = InterfaceWrapperHelper.getModelTranslationMap(kpiFieldDef);
    final ITranslatableString caption;
    final ITranslatableString description;
    if (Check.isEmpty(kpiFieldDef.getName(), true)) {
        final IModelTranslationMap adElementTrl = InterfaceWrapperHelper.getModelTranslationMap(adElement);
        caption = adElementTrl.getColumnTrl(I_AD_Element.COLUMNNAME_Name, adElement.getName());
        description = adElementTrl.getColumnTrl(I_AD_Element.COLUMNNAME_Description, adElement.getDescription());
    } else {
        caption = kpiFieldDefTrl.getColumnTrl(I_WEBUI_KPI_Field.COLUMNNAME_Name, kpiFieldDef.getName());
        description = ImmutableTranslatableString.empty();
    }
    // 
    // Extract offset field's caption and description
    final ITranslatableString offsetCaption;
    if (!isComputeOffset) {
        offsetCaption = ImmutableTranslatableString.empty();
    } else if (Check.isEmpty(kpiFieldDef.getOffsetName(), true)) {
        offsetCaption = caption;
    } else {
        offsetCaption = kpiFieldDefTrl.getColumnTrl(I_WEBUI_KPI_Field.COLUMNNAME_OffsetName, kpiFieldDef.getOffsetName());
    }
    return KPIField.builder().setFieldName(fieldName).setGroupBy(kpiFieldDef.isGroupBy()).setCaption(caption).setOffsetCaption(offsetCaption).setDescription(description).setUnit(kpiFieldDef.getUOMSymbol()).setValueType(KPIFieldValueType.fromDisplayType(kpiFieldDef.getAD_Reference_ID())).setNumberPrecision(extractNumberPrecision(kpiFieldDef.getAD_Reference_ID())).setColor(kpiFieldDef.getColor()).setESPath(kpiFieldDef.getES_FieldPath()).build();
}
Also used : I_AD_Element(org.compiere.model.I_AD_Element) IModelTranslationMap(de.metas.i18n.IModelTranslationMap) ITranslatableString(de.metas.i18n.ITranslatableString) ITranslatableString(de.metas.i18n.ITranslatableString) ImmutableTranslatableString(de.metas.i18n.ImmutableTranslatableString)

Aggregations

IModelTranslationMap (de.metas.i18n.IModelTranslationMap)10 ITranslatableString (de.metas.i18n.ITranslatableString)6 DocumentFieldDescriptor (de.metas.ui.web.window.descriptor.DocumentFieldDescriptor)4 DocumentFieldWidgetType (de.metas.ui.web.window.descriptor.DocumentFieldWidgetType)4 ImmutableTranslatableString (de.metas.i18n.ImmutableTranslatableString)3 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)3 LookupDescriptor (de.metas.ui.web.window.descriptor.LookupDescriptor)3 LookupDescriptorProvider (de.metas.ui.web.window.descriptor.LookupDescriptorProvider)3 SqlLookupDescriptor (de.metas.ui.web.window.descriptor.sql.SqlLookupDescriptor)3 ImmutableList (com.google.common.collect.ImmutableList)2 IMsgBL (de.metas.i18n.IMsgBL)2 IADProcessDAO (de.metas.process.IADProcessDAO)2 EntityNotFoundException (de.metas.ui.web.exceptions.EntityNotFoundException)2 ProcessId (de.metas.ui.web.process.ProcessId)2 SqlDocumentEntityDataBindingDescriptor (de.metas.ui.web.window.descriptor.sql.SqlDocumentEntityDataBindingDescriptor)2 SqlDocumentFieldDataBindingDescriptor (de.metas.ui.web.window.descriptor.sql.SqlDocumentFieldDataBindingDescriptor)2 Joiner (com.google.common.base.Joiner)1 Preconditions (com.google.common.base.Preconditions)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Amount (de.metas.currency.Amount)1