What kind of data are you trying to retrieve/display from Teradata?
The reason I ask is that we may already be logging this data into postgresql with our current collector(s). If we are, you will already have the data you are looking for. Is it possible to provide more specifically what you are looking for in terms of metrics? If not, there's another approach you can probably take, but one thing at a time...
I was referring to the display information you were talking about in the quoted post with regards to my inquiry about "metrics".
I would assume you are using the Portlet Development Kit (PDK), so the following would be the best solution:
1. Take a look the API documentation (should be in tdpdk-xx.xx.xx.xx\doc\api). Find the documentation for the package com.teradata.dcs.data.model. All the classes in that package represent the metrics that are collected by the DCS and logged to PostgreSQL currently. Look through the classes and find the metrics (ie. the information you want to display) and take note of what class they are associated with.
2. Each class should have a corresponding Data Access Object (DAO) class that resides under com.teradata.data.dcs.dao. The DAO is what you use to retrieve the data from PostgreSQL.
3. To use a DAO, you need to create a bean in the dataSourceiBatis.xml file that references an implementation of that DAO. For example, if you wanted to get QueryLog data, you would create your bean as follows:
bean id="queryCountDAO" class=" com.teradata.dcs.data.dao.ibatis.QueryCountDAOiBatis" >
description>DAO for accessing Query Count table
property name="sqlMapClient" ref="dcsSqlMapClient" />
/bean>
The class attribute references the actual implementation of the DAO. DAO implementations reside under the package com.teradata.dcs.data.dao.ibatis. The property tag injects a sql map which allows you to retrieve data from PostgreSQL that was collected by the DCS. The sql map uses a datasource (ie. a connection) that is connected to PostgreSQL.
4. Now you inject that bean into your manager implementation, which is defined in applicationContext.xml. So you would do the following:
bean id="myManager" class=" com.teradata.portlets.myPortletName.myManagerImpl">
description>The business delegate for this application
property name="myJavaQueryCountDAO" ref="queryCountDAO"/>
/bean>
You just need a corresponding java setter for the myJavaQueryCountDAO variable of type QueryCountDAO. Now you can access the data from PostgreSQL.
The DAOs give you indirect access to PostgreSQL. If you have a working DCS instance, which it sounds like your portal does based upon your comments above, then you will be able to retrieve any/all of the data you see displayed by the viewpoint portlets. You don't need a URL/Username/Password as you can see.
NOTE: I have taken out the less than from the .xml examples because it wouldn't post the .xml if i left it there.
The forum software really hacked up my previous post badly. It took out words and examples before posting it for some reason. I have edited and it should be good now. Let me know if you still have more questions.
Yes, you need to add a couple of things to your manager class. You need:
1. A reference to your injected DAO object:
private QueryCountDAO myJavaQueryCountDAO;
2. A setter for the DAO:
public void setMyJavaQueryCountDAO(QueryCountDAO myJavaQueryCountDAO)
{
this.myJavaQueryCountDAO = myJavaQueryCountDAO;
}
3. A manager function that retrieves the data:
public List getMyQueryCountData(int systemId, Timestamp startTime, Timestamp endTime)
{
return myJavaQueryCountDAO.getQueryCountSumOverTime(systemId, startTime, endTime);
}
4. Some function that creates a collection of widget model objects for your desired widget type from the data your have retrieved from the DAO. Widget model objects are under the package com.teradata.tags.widgets.model.
I would highly recommend you go through the skewed sessions portlet tutorial as this will give you knowledge of all the basic concepts. Let me know if you have more questions.
You probably need to add the imports for the missing symbols. Ie.
import com.teradata.dcs.data.dao.QueryCount;
import java.sql.Timestamp;
In regards to your first inquiry on this page. Since you are getting an error with SkewedSessions, take a look at the stack trace that is generated when you add the portlet to the page. It will give you loads of information about the issue(s) you are having. This will answer your "Wonder what the problem is..." statement. ;^)
Take a look at the Widgetopia portlet in the PDK for examples. The Widgetopia portlet has examples of how to use all the different widgets that are available.
It shows you exactly what you need to know to populate each widget with meaningful data. It is the simplest available example you will find. The WidgetopiaManagerImpl.java creates all of the models with data. Each model is then put into the view in the WidgetopiaViewController.java. Each model is then passed to its proper tag in the summary.jsp. I would highly recommend you got back and understand this portlet in its entirety if you want to learn widgets.
"I'll probably do that but all I learned from it was how to create those Widgets in the sample. I've successfully created all of them but I'm trying to display information from our database. I don't know if I missed it but it doesn't explain that. "
On the first page of this topic, I talked about the API documentation (my third post) and explained how "All the classes in that package represent the metrics that are collected by the DCS and logged to PostgreSQL currently". This is where the two pieces fit together. All the data collected from Teradata is logged to PostgreSQL. To retrieve the data, you use the provided DAO function(s) (see my third post for the package locations), which usually return a java.util.List of model objects where each model object contains the data for a single row from PostgreSQL. Now you have the data you need to populate a widget with meaningful data. Now you take that data you have received from the DAO (your List of model objects), create the object for the widget type that you wish to use and populate the widget object with the data you have received from the DAO. This is exactly what the Skewed Sessions portlet does. The getCurrentSkewedSessions() function in SkewedSessionsManagerImpl.java gets the data from the DAO and the summary() function in SkewedSessionsViewController creates a SkewedSessionsTableWidget object that contains the data. The SkewedSessionsTableWidget object extends the TableWidget class and defines the data that the table widget will display.
"Is there a way to edit the DynamicQuery portlet to just run a certain SQL statement each time without having to type it?"
The DynamicQuery portlet already does this for you. It saves the last query, system and username that you have run as a portlet preference.
In the executeQuery() function of the DynamicQueryDataserverController.java, the query, system and username are saved to preferences:
// Set the system name in the preferences object
preferences.setSystemName(manager.getSystem(systemId) .getName());
// Set the username in the preferences object
preferences.setUsername(username);
// Set the SQL query in the preferences object
preferences.setSqlQuery(sql);
// Save the last query
ctx.savePreferences("DynamicQuery", preferences);
In the summary() function of the DynamicQueryViewController.java, the preferences are loaded:
// Retrieve the previous query data
final DynamicQueryPreferences preferences = (DynamicQueryPreferences) ctx.loadPreferences(
"DynamicQuery", new DynamicQueryPreferences());
// Add the data for the previous query
ctx.addViewObject("preferences", preferences);
"I understand what you're saying but I'm trying to figure out how to do this. Your first post indicated how to put the QueryCountDAO into the two .xml files but I wasn't even sure if that same method could be used for every DAO I use. How do you figure out which property name and reference to use?
I also know that the DAOs also have to be implemented in Impl file as well. I followed the skewed sessions and it doesn't completely work. Will following the SkewedSessions sample and using the same method be enough to use any type of DAO?"
Take a look at the "What is Dependency Injection" article bundled with the PDK for a brief overview of what is going on here. My earlier post with the QueryCountDAO in the .xml files is essentially a generic template for what you need to be doing for any DAO you will need. You can cut and paste and then change the id, class and any properties being injected and you will have a working bean.
The property tag injects a java object into the configured bean at runtime; in the earlier example, the java object is the DAO and the configured bean is the manager. The "name" attribute is that name that corresponds to the variable you are trying to set in the manager. It is case sensitive, so this must be the same as the manager variable name. The "ref" attribute is a reference to the DAO bean you have declared in your dataSourceiBatis.xml file. The value of the "ref" attribute must exactly match the "id" attribute of the bean that you are trying to inject into your Java Bean.
Yes. You can use the same method in SkewedSessions for any type of DAO. You just need to figure out what DAO(s) you will be using to retrieve data and what widget(s) you will be using to display the data. The SkewedSessions example is definitely a good template for almost anything you will need to do.
You can display any type of data with any type of widget. A widget is simply a tool to meaningfully display otherwise boring and/or confusing data. Deciding how to display meaningful data is the decision of the programmer and/or portlet designer.
These are very elementary compilation errors. There are symbols in your code that the compiler cannot find. You need to go through all the errors and figure out what symbols the compiler is complaining about. For example, this line:
lastPercentInState.put(preferences.getSystem(), statistics.getPercentInState());
lastPercentInState is a variable that is never declared.
You will need to provide more information:
1. What database are you referring to? The Teradata database, the DCS cache database, a third-party database?
2. What information do you want to display?
You have yourself confused here.
The DynamicQuery portlet displays query result sets from queries run directly against the Teradata database. It connects directly to the Teradata database and runs the query you type in, displaying the results of the query.
The DCS cache database is where DCS data collectors persist the data they have collected from the Teradata database.
I have given you a basic template to retrieve and display data from the DCS cache database on earlier pages of this thread. It is virtually a cut and paste template that you can reuse for retrieving all types of data. To retrieve data from the DCS cache database, you use the DAOs that have been supplied to you. These DAOs return a List of Model objects with the data. The key to understanding the data is the javadocs. The javadocs for the DAOs and the Models contain the documentation that describes the data associated with them.
1. Take a look the API documentation (should be in tdpdk-xx.xx.xx.xx\doc\api). Find the documentation for the package com.teradata.dcs.data.model. All the classes in that package represent the metrics that are collected by the DCS and logged to PostgreSQL currently. Look through the classes and find the metrics (ie. the information you want to display) and take note of what class they are associated with.
2. Each class should have a corresponding Data Access Object (DAO) class that resides under com.teradata.data.dcs.dao. The DAO is what you use to retrieve the data from PostgreSQL.
I cannot give you specific help beyond that without you giving me more specific information related to the type of data you are trying to retrieve and display. Different types of information are associated with different DAOs, Models, etc.
You are trying to pass in a List of Integer objects to the getCurrentSystemHealth(int) function. This function takes a single system id int (or Integer) only:
public List getCurrentActiveSystemHealth(SystemHealthPreferences preferences)
{
Integer id = getSystemId(preferences.getSystem());
if (id != null)
{
// fetch the data
result = systemHealthDAO.getCurrentSystemHealth(id);
}
return result;
}
Sure, you will need that as well:
public List getCurrentActiveSystemHealth(SystemHealthPreferences preferences)
{
SystemHealth result;
Integer id = getSystemId(preferences.getSystem());
if (id != null)
{
// fetch the data
result = systemHealthDAO.getCurrentSystemHealth(id);
}
return result;
}
Change the function header to return a SystemHealth object type instead of a List Object.
On a side note, I highly recommend you install/use an IDE such as Eclipse, ItelliJ, or NetBeans to help you solve some of these compilation errors. A good IDE will highlight these simple compilation errors and give you tips to help you resolve them.


Hi, I'm currently trying to create a graph widget which displays the data from the teradata database. I'm thinking that in order for the data to be populated to my widget then I need a postgres username and password and the jdbcUrl. These changes are supposed to go into the content.xml and server.xml file but the problem is trying to figure out what is the username, password and Url? Will that be all the change that is needed to get information to be displayed on a widget?
If possible, It would make it easier for me if anyone had a same of a widget being populated with some simple data. Thanks.