Package beans.service.mes

Source Code of beans.service.mes.MedicEconomicStandartBean

package beans.service.mes;

import framework.beans.FacadeBean;
import framework.beans.security.BeanRights;
import framework.beans.EntityDetails;
import framework.beans.GenericEntity;
import beans.directory.mkb10.entity.Mkb10;
import beans.directory.service.entity.Service;
import beans.directory.simple.entities.ReceptionType;
import beans.service.mes.entity.MedicEconomicStandart;
import beans.service.mes.entity.MedicEconomicStandartDetail;
import framework.generic.ClipsServerException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import javax.ejb.Stateful;
import beans.UserRightsSet;
import beans.directory.mes.entity.MesClass;
import beans.directory.simple.entities.MESTargets;
import framework.audit.AuditDoc;
import java.util.Date;
import java.util.List;

/**
*
* @author finder
*/

@Stateful(mappedName="clips-beans/MedicEconomicStandartBean")
public class MedicEconomicStandartBean  extends FacadeBean<MedicEconomicStandart> implements MedicEconomicStandartBeanRemote {

    public MedicEconomicStandartBean() {
        super(MedicEconomicStandart.class);
    }


  @Override
  protected void initBeanRights() {
    int [] r = new int[4];
    r[COMMAND_READ] = RightPresence(UserRightsSet.READ_MES.id);
    int cmr = RightPresence(UserRightsSet.MODIFY_MES.id);
    r[COMMAND_CREATE] = cmr;
    r[COMMAND_MODIFY] = cmr;
    r[COMMAND_REMOVE] = cmr;
    rights = new BeanRights(r);
  }


  @Override
  protected void onUpdate(MedicEconomicStandart entity, EntityDetails details,
            AuditDoc auditDoc, List<AuditDoc> auditDocList) throws ClipsServerException {
    MedicEconomicStandartDetail    det = (MedicEconomicStandartDetail)details;
    entity.setCode(det.code);
    entity.setDiseaseName(det.diseaseName);
    entity.setSizeOfCure(det.sizeOfCure);
    entity.setCriteriaOfQuality(det.criteriaOfQuality);
    entity.setNormalDuration(det.normalDuration);
    entity.setComplexitySupervision(det.complexitySupervision);
    entity.setComplexityOperations(det.complexityOperations);
    entity.setMesTariff(det.tariff);
   
    syncSets(entity.getMkb10Collection(), det.mkb10, Mkb10.class, "Справочник мкб10");
    syncSets(entity.getReceptionTypeCollection(), det.receptionTypes, ReceptionType.class, "Тип приема");
    syncSets(entity.getServiceCollection(), det.service, Service.class, "Услуги");

    entity.setMesClass(findEntity(MesClass.class, det.mesClassId));
    entity.setTargets(findEntity(MESTargets.class, det.targetsId));
  }

  protected <T extends GenericEntity> void syncSets(Set<T> entitys, Set<Integer> ids, Class<T> clazz, String entityName) throws ClipsServerException{
    HashSet<Integer>      idset = new HashSet<Integer>(ids);

    for (Iterator<? extends GenericEntity> it = entitys.iterator(); it.hasNext();) {
      GenericEntity  genericEntity = it.next();
      Integer      id = genericEntity.getId();
      if (id == null){
        idset.remove(null);
      }
      else
      {
        if (!idset.remove(id)){
          it.remove();
        }
      }

    }

    for (Integer integer : idset) {
      T          entyty = findEntity(clazz, integer);
      entitys.add(entyty);
    }
  }
}
TOP

Related Classes of beans.service.mes.MedicEconomicStandartBean

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.