Coverage Report - org.kuali.student.lum.program.server.metadata.ProgramMetadataServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ProgramMetadataServiceImpl
0%
0/18
0%
0/12
3.25
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may
 3  
  * not use this file except in compliance with the License. You may obtain a copy of the License at
 4  
  * http://www.osedu.org/licenses/ECL-2.0 Unless required by applicable law or agreed to in writing, software distributed
 5  
  * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 6  
  * implied. See the License for the specific language governing permissions and limitations under the License.
 7  
  */
 8  
 
 9  
 package org.kuali.student.lum.program.server.metadata;
 10  
 
 11  
 import java.util.ArrayList;
 12  
 import java.util.List;
 13  
 
 14  
 import org.kuali.student.common.assembly.data.ConstraintMetadata;
 15  
 import org.kuali.student.common.assembly.dictionary.MetadataServiceImpl;
 16  
 import org.kuali.student.common.dictionary.dto.FieldDefinition;
 17  
 import org.kuali.student.common.dictionary.service.DictionaryService;
 18  
 import org.kuali.student.common.dto.DtoConstants.DtoState;
 19  
 import org.kuali.student.lum.lu.LUConstants;
 20  
 
 21  
 /**
 22  
  * This class provides metadata lookup for service dto objects.
 23  
  * 
 24  
  * @author Kuali Student Team
 25  
  */
 26  
 public class ProgramMetadataServiceImpl extends MetadataServiceImpl {
 27  
 
 28  
     public ProgramMetadataServiceImpl(DictionaryService... dictionaryServices) {
 29  0
         super(dictionaryServices);
 30  0
     }
 31  
 
 32  
     @Override
 33  
     protected List<ConstraintMetadata> getConstraints(FieldDefinition fd, String type, String state, String nextState,
 34  
             String workflowNode, String documentTypeName) {
 35  0
         List<ConstraintMetadata> constraints = new ArrayList<ConstraintMetadata>();
 36  0
         ConstraintMetadata constraintMetadata = new ConstraintMetadata();
 37  
         //The nextState should not get a defaulted value when we're using Modify Program Proposal functionality.
 38  0
         String nextStateValue = nextState;
 39  0
         if (!LUConstants.PROPOSAL_TYPE_MAJOR_DISCIPLINE_MODIFY.equals(documentTypeName)) {
 40  0
             nextStateValue = getNextState(state);
 41  
         }
 42  0
         updateConstraintMetadata(constraintMetadata, fd, type, getNonNullState(state), nextStateValue, workflowNode);
 43  0
         constraints.add(constraintMetadata);
 44  
 
 45  0
         return constraints;
 46  
     }
 47  
 
 48  
     private String getNonNullState(String state) {
 49  0
         return (null == state ? DtoState.DRAFT.toString() : state);
 50  
     }
 51  
 
 52  
     private String getNextState(String state) {
 53  0
         if (null == state || DtoState.DRAFT.toString().equalsIgnoreCase(state)) {
 54  0
             return DtoState.APPROVED.toString();
 55  0
         } else if (DtoState.APPROVED.toString().equalsIgnoreCase(state)) {
 56  0
             return DtoState.ACTIVE.toString();
 57  0
         } else if (DtoState.ACTIVE.toString().equalsIgnoreCase(state)) {
 58  0
             return DtoState.SUPERSEDED.toString();
 59  
         }
 60  0
         return null;
 61  
     }
 62  
 }