| 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.assembly.data.AssemblyException; |
| 7 | |
import org.kuali.student.common.assembly.data.Data; |
| 8 | |
import org.kuali.student.common.assembly.data.Metadata; |
| 9 | |
import org.kuali.student.common.assembly.dictionary.MetadataServiceImpl; |
| 10 | |
import org.kuali.student.common.assembly.old.Assembler; |
| 11 | |
import org.kuali.student.common.assembly.old.data.SaveResult; |
| 12 | |
import org.kuali.student.common.assembly.transform.MetadataFilter; |
| 13 | |
import org.kuali.student.common.assembly.transform.TransformFilter; |
| 14 | |
import org.kuali.student.common.exceptions.DataValidationErrorException; |
| 15 | |
import org.kuali.student.common.exceptions.DoesNotExistException; |
| 16 | |
import org.kuali.student.common.exceptions.InvalidParameterException; |
| 17 | |
import org.kuali.student.common.exceptions.MissingParameterException; |
| 18 | |
import org.kuali.student.common.exceptions.OperationFailedException; |
| 19 | |
import org.kuali.student.common.rice.authorization.PermissionType; |
| 20 | |
import org.kuali.student.common.ui.client.service.DataSaveResult; |
| 21 | |
import org.kuali.student.common.ui.server.gwt.DataService; |
| 22 | |
import org.kuali.student.common.ui.shared.IdAttributes; |
| 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; |
| 65 | |
} |
| 66 | |
|
| 67 | |
protected String getDefaultMetaDataState() { |
| 68 | 0 | return null; |
| 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 | |
} |