public VarDTO_Light getVarLight(long id) {
   Var v = em.find(Var.class, id);
   if (v != null) {
     v.setEM(em);
     return v.toDTO_Light();
   } else return null;
 }
 @Override
 public VarDTO_Detailed getVarDetailed(long id, UserAccountDTO dto, UserHistoryDTO hist_dto) {
   Var v = em.find(Var.class, id);
   if (v != null) {
     v.setEM(em);
     if (dto != null && dto.getId() != 0 && dto.getCurrent_research() == 0) {
       dto.setCurrent_research(v.getResearch_id());
     }
     return v.toDTO_Detailed(dto, hist_dto, em);
   } else return null;
 }
 @Override
 public ArrayList<VarDTO_Research> getVarsResearchNames(ArrayList<Long> keys) {
   ArrayList<VarDTO_Research> map = new ArrayList<VarDTO_Research>();
   for (Long k : keys) {
     Var v = em.find(Var.class, k);
     if (v != null) {
       v.setEM(em);
       VarDTO_Detailed dto = v.toDTO_Detailed(null, null, em);
       map.add(
           new VarDTO_Research(
               dto.getId(), dto.getResearch_id().intValue(), dto.getResearch_name()));
     }
   }
   return map;
 }
 @Override
 public ArrayList<VarDTO_Light> getResearchVarsSummaries(long research_id) {
   // Variant 1
   //        ArrayList<VarDTO_Light> list = new ArrayList<VarDTO_Light>();
   //        SocioResearch dsResearch,detached;
   //	try {
   //		 dsResearch = em.find(SocioResearch.class, research_id);
   //	     ArrayList<Long> var_ids = dsResearch.getVar_ids();
   //	     for(Long var_id:var_ids)
   //	     {
   //	    	 Var var = em.find(Var.class,var_id);
   //	    	 list.add(var.toDTO_Light());
   //	     }
   //	} finally
   //        {
   //        }
   // Variant 2
   //        TypedQuery<Var> q = em.createQuery("SELECT x FROM Var x WHERE x.research_id = :id
   // ORDER BY x.id", Var.class);
   //        q.setParameter("id", research_id);
   //        List<Var> l = q.getResultList();
   //        for(Var v:l)
   //        {
   //            list.add(v.toDTO_Light());
   //        }
   // Variant 3
   return Var.getResearchVarsLight(em, research_id);
   // throw new UnsupportedOperationException("Not supported yet.");
 }
 @Override
 public ArrayList<VarDTO_Light> getVarDTOs(ArrayList<Long> ids) {
   //       ArrayList<VarDTO_Light> arr = new ArrayList<VarDTO_Light>();
   //	if (ids != null)
   //		for(Long key:ids)
   //		{
   //			VarDTO_Light dto = getVarLight(key);
   //			arr.add(dto);
   //		}
   return Var.getResearchVarsLightDTOs(em, ids);
 }
 @Override
 public ArrayList<VarDTO_Light> getResearchVarsWeightCandidates(long research_id) {
   return Var.getResearchVarsWeightCandidates(em, research_id);
 }
 @Override
 public VarDTO getVar(long id, UserAccountDTO dto, UserHistoryDTO hist_dto) {
   Var v = em.find(Var.class, id);
   v.setEM(em);
   return v.toDTO(dto, hist_dto, em);
 }
 @Override
 public ArrayList<Double> get2DDistribution(
     long var_id1, long var_id2, UserAccountDTO dto, UserHistoryDTO hist_dto) {
   return Var.calc2DDistribution(var_id1, var_id2, dto, hist_dto, em);
 }