Search in sources :

Example 1 with AudioFieldMeta

use of fi.otavanopisto.muikku.plugins.material.fieldmeta.AudioFieldMeta in project muikku by otavanopisto.

the class HtmlMaterialFieldChangeListener method onHtmlMaterialAudioFieldCreated.

// Audio field
public void onHtmlMaterialAudioFieldCreated(@Observes HtmlMaterialFieldCreateEvent event) throws MaterialQueryIntegrityExeption, MaterialFieldMetaParsingExeption {
    if (event.getField().getType().equals("application/vnd.muikku.field.audio")) {
        ObjectMapper objectMapper = new ObjectMapper();
        AudioFieldMeta audioFieldMeta;
        try {
            audioFieldMeta = objectMapper.readValue(event.getField().getContent(), AudioFieldMeta.class);
        } catch (IOException e) {
            throw new MaterialFieldMetaParsingExeption("Could not parse audio field meta", e);
        }
        QueryField queryField = queryFieldController.findQueryFieldByMaterialAndName(event.getMaterial(), audioFieldMeta.getName());
        if (queryField != null) {
            throw new MaterialQueryIntegrityExeption("Field with same name already exists in the database");
        }
        queryAudioFieldController.createQueryAudioField(event.getMaterial(), audioFieldMeta.getName());
    }
}
Also used : QueryField(fi.otavanopisto.muikku.plugins.material.model.QueryField) IOException(java.io.IOException) AudioFieldMeta(fi.otavanopisto.muikku.plugins.material.fieldmeta.AudioFieldMeta) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Aggregations

AudioFieldMeta (fi.otavanopisto.muikku.plugins.material.fieldmeta.AudioFieldMeta)1 QueryField (fi.otavanopisto.muikku.plugins.material.model.QueryField)1 IOException (java.io.IOException)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1