Skip to content
Snippets Groups Projects
Commit c891cbe6 authored by Dominik Lechner's avatar Dominik Lechner
Browse files

Write document to file

parent 76d18341
No related branches found
No related tags found
No related merge requests found
......@@ -30,10 +30,10 @@
<icon>VAADIN:CONTROLLER</icon>
<node name="Group3" kind="123" title="">
<node name="Attribute" kind="10077" />
<node name="DocumentTemplate" kind="10077" />
<node name="Employee" kind="10077" />
<node name="KeywordEntry" kind="10077" />
<node name="KeywordAttribute" kind="10077" />
<node name="Employee" kind="10077" />
<node name="DocumentTemplate" kind="10077" />
<node name="INTERNAL_ADMINISTRATOR" kind="159" />
</node>
</node>
......
......@@ -11,38 +11,53 @@
</entityProvider>
<entityField>
<name>DATE_EDIT</name>
<title>Date edit</title>
</entityField>
<entityField>
<name>DESCRIPTION</name>
<title>Description</title>
</entityField>
<entityField>
<name>DOCUMENTMANAGEMENTID</name>
<valueProcess>%aditoprj%/entity/DocumentTemplate_entity/entityfields/documentmanagementid/valueProcess.js</valueProcess>
</entityField>
<entityField>
<name>DATE_NEW</name>
<valueProcess>%aditoprj%/entity/Documentmanagement_entity/entityfields/date_new/valueProcess.js</valueProcess>
<title>Date new</title>
<valueProcess>%aditoprj%/entity/DocumentTemplate_entity/entityfields/date_new/valueProcess.js</valueProcess>
</entityField>
<entityField>
<name>USER_NEW</name>
<valueProcess>%aditoprj%/entity/Documentmanagement_entity/entityfields/user_new/valueProcess.js</valueProcess>
<valueProcess>%aditoprj%/entity/DocumentTemplate_entity/entityfields/user_new/valueProcess.js</valueProcess>
</entityField>
<entityField>
<name>TYPE</name>
<title>Type</title>
<mandatory v="true" />
</entityField>
<entityField>
<name>USER_EDIT</name>
</entityField>
<entityField>
<name>NAME</name>
<title>Name</title>
<mandatory v="true" />
</entityField>
<entityField>
<name>LANGUAGE_documentmanagement</name>
<title>Language</title>
<mandatory v="true" />
</entityField>
<entityField>
<name>BINDATA</name>
<contentType>FILE</contentType>
</entityField>
</entityFields>
<recordContainers>
<dbRecordContainer>
<name>db</name>
<alias>Data_alias</alias>
<onDBInsert>%aditoprj%/entity/DocumentTemplate_entity/recordcontainers/db/onDBInsert.js</onDBInsert>
<linkInformation>
<linkInformation>
<name>982325b6-d12e-43f9-8ac2-c4b9f013aafd</name>
......
import("system.util");
import("system.vars");
import("system.result");
import("system.neon");
if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
result.string(util.getNewUUID());
\ No newline at end of file
import("system.vars");
import("Document_lib");
if(vars.get("$field.BINDATA") != "")
{
DocumentUtil.writeDocumentToDrive(vars.get("$field.BINDATA"), vars.get("$field.DOCUMENTMANAGEMENTID"));
}
\ No newline at end of file
......@@ -48,7 +48,7 @@
</entry>
<entry>
<key>Document Template</key>
<value>Doku Vorlage</value>
<value>Dokumenten-Vorlage</value>
</entry>
<entry>
<key>${ADDRESS_STATE}</key>
......
<?xml version="1.0" encoding="UTF-8"?>
<neonContext xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.1.0">
<name>DocumentTemplate</name>
<title>Document Management</title>
<title>Document Template</title>
<majorModelMode>DISTRIBUTED</majorModelMode>
<icon>VAADIN:FILE_FONT</icon>
<filterview>DocumentTemplateFilter_view</filterview>
<editview>DocumentTemplateEdit_view</editview>
<entity>DocumentTemplate_entity</entity>
<references>
<neonViewReference>
<name>d63a58ee-5ff0-4633-af45-7469707a888c</name>
<view>DocumentTemplateFilter_view</view>
</neonViewReference>
<neonViewReference>
<name>d49f9ade-9f33-4996-8482-d2520f6cb8db</name>
<view>DocumentTemplateEdit_view</view>
</neonViewReference>
</references>
</neonContext>
<?xml version="1.0" encoding="UTF-8"?>
<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.1">
<name>DocumentTemplateEdit_view</name>
<title>Document Template</title>
<majorModelMode>DISTRIBUTED</majorModelMode>
<icon>VAADIN:FILE_FONT</icon>
<layout>
<boxLayout>
<name>layout</name>
</boxLayout>
</layout>
<children>
<genericViewTemplate>
<name>Details</name>
<editMode v="true" />
<showDrawer v="false" />
<entityField>#ENTITY</entityField>
<title></title>
<fields>
<entityFieldLink>
<name>e3940793-c511-4fb1-93e7-68fb9f614b32</name>
<entityField>TYPE</entityField>
</entityFieldLink>
<entityFieldLink>
<name>5e68bfdb-b5c9-4ea0-8f5d-152e36262401</name>
<entityField>NAME</entityField>
</entityFieldLink>
<entityFieldLink>
<name>ea86f04c-cd45-4d19-b8c7-70288148a9c2</name>
<entityField>LANGUAGE_documentmanagement</entityField>
</entityFieldLink>
<entityFieldLink>
<name>0fed8c5c-1be5-4599-938d-31241c4c9395</name>
<entityField>DESCRIPTION</entityField>
</entityFieldLink>
<entityFieldLink>
<name>63388992-5b40-4f1e-a2be-aa35bedbfd2e</name>
<entityField>BINDATA</entityField>
</entityFieldLink>
</fields>
</genericViewTemplate>
</children>
</neonView>
<?xml version="1.0" encoding="UTF-8"?>
<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.1">
<name>DocumentTemplateFilter_view</name>
<title>Document Template</title>
<majorModelMode>DISTRIBUTED</majorModelMode>
<icon>VAADIN:FILE_FONT</icon>
<layout>
<boxLayout>
<name>layout</name>
......@@ -11,7 +13,7 @@
<tableViewTemplate>
<name>Search</name>
<entityField>#ENTITY</entityField>
<title>Document Management</title>
<title>Document Template</title>
<columns>
<neonTableColumn>
<name>b71e5a83-7bb6-4638-bf77-28193831e341</name>
......
import("system.logging");
import("system.util");
import("system.fileIO");
import("system.result");
import("system.db");
import("system.vars");
import("system.neon");
import("Sql_lib");
//Global path for downloaded documents
var path = vars.get("$sys.serverhome") + "/binaryfiles/"
/**
* Provides static methods for managing documents.
* Do not create an instance of this
......@@ -73,6 +79,28 @@ DocumentUtil.deleteCurrentDocument = function() {
}
}
/**
* Utility function to write the document to harddrive.
*
* @param {String} pUploadValue the value of the uploadcomponent (filename + filedata)
* @param {String} pFileName opt filename, overrides the filename of pUploadValue
*/
DocumentUtil.writeDocumentToDrive = function(pUploadValue, pFileName)
{
let filename;
if(pFileName != null && pFileName != "")
{
filename = pFileName;
}
else
{
filename = DocumentUtil.getFilenameFromUpload(pUploadValue);
}
let bindata = DocumentUtil.getBindataFromUpload(pUploadValue);
fileIO.storeData(path + filename, bindata, util.DATA_BINARY, false);
}
/**
* Utility function to retrieve the filename from an uploadcomponent value.
* The value of an uploadcomponent contains filename + filedata separated by
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment