?? newsms.java
字號:
/**
* This class serves as a model component, in a MVC pattern.
* The action class or the web service manager class calls the
* relevant method in this class.
* This class is responsible for processing any business processes and
* gets the result from a datasource.
* It returns the result set in a pre-defined data object
*
*/
/**
* Change History:
* Author Date Version Details
* Jerome Josephraj 28 October 2002 1.0 Created
*
*/
package com.ddj.wsstruts.ms;
//Java imports
import java.sql.ResultSet;
import java.util.Collection;
import java.util.Vector;
import com.ddj.wsstruts.valueobject.News;
import com.ddj.wsstruts.constant.SystemConstants;
import com.ddj.wsstruts.ms.AbstractMs;
import com.ddj.wsstruts.util.DatabaseManager;
import com.ddj.wsstruts.valueobject.NewsSearchResult;
//log4j imports
import org.apache.log4j.Category;
public class NewsMs extends AbstractMs {
/*
* This method is used to search for a news
* The required news details are passed through News bean from
* the news maintenance action class. This method checks for all the
* mandatory fields and raises validationerrors for any missing mandatory field
*
* Mandatory fields are - none
*
* @NewsSearchResult Object
* @return Collection object
*/
public Collection getNews(NewsSearchResult newsSearchCOD)
throws Exception {
//Check if the newsCOD exists
if(newsSearchCOD == null) {
throw new Exception(this.getClass().getName()+ " NewsSearchCod is null ");
}
//Call DMS to search for an user
return this.getNewsResult(newsSearchCOD);
}
/*
* This method searches a news in the database as per the search criteria
* and populates the Collection with News COD.
*
* @param News news - News COD object
* @returns Collection
*/
public Collection getNewsResult(NewsSearchResult newsSearchCOD)
throws Exception {
boolean flag = false;
Vector newsList = new Vector();
StringBuffer query = new StringBuffer();
ResultSet rs = null;
Vector data = null;
Vector dataType = null;
DatabaseManager dbManager = null;
//Build the query
query.append("Select * From News");
//Get the resultset
dbManager = new DatabaseManager();
rs = dbManager.executeQuery(query.toString());
//Create a new COD and set the relevant values in it
NewsSearchResult newsSearchResultCOD = new NewsSearchResult();
while(rs.next()) {
//Get news context and populate the value object
newsSearchResultCOD.setNewsContent(rs.getString("NewsContent"));
newsList.add(newsSearchResultCOD);
newsSearchResultCOD = new NewsSearchResult();
}
return newsList;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -