Search in sources :

Example 6 with WorkspaceMaterialAudioFieldAnswerClip

use of fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialAudioFieldAnswerClip in project muikku by otavanopisto.

the class WorkspaceAudioFieldIOHandler method retrieve.

@Override
public String retrieve(WorkspaceMaterialField field, WorkspaceMaterialReply reply) throws WorkspaceFieldIOException {
    List<Clip> result = new ArrayList<>();
    WorkspaceMaterialAudioFieldAnswer fieldAnswer = workspaceMaterialFieldAnswerController.findWorkspaceMaterialAudioFieldAnswerByFieldAndReply(field, reply);
    if (fieldAnswer != null) {
        List<WorkspaceMaterialAudioFieldAnswerClip> answerClips = workspaceMaterialFieldAnswerController.listWorkspaceMaterialAudioFieldAnswerClipsByFieldAnswer(fieldAnswer);
        for (WorkspaceMaterialAudioFieldAnswerClip answerClip : answerClips) {
            result.add(new Clip(answerClip.getClipId(), answerClip.getFileName(), answerClip.getContentType()));
        }
    }
    try {
        return new ObjectMapper().writeValueAsString(result);
    } catch (IOException e) {
        throw new WorkspaceFieldIOException("Could not marshal audio audio response", e);
    }
}
Also used : WorkspaceMaterialAudioFieldAnswerClip(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialAudioFieldAnswerClip) WorkspaceMaterialAudioFieldAnswer(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialAudioFieldAnswer) ArrayList(java.util.ArrayList) WorkspaceMaterialAudioFieldAnswerClip(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialAudioFieldAnswerClip) IOException(java.io.IOException) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Aggregations

WorkspaceMaterialAudioFieldAnswerClip (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialAudioFieldAnswerClip)6 WorkspaceMaterialAudioFieldAnswer (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialAudioFieldAnswer)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 EntityManager (javax.persistence.EntityManager)2 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)2 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)2 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)1 WorkspaceMaterial (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial)1 WorkspaceRootFolder (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceRootFolder)1 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1