Thursday, 10 November 2011

ervice Invocation Adapters

03-Service Invocation Adapters

SCA – Service Component Architecture

to be written –

File Adapter

Lets extend the use case where the successfully approved candidates data will be written into DB , those whose applications are rejected would be written into file system . Some of the out of box adapters such as file and database adapter will be used for this purpose
Lets Open composite.xml drag n drop database adapter on the composite ,

Give the name as “Rejected Applications”

Select File Write Operation

/tmp is the output folder , %SEQ% is auto generated sequence id appended to file name

Select the XSD (Admission Process XSD )
Save the Composite . Open the BPM Process , drag n drop the Service component next Is Accepted as shown below, In the Implementation select the File Adapter that we just defined,
You would need to do Data Association to Student Application Data Object,

DataBase Adapter

Similarly to above steps open composite and drag n drop DB Adapter, Establish DB Connection if not already available
please use the below schema to create table after logging in as sys
---------------------------------------------------
login as sys
CREATE USER university IDENTIFIED BY welcome1;
GRANT resource,  connect   to university;
----
login as university
--Step 1-----------------------------
CREATE SEQUENCE "UNIVERSITY"."STUDENTSEQ" MINVALUE 1
MAXVALUE 100000 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE ;
--Step 2----------------------------
CREATE TABLE "UNIVERSITY"."APPLICATIONS"
  (
    "ID"              NUMBER NOT NULL ENABLE,
    "FISTNAME"        VARCHAR2(20 BYTE),
    "LASTNAME"        VARCHAR2(20 BYTE),
    "AGE"             NUMBER,
    "MARKSPERCENT"    NUMBER,
    "RESERVATION"     VARCHAR2(20 BYTE),
    "ANNUALINCOME"    VARCHAR2(20 BYTE),
    "ADMISSIONSTATUS" VARCHAR2(20 BYTE),
    CONSTRAINT "APPLICATIONS_PK" PRIMARY KEY ("ID") USING INDEX
    PCTFREE 10 INITRANS 2 MAXTRANS 255 NOCOMPRESS LOGGING
   TABLESPACE "USERS" ENABLE
  )
--Step 3---------------------------------
CREATE OR REPLACE TRIGGER  "ASSIGN_APPL_ID" BEFORE INSERT ON applications
FOR EACH ROW
BEGIN
 IF :NEW.ID IS NULL OR :NEW.ID < 0 THEN
   SELECT STUDENTSEQ.NEXTVAL
     INTO :NEW.ID
     FROM DUAL;
   END IF;
END;

Note down JNDI name eis/DB/university

Perform Insert Operation

Import Applications table from University Schema


ID is Auto generated based on Schema , rest of the parameters are part of payload from BPM User Initiator Task

Ensure that STUDENTSEQ is selected

Customize Adapter Service by selecting Module name as Data and Name as Selected Applications

Save all,
Now open BPM Process, drag n drop service component after Admin Approval task, select service implementation as the DB Service that we just defined
we would need xml transformation to send input payload into database.

Save All, so thats it we are all set to deploy and run the process
Summary : Student jcooper enters his student application , based on business rules if his percentage is greater than 70% this application is accepted , needs to be approved by Admin officer jstein, after approval the data is written into Database
Alternative flow, if the percentage is less than 70, the student application is rejected by the business rule and his data is written into file system , and his data is stored at /tmp location

No comments:

Post a Comment