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);
}
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;
}
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));
}
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;
}
Aggregations