/** * Updates column hint values by given axis attributes. * * @param outputAttrs the latest axis attributes * @param cachedOutputAttrs the last(cached) axis attributes * @param newHint the column hint */ private static void updateColumnHintFromAxisAttrs( AxisAttributes axisAttributes, AxisAttributes cachedAxisAttributes, ColumnHint newHint) { if (axisAttributes == null) return; Object newValue = axisAttributes.getAxisType(); Object oldValue = cachedAxisAttributes == null ? null : cachedAxisAttributes.getAxisType(); if (!CompareUtil.isEquals(oldValue, newValue)) { newHint.setProperty( ColumnHint.ANALYSIS_MEMBER, convertAxisTypeToAnalysisType((AxisType) newValue)); } newValue = axisAttributes.isOnColumnLayout(); oldValue = cachedAxisAttributes == null ? null : cachedAxisAttributes.isOnColumnLayout(); if (!CompareUtil.isEquals(oldValue, newValue)) { newHint.setProperty(ColumnHint.ON_COLUMN_LAYOUT_MEMBER, newValue); } newValue = axisAttributes.getRelatedColumns(); oldValue = cachedAxisAttributes == null ? null : cachedAxisAttributes.getRelatedColumns(); if (!CompareUtil.isEquals(oldValue, newValue)) { String analysisColumnName = null; DataElementIdentifiers columns = ((ResultSubset) newValue).getColumnIdentifiers(); if (columns != null && !columns.getIdentifiers().isEmpty()) analysisColumnName = columns.getIdentifiers().get(0).getName(); newHint.setProperty(ColumnHint.ANALYSIS_COLUMN_MEMBER, analysisColumnName); } }
/** * Updates a oda result set definition. * * @param param */ private void updateOrVerifyResultSetDefinition1(ResultSetDefinition setDefn, boolean update) { List columns = setDefn.getResultSetColumns().getResultColumnDefinitions(); ColumnDefinition column1 = (ColumnDefinition) columns.get(0); ColumnDefinition column2 = (ColumnDefinition) columns.get(1); DataElementAttributes dataAttrs = column1.getAttributes(); DataElementUIHints dataUIHints = dataAttrs.getUiHints(); if (update) dataUIHints.setDisplayName("new display name for column 1"); // $NON-NLS-1$ else assertEquals("new display name for column 1", dataUIHints.getDisplayName()); OutputElementAttributes usageHints = column1.getUsageHints(); if (update) usageHints.setHelpText("new help text for column 1"); // $NON-NLS-1$ else assertEquals("new help text for column 1", usageHints.getHelpText()); // Setting to null object if (update) usageHints.getFormattingHints().setDisplayFormat("new format for column 1"); // $NON-NLS-1$ else assertEquals(null, usageHints.getFormattingHints().getDisplayFormat()); if (update) { AxisAttributes axisAttrs = DesignFactory.eINSTANCE.createAxisAttributes(); axisAttrs.setAxisType(AxisType.DIMENSION_MEMBER_LITERAL); axisAttrs.setOnColumnLayout(false); column1.setMultiDimensionAttributes(axisAttrs); } else { AxisAttributes axisAttrs = column1.getMultiDimensionAttributes(); assertEquals(AxisType.DIMENSION_MEMBER_LITERAL, axisAttrs.getAxisType()); assertFalse(axisAttrs.isOnColumnLayout()); } // new display name and help text, etc. if (update) { dataUIHints = DesignFactory.eINSTANCE.createDataElementUIHints(); dataUIHints.setDisplayName("new display name for column 2"); // $NON-NLS-1$ dataAttrs = column2.getAttributes(); dataAttrs.setUiHints(dataUIHints); } else { dataUIHints = column2.getAttributes().getUiHints(); assertEquals("new display name for column 2", dataUIHints.getDisplayName()); } if (update) { usageHints = DesignFactory.eINSTANCE.createOutputElementAttributes(); usageHints.setHelpText("new help text for column 2"); // $NON-NLS-1$ ValueFormatHints format = DesignFactory.eINSTANCE.createValueFormatHints(); format.setDisplayFormat("new format for column 2"); // $NON-NLS-1$ usageHints.setFormattingHints(format); column2.setUsageHints(usageHints); } else { usageHints = column2.getUsageHints(); assertEquals("new help text for column 2", usageHints.getHelpText()); ValueFormatHints format = usageHints.getFormattingHints(); assertEquals("new format for column 2", format.getDisplayFormat()); } }