public ShipmentProcessInfo(
     Container pallet, DispatchWrapper dispatch, boolean errorIfAlreadyAdded) {
   super(pallet == null ? null : pallet.getId());
   init(
       dispatch.getDispatchSpecimenCollection(false),
       errorIfAlreadyAdded,
       dispatch.getSenderCenter());
 }
  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;
  }
Esempio n. 3
0
  /*
   * childSpc created in setUp()
   */
  @Test
  public void testGetDispatches() throws Exception {
    String name = "testGetDispatches" + r.nextInt();
    SiteWrapper destSite = SiteHelper.addSite(name);
    ShippingMethodWrapper method = ShippingMethodWrapper.getShippingMethods(appService).get(0);
    DispatchWrapper d = DispatchHelper.addDispatch(site, destSite, method);

    d.addSpecimens(Arrays.asList(childSpc), DispatchSpecimenState.NONE);
    d.persist();
    childSpc.reload();

    List<DispatchWrapper> specimenDispatches = childSpc.getDispatches();
    Assert.assertEquals(1, specimenDispatches.size());
    Assert.assertTrue(specimenDispatches.contains(d));

    Assert.assertTrue(d.isInCreationState());

    // site send specimens
    d.setState(DispatchState.IN_TRANSIT);
    d.persist();
    Assert.assertTrue(d.isInTransitState());

    // dest site receive specimen
    d.setState(DispatchState.RECEIVED);
    d.receiveSpecimens(Arrays.asList(childSpc));
    d.persist();
    Assert.assertTrue(d.isInReceivedState());

    // make sure spc now belongs to destSite
    destSite.reload();
    childSpc.reload();
    Assert.assertEquals(destSite, childSpc.getCurrentCenter());

    // dispatch specimen to second site
    SiteWrapper destSite2 = SiteHelper.addSite(name + "_2");

    DispatchWrapper d2 = DispatchHelper.addDispatch(destSite, destSite2, method);
    d2.addSpecimens(Arrays.asList(childSpc), DispatchSpecimenState.NONE);

    parentSpc.reload();
    // assign a position to this specimen
    ContainerTypeWrapper topType =
        ContainerTypeHelper.addContainerType(destSite, "ct11", "ct11", 1, 5, 6, true);
    ContainerWrapper topCont = ContainerHelper.addContainer("11", "11", destSite, topType);
    ContainerTypeWrapper childType =
        ContainerTypeHelper.addContainerType(destSite, "ct22", "ct22", 2, 4, 7, false);
    topType.addToChildContainerTypeCollection(Arrays.asList(childType));
    topType.persist();
    ContainerWrapper cont =
        ContainerHelper.addContainer("22", "22", topCont, destSite, childType, 4, 5);
    childType.addToSpecimenTypeCollection(Arrays.asList(childSpc.getSpecimenType()));
    childType.persist();
    cont.reload();
    cont.addSpecimen(2, 3, childSpc);
    parentSpc.persist();

    // add to new dispatch
    d2.addSpecimens(Arrays.asList(childSpc), DispatchSpecimenState.NONE);
    d2.persist();

    // make sure spc still belongs to destSite
    destSite2.reload();
    childSpc.reload();
    Assert.assertEquals(destSite2, childSpc.getCurrentCenter());

    childSpc.reload();
    specimenDispatches = childSpc.getDispatches();
    Assert.assertEquals(2, specimenDispatches.size());
    Assert.assertTrue(specimenDispatches.contains(d));
    Assert.assertTrue(specimenDispatches.contains(d2));
  }