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 | 0 | public class CluSetDataService implements DataService{ |
27 | |
|
28 | 0 | final static Logger LOG = Logger.getLogger(CluSetDataService.class); |
29 | |
private Assembler<Data, Void> assembler; |
30 | |
private MetadataServiceImpl metadataService; |
31 | |
|
32 | |
public MetadataServiceImpl getMetadataService() { |
33 | 0 | return metadataService; |
34 | |
} |
35 | |
|
36 | |
public void setMetadataService(MetadataServiceImpl metadataService) { |
37 | 0 | this.metadataService = metadataService; |
38 | 0 | } |
39 | |
|
40 | |
public Assembler<Data, Void> getAssembler() { |
41 | 0 | return assembler; |
42 | |
} |
43 | |
|
44 | |
public void setAssembler(Assembler<Data, Void> assembler) { |
45 | 0 | this.assembler = assembler; |
46 | 0 | } |
47 | |
|
48 | |
@Override |
49 | |
public Data getData(String dataId) throws OperationFailedException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException { |
50 | 0 | Data result = null; |
51 | |
try { |
52 | 0 | result = assembler.get(dataId); |
53 | 0 | } catch (Exception e){ |
54 | 0 | throw new OperationFailedException("Failed to retrieve data from id " + dataId, e); |
55 | 0 | } |
56 | 0 | return result; |
57 | |
} |
58 | |
|
59 | |
@Override |
60 | |
public Metadata getMetadata(String id, Map<String,String> idAttributes) { |
61 | 0 | Metadata metadata = metadataService.getMetadata(id); |
62 | 0 | return metadata; |
63 | |
} |
64 | |
|
65 | |
protected String getDefaultMetaDataType() { |
66 | 0 | return null; |
67 | |
} |
68 | |
|
69 | |
protected String getDefaultMetaDataState() { |
70 | 0 | return null; |
71 | |
} |
72 | |
|
73 | |
@Override |
74 | |
public Boolean isAuthorized(PermissionType type, Map<String, String> attributes) { |
75 | 0 | return new Boolean(true); |
76 | |
} |
77 | |
|
78 | |
@Override |
79 | |
public DataSaveResult saveData(Data data) throws OperationFailedException { |
80 | |
try { |
81 | 0 | SaveResult<Data> saveResult = assembler.save(data); |
82 | 0 | if (saveResult != null) { |
83 | 0 | return new DataSaveResult(saveResult.getValidationResults(), saveResult.getValue()); |
84 | |
} |
85 | 0 | } catch (Exception e) { |
86 | 0 | LOG.error("Unable to save", e); |
87 | 0 | throw new OperationFailedException("Unable to save"); |
88 | 0 | } |
89 | 0 | return null; |
90 | |
} |
91 | |
|
92 | |
@Override |
93 | |
public List<ValidationResultInfo> validateData(Data data) |
94 | |
throws OperationFailedException { |
95 | 0 | return null; |
96 | |
} |
97 | |
} |