protected boolean isParameterDateOrTime() { ReportInputParameter parameter = getItem(); return Optional.ofNullable(parameter) .map(reportInputParameter -> ParameterType.DATE.equals(parameter.getType()) || ParameterType.DATETIME.equals(parameter.getType()) || ParameterType.TIME.equals(parameter.getType())) .orElse(false); } }
@Override protected Collection<ReportInputParameter> getCollection() { return super.getCollection().stream() .filter(reportInputParameter -> reportInputParameter.getType().equals(ParameterType.TEXT)) .collect(Collectors.toList()); } }
@Nullable protected Object convertParameterIfNecessary(ReportInputParameter parameter, @Nullable Object paramValue, boolean useForInputParametersForm) { Object resultingParamValue = paramValue; if (ParameterType.ENTITY == parameter.getType()) { if (paramValue instanceof Collection || paramValue instanceof ParameterPrototype) { resultingParamValue = handleCollectionParameter(paramValue, useForInputParametersForm); } } else if (ParameterType.ENTITY_LIST == parameter.getType()) { if (!(paramValue instanceof Collection) && !(paramValue instanceof ParameterPrototype)) { resultingParamValue = Collections.singletonList(paramValue); } else if (paramValue instanceof ParameterPrototype && useForInputParametersForm) { resultingParamValue = handleCollectionParameter(paramValue, false); } } return resultingParamValue; }
protected void initScreensLookup() { ReportInputParameter parameter = getItem(); if (parameter.getType() == ParameterType.ENTITY || parameter.getType() == ParameterType.ENTITY_LIST) { Class clazz = parameterClassResolver.resolveClass(parameter); if (clazz != null) { Map<String, String> screensMap = screensHelper.getAvailableBrowserScreens(clazz); screen.setOptionsMap(screensMap); } } }
@Nullable public Class resolveClass(ReportInputParameter parameter) { Class aClass = primitiveParameterTypeMapping.get(parameter.getType()); if (aClass == null) { if (parameter.getType() == ParameterType.ENTITY || parameter.getType() == ParameterType.ENTITY_LIST) { MetaClass metaClass = metadata.getSession().getClass(parameter.getEntityMetaClass()); if (metaClass != null) { return metaClass.getJavaClass(); } else { return null; } } else if (parameter.getType() == ParameterType.ENUMERATION) { if (StringUtils.isNotBlank(parameter.getEnumerationClass())) { return scripting.loadClass(parameter.getEnumerationClass()); } } } return aClass; }
protected void setCurrentDateAsNow(ReportInputParameter parameter, Field dateField) { Date now = reportService.currentDateOrTime(parameter.getType()); dateField.setValue(now); parameter.setDefaultValue(reportService.convertToString(now.getClass(), now)); }
protected boolean canHaveDefaultValue() { ReportInputParameter parameter = getItem(); if (parameter == null) { return false; } if (isParameterDateOrTime() && BooleanUtils.isTrue(parameter.getDefaultDateIsCurrent())) { return false; } ParameterType type = parameter.getType(); return type != null && type != ParameterType.ENTITY_LIST && (type != ParameterType.ENTITY || StringUtils.isNotBlank(parameter.getEntityMetaClass())) && (type != ParameterType.ENUMERATION || StringUtils.isNotBlank(parameter.getEnumerationClass())); }
protected InputParameterInfo mapInputParameterInfo(ReportInputParameter parameter) { InputParameterInfo inputParameterInfo = new InputParameterInfo(); inputParameterInfo.name = parameter.getName(); inputParameterInfo.alias = parameter.getAlias(); if (parameter.getType() != null) { inputParameterInfo.type = parameter.getType().toString(); } inputParameterInfo.required = Boolean.TRUE.equals(parameter.getRequired()); inputParameterInfo.hidden = Boolean.TRUE.equals(parameter.getHidden()); if (parameter.getEntityMetaClass() != null) { inputParameterInfo.entityMetaClass = parameter.getEntityMetaClass(); } if (parameter.getEnumerationClass() != null) { inputParameterInfo.enumerationClass = parameter.getEnumerationClass(); } return inputParameterInfo; }
@Override protected Map<String, Object> handleParameters(com.haulmont.yarg.structure.Report report, Map<String, Object> params) { Map<String, Object> handledParams = new HashMap<String, Object>(super.handleParameters(report, params)); for (ReportParameter reportParameter : report.getReportParameters()) { if (reportParameter instanceof ReportInputParameter) { ReportInputParameter reportInputParameter = (ReportInputParameter) reportParameter; String paramName = reportParameter.getAlias(); Object paramValue = handledParams.get(paramName); if (BooleanUtils.isTrue(reportInputParameter.getDefaultDateIsCurrent())) { handleDateTimeRelatedParameterAsNow(paramName, paramValue, reportInputParameter.getType(), handledParams); } if (paramValue == null) { continue; } if (reportInputParameter.getPredefinedTransformation() != null) { handledParams.put(paramName, handlePredefinedTransformation(paramValue, reportInputParameter.getPredefinedTransformation())); } else if (!Strings.isNullOrEmpty(reportInputParameter.getTransformationScript())) { handledParams.put(paramName, handleScriptTransformation(paramValue, reportInputParameter.getTransformationScript(), handledParams)); } } } return handledParams; }
reportHasMoreThanOneParameter || inputParametersRequiredByTemplates); boolean reportTypeIsSingleEntity = ParameterType.ENTITY == parameter.getType() && resultingParamValue instanceof Collection; boolean moreThanOneEntitySelected = resultingParamValue instanceof Collection && ((Collection) resultingParamValue).size() > 1;
public Field createField(ReportInputParameter parameter) { Field field = fieldCreationMapping.get(parameter.getType()).createField(parameter); field.setRequiredMessage(messages.formatMessage(this.getClass(), "error.paramIsRequiredButEmpty", parameter.getLocName())); field.setId("param_" + parameter.getAlias()); field.setWidth("100%"); field.setFrame(frame.getWrappedFrame()); field.setEditable(true); field.setRequired(parameter.getRequired()); return field; }
@Override public void setItem(Entity item) { ReportInputParameter newParameter = (ReportInputParameter) metadata.create(parameterDs.getMetaClass()); metadata.getTools().copy(item, newParameter); newParameter.setId((UUID) item.getId()); if (newParameter.getParameterClass() == null) { newParameter.setParameterClass(parameterClassResolver.resolveClass(newParameter)); } super.setItem(newParameter); enableControlsByParamType(newParameter.getType()); initScreensLookup(); initTransformations(); }
protected Object prepareValue(ReportInputParameter inputParam, ParameterValueInfo paramValue) { ParameterType parameterType = inputParam.getType(); if (parameterType == ParameterType.ENTITY) { if (paramValue.value != null) {