我是蒙德里安的初学者。我想为Mondrian中的假设分析创建方案。我尝试了http://julianhyde.blogspot.com/2009/06/cell-writeback-in-mondrian.html,但没有成功。我不知道该如何编写脚本,也不知道它在mondrina 3.14 jar中是否受支持。
我试图像下面的代码那样不使用场景维度,一旦我在模式中编写场景维度,它就会给我错误,没有提供默认措施。
Class.forName("mondrian.olap4j.MondrianOlap4jDriver");
try (final java.sql.Connection connection = java.sql.DriverManager
.getConnection("jdbc:mondrian:Jdbc=jdbc:mysql://"
+ this.env.getProperty("db.host") + ":3306/"
+ this.env.getProperty("db.source.jdbcDB")
+ "?user="
+ this.env.getProperty("db.source.userName")
+ "&useSSL=false&password="
+ this.env.getProperty("db.source.password") + ";"
+ "Catalog=file:C:\\Users\\shahhard\\Desktop\\scenario.xml;"
+ "JdbcDrivers="
+ this.env.getProperty("db.source.driver.class")
+ ";"
+ this.env.getProperty("db.source.driver.class")
+ "Cache.Mode=LFU;Cache.Timeout=600;Cache.Size=100")) {
final MondrianOlap4jConnection olapConnection = connection
.unwrap(MondrianOlap4jConnection.class);
final Scenario scenario = olapConnection.createScenario();
final String sid = scenario.getId();
String query = mondrianQuery.getQuery();
query = query.replace("<SID>", sid);
try (OlapStatement statement = olapConnection
.createStatement()) {
final CellSet cellSet = statement.executeOlapQuery(query);
print(cellSet);
if (mondrianQuery.getValue() != null) {
olapConnection.setScenario(scenario);
final List<Integer> list = new ArrayList<>();
list.add(mondrianQuery.getxCellOffset());
list.add(mondrianQuery.getyCellOffset());
final Cell cell = cellSet.getCell(list);
System.out.println(cell.getValue());
cell.setValue(mondrianQuery.getValue(),
AllocationPolicy.EQUAL_ALLOCATION);
final CellSet cellSet1 = statement
.executeOlapQuery(query);
print(cellSet1);
print(cellSet);
}
}
} catch (final Exception e) {
// TODO: handle exception
logger.error("", e);
}
} catch (final Exception e) {
// TODO: handle exception
}