| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| MockHelper |
|
| 1.0;1 |
| 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.mock.utilities; | |
| 17 | ||
| 18 | ||
| 19 | import java.util.Date; | |
| 20 | ||
| 21 | import org.kuali.student.r2.common.dto.ContextInfo; | |
| 22 | import org.kuali.student.r2.common.dto.MetaInfo; | |
| 23 | import org.kuali.student.r2.common.infc.*; | |
| 24 | ||
| 25 | ||
| 26 | /** | |
| 27 | * A helper class for the Mock implementation | |
| 28 | * @author nwright | |
| 29 | */ | |
| 30 | 0 | public class MockHelper { |
| 31 | ||
| 32 | /** | |
| 33 | * Create a new MetaInfo with the create id and time as well as the update | |
| 34 | * date and time and version ind set | |
| 35 | * @param context | |
| 36 | * @return | |
| 37 | */ | |
| 38 | public MetaInfo createMeta(Context context) { | |
| 39 | 0 | MetaInfo mInfo = MetaInfo.newInstance(); |
| 40 | 0 | Date now = new Date(); |
| 41 | 0 | mInfo.setCreateId(context.getPrincipalId()); |
| 42 | 0 | mInfo.setCreateTime(now); |
| 43 | 0 | mInfo.setUpdateId(context.getPrincipalId()); |
| 44 | 0 | mInfo.setUpdateTime(now); |
| 45 | 0 | mInfo.setVersionInd("1"); |
| 46 | 0 | return mInfo; |
| 47 | } | |
| 48 | ||
| 49 | /** | |
| 50 | * Updates the MetaInfo with new user id and date stamp | |
| 51 | * Also increments the verssion indicator | |
| 52 | * @param orig | |
| 53 | * @param context | |
| 54 | * @return new metainfo | |
| 55 | */ | |
| 56 | public MetaInfo updateMeta(Meta orig, Context context) { | |
| 57 | 0 | Date now = new Date(); |
| 58 | 0 | int oldVersionInd = Integer.parseInt(orig.getVersionInd()); |
| 59 | 0 | MetaInfo mInfo = MetaInfo.getInstance(orig); |
| 60 | 0 | mInfo.setUpdateId(context.getPrincipalId()); |
| 61 | 0 | mInfo.setUpdateTime(now); |
| 62 | 0 | mInfo.setVersionInd("" + (oldVersionInd + 1)); |
| 63 | 0 | return mInfo; |
| 64 | } | |
| 65 | ||
| 66 | ||
| 67 | ||
| 68 | } | |
| 69 |