Deploy Custom ADF Application to WebCenter Spaces

Requirement- How to deploy custom ADF task flow to Webcenter spaces

Solutions-You can extend or alter the look and feel and functionality of Oracle WebCenter Spaces task flows using the Oracle JDeveloper Customization Developer role. If you want to build custom task flow application to spaces.If you want 100% customization then you can use custom task flow.see this Portal vs Spaces. When you want to deploy 100% task flow, its bit trickt.Please follow the steps

Steps-

ADF application with custom task flow-

-> Create a new deployment profile (“ADF Library JAR file”) for the View Controller project
-> Delete the existing WAR deployment profile from View Controller -> Project Properties
-> Deploy the View Controller to ADF Library JAR (Right Click on ViewController -> Deploy)
-> Note the location of the JAR file

Create a wrapper project which will be deployed as WAR file and will include the taskflow JAR file

-> Create a new Generic Project
-> Create a WAR deployment Profile
-> Add task flow JAR file to WAR deployment.
-> Right click on the new project -> Project Properties
-> Select library and classpath
. Click ‘Add JAR/directory’
. Add the JAR created in step (4)
-> Edit web.xml for the wrapper project and remove all entries
. Note: FAILURE to do this will result in errors
-> Deploy the Wrapper project to Webcenter spaces (Right Click wrapper project -> Deploy)
. Create connection to Server
. Select WC_Spaces Managed Server
. Ensure to select radio button “Deploy as shared library”
. After Deployment, Ensure Library is displayed by logging into the WLS Console (Admin server)
Extend Spaces and reference the library that contains the custom task flow
1. Download and install Oracle JDeveloper WebCenter Framework and Services Design Time Extensions:
. In JDeveloper, select Help > Check for Updates.
. Click Next, and then Next again to display all available updates.
. Use the search field to filter the list, for example, enter ‘webcenter framework’.
. Select WebCenter Framework and Services Design Time.
. Click Finish.
2. Download the WebCenter Spaces development ZIP file (DesignWebCenterSpaces_ps4.zip) from Oracle Technology Network:
http://download.oracle.com/otndocs/tech/webcenter/files/DesignWebCenterSpaces_ps4.zip
3. Copy WebCenter’s WLST (WebLogic Scripting Tool) commands to the Oracle home directory where JDeveloper is installed:
. Navigate to \copy_to_common
. Make a copy of the common directory.
. The common directory is located under \copy_to_common.
. Navigate to: \oracle_common
. Copy the content of the common directory here.
. Copy new version of oracle.webcenter.portal.jar to the Oracle JDeveloper extensions directory:
a. Navigate to \copy_to_jdev_ext
b. Make a copy of oracle.webcenter.portal.jar.
c. The oracle.webcenter.portal.jar file is located under
\copy_to_jdev_ext.
d. Navigate to: \jdeveloper\jdev\extensions\
e. Copy the oracle.webcenter.portal.jar file here.
4. Restart JDeveloper if it is open.
5. Edit weblogic.xml and add your library
6. Modify the config.properties files

Before you can build the shared library list and deploy extend.spaces.webapp.war to the WebCenter Spaces managed server, you must provide some information about your environment and your WebCenter Spaces installation in the configuration file config.properties

. To set build and deployment properties for the extend.spaces.webapp shared library
. Open DesignWebCenterSpaces.jws.
. Expand the WebCenterSpacesExtensionLibrary project.
. Open config.properties.
. Enter information about your JDeveloper environment and WebCenter Spaces installation, as shown in
. The config.properties file describes each property and offers examples. The defaults provided are only samples and must be replaced with your own, installation-specific values.
7. Save your updates to config.properties
8. Select WebCenterSpacesExtensionLibrary project and deploy to WC_Spaces using ANT
. Clean stage
. Deploy-shared-lib
. After Deployment, Ensure Library is displayed in WLS Console

Register the taskflow in Resource Catalog
1. Login to Webcenter spaces
2. Click on ‘Administration’
3. Create a new catalog and copy it from the default catalog
4. Select the newly created catalog and click on ‘Edit’ -> ‘Edit’
5. In the ‘Edit’ popup, select Add -> Add from library
6. In the search box, enter the name of your taskflow
7. Select your taskflow and give it a ‘Name’ and click ‘Add’. This adds the taskflow to the resource catalog
8. Select the newly created catalog and click Edit -> show
9. Click on ‘Configuratiions’ tab
10. Change the ‘Resource Catalog for Home spaces’ to the newly created catalog and click ‘Apply’
11. Now go back to webcenter spaces and to test the newly created taskflow:
. Create a new page
. Click on ‘Add Content’
. Select the taskflow from the catalog and click ‘Add’. The taskflow should
appear on the page
. Click ‘Save’ and ‘Close’

Make the most of Pmd, Findbugs and CheckStyle result

Many Java static analysis tools exist right there, each one focus on a specific area and has its advantages, we can enumerate:
Pmd which is a static rule-set based Java source code analyzer that identifies potential problems like:
1. Possible bugs—Empty try/catch/finally/switch blocks.
2. Dead code—Unused local variables, parameters and private methods.
3. Empty if/while statements.
4. Overcomplicated expressions—Unnecessary if statements, for loops that could be while loops.
5. Suboptimal code—Wasteful String/StringBuffer usage.

FindBugs which looks for bugs in Java code. It uses static analysis to identify hundreds of different potential types of errors in Java programs.

Checkstyle defines a set of available modules, each of which provides rules checking with a configurable level of strictness (mandatory, optional…). Each rule can raise notifications, warnings, and errors.

Many ways exist to exploit the results of these tools:

XML format: XML files could be generated from each of these tools, and it can be used to create an HTML report or used by another tool to exploit the analysis result.
HTML format: HTML report is the prefered way to generate reports and share them between the team, and you can create your custom report by using an xsl stylesheet.
IDE Plugins: almost all known IDE provides plugins for these tools, which gives the possibility to discover all violations from the source code.

One of the problems with code quality tools is that they tend to overwhelm developers with problems that aren’t really problems — that is, false positives. When false positives occur, developers learn to ignore the output of the tool or abandon it altogether.
And to exploit better their result, it’s better to have a way to focus only on what we want and gives to developers a useful view. In this post we will discover another interesting way to exploit better the result of all known java static analysis tools, and query them like a database.

JArchitect and CQLinq –

JArchitect is another static analysis tool which complements the other tools, it uses a code query langage based on Linq ( CQLinq) to query the code base like a database.
Until JArchitect 3 you can query only analysis data extracted from JArchitect, however the V4 gives the possibility to import the analysis result from many other static analysis tools and query them with CQLinq.
Let’s take as example the source code of the PDT core (the Php plugin for eclipse). and discover how we can exploit the analysis result of these tools from JArchitect.
To begin here are the steps to follows before requesting the analysis result:
Step1:
Analyse the project with PMD, CPD, FindBugs and CheckStyle. And generate the XML files containing the result.
Step2:
Analyze the project with JArchitect.
Step3:
Import all the xml files into JArchitect from the menu “Plugins->Import Plugins Result Files”
JArchitect provides by default many useful queries to request these tools, and all these queries could be customized easily.

Let’s discover some CQLinq queries:

Get all issues:
The request to get all issues is very simple, however as you can see it’s not very interesting, indeed it’s a challenge to exploit a result with 232 725 issues.

To exploit better the result of these tools we can filter it with CQLinq and focus only on what we want.
Request by tool
We can modify the first request and add a criteria about the tool concerned.

Request by ruleset
We can also filter by issue ruleset :

Request by priority
We can also filter by priority:

Most recurrent issues
It’s interesting to know which issues are the most reported by these tools.


Classes having most issues
It’s very interesting to know the classes which contains many violations


As we can observe CheckStyle report thousand of issues and many of them could be ignored.
The previous query is interesting, but it’s not give us exactly the classes with lack of quality, another useful metric to take into account is the NBLinesOfCode, it’s normal that a class with many lines of code contains many issues, for that we can modify the previous request to calculate the ratio between the Issues count and the NBLinesofCode.


What’s very strange in this result is that the ratio of the 8 first classes is more than 200, in this case we have more than 200 issues by code line.
To explain this behavior let’s take a look at some lines of the CompilerAstParser:

The NbLinesOfCode is the number of statements and not the physical lines, and this Class declare many arrays , each one is declared by thousand of physical lines, however each array declaration is considered as one statement.
And as shown before for the most recurrent issues query, the following rule ‘+’ should be on a new line. is violated thousand of times for each array. Maybe it’s better to remove these kind of rules from the CheckStyle configuration file.

Most popular methods having issues

When the static analysis tools report the issues, it’s useful to locate which the prioritary issues to resolve? specially if it concerns bugs.
It’s true that a bug could exist in a specific method, but what interesting to know is how many methods are impacted by the bug, and the popular method are the most used ones and it’s better to resolve them quickly.

Using CQLinq we can combine the result of all these tools and also the result of JArchitect to create more elaborated queries, and add these checks to the build process.

Issues Trend
Having issues in a project is not an exception, we can say that’s normal, however we have to check the quality trend of the project. Indeed it’s a bad indicator if the number of issues grows after changes and evolutions.
JArchitect provides the Trend Monitoring feature to create trend charts. Trend charts are made of trend metrics values logged over time at analysis time. More than 50 trend metrics are available per default and it is easy to create your own trend metrics.
Let’s create a trend metric for the Pmd issues:

And after you can easily create the trend chart to monitor the previous trend metric and add it to the JArchitect dashboard.

With this trend chart we can monitor the evolution of the Pmd issues, and try to understand the reasons when the metric grows over versions.

Customize the JArchitect report
JArchitect make possible to append extra report sections in the HTML report that lists some CQLinq queries.
In the CQLinq Query Explorer panel, a particular CQLinq group reported is bordered with an orange rectangle.

You can also add to the report the Pmd trend chart:

And in the HTML report these added sections are accesible from the menu:

And here’s the page added in the report for the Pmd CQLinq queries:

Conclusion

JArchitect 4 is now open to other static analysis tools, and you can also plug your customized tool easily as descibed here. This way you can use all the JArchitect features to exploit better the result from the known java static analysis tools.

Get the current node of a tree table in Oracle ADF | Techartifact

Requirement- To get the current current node of tree table and get value of that node.

Solution- we will get the rowKeySet of the treetable.The using findNodeByKeyPath method , we will get the selected node.I already posted to get selected row of tree

RowKeySet selectedRows = treeTable.getSelectedRowKeys();
//use EL to access binding (note that you can do this in Java as well)
JUCtrlHierBinding treeTableBinding = (JUCtrlHierBinding) executeValueExpression("#{bindings.<tree binding name>}");  
//get first entry of selected rows (single selection case)
JUCtrlHierNodeBinding node =  treeTableBinding .findNodeByKeyPath((List)selectedRows .iterator().next());
... do the work with the node here ...

private Object executeValueExpression(String valueExpression){
      FacesContext fctx = FacesContext.getCurrentInstance();
      ELContext elctx = fctx.getELContext();
      Application app = fctx.getApplication();
      ExpressionFactory exprFactory = app.getExpressionFactory();
      ValueExpression valueExpr = exprFactory.createValueExpression(
                                elctx,
                                valueExpression,
                                Object.class);
       return valueExpr.getValue(elctx);
      }

Happy coding with Vinay Kumar in Techartifact