public List<PointOfContactBean> findPointOfContactsBySampleId(String sampleId)
     throws PointOfContactException {
   try {
     CaNanoLabApplicationService appService =
         (CaNanoLabApplicationService) ApplicationServiceProvider.getApplicationService();
     DetachedCriteria crit =
         DetachedCriteria.forClass(Sample.class)
             .add(Property.forName("id").eq(new Long(sampleId)));
     crit.setFetchMode("primaryPointOfContact", FetchMode.JOIN);
     crit.setFetchMode("primaryPointOfContact.organization", FetchMode.JOIN);
     crit.setFetchMode("otherPointOfContactCollection", FetchMode.JOIN);
     crit.setFetchMode("otherPointOfContactCollection.organization", FetchMode.JOIN);
     crit.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
     List results = appService.query(crit);
     List<PointOfContactBean> pointOfContactCollection = new ArrayList<PointOfContactBean>();
     for (int i = 0; i < results.size(); i++) {
       Sample particle = (Sample) results.get(i);
       PointOfContact primaryPOC = particle.getPrimaryPointOfContact();
       Collection<PointOfContact> otherPOCs = particle.getOtherPointOfContactCollection();
       pointOfContactCollection.add(new PointOfContactBean(primaryPOC));
       for (PointOfContact poc : otherPOCs) {
         pointOfContactCollection.add(new PointOfContactBean(poc));
       }
     }
     return pointOfContactCollection;
   } catch (Exception e) {
     String err = "Problem finding all PointOfContact collections with the given sample ID.";
     logger.error(err, e);
     throw new PointOfContactException(err, e);
   }
 }
 @SuppressWarnings("unchecked")
 @Override
 public List<CtSubmenus> getSubmenus(List<Integer> listOfMenus) throws Exception {
   DetachedCriteria criteria = DetachedCriteria.forClass(CtSubmenus.class);
   criteria.setResultTransformer(DetachedCriteria.DISTINCT_ROOT_ENTITY);
   criteria.setFetchMode("CtMenus", FetchMode.JOIN);
   criteria.add(Property.forName("CtMenus.idMenu").in(listOfMenus));
   List<CtSubmenus> listOfSubmenus = getHibernateTemplate().findByCriteria(criteria);
   log.debug("Se obtuvieron " + listOfSubmenus.size() + " registros de la tabla CtSubmenus.");
   return listOfSubmenus;
 }
Exemplo n.º 3
0
  /*
   * (non-Javadoc)
   *
   * @see com.changpeng.common.action.AbstractAction#go()
   */
  @Override
  protected String go() throws Exception {

    DetachedCriteria detachedCriteria =
        DetachedCriteria.forClass(SysUser.class).add(Restrictions.eq("roleid", 1));

    // 这里要判断出登录帐号所属的group
    // 如果是admin,看所有的,如果不是admin,则根据登录人员的所属角色,判断角色对用户和对部门的可见性

    if (loginname != null && !"".equals(loginname))
      detachedCriteria.add(Restrictions.like("loginname", loginname, MatchMode.ANYWHERE));
    if (username != null && !"".equals(username))
      detachedCriteria.add(Restrictions.like("username", username, MatchMode.ANYWHERE));
    if (systemno != null && !"".equals(systemno))
      detachedCriteria.add(Restrictions.like("systemno", systemno, MatchMode.ANYWHERE));
    // 必须是没有删除的啊
    detachedCriteria.add(Restrictions.eq("delflag", false));
    // 取消掉自己的显示
    detachedCriteria.add(Restrictions.ne("userid", getLoginUser().getUserid()));
    SysUser sysUser = getLoginUser();
    SysGroup group = sysUser.getSysGroup();
    // 如果没有所属的group,则能查看所有的数据信息,否则只能看本部门和下级部门的数据
    if (group != null && group.getGroupid() != 1) { // 不是深圳律协的人上来的话
      int groupid = group.getGroupid();
      GroupTree tree = new GroupTree();
      List groupidlist = tree.getChildGroupIds(groupid);
      detachedCriteria
          .createAlias("sysGroup", "sysGroup")
          .add(Restrictions.in("sysGroup.groupid", groupidlist));
      if (groupname != null && !"".equals(groupname)) {
        detachedCriteria.add(
            Restrictions.like("sysGroup.groupname", groupname, MatchMode.ANYWHERE));
      }

      // detachedCriteria.add(Restrictions.in("groupid", groupidlist));
    } else if (groupname != null && !"".equals(groupname)) {
      detachedCriteria
          .createAlias("sysGroup", "sysGroup")
          .add(Restrictions.like("sysGroup.groupname", groupname, MatchMode.ANYWHERE));
    }
    detachedCriteria.setFetchMode("sysGroup", FetchMode.JOIN);

    // 按userid逆序排序
    detachedCriteria.addOrder(Order.desc("userid"));
    BasicService service = (BasicService) getBean("basicService");
    this.page = service.findPageByCriteria(detachedCriteria, pageSize, pageNo);
    // TODO Auto-generated method stub
    return SUCCESS;
  }
 @SuppressWarnings("unchecked")
 @Override
 public DHashes getUserHash(Integer idUsuario) throws Exception {
   DetachedCriteria criteria = DetachedCriteria.forClass(DHashes.class);
   criteria.setResultTransformer(DetachedCriteria.DISTINCT_ROOT_ENTITY);
   criteria.setFetchMode("CtUsuarios", FetchMode.JOIN);
   criteria.add(Property.forName("CtUsuarios.idUsuario").eq(idUsuario));
   List<DHashes> listOfHashes = getHibernateTemplate().findByCriteria(criteria);
   if (listOfHashes.size() > 0) {
     log.info("Se encontro hash asociado al usuario con id " + idUsuario);
     return listOfHashes.get(0);
   } else {
     return null;
   }
 }
  private Sample findFullyLoadedSampleByName(String sampleName) throws Exception {
    CaNanoLabApplicationService appService =
        (CaNanoLabApplicationService) ApplicationServiceProvider.getApplicationService();
    // load composition and characterization separate because of Hibernate
    // join limitation
    DetachedCriteria crit =
        DetachedCriteria.forClass(Sample.class)
            .add(Property.forName("name").eq(sampleName).ignoreCase());
    Sample sample = null;

    // load composition and characterization separate because of
    // Hibernate join limitation
    crit.setFetchMode("primaryPointOfContact", FetchMode.JOIN);
    crit.setFetchMode("primaryPointOfContact.organization", FetchMode.JOIN);
    crit.setFetchMode("otherPointOfContactCollection", FetchMode.JOIN);
    crit.setFetchMode("otherPointOfContactCollection.organization", FetchMode.JOIN);
    crit.setFetchMode("keywordCollection", FetchMode.JOIN);
    crit.setFetchMode("publicationCollection", FetchMode.JOIN);
    crit.setFetchMode("publicationCollection.authorCollection", FetchMode.JOIN);
    crit.setFetchMode("publicationCollection.keywordCollection", FetchMode.JOIN);
    crit.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);

    List result = appService.query(crit);
    if (!result.isEmpty()) {
      sample = (Sample) result.get(0);
    }
    if (sample == null) {
      throw new NotExistException("Sample doesn't exist in the database");
    }

    // fully load composition
    SampleComposition comp = this.loadComposition(sample.getId().toString());
    sample.setSampleComposition(comp);

    // fully load characterizations
    List<Characterization> chars = this.loadCharacterizations(sample.getId().toString());
    if (chars != null && !chars.isEmpty()) {
      sample.setCharacterizationCollection(new HashSet<Characterization>(chars));
    } else {
      sample.setCharacterizationCollection(null);
    }
    return sample;
  }
Exemplo n.º 6
0
  private void addCriteria(DetachedCriteria dc, String yearMonth) {
    dc.createAlias("emp." + Employee.PROP_EMP_DEPT_NO, "empOrgDept", 1);
    dc.createAlias("emp." + Employee.PROP_EMP_LOCATION_NO, "empOrgLoc", 1);
    dc.createAlias(Attendmonthly.PROP_ATTM_PB_NO, "attmPbNo", 1);

    dc.add(Restrictions.eq(Attendmonthly.PROP_ATTM_YEARMONTH, yearMonth));
    BaseCrit.addEmpDC(dc, "emp", this.emp);

    if (this.employee != null) {
      BaseCrit.addDC(dc, "emp." + Employee.PROP_ID, "eq", new String[] {this.employee.getId()});

      BaseCrit.addDeptDC(
          dc,
          "emp." + Employee.PROP_EMP_DEPT_NO,
          "emp." + Employee.PROP_EMP_PB_NO,
          null,
          this.employee.getEmpDeptNo());
      BaseCrit.addDC(
          dc,
          "emp." + Employee.PROP_EMP_TYPE,
          Emptype.PROP_ID,
          new Object[] {this.employee.getEmpType()});
      BaseCrit.addDC(
          dc,
          "emp." + Employee.PROP_EMP_LOCATION_NO,
          Location.PROP_ID,
          new Object[] {this.employee.getEmpLocationNo()});
    }

    if (this.searchType != 0) {
      switch (this.searchType) {
        case 1:
          dc.add(Restrictions.gt("attmLeaveHours", new BigDecimal(0)));
          break;
        case 2:
          dc.add(Restrictions.gt("attmLateTimes", new BigDecimal(0)));
          break;
        case 3:
          dc.add(Restrictions.gt("attmEarlyLeave", new BigDecimal(0)));
          break;
        case 4:
          dc.add(Restrictions.gt("attmOvertimeHours", new BigDecimal(0)));
          break;
        case 5:
          dc.add(Restrictions.gt("attmOffDutyHours", new BigDecimal(0)));
      }
    }

    if ("export".equals(this.searchOrExport)) {
      dc.setFetchMode(Attendmonthly.PROP_ATTM_DEPT, FetchMode.JOIN);
      dc.setFetchMode(Attendmonthly.PROP_ATTM_LOCATION, FetchMode.JOIN);
      dc.setFetchMode(Attendmonthly.PROP_ATTM_EMPTYPE, FetchMode.JOIN);
      dc.setFetchMode(Attendmonthly.PROP_ATTM_PB_NO, FetchMode.JOIN);

      addOrders(dc, null, new String[] {"emp." + Employee.PROP_EMP_DISTINCT_NO + "-up"});
    } else {
      addOrders(dc, this.page, new String[] {"emp." + Employee.PROP_EMP_DISTINCT_NO + "-up"});

      this.page.splitPage(dc);
    }
  }
Exemplo n.º 7
0
  public String requestService(org.dom4j.Element rootElement) {

    StringBuilder result = new StringBuilder();
    StringBuilder temp = new StringBuilder();
    StringBuilder lawyertemp = new StringBuilder();
    result.append("<response>");
    try {
      BasicService userservice = (BasicService) globals.getBean("basicService");
      DetachedCriteria detachedCriteria =
          DetachedCriteria.forClass(SysUser.class)
              .add(Restrictions.eq("roleid", 1))
              .add(Restrictions.eq("delflag", false));
      detachedCriteria.setFetchMode("sysGroup", FetchMode.JOIN);
      List list = userservice.findAllByCriteria(detachedCriteria);
      int lawersize = list == null ? 0 : list.size();
      temp.append("<respcode>").append(lawersize).append("</respcode>");
      temp.append("<respmsg>").append("有" + lawersize + "个律师").append("</respmsg>");

      lawyertemp.append("<lawyers>");
      for (int i = 0; i < lawersize; i++) {
        SysUser lawyer = (SysUser) list.get(i);
        // 有事务所并且不是离职的律师了
        String cardno = lawyer.getCardno();
        if (lawyer.getSysGroup() != null
            && lawyer.getSysGroup().getGroupid() != -1
            && cardno != null
            && !cardno.trim().equals("")) {
          lawyertemp.append("<lawyer>");
          lawyertemp.append("<userid>").append(lawyer.getUserid()).append("</userid>");
          lawyertemp
              .append("<cardno>")
              .append(lawyer.getCardno() == null ? "" : lawyer.getCardno())
              .append("</cardno>");
          lawyertemp
              .append("<username>")
              .append(lawyer.getUsername() == null ? "" : lawyer.getUsername())
              .append("</username>");

          lawyertemp
              .append("<officename>")
              .append(lawyer.getSysGroup().getGroupname())
              .append("</officename>");

          lawyertemp
              .append("<mobile>")
              .append(lawyer.getSystemno() == null ? "" : lawyer.getSystemno())
              .append("</mobile>");
          //					lawyertemp.append("<mobile>").append(lawyer.getMobile() == null ? "" :
          // lawyer.getMobile()).append("</mobile>");
          lawyertemp.append("<lawyerno>").append(lawyer.getLawerno()).append("</lawyerno>");
          lawyertemp
              .append("<photo>")
              .append(lawyer.getPhoto() == null ? "" : lawyer.getPhoto())
              .append("</photo>");
          lawyertemp.append("</lawyer>\r\n");
        } else {
          LOG.info(lawyer.getUsername() + "所在的事务所为空,忽略");
        }
      }
      lawyertemp.append("</lawyers>");

    } catch (Exception e) {
      LOG.error(e);
      result.append("<respcode>").append(-1).append("</respcode>");
      result.append("<respmsg>获取律师信息异常:").append(e.getMessage()).append("</respmsg>");
    }
    result.append(temp);
    result.append(lawyertemp);
    result.append("</response>");
    return result.toString();
  }
  private List<Characterization> loadCharacterizations(String sampleId) throws Exception {
    List<Characterization> chars = new ArrayList<Characterization>();

    CaNanoLabApplicationService appService =
        (CaNanoLabApplicationService) ApplicationServiceProvider.getApplicationService();
    DetachedCriteria crit = DetachedCriteria.forClass(Characterization.class);
    crit.createAlias("sample", "sample");
    crit.add(Property.forName("sample.id").eq(new Long(sampleId)));
    // fully load characterization
    crit.setFetchMode("pointOfContact", FetchMode.JOIN);
    crit.setFetchMode("pointOfContact.organization", FetchMode.JOIN);
    crit.setFetchMode("protocol", FetchMode.JOIN);
    crit.setFetchMode("protocol.file", FetchMode.JOIN);
    crit.setFetchMode("protocol.file.keywordCollection", FetchMode.JOIN);
    crit.setFetchMode("experimentConfigCollection", FetchMode.JOIN);
    crit.setFetchMode("experimentConfigCollection.technique", FetchMode.JOIN);
    crit.setFetchMode("experimentConfigCollection.instrumentCollection", FetchMode.JOIN);
    crit.setFetchMode("findingCollection", FetchMode.JOIN);
    crit.setFetchMode("findingCollection.datumCollection", FetchMode.JOIN);
    crit.setFetchMode("findingCollection.datumCollection.conditionCollection", FetchMode.JOIN);
    crit.setFetchMode("findingCollection.fileCollection", FetchMode.JOIN);
    crit.setFetchMode("findingCollection.fileCollection.keywordCollection", FetchMode.JOIN);
    crit.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
    List results = appService.query(crit);

    for (int i = 0; i < results.size(); i++) {
      Characterization achar = (Characterization) results.get(i);
      chars.add(achar);
    }
    return chars;
  }
  private SampleComposition loadComposition(String sampleId) throws Exception {
    SampleComposition composition = null;

    CaNanoLabApplicationService appService =
        (CaNanoLabApplicationService) ApplicationServiceProvider.getApplicationService();
    DetachedCriteria crit = DetachedCriteria.forClass(SampleComposition.class);
    crit.createAlias("sample", "sample");
    crit.add(Property.forName("sample.id").eq(new Long(sampleId)));
    crit.setFetchMode("nanomaterialEntityCollection", FetchMode.JOIN);
    crit.setFetchMode("nanomaterialEntityCollection.fileCollection", FetchMode.JOIN);
    crit.setFetchMode(
        "nanomaterialEntityCollection.fileCollection.keywordCollection", FetchMode.JOIN);
    crit.setFetchMode("nanomaterialEntityCollection.composingElementCollection", FetchMode.JOIN);
    crit.setFetchMode(
        "nanomaterialEntityCollection.composingElementCollection.inherentFunctionCollection",
        FetchMode.JOIN);
    crit.setFetchMode(
        "nanomaterialEntityCollection.composingElementCollection.inherentFunctionCollection.targetCollection",
        FetchMode.JOIN);
    crit.setFetchMode("functionalizingEntityCollection", FetchMode.JOIN);
    crit.setFetchMode("functionalizingEntityCollection.fileCollection", FetchMode.JOIN);
    crit.setFetchMode(
        "functionalizingEntityCollection.fileCollection.keywordCollection", FetchMode.JOIN);
    crit.setFetchMode("functionalizingEntityCollection.functionCollection", FetchMode.JOIN);
    crit.setFetchMode(
        "functionalizingEntityCollection.functionCollection.targetCollection", FetchMode.JOIN);
    crit.setFetchMode("functionalizingEntityCollection.activationMethod", FetchMode.JOIN);
    crit.setFetchMode("chemicalAssociationCollection", FetchMode.JOIN);
    crit.setFetchMode("chemicalAssociationCollection.fileCollection", FetchMode.JOIN);
    crit.setFetchMode(
        "chemicalAssociationCollection.fileCollection.keywordCollection", FetchMode.JOIN);
    crit.setFetchMode("chemicalAssociationCollection.associatedElementA", FetchMode.JOIN);
    crit.setFetchMode("chemicalAssociationCollection.associatedElementB", FetchMode.JOIN);
    crit.setFetchMode("fileCollection", FetchMode.JOIN);
    crit.setFetchMode("fileCollection.keywordCollection", FetchMode.JOIN);
    crit.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
    List result = appService.query(crit);

    if (!result.isEmpty()) {
      composition = (SampleComposition) result.get(0);
    }
    return composition;
  }