Widgets

Viewpoint
Enthusiast

Widgets

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.
42 REPLIES
Teradata Employee

Re: Widgets

What kind of data are you trying to retrieve/display from Teradata?
Enthusiast

Re: Widgets

Well, the place I work for wants me to display information for the users like cpu performance, state of system, users online...stuff like that.
Teradata Employee

Re: Widgets

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...
Enthusiast

Re: Widgets

I'm not sure what you mean when you talk about metrics but if there is another method of doing this then I would like to know. We are already receiving data on our tdviewpoint portal but now we are trying to develop a portlet which would be displaying information that is in some existing portlets but it will be displayed using graphs. i.e. CPU performance. I just don't think we have access to that information on the dev kit. For example, I can't get the SkewedSessions tutorial to work because we don't have access to our DCS.

I just wanted to make it clear what I'm trying to do.
Teradata Employee

Re: Widgets

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.
Teradata Employee

Re: Widgets

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.
Enthusiast

Re: Widgets

Thanks. Ok, that made sense so far but bear with me on this because this is the first time i've used Teradata. I'm trying to implement your Query example over here. So after I follow those steps do I only have to add a few lines of code to the Manager and ManagerImpl file for it to display? I also think there might be some changes I will have to make in the summary.jsp file.
Teradata Employee

Re: Widgets

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.
Enthusiast

Re: Widgets

Thanks. I actually went through that tutorial but it bugged me that I couldn't get anything to display. Thats one of the reasons why I figured that maybe I didn't have access to a DCS so I asked for a username and password.