Coverage Report - org.kuali.student.r2.core.class1.atp.service.impl.MockHelper
 
Classes in this File Line Coverage Branch Coverage Complexity
MockHelper
0%
0/20
0%
0/4
1.667
 
 1  
  /*
 2  
  * Copyright 2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may        obtain a copy of the License at
 7  
  *
 8  
  *         http://www.osedu.org/licenses/ECL-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.student.r2.core.class1.atp.service.impl;
 17  
 
 18  
 import java.util.Date;
 19  
 
 20  
 import java.util.List;
 21  
 
 22  
 import org.kuali.student.common.util.UUIDHelper;
 23  
 import org.kuali.student.r2.common.dto.AttributeInfo;
 24  
 import org.kuali.student.r2.common.dto.MetaInfo;
 25  
 import org.kuali.student.r2.common.infc.Context;
 26  
 import org.kuali.student.r2.common.infc.Meta;
 27  
 
 28  
 /**
 29  
  * A helper class for the Mock implementation
 30  
  * @author nwright
 31  
  */
 32  0
 public class MockHelper {
 33  
 
 34  
     /**
 35  
      * Create a new MetaInfo with the create id and time as well as the update
 36  
      * date and time and version ind set
 37  
      * @param context
 38  
      * @return
 39  
      */
 40  
     public MetaInfo createMeta(Context context) {
 41  0
         MetaInfo mInfo = MetaInfo.newInstance();
 42  0
         Date now = new Date();
 43  0
         mInfo.setCreateId(context.getPrincipalId());
 44  0
         mInfo.setCreateTime(now);
 45  0
         mInfo.setUpdateId(context.getPrincipalId());
 46  0
         mInfo.setUpdateTime(now);
 47  0
         mInfo.setVersionInd("1");
 48  0
         return mInfo;
 49  
     }
 50  
 
 51  
     /**
 52  
      * Updates the MetaInfo with new user id and date stamp
 53  
      * Also increments the verssion indicator
 54  
      * @param orig
 55  
      * @param context
 56  
      * @return new metainfo
 57  
      */
 58  
     public MetaInfo updateMeta(Meta orig, Context context) {
 59  0
         Date now = new Date();
 60  0
         int oldVersionInd = Integer.parseInt(orig.getVersionInd());
 61  0
         MetaInfo mInfo = MetaInfo.getInstance(orig);
 62  0
         mInfo.setUpdateId(context.getPrincipalId());
 63  0
         mInfo.setUpdateTime(now);
 64  0
         mInfo.setVersionInd("" + (oldVersionInd + 1));
 65  0
         return mInfo;
 66  
     }
 67  
 
 68  
     /**
 69  
      * Set the id on any attributes that do not have an id already set
 70  
      * @param attrs 
 71  
      */
 72  
     public void setIdOnAttributesThatDoNotHaveOne(List<AttributeInfo> attrs) {
 73  0
         for (AttributeInfo attr : attrs) {
 74  0
             if (attr.getId() == null) {
 75  0
                 attr.setId(UUIDHelper.genStringUUID());
 76  
             }
 77  
         }
 78  0
     }
 79  
 }