Creating Business Service and Service Program in ORMB / CC&B / Oracle Utilities

Creating Business Service and Service Programin ORMB / CC&B / Oracle Utilities

In Previous article, we have seen that how to create the Data Area and benefits of using Data Area. This article will focus on creating the Business Service and Service Program in CC&B.

First we have to create the Business Service in application then we have to code it in JAVA and deploy the updated “cm.jar“ file on server.

Go to “Admin | S | Service Program +“ and enter the Service name, Description and select the “Java Based Service” as Service Type.  In this example my service name is “PERSER“.

Now go to “Admin | B | Business Service +“ and enter the Business Service name and select the previously create service “PERSER“ for Service Name using look up. In this case the Business Service Name is “CM_PERSER“.
Now go to the “Schema” and add following code and click on Save.

<schema>
    <includeDA name="PersonDataA"/>
</schema>

You can see one benefit of having “Data Area”. Instead of declaring schema we have used existing data area which we have created earlier.
We are now ready to create the Business Service for “PERSER“ Service Program using Java Code.

Open Eclipse and go to “File | New | Page Service“.

Select Page type as “Query“ and click on Next.

Enter the Program name and Service name as “PERSER“, which we have created earlier. In Module, Click on “Add” and Select “DM” (This is demo module, I normally uses this Module).

It’s time to add the header. As we have already discussed that i want to get the Person name from user. And in DataArea, we have added ENTITY-NAME in header. So in same way, we have to add ENTITY-NAME here also.

So go to “Edit array of Header Fields“ and on “+” button Search for the “ENTITY_NAME” and click on OK. Come back to main service windows and click on “Edit array of Lists“. We want the list of person name which will be the part of body. To include the List in body first we have to declare the List and then add it in the body.
When we click on “Edit array of Lists“, one pop up window will appear on that click on “+”.

Edit Array Eclipse ORMB / CC&B / Oracle Utilities
Edit Array Eclipse ORMB

After clicking on “+”, one new window will open.

Annotation Editor in Eclipse of ORMB / CC&B / Oracle Utilities
Annotation Editor in Eclipse of ORMB

In that provide the Name and Size. In this example I have used name = “PerNameList“ and size = 100. Click on “Edit Data Element“ button of body.
One window will be opened. In that select “Edit Contents“.

Annotation Editor - Edit Content in Eclipse of ORMB / CC&B / Oracle Utilities
Annotation Editor - Edit Content in Eclipse of ORMB

Again window will open in that click on “+” and select “Field”.

Add Child Annotation in Eclipse for ORMB / CC&B / Oracle Utilities
Add Child Annotation in Eclipse for ORMB

One new window will open, enter the “ENTITY_NAME” as “Name”, you can search the Name from search option. Click on Ok / Finish Button until you come to Parent Window shown below.

Page Service in Eclipse of ORMB / CC&B / Oracle Utilities
Page Service in Eclipse of ORMB

Click on Edit “DataElement“ of the Body and click on “Edit Contents“, then click on”+” and List. In List, give the previously created list name which is “PerNameList” and owner is “cm”. And click on Ok / Finish.  Java file will be created, which have following code:

/**
 * @author jitendra zaa
 *
@QueryPage (program = PERSER, service = PERSER,
 *      body = @DataElement (contents = { @ListField (name = PerNameList)
 *                  , @DataField (name = ENTITY_NAME)}),
 *      actions = { "add"
 *            , "change"
 *            , "read"
 *            , "delete"},
 *      header = { @DataField (name = ENTITY_NAME)},
 *      headerFields = { @DataField (name = ENTITY_NAME)},
 *      lists = { @List (name = PerNameList, size = 100,
 *                  body = @DataElement (contents = { @DataField (name = ENTITY_NAME)}))},
 *      modules = { "demo"})
 */
public class PerSer extends PerSer_Gen {

}

As you can see, the entire configuration is added as annotation in Java Program.

Artifcat generator in Eclipse for CC&B / ORMB / Oracle Utilities
Artifcat generator in Eclipse for CC&B

Click on “Generate Artifacts” to generate the supported classes for the “Business Service / Page Service”.
After successful completion add following method in above Java File:

protected DataElement read(PageHeader header) throws ApplicationError {
		System.out.println(" ************ In PerSer Read Method ************ ");
		DataElement ret = new DataElement();
		DataElement perData ;
		ItemList perList = new DataElement().newList(STRUCTURE.list_PerNameList.name);

		String entityName = "" ;
		if(header.get("ENTITY_NAME") != null)
		{
			entityName = header.get("ENTITY_NAME").toString();
		}
		System.out.println(" *************** Header Value **************"+entityName);
		/* If value is not coming through header */
		if(entityName.equals("")){
			entityName = "A";
		}
		PreparedStatement stmt = createPreparedStatement("SELECT ENTITY_NAME FROM CI_PER_NAME WHERE ENTITY_NAME LIKE :entityName");
		stmt.bindString("entityName", entityName, "ENTITY_NAME");
		System.out.println("******** SQL Statement : "+ stmt.toString()+" ************ ");
		List resultSetList = stmt.list();

		if (resultSetList != null && !resultSetList.isEmpty()) {
			for (SQLResultRow eResult : resultSetList) {
				perData = perList.newDataElement();
				if (eResult.getString("ENTITY_NAME") != null
						&& !eResult.getString("ENTITY_NAME").trim().equals("")) {
					perData.put(STRUCTURE.ENTITY_NAME, eResult.getString("ENTITY_NAME").toString().trim());
					System.out.println("****** Name : **********"+eResult.getString("ENTITY_NAME"));
				}
			}
		}
		ret.addList(perList);
		return ret;
	}

The code style is not as per the standards because, I have used SOP statements instead of Loggers. However above example is just getting clear that how to create the “Business Service” through Java. Now click on “Deploy” button to generate the new “cm.jar” and deploy.

Deploy cm.jar in Eclipse for ORMB / CC&B / Oracle Utilities
Deploy cm.jar in Eclipse for ORMB

After successfully completion of the deployment, restart the application.

Related posts

  • sriram

    Wonderful article. can u share some more on cc&b and ormb?? Thanks again for sharing this.

  • Akriti Dubey

    Great article..Very helpful for beginners like me. Thanks.