Package custom.energypro.vinnica.analysis

Source Code of custom.energypro.vinnica.analysis.AnalizSpozhByRPsLast3MonthScriptlet

package custom.energypro.vinnica.analysis;

import java.rmi.RemoteException;

import net.sf.jasperreports.engine.JRDefaultScriptlet;
import net.sf.jasperreports.engine.JRScriptletException;

import com.uens.analysis.AnalysisProcessorImpl;
import com.uens.query.ViewProcessor;
import com.uens.query.model.Marker;
import com.uens.query.model.MarkerExt;

public class AnalizSpozhByRPsLast3MonthScriptlet extends JRDefaultScriptlet {

  private String rootMarker = null;

  @Override
  public void beforeReportInit() throws JRScriptletException {
    super.beforeReportInit();
    initRootMarker();
  }

  private void initRootMarker() throws JRScriptletException {
    try {
      ViewProcessor vp = (ViewProcessor) getParameterValue(AnalysisProcessorImpl.REPORT_VIEWPROCESSOR_PARAM);
      if (vp != null) {
        Marker m = vp.getMarker(7);
        rootMarker = m.getName();
      }
    } catch (RemoteException e) {
      throw new JRScriptletException(e.getMessage(), e);
    }
  }

  public String getRPMarker() throws JRScriptletException {
    if (rootMarker == null) {
      return null;
    }
    ViewProcessor vp = (ViewProcessor) getParameterValue(AnalysisProcessorImpl.REPORT_VIEWPROCESSOR_PARAM);
    if (vp == null) {
      return null;
    }
    try {
      Integer rpCode = (Integer) getFieldValue("RPCODE");
      MarkerExt[] ams = vp.getAssignedMarkers("EPRECORDPOINT", rpCode);
      String result = null;
      for (int i = 0; i < ams.length; i++) {
        MarkerExt m = ams[i];
        if (m.getName().startsWith(rootMarker)) {
          String[] parts = m.getName().split(" => ");
          if (parts.length > 2) {
            result = parts[parts.length - 2];
          } else {
            result = parts[parts.length - 1];
          }
          break;
        }
      }
      return result;
    } catch (RemoteException e) {
      e.printStackTrace();
      return null;
    }
  }

}
TOP

Related Classes of custom.energypro.vinnica.analysis.AnalizSpozhByRPsLast3MonthScriptlet

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.