Commit 2af011e1 by Nilu

Email fetcher for email ingest

parent d705595f
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">tl_attachment</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="attachment_name" type="String" nullable="true" length="100"/>
<column name="attachment_file" type="BLOB" nullable="true"/>
<column name="email_message_id" type="Long" length="11" nullable="true"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_attachment" indexName="idx_tl_attachment_email_message_id" isUnique="false"><column name="email_message_id"/></NODE>
</NODE></OBJECTS>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">tl_email_message</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="message_id" type="String" nullable="true" length="1000"/>
<column name="email_from" type="String" nullable="false" length="500"/>
<column name="email_to" type="String" nullable="false" length="500"/>
<column name="email_cc" type="String" nullable="true" length="500"/>
<column name="subject" type="String" nullable="true" length="1000"/>
<column name="description" type="CLOB" nullable="true"/>
<column name="received_date" type="Date" nullable="false"/>
<column name="job_id" type="Long" length="11" nullable="true"/>
</NODE>
</NODE></OBJECTS>
\ No newline at end of file
-- DROP TABLE tl_attachment;
CREATE TABLE tl_attachment (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
attachment_name varchar(100) NULL,
attachment_file image NULL,
email_message_id numeric(12) NULL
);
ALTER TABLE tl_attachment ADD
CONSTRAINT PK_tl_attachment PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_attachment_email_message_id
ON tl_attachment (email_message_id);
-- DROP TABLE tl_email_message;
CREATE TABLE tl_email_message (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
message_id varchar(1000) NULL,
email_from varchar(500) NOT NULL,
email_to varchar(500) NOT NULL,
email_cc varchar(500) NULL,
subject varchar(1000) NULL,
description text NULL,
received_date datetime NOT NULL,
job_id numeric(12) NULL
);
ALTER TABLE tl_email_message ADD
CONSTRAINT PK_tl_email_message PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- DROP TABLE tl_attachment;
CREATE TABLE tl_attachment (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
attachment_name varchar2(100) NULL,
attachment_file blob NULL,
email_message_id number(12) NULL
);
ALTER TABLE tl_attachment ADD
CONSTRAINT PK_tl_attachment PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_attachment_email_message_id
ON tl_attachment (email_message_id);
-- DROP TABLE tl_email_message;
CREATE TABLE tl_email_message (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
message_id varchar2(1000) NULL,
email_from varchar2(500) NOT NULL,
email_to varchar2(500) NOT NULL,
email_cc varchar2(500) NULL,
subject varchar2(1000) NULL,
description clob NULL,
received_date date NOT NULL,
job_id number(12) NULL
);
ALTER TABLE tl_email_message ADD
CONSTRAINT PK_tl_email_message PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- @AutoRun
-- drop table tl_attachment;
CREATE TABLE tl_attachment (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
attachment_name varchar(100) NULL,
attachment_file bytea NULL,
email_message_id numeric(12) NULL
);
ALTER TABLE tl_attachment ADD
CONSTRAINT pk_tl_attachment PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_attachment_email_message_id
ON tl_attachment (email_message_id);
-- @AutoRun
-- drop table tl_email_message;
CREATE TABLE tl_email_message (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
message_id varchar(1000) NULL,
email_from varchar(500) NOT NULL,
email_to varchar(500) NOT NULL,
email_cc varchar(500) NULL,
subject varchar(1000) NULL,
description text NULL,
received_date timestamp NOT NULL,
job_id numeric(12) NULL
);
ALTER TABLE tl_email_message ADD
CONSTRAINT pk_tl_email_message PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
package performa.form;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import oneit.logging.LogLevel;
import oneit.logging.LogMgr;
import oneit.objstore.ObjectTransaction;
import oneit.objstore.StorageException;
import oneit.servlets.forms.RedisplayResult;
import oneit.servlets.forms.SubmissionDetails;
import oneit.servlets.forms.SuccessfulResult;
import oneit.servlets.objstore.ORMFormProcessor;
import oneit.utils.BusinessException;
import performa.utils.PerformaEmailFetcher;
public class RunEmailFetcherFP extends ORMFormProcessor
{
@Override
public SuccessfulResult processForm(ObjectTransaction objTran, SubmissionDetails submission, Map params) throws BusinessException, StorageException
{
LogMgr.log(PerformaEmailFetcher.LOG, LogLevel.PROCESSING1, "RunEmailFetcherFP called");
List<String> visitedNodes = new ArrayList<>();
PerformaEmailFetcher.runEmailFetcher(visitedNodes);
submission.getRequest().setAttribute("VisitedNodes", visitedNodes);
return RedisplayResult.getInstance();
}
}
\ No newline at end of file
package performa.orm;
public class Attachment extends BaseAttachment
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public Attachment ()
{
// Do not add any code to this, always put it in initialiseNewObject
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='http://www.oneit.com.au/schemas/5.2/BusinessObject.xsd'>
<BUSINESSCLASS name="Attachment" package="performa.orm">
<TABLE name="tl_attachment" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="AttachmentName" type="String" dbcol="attachment_name" length="100" />
<ATTRIB name="AttachmentFile" type="BinaryContent" dbcol="attachment_file" attribHelper="BLOBAttributeHelper" attribHelperInstance="BLOBAttributeHelper.INSTANCE" binaryHandler="loggedin"/>
<SINGLEREFERENCE name="EmailMessage" type="EmailMessage" dbcol="email_message_id" backreferenceName="Attachments"/>
</TABLE>
</BUSINESSCLASS>
</ROOT>
\ No newline at end of file
package performa.orm;
public class EmailMessage extends BaseEmailMessage
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public EmailMessage ()
{
// Do not add any code to this, always put it in initialiseNewObject
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='http://www.oneit.com.au/schemas/5.2/BusinessObject.xsd'>
<BUSINESSCLASS name="EmailMessage" package="performa.orm">
<MULTIPLEREFERENCE name="Attachments" type="Attachment" backreferenceName="EmailMessage"/>
<TABLE name="tl_email_message" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="MessageId" type="String" dbcol="message_id" length="1000" />
<ATTRIB name="EmailFrom" type="String" dbcol="email_from" length="500" mandatory="true"/>
<ATTRIB name="EmailTo" type="String" dbcol="email_to" length="500" mandatory="true"/>
<ATTRIB name="EmailCC" type="String" dbcol="email_cc" length="500" />
<ATTRIB name="Subject" type="String" dbcol="subject" length="1000" />
<ATTRIB name="Description" type="String" dbcol="description" />
<ATTRIB name="ReceivedDate" type="Date" dbcol="received_date" mandatory="true"/>
<SINGLEREFERENCE name="Job" type="Job" dbcol="job_id" />
</TABLE>
<SEARCH type="All" paramFilter="tl_email_message.object_id is not null"/>
</BUSINESSCLASS>
</ROOT>
\ No newline at end of file
...@@ -28,4 +28,9 @@ ...@@ -28,4 +28,9 @@
<INHERITS factory="Named" nodename="CoreORMAdmin"/> <INHERITS factory="Named" nodename="CoreORMAdmin"/>
</NODE> </NODE>
<NODE name="test_imap_jsp" factory="Participant">
<INHERITS factory="Named" nodename="CoreORMAdmin"/>
<FORM name="*.runEmailFetcher" factory="Participant" class="performa.form.RunEmailFetcherFP"/>
</NODE>
</OBJECTS> </OBJECTS>
\ No newline at end of file
...@@ -31,4 +31,16 @@ ...@@ -31,4 +31,16 @@
<NODE name="DashboardTypes::Performa"> <NODE name="DashboardTypes::Performa">
<MAP value="HOME_TL" description="HomePage" JSP="/extensions/performa/editor/additionalHomePage.jsp" /> <MAP value="HOME_TL" description="HomePage" JSP="/extensions/performa/editor/additionalHomePage.jsp" />
</NODE> </NODE>
<NODE name="WEB_BATCH::Email">
<TASK factory="Participant" class="oneit.appservices.batch.DefaultTask">
<RUN class="performa.utils.PerformaEmailFetcher" factory="Participant" />
<WHEN factory="MetaComponent" component="BatchSchedule" selector="performa.runbatch">
<NODE name="schedule" class="oneit.appservices.batch.QuickSchedule">
<NODE name="period" factory="Integer" value="5"/>
</NODE>
</WHEN>
</TASK>
</NODE>
</OBJECTS> </OBJECTS>
\ No newline at end of file
<%@ page extends="oneit.servlets.jsp.FormJSP" %>
<%@ include file="/setuprequest.jsp" %>
<%@ include file="inc/stdimports.jsp" %>
<%@ include file="../../../editor/stdimports.jsp" %>
<%! protected String getName (ServletConfig config) { return "test_imap_jsp"; } %>
<%
ORMProcessState process = (ORMProcessState) ProcessDecorator.getDefaultProcess(request);
ObjectTransaction objTran = process.getTransaction ();
request.setAttribute("oneit.pageFormDetails", CollectionUtils.mapEntry("name", "test_imap").mapEntry("enctype", "multipart/form-data").toMap());
request.setAttribute("oneit.pageHeaderTitle", "Test IMAP");
List<String> visitedNodes = (List<String>) request.getAttribute("VisitedNodes");
request.setAttribute("VisitedNodes", null);
%>
<%@include file="/editor/header.jsp" %>
<%
if(visitedNodes != null)
{
%>
<h3>Folders Visited</h3>
<%
for(String node : visitedNodes)
{
%>
<oneit:toString value="<%= node%>" mode="EscapeHTML"/> <br/>
<%
}
}
%>
<div class="bottomButtons" hidden="true">
<oneit:button value="Run" name="runEmailFetcher" cssClass="BUTTON_PRIMARY"
requestAttribs="<%= CollectionUtils.EMPTY_MAP %>"/>
</div>
<%@include file="/editor/footer.jsp" %>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au">
<NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">tl_attachment</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="attachment_name" type="String" nullable="true" length="100"/>
<column name="attachment_file" type="BLOB" nullable="true"/>
<column name="email_message_id" type="Long" length="11" nullable="true"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_attachment" indexName="idx_tl_attachment_email_message_id" isUnique="false">
<column name="email_message_id"/>
</NODE>
</NODE>
</OBJECTS>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au">
<NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">tl_email_message</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="message_id" type="String" nullable="true" length="1000"/>
<column name="email_from" type="String" nullable="false" length="500"/>
<column name="email_to" type="String" nullable="false" length="500"/>
<column name="email_cc" type="String" nullable="true" length="500"/>
<column name="subject" type="String" nullable="true" length="1000"/>
<column name="description" type="CLOB" nullable="true"/>
<column name="received_date" type="Date" nullable="false"/>
<column name="job_id" type="Long" length="11" nullable="true"/>
</NODE>
</NODE>
</OBJECTS>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment