開源BI報表及OLAP多維分析平臺OPENI(二)—搭建Eclipse下的Openi開發環境
開源BI報表及OLAP多維分析平臺OPENI(二)—搭建Eclipse下的Openi開發環境
接著上節的demo來看如何在Eclipse下搭建Openi的開發及調試環境.
一.下載openi-1.3.0-RELEASE-src
a. 官方網站: http://www.openi.org 或http://openi.sourceforge.net/index.html
b.下載源代碼版本: http://sourceforge.net/project/showfiles.php?group_id=142873
二.新建web project
在MyEclipse下新建web project:openi
1.openi-1.3.0-RELEASE-src\openi\src下的文件copy到上面新建的openisrc下.
2.openi-1.3.0-RELEASE\openi\openi.war,在tomcat解壓后的文件夾下,將除WEB-INF之外的所有文件copy至剛才新建的項目
3.在MyEclipse下發布openi
4.當然,別忘了把openi-1.3.0-RELEASE\openi\ openi-projects.war,openi-1.3.0-RELEASE\openi\ mondrian.war拷貝到<tomcat_home>\webapps
5.查看,并設置斷點進行調試
啟動tomcat, http://localhost:8080/openi,應該可以訪問了.用戶密碼如果沒有修改的話,應該就是tomcat/tomcat,如果不對,請去<tomcat_home>\conf\tomcat-users.xml自己去找.
三、修改端口
該項目默認的端口是8080.而大多數tomcat可能設置成別的端口如8088等。在這里通過查看源代碼,及在MyEclipse下面調試源代碼,就可以發現,org.openi.project.ProjectFactory類中方法:getProject
public static Project getProject(String baseDirName, String projectId)

throws IOException
{
// important to give proper feedback to caller

if (baseDirName == null)
{
throw new IOException(
"Project directory name is null. This should be the location for all projects");
}

BeanStorage storage = new BeanStorage();

String projectFilePath = new File(baseDirName,
projectId + "/project.xml").getCanonicalPath();
logger.debug("Trying to restore project: " + projectFilePath);
Project retProject = null;

try
{
retProject = (Project) storage.restoreBeanFromFile(projectFilePath);

}catch(Exception e)
{
logger.debug("trouble restoring project from " + projectFilePath, e);
logger.debug("possibly old format, trying xslt");
}


if(retProject == null)
{
String xsltPath = new File(baseDirName).getParent()
+ "/openi/WEB-INF/project/project.xsl";
logger.debug(
"transforming project.xml into new format using template "
+ xsltPath);

try
{
String backup = backupOldFile(projectFilePath);
transformProjectToNewFormat(backup, projectFilePath, xsltPath);
//transformed, try to restore again, this time if it doesn't work, throw IOException:
retProject = (Project) storage.restoreBeanFromFile(projectFilePath);

} catch (Exception ex)
{
//logger.error(ex.getStackTrace());
throw new IOException(
"An error occured while transforming project.xml into new format\nroot cause:"
+ ex.getMessage());
}
}

return retProject;
}

從中可以看出project的datasource的來源.它來自文件:<tomcat_home>\webapps\openi-projects\foodmart\project.xml
在此文件中
<dataSourceMap>
<entry>
<string>mondrian</string>
<org.openi.analysis.Datasource>
<server>http://localhost:8080/mondrian/xmla</server>
<xmlaDatasource>MondrianFoodMart</xmlaDatasource>
<catalog>FoodMart</catalog>
</org.openi.analysis.Datasource>
</entry>

只需要把這里面的8080改成自己的端口就OK了。(當然,別忘了修改tomcat\conf server.xml中的端口了哦,呵呵).
請對openi或BI感興趣的朋友多多支持,讓俺認真研究研究,以便發更多的文件.下節寫寫對整個openi的設計.