Friday, March 5, 2010

Managing ADF Customizations with MDS

In this simple scenario I am an ISV who needs to deliver different versions of my app to different customers. I also want to give end users the possibility to „personalize“ the application.

A customized application contains a base application and one or more layers
containing customizations. MDS stores the customizations in a metadata repository and retrieves them at runtime to merge the customizations with the base metadata to reveal the customized application. Since the customizations are saved separately from the base, the customizations are upgrade safe; a new patch to base can be applied without breaking customizations. When a customized application is launched, the customization content is applied over the base application.

Seeded customization of an application is the process of taking a generalized
application and making modifications to suit the needs of a particular group, such as a specific industry or site. Seeded customizations exist as part of the deployed application, and endure for the life of a given deployment.






















package oracle.model.cust;

import java.io.IOException;
import java.io.InputStream;

import java.util.Properties;

import oracle.mds.core.MetadataObject;
import oracle.mds.core.RestrictedSession;
import oracle.mds.cust.CacheHint;
import oracle.mds.cust.CustomizationClass;

public class CustCC extends CustomizationClass {
private static final String DEFAULT_LAYER_NAME = "CustSite";
private String mLayerName = DEFAULT_LAYER_NAME;

public CustCC() {
}

public CustCC(String layerName) {
mLayerName = layerName;
}

public CacheHint getCacheHint() {
return CacheHint.ALL_USERS;
}

public String getName() {
return mLayerName;
}

public String[] getValue(RestrictedSession sess, MetadataObject mo) {

// This needs to return the site value at runtime.
// For now, it's always null.
Properties properties = new Properties();
String configuredValue = null;
Class clazz = CustCC.class;
InputStream is = clazz.getResourceAsStream("/customization.properties");
if (is != null){
try {
properties.load(is);
String propValue = properties.getProperty(mLayerName);
if (propValue != null){
configuredValue = propValue;
}
} catch (IOException e) {
e.printStackTrace();
}
}
return new String[] {configuredValue};
}

}















Step 4 - Add the customization class available to the MDS Configuration, by editing the adf-config.xml file.









Step 5 – Create the customization.properties file in the Model project. Ensure it is in the \src directory.



Add the following entries

#Configured values for the default layer values
#CustSite=Cust1
CustSite=Cust2

Step 6 – These “layer” values must also be added to the base CustomizationLayerValues.xml file.



Add the following entries –



Step 7 – In JDeveloper, Switch to customiser role
Tools / Preferences / Roles



View Customization Context



Customising the ADF Model
In this section we will customise the Model for Cust2 and add the emp_email attribute to EO and VO.

Step 1 – Enter Edit mode and select Cust2



Step 2 - In SQLPLUS, add the new column to the table.
alter table myEmps add
(emp_email varchar2(20))


Step 3 – Amend the Model project and add the emp_email attribute to the EO and VO.



This change is saved in a separate xml file, specific for cust2.



Do the same for the VO.



Customizing the UI
In this section we will amend the browseEmps.jspx to include the emp_email attribute for cust2.

Step 1 – open browseEmps.jspx.

The datacontrol now includes the new attribute –









No comments: