mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 05:01:07 +00:00
add more support for byte[]/BLOB field type; checkpoint
This commit is contained in:
@ -253,7 +253,8 @@ public abstract class QRecordEntity
|
||||
|| returnType.equals(BigDecimal.class)
|
||||
|| returnType.equals(Instant.class)
|
||||
|| returnType.equals(LocalDate.class)
|
||||
|| returnType.equals(LocalTime.class));
|
||||
|| returnType.equals(LocalTime.class)
|
||||
|| returnType.equals(byte[].class));
|
||||
/////////////////////////////////////////////
|
||||
// note - this list has implications upon: //
|
||||
// - QFieldType.fromClass //
|
||||
|
@ -165,6 +165,11 @@ public class QRecordEntityField
|
||||
{
|
||||
return (ValueUtils.getValueAsLocalTime(value));
|
||||
}
|
||||
|
||||
if(type.equals(byte[].class))
|
||||
{
|
||||
return (ValueUtils.getValueAsByteArray(value));
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
|
@ -167,7 +167,8 @@ public interface QRecordEnum
|
||||
|| returnType.equals(BigDecimal.class)
|
||||
|| returnType.equals(Instant.class)
|
||||
|| returnType.equals(LocalDate.class)
|
||||
|| returnType.equals(LocalTime.class));
|
||||
|| returnType.equals(LocalTime.class)
|
||||
|| returnType.equals(byte[].class));
|
||||
/////////////////////////////////////////////
|
||||
// note - this list has implications upon: //
|
||||
// - QFieldType.fromClass //
|
||||
|
@ -85,6 +85,10 @@ public enum QFieldType
|
||||
{
|
||||
return (BOOLEAN);
|
||||
}
|
||||
if(c.equals(byte[].class))
|
||||
{
|
||||
return (BLOB);
|
||||
}
|
||||
|
||||
throw (new QException("Unrecognized class [" + c + "]"));
|
||||
}
|
||||
|
@ -26,11 +26,15 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
import com.kingsrook.qqq.backend.core.BaseTest;
|
||||
import com.kingsrook.qqq.backend.core.context.QContext;
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
|
||||
import com.kingsrook.qqq.backend.core.model.templates.ConvertHtmlToPdfInput;
|
||||
import com.kingsrook.qqq.backend.core.model.templates.RenderTemplateInput;
|
||||
import com.kingsrook.qqq.backend.core.model.templates.RenderTemplateOutput;
|
||||
import com.kingsrook.qqq.backend.core.model.templates.TemplateType;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
@ -46,10 +50,10 @@ class ConvertHtmlToPdfActionTest extends BaseTest
|
||||
@Test
|
||||
void test() throws QException, IOException
|
||||
{
|
||||
QInstance instance = QContext.getQInstance();
|
||||
ConvertHtmlToPdfInput input = new ConvertHtmlToPdfInput();
|
||||
QInstance instance = QContext.getQInstance();
|
||||
|
||||
input.setHtml("""
|
||||
RenderTemplateInput renderTemplateInput = new RenderTemplateInput();
|
||||
renderTemplateInput.setCode("""
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
@ -70,7 +74,7 @@ class ConvertHtmlToPdfActionTest extends BaseTest
|
||||
<div class="center_div">
|
||||
<h1>
|
||||
<img src="images/qqq-logo-2.png" width=50>
|
||||
Hello QQQ!
|
||||
Hello, $name
|
||||
</h1>
|
||||
<div class="myclass">
|
||||
<p>This is a test of converting HTML to PDF!!</p>
|
||||
@ -80,6 +84,12 @@ class ConvertHtmlToPdfActionTest extends BaseTest
|
||||
</body>
|
||||
</html>
|
||||
""");
|
||||
renderTemplateInput.setTemplateType(TemplateType.VELOCITY);
|
||||
renderTemplateInput.setContext(Map.of("name", "Darin"));
|
||||
RenderTemplateOutput renderTemplateOutput = new RenderTemplateAction().execute(renderTemplateInput);
|
||||
|
||||
ConvertHtmlToPdfInput input = new ConvertHtmlToPdfInput();
|
||||
input.setHtml(renderTemplateOutput.getResult());
|
||||
|
||||
OutputStream outputStream = new FileOutputStream("/tmp/file.pdf");
|
||||
input.setOutputStream(outputStream);
|
||||
@ -97,6 +107,7 @@ class ConvertHtmlToPdfActionTest extends BaseTest
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// for local dev on a mac, turn this on to auto-open the generated PDF //
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// todo not commit
|
||||
// Runtime.getRuntime().exec(new String[] { "/usr/bin/open", "/tmp/file.pdf" });
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user