use of org.kuali.kfs.core.api.mo.common.active.MutableInactivatable in project cu-kfs by CU-CommunityApps.
the class BatchFeedHelperServiceImpl method performExistenceAndActiveValidation.
/**
* @see com.rsmart.kuali.kfs.sys.batch.service.BatchFeedHelperService#performExistenceAndActiveValidation(org.kuali.kfs.kns.bo.PersistableBusinessObject,
* java.lang.String, java.lang.String, org.kuali.kfs.kns.util.ErrorMap)
*/
public void performExistenceAndActiveValidation(PersistableBusinessObject businessObject, String referenceName, String propertyName, MessageMap errorMap) {
Object propertyValue = ObjectUtils.getPropertyValue(businessObject, propertyName);
if (propertyValue != null) {
businessObject.refreshReferenceObject(referenceName);
Object referenceValue = ObjectUtils.getPropertyValue(businessObject, referenceName);
if (ObjectUtils.isNull(referenceValue)) {
addExistenceError(propertyName, propertyValue.toString(), errorMap);
} else if (MutableInactivatable.class.isAssignableFrom(referenceValue.getClass())) {
if (!((MutableInactivatable) referenceValue).isActive()) {
addInactiveError(propertyName, propertyValue.toString(), errorMap);
}
}
}
}
use of org.kuali.kfs.core.api.mo.common.active.MutableInactivatable in project cu-kfs by CU-CommunityApps.
the class RassUpdateServiceImpl method mergeBusinessObjectListProperty.
protected void mergeBusinessObjectListProperty(Object businessObject, RassListPropertyDefinition listPropertyMapping, List<?> newSubObjects) {
RassSubObjectDefinition subObjectDefinition = listPropertyMapping.getSubObjectDefinition();
List<Object> existingList = ObjectPropertyUtils.getPropertyValue(businessObject, listPropertyMapping.getBoPropertyName());
Set<Integer> indexesOfSubObjectsToInactivate = IntStream.range(0, existingList.size()).mapToObj(Integer::valueOf).collect(Collectors.toCollection(HashSet::new));
for (Object newSubObject : newSubObjects) {
int i = 0;
while (i < existingList.size() && !subObjectPrimaryKeysMatch(subObjectDefinition, existingList.get(i), newSubObject)) {
i++;
}
if (i < existingList.size()) {
mergeNonPrimaryKeyUpdatesIntoExistingSubObject(subObjectDefinition, existingList.get(i), newSubObject);
indexesOfSubObjectsToInactivate.remove(i);
} else {
existingList.add(newSubObject);
}
}
for (Integer indexOfObjectToInactivate : indexesOfSubObjectsToInactivate) {
Object existingSubObject = existingList.get(indexOfObjectToInactivate);
if (existingSubObject instanceof MutableInactivatable) {
((MutableInactivatable) existingSubObject).setActive(false);
}
if (existingSubObject instanceof Primaryable && StringUtils.isNotBlank(subObjectDefinition.getPrimaryIndicatorPropertyName())) {
ObjectPropertyUtils.setPropertyValue(existingSubObject, subObjectDefinition.getPrimaryIndicatorPropertyName(), Boolean.FALSE);
}
}
}
use of org.kuali.kfs.core.api.mo.common.active.MutableInactivatable in project cu-kfs by CU-CommunityApps.
the class RassServiceImplTest method assertProjectDirectorsWereUpdatedAsExpected.
private void assertProjectDirectorsWereUpdatedAsExpected(RassXmlAwardEntryFixture expectedAwardOrProposal, List<? extends CGProjectDirector> actualDirectors, int i) {
List<RassXMLAwardPiCoPiEntryFixture> expectedDirectors = expectedAwardOrProposal.piFixtures;
assertEquals("Wrong number of directors at index " + i, expectedDirectors.size(), actualDirectors.size());
for (int j = 0; j < expectedDirectors.size(); j++) {
String multiIndex = i + KFSConstants.COMMA + j;
RassXMLAwardPiCoPiEntryFixture expectedDirector = expectedDirectors.get(j);
CGProjectDirector actualDirector = actualDirectors.get(j);
assertEquals("Wrong proposal number for director at index " + multiIndex, expectedAwardOrProposal.proposalNumber, actualDirector.getProposalNumber());
assertEquals("Wrong principal ID/name for director at index " + multiIndex + " in spite of principalId/principalName equivalency for this test scenario", expectedDirector.projectDirectorPrincipalName, actualDirector.getPrincipalId());
assertTrue("A primary director indicator should have been supported for director at index " + multiIndex, actualDirector instanceof Primaryable);
assertEquals("Wrong primary director indicator for director at index " + multiIndex, expectedDirector.getNullSafePrimary(), ((Primaryable) actualDirector).isPrimary());
assertTrue("An active-object indicator should have been supported for director at index " + multiIndex, actualDirector instanceof MutableInactivatable);
assertEquals("Wrong active indicator for director at index " + multiIndex, expectedDirector.getNullSafeActive(), ((MutableInactivatable) actualDirector).isActive());
}
}
use of org.kuali.kfs.core.api.mo.common.active.MutableInactivatable in project cu-kfs by CU-CommunityApps.
the class RassServiceImplTest method assertObjectsWereUpdatedAsExpected.
private <E extends Enum<E>, R extends PersistableBusinessObject> void assertObjectsWereUpdatedAsExpected(ExpectedObjectUpdateResultGrouping<E, R> expectedResultGrouping, List<Maintainable> actualResults, ObjectUpdateValidator<E, R> resultValidator) {
List<ExpectedObjectUpdateResult<E>> expectedResults = findExpectedSuccessfulResults(expectedResultGrouping.getExpectedObjectUpdateResults());
Class<R> businessObjectClass = expectedResultGrouping.getBusinessObjectClass();
String objectLabel = businessObjectClass.getSimpleName();
assertEquals("Wrong number of " + objectLabel + " objects created or updated for file", expectedResults.size(), actualResults.size());
for (int i = 0; i < expectedResults.size(); i++) {
ExpectedObjectUpdateResult<E> expectedResult = expectedResults.get(i);
Maintainable actualResult = actualResults.get(i);
assertEquals("Wrong maintenance action for " + objectLabel + " at index " + i, expectedResult.getExpectedMaintenanceAction(), actualResult.getMaintenanceAction());
E expectedObjectFixture = expectedResult.getBusinessObjectFixture();
R actualObject = businessObjectClass.cast(actualResult.getDataObject());
if ((actualObject instanceof MutableInactivatable) && (KRADConstants.MAINTENANCE_NEW_ACTION.equalsIgnoreCase(actualResult.getMaintenanceAction()))) {
assertTrue(objectLabel + " at index " + i + " should have been marked as active", ((MutableInactivatable) actualObject).isActive());
}
resultValidator.assertObjectWasUpdatedAsExpected(expectedObjectFixture, actualObject, i);
}
}
Aggregations