Widgets
Teradata Teradata Discussion Forums Teradata.com Discussion Forum
Visit Teradata.com
Home       Guidelines    Member List
Welcome Guest ( Login | Register )
        


This online forum is for user-to-user discussions of Teradata products, and is not an official customer support channel for Teradata. If you require direct assistance, please contact Teradata support.

«««12345»»»

Widgets Expand / Collapse
Author
Message
Posted 6/12/2009 10:02:30 AM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 7/7/2009 9:55:02 AM
Posts: 38, Visits: 147
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.
Post #15774
Posted 6/16/2009 9:27:09 AM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 7/7/2009 9:55:02 AM
Posts: 38, Visits: 147
Is there a way to edit the DynamicQuery portlet to just run a certain SQL statement each time without having to type it?
Post #15811
Posted 6/19/2009 11:33:10 AM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 7/8/2009 5:31:22 PM
Posts: 30, Visits: 55
"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.


Viewpoint Framework Development

Post #15865
Posted 6/19/2009 11:49:46 AM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 7/8/2009 5:31:22 PM
Posts: 30, Visits: 55
"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);


Viewpoint Framework Development

Post #15867
Posted 6/19/2009 12:01:00 PM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 7/7/2009 9:55:02 AM
Posts: 38, Visits: 147
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?
Post #15869
Posted 6/19/2009 12:35:04 PM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 7/8/2009 5:31:22 PM
Posts: 30, Visits: 55
"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.


Viewpoint Framework Development

Post #15870
Posted 6/22/2009 12:49:34 PM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 7/7/2009 9:55:02 AM
Posts: 38, Visits: 147
Yeah, I know DynamicQuery saves your last statement but what I meant was if there was a way to just set all the infomation that is inputted into the code so that whenever the DQ portlet is deployed it just runs it automatically. Would it work if I just replaced "username" and "sql" with an actual username and sql statement?
Post #15881
Posted 6/24/2009 8:59:57 AM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 7/7/2009 9:55:02 AM
Posts: 38, Visits: 147
Alright, I'll just walk you through what I've done now. I'm not sure these are right. Have I made any mistakes or left anything out?































bean id="systemHealthDAO"







class="com.teradata.dcs.data.dao.ibatis.SystemHealthDAOiBatis">







description>DAO for accessing System Health







property name="sqlMapClient" ref="dcsSqlMapClient" />







/bean>























!-- The SystemHealth manager implemenation -->







bean id="systemHealthManager" class="com.teradata.portlets.systemhealth.service.impl.SystemHealthManagerImpl">







description>The business delegate for this application







property name="myJavaSystemHealthDAO" ref="systemHealthDAO"/>







/bean>















1. A reference to your injected DAO object:















private SystemHealthDAO myJavaSystemHealthDAO;































2. A setter for the DAO:























public void setMyJavSystemHealthDAO(SystemHealthDAO myJavaSystemHealthDAO)







{







this.myJavaSystemHealthDAO = myJavaSystemHealthDAO;







}































3. A manager function that retrieves the data:















I wasn't sure of what I do here because I think this get function is only for query count































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've already created sample widgets but can you use every type of widget for system health?
Post #15896
Posted 6/25/2009 3:50:42 PM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 7/8/2009 5:31:22 PM
Posts: 30, Visits: 55
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.

Viewpoint Framework Development

Post #15914
Posted 6/25/2009 4:12:48 PM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 7/7/2009 9:55:02 AM
Posts: 38, Visits: 147
Alright. Well, I followed the skewedsessions tutorial and I created a project for the systemhealthDAO. Could I get help with these errors?

[javac] C:\SystemHealth\src\java\com\teradata\portlets\systemhealth\service\
impl\SystemHealthManagerImpl.java:93: cannot find symbol
[javac] symbol : variable lastPercentInState
[javac] location: class com.teradata.portlets.systemhealth.service.impl.Syst
emHealthManagerImpl
[javac] lastPercentInState.put(preferences.getSystem(), st
atistics.getPercentInState());
[javac] ^
[javac] C:\SystemHealth\src\java\com\teradata\portlets\systemhealth\service\
impl\SystemHealthManagerImpl.java:98: cannot find symbol
[javac] symbol : class Session
[javac] location: class com.teradata.portlets.systemhealth.service.impl.Syst
emHealthManagerImpl
[javac] List sessions = sessionDAO.getCurrentActiveSe
ssions(systemIds);
[javac] ^
[javac] C:\SystemHealth\src\java\com\teradata\portlets\systemhealth\service\
impl\SystemHealthManagerImpl.java:98: cannot find symbol
[javac] symbol : variable sessionDAO
[javac] location: class com.teradata.portlets.systemhealth.service.impl.Syst
emHealthManagerImpl
[javac] List sessions = sessionDAO.getCurrentActiveSe
ssions(systemIds);
[javac] ^
[javac] C:\SystemHealth\src\java\com\teradata\portlets\systemhealth\service\
impl\SystemHealthManagerImpl.java:100: cannot find symbol
[javac] symbol : class Session
[javac] location: class com.teradata.portlets.systemhealth.service.impl.Syst
emHealthManagerImpl
[javac] for (Session session : sessions)
[javac] ^
[javac] C:\SystemHealth\src\java\com\teradata\portlets\systemhealth\service\
impl\SystemHealthManagerImpl.java:121: cannot find symbol
[javac] symbol : variable lastPercentInState
[javac] location: class com.teradata.portlets.systemhealth.service.impl.Syst
emHealthManagerImpl
[javac] return lastPercentInState.get(systemName);
[javac] ^
[javac] 17 errors





*
* SystemHealthManagerImpl.java
*/

package com.teradata.portlets.systemhealth.service.impl;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.teradata.portlets.systemhealth.service.SystemHealthManager;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.ArrayList;
import com.teradata.dcs.data.dao.SystemHealthDAO;
import com.teradata.dcs.config.model.System;
import com.teradata.dcs.config.model.SystemHealthCanaryThreshold;
import com.teradata.dcs.config.model.SystemHealthMetricThreshold;
import com.teradata.dcs.data.model.SystemHealth;
import com.teradata.portlets.systemhealth.model.SystemHealthPreferences;
import com.teradata.dcs.data.model.SystemStatistics;
import com.teradata.dcs.data.dao.SystemStatisticsDAO;


/**
* This class implements the Business Delegate pattern. (see
* http://java.sun.com/blueprints/corej2eepatterns/Patterns/BusinessDelegate.html).
* This class is used to interface between the DAO's (see
* http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html)
* and the controllers. Business logic should be implemented here.
*/
public class SystemHealthManagerImpl implements SystemHealthManager
{
private static Log log = LogFactory.getLog(SystemHealthManagerImpl.class);

private SystemHealthDAO systemHealthDAO;

private SystemStatisticsDAO statisticsDAO;

private Map ();

/**
* Set the statistics DAO.
*
* @param value The Statistics DAO.
*/
public void setStatisticsDAO(SystemStatisticsDAO value)
{
statisticsDAO = value;
}

/**
* Set the systemhealth DAO
*
* @param value The Systemhealth DAO.
*/
public void setSystemHealthDAO(SystemHealthDAO value)
{
systemHealthDAO = value;
}

/**
* Retrieves a list of the names of the systems that are monitored by the
* Data Collector.
*
* @return A list of system names.
*/
public List getMonitoredSystems()
{
List systems = systemHealthDAO.getAvailableSystems();
List ();
for (System system : systems)
{
systemNames.add(system.getName());
}
return systemNames;
}
/**
* Gets a list of active system health on the specified system. Eacg list
* item is a system health model.
*
*@param preferences The user's portlet preferences for this portlet instance.
*/
public List getHealth(SystemHealthPreferences preferences)
{
List ();
Integer id = getSystemId(preferences.getSystem());
if (id != null)
{
SystemStatistics statistics = statisticsDAO.getCurrentSystemStatistics(id);
// save the system value
if (statistics != null && statistics.getPercentInState() > preferences.getSystemHealthMetricThreshold())
{
lastPercentInState.put(preferences.getSystem(), statistics.getPercentInState());
List ();
systemIds.add(id);

// fetch the data
List sessions = sessionDAO.getCurrentActiveSessions(systemIds);

for (Session session : sessions)
{
if ((session.getComputedState().equals("ACTIVE"))
&&(session.getPercentInState() > preferences.getSystemHealthMetricThreshold()))
{
result.add(session);
}
}
}
}
return result;
}

/**
* Get the most recent percent in state for the specified system.
*
* @param systemName the system to monitor.
* @return the percent in state or null if no value has been fetched.
*/
public Float getCurrentPercentInState(String systemName)
{
return lastPercentInState.get(systemName);
}
}
Post #15915
« Prev Topic | Next Topic »

«««12345»»»

Reading This Topic Expand / Collapse
Active Users: 0 ( 0 guests, 0 members, 0 anonymous members )
No members currently viewing this topic.


All times are GMT -5:00, Time now is 4:25pm

Powered By InstantForum.NET v4.1.4 © 2009
Execution: 0.078. 9 queries. Compression Disabled.