<%@ page language="java"
	contentType="text/xml;charset=Shift_JIS"
	import="java.util.*,openolap.viewer.Report,openolap.viewer.CellData,openolap.viewer.EdgeCoordinates,openolap.viewer.common.CommonSettings;"
%><%!
// ********************************************************
// Function
// ********************************************************

%><%

	Report report = (Report)session.getAttribute("report");
	ArrayList cellDataList = (ArrayList)request.getAttribute("cellDataList");

if(cellDataList == null ) {
	throw new IllegalStateException("セッションにcellDataListが存在しない。in dataInfo.jsp");
}

	// CellValueデータ格納XMLに、軸のIDとKeyの情報を含めるかの設定を取得
	CommonSettings commonSettings = (CommonSettings)getServletConfig().getServletContext().getAttribute("apCommonSettings");
	boolean valueXmlContainsAxesInfo = commonSettings.getValueXmlContainsAxesInfo();


%><?xml version="1.0" encoding="Shift_JIS"?>
<CellDataInfo>
<%
	Iterator it = cellDataList.iterator();

	while (it.hasNext()) {
		CellData cellData = (CellData) it.next();
		EdgeCoordinates colCordinates = cellData.getColCoordinates();
		LinkedHashMap   colIdKeyMap   = colCordinates.getAxisIdMemKeyMap();
		EdgeCoordinates rowCordinates = cellData.getRowCoordinates();
		LinkedHashMap   rowIdKeyMap   = rowCordinates.getAxisIdMemKeyMap();

		out.println("<Cell>");
			out.println("<Col>");
				out.println("<Index>");
					out.println(colCordinates.getIndex());
//System.out.print(colCordinates.getIndex() + ",");
				out.println("</Index>");

				if(valueXmlContainsAxesInfo) {
					out.println("<Axes>");
						Iterator colIt = colIdKeyMap.keySet().iterator();
						while (colIt.hasNext()) {
							Integer key = (Integer) colIt.next();
							out.println("<Axis id='" + key  + "'>");
								out.println("<Key>" + (String)colIdKeyMap.get(key) + "</Key>");
							out.println("</Axis>");
						}
					out.println("</Axes>");
				}

			out.println("</Col>");
			out.println("<Row>");
				out.println("<Index>");
					out.println(rowCordinates.getIndex());
				out.println("</Index>");

				if(valueXmlContainsAxesInfo) {
					out.println("<Axes>");
						Iterator rowIt = rowIdKeyMap.keySet().iterator();
						while (rowIt.hasNext()) {
							Integer key = (Integer) rowIt.next();
							out.println("<Axis id='" + key  + "'>");
								out.println("<Key>" + (String)rowIdKeyMap.get(key) + "</Key>");
							out.println("</Axis>");
						}
					out.println("</Axes>");
				}

			out.println("</Row>");
			out.println("<Data>");
				out.println("<Measure>");
					out.println(cellData.getMeasureMemberUniqueName());
				out.println("</Measure>");
				out.println("<Value>");
					out.println(cellData.getValue());
				out.println("</Value>");
				out.println("<Value2>");
					out.println(cellData.getValue2());
				out.println("</Value2>");
			out.println("</Data>");
		out.println("</Cell>");
	}

%>
</CellDataInfo>

