Exemple #1
0
 @SuppressWarnings("unchecked")
 @Override
 public void applySyncChange(Award award, AwardSyncChange change)
     throws NoSuchFieldException, IllegalAccessException, InvocationTargetException,
         ClassNotFoundException, NoSuchMethodException, InstantiationException,
         AwardSyncException {
   Collection awardPersons = award.getProjectPersons();
   AwardSyncXmlExport unitExport =
       (AwardSyncXmlExport) change.getXmlExport().getValues().get("units");
   AwardPerson person =
       (AwardPerson)
           getAwardSyncUtilityService()
               .findMatchingBo(awardPersons, change.getXmlExport().getKeys());
   if (StringUtils.equals(change.getSyncType(), AwardSyncType.ADD_SYNC.getSyncValue())) {
     if (person != null) {
       checkAndFixLeadUnit(person, unitExport);
       setValuesOnSyncable(person, change.getXmlExport().getValues(), change);
       fixLeadUnit(award, person);
     } else {
       throw new AwardSyncException(Constants.AWARD_SYNC_NOT_APPLICABLE, true);
     }
   } else {
     if (person != null) {
       AwardPersonUnit unit =
           (AwardPersonUnit)
               getAwardSyncUtilityService()
                   .findMatchingBo((Collection) person.getUnits(), unitExport.getKeys());
       if (unit != null) {
         person.getUnits().remove(unit);
       }
     } else {
       throw new AwardSyncException(Constants.AWARD_SYNC_NOT_APPLICABLE, true);
     }
   }
 }
Exemple #2
0
 /**
  * If the export is for a lead unit, then clear other lead unit identifiers.
  *
  * @param person
  * @param export
  */
 protected void checkAndFixLeadUnit(AwardPerson person, AwardSyncXmlExport export) {
   if ((Boolean) export.getValues().get("leadUnit")) {
     // if we are syncing a lead unit, remove any other lead units
     for (AwardPersonUnit unit : person.getUnits()) {
       unit.setLeadUnit(false);
     }
   }
 }