@Override public Field createField(ReportInputParameter parameter) { LookupField lookupField = componentsFactory.createComponent(LookupField.class); String enumClassName = parameter.getEnumerationClass(); if (StringUtils.isNotBlank(enumClassName)) { Class enumClass = scripting.loadClass(enumClassName); if (enumClass != null) { Object[] constants = enumClass.getEnumConstants(); List<Object> optionsList = new ArrayList<>(); Collections.addAll(optionsList, constants); lookupField.setOptionsList(optionsList); lookupField.setCaptionMode(CaptionMode.ITEM); if (optionsList.size() < 10) { lookupField.setTextInputAllowed(false); } } } return lookupField; } }
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())); }
@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 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; }