Skip to content

Commit

Permalink
MONDRIAN:
Browse files Browse the repository at this point in the history
* Add "type" attribute to Cell's Value element.
  Now, JPivot can extract values from XMLA_Cell when building chart's dataset.

[git-p4: depot-paths = "//open/mondrian/": change = 3960]
  • Loading branch information
goncha committed Aug 8, 2005
1 parent 2b7cc34 commit 47eadba
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 31 deletions.
36 changes: 30 additions & 6 deletions src/main/mondrian/xmla/XmlaMediator.java
Expand Up @@ -12,6 +12,7 @@
import java.io.IOException;
import java.io.StringReader;
import java.io.Writer;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
Expand Down Expand Up @@ -197,18 +198,24 @@ private void execute(Element execute, SAXHandler saxHandler) {
try {
saxHandler.startElement("ExecuteResponse", new String[] {
"xmlns", XMLA_NS});
saxHandler.startElement("return");
saxHandler.startElement("return", new String[] {
"xmlns:xsi", XSI_NS,
"xmlns:xsd", XSD_NS,});
saxHandler.startElement("root", new String[] {
"xmlns", isDrillThrough ? XMLA_ROWSET_NS : XMLA_MDDATASET_NS});
saxHandler.startElement("xsd:schema", new String[] {
"xmlns:xsd", "http://www.w3.org/2001/XMLSchema"});
"xmlns:xsd", XSD_NS});
// todo: schema definition
saxHandler.endElement();
try {
if (isDrillThrough)
executeDrillThroughQuery(statement.substring(dtOffset + "DRILLTHROUGH".length()), properties).unparse(saxHandler);
else
if (isDrillThrough) {
StringBuffer dtStatement = new StringBuffer();
dtStatement.append(statement.substring(0, dtOffset)); // formulas
dtStatement.append(statement.substring(dtOffset + "DRILLTHROUGH".length())); // select to end
executeDrillThroughQuery(dtStatement.toString(), properties).unparse(saxHandler);
} else {
executeQuery(statement, properties).unparse(saxHandler);
}
} finally {
saxHandler.endElement();
saxHandler.endElement();
Expand Down Expand Up @@ -521,8 +528,25 @@ private void emitCell(SAXHandler saxHandler, Cell cell, int ordinal) throws SAXE
String cellPropLong = cellPropLongs[i];
final Object value =
cell.getPropertyValue(cellPropLong);

String valueType = null;
if (value instanceof Integer) {
valueType = "xsd:int";
} else if (value instanceof Long) {
valueType = "xsd:long";
} else if (value instanceof Double || value instanceof BigDecimal) {
valueType = "xsd:double";
} else {
valueType = "xsd:string";
}

if (value != null) {
saxHandler.startElement(cellProps[i]);
if (cellPropLong == Property.VALUE.name) {
saxHandler.startElement(cellProps[i], new String[]{"xsi:type", valueType});
} else {
saxHandler.startElement(cellProps[i]);
}

String valueString = value.toString();

if (cellPropLong == Property.VALUE.name &&
Expand Down
50 changes: 25 additions & 25 deletions testsrc/main/mondrian/xmla/XmlaTest.java
Expand Up @@ -1437,7 +1437,7 @@ public void testSelect() {
"<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">",
" <SOAP-ENV:Body>",
" <ExecuteResponse xmlns=\"urn:schemas-microsoft-com:xml-analysis\">",
" <return>",
" <return xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">",
" <root xmlns=\"urn:schemas-microsoft-com:xml-analysis:mddataset\">",
" <xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"/>",
" <OlapInfo>",
Expand Down Expand Up @@ -1522,27 +1522,27 @@ public void testSelect() {
" </Axes>",
" <CellData>",
" <Cell CellOrdinal=\"0\">",
" <Value>266773</Value>",
" <Value xsi:type=\"xsd:double\">266773</Value>",
" <FmtValue>266,773</FmtValue>",
" <FormatString>Standard</FormatString>",
" </Cell>",
" <Cell CellOrdinal=\"1\">",
" <Value>225627.2336</Value>",
" <Value xsi:type=\"xsd:double\">225627.2336</Value>",
" <FmtValue>225,627.23</FmtValue>",
" <FormatString>#,###.00</FormatString>",
" </Cell>",
" <Cell CellOrdinal=\"2\">",
" <Value>565238.13</Value>",
" <Value xsi:type=\"xsd:double\">565238.13</Value>",
" <FmtValue>565,238.13</FmtValue>",
" <FormatString>#,###.00</FormatString>",
" </Cell>",
" <Cell CellOrdinal=\"3\">",
" <Value>86837</Value>",
" <Value xsi:type=\"xsd:int\">86837</Value>",
" <FmtValue>86,837</FmtValue>",
" <FormatString>#,###</FormatString>",
" </Cell>",
" <Cell CellOrdinal=\"4\">",
" <Value>5581</Value>",
" <Value xsi:type=\"xsd:int\">5581</Value>",
" <FmtValue>5,581</FmtValue>",
" <FormatString>#,###</FormatString>",
" </Cell>",
Expand Down Expand Up @@ -1636,7 +1636,7 @@ public void testSelect2() {
"<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">",
" <SOAP-ENV:Body>",
" <ExecuteResponse xmlns=\"urn:schemas-microsoft-com:xml-analysis\">",
" <return>",
" <return xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">",
" <root xmlns=\"urn:schemas-microsoft-com:xml-analysis:mddataset\">",
" <xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"/>",
" <OlapInfo>",
Expand Down Expand Up @@ -1858,92 +1858,92 @@ public void testSelect2() {
" </Axes>",
" <CellData>",
" <Cell CellOrdinal=\"0\">",
" <Value>14861.5006</Value>",
" <Value xsi:type=\"xsd:double\">14861.5006</Value>",
" <FmtValue>$14,861.50</FmtValue>",
" <FormatString>Currency</FormatString>",
" </Cell>",
" <Cell CellOrdinal=\"1\">",
" <Value>2316</Value>",
" <Value xsi:type=\"xsd:int\">2316</Value>",
" <FmtValue>2,316</FmtValue>",
" <FormatString>#,#</FormatString>",
" </Cell>",
" <Cell CellOrdinal=\"2\">",
" <Value>3261.2206</Value>",
" <Value xsi:type=\"xsd:double\">3261.2206</Value>",
" <FmtValue>$3,261.22</FmtValue>",
" <FormatString>Currency</FormatString>",
" </Cell>",
" <Cell CellOrdinal=\"3\">",
" <Value>972</Value>",
" <Value xsi:type=\"xsd:int\">972</Value>",
" <FmtValue>972</FmtValue>",
" <FormatString>#,#</FormatString>",
" </Cell>",
" <Cell CellOrdinal=\"4\">",
" <Value>11600.28</Value>",
" <Value xsi:type=\"xsd:double\">11600.28</Value>",
" <FmtValue>$11,600.28</FmtValue>",
" <FormatString>Currency</FormatString>",
" </Cell>",
" <Cell CellOrdinal=\"5\">",
" <Value>1344</Value>",
" <Value xsi:type=\"xsd:int\">1344</Value>",
" <FmtValue>1,344</FmtValue>",
" <FormatString>#,#</FormatString>",
" </Cell>",
" <Cell CellOrdinal=\"6\">",
" <Value>7848.9727</Value>",
" <Value xsi:type=\"xsd:double\">7848.9727</Value>",
" <FmtValue>$7,848.97</FmtValue>",
" <FormatString>Currency</FormatString>",
" </Cell>",
" <Cell CellOrdinal=\"7\">",
" <Value>1632</Value>",
" <Value xsi:type=\"xsd:int\">1632</Value>",
" <FmtValue>1,632</FmtValue>",
" <FormatString>#,#</FormatString>",
" </Cell>",
" <Cell CellOrdinal=\"8\">",
" <Value>2663.8927</Value>",
" <Value xsi:type=\"xsd:double\">2663.8927</Value>",
" <FmtValue>$2,663.89</FmtValue>",
" <FormatString>Currency</FormatString>",
" </Cell>",
" <Cell CellOrdinal=\"9\">",
" <Value>792</Value>",
" <Value xsi:type=\"xsd:int\">792</Value>",
" <FmtValue>792</FmtValue>",
" <FormatString>#,#</FormatString>",
" </Cell>",
" <Cell CellOrdinal=\"10\">",
" <Value>5185.08</Value>",
" <Value xsi:type=\"xsd:double\">5185.08</Value>",
" <FmtValue>$5,185.08</FmtValue>",
" <FormatString>Currency</FormatString>",
" </Cell>",
" <Cell CellOrdinal=\"11\">",
" <Value>840</Value>",
" <Value xsi:type=\"xsd:int\">840</Value>",
" <FmtValue>840</FmtValue>",
" <FormatString>#,#</FormatString>",
" </Cell>",
" <Cell CellOrdinal=\"12\">",
" <Value>16721.1979</Value>",
" <Value xsi:type=\"xsd:double\">16721.1979</Value>",
" <FmtValue>$16,721.20</FmtValue>",
" <FormatString>Currency</FormatString>",
" </Cell>",
" <Cell CellOrdinal=\"13\">",
" <Value>3444</Value>",
" <Value xsi:type=\"xsd:int\">3444</Value>",
" <FmtValue>3,444</FmtValue>",
" <FormatString>#,#</FormatString>",
" </Cell>",
" <Cell CellOrdinal=\"14\">",
" <Value>5481.6379</Value>",
" <Value xsi:type=\"xsd:double\">5481.6379</Value>",
" <FmtValue>$5,481.64</FmtValue>",
" <FormatString>Currency</FormatString>",
" </Cell>",
" <Cell CellOrdinal=\"15\">",
" <Value>1632</Value>",
" <Value xsi:type=\"xsd:int\">1632</Value>",
" <FmtValue>1,632</FmtValue>",
" <FormatString>#,#</FormatString>",
" </Cell>",
" <Cell CellOrdinal=\"16\">",
" <Value>11239.56</Value>",
" <Value xsi:type=\"xsd:double\">11239.56</Value>",
" <FmtValue>$11,239.56</FmtValue>",
" <FormatString>Currency</FormatString>",
" </Cell>",
" <Cell CellOrdinal=\"17\">",
" <Value>1812</Value>",
" <Value xsi:type=\"xsd:int\">1812</Value>",
" <FmtValue>1,812</FmtValue>",
" <FormatString>#,#</FormatString>",
" </Cell>",
Expand Down

0 comments on commit 47eadba

Please sign in to comment.