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