Search in sources :

Example 1 with ProcessInfoParameter

use of de.metas.process.ProcessInfoParameter in project metasfresh-webui-api by metasfresh.

the class ADProcessParametersRepository method createProcessInfoParameter.

private static ProcessInfoParameter createProcessInfoParameter(final IDocumentFieldView field) {
    final String parameterName = field.getFieldName();
    final Object fieldValue = field.getValue();
    final Object parameter;
    final String info;
    final Object parameterTo;
    final String infoTo;
    if (fieldValue instanceof LookupValue) {
        final LookupValue lookupValue = (LookupValue) fieldValue;
        parameter = lookupValue.getId();
        info = lookupValue.getDisplayName();
        parameterTo = null;
        infoTo = null;
    } else if (fieldValue instanceof DateRangeValue) {
        final DateRangeValue dateRange = (DateRangeValue) fieldValue;
        parameter = dateRange.getFrom();
        info = parameter == null ? null : parameter.toString();
        parameterTo = dateRange.getTo();
        infoTo = parameterTo == null ? null : parameterTo.toString();
    } else if (fieldValue instanceof Password) {
        final Password password = Password.cast(fieldValue);
        parameter = password.getAsString();
        info = Password.OBFUSCATE_STRING;
        parameterTo = null;
        infoTo = null;
    } else {
        parameter = fieldValue;
        info = fieldValue == null ? null : fieldValue.toString();
        parameterTo = null;
        infoTo = null;
    }
    return new ProcessInfoParameter(parameterName, parameter, parameterTo, info, infoTo);
}
Also used : DateRangeValue(de.metas.ui.web.window.datatypes.DateRangeValue) ProcessInfoParameter(de.metas.process.ProcessInfoParameter) LookupValue(de.metas.ui.web.window.datatypes.LookupValue) Password(de.metas.ui.web.window.datatypes.Password)

Example 2 with ProcessInfoParameter

use of de.metas.process.ProcessInfoParameter in project metasfresh-webui-api by metasfresh.

the class ADProcessParametersRepository method retrieveProcessInfoParameters.

private final Map<String, ProcessInfoParameter> retrieveProcessInfoParameters(final DocumentId adPInstanceId) {
    final Properties ctx = Env.getCtx();
    final Map<String, ProcessInfoParameter> processInfoParameters = adPInstanceDAO.retrieveProcessInfoParameters(ctx, adPInstanceId.toInt()).stream().collect(GuavaCollectors.toImmutableMapByKey(ProcessInfoParameter::getParameterName));
    return processInfoParameters;
}
Also used : ProcessInfoParameter(de.metas.process.ProcessInfoParameter) Properties(java.util.Properties)

Example 3 with ProcessInfoParameter

use of de.metas.process.ProcessInfoParameter in project metasfresh-webui-api by metasfresh.

the class ADProcessParametersRepository method refresh.

@Override
public void refresh(final Document processParameters) {
    final DocumentId adPInstanceId = processParameters.getDocumentId();
    final Map<String, ProcessInfoParameter> processInfoParameters = retrieveProcessInfoParameters(adPInstanceId);
    processParameters.refreshFromSupplier(new ProcessInfoParameterDocumentValuesSupplier(adPInstanceId, processInfoParameters));
}
Also used : ProcessInfoParameter(de.metas.process.ProcessInfoParameter) DocumentId(de.metas.ui.web.window.datatypes.DocumentId)

Example 4 with ProcessInfoParameter

use of de.metas.process.ProcessInfoParameter in project metasfresh-webui-api by metasfresh.

the class ADProcessParametersRepository method extractParameterValue.

private static Object extractParameterValue(final Map<String, ProcessInfoParameter> processInfoParameters, final DocumentFieldDescriptor parameterDescriptor) {
    final String fieldName = parameterDescriptor.getFieldName();
    final ProcessInfoParameter processInfoParameter = processInfoParameters.get(fieldName);
    if (processInfoParameter == null) {
        return null;
    }
    final Object parameterValue = processInfoParameter.getParameter();
    final String parameterDisplay = processInfoParameter.getInfo();
    final Object parameterValueConv = parameterDescriptor.convertToValueClass(parameterValue, new LookupValueByIdSupplier() {

        @Override
        public DocumentZoomIntoInfo getDocumentZoomInto(final int id) {
            throw new UnsupportedOperationException();
        }

        @Override
        public LookupValue findById(final Object id) {
            return LookupValue.fromObject(id, parameterDisplay);
        }
    });
    return parameterValueConv;
}
Also used : ProcessInfoParameter(de.metas.process.ProcessInfoParameter) DocumentZoomIntoInfo(de.metas.ui.web.window.model.lookup.DocumentZoomIntoInfo) LookupValueByIdSupplier(de.metas.ui.web.window.model.lookup.LookupValueByIdSupplier) LookupValue(de.metas.ui.web.window.datatypes.LookupValue)

Aggregations

ProcessInfoParameter (de.metas.process.ProcessInfoParameter)4 LookupValue (de.metas.ui.web.window.datatypes.LookupValue)2 DateRangeValue (de.metas.ui.web.window.datatypes.DateRangeValue)1 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)1 Password (de.metas.ui.web.window.datatypes.Password)1 DocumentZoomIntoInfo (de.metas.ui.web.window.model.lookup.DocumentZoomIntoInfo)1 LookupValueByIdSupplier (de.metas.ui.web.window.model.lookup.LookupValueByIdSupplier)1 Properties (java.util.Properties)1