/** * Check if the meta class is applicable for the input parameter */ public boolean parameterMatchesMetaClass(ReportInputParameter parameter, MetaClass metaClass) { if (isNotBlank(parameter.getEntityMetaClass())) { MetaClass parameterMetaClass = metadata.getClassNN(parameter.getEntityMetaClass()); return (metaClass.equals(parameterMetaClass) || metaClass.getAncestors().contains(parameterMetaClass)); } else { return false; } }
protected void refreshViewNames(@Nullable ReportInputParameter reportInputParameter) { if (reportInputParameter != null) { if (StringUtils.isNotBlank(reportInputParameter.getEntityMetaClass())) { MetaClass parameterMetaClass = metadata.getClass(reportInputParameter.getEntityMetaClass()); Collection<String> viewNames = metadata.getViewRepository().getViewNames(parameterMetaClass); Map<String, Object> views = new HashMap<>(); for (String viewName : viewNames) { views.put(viewName, viewName); } views.put(View.LOCAL, View.LOCAL); views.put(View.MINIMAL, View.MINIMAL); viewNameLookup.setOptionsMap(views); return; } } viewNameLookup.setOptionsMap(new HashMap<>()); }
CollectionUtils.filter(filteredParams, predicate); if (filteredParams.size() == 1) { return metadata.getClass(filteredParams.get(0).getEntityMetaClass()); } else { return null;
protected void storeIndexFields(Report report) { if (PersistenceHelper.isLoaded(report, "xml")) { StringBuilder entityTypes = new StringBuilder(IDX_SEPARATOR); if (report.getInputParameters() != null) { for (ReportInputParameter parameter : report.getInputParameters()) { if (isNotBlank(parameter.getEntityMetaClass())) { entityTypes.append(parameter.getEntityMetaClass()) .append(IDX_SEPARATOR); } } } report.setInputEntityTypesIdx(entityTypes.length() > 1 ? entityTypes.toString() : null); StringBuilder screens = new StringBuilder(IDX_SEPARATOR); if (report.getReportScreens() != null) { for (ReportScreen reportScreen : report.getReportScreens()) { screens.append(reportScreen.getScreenId()) .append(IDX_SEPARATOR); } } report.setScreensIdx(screens.length() > 1 ? screens.toString() : null); StringBuilder roles = new StringBuilder(IDX_SEPARATOR); if (report.getRoles() != null) { for (Role role : report.getRoles()) { roles.append(role.getId().toString()) .append(IDX_SEPARATOR); } } report.setRolesIdx(roles.length() > 1 ? roles.toString() : null); } }
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; }
@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; }
@Override public Field createField(ReportInputParameter parameter) { PickerField pickerField = componentsFactory.createComponent(PickerField.class); MetaClass entityMetaClass = metadata.getClassNN(parameter.getEntityMetaClass()); pickerField.setMetaClass(entityMetaClass); PickerField.LookupAction pickerLookupAction = pickerField.addLookupAction(); pickerField.addAction(pickerLookupAction); pickerField.addClearAction(); String parameterScreen = parameter.getScreen(); if (StringUtils.isNotEmpty(parameterScreen)) { pickerLookupAction.setLookupScreen(parameterScreen); pickerLookupAction.setLookupScreenParams(Collections.emptyMap()); } else { pickerLookupAction.setLookupScreen(COMMON_LOOKUP_SCREEN_ID); Map<String, Object> params = new HashMap<>(); params.put(CLASS_PARAMETER, entityMetaClass); if (parameter.getReport().getReportType() == ReportType.SIMPLE) { WindowParams.MULTI_SELECT.set(params, false); } pickerLookupAction.setLookupScreenParams(params); } return pickerField; } }
if (parameterType == ParameterType.ENTITY) { if (paramValue.value != null) { MetaClass entityClass = metadata.getClassNN(inputParam.getEntityMetaClass()); checkCanReadEntity(entityClass); Object entityId = getIdFromString(paramValue.value, entityClass); MetaClass entityClass = metadata.getClassNN(inputParam.getEntityMetaClass()); checkCanReadEntity(entityClass); List<Entity> entities = new ArrayList<>();
@Override public Field createField(final ReportInputParameter parameter) { TokenList tokenList = componentsFactory.createComponent(TokenList.class); MetaClass entityMetaClass = metadata.getClassNN(parameter.getEntityMetaClass());