List of usage examples for org.dom4j DocumentFactory getInstance
public static synchronized DocumentFactory getInstance()
From source file:org.onosproject.xmpp.core.ctl.handlers.XmppDecoder.java
License:Apache License
@Override protected void decode(ChannelHandlerContext channelHandlerContext, Object object, List out) throws Exception { if (object instanceof Element) { Element root = (Element) object; try {//w w w . j av a 2 s . c o m Packet packet = recognizeAndReturnXmppPacket(root); validate(packet); out.add(packet); } catch (UnsupportedStanzaTypeException e) { throw e; } catch (Exception e) { throw new XmppValidationException(false); } } else if (object instanceof XMLEvent) { XMLEvent event = (XMLEvent) object; if (event.isStartElement()) { final StartElement element = event.asStartElement(); if (element.getName().getLocalPart().equals(XmppConstants.STREAM_QNAME)) { DocumentFactory df = DocumentFactory.getInstance(); QName qname = (element.getName().getPrefix() == null) ? df.createQName(element.getName().getLocalPart(), element.getName().getNamespaceURI()) : df.createQName(element.getName().getLocalPart(), element.getName().getPrefix(), element.getName().getNamespaceURI()); Element newElement = df.createElement(qname); Iterator nsIt = element.getNamespaces(); // add all relevant XML namespaces to Element while (nsIt.hasNext()) { Namespace ns = (Namespace) nsIt.next(); newElement.addNamespace(ns.getPrefix(), ns.getNamespaceURI()); } Iterator attrIt = element.getAttributes(); // add all attributes to Element while (attrIt.hasNext()) { Attribute attr = (Attribute) attrIt.next(); newElement.addAttribute(attr.getName().getLocalPart(), attr.getValue()); } XmppStreamOpen xmppStreamOpen = new XmppStreamOpen(newElement); validator.validateStream(xmppStreamOpen); out.add(xmppStreamOpen); } } else if (event.isEndElement()) { out.add(new XmppStreamClose()); } } }
From source file:org.opencms.setup.xml.v8.CmsXmlUpdateMenuRules.java
License:Open Source License
/** * Creates a menu item rule element.<p> * /*from w w w. j a v a2 s. c om*/ * @param cls the class for the menu item rule * * @return the menu item rule element */ private Element createMenuItemRule(String cls) { Element mirElem = DocumentFactory.getInstance().createElement(CmsWorkplaceConfiguration.N_MENUITEMRULE); mirElem.addAttribute(I_CmsXmlConfiguration.A_CLASS, cls); return mirElem; }
From source file:org.openxml4j.opc.signature.RelationshipTransform.java
License:Apache License
@SuppressWarnings("unchecked") public static void RemoveAllNameSpacesExceptRelationship(Element elem) { // if the default namespace is not correct or if it has a prefix // fix it by setting to correct value without prefix if (elem.getNamespace().getStringValue() != PackageNamespaces.RELATIONSHIPS || elem.getNamespace().getPrefix() != "") { elem.setQName(new QName(elem.getName(), DocumentFactory.getInstance().createNamespace("", PackageNamespaces.RELATIONSHIPS))); }/*from w ww .ja v a 2 s .co m*/ // remove all additional namespace declarations List<Namespace> additionalNameSpaces = elem.additionalNamespaces(); for (Namespace nms : additionalNameSpaces) { elem.remove(nms); } }
From source file:org.pentaho.aggdes.model.ssas.ConversionUtil.java
License:Open Source License
public static List<Document> generateMondrianDocsFromSSASSchema(final InputStream input) throws DocumentException, IOException, AggDesignerException { Document ssasDocument = parseAssl(input); // issue: if we have multi-line text, there is a problem with identing names / etc // solution: clean up the dom before traversal List allElements = ssasDocument.selectNodes("//*"); for (int i = 0; i < allElements.size(); i++) { Element element = (Element) allElements.get(i); element.setText(element.getText().replaceAll("[\\s]+", " ").trim()); }// ww w. j a va 2 s . c o m List ssasDatabases = ssasDocument.selectNodes("//assl:Database"); List<Document> mondrianDocs = new ArrayList<Document>(ssasDatabases.size()); for (int i = 0; i < ssasDatabases.size(); i++) { Document mondrianDoc = DocumentFactory.getInstance().createDocument(); Element mondrianSchema = DocumentFactory.getInstance().createElement("Schema"); mondrianDoc.add(mondrianSchema); Element ssasDatabase = (Element) ssasDatabases.get(i); mondrianSchema.add(DocumentFactory.getInstance().createAttribute(mondrianSchema, "name", getXPathNodeText(ssasDatabase, "assl:Name"))); populateCubes(mondrianSchema, ssasDatabase); mondrianDocs.add(mondrianDoc); } return mondrianDocs; }
From source file:org.pentaho.aggdes.model.ssas.ConversionUtil.java
License:Open Source License
private static void populateCubes(Element mondrianSchema, Element ssasDatabase) throws AggDesignerException { List allMeasureGroups = ssasDatabase .selectNodes("assl:Cubes/assl:Cube/assl:MeasureGroups/assl:MeasureGroup"); Map<String, List<Table>> dataSourceViews = new HashMap<String, List<Table>>(); for (int i = 0; i < allMeasureGroups.size(); i++) { Element ssasMeasureGroup = (Element) allMeasureGroups.get(i); String measureGroupName = getXPathNodeText(ssasMeasureGroup, "assl:Name"); if (isVirtualMeasureGroup(ssasMeasureGroup)) { String cubeName = getXPathNodeText(ssasMeasureGroup, "../../assl:Name"); logger.debug("Skipping SSAS Virtual Cube, Measure Group " + cubeName + ", " + measureGroupName); } else {/*from w w w . j a v a 2 s . co m*/ Element mondrianCube = DocumentFactory.getInstance().createElement("Cube"); mondrianCube.addAttribute("name", measureGroupName); String dataSourceViewID = getXPathNodeText(ssasMeasureGroup, "../../assl:Source/assl:DataSourceViewID").toLowerCase(); List<Table> allTables = dataSourceViews.get(dataSourceViewID); if (allTables == null) { Element ssasDataSourceView = (Element) ssasDatabase.selectSingleNode( "assl:DataSourceViews/assl:DataSourceView[translate(assl:ID, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')='" + dataSourceViewID + "']/assl:Schema/xs:schema/xs:element"); allTables = generateStarModels(ssasDataSourceView); dataSourceViews.put(dataSourceViewID, allTables); } // add fact table String factTableName = getXPathNodeText(ssasMeasureGroup, "assl:Measures/assl:Measure/assl:Source/assl:Source/assl:TableID"); Table factTable = findTable(allTables, factTableName); if (factTable == null) { logger.error("Failed to locate fact table: " + factTableName); } // view or table if (factTable.queryDefinition != null) { Element fact = DocumentFactory.getInstance().createElement("View"); fact.addAttribute("alias", factTable.dbName); Element sql = DocumentFactory.getInstance().createElement("SQL"); sql.addAttribute("dialect", "generic"); sql.add(DocumentFactory.getInstance().createCDATA(factTable.queryDefinition)); fact.add(sql); mondrianCube.add(fact); } else { Element fact = DocumentFactory.getInstance().createElement("Table"); if (factTable.dbSchemaName != null && factTable.dbSchemaName.trim().length() != 0) { fact.addAttribute("schema", factTable.dbSchemaName); } fact.addAttribute("name", factTable.dbName); mondrianCube.add(fact); } // add dimensions populateDimensions(mondrianCube, ssasDatabase, ssasMeasureGroup, factTable, allTables); // add measures populateCubeMeasures(mondrianCube, ssasMeasureGroup, factTable, measureGroupName); // add cube mondrianSchema.add(mondrianCube); } } }
From source file:org.pentaho.aggdes.model.ssas.ConversionUtil.java
License:Open Source License
private static void populateDimensions(Element mondrianCube, Element ssasDatabase, Element ssasMeasureGroup, Table factTable, List<Table> allTables) throws AggDesignerException { // add dimensions List measureDimensions = ssasMeasureGroup.selectNodes("assl:Dimensions/assl:Dimension"); for (int j = 0; j < measureDimensions.size(); j++) { Element measureDimension = (Element) measureDimensions.get(j); String cubeDimensionId = getXPathNodeText(measureDimension, "assl:CubeDimensionID"); Element cubeDimension = (Element) ssasMeasureGroup .selectSingleNode("../../assl:Dimensions/assl:Dimension[assl:ID='" + cubeDimensionId + "']"); String databaseDimensionId = getXPathNodeText(cubeDimension, "assl:DimensionID"); Element databaseDimension = (Element) ssasDatabase .selectSingleNode("assl:Dimensions/assl:Dimension[assl:ID='" + databaseDimensionId + "']"); Element mondrianDimension = DocumentFactory.getInstance().createElement("Dimension"); String dimensionName = getXPathNodeText(cubeDimension, "assl:Name"); mondrianDimension.addAttribute("name", dimensionName); // locate the key attribute Element keyAttribute = (Element) databaseDimension .selectSingleNode("assl:Attributes/assl:Attribute[assl:Usage='Key']"); String keyAttributeID = getXPathNodeText(keyAttribute, "assl:ID"); String foreignKey = null; // first look in the dimension object within the measures List nodes = measureDimension.selectNodes("assl:Attributes/assl:Attribute[assl:AttributeID='" + keyAttributeID + "']/assl:KeyColumns/assl:KeyColumn/assl:Source/assl:TableID"); if (nodes.size() > 1) { logger.warn("(1) Key Column foreign key contains more than one column in dimension " + dimensionName + ", SKIPPING DIMENSION"); continue; }/* w w w .j a v a 2s . com*/ Element keyTableObject = (Element) measureDimension .selectSingleNode("assl:Attributes/assl:Attribute[assl:AttributeID='" + keyAttributeID + "']/assl:KeyColumns/assl:KeyColumn/assl:Source/assl:TableID"); if (keyTableObject == null) { keyTableObject = (Element) keyAttribute .selectSingleNode("assl:KeyColumns/assl:KeyColumn/assl:Source/assl:TableID"); nodes = keyAttribute.selectNodes("assl:KeyColumns/assl:KeyColumn/assl:Source/assl:TableID"); if (nodes.size() > 1) { logger.warn("(2) Key Column foreign key contains more than one column in dimension " + dimensionName + ", SKIPPING DIMENSION"); continue; } } if (keyTableObject != null) { String tableID = keyTableObject.getTextTrim(); List<Table> tables = findTables(allTables, tableID); for (Table table : tables) { if (table == factTable) { Element keyColumnObject = (Element) measureDimension.selectSingleNode( "assl:Attributes/assl:Attribute[assl:AttributeID='" + keyAttributeID + "']/assl:KeyColumns/assl:KeyColumn/assl:Source/assl:ColumnID"); if (keyColumnObject == null) { keyColumnObject = (Element) keyAttribute .selectSingleNode("assl:KeyColumns/assl:KeyColumn/assl:Source/assl:ColumnID"); } foreignKey = keyColumnObject.getTextTrim(); break; } Key foreignKeyObject = table.getFactForeignKey(factTable); if (foreignKeyObject != null) { if (foreignKeyObject.columns.size() > 1) { logger.warn("FOREIGN KEY " + foreignKeyObject + " CONTAINS MORE THAN ONE COLUMN IN DIMENSION " + dimensionName); } else { foreignKey = foreignKeyObject.columns.get(0); if (foreignKey != null) { break; } } } } } else { logger.warn("FAILED TO FIND FOREIGN KEY!"); } if (foreignKey == null) { logger.warn("FAILED TO FIND FOREIGN KEY. Excluding Dimension " + dimensionName); continue; } Column foreignKeyObject = factTable.findColumn(foreignKey); mondrianDimension.addAttribute("foreignKey", foreignKeyObject.dbName); // get hierarchies populateHierarchies(mondrianDimension, cubeDimension, databaseDimension, keyAttribute, factTable, allTables, foreignKey); mondrianCube.add(mondrianDimension); } }
From source file:org.pentaho.aggdes.model.ssas.ConversionUtil.java
License:Open Source License
private static void populateHierarchies(Element mondrianDimension, Element ssasCubeDimension, Element ssasDatabaseDimension, Element ssasDimensionKeyAttribute, Table factTable, List<Table> allTables, String factForeignKey) throws AggDesignerException { // first do parent child hierarchies // for each attribute in cube dimension, see if it's database dimension attribute is USAGE PARENT // SSAS 2005 only supports one parent child hierarchy per dimension List cubeAttributes = ssasCubeDimension.selectNodes("assl:Attributes/assl:Attribute"); for (int i = 0; i < cubeAttributes.size(); i++) { Element cubeAttribute = (Element) cubeAttributes.get(i); // retrieve database attribute String attribID = getXPathNodeText(cubeAttribute, "assl:AttributeID"); Element databaseAttribute = (Element) ssasDatabaseDimension .selectSingleNode("assl:Attributes/assl:Attribute[assl:ID='" + attribID + "']"); Element usageElement = (Element) databaseAttribute.selectSingleNode("assl:Usage"); if (usageElement != null && "Parent".equals(usageElement.getTextTrim())) { populateParentChildHierarchy(mondrianDimension, databaseAttribute, ssasDimensionKeyAttribute, ssasDatabaseDimension, factTable, factForeignKey, allTables, attribID); }/*from w ww . jav a 2 s .co m*/ } // handle the traditional hierarchies List hierarchies = ssasCubeDimension.selectNodes("assl:Hierarchies/assl:Hierarchy"); for (int k = 0; k < hierarchies.size(); k++) { Element hierarchy = (Element) hierarchies.get(k); String databaseHierarchyID = getXPathNodeText(hierarchy, "assl:HierarchyID"); Element databaseHierarchy = (Element) ssasDatabaseDimension .selectSingleNode("assl:Hierarchies/assl:Hierarchy[assl:ID='" + databaseHierarchyID + "']"); if (databaseHierarchy == null) { throw new AggDesignerException("Failed to locate hierarchy " + databaseHierarchyID); } Element mondrianHierarchy = DocumentFactory.getInstance().createElement("Hierarchy"); mondrianHierarchy.addAttribute("name", getXPathNodeText(databaseHierarchy, "assl:Name")); String tableID = getXPathNodeText(ssasDimensionKeyAttribute, "assl:KeyColumns/assl:KeyColumn/assl:Source/assl:TableID"); Table primaryKeyTable = findTable(allTables, tableID); String primaryKey = getXPathNodeText(ssasDimensionKeyAttribute, "assl:KeyColumns/assl:KeyColumn/assl:Source/assl:ColumnID"); Column primaryKeyColumn = primaryKeyTable.findColumn(primaryKey); mondrianHierarchy.addAttribute("primaryKey", primaryKeyColumn.dbName); Element allMemberName = (Element) databaseHierarchy.selectSingleNode("assl:AllMemberName"); if (allMemberName != null && allMemberName.getTextTrim().length() != 0) { mondrianHierarchy.addAttribute("allMemberName", allMemberName.getTextTrim()); mondrianHierarchy.addAttribute("hasAll", "true"); } else { mondrianHierarchy.addAttribute("hasAll", "false"); } // determine if this hierarchy is a snow flake // we can tell this by looking at the levels // preprocess levels to determine snowflake-ness List ssasLevels = databaseHierarchy.selectNodes("assl:Levels/assl:Level"); List<String> tables = new ArrayList<String>(); for (int l = 0; l < ssasLevels.size(); l++) { Element level = (Element) ssasLevels.get(l); String sourceAttribID = getXPathNodeText(level, "assl:SourceAttributeID"); Element sourceAttribute = (Element) ssasDatabaseDimension .selectSingleNode("assl:Attributes/assl:Attribute[assl:ID='" + sourceAttribID + "']"); String levelTableID = getXPathNodeText(sourceAttribute, "assl:NameColumn/assl:Source/assl:TableID"); if (!tables.contains(levelTableID)) { // insert the table in the correct order tables.add(0, levelTableID); } } // skip if degenerate dimension if (tables.size() != 1 || !tables.get(0).equals(factTable.logicalName)) { populateHierarchyRelation(mondrianHierarchy, tables, ssasDatabaseDimension, factTable, allTables, databaseHierarchyID, factForeignKey); } else { mondrianHierarchy.add(DocumentFactory.getInstance().createComment("Degenerate Hierarchy")); } // render levels populateHierarchyLevels(mondrianHierarchy, ssasLevels, ssasDatabaseDimension, allTables, tables.size() > 1); mondrianDimension.add(mondrianHierarchy); } // finally, do attribute hierarchies populateAttributeHierarchies(mondrianDimension, cubeAttributes, ssasDatabaseDimension, ssasDimensionKeyAttribute, factTable, factForeignKey, allTables); }
From source file:org.pentaho.aggdes.model.ssas.ConversionUtil.java
License:Open Source License
/** * generates <Hierarchy> mondrian tags *///from ww w. ja va 2 s . c o m private static void populateHierarchyRelation(Element mondrianHierarchy, List<String> tables, Element ssasDatabaseDimension, Table factTable, List<Table> allTables, String ssasHierarchyID, String factForeignKey) throws AggDesignerException { // we should specify the foreign key here also Table currentTable = factTable.findBranchWithTables(tables, factTable.logicalName, factForeignKey); if (currentTable == null) { currentTable = findFragmentWithTables(tables, allTables, factForeignKey); if (currentTable == null) { throw new AggDesignerException("Error: " + ssasHierarchyID + " star schema branch not found. " + factTable.logicalName + "." + factForeignKey); } currentTable.getRoot().parentJoin = new Join(factTable, new Key(factForeignKey), currentTable, new Key(factForeignKey)); logger.debug("IMPLICIT STAR JOIN FOR " + currentTable.logicalName + "." + factForeignKey + " to " + factTable.logicalName + "." + factForeignKey); } Element currentHierarchyRelation = null; if (currentTable.queryDefinition != null) { currentHierarchyRelation = DocumentFactory.getInstance().createElement("View"); currentHierarchyRelation.addAttribute("alias", currentTable.dbName); Element sql = DocumentFactory.getInstance().createElement("SQL"); sql.addAttribute("dialect", "generic"); sql.add(DocumentFactory.getInstance().createCDATA(currentTable.queryDefinition)); currentHierarchyRelation.add(sql); } else { currentHierarchyRelation = DocumentFactory.getInstance().createElement("Table"); if (currentTable.dbSchemaName != null && currentTable.dbSchemaName.trim().length() != 0) { currentHierarchyRelation.addAttribute("schema", currentTable.dbSchemaName); } currentHierarchyRelation.addAttribute("name", currentTable.dbName); } // expand tables so that explicit naming of tables when rendering levels is known if (!tables.contains(currentTable.logicalName)) { tables.add(currentTable.logicalName); } while (!currentTable.parentJoin.parentTable.logicalName.equals(factTable.logicalName)) { Element hierarchyRelation = DocumentFactory.getInstance().createElement("Join"); Element tableRelation = null; if (currentTable.queryDefinition != null) { tableRelation = DocumentFactory.getInstance().createElement("View"); tableRelation.addAttribute("alias", currentTable.dbName); Element sql = DocumentFactory.getInstance().createElement("SQL"); sql.addAttribute("dialect", "generic"); sql.add(DocumentFactory.getInstance().createCDATA(currentTable.queryDefinition)); tableRelation.add(sql); } else { tableRelation = DocumentFactory.getInstance().createElement("Table"); if (currentTable.parentJoin.parentTable.dbSchemaName != null && currentTable.parentJoin.parentTable.dbSchemaName.trim().length() != 0) { tableRelation.addAttribute("schema", currentTable.parentJoin.parentTable.dbSchemaName); } tableRelation.addAttribute("name", currentTable.parentJoin.parentTable.dbName); } if (!tables.contains(currentTable.parentJoin.parentTable.logicalName)) { tables.add(currentTable.parentJoin.parentTable.logicalName); } hierarchyRelation.addAttribute("leftKey", currentTable.parentJoin.parentKeyObject.columns.get(0)); hierarchyRelation.addAttribute("rightKey", currentTable.parentJoin.childKeyObject.columns.get(0)); hierarchyRelation.add(tableRelation); hierarchyRelation.add(currentHierarchyRelation); currentHierarchyRelation = hierarchyRelation; currentTable = currentTable.parentJoin.parentTable; } if (currentHierarchyRelation.getName().equals("Join")) { mondrianHierarchy.addAttribute("primaryKeyTable", currentTable.dbName); } mondrianHierarchy.add(currentHierarchyRelation); }
From source file:org.pentaho.aggdes.model.ssas.ConversionUtil.java
License:Open Source License
/** * generates <Level> mondrian tags *///from w w w . j av a 2 s . co m private static void populateHierarchyLevels(Element mondrianHierarchy, List ssasLevels, Element ssasDatabaseDimension, List<Table> allTables, boolean includeTableName) throws AggDesignerException { for (int l = 0; l < ssasLevels.size(); l++) { Element level = (Element) ssasLevels.get(l); Element mondrianLevel = DocumentFactory.getInstance().createElement("Level"); mondrianLevel.addAttribute("name", getXPathNodeText(level, "assl:Name")); String sourceAttribID = getXPathNodeText(level, "assl:SourceAttributeID"); Element sourceAttribute = (Element) ssasDatabaseDimension .selectSingleNode("assl:Attributes/assl:Attribute[assl:ID='" + sourceAttribID + "']"); Element keyUniquenessGuarantee = (Element) sourceAttribute .selectSingleNode("assl:KeyUniquenessGuarantee"); boolean keyUniqueness = false; if (keyUniquenessGuarantee != null) { keyUniqueness = "true".equals(keyUniquenessGuarantee.getTextTrim()); } mondrianLevel.addAttribute("uniqueMembers", "" + keyUniqueness); String levelTableID = getXPathNodeText(sourceAttribute, "assl:NameColumn/assl:Source/assl:TableID"); Table levelTable = findTable(allTables, levelTableID); if (includeTableName) { mondrianLevel.addAttribute("table", levelTable.dbName); // tableName); } // don't assume single column for keys List<Element> nodes = (List<Element>) sourceAttribute .selectNodes("assl:KeyColumns/assl:KeyColumn/assl:Source/assl:ColumnID"); // get the last key column in the list. String keyColumn = nodes.get(nodes.size() - 1).getTextTrim(); // String keyColumn = getXPathNodeText(sourceAttribute, "assl:KeyColumns/assl:KeyColumn/assl:Source/assl:ColumnID"); String nameColumn = getXPathNodeText(sourceAttribute, "assl:NameColumn/assl:Source/assl:ColumnID"); if (keyColumn == null || keyColumn.equals(nameColumn)) { Column nameColumnObj = levelTable.findColumn(nameColumn); nameColumnObj.addToMondrian(mondrianLevel, "column", "KeyExpression"); } else { Column keyColumnObj = levelTable.findColumn(keyColumn); keyColumnObj.addToMondrian(mondrianLevel, "column", "KeyExpression"); Column nameColumnObj = levelTable.findColumn(nameColumn); nameColumnObj.addToMondrian(mondrianLevel, "nameColumn", "NameExpression"); } String datatype = getXPathNodeText(sourceAttribute, "assl:NameColumn/assl:DataType"); // TODO: create example with numeric column, // this code is more stubbed then tested if (datatype.equals("Numeric")) { mondrianLevel.addAttribute("type", "Numeric"); } mondrianHierarchy.add(mondrianLevel); } }
From source file:org.pentaho.aggdes.model.ssas.ConversionUtil.java
License:Open Source License
/** * generates parent child hierarchy// w ww . j a v a 2 s. co m */ private static void populateParentChildHierarchy(Element mondrianDimension, Element databaseAttribute, Element ssasDimensionKeyAttribute, Element ssasDatabaseDimension, Table factTable, String factForeignKey, List<Table> allTables, String attributeID) throws AggDesignerException { mondrianDimension.add(DocumentFactory.getInstance().createComment("Parent Child Hierarchy")); Element mondrianHierarchy = DocumentFactory.getInstance().createElement("Hierarchy"); mondrianHierarchy.addAttribute("name", getXPathNodeText(databaseAttribute, "assl:Name")); String tableID = getXPathNodeText(ssasDimensionKeyAttribute, "assl:KeyColumns/assl:KeyColumn/assl:Source/assl:TableID"); String keyColumnID = getXPathNodeText(ssasDimensionKeyAttribute, "assl:KeyColumns/assl:KeyColumn/assl:Source/assl:ColumnID"); Table table = findTable(allTables, tableID); Column keyColumnObject = table.findColumn(keyColumnID); if (keyColumnObject.expression != null) { logger.warn("Mondrian does not support primary key expressions"); } mondrianHierarchy.addAttribute("primaryKey", keyColumnObject.dbName); // not certain on where to get the all member name for parent / child rels // ssas seems to use "All" for the default name // Element allMemberName = (Element)databaseHierarchy.selectSingleNode("assl:AllMemberName"); // if (allMemberName != null) { mondrianHierarchy.addAttribute("allMemberName", "All"); mondrianHierarchy.addAttribute("hasAll", "true"); // } List<String> tables = new ArrayList<String>(); tables.add(tableID); populateHierarchyRelation(mondrianHierarchy, tables, ssasDatabaseDimension, factTable, allTables, attributeID, factForeignKey); Element mondrianLevel = DocumentFactory.getInstance().createElement("Level"); // <Level name="Employee Id" type="Numeric" uniqueMembers="true" column="employee_id" // parentColumn="supervisor_id" nameColumn="full_name" nullParentValue="0"> // for now, use the hierarchy name for the level name mondrianLevel.addAttribute("name", getXPathNodeText(databaseAttribute, "assl:Name")); // mondrianLevel.addAttribute("type", "Numeric"); mondrianLevel.addAttribute("uniqueMembers", "true"); // NameColumn String parentID = getXPathNodeText(databaseAttribute, "assl:KeyColumns/assl:KeyColumn/assl:Source/assl:ColumnID"); String columnID = getXPathNodeText(databaseAttribute, "assl:NameColumn/assl:Source/assl:ColumnID"); keyColumnObject.addToMondrian(mondrianLevel, "column", "KeyExpression"); Column parentColumnObject = table.findColumn(parentID); parentColumnObject.addToMondrian(mondrianLevel, "parentColumn", "ParentExpression"); Column nameColumnObject = table.findColumn(columnID); nameColumnObject.addToMondrian(mondrianLevel, "nameColumn", "NameExpression"); // do we need ordinal col? // from http://msdn2.microsoft.com/en-us/library/ms174935.aspx // User Defined Hierarchies // By default, any member whose parent key equals its own member key, null, 0 (zero), // or a value absent from the column for member keys is assumed to be a member of the // top level (excluding the (All) level). mondrianLevel.addAttribute("nullParentValue", "0"); mondrianHierarchy.add(mondrianLevel); mondrianDimension.add(mondrianHierarchy); }