Package clips.delegate.report

Source Code of clips.delegate.report.DiseaseReportLocal

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package clips.delegate.report;

import beans.report.SelectorIndefiner;
import beans.report.selectors.baseSelectors.TableContainer.Mode;
import cli_fmw.delegate.report.ReportLocal;
import beans.report.selectors.baseSelectors.TableContainer;
import beans.report.selectors.baseSelectors.AbstractReportTable;
import beans.report.DiseaseReportBean;
import beans.report.DiseaseReportBeanRemote;
import beans.report.DiseaseReportMaps;
import beans.report.selectors.ReportTableFactory;
import cli_fmw.delegate.directory.complex.DirectoryLocator;
import clips.delegate.directory.complex.DirectoryMKB10;
import clips.delegate.directory.complex.DirectoryMKB10Item;
import cli_fmw.delegate.DelegateLine2;
import beans.report.DiseaseReportDetals;
import cli_fmw.main.ClipsException;
import beans.report.selectors.disease.DiseaseLine;
import cli_fmw.delegate.AuditListener;
import java.util.ArrayList;
import java.util.List;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperPrint;
import org.jdom.Element;

/**
*
* @author finder
*/
public class DiseaseReportLocal
    extends DelegateLine2<DiseaseReportBeanRemote, DiseaseReportDetals> implements TableContainer<AbstractReportTable<?>> {
    
   /* ReportItemCache reportItems = new ReportItemCache(getECM());
    private class ReportItemCache extends DelegateExtraCache<List<AbstractReportTable>> {

        public ReportItemCache(ExtraCacheManager contaner) {
            super(contaner);
        }
       
        @Override
        protected void setPrimary(List<AbstractReportTable> items) throws ClipsException {    
      ReportTableFactory          factory = new ReportTableFactory();
      Element                el = new Element("report");
      factory.toXml(items, el);
      getDetails().setXml(el);
        }

        @Override
        protected List<AbstractReportTable> init() throws Exception {
    ReportTableFactory              factory = new ReportTableFactory();
    ArrayList<AbstractReportTable>        list = factory.parseXml(getDetails().getXml());
            return list;
        }

        @Override
        protected List<AbstractReportTable> initNew() {
            return new ArrayList<AbstractReportTable>();
        }
    }*/
   
  public DiseaseReportLocal(AuditListener al) {
            super(al);
  }

    DiseaseReportLocal(DiseaseReportDetals detals, AuditListener al) {
    super(detals, al);
  }

    @Override
    protected DiseaseReportDetals getNewDetails() {
        return new DiseaseReportDetals();
    }
   
  @Override
  protected String getBeanName() {
    return DiseaseReportBean.class.getSimpleName();
  }
 
  public String getName() throws ClipsException{
    return getDetails().name;
  }
 
  public void setName(String name) throws ClipsException{
    getDetails().name = name;
    fireContentStateEvent();
  }
 
  public String getFormNumber() throws ClipsException {
    return getDetails().formNumber;
  }

  public void setFormNumber(String formNumber) throws ClipsException {
    getDetails().formNumber = formNumber;
    fireContentStateEvent();
  }

  public String getOkudFormCode() throws ClipsException {
    return getDetails().okudFormCode;
  }

  public void setOkudFormCode(String okudFormCode) throws ClipsException {
    getDetails().okudFormCode = okudFormCode;
    fireContentStateEvent();
  }

  public String getResolutionDateNumber() throws ClipsException {
    return getDetails().resolutionDateNumber;
  }

  public void setResolutionDateNumber(String resolutionDateNumber) throws ClipsException {
    getDetails().resolutionDateNumber = resolutionDateNumber;
    fireContentStateEvent();
  }

  public String getTargetDeaprtaments() throws ClipsException {
    return getDetails().targetDeaprtaments;
  }

  public void setTargetDeaprtaments(String targetDeaprtaments) throws ClipsException {
    getDetails().targetDeaprtaments = targetDeaprtaments;
    fireContentStateEvent();
  }
 
  public String getTargetDates() throws ClipsException {
    return getDetails().targetDates;
  }

  public void setTargetDates(String targetDates) throws ClipsException {
    getDetails().targetDates = targetDates;
    fireContentStateEvent();
 

  public int getType() throws ClipsException {
    return getDetails().type;
  }

  public void setType(int type) throws ClipsException {
    getDetails().type = type;
    fireContentStateEvent();
  }
 

  public ReportLocal getReport() throws ClipsException {
    if (getDetails().reportId != 0) {
      return new ReportLocal(getDetails().reportId, getAuditListener());
    }
    else {
      return null;
    }
  }

  public void setReport(ReportLocal report) throws ClipsException {
    if (report.isNewlyCreated()) {
      throw new ClipsException("Отчет должен быть сперва сохранен!");
    }
    getDetails().reportId = report.getID();
    fireContentStateEvent();
  }
 
  @Override
  public List<AbstractReportTable<?>> getTables() throws ClipsException{
    ReportTableFactory              factory = new ReportTableFactory();
    ArrayList<AbstractReportTable<?>>      list = factory.parseXml(getDetails().getXml());
    return list;
  }
 
  @Override
  public void setTables(List<AbstractReportTable<?>> tables) throws ClipsException{
    ReportTableFactory          factory = new ReportTableFactory();
    Element                el = new Element("report");
    factory.toXml(tables, el);
    getDetails().setXml(el);
    fireContentStateEvent();
  }

  @Override
  public Mode getMode() {
    return Mode.normal;
  }

  @Override
  public SelectorIndefiner[] getSelectorList() {
    return DiseaseReportMaps.getSelectorList();
  }
 
  public static void resoveName(DiseaseLine line) throws ClipsException{
    String        name = line.getLineTitle();
    if (name == null || name.length() == 0 || line.isAutoGenerated()){
      boolean      firstPass = true;
      DirectoryMKB10  dir = DirectoryLocator.getDirectory(DirectoryMKB10.class, false);
      for (int mkb10id : line.getItems()) {
        DirectoryMKB10Item    item = dir.getItemFromID(mkb10id);
        String          nameItem = (item == null)? null: item.getTitle();
        if (firstPass){
          name = nameItem;
          firstPass = name == null;
        }
        else if (name != null) {
          name += ", " + nameItem;
        }
      }
      line.setAutoGenerated(true);
    }
    if (name == null || name.length() == 0) {
      name = "Пустая линия";
    }
    line.setLineTitle(name);
  }

  @Override
  public String toString() {
    try {
      return getName();
    } catch (ClipsException ex) {
      ex.printStackTrace();
    }
    return "<Ошибка>";
  }
 
  public JasperPrint getReport(int year) throws ClipsException, JRException {
    try{
            return getBean().getReport(year);
    }
    catch (JRException ex){
      throw ex;
    }
    catch (Exception ex){
      clearBean();
      throw new ClipsException("Не удалось получить отчет", ex);
    }
  }

}
TOP

Related Classes of clips.delegate.report.DiseaseReportLocal

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.