Commit 2944cd44 by Harsh Shah

Finish Release-20190410

parents 9052a704 c7008ee7
......@@ -27,6 +27,7 @@
<column name="client_id" type="Long" length="11" nullable="true"/>
<column name="hiring_team_id" type="Long" length="11" nullable="true"/>
<column name="company_user_id" type="Long" length="11" nullable="true"/>
<column name="job_title_id" type="Long" length="11" nullable="true"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_assessment_template" indexName="idx_tl_assessment_template_TemplateID" isUnique="true"><column name="template_name"/><column name="hiring_team_id"/><column name="company_user_id"/></NODE>
......
<?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
......@@ -15,7 +15,11 @@
<column name="verification_mail_send_date" type="Date" nullable="true"/>
<column name="verification_key" type="String" nullable="true" length="10"/>
<column name="is_account_verified" type="Boolean" nullable="true"/>
<column name="is_password_changed" type="Boolean" nullable="true"/>
<column name="google_address_text" type="String" nullable="true" length="300"/>
<column name="is_email_ingest" type="Boolean" nullable="true"/>
<column name="is_masked_email" type="Boolean" nullable="true"/>
<column name="known_as_alias" type="String" nullable="true" length="100"/>
<column name="test_input_id" type="Long" length="11" nullable="true"/>
<column name="user_id" type="Long" length="11" nullable="true"/>
</NODE>
......
<?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
<?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_ilo_job_title</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="job_title" type="String" nullable="true" length="200"/>
<column name="occupation_id" type="Long" length="11" nullable="true"/>
</NODE>
</NODE></OBJECTS>
\ No newline at end of file
......@@ -41,6 +41,7 @@
<column name="occupation_id" type="Long" length="11" nullable="false"/>
<column name="shortened_url_id" type="Long" length="11" nullable="true"/>
<column name="template_id" type="Long" length="11" nullable="true"/>
<column name="job_title_id" type="Long" length="11" nullable="true"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_job" indexName="idx_tl_job_client_id" isUnique="false"><column name="client_id"/></NODE>
......
<?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_message_template</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="template_name" type="String" nullable="false" length="200"/>
<column name="subject" type="String" nullable="false" length="200"/>
<column name="application_status" type="String" nullable="false" length="200"/>
<column name="delay_hrs" type="Long" nullable="true"/>
<column name="delay_min" type="Long" nullable="true"/>
<column name="variance" type="Long" nullable="true"/>
<column name="business_hours_only" type="Boolean" nullable="true"/>
<column name="message_content" type="CLOB" nullable="false"/>
</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_scheduled_email</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="subject" type="String" nullable="false" length="200"/>
<column name="scheduled_date" type="Date" nullable="false"/>
<column name="application_status" type="String" nullable="false" length="200"/>
<column name="message_content" type="CLOB" nullable="false"/>
<column name="job_application_id" type="Long" length="11" nullable="false"/>
<column name="message_template_id" type="Long" length="11" nullable="true"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_scheduled_email" indexName="idx_tl_scheduled_email_job_application_id" isUnique="false"><column name="job_application_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">it_does_not_matter</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"/>
</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_sent_email</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="subject" type="String" nullable="false" length="200"/>
<column name="sent_date" type="Date" nullable="false"/>
<column name="application_status" type="String" nullable="false" length="200"/>
<column name="message_content" type="CLOB" nullable="false"/>
<column name="email_to" type="CLOB" nullable="false"/>
<column name="job_application_id" type="Long" length="11" nullable="false"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_sent_email" indexName="idx_tl_sent_email_job_application_id" isUnique="false"><column name="job_application_id"/></NODE>
</NODE></OBJECTS>
\ No newline at end of file
......@@ -26,7 +26,8 @@ CREATE TABLE tl_assessment_template (
job_id numeric(12) NULL,
client_id numeric(12) NULL,
hiring_team_id numeric(12) NULL,
company_user_id numeric(12) NULL
company_user_id numeric(12) NULL,
job_title_id numeric(12) NULL
);
......
-- 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);
......@@ -14,7 +14,11 @@ CREATE TABLE oneit_sec_user_extension (
verification_mail_send_date datetime NULL,
verification_key varchar(10) NULL,
is_account_verified char(1) NULL,
is_password_changed char(1) NULL,
google_address_text varchar(300) NULL,
is_email_ingest char(1) NULL,
is_masked_email char(1) NULL,
known_as_alias varchar(100) NULL,
test_input_id numeric(12) NULL,
user_id numeric(12) NULL
);
......
-- 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_ilo_job_title;
CREATE TABLE tl_ilo_job_title (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
job_title varchar(200) NULL,
occupation_id numeric(12) NULL
);
ALTER TABLE tl_ilo_job_title ADD
CONSTRAINT PK_tl_ilo_job_title PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
......@@ -40,7 +40,8 @@ CREATE TABLE tl_job (
hiring_team_id numeric(12) NULL,
occupation_id numeric(12) NOT NULL,
shortened_url_id numeric(12) NULL,
template_id numeric(12) NULL
template_id numeric(12) NULL,
job_title_id numeric(12) NULL
);
......
-- DROP TABLE tl_message_template;
CREATE TABLE tl_message_template (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
template_name varchar(200) NOT NULL,
subject varchar(200) NOT NULL,
application_status varchar(200) NOT NULL,
delay_hrs numeric(12) NULL,
delay_min numeric(12) NULL,
variance numeric(12) NULL,
business_hours_only char(1) NULL,
message_content text NOT NULL
);
ALTER TABLE tl_message_template ADD
CONSTRAINT PK_tl_message_template PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- DROP TABLE tl_scheduled_email;
CREATE TABLE tl_scheduled_email (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
subject varchar(200) NOT NULL,
scheduled_date datetime NOT NULL,
application_status varchar(200) NOT NULL,
message_content text NOT NULL,
job_application_id numeric(12) NOT NULL,
message_template_id numeric(12) NULL
);
ALTER TABLE tl_scheduled_email ADD
CONSTRAINT PK_tl_scheduled_email PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_scheduled_email_job_application_id
ON tl_scheduled_email (job_application_id);
-- DROP TABLE it_does_not_matter;
CREATE TABLE it_does_not_matter (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
);
ALTER TABLE it_does_not_matter ADD
CONSTRAINT PK_it_does_not_matter PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- DROP TABLE tl_sent_email;
CREATE TABLE tl_sent_email (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
subject varchar(200) NOT NULL,
sent_date datetime NOT NULL,
application_status varchar(200) NOT NULL,
message_content text NOT NULL,
email_to text NOT NULL,
job_application_id numeric(12) NOT NULL
);
ALTER TABLE tl_sent_email ADD
CONSTRAINT PK_tl_sent_email PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_sent_email_job_application_id
ON tl_sent_email (job_application_id);
......@@ -27,7 +27,8 @@ CREATE TABLE tl_assessment_template (
job_id number(12) NULL,
client_id number(12) NULL,
hiring_team_id number(12) NULL,
company_user_id number(12) NULL
company_user_id number(12) NULL,
job_title_id number(12) NULL
);
......
-- 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);
......@@ -15,7 +15,11 @@ CREATE TABLE oneit_sec_user_extension (
verification_mail_send_date date NULL,
verification_key varchar2(10) NULL,
is_account_verified char(1) NULL,
is_password_changed char(1) NULL,
google_address_text varchar2(300) NULL,
is_email_ingest char(1) NULL,
is_masked_email char(1) NULL,
known_as_alias varchar2(100) NULL,
test_input_id number(12) NULL,
user_id number(12) NULL
);
......
-- 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
-- DROP TABLE tl_ilo_job_title;
CREATE TABLE tl_ilo_job_title (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
job_title varchar2(200) NULL,
occupation_id number(12) NULL
);
ALTER TABLE tl_ilo_job_title ADD
CONSTRAINT PK_tl_ilo_job_title PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
......@@ -41,7 +41,8 @@ CREATE TABLE tl_job (
hiring_team_id number(12) NULL,
occupation_id number(12) NOT NULL,
shortened_url_id number(12) NULL,
template_id number(12) NULL
template_id number(12) NULL,
job_title_id number(12) NULL
);
......
-- DROP TABLE tl_message_template;
CREATE TABLE tl_message_template (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
template_name varchar2(200) NOT NULL,
subject varchar2(200) NOT NULL,
application_status varchar2(200) NOT NULL,
delay_hrs number(12) NULL,
delay_min number(12) NULL,
variance number(12) NULL,
business_hours_only char(1) NULL,
message_content clob NOT NULL
);
ALTER TABLE tl_message_template ADD
CONSTRAINT PK_tl_message_template PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- DROP TABLE tl_scheduled_email;
CREATE TABLE tl_scheduled_email (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
subject varchar2(200) NOT NULL,
scheduled_date date NOT NULL,
application_status varchar2(200) NOT NULL,
message_content clob NOT NULL,
job_application_id number(12) NOT NULL,
message_template_id number(12) NULL
);
ALTER TABLE tl_scheduled_email ADD
CONSTRAINT PK_tl_scheduled_email PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_scheduled_email_job_application_id
ON tl_scheduled_email (job_application_id);
-- DROP TABLE it_does_not_matter;
CREATE TABLE it_does_not_matter (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
);
ALTER TABLE it_does_not_matter ADD
CONSTRAINT PK_it_does_not_matter PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- DROP TABLE tl_sent_email;
CREATE TABLE tl_sent_email (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
subject varchar2(200) NOT NULL,
sent_date date NOT NULL,
application_status varchar2(200) NOT NULL,
message_content clob NOT NULL,
email_to clob NOT NULL,
job_application_id number(12) NOT NULL
);
ALTER TABLE tl_sent_email ADD
CONSTRAINT PK_tl_sent_email PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_sent_email_job_application_id
ON tl_sent_email (job_application_id);
......@@ -27,7 +27,8 @@ CREATE TABLE tl_assessment_template (
job_id numeric(12) NULL,
client_id numeric(12) NULL,
hiring_team_id numeric(12) NULL,
company_user_id numeric(12) NULL
company_user_id numeric(12) NULL,
job_title_id numeric(12) NULL
);
......
-- @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);
......@@ -15,7 +15,11 @@ CREATE TABLE oneit_sec_user_extension (
verification_mail_send_date timestamp NULL,
verification_key varchar(10) NULL,
is_account_verified char(1) NULL,
is_password_changed char(1) NULL,
google_address_text varchar(300) NULL,
is_email_ingest char(1) NULL,
is_masked_email char(1) NULL,
known_as_alias varchar(100) NULL,
test_input_id numeric(12) NULL,
user_id numeric(12) NULL
);
......
-- @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
-- @AutoRun
-- drop table tl_ilo_job_title;
CREATE TABLE tl_ilo_job_title (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
job_title varchar(200) NULL,
occupation_id numeric(12) NULL
);
ALTER TABLE tl_ilo_job_title ADD
CONSTRAINT pk_tl_ilo_job_title PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
......@@ -41,7 +41,8 @@ CREATE TABLE tl_job (
hiring_team_id numeric(12) NULL,
occupation_id numeric(12) NOT NULL,
shortened_url_id numeric(12) NULL,
template_id numeric(12) NULL
template_id numeric(12) NULL,
job_title_id numeric(12) NULL
);
......
-- @AutoRun
-- drop table tl_message_template;
CREATE TABLE tl_message_template (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
template_name varchar(200) NOT NULL,
subject varchar(200) NOT NULL,
application_status varchar(200) NOT NULL,
delay_hrs numeric(12) NULL,
delay_min numeric(12) NULL,
variance numeric(12) NULL,
business_hours_only char(1) NULL,
message_content text NOT NULL
);
ALTER TABLE tl_message_template ADD
CONSTRAINT pk_tl_message_template PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- @AutoRun
-- drop table tl_scheduled_email;
CREATE TABLE tl_scheduled_email (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
subject varchar(200) NOT NULL,
scheduled_date timestamp NOT NULL,
application_status varchar(200) NOT NULL,
message_content text NOT NULL,
job_application_id numeric(12) NOT NULL,
message_template_id numeric(12) NULL
);
ALTER TABLE tl_scheduled_email ADD
CONSTRAINT pk_tl_scheduled_email PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_scheduled_email_job_application_id
ON tl_scheduled_email (job_application_id);
-- @AutoRun
-- drop table it_does_not_matter;
CREATE TABLE it_does_not_matter (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
);
ALTER TABLE it_does_not_matter ADD
CONSTRAINT pk_it_does_not_matter PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- @AutoRun
-- drop table tl_sent_email;
CREATE TABLE tl_sent_email (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
subject varchar(200) NOT NULL,
sent_date timestamp NOT NULL,
application_status varchar(200) NOT NULL,
message_content text NOT NULL,
email_to text NOT NULL,
job_application_id numeric(12) NOT NULL
);
ALTER TABLE tl_sent_email ADD
CONSTRAINT pk_tl_sent_email PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_sent_email_job_application_id
ON tl_sent_email (job_application_id);
package performa.batch;
import java.util.Set;
import oneit.appservices.batch.ORMBatch;
import oneit.logging.*;
import oneit.objstore.ObjectTransaction;
......@@ -8,9 +7,7 @@ import oneit.objstore.StorageException;
import oneit.objstore.rdbms.filters.LessThanFilter;
import oneit.utils.DateDiff;
import oneit.utils.parsers.FieldException;
import performa.intercom.utils.IntercomUtils;
import performa.orm.Job;
import performa.orm.Company;
import performa.orm.types.JobStatus;
......@@ -34,13 +31,6 @@ public class CloseJobBatch extends ORMBatch
LogMgr.log(CLOSE_JOB_BATCH, LogLevel.PROCESSING1, "Setting Job Status to Closed in job : ", job);
}
// Update closed job details to intercom
Set<Company> companies = Job.pipesJob(expiringJobs).toCreatedBy().toCompany().uniqueVals();
for (Company company : companies)
{
IntercomUtils.updateCompany(company);
}
}
}
\ No newline at end of file
package performa.batch;
import java.util.Date;
import javax.activation.DataSource;
import oneit.appservices.batch.ORMBatch;
import oneit.components.InitialisationParticipant;
import oneit.components.ParticipantInitialisationContext;
import oneit.email.Emailer;
import oneit.email.TextDataSource;
import oneit.logging.LogLevel;
import oneit.logging.LogMgr;
import oneit.logging.LoggingArea;
import oneit.objstore.ObjectTransaction;
import oneit.objstore.StorageException;
import oneit.objstore.rdbms.filters.LessThanEqualFilter;
import oneit.utils.InitialisationException;
import oneit.utils.StringUtils;
import oneit.utils.parsers.FieldException;
import performa.orm.JobApplication;
import performa.orm.ScheduledEmail;
import performa.orm.SentEmail;
import performa.orm.types.PlaceholderOptions;
import oneit.net.LoopbackHTTP;
import oneit.utils.RandomStringGen;
import performa.orm.Candidate;
import performa.orm.Job;
import performa.utils.Utils;
public class MessagingEngineBatch extends ORMBatch implements InitialisationParticipant
{
private Emailer emailEngine;
public static LoggingArea MESSAGING_ENGINE_BATCH = LoggingArea.createLoggingArea("MessagingEngineBatch");
@Override
public void run(ObjectTransaction ot) throws StorageException, FieldException
{
LogMgr.log (MESSAGING_ENGINE_BATCH, LogLevel.PROCESSING1, "RUNNING Messaging Engine Batch");
ScheduledEmail[] scheduledEmails = ScheduledEmail.SearchByAll().andScheduledDate(new LessThanEqualFilter<>(new Date())).search(ot);
for (ScheduledEmail scheduledEmail : scheduledEmails)
{
LogMgr.log (MESSAGING_ENGINE_BATCH, LogLevel.PROCESSING1, "Starting to create email for scheduled email : " , scheduledEmail);
JobApplication jobApplication = scheduledEmail.getJobApplication();
Job job = jobApplication.getJob();
Candidate candidate = jobApplication.getCandidate();
// for existing users without a verification code
if( candidate.getVerificationKey() == null)
{
candidate.setVerificationKey(new RandomStringGen().generateAlphaNum(6));
}
String jobLink = LoopbackHTTP.getRemoteAccessURL()
+ Utils.APPLICANT_LINK
+ "?id=" + job.getID()
+ "&key=" + job.getRandomKey()
+ "&aid=" + candidate.getID()
+ "&pin=" + candidate.getVerificationKey();
// replace tags
String messageContent = StringUtils.replace(scheduledEmail.getMessageContent(),
new String[] {PlaceholderOptions.FIRST_NAME.getPlaceholder(),
PlaceholderOptions.SURNAME.getPlaceholder(),
PlaceholderOptions.EMAIL_ADDRESS.getPlaceholder(),
PlaceholderOptions.LOCATION.getPlaceholder(),
PlaceholderOptions.JOB_TITLE.getPlaceholder(),
PlaceholderOptions.JOB_REFERENCE.getPlaceholder(),
PlaceholderOptions.HIRING_TEAM.getPlaceholder(),
PlaceholderOptions.JOB_LINK.getPlaceholder()},
new String[] {candidate.getFirstName(),
candidate.getUser().getLastName(),
candidate.getUser().getEmail(),
StringUtils.subNulls(job.getGoogleAddressText(), ""),
job.getJobTitle(),
StringUtils.subNulls(job.getReferenceNumber(), ""),
job.getHiringTeam().getHiringTeamName(),
jobLink});
LogMgr.log (MESSAGING_ENGINE_BATCH, LogLevel.PROCESSING1, "Replaced tags of message content : " , messageContent);
TextDataSource mesgBodyDataSource = new TextDataSource(messageContent, "text/html", "");
String toEmail = candidate.getUser().getEmail();
String fromEmail = "Matchd<help@matchd.com>";
String replyToEmail = job.getCreatedBy().getUser().getEmail();
SentEmail sentEmail = SentEmail.createSentEmail(ot);
emailEngine.sendEmail(new String[] {toEmail}, fromEmail, new String[] {replyToEmail}, scheduledEmail.getSubject() , new DataSource[]{mesgBodyDataSource});
LogMgr.log (MESSAGING_ENGINE_BATCH, LogLevel.PROCESSING1, "Email sent to : " , toEmail, " from : ", fromEmail);
sentEmail.setSubject(scheduledEmail.getSubject());
sentEmail.setSentDate(new Date());
sentEmail.setApplicationStatus(scheduledEmail.getApplicationStatus());
sentEmail.setMessageContent(messageContent);
sentEmail.setEmailTo(toEmail);
sentEmail.setJobApplication(jobApplication);
LogMgr.log (MESSAGING_ENGINE_BATCH, LogLevel.PROCESSING1, "SentEmail object created to store sent email details : " , sentEmail);
scheduledEmail.delete();
}
LogMgr.log (MESSAGING_ENGINE_BATCH, LogLevel.PROCESSING1, "End of Messaging Engine Batch");
}
@Override
public void init(ParticipantInitialisationContext context) throws InitialisationException
{
super.init(context);
emailEngine = (Emailer) context.getSingleChild("EmailEngine");
}
}
\ No newline at end of file
......@@ -10,7 +10,6 @@ import oneit.objstore.StorageException;
import oneit.objstore.parser.BusinessObjectParser;
import oneit.objstore.rdbms.filters.EqualsFilter;
import oneit.objstore.utils.ObjstoreUtils;
import oneit.security.SecUser;
import oneit.servlets.forms.SubmissionDetails;
import oneit.servlets.forms.SuccessfulResult;
import oneit.servlets.process.ORMProcessState;
......@@ -19,8 +18,6 @@ import oneit.utils.BusinessException;
import oneit.utils.Debug;
import oneit.utils.filter.CollectionFilter;
import oneit.utils.filter.Filter;
import performa.intercom.utils.IntercomUtils;
import performa.orm.CompanyUser;
import performa.orm.Job;
import performa.orm.JobApplication;
import performa.orm.types.ApplicationStatus;
......@@ -58,18 +55,7 @@ public class BulkUpdateFP extends SaveFP
LogMgr.log(JobApplication.LOG, LogLevel.PROCESSING1,"In BulkUpdateFP Job Application Status successfully changed : ", application );
}
}
// restarting process as custom attributes needs to be updated to intercom
completeProcessRestartAndRestoreAttribs(process, request);
SecUser secUser = SecUser.getTXUser(process.getTransaction());
CompanyUser companyUser = secUser.getExtension(CompanyUser.REFERENCE_CompanyUser);
// Update company in intercom
if(companyUser.getCompany() != null)
{
IntercomUtils.updateCompany(companyUser.getCompany());
}
return super.processForm(process, submission, params);
}
}
......@@ -5,15 +5,12 @@ import javax.servlet.http.HttpServletRequest;
import oneit.logging.LogLevel;
import oneit.logging.LogMgr;
import oneit.objstore.StorageException;
import oneit.security.SecUser;
import oneit.servlets.forms.RedisplayResult;
import oneit.servlets.forms.SubmissionDetails;
import oneit.servlets.forms.SuccessfulResult;
import oneit.servlets.process.ORMProcessState;
import oneit.servlets.process.SaveFP;
import oneit.utils.BusinessException;
import performa.intercom.utils.IntercomUtils;
import performa.orm.CompanyUser;
import performa.orm.JobApplication;
public class ChangeApplicationStatusFP extends SaveFP
......@@ -36,18 +33,6 @@ public class ChangeApplicationStatusFP extends SaveFP
jobApplication.setApplicationStatus(jobApplication.getWorkFlow().getApplicationStatus());
LogMgr.log(JobApplication.LOG, LogLevel.PROCESSING1,"In ChangeApplicationStatusFP Job Application Status successfully changed : ", jobApplication );
// restarting process as custom attributes needs to be updated to intercom
completeProcessRestartAndRestoreAttribs(process, request);
SecUser secUser = SecUser.getTXUser(process.getTransaction());
CompanyUser companyUser = secUser.getExtension(CompanyUser.REFERENCE_CompanyUser);
// Update company in intercom
if(companyUser.getCompany() != null)
{
IntercomUtils.updateCompany(companyUser.getCompany());
}
return super.processForm(process, submission, params);
}
......
......@@ -6,12 +6,10 @@ import javax.servlet.http.HttpServletRequest;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.parser.BusinessObjectParser;
import oneit.objstore.services.TransactionTask;
import oneit.servlets.forms.*;
import oneit.servlets.process.*;
import oneit.utils.*;
import oneit.utils.parsers.FieldException;
import performa.intercom.utils.IntercomUtils;
import performa.orm.*;
import performa.orm.types.ApplicationStatus;
import performa.utils.AnalysisEngine;
......@@ -24,7 +22,8 @@ public class CompleteApplicationFP extends SaveFP
{
HttpServletRequest request = submission.getRequest();
ObjectTransaction objTran = process.getTransaction();
JobApplication jobApplication = (JobApplication) process.getAttribute("JobApplication");
JobApplication jobApplication = process.getAttribute("JobApplication") != null ? (JobApplication) process.getAttribute("JobApplication") : (JobApplication)request.getAttribute("JobApplication");
jobApplication = jobApplication.getInTransaction(objTran);
if(jobApplication.getStatus() != ObjectStatus.NEW) //getInTransaction will return NULL for NEW object, resulting NPE
{
......@@ -41,16 +40,8 @@ public class CompleteApplicationFP extends SaveFP
{
updateJobApplication(objTran, jobApplication.getID().longID());
}
// restarting process as custom attributes needs to be updated to intercom
completeProcessRestartAndRestoreAttribs(process, request);
jobApplication = (JobApplication) process.getAttribute("JobApplication");
// Update company in intercom
if(jobApplication != null && jobApplication.getJob().getCreatedBy() != null)
{
IntercomUtils.updateCompany(jobApplication.getJob().getCreatedBy().getCompany());
}
process.setAttribute("JobApplication", jobApplication);
return super.processForm(process, submission, params);
}
......@@ -61,7 +52,8 @@ public class CompleteApplicationFP extends SaveFP
{
HttpServletRequest request = submission.getRequest();
ObjectTransaction objTran = ObjectTransaction.getTransaction();
JobApplication jobApplication = (JobApplication) process.getAttribute("JobApplication");
JobApplication jobApplication = process.getAttribute("JobApplication") != null ? (JobApplication) process.getAttribute("JobApplication") : (JobApplication)request.getAttribute("JobApplication");
jobApplication = jobApplication.getInTransaction(objTran);
if(!jobApplication.cultureCompleted())
{
......@@ -94,6 +86,7 @@ public class CompleteApplicationFP extends SaveFP
{
jobApplication.setApplicationStatus(ApplicationStatus.UNSUITABLE);
}
LogMgr.log(JobApplication.LOG, LogLevel.PROCESSING2, "Job Application Completed", jobApplication);
}
}
\ No newline at end of file
package performa.form;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import oneit.logging.*;
import oneit.objstore.ObjectTransaction;
import oneit.objstore.StorageException;
import oneit.security.SecUser;
import oneit.servlets.forms.*;
import oneit.servlets.process.*;
import oneit.servlets.security.SessionSecUserDecorator;
import oneit.utils.*;
import performa.orm.*;
import performa.utils.Utils;
public class ConfirmDetailsFP extends SaveFP
{
private static final LoggingArea LOG = LoggingArea.createLoggingArea("ConfirmDetailsFP");
@Override
public SuccessfulResult processForm(ORMProcessState process, SubmissionDetails submission, Map params) throws BusinessException, StorageException
{
HttpServletRequest request = submission.getRequest();
ObjectTransaction objTran = process.getTransaction();
Job job = (Job) request.getAttribute("Job");
String email = job.getEmail();
Debug.assertion(email != null, "Email not avaialble");
email = email.toLowerCase();
LogMgr.log(LOG, LogLevel.PROCESSING1, "Started to send varification email.", job , email);
SecUser secUser = SecUser.searchNAME(objTran, email);
if(secUser == null)
{
secUser = SecUser.createSecUser(objTran);
secUser.setUserName(email);
secUser.setEmail(email);
secUser.setAttribute("md5:" + SecUser.FIELD_Password, CompanyUser.DEFAULT_PASSWORD);
secUser.addRole(Utils.getRole(Utils.ROLE_APPLICANT, objTran));
}
Candidate candidate = secUser.getExtensionOrCreate(Candidate.REFERENCE_Candidate);
LogMgr.log(LOG, LogLevel.PROCESSING1, "New user created :: ", secUser, " Candidate: " , candidate);
request.getSession().setAttribute (SecUser.SEC_USER_ID, secUser);
request.getSession().setAttribute (SessionSecUserDecorator.REFRESH_SECURITY, Boolean.TRUE);
return super.processForm(process, submission, params);
}
}
\ No newline at end of file
......@@ -91,23 +91,6 @@ public class MakePaymentFP extends SaveFP
// StripeUtils.updatePlan(company);
}
// restarting process as custom attributes needs to be updated to intercom
// Set<String> attribsToRestore = new HashSet<>();
// attribsToRestore.add("Job");
// attribsToRestore.add("Company");
//
// completeProcessRestartAndRestoreAttribs(process, attribsToRestore);
//
// secUser = SecUser.getTXUser(process.getTransaction());
// companyUser = secUser.getExtension(CompanyUser.REFERENCE_CompanyUser);
//
// // Update company in intercom
// if(companyUser.getCompany() != null)
// {
// IntercomUtils.updateCompany(companyUser.getCompany());
// }
return super.processForm(process, submission, p);
}
}
\ 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
......@@ -3,19 +3,23 @@ package performa.form;
import com.stripe.model.Subscription;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import oneit.business.content.Article;
import oneit.logging.LogLevel;
import oneit.logging.LogMgr;
import oneit.net.LoopbackHTTP;
import oneit.objstore.StorageException;
import oneit.objstore.parser.BusinessObjectParser;
import oneit.servlets.forms.SubmissionDetails;
import oneit.servlets.forms.SuccessfulResult;
import oneit.servlets.process.ORMProcessState;
import oneit.servlets.process.ProcessRedirectResult;
import oneit.servlets.process.SaveFP;
import oneit.utils.BusinessException;
import oneit.utils.CollectionUtils;
import oneit.utils.MultiException;
import performa.orm.HiringTeam;
import performa.utils.StripeUtils;
import performa.utils.WebUtils;
public class SaveCompanyFP extends SaveFP
......@@ -27,6 +31,10 @@ public class SaveCompanyFP extends SaveFP
HiringTeam hiringTeam = (HiringTeam) process.getAttribute("HiringTeam");
Boolean isPayment = (Boolean) request.getAttribute("IsPayment");
Subscription subscription = StripeUtils.retrieveSubscription(hiringTeam.getStripeSubscription());
Boolean isHTLogoPresent = process.getAttribute("IsHTLogoPresent") != null ? (Boolean) process.getAttribute("IsHTLogoPresent") : Boolean.FALSE;
Article article = WebUtils.getArticleByShortCut(process.getTransaction(), WebUtils.MY_COMPANY);
String nextPage = LoopbackHTTP.getRemoteAccessURL(request)
+ article.getLink(request, CollectionUtils.mapEntry("cms.rm", hiringTeam.getHiringTeamLogo() != null ? "Page" : "HiringTeam").toMap(), "/");
if(CollectionUtils.equals(hiringTeam.getIsLogoDeleted(), Boolean.TRUE))
{
......@@ -62,8 +70,17 @@ public class SaveCompanyFP extends SaveFP
}
}
// // Update company in intercom
// IntercomUtils.updateCompany(company);
//Set attribute IsHTLogoPresent false when HT logo is not uploaded or deleted
if(hiringTeam.getHiringTeamLogo() == null && !isHTLogoPresent)
{
process.setAttribute("IsHTLogoPresent", Boolean.FALSE);
return new ProcessRedirectResult(nextPage, new String[]{});
}
process.setAttribute("nextPage", nextPage);
process.setAttribute("HiringTeam", hiringTeam);
return super.processForm(process, submission, params);
}
......
......@@ -53,6 +53,7 @@ public class SaveCultureTemplateFP extends ORMProcessFormProcessor
{
CultureCriteria criteriaCopy = CultureCriteria.createCultureCriteria(newObjTran);
criteriaCopy.setIsApplicable(criteria.getIsApplicable());
criteriaCopy.setCultureElement(criteria.getCultureElement().getInTransaction(newObjTran));
criteriaCopy.setImportance(criteria.getImportance());
......
......@@ -8,7 +8,6 @@ import oneit.logging.LogLevel;
import oneit.logging.LogMgr;
import oneit.objstore.StorageException;
import oneit.objstore.parser.BusinessObjectParser;
import oneit.security.SecUser;
import oneit.servlets.forms.SubmissionDetails;
import oneit.servlets.forms.SuccessfulResult;
import oneit.servlets.process.ORMProcessState;
......@@ -17,7 +16,6 @@ import oneit.utils.BusinessException;
import oneit.utils.DateDiff;
import oneit.utils.MultiException;
import oneit.utils.math.NullArith;
import performa.intercom.utils.IntercomUtils;
import performa.orm.*;
import performa.orm.types.*;
import performa.utils.StripeUtils;
......@@ -90,18 +88,6 @@ public class SaveJobFP extends SaveFP
job.setAssessmentType(occupation.getAssessmentType());
}
// restarting process as custom attributes needs to be updated to intercom
completeProcessRestartAndRestoreAttribs(process, request);
SecUser secUser = SecUser.getTXUser(process.getTransaction());
CompanyUser companyUser = secUser.getExtension(CompanyUser.REFERENCE_CompanyUser);
// Update company in intercom
if(companyUser.getCompany() != null)
{
IntercomUtils.updateCompany(companyUser.getCompany());
}
return super.processForm(process, submission, params);
}
......@@ -124,6 +110,8 @@ public class SaveJobFP extends SaveFP
// }
// }
BusinessObjectParser.assertFieldCondition(job.getILOJobTitle() != null , job, Job.SINGLEREFERENCE_ILOJobTitle, "mandatory", exceptions, true, request);
if(status != null && status == JobStatus.OPEN)
{
BusinessObjectParser.assertFieldCondition(billingTeam.getCardID() != null , billingTeam, HiringTeam.FIELD_CardID, "mandatoryCardDetails", exceptions, true, request);
......
......@@ -60,7 +60,8 @@ public class SaveRequirementsTemplateFP extends ORMProcessFormProcessor
newTemplate.setOccupation(job.getOccupation().getInTransaction(newObjTran));
newTemplate.setRequireCV(job.getRequireCV());
newTemplate.setAssessmentType(job.getAssessmentType());
newTemplate.setLevel(job.getLevel().getInTransaction(newObjTran));
// newTemplate.setLevel(job.getLevel().getInTransaction(newObjTran));
newTemplate.setILOJobTitle(job.getILOJobTitle().getInTransaction(newObjTran));
for (WorkFlow workflow : job.getWorkFlowsSet())
{
......@@ -101,7 +102,8 @@ public class SaveRequirementsTemplateFP extends ORMProcessFormProcessor
Job job = (Job) request.getAttribute("Job");
BusinessObjectParser.assertFieldCondition(job.getAssessmentTemplateName() != null, job , Job.FIELD_AssessmentTemplateName, "mandatory", exceptions, true, request);
BusinessObjectParser.assertFieldCondition(job.getILOJobTitle() != null , job, Job.SINGLEREFERENCE_ILOJobTitle, "mandatory", exceptions, true, request);
for(AssessmentCriteria criteria: job.getAssessmentCriteriasSet())
{
BusinessObjectParser.assertFieldCondition(criteria.getName() != null, criteria , AssessmentCriteria.FIELD_Name, "mandatory", exceptions, true, request);
......
......@@ -19,8 +19,6 @@ import oneit.utils.CollectionUtils;
import oneit.utils.InitialisationException;
import oneit.utils.MultiException;
import oneit.utils.StringUtils;
import performa.intercom.resources.User;
import performa.intercom.utils.IntercomUtils;
import performa.orm.CompanyUser;
import performa.utils.Utils;
......@@ -82,19 +80,7 @@ public class SaveUserDetailsFP extends SaveFP
Utils.sendEmailChangedMail(companyUser, request, emailer, SaveUserDetailsFP.class.getName());
}
}
User intercomUser = (User)request.getSession().getAttribute("IntercomUser");
if(intercomUser == null)
{
performa.intercom.resources.Company intercomCompany = IntercomUtils.findOrCreateCompany(companyUser.getCompany());
IntercomUtils.createIntercomUser(secUser, "Hiring Team", intercomCompany, companyUser.getPhone());
}
else
{
IntercomUtils.updateIntercomUser(secUser, companyUser.getPhone());
}
}
return super.processForm(process, submission, params);
......
......@@ -17,7 +17,6 @@ import oneit.servlets.forms.*;
import oneit.servlets.process.*;
import oneit.servlets.security.SessionSecUserDecorator;
import oneit.utils.*;
import performa.intercom.utils.IntercomUtils;
import performa.orm.*;
import performa.orm.types.RoleType;
import performa.utils.StripeUtils;
......@@ -165,12 +164,6 @@ public class SendCompanyUserInvitesFP extends SaveFP
}
}
// Create company and the first user of it in intercom
performa.intercom.resources.Company intercomCompany = IntercomUtils.findOrCreateCompany(company);
IntercomUtils.createIntercomUser(secUser, "Hiring Team", intercomCompany, companyUser.getPhone());
return super.processForm(process, submission, params);
}
......@@ -201,14 +194,14 @@ public class SendCompanyUserInvitesFP extends SaveFP
Map defaultParams = CollectionUtils.mapEntry("link", link)
.mapEntry("create_job_link", jobCreateLink)
.toMap();
ObjectTransform transform = Utils.createCompoundTransform(defaultParams, companyUser.getUser(), companyUser.getCompany());
ObjectTransform transform = Utils.createCompoundTransform(defaultParams, companyUser.getUser(), companyUser.getCompany(),companyUser.getDefaultHiringTeam());
Utils.sendMail(ownerAccountCreatedEmailer, transform, new String[]{companyUser.getEmailAddressFromUser()}, null, companyUser);
}
else
{
Map defaultParams = CollectionUtils.mapEntry("link", link).toMap();
ObjectTransform transform = Utils.createCompoundTransform(defaultParams, companyUser.getCompany(), companyUser.getUser());
ObjectTransform transform = Utils.createCompoundTransform(defaultParams, companyUser.getCompany(), companyUser.getUser(), companyUser.getDefaultHiringTeam());
Utils.sendMail(emailer, transform, new String[]{companyUser.getEmailAddressFromUser()}, null, companyUser);
}
......
......@@ -173,7 +173,7 @@ public class SendUserInvitationFP extends SaveFP
+ "?id=" + companyUser.getID()
+ "&key=" + companyUser.getVerificationKey();
Map defaultParams = CollectionUtils.mapEntry("link", link).toMap();
ObjectTransform transform = Utils.createCompoundTransform(defaultParams, companyUser.getCompany(), SecUser.getTXUser(objTran));
ObjectTransform transform = Utils.createCompoundTransform(defaultParams, companyUser.getCompany(),companyUser.getDefaultHiringTeam(), SecUser.getTXUser(objTran));
Utils.sendMail(invitationEmailer, transform, new String[]{companyUser.getEmailAddressFromUser()}, null, companyUser);
......
......@@ -5,6 +5,7 @@ import javax.servlet.http.HttpServletRequest;
import oneit.objstore.ObjectTransaction;
import oneit.objstore.StorageException;
import oneit.objstore.parser.BusinessObjectParser;
import oneit.objstore.rdbms.filters.EqualsFilter;
import oneit.servlets.forms.SubmissionDetails;
import oneit.servlets.forms.SuccessfulResult;
import oneit.servlets.process.ORMProcessState;
......@@ -13,6 +14,7 @@ import oneit.servlets.process.SaveFP;
import oneit.utils.BusinessException;
import oneit.utils.Debug;
import oneit.utils.MultiException;
import performa.orm.AssessmentCriteriaAnswer;
import performa.orm.JobApplication;
......@@ -32,24 +34,20 @@ public class ValidateApplicationFP extends SaveFP
super.validate(process, submission, exceptions, params);
HttpServletRequest request = submission.getRequest();
ObjectTransaction objTran = ObjectTransaction.getTransaction();
JobApplication jobApplication = (JobApplication) process.getAttribute("JobApplication");
ObjectTransaction objTran = process.getTransaction();
JobApplication jobApplication = process.getAttribute("JobApplication") != null ? (JobApplication) process.getAttribute("JobApplication") : (JobApplication)request.getAttribute("JobApplication");
boolean fromRequirements = request.getAttribute("fromRequirements") != null ? (boolean) request.getAttribute("fromRequirements"): false;
boolean fromCoverLetter = request.getAttribute("fromCoverLetter") != null ? (boolean) request.getAttribute("fromCoverLetter"): false;
Debug.assertion(jobApplication != null, "No jobApplication found . Call from " + getClass().getName());
jobApplication = jobApplication.getInTransaction(objTran);
if(jobApplication.isIncludeAssessmentCriteria() && fromRequirements)
{
JobApplication application = jobApplication.getInTransaction(objTran);
// JobApplication application = jobApplication.getInTransaction(objTran);
AssessmentCriteriaAnswer[] application = AssessmentCriteriaAnswer.SearchByAll().andJobApplication(new EqualsFilter<>(jobApplication)).search(objTran);
BusinessObjectParser.assertFieldCondition(jobApplication.getJob().getAssessmentCriteriasCount() == application.getAssessmentCriteriaAnswersCount(), jobApplication, JobApplication.FIELD_ObjectID, "completeAssessment", exceptions, true, request);
BusinessObjectParser.assertFieldCondition(jobApplication.getJob().getAssessmentCriteriasCount() == application.length, jobApplication, JobApplication.FIELD_ObjectID, "completeAssessment", exceptions, true, request);
}
if(fromCoverLetter)
{
BusinessObjectParser.assertFieldCondition(jobApplication.getCV() != null , jobApplication, JobApplication.FIELD_CV, "uploadCV", exceptions, true, request);
BusinessObjectParser.assertFieldCondition(jobApplication.getCoverLetter() != null , jobApplication, JobApplication.FIELD_CoverLetter, "uploadCover", exceptions, true, request);
}
}
}
\ No newline at end of file
......@@ -2,131 +2,38 @@ package performa.form;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import oneit.business.content.Article;
import oneit.components.ParticipantInitialisationContext;
import oneit.email.ConfigurableArticleTemplateEmailer;
import oneit.email.ConfigurableEmailerException;
import oneit.logging.*;
import oneit.net.LoopbackHTTP;
import oneit.objstore.StorageException;
import oneit.objstore.parser.BusinessObjectParser;
import oneit.security.SecUser;
import oneit.servlets.forms.*;
import oneit.servlets.process.*;
import oneit.servlets.security.SessionSecUserDecorator;
import oneit.utils.*;
import performa.intercom.utils.IntercomUtils;
import performa.orm.*;
import performa.utils.Utils;
import performa.utils.WebUtils;
public class VerifyIdentityFP extends SaveFP
{
private static LoggingArea LOG = LoggingArea.createLoggingArea("VerifyIdentity");
protected ConfigurableArticleTemplateEmailer emailer;
@Override
protected Map validate(SubmissionDetails submission, MultiException exceptions)
{
HttpServletRequest request = submission.getRequest();
Job job = (Job) request.getAttribute("Job");
Candidate candidate = (Candidate) request.getAttribute("Candidate");
SecUser secUser = candidate.getUser();
Boolean isVerify = CollectionUtils.equals(request.getAttribute("isVerify"), Boolean.TRUE);
BusinessObjectParser.assertFieldCondition(secUser.getEmail() != null , job, Job.FIELD_Email, "mandatory", exceptions, true, request);
BusinessObjectParser.assertFieldCondition(StringUtils.isEmailAddress(secUser.getEmail()), job, Job.FIELD_Email, "invalid", exceptions, true, request);
BusinessObjectParser.assertFieldCondition(secUser.getFirstName() != null, secUser, SecUser.FIELD_FirstName, "mandatory", exceptions, true, request);
BusinessObjectParser.assertFieldCondition(secUser.getLastName() != null, secUser, SecUser.FIELD_LastName, "mandatory", exceptions, true, request);
if(isVerify)
{
BusinessObjectParser.assertFieldCondition(candidate.isTrue(candidate.getPrivacyPolicyAgreed()), candidate, Candidate.FIELD_PrivacyPolicyAgreed, "agreePrivacy", exceptions, true, request);
BusinessObjectParser.assertFieldCondition(candidate.isTrue(candidate.getConditionsAgreed()), candidate, Candidate.FIELD_ConditionsAgreed, "agreeTerms", exceptions, true, request);
}
return super.validate(submission, exceptions);
}
@Override
public SuccessfulResult processForm(ORMProcessState process, SubmissionDetails submission, Map params) throws BusinessException, StorageException
{
HttpServletRequest request = submission.getRequest();
Boolean isVerify = CollectionUtils.equals(request.getAttribute("isVerify"), Boolean.TRUE);
Job job = (Job) request.getAttribute("Job");
JobApplication jobApplication = (JobApplication) request.getAttribute("JobApplication");
String nextPage = (String) request.getAttribute("nextPage");
Candidate candidate = (Candidate) request.getAttribute("Candidate");
if(isVerify)
if(candidate.isTrue(candidate.getIsEmailIngest()) && candidate.getKnownAsAlias() == null && !candidate.isTrue(candidate.getIsPasswordChanged()))
{
SecUser secUser = candidate.getUser();
LogMgr.log(LOG, LogLevel.PROCESSING1, "Verifing User", job, secUser);
// if(CollectionUtils.equals(job.getPassword(), job.getConfirmPassword()))
// {
// secUser.setAttribute("md5:" + SecUser.FIELD_Password, job.getPassword());
candidate.setIsAccountVerified(Boolean.TRUE);
sendMail(candidate, job, request);
// Create a applicant user in intercom
IntercomUtils.createIntercomUser(secUser, "Applicant", null, candidate.getPhone());
request.getSession().setAttribute (SecUser.SEC_USER_ID, secUser);
request.getSession().setAttribute (SessionSecUserDecorator.REFRESH_SECURITY, Boolean.TRUE);
// request.setAttribute("nextPage", nextPage + "&JobID=" + job.getObjectID());
LogMgr.log(LOG, LogLevel.PROCESSING1, "Password resetted", job, secUser);
// }
request.getSession().setAttribute (SecUser.SEC_USER_ID, candidate.getUser());
request.getSession().setAttribute (SessionSecUserDecorator.REFRESH_SECURITY, Boolean.TRUE);
}
// storing candidate location in application for distance calculation to be accurate even if user edits
// location in the next application
jobApplication.setGoogleAddressText(candidate.getGoogleAddressText());
process.completeAndRestart();
return new ProcessRedirectResult(nextPage + "&JobID=" + job.getObjectID(), new String[0]);
}
@Override
public void init(ParticipantInitialisationContext context) throws InitialisationException
{
super.init(context);
emailer = (ConfigurableArticleTemplateEmailer) (context.getSingleChild("ApplicantAccountCreatedEmailer"));
}
protected void sendMail(Candidate candidate, Job job, HttpServletRequest request) throws BusinessException
{
try
{
LogMgr.log(LOG, LogLevel.PROCESSING1, "Sending Account Created mail from VerifyIdentityFP to :: ", candidate);
Article applyJobArticle = WebUtils.getArticleByShortCut(candidate.getTransaction(), WebUtils.APPLY_JOB);
String link = LoopbackHTTP.getRemoteAccessURL(request)
+ applyJobArticle.getLink(request, CollectionUtils.mapEntry("cms.rm", WebUtils.FORGOT_PASSWORD).toMap(), "/")
+ "&id=" + job.getID()
+ "&key=" + job.getRandomKey();
Map defaultParams = CollectionUtils.mapEntry("link", link).toMap();
ObjectTransform transform = Utils.createCompoundTransform(defaultParams, candidate.getUser());
Utils.sendMail(emailer, transform, new String[]{candidate.getUser().getUserName()}, null, candidate);
LogMgr.log(LOG, LogLevel.PROCESSING1, "Sent Account Created mail successfully from " + VerifyIdentityFP.class + " to :: ", candidate);
}
catch (ConfigurableEmailerException ex)
if(candidate.isFalse(candidate.getIsMaskedEmail()) && candidate.isFalse(candidate.getIsAccountVerified()))
{
LogMgr.log(LOG, LogLevel.SYSTEMERROR1, ex, "Error occured while sending mail for Candidate :: " + candidate);
throw new BusinessException("We are unable to send mail. Please try again or contact Matchd for more details.");
candidate.setIsAccountVerified(true);
LogMgr.log(LOG, LogLevel.PROCESSING1, "Verifing User ", candidate);
}
return super.processForm(process, submission, params);
}
}
\ No newline at end of file
package performa.intercom.resources;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.Maps;
import java.util.Map;
@SuppressWarnings("UnusedDeclaration")
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class Admin extends TypedData implements Replier {
private static final Map<String, String> SENTINEL = Maps.newHashMap();
public static final String TYPE_NOBODY = "nobody_admin";
// don't make public for now
static AdminCollection list(Map<String, String> params)
throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
return DataResource.list(params, "admins", AdminCollection.class);
}
public static AdminCollection list()
throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
return DataResource.list(SENTINEL, "admins", AdminCollection.class);
}
@SuppressWarnings("FieldCanBeLocal")
@JsonProperty("type")
private final String type = "admin";
@JsonProperty("id")
private String id;
@JsonProperty("name")
private String name;
@JsonProperty("email")
private String email;
@JsonProperty("created_at")
private long createdAt;
@JsonProperty("updated_at")
private long updatedAt;
@JsonProperty("open")
private long open;
@JsonProperty("closed")
private long closed;
public Admin() {
}
@JsonIgnore
public String getReplyType() {
return getType() + "_reply";
}
public String getType() {
return type;
}
@JsonIgnore
public boolean isNobody() {
return TYPE_NOBODY.equalsIgnoreCase(getType());
}
@JsonIgnore
public boolean isSomebody() {
return (!isNobody()) && (getId() != null);
}
public String getId() {
return id;
}
public Admin setId(String id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public String getEmail() {
return email;
}
public long getCreatedAt() {
return createdAt;
}
public long getUpdatedAt() {
return updatedAt;
}
public long getOpen() {
return open;
}
public long getClosed() {
return closed;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Admin admin = (Admin) o;
if (closed != admin.closed) return false;
if (createdAt != admin.createdAt) return false;
if (open != admin.open) return false;
if (updatedAt != admin.updatedAt) return false;
if (email != null ? !email.equals(admin.email) : admin.email != null) return false;
if (id != null ? !id.equals(admin.id) : admin.id != null) return false;
if (name != null ? !name.equals(admin.name) : admin.name != null) return false;
//noinspection RedundantIfStatement
if (!type.equals(admin.type)) return false;
return true;
}
@Override
public int hashCode() {
int result = type.hashCode();
result = 31 * result + (id != null ? id.hashCode() : 0);
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (email != null ? email.hashCode() : 0);
result = 31 * result + (int) (createdAt ^ (createdAt >>> 32));
result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32));
result = 31 * result + (int) (open ^ (open >>> 32));
result = 31 * result + (int) (closed ^ (closed >>> 32));
return result;
}
@Override
public String toString() {
return "Admin{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
", email='" + email + '\'' +
", createdAt=" + createdAt +
", updatedAt=" + updatedAt +
"} " + super.toString();
}
}
package performa.intercom.resources;
import performa.intercom.resources.Admin;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Iterator;
import java.util.List;
@SuppressWarnings("UnusedDeclaration")
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class AdminCollection extends TypedDataCollection<Admin> implements Iterator<Admin> {
protected TypedDataCollectionIterator<Admin> iterator;
public AdminCollection() {
type = "company.list";
iterator = new TypedDataCollectionIterator<Admin>(this);
}
@Override
public AdminCollection nextPage() {
return fetchNextPage(AdminCollection.class);
}
@SuppressWarnings("EmptyMethod")
@JsonProperty("admins")
@Override
public List<Admin> getPage() {
return super.getPage();
}
public boolean hasNext() {
return iterator.hasNext();
}
public Admin next() {
return iterator.next();
}
public void remove() {
iterator.remove();
}
}
package performa.intercom.resources;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.annotations.VisibleForTesting;
@SuppressWarnings("UnusedDeclaration")
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class AdminMessage extends TypedData {
@JsonProperty("type")
private final String type = "admin_message";
@JsonProperty("id")
private String id;
@JsonProperty("message_type")
private String messageType;
@JsonProperty("subject")
private String subject=""; // Set default to blank string so null pointer exception won't thrown if messageType = inapp and subject not set
@JsonProperty("body")
private String body;
@JsonProperty("template")
private String template="plain"; // Set default to plain so null pointer exception won't thrown if messageType = inapp and template not set
@JsonProperty("created_at")
private long createdAt;
@JsonProperty("from")
private Admin admin;
@JsonProperty("to")
private User user;
public AdminMessage() {
}
public String getType() {
return type;
}
public String getId() {
return id;
}
@SuppressWarnings("UnusedReturnValue")
@VisibleForTesting
AdminMessage setId(String id) {
this.id = id;
return this;
}
public String getMessageType() {
return messageType;
}
public AdminMessage setMessageType(String messageType) {
this.messageType = messageType;
return this;
}
public String getSubject() {
return subject;
}
public AdminMessage setSubject(String subject) {
this.subject = subject;
return this;
}
public String getBody() {
return body;
}
public AdminMessage setBody(String body) {
this.body = body;
return this;
}
public String getTemplate() {
return template;
}
public AdminMessage setTemplate(String template) {
this.template = template;
return this;
}
public long getCreatedAt() {
return createdAt;
}
@SuppressWarnings("UnusedReturnValue")
public AdminMessage setCreatedAt(long createdAt) {
this.createdAt = createdAt;
return this;
}
public Admin getAdmin() {
return admin;
}
public AdminMessage setAdmin(Admin admin) {
this.admin = admin;
return this;
}
public User getUser() {
return user;
}
public AdminMessage setUser(User user) {
this.user = user;
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AdminMessage message = (AdminMessage) o;
if (createdAt != message.createdAt) return false;
if (admin != null ? !admin.equals(message.admin) : message.admin != null) return false;
if (body != null ? !body.equals(message.body) : message.body != null) return false;
if (id != null ? !id.equals(message.id) : message.id != null) return false;
if (messageType != null ? !messageType.equals(message.messageType) : message.messageType != null) return false;
if (subject != null ? !subject.equals(message.subject) : message.subject != null) return false;
if (template != null ? !template.equals(message.template) : message.template != null) return false;
if (!type.equals(message.type)) return false;
//noinspection RedundantIfStatement
if (user != null ? !user.equals(message.user) : message.user != null) return false;
return true;
}
@Override
public int hashCode() {
int result = type.hashCode();
result = 31 * result + (id != null ? id.hashCode() : 0);
result = 31 * result + (messageType != null ? messageType.hashCode() : 0);
result = 31 * result + (subject != null ? subject.hashCode() : 0);
result = 31 * result + (body != null ? body.hashCode() : 0);
result = 31 * result + (template != null ? template.hashCode() : 0);
result = 31 * result + (int) (createdAt ^ (createdAt >>> 32));
result = 31 * result + (admin != null ? admin.hashCode() : 0);
result = 31 * result + (user != null ? user.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "AdminMessage{" +
"id='" + id + '\'' +
", messageType='" + messageType + '\'' +
", subject='" + subject + '\'' +
", body='" + body + '\'' +
", template='" + template + '\'' +
", createdAt=" + createdAt +
", admin=" + admin +
", user=" + user +
"} " + super.toString();
}
}
package performa.intercom.resources;
import performa.intercom.resources.Admin;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
@SuppressWarnings("UnusedDeclaration")
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
class AdminMessageResponse extends TypedData {
@JsonProperty("id")
private String id;
@JsonProperty("message_type")
private String messageType;
@JsonProperty("subject")
private String subject;
@JsonProperty("body")
private String body;
@JsonProperty("template")
private String template;
@JsonProperty("created_at")
private long createdAt;
@JsonProperty("updated_at")
private long updatedAt;
@JsonProperty("owner")
private Admin admin;
@JsonProperty("to")
private User user;
public AdminMessageResponse() {
}
public String getType() {
return "admin_message";
}
public String getId() {
return id;
}
public AdminMessageResponse setId(String id) {
this.id = id;
return this;
}
public String getMessageType() {
return messageType;
}
public AdminMessageResponse setMessageType(String messageType) {
this.messageType = messageType;
return this;
}
public String getSubject() {
return subject;
}
public AdminMessageResponse setSubject(String subject) {
this.subject = subject;
return this;
}
public String getBody() {
return body;
}
public AdminMessageResponse setBody(String body) {
this.body = body;
return this;
}
public String getTemplate() {
return template;
}
public AdminMessageResponse setTemplate(String template) {
this.template = template;
return this;
}
public long getCreatedAt() {
return createdAt;
}
public AdminMessageResponse setCreatedAt(long createdAt) {
this.createdAt = createdAt;
return this;
}
public long getUpdatedAt() {
return updatedAt;
}
public AdminMessageResponse setUpdatedAt(long updatedAt) {
this.updatedAt = updatedAt;
return this;
}
public Admin getAdmin() {
return admin;
}
public AdminMessageResponse setAdmin(Admin admin) {
this.admin = admin;
return this;
}
public User getUser() {
return user;
}
public AdminMessageResponse setUser(User user) {
this.user = user;
return this;
}
}
package performa.intercom.resources;
import performa.intercom.resources.Admin;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
@SuppressWarnings("UnusedDeclaration")
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class AdminReply extends Reply<Admin> {
@SuppressWarnings("UnusedDeclaration")
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
static class AdminStringReply {
private AdminReply reply;
public AdminStringReply(AdminReply reply) {
this.reply = reply;
}
@JsonProperty("type")
public String getType() {
return reply.getType();
}
@JsonProperty("message_type")
public String getMessageType() {
return reply.getMessageType();
}
@JsonProperty("body")
public String getBody() {
return reply.getBody();
}
@JsonProperty("admin_id")
public String getAdminID() {
return reply.getFrom().getId();
}
@JsonProperty("assignee_id")
public String getAssigneeID() {
return reply.getAssigneeID();
}
@JsonProperty("attachment_urls")
private String[] getAttachmentUrls() {
return reply.getAttachmentUrls();
}
}
@JsonProperty("assignee_id")
private String assigneeID;
public AdminReply(Admin admin) {
this.from = admin;
}
public Reply<Admin> setMessageType(String messageType) {
return setMessageReplyType(messageType);
}
public String getAssigneeID() {
return assigneeID;
}
public Reply<Admin> setAssigneeID(String assigneeID) {
this.assigneeID = assigneeID;
this.setMessageType(Conversation.MESSAGE_TYPE_ASSIGNMENT);
return this;
}
@Override
public String toString() {
return "AdminReply{} " + super.toString();
}
}
package performa.intercom.resources;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
@SuppressWarnings("UnusedDeclaration")
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class Author extends TypedData {
@JsonProperty("type")
private String type;
@JsonProperty("id")
private String id;
@JsonProperty("name")
private String name;
@JsonProperty("email")
private String email;
@JsonProperty("user_id")
private String userId;
public Author() {
}
public String getType() {
return type;
}
@JsonIgnore
public boolean isUser() {
return "user".equalsIgnoreCase(getType());
}
@JsonIgnore
public boolean isAdmin() {
return "admin".equalsIgnoreCase(getType());
}
public String getId() {
return id;
}
public Author setId(String id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public Author setName(String name) {
this.name = name;
return this;
}
public String getEmail() {
return email;
}
public Author setEmail(String email) {
this.email = email;
return this;
}
public String getUserId() {
return userId;
}
public Author setUserId(String userId) {
this.userId = userId;
return this;
}
@Override
public int hashCode() {
int result = id != null ? id.hashCode() : 0;
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (email != null ? email.hashCode() : 0);
result = 31 * result + (userId != null ? userId.hashCode() : 0);
return result;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Author author = (Author) o;
if (email != null ? !email.equals(author.email) : author.email != null) return false;
if (id != null ? !id.equals(author.id) : author.id != null) return false;
if (name != null ? !name.equals(author.name) : author.name != null) return false;
//noinspection RedundantIfStatement
if (userId != null ? !userId.equals(author.userId) : author.userId != null) return false;
return true;
}
@Override
public String toString() {
return "Author{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
", email='" + email + '\'' +
", userId='" + userId + '\'' +
"} " + super.toString();
}
}
package performa.intercom.resources;
public class AuthorizationException extends IntercomException {
private static final long serialVersionUID = 2917082281352001861L;
public AuthorizationException(String message) {
super(message);
}
public AuthorizationException(String message, Throwable cause) {
super(message, cause);
}
public AuthorizationException(ErrorCollection errorCollection) {
super(errorCollection);
}
public AuthorizationException(ErrorCollection errorCollection, Throwable cause) {
super(errorCollection, cause);
}
}
package performa.intercom.resources;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.net.URI;
@SuppressWarnings("UnusedDeclaration")
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
public class Avatar extends TypedData {
@JsonProperty("type")
private final String type = "avatar";
@JsonProperty("image_url")
private URI imageURL;
Avatar() {
}
public String getType() {
return type;
}
public URI getImageURL() {
return imageURL;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Avatar avatar = (Avatar) o;
if (imageURL != null ? !imageURL.equals(avatar.imageURL) : avatar.imageURL != null) return false;
//noinspection RedundantIfStatement
if (!type.equals(avatar.type)) return false;
return true;
}
@Override
public int hashCode() {
int result = type.hashCode();
result = 31 * result + (imageURL != null ? imageURL.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "Avatar{" +
"type='" + type + '\'' +
", imageURL=" + imageURL +
"} " + super.toString();
}
}
package performa.intercom.resources;
public class ClientException extends IntercomException {
private static final long serialVersionUID = -2111295679006526646L;
public ClientException(String message) {
super(message);
}
public ClientException(String message, Throwable cause) {
super(message, cause);
}
public ClientException(ErrorCollection errorCollection) {
super(errorCollection);
}
public ClientException(ErrorCollection errorCollection, Throwable cause) {
super(errorCollection, cause);
}
}
package performa.intercom.resources;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Iterator;
import java.util.List;
@SuppressWarnings("UnusedDeclaration")
@JsonIgnoreProperties(ignoreUnknown = true)
public class CompanyCollection extends TypedDataCollection<Company> implements Iterator<Company> {
protected TypedDataCollectionIterator<Company> iterator;
@JsonProperty("total_count")
private long totalCount;
public CompanyCollection() {
type = "company.list";
iterator = new TypedDataCollectionIterator<Company>(this);
}
public CompanyCollection(List<Company> companies) {
this();
this.page = companies;
}
@SuppressWarnings("EmptyMethod")
@JsonProperty("companies")
@Override
public List<Company> getPage() {
return super.getPage();
}
public long getTotalCount() {
return totalCount;
}
@Override
public CompanyCollection nextPage() {
return fetchNextPage(CompanyCollection.class);
}
public boolean hasNext() {
return iterator.hasNext();
}
public Company next() {
return iterator.next();
}
public void remove() {
iterator.remove();
}
@Override
public String toString() {
return "CompanyCollection{" +
", totalCount=" + totalCount +
"} " + super.toString();
}
void addCompany(Company company) {
page.add(company);
}
}
package performa.intercom.resources;
import com.google.common.base.Objects;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import java.util.List;
class CompanyUpdateBuilder {
/**
* Provide restrictions on the company data that can be sent via a user update
*/
static List<CompanyWithStringPlan> buildUserUpdateCompanies(CompanyCollection add, CompanyCollection remove) {
final List<CompanyWithStringPlan> updatableCompanies = Lists.newArrayList();
if (add != null) {
final List<Company> companies = add.getPage();
for (Company company : companies) {
if (!isCompanyInList(company, remove)) {
updatableCompanies.add(prepareUpdatableCompany(company));
}
}
}
if (remove != null) {
final List<Company> companies = remove.getPage();
for (Company company : companies) {
updatableCompanies.add(prepareUpdatableCompany(company).setRemove(Boolean.TRUE));
}
}
return updatableCompanies;
}
private static boolean isCompanyInList(final Company company, CompanyCollection companyCollection) {
if (companyCollection == null) {
return false;
}
return Iterables.any(companyCollection.getPage(), new Predicate<Company>() {
@Override
public boolean apply(Company e) {
return Objects.equal(company.getCompanyID(), e.getCompanyID())
|| Objects.equal(company.getId(), e.getId());
}
});
}
private static CompanyWithStringPlan prepareUpdatableCompany(Company company) {
final CompanyWithStringPlan updatableCompany = new CompanyWithStringPlan();
updatableCompany.setId(company.getId());
updatableCompany.setCompanyID(company.getCompanyID());
updatableCompany.setName(company.getName());
updatableCompany.setSessionCount(company.getSessionCount());
updatableCompany.setMonthlySpend(company.getMonthlySpend());
updatableCompany.setRemoteCreatedAt(company.getRemoteCreatedAt());
if (company.getCustomAttributes() != null) {
updatableCompany.getCustomAttributes().putAll(company.getCustomAttributes());
}
if (company.getPlan() != null) {
updatableCompany.setPlan(company.getPlan().getName());
}
return updatableCompany;
}
}
package performa.intercom.resources;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.Maps;
import java.util.Map;
@SuppressWarnings("UnusedDeclaration")
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@JsonIgnoreProperties(ignoreUnknown = true)
class CompanyWithStringPlan extends TypedData {
@JsonProperty("id")
private String id;
@JsonProperty("name")
private String name;
@JsonProperty("company_id")
private String companyID;
@JsonProperty("session_count")
private int sessionCount;
@JsonProperty("monthly_spend")
private float monthlySpend;
@JsonProperty("remote_created_at")
private long remoteCreatedAt;
@JsonProperty("plan")
private String plan;
@JsonIgnoreProperties(ignoreUnknown = false)
@JsonProperty("custom_attributes")
private Map<String, CustomAttribute> customAttributes = Maps.newHashMap();
@JsonProperty("remove")
@JsonInclude(JsonInclude.Include.NON_NULL)
private Boolean remove;
public CompanyWithStringPlan() {
}
public String getType() {
return "company";
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCompanyID() {
return companyID;
}
public void setCompanyID(String companyID) {
this.companyID = companyID;
}
public Integer getSessionCount() {
return sessionCount;
}
public void setSessionCount(Integer sessionCount) {
this.sessionCount = sessionCount;
}
public float getMonthlySpend() {
return monthlySpend;
}
public void setMonthlySpend(float monthlySpend) {
this.monthlySpend = monthlySpend;
}
public long getRemoteCreatedAt() {
return remoteCreatedAt;
}
public void setRemoteCreatedAt(long remoteCreatedAt) {
this.remoteCreatedAt = remoteCreatedAt;
}
public String getPlan() {
return plan;
}
public void setPlan(String plan) {
this.plan = plan;
}
public Map<String, CustomAttribute> getCustomAttributes() {
return customAttributes;
}
public void setCustomAttributes(Map<String, CustomAttribute> customAttributes) {
this.customAttributes = customAttributes;
}
public Boolean getRemove() {
return remove;
}
public CompanyWithStringPlan setRemove(Boolean remove) {
this.remove = remove;
return this;
}
}
package performa.intercom.resources;
import com.google.common.collect.Lists;
class Conditions {
/**
* Ensures that an object reference passed as a parameter to the calling
* method is not null. Variant of Guava's Preconditions that returns an
* InvalidException containing an ErrorCollection
*
* @param reference an object reference
* @param errorMessage the exception message to use if the check fails
* @return the non-null reference that was validated
* @throws InvalidException if {@code reference} is null
*/
public static <T> T checkNotNull(T reference, String errorMessage) {
if (reference == null) {
throw new InvalidException(
new ErrorCollection(
Lists.newArrayList(
new Error("invalid", "item method must be supplied"))));
}
return reference;
}
}
package performa.intercom.resources;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Iterator;
import java.util.List;
@SuppressWarnings("UnusedDeclaration")
@JsonIgnoreProperties(ignoreUnknown = true)
public class ContactCollection extends TypedDataCollection<Contact> implements Iterator<Contact> {
protected TypedDataCollectionIterator<Contact> iterator;
public ContactCollection() {
iterator = new TypedDataCollectionIterator<Contact>(this);
}
public ContactCollection(List<Contact> contacts) {
this();
this.page = contacts;
}
@SuppressWarnings("EmptyMethod")
@JsonProperty("contacts")
@Override
public List<Contact> getPage() {
return super.getPage();
}
@Override
public ContactCollection nextPage() {
return fetchNextPage(ContactCollection.class);
}
public boolean hasNext() {
return iterator.hasNext();
}
public Contact next() {
return iterator.next();
}
public void remove() {
iterator.remove();
}
}
package performa.intercom.resources;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
@SuppressWarnings("UnusedDeclaration")
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class ContactMessage extends TypedMessage<Contact, ContactMessage> {
public ContactMessage() {
}
@Override
public String toString() {
return "ContactMessage{} " + super.toString();
}
}
package performa.intercom.resources;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Iterator;
import java.util.List;
@SuppressWarnings("UnusedDeclaration")
@JsonIgnoreProperties(ignoreUnknown = true)
public class ConversationCollection extends TypedDataCollection<Conversation> implements Iterator<Conversation> {
protected TypedDataCollectionIterator<Conversation> iterator;
public ConversationCollection() {
type = "conversation.list";
iterator = new TypedDataCollectionIterator<Conversation>(this);
}
@SuppressWarnings("EmptyMethod")
@JsonProperty("conversations")
public List<Conversation> getPage() {
return super.getPage();
}
@Override
public ConversationCollection nextPage() {
return fetchNextPage(ConversationCollection.class);
}
public boolean hasNext() {
return iterator.hasNext();
}
public Conversation next() {
return iterator.next();
}
public void remove() {
iterator.remove();
}
}
package performa.intercom.resources;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
@SuppressWarnings("UnusedDeclaration")
@JsonIgnoreProperties(ignoreUnknown = true)
public class ConversationMessage extends TypedData {
@SuppressWarnings("FieldCanBeLocal")
@JsonProperty("type")
private final String type = "conversation_message";
@JsonProperty
private String subject;
@JsonProperty
private String body;
@JsonProperty
private Author author;
public ConversationMessage() {
}
public String getType() {
return type;
}
public String getSubject() {
return subject;
}
public String getBody() {
return body;
}
public Author getAuthor() {
return author;
}
@Override
public int hashCode() {
int result = subject != null ? subject.hashCode() : 0;
result = 31 * result + (body != null ? body.hashCode() : 0);
result = 31 * result + (author != null ? author.hashCode() : 0);
return result;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ConversationMessage that = (ConversationMessage) o;
if (author != null ? !author.equals(that.author) : that.author != null) return false;
if (body != null ? !body.equals(that.body) : that.body != null) return false;
//noinspection RedundantIfStatement
if (subject != null ? !subject.equals(that.subject) : that.subject != null) return false;
return true;
}
@Override
public String toString() {
return "ConversationMessage{" +
"type='" + type + '\'' +
", subject='" + subject + '\'' +
", body='" + body + '\'' +
", author=" + author +
"} " + super.toString();
}
}
package performa.intercom.resources;
import performa.intercom.resources.Admin;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
@SuppressWarnings("UnusedDeclaration")
@JsonIgnoreProperties(ignoreUnknown = true)
public class ConversationPart extends TypedData {
@JsonProperty("type")
private final String type = "conversation_part";
@JsonProperty
private String id;
@JsonProperty("part_type")
private String partType;
@JsonProperty
private String body;
@JsonProperty
private Author author;
@JsonProperty("assigned_to")
private Admin assignedTo;
@JsonProperty("created_at")
private long createdAt;
@JsonProperty("updated_at")
private long updatedAt;
@JsonProperty("notified_at")
private long NotifiedAt;
public ConversationPart() {
}
public String getType() {
return type;
}
public String getId() {
return id;
}
public String getPartType() {
return partType;
}
public String getBody() {
return body;
}
public Author getAuthor() {
return author;
}
public Admin getAssignedTo() {
return assignedTo;
}
public long getCreatedAt() {
return createdAt;
}
public long getUpdatedAt() {
return updatedAt;
}
public long getNotifiedAt() {
return NotifiedAt;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ConversationPart that = (ConversationPart) o;
if (NotifiedAt != that.NotifiedAt) return false;
if (createdAt != that.createdAt) return false;
if (updatedAt != that.updatedAt) return false;
if (assignedTo != null ? !assignedTo.equals(that.assignedTo) : that.assignedTo != null) return false;
if (author != null ? !author.equals(that.author) : that.author != null) return false;
if (body != null ? !body.equals(that.body) : that.body != null) return false;
if (id != null ? !id.equals(that.id) : that.id != null) return false;
if (partType != null ? !partType.equals(that.partType) : that.partType != null) return false;
//noinspection RedundantIfStatement
if (!type.equals(that.type)) return false;
return true;
}
@Override
public int hashCode() {
int result = type.hashCode();
result = 31 * result + (id != null ? id.hashCode() : 0);
result = 31 * result + (partType != null ? partType.hashCode() : 0);
result = 31 * result + (body != null ? body.hashCode() : 0);
result = 31 * result + (author != null ? author.hashCode() : 0);
result = 31 * result + (assignedTo != null ? assignedTo.hashCode() : 0);
result = 31 * result + (int) (createdAt ^ (createdAt >>> 32));
result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32));
result = 31 * result + (int) (NotifiedAt ^ (NotifiedAt >>> 32));
return result;
}
@Override
public String toString() {
return "ConversationPart{" +
"type='" + type + '\'' +
", id='" + id + '\'' +
", partType='" + partType + '\'' +
", body='" + body + '\'' +
", author=" + author +
", assignedTo=" + assignedTo +
", createdAt=" + createdAt +
", updatedAt=" + updatedAt +
", NotifiedAt=" + NotifiedAt +
"} " + super.toString();
}
}
package performa.intercom.resources;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
@SuppressWarnings("UnusedDeclaration")
@JsonIgnoreProperties(ignoreUnknown = true)
public class ConversationPartCollection extends TypedDataCollection<ConversationPart> {
public ConversationPartCollection() {
type = "conversation_part.list";
}
@SuppressWarnings("EmptyMethod")
@JsonProperty("conversation_parts")
public List<ConversationPart> getPage() {
return super.getPage();
}
@Override
public ConversationPartCollection nextPage() {
return new ConversationPartCollection();
}
}
package performa.intercom.resources;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.TreeNode;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.io.IOException;
import java.util.Map;
class CountItemDeserializer extends StdDeserializer<Counts.CountItem> {
private static final long serialVersionUID = 8226175715446656115L;
public CountItemDeserializer() {
super(Counts.CountItem.class);
}
@Override
public Counts.CountItem deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
final TreeNode treeNode = jp.getCodec().readTree(jp);
final Map.Entry<String, JsonNode> next = ((ObjectNode) treeNode).fields().next();
return new Counts.CountItem(next.getKey(), next.getValue().asLong());
}
}
package performa.intercom.resources;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import java.io.IOException;
class CountItemSerializer extends StdSerializer<Counts.CountItem> {
public CountItemSerializer() {
super(Counts.CountItem.class);
}
@Override
public void serialize(Counts.CountItem value, JsonGenerator jgen, SerializerProvider provider)
throws IOException {
jgen.writeStartObject();
jgen.writeNumberField(value.getName(), value.getValue());
jgen.writeEndObject();
}
}
package performa.intercom.resources;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.Maps;
import java.net.URI;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@SuppressWarnings("UnusedDeclaration")
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class Counts {
static Counts countQuery(Map<String, String> query) {
final URI build = UriBuilder.newBuilder()
.path("counts")
.query(query)
.build();
final HttpClient resource = new HttpClient(build);
return resource.get(Counts.class);
}
public static Counts.Totals appTotals() throws InvalidException, AuthorizationException {
final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path("counts").build());
return resource.get(Totals.class);
}
// public static Long userCount() throws InvalidException, AuthorizationException{
// final HashMap<String, String> params = Maps.newHashMap();
// params.put("type", "user");
// return countQuery(params).getUser().getUser();
// }
public static List<CountItem> userTags() throws InvalidException, AuthorizationException {
final HashMap<String, String> params = Maps.newHashMap();
params.put("type", "user");
params.put("count", "tag");
return countQuery(params).getUser().getTags();
}
public static List<CountItem> userSegments() throws InvalidException, AuthorizationException {
final HashMap<String, String> params = Maps.newHashMap();
params.put("type", "user");
params.put("count", "segment");
return countQuery(params).getUser().getSegments();
}
public static Counts.Conversation conversationTotals() throws InvalidException, AuthorizationException {
final HashMap<String, String> params = Maps.newHashMap();
params.put("type", "conversation");
return countQuery(params).getConversation();
}
public static Counts.Conversation conversationAdmins() throws InvalidException, AuthorizationException {
final HashMap<String, String> params = Maps.newHashMap();
params.put("type", "conversation");
params.put("count", "admin");
return countQuery(params).getConversation();
}
// public static Long companyCount() throws InvalidException, AuthorizationException{
// final HashMap<String, String> params = Maps.newHashMap();
// params.put("type", "company");
// return countQuery(params).getCompany().getCompanies();
// }
public static List<CountItem> companySegments() throws InvalidException, AuthorizationException {
final HashMap<String, String> params = Maps.newHashMap();
params.put("type", "company");
params.put("count", "segment");
return countQuery(params).getCompany().getSegments();
}
public static List<CountItem> companyTags() throws InvalidException, AuthorizationException {
final HashMap<String, String> params = Maps.newHashMap();
params.put("type", "company");
params.put("count", "tag");
return countQuery(params).getCompany().getTags();
}
public static List<CountItem> companyUsers() throws InvalidException, AuthorizationException {
final HashMap<String, String> params = Maps.newHashMap();
params.put("type", "company");
params.put("count", "user");
return countQuery(params).getCompany().getUsers();
}
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class Totals {
@JsonProperty("company")
private CountItem company;
@JsonProperty("segment")
private CountItem segment;
@JsonProperty("tag")
private CountItem tag;
@JsonProperty("user")
private CountItem user;
public CountItem getCompany() {
return company;
}
public CountItem getSegment() {
return segment;
}
public CountItem getTag() {
return tag;
}
public CountItem getUser() {
return user;
}
@Override
public String toString() {
return "Totals{" +
"company=" + company +
", segment=" + segment +
", tag=" + tag +
", user=" + user +
'}';
}
}
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class CountItem {
private String name;
private long value;
public CountItem(String name, long value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public long getValue() {
return value;
}
@Override
public String toString() {
return "CountItem{" +
"name='" + name + '\'' +
", value=" + value +
'}';
}
}
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class Conversation {
@JsonProperty("admin")
List<Admin> admins;
@JsonProperty("assigned")
private long assigned;
@JsonProperty("closed")
private long closed;
@JsonProperty("open")
private long open;
@JsonProperty("unassigned")
private long unassigned;
Conversation() {
}
public List<Admin> getAdmins() {
return admins;
}
public long getAssigned() {
return assigned;
}
public long getClosed() {
return closed;
}
public long getOpen() {
return open;
}
public long getUnassigned() {
return unassigned;
}
@Override
public String toString() {
return "Conversation{" +
"assigned=" + assigned +
", closed=" + closed +
", open=" + open +
", unassigned=" + unassigned +
", admins=" + admins +
'}';
}
}
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class User {
@JsonProperty("user")
private long user;
@JsonProperty("tag")
private List<CountItem> tags;
@JsonProperty("segment")
private List<CountItem> segments;
User() {
}
public long getUser() {
return user;
}
public List<CountItem> getTags() {
return tags;
}
public List<CountItem> getSegments() {
return segments;
}
@Override
public String toString() {
return "User{" +
"user=" + user +
", tags=" + tags +
", segments=" + segments +
'}';
}
}
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class Company {
@JsonProperty("company")
private long companies;
@JsonProperty("tag")
private List<CountItem> tags;
@JsonProperty("user")
private List<CountItem> users;
@JsonProperty("segment")
private List<CountItem> segments;
Company() {
}
public long getCompanies() {
return companies;
}
public List<CountItem> getTags() {
return tags;
}
public List<CountItem> getUsers() {
return users;
}
public List<CountItem> getSegments() {
return segments;
}
@Override
public String toString() {
return "Company{" +
"companies=" + companies +
", tags=" + tags +
", users=" + users +
", segments=" + segments +
'}';
}
}
@JsonProperty("type")
private String type = "count";
@JsonProperty("company")
private Counts.Company company;
@JsonProperty("user")
private Counts.User user;
@JsonProperty("conversation")
private Counts.Conversation conversation;
public String getType() {
return type;
}
public Company getCompany() {
return company;
}
public User getUser() {
return user;
}
public Conversation getConversation() {
return conversation;
}
@Override
public String toString() {
return "Counts{" +
"type='" + type + '\'' +
", company=" + company +
", user=" + user +
", conversation=" + conversation +
'}';
}
}
package performa.intercom.resources;
import com.google.common.collect.Lists;
import java.io.Serializable;
import java.util.ArrayList;
@SuppressWarnings("UnusedDeclaration")
public class CustomAttribute<T> {
@SuppressWarnings("unchecked")
private static final ArrayList<? extends Class<? extends Serializable>> CLASSES = Lists.newArrayList(String.class, Long.class, Float.class, Double.class, Boolean.class, Integer.class);
public static StringAttribute newStringAttribute(String name, String value) {
return new StringAttribute(name, value);
}
public static BooleanAttribute newBooleanAttribute(String name, boolean value) {
return new BooleanAttribute(name, value);
}
public static DoubleAttribute newDoubleAttribute(String name, double value) {
return new DoubleAttribute(name, value);
}
public static LongAttribute newLongAttribute(String name, long value) {
return new LongAttribute(name, value);
}
public static IntegerAttribute newIntegerAttribute(String name, int value) {
return new IntegerAttribute(name, value);
}
public static FloatAttribute newFloatAttribute(String name, float value) {
return new FloatAttribute(name, value);
}
public static class StringAttribute extends CustomAttribute<String> {
private StringAttribute(String name, String value) {
super(name, value, String.class);
}
private StringAttribute(String name, String value, Class<String> clazz) {
super(name, value, clazz);
}
}
public static class BooleanAttribute extends CustomAttribute<Boolean> {
private BooleanAttribute(String name, boolean value) {
super(name, value, Boolean.class);
}
private BooleanAttribute(String name, boolean value, Class<Boolean> clazz) {
super(name, value, clazz);
}
}
public static class DoubleAttribute extends CustomAttribute<Double> {
private DoubleAttribute(String name, double value, Class<Double> clazz) {
super(name, value, clazz);
}
private DoubleAttribute(String name, double value) {
super(name, value, Double.class);
}
}
public static class FloatAttribute extends CustomAttribute<Float> {
private FloatAttribute(String name, float value, Class<Float> clazz) {
super(name, value, clazz);
}
private FloatAttribute(String name, float value) {
super(name, value, Float.class);
}
}
public static class IntegerAttribute extends CustomAttribute<Integer> {
private IntegerAttribute(String name, int value) {
super(name, value, Integer.class);
}
private IntegerAttribute(String name, int value, Class<Integer> clazz) {
super(name, value, clazz);
}
}
public static class LongAttribute extends CustomAttribute<Long> {
public LongAttribute(String name, long value, Class<Long> clazz) {
super(name, value, clazz);
}
public LongAttribute(String name, long value) {
super(name, value, Long.class);
}
}
private String name;
private T value;
private Class<T> clazz;
public CustomAttribute(String name, T value, Class<T> clazz) {
//noinspection SuspiciousMethodCalls
if (!CLASSES.contains(clazz)) {
throw new InvalidException(String.format("cannot accept class type [%s] for custom attribute", clazz.getName()));
}
this.name = name;
this.value = value;
this.clazz = clazz;
}
public Class<T> getValueClass() {
return clazz;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public T getValue() {
return value;
}
public void setValue(T value) {
this.value = value;
}
public <C> C as(Class<C> c) {
//noinspection unchecked
return (C) getValue();
}
public long longValue() {
return as(Long.class);
}
public String textValue() {
return as(String.class);
}
public boolean booleanValue() {
return as(Boolean.class);
}
public float floatValue() {
return as(Float.class);
}
public double doubleValue() {
return as(Double.class);
}
public int integerValue() {
return as(Integer.class);
}
@Override
public int hashCode() {
int result = name != null ? name.hashCode() : 0;
result = 31 * result + (value != null ? value.hashCode() : 0);
result = 31 * result + (clazz != null ? clazz.hashCode() : 0);
return result;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CustomAttribute that = (CustomAttribute) o;
if (clazz != null ? !clazz.equals(that.clazz) : that.clazz != null) return false;
if (name != null ? !name.equals(that.name) : that.name != null) return false;
//noinspection RedundantIfStatement
if (value != null ? !value.equals(that.value) : that.value != null) return false;
return true;
}
@Override
public String toString() {
return "CustomAttribute{" +
"name='" + name + '\'' +
", value=" + value +
", clazz=" + clazz +
'}';
}
}
package performa.intercom.resources;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.node.JsonNodeType;
import com.fasterxml.jackson.databind.node.NumericNode;
import com.fasterxml.jackson.databind.node.ValueNode;
import java.io.IOException;
class CustomAttributeDeserializer extends StdDeserializer<CustomAttribute> {
private static final long serialVersionUID = 5069924730975394938L;
public CustomAttributeDeserializer() {
super(CustomAttribute.class);
}
@Override
public CustomAttribute deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
CustomAttribute cda = null;
final String currentName = jp.getParsingContext().getCurrentName();
final ObjectMapper mapper = (ObjectMapper) jp.getCodec();
final ValueNode vNode = mapper.readTree(jp);
if (vNode.asToken().isScalarValue()) {
if (vNode.getNodeType() == JsonNodeType.BOOLEAN) {
cda = new CustomAttribute<Boolean>(currentName, vNode.asBoolean(), Boolean.class);
} else if (vNode.getNodeType() == JsonNodeType.STRING) {
cda = new CustomAttribute<String>(currentName, vNode.asText(), String.class);
} else if (vNode.getNodeType() == JsonNodeType.NUMBER) {
final NumericNode nNode = (NumericNode) vNode;
if (currentName.endsWith("_at")) {
cda = new CustomAttribute<Long>(currentName, vNode.longValue(), Long.class);
} else if (nNode.isInt()) {
cda = new CustomAttribute<Integer>(currentName, vNode.intValue(), Integer.class);
} else if (nNode.isFloat()) {
cda = new CustomAttribute<Float>(currentName, vNode.floatValue(), Float.class);
} else if (nNode.isDouble()) {
cda = new CustomAttribute<Double>(currentName, vNode.doubleValue(), Double.class);
} else if (nNode.isLong()) {
cda = new CustomAttribute<Long>(currentName, vNode.longValue(), Long.class);
} else {
cda = new CustomAttribute<String>(currentName, vNode.asText(), String.class);
}
} else {
cda = new CustomAttribute<String>(currentName, vNode.asText(), String.class);
}
}
return cda;
}
}
package performa.intercom.resources;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import java.io.IOException;
class CustomAttributeSerializer extends StdSerializer<CustomAttribute> {
public CustomAttributeSerializer() {
super(CustomAttribute.class);
}
@Override
public void serialize(CustomAttribute value, JsonGenerator jgen, SerializerProvider provider)
throws IOException {
// the field name has already been written
jgen.writeObject(value.getValue());
}
}
package performa.intercom.resources;
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import java.net.URI;
import java.util.List;
import java.util.Map;
abstract class DataResource {
@SuppressWarnings("SameParameterValue")
public static <T> T find(String id, String collectionPath, Class<T> c) {
final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).path(id).build());
return resource.get(c);
}
public static <T> T find(Map<String, String> params, String collectionPath, Class<T> c) {
final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).query(params).build());
return resource.get(c);
}
public static <T, R> R create(T entity, String collectionPath, Class<R> response) {
final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).build());
return resource.post(response, entity);
}
public static <T, R> R create(T entity, List<String> paths, Class<R> response) {
final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(paths).build());
return resource.post(response, entity);
}
public static <T, R> R update(T entity, String collectionPath, Class<R> response) {
final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).build());
return resource.post(response, entity);
}
public static <T, R> R post(T entity, URI path, Class<R> response) {
final HttpClient resource = new HttpClient(path);
return resource.post(response, entity);
}
public static <T, R> R updatePut(T entity, URI collectionPath, Class<R> response) {
final HttpClient resource = new HttpClient(collectionPath);
return resource.put(response, entity);
}
@SuppressWarnings("SameParameterValue")
public static <T, R> R update(T entity, String collectionPath, String id, Class<R> response) {
final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).path(id).build());
return resource.post(response, entity);
}
public static <T> T delete(String id, String collectionPath, Class<T> c) {
final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).path(id).build());
return resource.delete(c);
}
public static <C> C list(Map<String, String> params, String collectionPath, Class<C> c) {
final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).query(params).build());
return resource.get(c);
}
public static <C> C scroll(String scrollParam, String collectionPath, Class<C> c) {
Map<String, String> params = Maps.newHashMap();
if (!Strings.isNullOrEmpty(scrollParam)) {
params.put("scroll_param", scrollParam);
}
final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath + "/scroll").query(params).build());
return resource.get(c);
}
}
package performa.intercom.resources;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
@SuppressWarnings("UnusedDeclaration")
@JsonIgnoreProperties(ignoreUnknown = true)
public class Error extends TypedData {
@SuppressWarnings("FieldCanBeLocal")
@JsonProperty("type")
private final String type = "error";
@JsonProperty("code")
private String code;
@JsonProperty("message")
private String message;
public Error() {
}
public Error(String code, String message) {
this.code = code;
this.message = message;
}
public String getType() {
return type;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@Override
public int hashCode() {
int result = code != null ? code.hashCode() : 0;
result = 31 * result + (message != null ? message.hashCode() : 0);
return result;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Error error = (Error) o;
if (code != null ? !code.equals(error.code) : error.code != null) return false;
//noinspection RedundantIfStatement
if (message != null ? !message.equals(error.message) : error.message != null) return false;
return true;
}
@Override
public String toString() {
return getType() + "{" +
"code='" + code + '\'' +
", message='" + message + '\'' +
"} " + super.toString();
}
}
package performa.intercom.resources;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Preconditions;
import java.util.List;
@SuppressWarnings("UnusedDeclaration")
@JsonIgnoreProperties(ignoreUnknown = true)
public final class ErrorCollection {
@JsonProperty("errors")
private List<Error> errors;
// for jackson
ErrorCollection() {
}
public ErrorCollection(List<Error> errors) {
Preconditions.checkNotNull(errors, "cannot create an error collection with a null error list");
Preconditions.checkArgument(errors.size() > 0, "cannot create an error collection with an empty error list");
this.errors = errors;
}
public List<Error> getErrors() {
return errors;
}
public String getType() {
return "error.list";
}
}
package performa.intercom.resources;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@SuppressWarnings("UnusedDeclaration")
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
public class Event extends TypedData {
private static final List<String> BULK_METHODS = Lists.newArrayList("post");
private static final ArrayList<String> BULK_PATHS = Lists.newArrayListWithExpectedSize(2);
static {
BULK_PATHS.add("bulk");
BULK_PATHS.add("events");
}
public static void create(Event event) throws InvalidException, AuthorizationException {
validateCreateEvent(event);
if (event.getCreatedAt() == 0L) {
event.setCreatedAt(System.currentTimeMillis() / 1000);
}
DataResource.create(event, "events", Void.class);
}
public static Job submit(List<JobItem<Event>> items)
throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
return submit(items, null);
}
public static Job submit(List<JobItem<Event>> items, Job job)
throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
return Job.submit(validateJobItems(items), job, BULK_PATHS);
}
public static JobItemCollection<Event> listJobErrorFeed(String jobID)
throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
return Job.listJobErrorFeed(jobID, Event.class);
}
@VisibleForTesting
static List<JobItem<Event>> validateJobItems(List<JobItem<Event>> items) {
final JobSupport jobSupport = new JobSupport();
for (JobItem<Event> item : items) {
jobSupport.validateJobItem(item, BULK_METHODS);
validateCreateEvent(item.getData());
}
return items;
}
private static final ErrorCollection INVALID_NAME = new ErrorCollection(
Lists.newArrayList(
new Error("invalid", "an event must supply an event name")));
private static final ErrorCollection INVALID_USER = new ErrorCollection(
Lists.newArrayList(
new Error("invalid", "an event must supply either an email or a user id")));
@VisibleForTesting
static void validateCreateEvent(Event event) {
if (Strings.isNullOrEmpty(event.getEventName())) {
throw new InvalidException(INVALID_NAME);
}
if (Strings.isNullOrEmpty(event.getUserID())
&& Strings.isNullOrEmpty(event.getEmail())) {
throw new InvalidException(INVALID_USER);
}
}
@SuppressWarnings("FieldCanBeLocal")
@JsonProperty("type")
private final String type = "event";
@JsonProperty("event_name")
private String eventName;
@JsonProperty("created_at")
private long createdAt;
@JsonProperty("email")
private String email;
@JsonProperty("user_id")
private String userID;
@JsonProperty("metadata")
private Map<String, Object> metadata = Maps.newHashMap();
public Event() {
}
public String getType() {
return type;
}
public String getEventName() {
return eventName;
}
public Event setEventName(String eventName) {
this.eventName = eventName;
return this;
}
public long getCreatedAt() {
return createdAt;
}
@SuppressWarnings("UnusedReturnValue")
public Event setCreatedAt(long createdAt) {
this.createdAt = createdAt;
return this;
}
public String getEmail() {
return email;
}
public Event setEmail(String email) {
this.email = email;
return this;
}
public String getUserID() {
return userID;
}
public Event setUserID(String userID) {
this.userID = userID;
return this;
}
public Event putMetadata(String name, String value) {
metadata.put(name, value);
return this;
}
public Event putMetadata(String name, boolean value) {
metadata.put(name, value);
return this;
}
public Event putMetadata(String name, int value) {
metadata.put(name, value);
return this;
}
public Event putMetadata(String name, double value) {
metadata.put(name, value);
return this;
}
public Event putMetadata(String name, long value) {
metadata.put(name, value);
return this;
}
public Event putMetadata(String name, float value) {
metadata.put(name, value);
return this;
}
public Map<String, Object> getMetadata() {
return metadata;
}
public Event setMetadata(Map<String, Object> metadata) {
this.metadata = metadata;
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Event event = (Event) o;
if (createdAt != event.createdAt) return false;
if (email != null ? !email.equals(event.email) : event.email != null) return false;
if (eventName != null ? !eventName.equals(event.eventName) : event.eventName != null) return false;
if (metadata != null ? !metadata.equals(event.metadata) : event.metadata != null) return false;
if (!type.equals(event.type)) return false;
//noinspection RedundantIfStatement
if (userID != null ? !userID.equals(event.userID) : event.userID != null) return false;
return true;
}
@Override
public int hashCode() {
int result = type.hashCode();
result = 31 * result + (eventName != null ? eventName.hashCode() : 0);
result = 31 * result + (int) (createdAt ^ (createdAt >>> 32));
result = 31 * result + (email != null ? email.hashCode() : 0);
result = 31 * result + (userID != null ? userID.hashCode() : 0);
result = 31 * result + (metadata != null ? metadata.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "Event{" +
"type='" + type + '\'' +
", eventName='" + eventName + '\'' +
", createdAt=" + createdAt +
", email='" + email + '\'' +
", userID='" + userID + '\'' +
", metadata=" + metadata +
"} " + super.toString();
}
}
package performa.intercom.resources;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URI;
public interface HttpConnectorSupplier {
HttpURLConnection connect(URI uri) throws IOException;
HttpConnectorSupplier defaultSupplier = new HttpConnectorSupplier() {
public HttpURLConnection connect(URI uri) throws IOException {
return (HttpURLConnection) uri.toURL().openConnection();
}
};
}
package performa.intercom.resources;
import org.slf4j.LoggerFactory;
import java.io.Closeable;
import java.net.HttpURLConnection;
class IOUtils {
private static final org.slf4j.Logger logger = LoggerFactory.getLogger("intercom-java");
/**
* Close a HttpURLConnection, ignores checked Exceptions and nulls,
* but rethrows RuntimeExceptions.
*
* @param connection the connection to disconnect
*/
public static void disconnectQuietly(HttpURLConnection connection) {
if (connection != null) {
try {
connection.disconnect();
} catch (RuntimeException rethrow) {
throw rethrow;
} catch (Exception e) {
logger.warn(e.getMessage());
}
}
}
/**
* Close a stream, ignores checked Exceptions and nulls,
* but rethrows RuntimeExceptions.
*
* @param stream the object to close
*/
public static void closeQuietly(Closeable stream) {
if (stream != null) {
try {
stream.close();
} catch (RuntimeException rethrow) {
throw rethrow;
} catch (Exception e) {
logger.warn(e.getMessage());
}
}
}
}
package performa.intercom.resources;
import java.net.URI;
public class Intercom {
private static final URI API_BASE_URI = URI.create("https://api.intercom.io/");
private static volatile URI apiBaseURI = API_BASE_URI;
private static volatile AuthKeyType authKeyType = AuthKeyType.API_KEY;
enum AuthKeyType {
API_KEY,
TOKEN
}
private static final String VERSION = "2.2.7";
public static final String USER_AGENT = "intercom-java/" + Intercom.VERSION;
private static volatile String apiKey;
private static volatile String token;
private static volatile String appID;
private static volatile int connectionTimeout = 3 * 1000;
private static volatile int requestTimeout = 60 * 1000;
private static volatile boolean requestUsingCaches = false;
private static volatile HttpConnectorSupplier httpConnectorSupplier = HttpConnectorSupplier.defaultSupplier;
public static long currentTimestamp() {
return System.currentTimeMillis()/1000;
}
public static int getConnectionTimeout() {
return connectionTimeout;
}
@SuppressWarnings("UnusedDeclaration")
public static void setConnectionTimeout(int connectionTimeout) {
Intercom.connectionTimeout = connectionTimeout;
}
public static int getRequestTimeout() {
return requestTimeout;
}
@SuppressWarnings("UnusedDeclaration")
public static void setRequestTimeout(int requestTimeout) {
Intercom.requestTimeout = requestTimeout;
}
public static boolean isRequestUsingCaches() {
return requestUsingCaches;
}
public static void setRequestUsingCaches(boolean requestUsingCaches) {
Intercom.requestUsingCaches = requestUsingCaches;
}
public static HttpConnectorSupplier getHttpConnectorSupplier() {
return httpConnectorSupplier;
}
public static void setHttpConnectorSupplier(HttpConnectorSupplier supplier) {
Intercom.httpConnectorSupplier = supplier;
}
public static String getAppID() {
return appID;
}
public static void setAppID(String appID) {
Intercom.appID = appID;
}
public static void setToken(String token) {
authKeyType = AuthKeyType.TOKEN;
Intercom.token = token;
}
public static String getApiKey() {
return Intercom.apiKey;
}
public static void setApiKey(String apiKey) {
authKeyType = AuthKeyType.API_KEY;
Intercom.apiKey = apiKey;
}
public static URI getApiBaseURI() {
return Intercom.apiBaseURI;
}
public static void setApiBaseURI(URI apiBaseURI) {
Intercom.apiBaseURI = apiBaseURI;
}
static AuthKeyType getAuthKeyType() {
return authKeyType;
}
public static String getToken() {
return token;
}
}
package performa.intercom.resources;
public class IntercomException extends RuntimeException {
private static final long serialVersionUID = -2723350106062183796L;
private ErrorCollection errorCollection;
@SuppressWarnings("WeakerAccess")
public IntercomException(String message) {
super(message);
}
public IntercomException(String message, Throwable cause) {
super(message, cause);
}
public IntercomException(ErrorCollection errorCollection) {
this(getMessage(errorCollection));
this.errorCollection = errorCollection;
}
public static String getMessage(ErrorCollection errorCollection) {
String message = "Could not read error message from server";
if(errorCollection!=null
&& errorCollection.getErrors() != null
&& errorCollection.getErrors().size() > 0
&& errorCollection.getErrors().get(0) != null
&& errorCollection.getErrors().get(0).getMessage() != null){
message = errorCollection.getErrors().get(0).getMessage();
}
return message;
}
@SuppressWarnings("WeakerAccess")
public IntercomException(ErrorCollection errorCollection, Throwable cause) {
this(getMessage(errorCollection), cause);
this.errorCollection = errorCollection;
}
public ErrorCollection getErrorCollection() {
return errorCollection;
}
public Error getFirstError() {
return errorCollection.getErrors().get(0);
}
}
package performa.intercom.resources;
public class InvalidException extends IntercomException {
private static final long serialVersionUID = -2111295679006526646L;
public InvalidException(String message) {
super(message);
}
public InvalidException(String message, Throwable cause) {
super(message, cause);
}
public InvalidException(ErrorCollection errorCollection) {
super(errorCollection);
}
public InvalidException(ErrorCollection errorCollection, Throwable cause) {
super(errorCollection, cause);
}
}
package performa.intercom.resources;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JavaType;
import com.google.common.collect.Maps;
import java.net.URI;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@SuppressWarnings("UnusedDeclaration")
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
public class Job extends TypedData {
private static final HashMap<String, String> SENTINEL = Maps.newHashMap();
public static Job find(String id)
throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
return find(id, SENTINEL);
}
public static Job find(String id, Map<String, String> params)
throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
return new HttpClient(
UriBuilder.newBuilder().path("jobs").path(id).query(params).build()
).get(Job.class);
}
public static Job update(Job job)
throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
return DataResource.post(
job,
UriBuilder.newBuilder().path("jobs").path(job.getID()).build(),
Job.class);
}
static <T extends TypedData> Job submit(List<JobItem<T>> items, List<String> bulkPaths)
throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
return submit(items, null, bulkPaths);
}
static <T extends TypedData> Job submit(List<JobItem<T>> items, Job job, List<String> bulkPaths)
throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
return DataResource.create(new JobItemRequest<T>(items, job), bulkPaths, Job.class);
}
static <T extends TypedData> JobItemCollection<T> listJobErrorFeed(String jobID, Class<T> c)
throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
final URI feedURI = UriBuilder.newBuilder()
.path("jobs")
.path(jobID)
.path("error")
.build();
final HttpClient resource = new HttpClient(feedURI);
final TypeReference<JobItemCollection<T>> typeReference =
new TypeReference<JobItemCollection<T>>() {
};
final JavaType type = MapperSupport
.objectMapper()
.getTypeFactory()
.constructParametricType(JobItemCollection.class, c);
return resource.get(type);
}
@JsonProperty("type")
private final String type = "job";
@JsonProperty("id")
private String id;
@JsonProperty("app_id")
private String appID;
@JsonProperty("created_at")
private long createdAt;
@JsonProperty("updated_at")
private long updatedAt;
@JsonProperty("completed_at")
private long completedAt;
@JsonProperty("closing_at")
private long closingAt;
@JsonProperty("name")
private String name;
@JsonProperty("state")
private String state;
@JsonProperty("tasks")
private List<JobTask> tasks;
@JsonProperty("links")
private Map<String, URI> links;
public Job() {
}
public String getType() {
return type;
}
public String getID() {
return id;
}
public Job setID(String id) {
this.id = id;
return this;
}
public long getCreatedAt() {
return createdAt;
}
public long getUpdatedAt() {
return updatedAt;
}
public long getCompletedAt() {
return completedAt;
}
public String getName() {
return name;
}
public Job setName(String name) {
this.name = name;
return this;
}
public String getState() {
return state;
}
public String getAppID() {
return appID;
}
public Map<String, URI> getLinks() {
return links;
}
public long getClosingAt() {
return closingAt;
}
public Job setClosingAt(long closingAt) {
this.closingAt = closingAt;
return this;
}
public List<JobTask> getTasks() {
return tasks;
}
@Override
public String toString() {
return "Job{" +
"type='" + type + '\'' +
", id='" + id + '\'' +
", appID='" + appID + '\'' +
", createdAt=" + createdAt +
", updatedAt=" + updatedAt +
", completedAt=" + completedAt +
", name='" + name + '\'' +
", state='" + state + '\'' +
", links=" + links +
"} " + super.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Job job = (Job) o;
if (createdAt != job.createdAt) return false;
if (updatedAt != job.updatedAt) return false;
if (completedAt != job.completedAt) return false;
//noinspection ConstantConditions
if (type != null ? !type.equals(job.type) : job.type != null) return false;
if (id != null ? !id.equals(job.id) : job.id != null) return false;
if (appID != null ? !appID.equals(job.appID) : job.appID != null) return false;
if (name != null ? !name.equals(job.name) : job.name != null) return false;
//noinspection SimplifiableIfStatement
if (state != null ? !state.equals(job.state) : job.state != null) return false;
return !(links != null ? !links.equals(job.links) : job.links != null);
}
@Override
public int hashCode() {
@SuppressWarnings("ConstantConditions") int result = type != null ? type.hashCode() : 0;
result = 31 * result + (id != null ? id.hashCode() : 0);
result = 31 * result + (appID != null ? appID.hashCode() : 0);
result = 31 * result + (int) (createdAt ^ (createdAt >>> 32));
result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32));
result = 31 * result + (int) (completedAt ^ (completedAt >>> 32));
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (state != null ? state.hashCode() : 0);
result = 31 * result + (links != null ? links.hashCode() : 0);
return result;
}
}
package performa.intercom.resources;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
@SuppressWarnings("UnusedDeclaration")
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
public class JobItem<T extends TypedData> extends TypedData {
@JsonProperty("type")
private final String type = "job_item";
@JsonProperty("id")
private String id;
@JsonProperty("updated_at")
private long updatedAt;
@JsonProperty("method")
private String method;
@JsonProperty("data_type")
private String dataType;
@JsonProperty("error")
private Error error;
@JsonProperty("data")
private T data;
public JobItem() {
}
public JobItem(String method, T data) {
this(method, data, null);
}
JobItem(String method, T data, String dataType) {
Conditions.checkNotNull(method, "item method must be supplied");
Conditions.checkNotNull(data, "item data must be supplied");
this.method = method;
this.data = data;
this.dataType = dataType;
if (dataType == null) {
this.dataType = data.getType();
}
Conditions.checkNotNull(data, "item dataType must be supplied");
}
public String getType() {
return type;
}
public String getID() {
return id;
}
public long getUpdatedAt() {
return updatedAt;
}
public String getMethod() {
return method;
}
public JobItem<T> setMethod(String method) {
this.method = method;
return this;
}
public Error getError() {
return error;
}
public T getData() {
return data;
}
public JobItem<T> setData(T data) {
this.data = data;
return this;
}
public String getDataType() {
return dataType;
}
@Override
public String toString() {
return "JobItem{" +
"type='" + type + '\'' +
", id='" + id + '\'' +
", updatedAt=" + updatedAt +
", method='" + method + '\'' +
", dataType='" + dataType + '\'' +
", error=" + error +
", data=" + data +
"} " + super.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
JobItem<?> jobItem = (JobItem<?>) o;
if (updatedAt != jobItem.updatedAt) return false;
//noinspection ConstantConditions
if (type != null ? !type.equals(jobItem.type) : jobItem.type != null) return false;
if (id != null ? !id.equals(jobItem.id) : jobItem.id != null) return false;
if (method != null ? !method.equals(jobItem.method) : jobItem.method != null) return false;
if (dataType != null ? !dataType.equals(jobItem.dataType) : jobItem.dataType != null) return false;
//noinspection SimplifiableIfStatement
if (error != null ? !error.equals(jobItem.error) : jobItem.error != null) return false;
return !(data != null ? !data.equals(jobItem.data) : jobItem.data != null);
}
@Override
public int hashCode() {
@SuppressWarnings("ConstantConditions") int result = type != null ? type.hashCode() : 0;
result = 31 * result + (id != null ? id.hashCode() : 0);
result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32));
result = 31 * result + (method != null ? method.hashCode() : 0);
result = 31 * result + (dataType != null ? dataType.hashCode() : 0);
result = 31 * result + (error != null ? error.hashCode() : 0);
result = 31 * result + (data != null ? data.hashCode() : 0);
return result;
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
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