/** * Returns the matched oda result set column with the specified name and position. * * @param columns the iterator that includes oda result set columns * @param paramName the result set column name * @param position the position * @return the matched oda result set column */ static OdaResultSetColumnHandle findOdaResultSetColumn( Iterator columns, String paramName, Integer position, Integer nativeDataType, Boolean duplicate) { if (position == null || nativeDataType == null) return null; while (columns.hasNext()) { OdaResultSetColumnHandle column = (OdaResultSetColumnHandle) columns.next(); Integer tmpNativeDataType = column.getNativeDataType(); String nativeName = column.getNativeName(); // if the column name is unique, not necessary to check position if (duplicate == Boolean.FALSE) { if (!StringUtil.isBlank(nativeName) && nativeName.equalsIgnoreCase(paramName) && (tmpNativeDataType == null || nativeDataType.equals(tmpNativeDataType))) { return column; } } // if same column name appears in more than one table or oda native name // is missing, column position needs to be checked if ((StringUtil.isBlank(nativeName) || nativeName.equalsIgnoreCase(paramName)) && (position.equals(column.getPosition())) && (tmpNativeDataType == null || nativeDataType.equals(tmpNativeDataType))) return column; } return null; }
/** * Finds a level by the given qualified name. * * @param elementName * @return the level if found, otherwise null */ public Level findCachedLevel(String elementName) { if (elementName == null) return null; String namespace = StringUtil.extractNamespace(elementName); String name = StringUtil.extractName(elementName); if (namespace == null) return (Level) cachedLevelNames.get(name); Library lib = module.getLibraryWithNamespace(namespace); return lib == null ? null : (Level) ((ModuleNameHelper) lib.getNameHelper()).findCachedLevel(name); }
/** * Gets the dimension with the specified name within this cube. * * @param dimensionName name of the dimension to find * @return dimension within the cube if found, otherwise <code>null</code> */ public DimensionHandle getDimension(String dimensionName) { if (StringUtil.isBlank(dimensionName)) return null; if (!getElement().canDynamicExtends()) { Dimension dimension = module.findDimension(dimensionName); if (dimension == null) return null; if (dimension.isContentOf(getElement())) return (DimensionHandle) dimension.getHandle(module); else { // check the client to find the children of the cube List<BackRef> clients = dimension.getClientList(); if (clients != null) { for (BackRef ref : clients) { DesignElement client = ref.getElement(); if (client.isContentOf(getElement())) return (DimensionHandle) client.getHandle(module); } } } } else if (getElement().getDynamicExtendsElement(getModule()) != null) { Cube cube = (Cube) getElement(); DesignElement element = cube.findLocalElement( dimensionName, MetaDataDictionary.getInstance().getElement(ReportDesignConstants.DIMENSION_ELEMENT)); return (DimensionHandle) (element == null ? null : element.getHandle(module)); } return null; }
/* * (non-Javadoc) * * @see org.eclipse.birt.report.designer.internal.ui.views.actions.GlobalStackAction#getDisplayLabel() */ protected String getDisplayLabel() { String displayLabel = REDO_LABEL; if (!StringUtil.isBlank(stack.getRedoLabel())) { displayLabel += " " + stack.getRedoLabel(); // $NON-NLS-1$ } return displayLabel; }
private List<SemanticException> doValidate(Module module, MasterPage toValidate) { List<SemanticException> list = new ArrayList<SemanticException>(); String type = toValidate.getStringProperty(module, IMasterPageModel.TYPE_PROP); String height = toValidate.getStringProperty(module, IMasterPageModel.HEIGHT_PROP); String width = toValidate.getStringProperty(module, IMasterPageModel.WIDTH_PROP); // if type is CUSTOM type, height and width must be specified. if (DesignChoiceConstants.PAGE_SIZE_CUSTOM.equalsIgnoreCase(type)) { // if type is CUSTOM type, height and width must be specified. if (StringUtil.isBlank(height) || StringUtil.isBlank(width)) { list.add(new SemanticError(toValidate, SemanticError.DESIGN_EXCEPTION_MISSING_PAGE_SIZE)); } } return list; }
/** * Creates a ResultSetDefinition with the given ROM ResultSet columns. * * @return the created ResultSetDefinition */ private ResultSetDefinition newOdaResultSetDefinition() { Iterator romSets = setDefinedResults.iterator(); String name = setHandle.getResultSetName(); if (!romSets.hasNext()) return null; ResultSetDefinition odaSetDefn = null; ResultSetColumns odaSetColumns = null; if (!StringUtil.isBlank(name)) { odaSetDefn = designFactory.createResultSetDefinition(); odaSetDefn.setName(name); } while (romSets.hasNext()) { if (odaSetDefn == null) odaSetDefn = designFactory.createResultSetDefinition(); if (odaSetColumns == null) odaSetColumns = designFactory.createResultSetColumns(); OdaResultSetColumnHandle setColumn = (OdaResultSetColumnHandle) romSets.next(); // get the colum hint ColumnHintHandle hint = AdapterUtil.findColumnHint( (OdaResultSetColumn) setColumn.getStructure(), setDefinedColumnHints.iterator()); ColumnDefinition columnDefn = designFactory.createColumnDefinition(); DataElementAttributes dataAttrs = designFactory.createDataElementAttributes(); String newName = setColumn.getNativeName(); dataAttrs.setName(newName); Integer position = setColumn.getPosition(); if (position != null) dataAttrs.setPosition(setColumn.getPosition().intValue()); Integer nativeDataType = setColumn.getNativeDataType(); if (nativeDataType != null) dataAttrs.setNativeDataTypeCode(nativeDataType.intValue()); columnDefn.setAttributes(dataAttrs); odaSetColumns.getResultColumnDefinitions().add(columnDefn); if (hint == null) continue; updateOdaColumnHint(columnDefn, hint); } if (odaSetDefn != null) odaSetDefn.setResultSetColumns(odaSetColumns); return odaSetDefn; }
/** * Creates unique result set column names if column names are <code>null</code> or empty string. * * @param resultSetColumn a list containing result set columns */ static void createUniqueResultSetColumnNames(List<ResultSetColumnInfo> columnInfo) { if (columnInfo == null || columnInfo.isEmpty()) return; Set<String> names = new HashSet<String>(); for (int i = 0; i < columnInfo.size(); i++) { ResultSetColumnInfo tmpInfo = columnInfo.get(i); OdaResultSetColumn column = tmpInfo.column; String nativeName = column.getNativeName(); if (nativeName != null) names.add(nativeName); } Set<String> newNames = new HashSet<String>(); for (int i = 0; i < columnInfo.size(); i++) { ResultSetColumnInfo tmpInfo = columnInfo.get(i); OdaResultSetColumn column = tmpInfo.column; String nativeName = column.getNativeName(); String name = column.getColumnName(); if (!StringUtil.isBlank(name)) { newNames.add(name); continue; } nativeName = StringUtil.trimString(nativeName); String newName = IdentifierUtility.getUniqueColumnName(names, newNames, nativeName, i); newNames.add(newName); column.setColumnName(newName); if (tmpInfo.hint != null) tmpInfo.hint.setProperty(ColumnHint.COLUMN_NAME_MEMBER, newName); } names.clear(); newNames.clear(); }
/** * Returns the matched oda result set column with the specified name and position. * * @param columns the iterator that includes oda result set columns * @param paramName the result set column name * @param position the position * @return the matched oda result set column */ static OdaResultSetColumnHandle findOdaResultSetColumn( Iterator columns, String paramName, Integer position, Integer nativeDataType) { if (position == null || nativeDataType == null) return null; while (columns.hasNext()) { OdaResultSetColumnHandle column = (OdaResultSetColumnHandle) columns.next(); Integer tmpNativeDataType = column.getNativeDataType(); String nativeName = column.getNativeName(); if ((StringUtil.isBlank(nativeName) || nativeName.equalsIgnoreCase(paramName)) && position.equals(column.getPosition()) && (tmpNativeDataType == null || nativeDataType.equals(tmpNativeDataType))) return column; } return null; }
/** * Gets the measure with the specified name within this cube. * * @param measureName name of the measure to find * @return measure within the cube if found, otherwise <code>null</code> */ public MeasureHandle getMeasure(String measureName) { if (StringUtil.isBlank(measureName)) return null; if (!getElement().canDynamicExtends()) { DesignElement measure = module.findOLAPElement(measureName); if (measure instanceof Measure && measure.isContentOf(getElement())) return (MeasureHandle) measure.getHandle(module); } else if (getElement().getDynamicExtendsElement(getModule()) != null) { Cube cube = (Cube) getElement(); DesignElement element = cube.findLocalElement( measureName, MetaDataDictionary.getInstance().getElement(ReportDesignConstants.MEASURE_ELEMENT)); return (MeasureHandle) (element == null ? null : element.getHandle(module)); } return null; }
protected void outwardUpdate() { String displayText = controlTypeChooser.getText(); if (StringUtil.isBlank(displayText)) { return; } if (ParameterDialog.DISPLAY_NAME_CONTROL_COMBO.equals(displayText)) { this.setProperty(ParameterDialog.CONTROLTYPE_VALUE, ParameterDialog.PARAM_CONTROL_COMBO); return; } if (ParameterDialog.DISPLAY_NAME_CONTROL_LIST.equals(displayText)) { this.setProperty(ParameterDialog.CONTROLTYPE_VALUE, ParameterDialog.PARAM_CONTROL_LIST); return; } this.setProperty( ParameterDialog.CONTROLTYPE_VALUE, CONTROL_TYPE_CHOICE_SET.findChoiceByDisplayName(displayText).getName()); }
/** * Sets the element name. * * @param name the new name. * @throws NameException if the element name is not allowed to change. */ public void setName(String name) throws NameException { name = StringUtil.trimString(name); // Ignore change to the current name. String oldName = element.getName(); if ((name == null && oldName == null) || (name != null && oldName != null && name.equals(oldName))) return; // ignore change to the dimension that refers a shared dimension Dimension sharedDimension = TabularDimensionPropSearchStrategy.getSharedDimension(module, element); if (sharedDimension != null && !sharedDimension.getName().equals(name)) return; checkName(name); DesignElement tmpElement = element; // if a contentElement is not local, need to make a local copy before changing the name if (tmpElement instanceof ContentElement && !((ContentElement) tmpElement).isLocal()) { eventTarget = ((ContentElement) tmpElement).getValueContainer(); tmpElement = copyTopCompositeValue(); } // Record the change. ActivityStack stack = getActivityStack(); NameRecord rename = new NameRecord(tmpElement, name); stack.startTrans(rename.getLabel()); // Drop the old name from the name space. // Change the name. stack.execute(rename); // Add the new name to the name space. renameSymbolFrom(oldName); // change the name of the dimension that shares this element if (element instanceof Dimension) { updateDimensions(stack); } stack.commit(); }
/** * Updates values in report parameter by given ROM data set parameter. * * @param reportParam the report parameter * @param dataSetParam the data set parameter * @param updateDefaultValue the flag which indicates if the default value need to be forced * updated. * @throws SemanticException */ protected void updateLinkedReportParameterFromROMParameter( AbstractScalarParameterHandle reportParam, OdaDataSetParameterHandle dataSetParam, boolean updateDefaultValue) throws SemanticException { assert reportParam != null; if (dataSetParam == null) return; // should not convert report parameter name here. Object defaultValue = dataSetParam.getExpressionProperty(OdaDataSetParameter.DEFAULT_VALUE_MEMBER).getValue(); String paramName = dataSetParam.getParamName(); if (StringUtil.isBlank(paramName)) { dataSetParam.setParamName(reportParam.getName()); } if (updateDefaultValue) setROMDefaultValue(reportParam, defaultValue); }
public boolean validStatus() { return this.getMessageType() != ERROR && !StringUtil.isBlank(nameEditor.getText()) && getSelectedDataSource() != null && getSelectedDataSet() != null; }
public String toString() { if (!StringUtil.isBlank(getName())) return getQualifiedReference(); return super.toString(); }
/** * Updates hint-related information on the ODA <code>columnDefn</code>. * * @param columnDefn * @param hint */ private void updateOdaColumnHint(ColumnDefinition columnDefn, ColumnHintHandle hint) { DataElementAttributes dataAttrs = columnDefn.getAttributes(); DataElementUIHints uiHints = null; // update display name String displayName = hint.getDisplayName(); String displayNameKey = hint.getDisplayNameKey(); if (displayName != null || displayNameKey != null) { uiHints = designFactory.createDataElementUIHints(); uiHints.setDisplayName(displayName); uiHints.setDisplayNameKey(displayNameKey); } // description maps to the description in data element UI hints. // String desc = hint.getDescription( ); // String descKey = hint.getDescriptionKey( ); /* * if ( desc != null || descKey != null ) { if ( uiHints == null ) * uiHints = designFactory.createDataElementUIHints( ); * * uiHints.setDescription( desc ); uiHints.setDescriptionKey( descKey ); * } */ dataAttrs.setUiHints(uiHints); // update usage hints. OutputElementAttributes outputAttrs = null; String helpText = hint.getHelpText(); String helpTextKey = hint.getHelpTextKey(); if (helpText != null || helpTextKey != null) { outputAttrs = designFactory.createOutputElementAttributes(); if (helpText != null || helpTextKey != null) { outputAttrs.setHelpText(helpText); outputAttrs.setHelpTextKey(helpTextKey); } } // heading maps to m_label String heading = hint.getHeading(); String headingKey = hint.getHeadingKey(); if (heading != null || headingKey != null) { if (outputAttrs == null) outputAttrs = designFactory.createOutputElementAttributes(); if (heading != null || headingKey != null) { outputAttrs.setLabel(heading); outputAttrs.setLabelKey(headingKey); } } // formatting related. FormatValue format = hint.getValueFormat(); // int displayLength = hint.getDisplayLength( ); // boolean wordWrap = hint.wordWrap( ); String horizontalAlign = hint.getHorizontalAlign(); if ((format != null && format.getPattern() != null) || horizontalAlign != null) { if (outputAttrs == null) outputAttrs = designFactory.createOutputElementAttributes(); ValueFormatHints formatHint = designFactory.createValueFormatHints(); if (format != null) formatHint.setDisplayFormat(format.getPattern()); // formatHint.setDisplaySize( displayLength ); formatHint.setHorizontalAlignment(convertToOdaHorizontalAlignment(horizontalAlign)); // formatHint.setTextWrapType( convertToROMWordWrap( wordWrap ) ); // cannot handle text format since two objects in ODA and ROM are // different. outputAttrs.setFormattingHints(formatHint); } columnDefn.setUsageHints(outputAttrs); // update axis attributes AxisAttributes axisAttrs = null; String analysisType = hint.getAnalysis(); AxisType axisType = convertAnalysisTypeToAxisType(analysisType); if (axisType != null) { axisAttrs = designFactory.createAxisAttributes(); axisAttrs.setAxisType(axisType); axisAttrs.setOnColumnLayout(hint.isOnColumnLayout()); String analysisColumnName = hint.getAnalysisColumn(); if (!StringUtil.isBlank(analysisColumnName)) { ResultSubset relatedColumns = designFactory.createResultSubset(); relatedColumns.addColumnIdentifier(analysisColumnName); axisAttrs.setRelatedColumns(relatedColumns); } } columnDefn.setMultiDimensionAttributes(axisAttrs); }
/** * Returns the qualified reference of this reference value, which is made up with library * namespace and element name. If no library namespace is available, only element name is * returned. * * <p>For example, * * <ul> * <li>The library namespace is "LibA", and element name is "style1". "LibA.style1" is retured. * <li>If it has no library namespace, * </ul> * * @return the qualified reference */ public String getQualifiedReference() { return StringUtil.buildQualifiedReference(getLibraryNamespace(), getName()); }
/* * (non-Javadoc) * * @see * org.eclipse.birt.report.model.core.namespace.INameHelper#getUniqueName * (org.eclipse.birt.report.model.core.DesignElement, java.lang.String) */ public String getUniqueName(int namespaceId, DesignElement element, String namePrefix) { if (element == null) return null; ElementDefn eDefn = (ElementDefn) element.getDefn(); String name = element.getName(); if (StringUtil.isBlank(name)) { // Use the given prefix if the element name is null name = namePrefix; } name = StringUtil.trimString(name); // replace all the illegal chars with '_' name = NamePropertyType.validateName(name); // Some elements can have a blank name. if (eDefn.getNameOption() == MetaDataConstants.NO_NAME) return null; if (eDefn.getNameOption() == MetaDataConstants.OPTIONAL_NAME && name == null && module instanceof ReportDesign) return null; if (module instanceof Library && element instanceof StyleElement && element.getContainer() == null && name != null) { return name; } // If the element already has a unique name, return it. NameSpace nameSpace = getCachedNameSpace(namespaceId); List<String> cachedContentNames = getCachedContentNames(namespaceId); NameSpace moduleNameSpace = nameContexts[namespaceId].getNameSpace(); String validName = name; if (element instanceof StyleElement) validName = validName == null ? null : validName.toLowerCase(); if (validName != null && isValidInNameSpace(nameSpace, element, validName) && isValidInNameSpace(moduleNameSpace, element, validName) && !cachedContentNames.contains(validName)) return name; // If the element has no name, create it as "New<new name>" where // "<new name>" is the new element display name for the element. Both // "New" and the new element display name are localized to the user's // locale. if (name == null) { // When creating a new report element which requires a name, the // default name will be "New" followed by the element name, such as // "New Label"; also, if "NewLabel" already exists, then a number // will be appended, such as "NewLabel1", etc. if (element instanceof ExtendedItem) { ExtensionElementDefn extDefn = ((ExtendedItem) element).getExtDefn(); PeerExtensionElementDefn peerDefn = (PeerExtensionElementDefn) extDefn; IReportItemFactory peerFactory = peerDefn.getReportItemFactory(); assert peerFactory != null; String extensionDefaultName = null; IMessages msgs = peerFactory.getMessages(); if (msgs != null) extensionDefaultName = msgs.getMessage((String) extDefn.getDisplayNameKey(), module.getLocale()); if (StringUtil.isBlank(extensionDefaultName)) extensionDefaultName = peerDefn.getName(); name = ModelMessages.getMessage(MessageConstants.NAME_PREFIX_NEW_MESSAGE); name = name + extensionDefaultName; } else { name = ModelMessages.getMessage( "New." //$NON-NLS-1$ + element.getDefn().getName()); name = name.trim(); } } // Add a numeric suffix that makes the name unique. int index = 0; String baseName = name; validName = name; if (element instanceof StyleElement) validName = validName == null ? null : validName.toLowerCase(); while (nameSpace.contains(validName) || moduleNameSpace.contains(validName) || cachedContentNames.contains(validName)) { name = baseName + ++index; validName = name; if (element instanceof StyleElement) validName = validName == null ? null : validName.toLowerCase(); } return name; }