Coverage Report - org.kuali.student.lum.common.client.lo.CategoryDataUtil
 
Classes in this File Line Coverage Branch Coverage Complexity
CategoryDataUtil
0%
0/52
0%
0/10
3.5
 
 1  
 package org.kuali.student.lum.common.client.lo;
 2  
 
 3  
 import org.kuali.student.common.assembly.data.Data;
 4  
 import org.kuali.student.common.assembly.data.Data.StringKey;
 5  
 import org.kuali.student.common.dto.MetaInfo;
 6  
 import org.kuali.student.common.dto.RichTextInfo;
 7  
 import org.kuali.student.lum.lo.dto.LoCategoryInfo;
 8  
 
 9  
 import java.util.Date;
 10  
 
 11  0
 public class CategoryDataUtil {
 12  
     
 13  
     public static Data toData(LoCategoryInfo loCategoryInfo) {
 14  0
         LoCategoryInfoHelper catHelper = new LoCategoryInfoHelper();
 15  0
         catHelper.setId(loCategoryInfo.getId());
 16  0
         catHelper.setName(loCategoryInfo.getName());
 17  0
         RichTextInfoHelper catRTHelper = RichTextInfoHelper.wrap(new Data());
 18  0
         RichTextInfo catRT = loCategoryInfo.getDesc();
 19  0
         if (null != catRT) {
 20  0
             catRTHelper.setFormatted(loCategoryInfo.getDesc().getFormatted());
 21  0
             catRTHelper.setPlain(loCategoryInfo.getDesc().getPlain());
 22  
         }
 23  0
         catHelper.setDesc(catRTHelper.getData());
 24  0
         catHelper.setLoRepository(loCategoryInfo.getLoRepository());
 25  0
         catHelper.setEffectiveDate(loCategoryInfo.getEffectiveDate());
 26  0
         catHelper.setExpirationDate(loCategoryInfo.getExpirationDate());
 27  
         /* TODO - doesn't work on the client; what to do?
 28  
         AttributesAssembler attAssembler = new AttributesAssembler();
 29  
         catHelper.setAttributes(attAssembler.assemble(cat.getAttributes()));
 30  
         */
 31  0
         catHelper.setState(loCategoryInfo.getState());
 32  0
         catHelper.setType(loCategoryInfo.getType());
 33  
 
 34  0
         MetaInfo mInfo = loCategoryInfo.getMetaInfo();
 35  0
         if (mInfo != null) {
 36  0
             MetaInfoHelper metaHelper = MetaInfoHelper.wrap(new Data());
 37  0
             metaHelper.setCreateId(mInfo.getCreateId());
 38  0
             metaHelper.setCreateTime(mInfo.getCreateTime());
 39  0
             metaHelper.setUpdateId(mInfo.getUpdateId());
 40  0
             metaHelper.setUpdateTime(mInfo.getUpdateTime());
 41  0
             metaHelper.setVersionInd(mInfo.getVersionInd());
 42  0
             catHelper.setMetaInfo(metaHelper.getData());
 43  
       }
 44  
        
 45  
  
 46  
         // TODO - LoCategoryInfoAssembler, w/ an assemble method so we can just do 
 47  
         // categoriesData.add(LoCategoryInfoAssembler.assemble(cat)) instead
 48  
         // of all the above
 49  0
         return catHelper.getData();
 50  
     }
 51  
     
 52  
     public static LoCategoryInfo toLoCategoryInfo(Data categoryData) {
 53  0
         LoCategoryInfo catInfo = null;
 54  0
         if (categoryData != null) {
 55  0
             LoCategoryInfoHelper catHelper = new LoCategoryInfoHelper(categoryData);
 56  0
             catInfo = new LoCategoryInfo();
 57  0
             catInfo.setId(catHelper.getId());
 58  0
             RichTextHelper rtHelper = new RichTextHelper(catHelper.getDesc());
 59  
             // testing
 60  0
             if (null != catHelper) {
 61  0
                 RichTextInfo descInfo = new RichTextInfo();
 62  0
                 descInfo.setFormatted(rtHelper.getFormatted());
 63  0
                 descInfo.setPlain(rtHelper.getPlain());
 64  0
                 catInfo.setDesc(descInfo);
 65  
             }
 66  0
             catInfo.setEffectiveDate(catHelper.getEffectiveDate());
 67  0
             catInfo.setExpirationDate(catHelper.getExpirationDate());
 68  0
             catInfo.setLoRepository(catHelper.getLoRepository());
 69  
             // TODO - this should't be necessary when DOL pushed down into LOPicker
 70  
             // and its LOCategoryBuilder
 71  
             // catInfo.setAttributes(catHelper.getAttributes());
 72  0
             catInfo.setName(catHelper.getName());
 73  0
             catInfo.setState(catHelper.getState());
 74  0
             catInfo.setType(catHelper.getType());
 75  
             // TODO - LoCategoryInfoAssembler, w/ a disassemble method so we can just do 
 76  
             // categoriesData.add(LoCategoryInfoAssembler.disassemble(catData)) instead
 77  
             // of all the above
 78  
 
 79  0
             MetaInfo metaInfo = new MetaInfo();
 80  0
             MetaInfoHelper metaHelper = MetaInfoHelper.wrap(catHelper.getMetaInfo());
 81  
 
 82  0
             if (metaHelper != null) {
 83  0
                     metaInfo.setCreateId(metaHelper.getCreateId());
 84  0
                     metaInfo.setCreateTime(metaHelper.getCreateTime());
 85  0
                     metaInfo.setUpdateId(metaHelper.getUpdateId());
 86  0
                     metaInfo.setUpdateTime(metaHelper.getUpdateTime());
 87  0
                     metaInfo.setVersionInd(metaHelper.getVersionInd());
 88  0
                     catInfo.setMetaInfo(metaInfo);
 89  
             }
 90  
         }
 91  0
         return catInfo;
 92  
     }
 93  
     
 94  
 }