Commit a9d0d9db by Chamath

MarkAsRead web service added.

parent 23ae6698
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<column name="is_read" type="Boolean" nullable="true"/> <column name="is_read" type="Boolean" nullable="true"/>
<column name="sent_by" type="Long" length="11" nullable="true"/> <column name="sent_by" type="Long" length="11" nullable="true"/>
<column name="work_flow_message" type="Long" length="11" nullable="true"/> <column name="work_flow_message" type="Long" length="11" nullable="true"/>
<column name="job_application_id" type="Long" length="11" nullable="true"/> <column name="job_application_id" type="Long" length="11" nullable="false"/>
</NODE> </NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_message" indexName="idx_tl_message_job_application_id" isUnique="false"><column name="job_application_id"/></NODE> <NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_message" indexName="idx_tl_message_job_application_id" isUnique="false"><column name="job_application_id"/></NODE>
......
...@@ -13,7 +13,7 @@ CREATE TABLE tl_message ( ...@@ -13,7 +13,7 @@ CREATE TABLE tl_message (
is_read char(1) NULL, is_read char(1) NULL,
sent_by numeric(12) NULL, sent_by numeric(12) NULL,
work_flow_message numeric(12) NULL, work_flow_message numeric(12) NULL,
job_application_id numeric(12) NULL job_application_id numeric(12) NOT NULL
); );
......
...@@ -14,7 +14,7 @@ CREATE TABLE tl_message ( ...@@ -14,7 +14,7 @@ CREATE TABLE tl_message (
is_read char(1) NULL, is_read char(1) NULL,
sent_by number(12) NULL, sent_by number(12) NULL,
work_flow_message number(12) NULL, work_flow_message number(12) NULL,
job_application_id number(12) NULL job_application_id number(12) NOT NULL
); );
......
...@@ -14,7 +14,7 @@ CREATE TABLE tl_message ( ...@@ -14,7 +14,7 @@ CREATE TABLE tl_message (
is_read char(1) NULL, is_read char(1) NULL,
sent_by numeric(12) NULL, sent_by numeric(12) NULL,
work_flow_message numeric(12) NULL, work_flow_message numeric(12) NULL,
job_application_id numeric(12) NULL job_application_id numeric(12) NOT NULL
); );
......
...@@ -184,7 +184,7 @@ public abstract class BaseMessage extends BaseBusinessClass ...@@ -184,7 +184,7 @@ public abstract class BaseMessage extends BaseBusinessClass
metaInfo.put ("backreferenceName", "Messages"); metaInfo.put ("backreferenceName", "Messages");
metaInfo.put ("dbcol", "job_application_id"); metaInfo.put ("dbcol", "job_application_id");
metaInfo.put ("mandatory", "false"); metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "JobApplication"); metaInfo.put ("name", "JobApplication");
metaInfo.put ("type", "JobApplication"); metaInfo.put ("type", "JobApplication");
metaInfo.put (METADATA_DB_TABLENAME, "tl_message"); metaInfo.put (METADATA_DB_TABLENAME, "tl_message");
...@@ -1030,6 +1030,8 @@ public abstract class BaseMessage extends BaseBusinessClass ...@@ -1030,6 +1030,8 @@ public abstract class BaseMessage extends BaseBusinessClass
*/ */
public void setJobApplication (JobApplication newJobApplication) throws StorageException, FieldException public void setJobApplication (JobApplication newJobApplication) throws StorageException, FieldException
{ {
BusinessObjectParser.assertFieldCondition (newJobApplication != null, this, SINGLEREFERENCE_JobApplication, "mandatory");
if (_JobApplication.wouldReferencedChange (newJobApplication)) if (_JobApplication.wouldReferencedChange (newJobApplication))
{ {
assertValid(); assertValid();
...@@ -1453,6 +1455,8 @@ public abstract class BaseMessage extends BaseBusinessClass ...@@ -1453,6 +1455,8 @@ public abstract class BaseMessage extends BaseBusinessClass
super.validate (context); super.validate (context);
context.check (getJobApplicationID() != null, this, SINGLEREFERENCE_JobApplication, "mandatory");
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<SINGLEREFERENCE name="SentBy" type="SecUser" dbcol="sent_by" /> <SINGLEREFERENCE name="SentBy" type="SecUser" dbcol="sent_by" />
<SINGLEREFERENCE name="WorkFlowMessage" type="WorkFlowMessage" dbcol="work_flow_message" /> <SINGLEREFERENCE name="WorkFlowMessage" type="WorkFlowMessage" dbcol="work_flow_message" />
<SINGLEREFERENCE name="JobApplication" type="JobApplication" dbcol="job_application_id" backreferenceName="Messages" mandatory="false"/> <SINGLEREFERENCE name="JobApplication" type="JobApplication" dbcol="job_application_id" backreferenceName="Messages" mandatory="true"/>
</TABLE> </TABLE>
......
package performa.ws;
import java.util.*;
import oneit.appservices.ws.JSONServiceRequest;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.utils.*;
import oneit.utils.parsers.FieldException;
import org.json.*;
import performa.orm.*;
public class MarkAsReadWSFP extends BaseMarkAsReadWSFP
{
private static final long serialVersionUID = 0L;
public static LoggingArea LOG = LoggingArea.createLoggingArea("MarkAsReadWSFPLOG");
// This constructor should not be called
public MarkAsReadWSFP ()
{
// Do not add any code to this, always put it in initialiseNewObject
}
@Override
public void processForm(JSONServiceRequest request, ObjectTransaction objTran, JSONObject result, MultiException exceptions,
Set<BaseBusinessClass> createdBBCs, Set<BaseBusinessClass> updatedBBCs) throws BusinessException, JSONException
{
JobApplication jobApplication = getJobApplication();
try
{
for (Message message : jobApplication.getMessagesSet())
{
message.setIsRead(Boolean.TRUE);
}
}
catch (FieldException ex)
{
LogMgr.log(LOG, LogLevel.BUSINESS1, ex, "Failed to update as Read in MarkAsReadWSFP");
throw new BusinessException("Failed to update as Read");
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='http://www.oneit.com.au/schemas/5.2/BusinessObject.xsd'>
<BUSINESSCLASS name='MarkAsReadWSFP' package='performa.ws' superclass='WebServicesFormProcessor'>
       <IMPORT value="oneit.appservices.ws.services.*"/>
<IMPORT value="performa.orm.*"/>
<TABLE tablePrefix="object" polymorphic="FALSE">
<SINGLEREFERENCE name="JobApplication" type="JobApplication" mandatory="true" />
</TABLE>
</BUSINESSCLASS>
</ROOT>
\ No newline at end of file
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
<NODE name="SaveWebService::Performa"> <NODE name="SaveWebService::Performa">
<Privilege name="performa.orm.MessageTemplate" factory="String" value="*"/> <Privilege name="performa.orm.MessageTemplate" factory="String" value="*"/>
<Privilege name="performa.orm.WorkFlowTemplate" factory="String" value="*"/> <Privilege name="performa.orm.WorkFlowTemplate" factory="String" value="*"/>
<Privilege name="performa.orm.Message" factory="String" value="*"/>
</NODE> </NODE>
<NODE name="JSONServices::Performa"> <NODE name="JSONServices::Performa">
...@@ -90,6 +91,10 @@ ...@@ -90,6 +91,10 @@
<INHERITS nodename="SaveWebService::.*" mandatory="false"/> <INHERITS nodename="SaveWebService::.*" mandatory="false"/>
</NODE> </NODE>
<NODE name="MarkAsRead" factory="Participant" class="oneit.appservices.ws.services.ORMFormProcessorService" fpClass="performa.ws.MarkAsReadWSFP" privilege="*">
<Overview>This service will set all messages to read in given job application</Overview>
</NODE>
<!-- Enum services --> <!-- Enum services -->
<NODE name="ResponseAction" factory="Participant" class="oneit.appservices.ws.services.EnumJSONService" enumClass="performa.orm.types.ResponseAction" privilege="*"/> <NODE name="ResponseAction" factory="Participant" class="oneit.appservices.ws.services.EnumJSONService" enumClass="performa.orm.types.ResponseAction" privilege="*"/>
<NODE name="StageType" factory="Participant" class="oneit.appservices.ws.services.EnumJSONService" enumClass="performa.orm.types.StageType" privilege="*"/> <NODE name="StageType" factory="Participant" class="oneit.appservices.ws.services.EnumJSONService" enumClass="performa.orm.types.StageType" privilege="*"/>
......
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