Coverage Report - org.kuali.student.lum.lu.ui.tools.server.gwt.CluSetDataService
 
Classes in this File Line Coverage Branch Coverage Complexity
CluSetDataService
0%
0/27
0%
0/2
1.6
 
 1  
 package org.kuali.student.lum.lu.ui.tools.server.gwt;
 2  
 
 3  
 import java.util.Map;
 4  
 
 5  
 import org.apache.log4j.Logger;
 6  
 import org.kuali.student.common.ui.client.service.DataSaveResult;
 7  
 import org.kuali.student.common.ui.server.gwt.DataService;
 8  
 import org.kuali.student.common.ui.shared.IdAttributes;
 9  
 import org.kuali.student.core.assembly.data.AssemblyException;
 10  
 import org.kuali.student.core.assembly.data.Data;
 11  
 import org.kuali.student.core.assembly.data.Metadata;
 12  
 import org.kuali.student.core.assembly.dictionary.MetadataServiceImpl;
 13  
 import org.kuali.student.core.assembly.old.Assembler;
 14  
 import org.kuali.student.core.assembly.old.data.SaveResult;
 15  
 import org.kuali.student.core.assembly.transform.MetadataFilter;
 16  
 import org.kuali.student.core.assembly.transform.TransformFilter;
 17  
 import org.kuali.student.core.exceptions.DataValidationErrorException;
 18  
 import org.kuali.student.core.exceptions.DoesNotExistException;
 19  
 import org.kuali.student.core.exceptions.InvalidParameterException;
 20  
 import org.kuali.student.core.exceptions.MissingParameterException;
 21  
 import org.kuali.student.core.exceptions.OperationFailedException;
 22  
 import org.kuali.student.core.rice.authorization.PermissionType;
 23  
 
 24  0
 public class CluSetDataService  implements DataService{
 25  
 
 26  0
     final static Logger LOG = Logger.getLogger(CluSetDataService.class);
 27  
     private Assembler<Data, Void> assembler;
 28  
     private MetadataServiceImpl metadataService;
 29  
     
 30  
     public MetadataServiceImpl getMetadataService() {
 31  0
         return metadataService;
 32  
     }
 33  
 
 34  
     public void setMetadataService(MetadataServiceImpl metadataService) {
 35  0
         this.metadataService = metadataService;
 36  0
     }
 37  
 
 38  
     public Assembler<Data, Void> getAssembler() {
 39  0
         return assembler;
 40  
     }
 41  
 
 42  
     public void setAssembler(Assembler<Data, Void> assembler) {
 43  0
         this.assembler = assembler;
 44  0
     }
 45  
 
 46  
     @Override
 47  
     public Data getData(String dataId) throws OperationFailedException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 48  0
         Data result = null;
 49  
         try {
 50  0
             result = assembler.get(dataId);
 51  0
         } catch (Exception e){
 52  0
             throw new OperationFailedException("Failed to retrieve data from id " + dataId, e);
 53  0
         }
 54  0
         return result;
 55  
     }
 56  
 
 57  
     @Override
 58  
     public Metadata getMetadata(String id, Map<String,String> idAttributes) {
 59  0
         Metadata metadata = metadataService.getMetadata(id);
 60  0
         return metadata;
 61  
     }
 62  
     
 63  
     protected String getDefaultMetaDataType() {
 64  0
         return null; //DEFAULT_METADATA_STATE;
 65  
     }
 66  
 
 67  
     protected String getDefaultMetaDataState() {
 68  0
         return null; //DEFAULT_METADATA_STATE;
 69  
     }
 70  
 
 71  
     @Override
 72  
     public Boolean isAuthorized(PermissionType type, Map<String, String> attributes) {
 73  0
         return new Boolean(true);
 74  
     }
 75  
 
 76  
     @Override
 77  
     public DataSaveResult saveData(Data data) throws OperationFailedException, DataValidationErrorException {
 78  
         try {
 79  0
             SaveResult<Data> saveResult = assembler.save(data);
 80  0
             if (saveResult != null) {
 81  0
                 return new DataSaveResult(saveResult.getValidationResults(), saveResult.getValue());
 82  
             }
 83  0
         } catch (Exception e) {
 84  0
             LOG.error("Unable to save", e);
 85  0
             throw new OperationFailedException("Unable to save");
 86  0
         }
 87  0
         return null;
 88  
     }
 89  
 }