예제 #1
0
  protected List<ModelWrapper<?>> search() throws Exception {
    List<ModelWrapper<?>> wrappers = new ArrayList<ModelWrapper<?>>();
    if (radioWaybill.getSelection()) {
      wrappers.addAll(
          OriginInfoWrapper.getShipmentsByWaybill(
              SessionManager.getAppService(), treeText.getText().trim()));
      wrappers.addAll(
          DispatchWrapper.getDispatchesByWaybill(
              SessionManager.getAppService(), treeText.getText().trim()));
      return wrappers;

    } else if (radioDateReceived.getSelection()) {
      Date date = dateWidget.getDate();
      if (date != null) {
        wrappers.addAll(
            OriginInfoWrapper.getShipmentsByDateReceived(
                SessionManager.getAppService(),
                date,
                SessionManager.getUser().getCurrentWorkingCenter()));
        wrappers.addAll(
            DispatchWrapper.getDispatchesByDateReceived(
                SessionManager.getAppService(),
                date,
                SessionManager.getUser().getCurrentWorkingCenter()));
        return wrappers;
      }
    } else {
      Date date = dateWidget.getDate();
      if (date != null) {
        wrappers.addAll(
            OriginInfoWrapper.getShipmentsByDateSent(
                SessionManager.getAppService(),
                date,
                SessionManager.getUser().getCurrentWorkingCenter()));
        wrappers.addAll(
            DispatchWrapper.getDispatchesByDateSent(
                SessionManager.getAppService(),
                date,
                SessionManager.getUser().getCurrentWorkingCenter()));
        return wrappers;
      }
    }
    return null;
  }
예제 #2
0
  public static AbstractAdapterBase addToNode(AdapterBase parentNode, Object obj) {
    if (currentInstance != null && obj instanceof OriginInfoWrapper) {
      OriginInfoWrapper originInfo = (OriginInfoWrapper) obj;
      String text = ""; // $NON-NLS-1$
      AdapterBase topNode = parentNode;
      if (parentNode.equals(currentInstance.searchedNode)
          && !currentInstance.radioWaybill.getSelection()) {
        Date date;
        if (currentInstance.radioDateReceived.getSelection()) {
          text = Messages.SpecimenTransitView_date_received_node_label;
          date = originInfo.getShipmentInfo().getReceivedAt();
        } else {
          text = Messages.SpecimenTransitView_date_packed_node_label;
          date = originInfo.getShipmentInfo().getPackedAt();
        }
        if (date == null) return null;
        date = (Date) date.clone();
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(Calendar.SECOND, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.HOUR_OF_DAY, 0);
        date = c.getTime();
        List<AbstractAdapterBase> dateNodeRes =
            parentNode.search(date.getClass(), DateNode.idBuilder(text, date));
        AbstractAdapterBase dateNode = null;
        if (dateNodeRes.size() > 0) dateNode = dateNodeRes.get(0);
        else {
          dateNode = new DateNode(parentNode, text, date);
          parentNode.addChild(dateNode);
        }
        topNode = (AdapterBase) dateNode;
      }

      List<AbstractAdapterBase> centerAdapterList =
          topNode.search(originInfo.getCenter().getClass(), originInfo.getCenter().getId());
      AdapterBase centerAdapter = null;

      if (centerAdapterList.size() > 0) centerAdapter = (AdapterBase) centerAdapterList.get(0);
      else if (originInfo.getCenter() instanceof ClinicWrapper) {
        centerAdapter =
            new ClinicWithShipmentAdapter(topNode, (ClinicWrapper) originInfo.getCenter());
        topNode.addChild(centerAdapter);
      }

      if (centerAdapter != null) {
        ShipmentAdapter shipmentAdapter = null;
        List<AbstractAdapterBase> shipmentAdapterList =
            centerAdapter.search(OriginInfoWrapper.class, originInfo.getId());
        if (shipmentAdapterList.size() > 0)
          shipmentAdapter = (ShipmentAdapter) shipmentAdapterList.get(0);
        else {
          shipmentAdapter = new ShipmentAdapter(centerAdapter, originInfo);
          centerAdapter.addChild(shipmentAdapter);
        }
        return shipmentAdapter;
      }
    } else if (currentInstance != null && obj instanceof DispatchWrapper) {
      List<AbstractAdapterBase> res =
          parentNode.search(DispatchWrapper.class, ((DispatchWrapper) obj).getId());
      if (res.size() == 0) {
        DispatchAdapter dispatch = new DispatchAdapter(parentNode, (DispatchWrapper) obj);
        parentNode.addChild(dispatch);
      }
    }

    return null;
  }