List<String> cubes = new ArrayList<String>();
cubes.add(cube);
return maintain(isFull,null,cubes);
}
public static synchronized OperResult maintain(boolean isFull,List<String> dims,List<String> cubes){
AWConnection awConnection = null;//分析工作空间连接
OperResult result = new OperResult();
Connection connection = null;
try {
Object bdd = StorageService.ctx.getBean("olapdatasource");
if(bdd instanceof org.apache.tomcat.dbcp.dbcp.BasicDataSource){
org.apache.tomcat.dbcp.dbcp.BasicDataSource bds = (BasicDataSource)bdd;
Connection conn1 = bds.getConnection();
if(conn1 instanceof org.apache.tomcat.dbcp.dbcp.DelegatingConnection){
org.apache.tomcat.dbcp.dbcp.DelegatingConnection dc = (org.apache.tomcat.dbcp.dbcp.DelegatingConnection)conn1;
connection = dc.getInnermostDelegate();
}
}else if(bdd instanceof org.jsoftware.fods.impl.FoDataSourceImpl){
org.jsoftware.fods.impl.FoDataSourceImpl bds = (org.jsoftware.fods.impl.FoDataSourceImpl)bdd;
connection = bds.getConnection().getMetaData().getConnection();
}
if(connection==null ){
result.setFailed(OLAP_CONNECTION_NOT_AVAILABLE);
return result;
}
OracleConnection conn = (OracleConnection) connection;
try{
awConnection = new AWConnection(conn);
}catch(Exception e){
result.setFailed(e.getMessage());
e.printStackTrace();
return result;
}
Interaction curInteraction = new Interaction();
// Set the AWConnection to use when building the analytic workspace.
curInteraction.setConnection(awConnection);
// Create an BuildDatabase object.
BuildDatabase myBuild =
(BuildDatabase)curInteraction.createAction("BUILDDATABASE");
// Set the name of the analytic workspace.
myBuild.setAWName(WebVariable.AW_GLOBAL_ID);//挂载分析空间global.global
// Specify not running solves when building the database.
myBuild.setBuildType("EXECUTE");
// myBuild.setRunSolve(true);
myBuild.setCleanMeasures(false);
myBuild.setCleanAttrs(false);
myBuild.setCleanDim(true);
myBuild.setTrackStatus(true);
// myBuild.setId("simple");
/**!
* TrackStatus
* true只导入增量数据
* false全数据导入
*/
// myBuild.setTrackStatus(isFull);
myBuild.setMaxJobQueues(0);
if(dims!=null){
for(String dimid:dims){
Dimension dim = new Dimension();
dim.setId(dimid);
myBuild.addBuildList(dim);
}
}
if(cubes!=null){
for(String cubeid:cubes){
Cube cube = new Cube();
cube.setId(cubeid);
myBuild.addBuildList(cube);
}
}
myBuild.Execute();
awConnection.executeCommand("aw detach "+WebVariable.AW_GLOBAL_ID);
result.setSucceed(getOLAPLog(conn));
awConnection.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
result.setFailed(OLAP_MAINTAIN_FAILED,e.getMessage());
} finally{
if(awConnection!=null){
awConnection.close();
awConnection = null;
}
}
return result;
}