Tuesday, July 26, 2011

Creating a ViewDef Programmatically

Make sure you have an adf-config.xml entry as below, where the ViewDef XML file will be persisted in MDS.

          <mds:namespace metadata-store-usage="globalStore-by-adfconfigfilter"
path="/sessiondef"/>

<mds:metadata-store-usage default-cust-store="true"
deploy-target="true"
id="globalStore-by-adfconfigfilter">
<mds:metadata-store class-name="oracle.mds.persistence.stores.db.DBMetadataStore">
<mds:property value="mds-ApplicationMDSDB"
name="repository-name"/>
<mds:property value="FAGlobal" name="partition-name"/>
<mds:property value="jdbc/mds/mds-ApplicationMDSDBDS"
name="jndi-datasource"/>
</mds:metadata-store>
</mds:metadata-store-usage>



Java Code
    public String writeSessionDefViewDefintion(){
String PACKAGE_NAME = "oracle.apps.atk.ess";
String voName = "MyViewName";
String viewDefFullName = "sessiondef."+PACKAGE_NAME+"."+voName+"MyViewDef";

ViewDefImpl viewDef = new ViewDefImpl(ViewDefImpl.DEF_SCOPE_SESSION,
voName + "MyViewDef");
viewDef.setFullName(viewDef.getBasePackage() + "." + PACKAGE_NAME +
"." + viewDef.getName());*/

AttributeDefImpl attrDef = viewDef.addViewAttribute("id", null, java.sql.Date.class);

Calendar cal = Calendar.getInstance();

// set Date portion to January 1, 1970
cal.set(cal.YEAR, 2011);
cal.set(cal.MONTH, cal.JULY);
cal.set(cal.DATE, 21);

cal.set(cal.HOUR_OF_DAY, 0);
cal.set(cal.MINUTE, 0);
cal.set(cal.SECOND, 0);
cal.set(cal.MILLISECOND, 0);

java.sql.Date defaultDate = new java.sql.Date(cal.getTime().getTime());
attrDef.setDefaultValue(defaultDate);
attrDef.setProperty(AttributeDefImpl.FMT_FORMAT,"MM-dd-yyyy");
attrDef.setProperty(AttributeDefImpl.FMT_FORMATTER,"oracle.jbo.format.DefaultDateFormatter");


// viewDef.setFullSql(true);
viewDef.resolveDefObject();
viewDef.registerDefObject();
viewDef.writeXMLContents();
viewDef.saveXMLContents();
viewDef.setDirty(true);
String viewInstanceName ="MyViewName" + "MyViewDef";
ViewObject dynamicVO =
this.findViewObject(viewInstanceName);

if (dynamicVO != null) {
dynamicVO.remove();
}
dynamicVO = createViewObject(viewInstanceName, viewDefFullName);
String VOName = dynamicVO.getDefFullName();
System.out.println("###VOName="+VOName);
this.setEssParamVOName(VOName);
return VOName;
}

3 comments:

Anonymous said...

order generic cialis generic cialis cialis achat vente cialis cialis comprare cialis cialis cialis vademecum

Anonymous said...

http://cialisnopreascriptionmg.net/ cialis no preascription
http://achatcialisgenerique20mg.net/ cialis sans ordonnance
http://acquistocialisgenerico20mg.net/ cialis online
http://comprarcialisgenerico20mg.net/ cialis comprar

Anonymous said...

http://acheterviagragnerique1.net/ vente viagra
http://comprarviagragenerico1.net/ comprar viagra
http://acquistareviagragenerico1.net/ acquistare viagra
http://kaufenvaigragenerika1.net/ viagra