use of fi.otavanopisto.muikku.plugins.material.fieldmeta.FileFieldMeta in project muikku by otavanopisto.
the class HtmlMaterialFieldChangeListener method onHtmlMaterialFileFieldCreated.
// File field
public void onHtmlMaterialFileFieldCreated(@Observes HtmlMaterialFieldCreateEvent event) throws MaterialQueryIntegrityExeption, MaterialFieldMetaParsingExeption {
if (event.getField().getType().equals("application/vnd.muikku.field.file")) {
ObjectMapper objectMapper = new ObjectMapper();
FileFieldMeta fileFieldMeta;
try {
fileFieldMeta = objectMapper.readValue(event.getField().getContent(), FileFieldMeta.class);
} catch (IOException e) {
throw new MaterialFieldMetaParsingExeption("Could not parse file field meta", e);
}
QueryField queryField = queryFieldController.findQueryFieldByMaterialAndName(event.getMaterial(), fileFieldMeta.getName());
if (queryField != null) {
throw new MaterialQueryIntegrityExeption("Field with same name already exists in the database");
}
queryFileFieldController.createQueryFileField(event.getMaterial(), fileFieldMeta.getName());
}
}
use of fi.otavanopisto.muikku.plugins.material.fieldmeta.FileFieldMeta in project muikku by otavanopisto.
the class FieldElementsHandler method handleFileField.
@Override
public Node handleFileField(Document ownerDocument, String paramName, String help, String hint) throws DeusNexException {
FileFieldMeta fileFieldData = fieldTranslator.translateFileField(paramName, help, hint);
Element inputElement = ownerDocument.createElement("input");
inputElement.setAttribute("type", "file");
inputElement.setAttribute("name", paramName);
// TODO Auto-generated method stub
return wrapWithObjectElement(ownerDocument, inputElement, fileFieldData);
}
Aggregations