Search in sources :

Example 11 with ITranslatableString

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

the class PPOrderLinesLoader method extractDescription.

private static final ITranslatableString extractDescription(final I_PP_Order ppOrder) {
    final ITranslatableString docTypeStr;
    final I_C_DocType docType = ppOrder.getC_DocType();
    if (docType != null) {
        final IModelTranslationMap docTypeTrlMap = InterfaceWrapperHelper.getModelTranslationMap(docType);
        docTypeStr = docTypeTrlMap.getColumnTrl(I_C_DocType.COLUMNNAME_Name, docType.getName());
    } else {
        docTypeStr = ImmutableTranslatableString.empty();
    }
    final ITranslatableString documentNoStr = ImmutableTranslatableString.constant(ppOrder.getDocumentNo());
    return ITranslatableString.compose(" ", docTypeStr, documentNoStr);
}
Also used : IModelTranslationMap(de.metas.i18n.IModelTranslationMap) ITranslatableString(de.metas.i18n.ITranslatableString) I_C_DocType(org.compiere.model.I_C_DocType)

Example 12 with ITranslatableString

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

the class BoardDescriptorRepository method createCard.

private BoardCard createCard(final ResultSet rs, final BoardDescriptor boardDescriptor) throws SQLException {
    final String adLanguage = null;
    final int laneId = rs.getInt(I_WEBUI_Board_RecordAssignment.COLUMNNAME_WEBUI_Board_Lane_ID);
    final int recordId = rs.getInt(I_WEBUI_Board_RecordAssignment.COLUMNNAME_Record_ID);
    final String caption = rs.getString("card$caption");
    final int userId = rs.getInt("card$user_id");
    final String userAvatarId = rs.getString("card$user_avatar_id");
    final String userFullname = rs.getString("card$user_fullname");
    // 
    // Retrieve card fields
    final Map<String, Object> cardValues = new LinkedHashMap<>();
    for (final BoardCardFieldDescriptor cardField : boardDescriptor.getCardFields()) {
        final BoardFieldLoader fieldLoader = cardField.getFieldLoader();
        final Object fieldValue = fieldLoader.retrieveValueAsJson(rs, adLanguage);
        if (fieldValue == null) {
            continue;
        }
        cardValues.put(cardField.getFieldName(), fieldValue);
    }
    final ITranslatableString description = buildDescription(cardValues, boardDescriptor);
    return BoardCard.builder().cardId(recordId).laneId(laneId).caption(ImmutableTranslatableString.constant(caption)).description(description).documentPath(DocumentPath.rootDocumentPath(boardDescriptor.getDocumentWindowId(), DocumentId.of(recordId))).user(BoardCardUser.builder().userId(userId).avatarId(userAvatarId).fullname(userFullname).build()).build();
}
Also used : BoardFieldLoader(de.metas.ui.web.board.BoardCardFieldDescriptor.BoardFieldLoader) ITranslatableString(de.metas.i18n.ITranslatableString) ToString(lombok.ToString) ITranslatableString(de.metas.i18n.ITranslatableString) DateTimeTranslatableString(de.metas.i18n.DateTimeTranslatableString) NumberTranslatableString(de.metas.i18n.NumberTranslatableString) ImmutableTranslatableString(de.metas.i18n.ImmutableTranslatableString) LinkedHashMap(java.util.LinkedHashMap)

Example 13 with ITranslatableString

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

the class DocumentFilterDescriptorsProviderFactory method createFilterParam.

private final DocumentFilterParamDescriptor.Builder createFilterParam(final DocumentFieldDescriptor field) {
    final ITranslatableString displayName = field.getCaption();
    final String fieldName = field.getFieldName();
    final DocumentFieldWidgetType widgetType = extractFilterWidgetType(field);
    final DocumentFieldDefaultFilterDescriptor filteringInfo = field.getDefaultFilterInfo();
    final LookupDescriptor lookupDescriptor = field.getLookupDescriptor(LookupDescriptorProvider.LookupScope.DocumentFilter);
    final Operator operator;
    if (widgetType.isText()) {
        operator = Operator.LIKE_I;
    } else if (filteringInfo.isRangeFilter()) {
        operator = Operator.BETWEEN;
    } else {
        operator = Operator.EQUAL;
    }
    return DocumentFilterParamDescriptor.builder().setDisplayName(displayName).setFieldName(fieldName).setWidgetType(widgetType).setOperator(operator).setLookupDescriptor(lookupDescriptor).setMandatory(false).setShowIncrementDecrementButtons(filteringInfo.isShowFilterIncrementButtons()).setAutoFilterInitialValue(filteringInfo.getAutoFilterInitialValue());
}
Also used : Operator(de.metas.ui.web.document.filter.DocumentFilterParam.Operator) DocumentFieldDefaultFilterDescriptor(de.metas.ui.web.window.descriptor.DocumentFieldDefaultFilterDescriptor) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) ITranslatableString(de.metas.i18n.ITranslatableString) ITranslatableString(de.metas.i18n.ITranslatableString) LookupDescriptor(de.metas.ui.web.window.descriptor.LookupDescriptor)

Example 14 with ITranslatableString

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

the class HUsToPickViewBasedProcess method checkPreconditionsApplicable.

@Override
public ProcessPreconditionsResolution checkPreconditionsApplicable() {
    final Optional<HUEditorRow> anyHU = retrieveEligibleHUEditorRows().findAny();
    if (anyHU.isPresent()) {
        return ProcessPreconditionsResolution.accept();
    }
    final ITranslatableString reason = Services.get(IMsgBL.class).getTranslatableMsgText(MSG_WEBUI_SELECT_ACTIVE_UNSELECTED_HU);
    return ProcessPreconditionsResolution.reject(reason);
}
Also used : IMsgBL(de.metas.i18n.IMsgBL) ITranslatableString(de.metas.i18n.ITranslatableString) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow)

Example 15 with ITranslatableString

use of de.metas.i18n.ITranslatableString 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)

Aggregations

ITranslatableString (de.metas.i18n.ITranslatableString)26 ImmutableTranslatableString (de.metas.i18n.ImmutableTranslatableString)9 IMsgBL (de.metas.i18n.IMsgBL)8 IModelTranslationMap (de.metas.i18n.IModelTranslationMap)5 DocumentFieldWidgetType (de.metas.ui.web.window.descriptor.DocumentFieldWidgetType)4 NumberTranslatableString (de.metas.i18n.NumberTranslatableString)3 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)3 LookupDescriptor (de.metas.ui.web.window.descriptor.LookupDescriptor)3 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 DateTimeTranslatableString (de.metas.i18n.DateTimeTranslatableString)2 BoardFieldLoader (de.metas.ui.web.board.BoardCardFieldDescriptor.BoardFieldLoader)2 WindowConstants (de.metas.ui.web.window.WindowConstants)2 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)2 LookupValue (de.metas.ui.web.window.datatypes.LookupValue)2 IntegerLookupValue (de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue)2 WindowId (de.metas.ui.web.window.datatypes.WindowId)2 DocumentFieldDescriptor (de.metas.ui.web.window.descriptor.DocumentFieldDescriptor)2