@Test
  public void testCampusCodeSearchResults() {
    service.setBusinessObjectClass(Unit.class);

    Map<String, String> fieldValues = new HashMap<String, String>();
    fieldValues.put(CAMPUS_CODE_FIELD, CAMPUS_CODE);
    List<? extends BusinessObject> searchResults = service.getSearchResults(fieldValues);
    assertEquals(SEARCH_RESULTS_CAMPUS_CODE_COUNT, searchResults.size());

    for (BusinessObject searchResult : searchResults) {
      Unit unit = (Unit) searchResult;
      assertTrue(StringUtils.startsWith(unit.getUnitNumber(), CAMPUS_CODE));
    }
  }
Beispiel #2
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) {
     return true;
   }
   if (obj == null) {
     return false;
   }
   if (!(obj instanceof AwardPersonUnit)) {
     return false;
   }
   AwardPersonUnit other = (AwardPersonUnit) obj;
   if (awardPerson == null) {
     if (other.awardPerson != null) {
       return false;
     }
   } else if (!awardPerson.equals(other.awardPerson)) {
     return false;
   }
   if (unit == null) {
     if (other.unit != null) {
       return false;
     }
   } else if (!unit.equals(other.unit)) {
     return false;
   }
   return true;
 }
Beispiel #3
0
 @Override
 public int hashCode() {
   final int PRIME = 31;
   int result = 1;
   result = PRIME * result + ((awardPerson == null) ? 0 : awardPerson.hashCode());
   result = PRIME * result + ((unit == null) ? 0 : unit.hashCode());
   return result;
 }
Beispiel #4
0
 private String getFundingSourceNameForType(int sourceType, String sourceCode) {
   String name = null;
   if (sourceType == 1) {
     Sponsor sponsor =
         getBusinessObjectService().findBySinglePrimaryKey(Sponsor.class, sourceCode);
     if (sponsor != null) {
       name = sponsor.getSponsorName();
     }
   } else if (sourceType == 2) {
     Unit unit = getBusinessObjectService().findBySinglePrimaryKey(Unit.class, sourceCode);
     if (unit != null) {
       name = unit.getUnitName();
     }
   } else {
     name = sourceCode;
   }
   return name;
 }
  /**
   * Uses a <code>{@link Unit}</code> obtained from the <code>{@link Unit}</code> lookup to create a
   * <code>{@link ProposalPersonUnit}</code> instance.
   *
   * @param unitId
   * @return ProposalPersonUnit
   */
  public ProposalPersonUnit createProposalPersonUnit(String unitId, ProposalPerson person) {
    ProposalPersonUnit retval = new ProposalPersonUnit();
    Map valueMap = new HashMap();
    valueMap.put("unitNumber", unitId);
    Collection<Unit> units = getBusinessObjectService().findMatching(Unit.class, valueMap);

    for (Unit found : units) {
      retval.setUnitNumber(found.getUnitNumber());
      retval.setUnit(found);
    }

    for (InvestigatorCreditType creditType : getInvestigatorCreditTypes()) {
      ProposalUnitCreditSplit creditSplit = new ProposalUnitCreditSplit();
      creditSplit.setProposalPersonUnit(retval);
      creditSplit.setInvCreditTypeCode(creditType.getCode());
      creditSplit.setCredit(new ScaleTwoDecimal(0));
      retval.getCreditSplits().add(creditSplit);
    }

    return retval;
  }
Beispiel #6
0
 public List<UnitAdministrator> getOspAdministrators() {
   List<UnitAdministrator> ospAdministrators = new ArrayList<UnitAdministrator>();
   if (unit != null) {
     for (UnitAdministrator unitAdministrator : unit.getUnitAdministrators()) {
       if (unitAdministrator
           .getUnitAdministratorType()
           .getDescription()
           .equals("OSP_ADMINISTRATOR")) {
         ospAdministrators.add(unitAdministrator);
       }
     }
   }
   return ospAdministrators;
 }
Beispiel #7
0
  @Before
  public void buildAllUnits() {
    // unit hierarchy = one-->two-->three
    one = new Unit();
    one.setUnitNumber("ONE");

    two = new Unit();
    two.setUnitNumber("TWO");
    two.setParentUnitNumber("ONE");

    three = new Unit();
    three.setUnitNumber("THREE");
    three.setParentUnitNumber("TWO");

    allUnits =
        new ArrayList<Unit>() {
          {
            add(one);
            add(two);
            add(three);
          }
        };
  }
  @Before
  public void buildAllUnits() {
    // unit hierarchy = one-->two-->three
    one = new Unit();
    one.setUnitNumber(ONE);

    two = new Unit();
    two.setUnitNumber(TWO);
    two.setParentUnitNumber(ONE);

    three = new Unit();
    three.setUnitNumber(THREE);
    three.setParentUnitNumber(TWO);

    // other unit hierachy = one-->other-->another
    other = new Unit();
    other.setUnitNumber(OTHER);
    other.setParentUnitNumber(ONE);

    another = new Unit();
    another.setUnitNumber(ANOTHER);
    another.setParentUnitNumber(OTHER);
  }
  /**
   * Units cannot be moved to its own descendants. This method returns false if it is moving to its
   * own descendants.
   *
   * @param maintenanceDocument
   * @return
   */
  private boolean moveUnit(MaintenanceDocument maintenanceDocument) {

    boolean valid = true;
    Unit unit = (Unit) maintenanceDocument.getNewMaintainableObject().getDataObject();
    String unitNumber = unit.getUnitNumber();
    String parentUnitNumber = unit.getParentUnitNumber();
    List<Unit> allSubUnits =
        KcServiceLocator.getService(UnitService.class).getAllSubUnits(unitNumber);
    for (Unit subunits : allSubUnits) {
      if (subunits.getUnitNumber().equals(parentUnitNumber)) {
        GlobalVariables.getMessageMap()
            .putError(
                "document.newMaintainableObject.parentUnitNumber",
                KeyConstants.MOVE_UNIT_OWN_DESCENDANTS,
                new String[] {unit.getParentUnitNumber(), unit.getParentUnitNumber()});
        valid = false;
      }
    }

    return valid;
  }
 private boolean isChildUnit(String childNumber, String parentNumber) {
   UnitService unitService = KcServiceLocator.getService(UnitService.class);
   Unit childUnit = unitService.getUnit(childNumber);
   Unit parentUnit = unitService.getUnit(parentNumber);
   return childUnit == null || parentUnit == null ? false : childUnit.isParentUnit(parentUnit);
 }
Beispiel #11
0
 /** @param unit */
 public void setUnit(Unit unit) {
   this.unit = unit;
   this.unitNumber = unit != null ? unit.getUnitNumber() : null;
 }
Beispiel #12
0
 public String getUnitName() {
   return unit != null ? unit.getUnitName() : null;
 }
  @Before
  public void setUp() {
    context =
        new JUnit4Mockery() {
          {
            setThreadingPolicy(new Synchroniser());
          }
        };
    roleListBuilder = GenericQueryResults.Builder.create();
    roleListBuilder.setResults(
        new ArrayList<PropAwardPersonRole>() {
          {
            add(createTestRole(3L, "PI", PropAwardPersonRoleServiceImpl.NIH_MULTIPLE_PI_HIERARCHY));
            add(createTestRole(4L, "KP", PropAwardPersonRoleServiceImpl.NIH_MULTIPLE_PI_HIERARCHY));
            add(
                createTestRole(
                    5L, "MPI", PropAwardPersonRoleServiceImpl.NIH_MULTIPLE_PI_HIERARCHY));
            add(
                createTestRole(
                    6L, "COI", PropAwardPersonRoleServiceImpl.NIH_MULTIPLE_PI_HIERARCHY));
          }
        });

    rule = new AwardProjectPersonsSaveRuleImpl();
    award = new Award();
    award.setSponsorCode(SPONSOR_CODE);

    unitA = new Unit();
    unitA.setUnitName("a");
    unitA.setUnitNumber("1");

    unitB = new Unit();
    unitB.setUnitName("b");
    unitB.setUnitNumber("2");

    KcPerson employee = KcPersonFixtureFactory.createKcPerson(PERSON_ID);
    piPerson = new AwardPerson(employee, ContactRoleFixtureFactory.MOCK_PI);
    piPerson.add(new AwardPersonUnit(piPerson, unitA, true));

    NonOrganizationalRolodex nonEmployee;
    nonEmployee = new NonOrganizationalRolodex();
    nonEmployee.setRolodexId(ROLODEX_ID);
    coiPerson = new AwardPerson(nonEmployee, ContactRoleFixtureFactory.MOCK_COI);
    coiPerson.add(new AwardPersonUnit(coiPerson, unitA, false));

    KcPerson employee2 = KcPersonFixtureFactory.createKcPerson(KP_PERSON_ID);
    kpPerson = new AwardPerson(employee2, ContactRoleFixtureFactory.MOCK_KEY_PERSON);
    kpPerson.setKeyPersonRole("Tester");
    kpPerson.add(new AwardPersonUnit(kpPerson, unitA, false));

    piPerson.setAward(award);
    coiPerson.setAward(award);
    kpPerson.setAward(award);

    roleService = getPropAwardPersonRoleService();
    piPerson.setPropAwardPersonRoleService(roleService);
    coiPerson.setPropAwardPersonRoleService(roleService);
    kpPerson.setPropAwardPersonRoleService(roleService);

    award.add(piPerson);
    award.add(coiPerson);
    award.add(kpPerson);

    GlobalVariables.setMessageMap(new MessageMap());
  }