Coverage Report - org.kuali.student.lum.program.server.transform.VersionCredentialProgramFilter
 
Classes in this File Line Coverage Branch Coverage Complexity
VersionCredentialProgramFilter
0%
0/13
0%
0/4
3
 
 1  
 package org.kuali.student.lum.program.server.transform;
 2  
 
 3  
 import java.util.Map;
 4  
 
 5  
 import org.kuali.student.common.assembly.data.Data;
 6  
 import org.kuali.student.common.assembly.data.Metadata;
 7  
 import org.kuali.student.lum.program.client.ProgramConstants;
 8  
 import org.kuali.student.lum.program.dto.CredentialProgramInfo;
 9  
 
 10  
 /**
 11  
  * When credential program is activated this filter sets the previous version to superseded and updates the end program
 12  
  * entry and and enroll terms. 
 13  
  * 
 14  
  * @author Will
 15  
  *
 16  
  */
 17  0
 public class VersionCredentialProgramFilter extends VersionProgramFilter {
 18  
 
 19  
         @Override
 20  
         public void applyOutboundDataFilter(Data data, Metadata metadata,
 21  
                         Map<String, Object> properties) throws Exception {
 22  0
                 Data previousVersionData = (Data)properties.get(VersionProgramFilter.PREVIOUS_VERSION_DATA);
 23  0
                 String versionFromId = data.query(ProgramConstants.VERSION_FROM_ID);
 24  
                 
 25  0
                 if (versionFromId != null){
 26  0
                         CredentialProgramInfo previousVersionCoreInfo = programService.getCredentialProgram(versionFromId);
 27  
                         
 28  0
                         if (previousVersionData == null){
 29  
                                 //This is an initial get. Create previous version data to send back to client 
 30  0
                                 previousVersionData = new Data();
 31  0
                                 previousVersionData.set(ProgramConstants.ID, previousVersionCoreInfo.getId());
 32  0
                                 previousVersionData.set(ProgramConstants.END_PROGRAM_ENTRY_TERM, previousVersionCoreInfo.getEndProgramEntryTerm());
 33  0
                                 previousVersionData.set(ProgramConstants.END_PROGRAM_ENROLL_TERM, previousVersionCoreInfo.getEndTerm());
 34  0
                                 previousVersionData.set(ProgramConstants.STATE, previousVersionCoreInfo.getState());
 35  
                         } 
 36  
                         
 37  0
                         data.set(PREVIOUS_VERSION_INFO, previousVersionData);
 38  
                 }                
 39  0
         }
 40  
 
 41  
 }