View Javadoc

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