@@ -0,0 +1,2179 @@
+/**%0A* OpenCPS is the open source Core Public Services software%0A* Copyright (C) 2016-present OpenCPS community%0A%0A* This program is free software: you can redistribute it and/or modify%0A* it under the terms of the GNU Affero General Public License as published by%0A* the Free Software Foundation, either version 3 of the License, or%0A* any later version.%0A%0A* This program is distributed in the hope that it will be useful,%0A* but WITHOUT ANY WARRANTY; without even the implied warranty of%0A* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the%0A* GNU Affero General Public License for more details.%0A* You should have received a copy of the GNU Affero General Public License%0A* along with this program. If not, see %3Chttp://www.gnu.org/licenses/%3E%0A*/%0A%0Apackage org.opencps.report.datasource.adapter;%0A%0Aimport org.json.JSONObject;%0A%0Aimport com.liferay.portal.kernel.log.Log;%0Aimport com.liferay.portal.kernel.log.LogFactoryUtil;%0A%0Aimport net.sf.jasperreports.engine.JRDataSource;%0Aimport net.sf.jasperreports.engine.JRException;%0Aimport net.sf.jasperreports.engine.JRField;%0A%0A/**%0A * @author trungnt%0A */%0Apublic class JRJSONDataSource implements JRDataSource %7B%0A%0A%09private JSONObject json = null;%0A%0A%09private boolean flag = false;%0A%0A%09private void setJson(String strJSON) %7B%0A%0A%09%09try %7B%0A%09%09%09json = new JSONObject(strJSON);%0A%09%09%7D%0A%09%09catch (org.json.JSONException e) %7B%0A%09%09%09_log%0A%09%09%09    .equals(e%0A%09%09%09        .getMessage());%0A%09%09%7D%0A%09%7D%0A%0A%09@Override%0A%09public Object getFieldValue(JRField field)%0A%09    throws JRException %7B%0A%0A%09%09try %7B%0A%09%09%09return this.json%0A%09%09%09    .getString(field%0A%09%09%09        .getName());%0A%09%09%7D%0A%09%09catch (Exception e) %7B%0A%09%09%09_log%0A%09%09%09    .error(e%0A%09%09%09        .getMessage());%0A%09%09%7D%0A%0A%09%09return null;%0A%09%7D%0A%0A%09@Override%0A%09public boolean next()%0A%09    throws JRException %7B%0A%0A%09%09if (this.json != null && !flag) %7B%0A%09%09%09flag = true;%0A%09%09%09return true;%0A%09%09%7D%0A%09%09else %7B%0A%09%09%09return false;%0A%09%09%7D%0A%09%7D%0A%0A%09/**%0A%09 * Return an instance of the class that implements the custom data adapter.%0A%09 */%0A%09public static JRDataSource getDataSource(String strJSON) %7B%0A%0A%09%09JRJSONDataSource adapter = new JRJSONDataSource();%0A%09%09adapter%0A%09%09    .setJson(strJSON);%0A%09%09return adapter;%0A%09%7D%0A%0A%09private Log _log = LogFactoryUtil%0A%09    .getLog(JRJSONDataSource.class%0A%09        .getName());%0A%0A%7D%0A

Add Jasper Json DataSource