Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
if (type == DocumentTemplate.types.HTML || type == DocumentTemplate.types.TXT || type == DocumentTemplate.types.EML)
{
return [util.decodeBase64String(bindata), type];
}
return ["", type];
}
/**
* loads a template
* @param {String} pTemplateId the id of the template
* @param {Boolean} pResolveSubtemplates true, if subtemplates should be resolved
*
* @return {DocumentTemplate}
*/
DocumentTemplateUtils.getTemplate = function (pTemplateId, pResolveSubtemplates)
{
var assignmentTable = "DOCUMENTTEMPLATE";
var assignmentName= "DOCUMENT";
var keyword = "TEMPLATE";
var binMeta = db.getBinaryMetadata(assignmentTable, assignmentName, pTemplateId, false, SqlUtils.getBinariesAlias(), keyword);
if (binMeta.length != 0)
{
return new DocumentTemplate(
db.getBinaryContent(binMeta[0][db.BINARY_ID], SqlUtils.getBinariesAlias()),
DocumentTemplate.types.fromBinaryMetadata(binMeta[0]),
binMeta[0][db.BINARY_FILENAME],
pResolveSubtemplates, pTemplateId);
}
return null;
}
/**
* loads the mimetype from a fileUpload or if it's empty from a template in ASYS_BINARIES
* @param {String} pTemplateId the id of the template
* @param {FileUpload} pFileUpload upload object
*
* @return {String} mimetype
*/
DocumentTemplateUtils.getMimeType = function (pTemplateId, pFileUpload)
{
var type;
if (pFileUpload && pFileUpload.isFilled())
{
type = pFileUpload.mimeType;
}
else
{
var assignmentTable = "DOCUMENTTEMPLATE";
var assignmentName= "DOCUMENT";
var keyword = "TEMPLATE";
var binMeta = db.getBinaryMetadata(assignmentTable, assignmentName, pTemplateId, false, SqlUtils.getBinariesAlias(), keyword);
if (binMeta.length != 0)
{
let binMeta = db.getBinaryMetadata(assignmentTable, assignmentName, pTemplateId, false, SqlUtils.getBinariesAlias(), keyword);
type = binMeta[0][db.BINARY_MIMETYPE];
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
}
/**
* loads the type from a fileUpload or if it's empty from a template in ASYS_BINARIES
* @param {String} pTemplateId the id of the template
* @param {FileUpload} pFileUpload upload object
*
* @return {String} type via DocumentTemplate.types or null
*/
DocumentTemplateUtils.getContentType = function (pTemplateId, pFileUpload)
{
var type;
if (pFileUpload.isFilled())
{
type = DocumentTemplate.types.fromFileExtension(pFileUpload.fileExtension);
}
else
{
var assignmentTable = "DOCUMENTTEMPLATE";
var assignmentName= "DOCUMENT";
var keyword = "TEMPLATE";
var binMeta = db.getBinaryMetadata(assignmentTable, assignmentName, pTemplateId, false, SqlUtils.getBinariesAlias(), keyword);
if (binMeta.length != 0)
{
let binMeta = db.getBinaryMetadata(assignmentTable, assignmentName, pTemplateId, false, SqlUtils.getBinariesAlias(), keyword);
type = DocumentTemplate.types.fromBinaryMetadata(binMeta[0]);
}