on 06-28-2012 10:11 AM
HI, Can anyone assist with the code below regarding onActionAdvancedSearch
public void onActionAdvancedSearch(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionAdvancedSearch(ServerEvent)
IWDMessageManager msgM = wdComponentAPI.getMessageManager();
//msgM.reportSuccess("onActionAdvancedSearch");
if (wdContext.nodeRespUnitList().getLeadSelection() < 0)
{
msgM.reportException("Please choose a specific Coordinating Unit from list or All to query all database.", true);
return;
}
wdContext.currentContextElement().setParamExportExcell("");
String paramExcell = "";
RicercheGruppo rg = wdContext.currentRicercheGruppoElement().modelObject();
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
//CmModel model = new CmModel();
ArrayList searchCriteria = new ArrayList();
SearchCriteria sc = new SearchCriteria();
// numero di record per pg: per migliorare i tempi si potrebbe mettere 50 al posto di 100
sc.setMaxResults(wdContext.currentContextElement().getNumRecord4Page()+"|1");
wdContext.currentPaginazioneElement().setCurrentPage(1);
//String appID = wdContext.currentAreaIndexListElement().getCode();
String appID = null;
int indArea = wdContext.nodeAreaIndexList().getLeadSelection();
int indCoordUnit = wdContext.nodeRespUnitList().getLeadSelection();
if (indArea <= 0 && indCoordUnit > 0)
{
appID = wdContext.currentRespUnitListElement().getCode();
}
else
{
appID = wdContext.currentAreaIndexListElement().getCode();
}
paramExcell = "appID=" + appID;
GregorianCalendar gc = new GregorianCalendar();
searchCriteria.add(wdContext.currentLabelsElement().getLabelDataEstrazione());
searchCriteria.add(df.format(gc.getTime()));
searchCriteria.add(wdContext.currentLabelsElement().getLbGroup());
if (indArea <= 0 && indCoordUnit > 0)
{
searchCriteria.add(wdContext.currentRespUnitListElement().getDescr());
paramExcell = paramExcell + "&coordinatingUnitDescr=" + (wdContext.currentRespUnitListElement().getDescr()).replaceAll(" ","%20");
}
else
{
searchCriteria.add(wdContext.currentAreaIndexListElement().getDescr());
paramExcell = paramExcell + "&coordinatingUnitDescr=" + (wdContext.currentAreaIndexListElement().getDescr()).replaceAll(" ","%20");
}
// searchCriteria.add(wdContext.currentApplicationListElement().getDescr());
//List<AttributeSearc> aas = new ArrayOfAttributeSearch();
List<AttributeSearch> aas=new ArrayList<AttributeSearch>();
if (wdContext.currentContextElement().getId_code() != null && !wdContext.currentContextElement().getId_code().trim().equals(""))
{
AttributeSearch as = new AttributeSearch();
as.setAttibuteNameSpace("http://sapportals.com/xmlns/FGP/MRLIBRARY/entitycustom");
as.setAttributeName("FGP_SYS_CM_PP_Content_ID");
as.setOperator("=");
List<String> avs = new ArrayList<String>();
String si = new String(wdContext.currentContextElement().getId_code());
avs.add(si);
as.setAttributeValues(avs);
aas.add(as);
paramExcell = paramExcell + "&ContentID=" + wdContext.currentContextElement().getId_code();
searchCriteria.add(wdContext.currentLabelsElement().getLbColumnId());
searchCriteria.add(wdContext.currentContextElement().getId_code());
}
if (wdContext.currentContextElement().getResearchDescription() != null && !wdContext.currentContextElement().getResearchDescription().trim().equals(""))
{
AttributeSearch as = new AttributeSearch();
as.setAttibuteNameSpace("http://sapportals.com/xmlns/FGP/MRLIBRARY/entitycustom");
as.setAttributeName("FGP_SYS_CM_PP_Content_ResearchDescription");
as.setOperator("=");
List<String> avs = new ArrayList<String>();
String si = new String(wdContext.currentContextElement().getResearchDescription());
avs.add(si);
as.setAttributeValues(avs);
aas.add(as);
paramExcell = paramExcell + "&ResearchDescription=" + (wdContext.currentContextElement().getResearchDescription()).replaceAll(" ","%20");
searchCriteria.add(wdContext.currentLabelsElement().getLabelDescription());
searchCriteria.add(wdContext.currentContextElement().getResearchDescription());
}
if (wdContext.currentSelectedItemsElement().getSelectedAreaText() != null && !wdContext.currentSelectedItemsElement().getSelectedAreaText().trim().equals(""))
{
if (aas!= null && aas.size() > 0)
{
AttributeSearch as = new AttributeSearch();
as.setOperator("AND");
aas.add(as);
}
AttributeSearch as = new AttributeSearch();
as.setAttibuteNameSpace("http://sapportals.com/xmlns/FGP/MRLIBRARY/entitycustom");
as.setAttributeName("FGP_SYS_CM_PP_Content_Geography_Areas_Area");
as.setOperator("IN");
List<String> avs = new ArrayList<String>();
ArrayList vals = wdContext.nodeHelpAreaList().currentHelpAreaListElement().modelObject().getArea();
String val = "";
String valDescr = "";
for (int i = 0; i < vals.size(); i++)
{
Area dcm = (Area) vals.get(i);
String si = new String();
if (dcm.getSelected())
{
si=dcm.getCodice();
avs.add(si);
val = val + "," + dcm.getCodice();
valDescr = valDescr + "," + dcm.getDescrizione();
}
}
as.setAttributeValues(avs);
aas.add(as);
paramExcell = paramExcell + "&GeographyAreas=" + startWith(val,",");
paramExcell = paramExcell + "&GeographyAreasDesc=" + startWith(valDescr,",");
searchCriteria.add(wdContext.currentLabelsElement().getLbColumnArea());
searchCriteria.add(wdContext.currentSelectedItemsElement().getSelectedAreaText());
}
if (wdContext.currentSelectedItemsElement().getSelectedCountryText() != null && !wdContext.currentSelectedItemsElement().getSelectedCountryText().trim().equals(""))
{
if (aas!= null && aas.size() > 0)
{
AttributeSearch as = new AttributeSearch();
as.setOperator("AND");
aas.add(as);
}
AttributeSearch as = new AttributeSearch();
as.setAttibuteNameSpace("http://sapportals.com/xmlns/FGP/MRLIBRARY/entitycustom");
as.setAttributeName("FGP_SYS_CM_PP_Content_Geography_Countries_Country");
as.setOperator("IN");
List<String> avs = new ArrayList<String>();
ArrayList vals = wdContext.nodeHelpCountryList().currentHelpCountryListElement().modelObject().getCountry();
String val = "";
String valDescr="";
for (int i = 0; i < vals.size(); i++)
{
Country dcm = (Country) vals.get(i);
String si = new String();
if (dcm.getSelected())
{
si=dcm.getCodice();
avs.add(si);
val = val + "," + dcm.getCodice();
valDescr = valDescr + "," + dcm.getDescrizione();
}
}
as.setAttributeValues(avs);
aas.add(as);
paramExcell = paramExcell + "&GeographyCountries=" + startWith(val,",");
paramExcell = paramExcell + "&GeographyCountriesDescr=" + startWith(valDescr,",");
searchCriteria.add(wdContext.currentLabelsElement().getLbColumnCountry());
searchCriteria.add(wdContext.currentSelectedItemsElement().getSelectedCountryText());
}
if (wdContext.nodeHelpResearchMacroType().getLeadSelection() >= 0)
{
if (aas!= null && aas.size() > 0)
{
AttributeSearch as = new AttributeSearch();
as.setOperator("AND");
aas.add(as);
}
AttributeSearch as = new AttributeSearch();
as.setAttibuteNameSpace("http://sapportals.com/xmlns/FGP/MRLIBRARY/entitycustom");
as.setAttributeName("FGP_SYS_CM_PP_Content_Characteristics_MacroType");
as.setOperator("=");
List<String> avs = new ArrayList<String>();
String si = new String(wdContext.currentHelpResearchMacroTypeElement().getCodice());
avs.add(si);
as.setAttributeValues(avs);
aas.add(as);
paramExcell = paramExcell + "&MacroType=" + wdContext.currentHelpResearchMacroTypeElement().getCodice();
paramExcell = paramExcell + "&MacroTypeDescr=" +(wdContext.currentHelpResearchMacroTypeElement().getDescrizione()).replaceAll(" ","%20");
searchCriteria.add(wdContext.currentLabelsElement().getLbColumnMacroType());
searchCriteria.add(wdContext.currentHelpResearchMacroTypeElement().getDescrizione());
}
if (wdContext.currentSelectedItemsElement().getSelectedResearchCategoryText() != null && !wdContext.currentSelectedItemsElement().getSelectedResearchCategoryText().trim().equals(""))
{
if (aas!= null && aas.size() > 0)
{
AttributeSearch as = new AttributeSearch();
as.setOperator("AND");
aas.add(as);
}
AttributeSearch as = new AttributeSearch();
as.setAttibuteNameSpace("http://sapportals.com/xmlns/FGP/MRLIBRARY/entitycustom");
as.setAttributeName("FGP_SYS_CM_PP_Content_Characteristics_Category");
as.setOperator("IN");
List<String> avs = new ArrayList<String>();
ArrayList vals = wdContext.nodeHelpResearchCategoryList().currentHelpResearchCategoryListElement().modelObject().getResearchCategory();
String val = "";
String valDescr="";
for (int i = 0; i < vals.size(); i++)
{
ResearchCategory dcm = (ResearchCategory) vals.get(i);
if (dcm.getSelected())
{
String si = new String(dcm.getCodice());
avs.add(si);
val = val + "," + dcm.getCodice();
valDescr = valDescr + "," + dcm.getDescrizione();
}
}
as.setAttributeValues(avs);
aas.add(as);
paramExcell = paramExcell + "&CharacteristicsCategory=" + startWith(val,",");
paramExcell = paramExcell + "&CharacteristicsCategoryDescr=" + startWith(valDescr,",");
searchCriteria.add(wdContext.currentLabelsElement().getLabelResearchCategory());
searchCriteria.add(wdContext.currentSelectedItemsElement().getSelectedResearchCategoryText());
}
if (wdContext.currentSelectedItemsElement().getSelectedProductCategoryText() != null && wdContext.currentSelectedItemsElement().getSelectedProductCategoryText().trim().length() > 0)
{
if (aas!= null && aas.size() > 0)
{
AttributeSearch as = new AttributeSearch();
as.setOperator("AND");
aas.add(as);
}
AttributeSearch as = new AttributeSearch();
as.setAttibuteNameSpace("http://sapportals.com/xmlns/FGP/MRLIBRARY/entitycustom");
as.setAttributeName("FGP_SYS_CM_PP_Content_Product_Categories_Category");
as.setOperator("IN");
List<String> avs = new ArrayList<String>();
ArrayList vals = rg.getProductCategoryList().getProductCategory();
String val = "";
String valDescr = "";
for (int i = 0; i < vals.size(); i++)
{
ProductCategory dcm = (ProductCategory) vals.get(i);
if (dcm.getSelected())
{
String si=new String(dcm.getCodice());
avs.add(si);
val = val + "," + dcm.getCodice();
valDescr = valDescr + "," + dcm.getDescrizione();
}
}
as.setAttributeValues(avs);
aas.add(as);
paramExcell = paramExcell + "&ProductCategories=" + startWith(val,",");
paramExcell = paramExcell + "&ProductCategoriesDescr=" + startWith(valDescr,",");
searchCriteria.add(wdContext.currentLabelsElement().getLbColumnProductCategory());
searchCriteria.add(wdContext.currentSelectedItemsElement().getSelectedProductCategoryText());
}
if (wdContext.currentSelectedItemsElement().getSelectedBrandText() != null && wdContext.currentSelectedItemsElement().getSelectedBrandText().trim().length() > 0)
{
if (aas!= null && aas.size() > 0)
{
AttributeSearch as = new AttributeSearch();
as.setOperator("AND");
aas.add(as);
}
AttributeSearch as = new AttributeSearch();
as.setAttibuteNameSpace("http://sapportals.com/xmlns/FGP/MRLIBRARY/entitycustom");
as.setAttributeName("FGP_SYS_CM_PP_Content_Product_brands_brand");
as.setOperator("IN");
List<String> avs = new ArrayList<String>();
ArrayList vals = rg.getProductList().getProduct();
String val = "";
String valDescr = "";
for (int i = 0; i < vals.size(); i++)
{
Product dcm = (Product) vals.get(i);
if (dcm.getSelected())
{
String si=new String(dcm.getCodice());
avs.add(si);
val = val + "," + dcm.getCodice();
valDescr = valDescr + "," + dcm.getDescrizione();
}
}
as.setAttributeValues(avs);
aas.add(as);
paramExcell = paramExcell + "&ProductBrands=" + startWith(val,",");
paramExcell = paramExcell + "&ProductBrandsDescr="+ startWith(valDescr,",");
searchCriteria.add(wdContext.currentLabelsElement().getLbColumnProductBrand());
searchCriteria.add(wdContext.currentSelectedItemsElement().getSelectedBrandText());
}
if (wdContext.nodeHelpStatus().getLeadSelection() >= 0)
{
if (aas!= null && aas.size() > 0)
{
AttributeSearch as = new AttributeSearch();
as.setOperator("AND");
aas.add(as);
}
AttributeSearch as = new AttributeSearch();
as.setAttibuteNameSpace("http://sapportals.com/xmlns/FGP/MRLIBRARY/entitycustom");
as.setAttributeName("FGP_SYS_CM_PP_Content_Status");
as.setOperator("=");
List<String> avs = new ArrayList<String>();
String si=new String(wdContext.currentHelpStatusElement().getCodice());
avs.add(si);
as.setAttributeValues(avs);
aas.add(as);
paramExcell = paramExcell + "&Status=" + wdContext.currentHelpStatusElement().getCodice();
paramExcell = paramExcell + "&StatusDescr=" + startWith(wdContext.currentHelpStatusElement().getDescrizione(),",");
searchCriteria.add(wdContext.currentLabelsElement().getLbColumnStatus());
searchCriteria.add(wdContext.currentHelpStatusElement().getDescrizione());
}
if (wdContext.nodeHelpResearchGroup().getLeadSelection() >= 0)
{
if (aas!= null && aas.size() > 0)
{
AttributeSearch as = new AttributeSearch();
as.setOperator("AND");
aas.add(as);
}
AttributeSearch as = new AttributeSearch();
as.setAttibuteNameSpace("http://sapportals.com/xmlns/FGP/MRLIBRARY/entitycustom");
as.setAttributeName("FGP_SYS_CM_PP_Content_Supplier_ResearchGroup");
as.setOperator("=");
List<String> avs = new ArrayList<String>();
String si=new String(wdContext.currentHelpResearchGroupElement().getCodice());
avs.add(si);
as.setAttributeValues(avs);
aas.add(as);
paramExcell = paramExcell + "&SupplierResearchGroup=" + wdContext.currentHelpResearchGroupElement().getCodice();
paramExcell = paramExcell + "&SupplierResearchGroupDescr=" + startWith(wdContext.currentHelpResearchGroupElement().getDescrizione(),",");
searchCriteria.add(wdContext.currentLabelsElement().getLbColumnResearchGroup());
searchCriteria.add(wdContext.currentHelpResearchGroupElement().getDescrizione());
}
if (wdContext.currentSelectedItemsElement().getSelectedDataCollectionMethodText() != null && wdContext.currentSelectedItemsElement().getSelectedDataCollectionMethodText().trim().length() > 0)
{
if (aas!= null && aas.size() > 0)
{
AttributeSearch as = new AttributeSearch();
as.setOperator("AND");
aas.add(as);
}
AttributeSearch as = new AttributeSearch();
as.setAttibuteNameSpace("http://sapportals.com/xmlns/FGP/MRLIBRARY/entitycustom");
as.setAttributeName("FGP_SYS_CM_PP_Content_Characteristics_DataCollectionMethods_DataCollectionMethod");
as.setOperator("IN");
List<String> avs = new ArrayList<String>();
ArrayList vals = rg.getDataCollectionMethodList().getDataCollectionMethod();
String val = "";
String valDescr = "";
for (int i = 0; i < vals.size(); i++)
{
DataCollectionMethod dcm = (DataCollectionMethod) vals.get(i);
String si = new String(dcm.getCodice());
avs.add(si);
val = val + "," + dcm.getCodice();
valDescr = valDescr + "," + dcm.getDescrizione();
}
as.setAttributeValues(avs);
aas.add(as);
paramExcell = paramExcell + "&DataCollectionMethod=" + startWith(val,",");
paramExcell = paramExcell + "&DataCollectionMethodDescr=" + startWith(valDescr,",");
searchCriteria.add(wdContext.currentLabelsElement().getLabelDataCollectionMethod());
searchCriteria.add(wdContext.currentSelectedItemsElement().getSelectedDataCollectionMethodText());
}
if (wdContext.currentSelectedItemsElement().getSelectedFiscalYearText() != null && wdContext.currentSelectedItemsElement().getSelectedFiscalYearText().trim().length() > 0)
{
if (aas!= null && aas.size() > 0)
{
AttributeSearch as = new AttributeSearch();
as.setOperator("AND");
aas.add(as);
}
AttributeSearch as = new AttributeSearch();
as.setAttibuteNameSpace("http://sapportals.com/xmlns/FGP/MRLIBRARY/entitycustom");
as.setAttributeName("FGP_SYS_CM_PP_Content_FiscalYears_FiscalYear");
as.setOperator("IN");
List<String> avs = new ArrayList<String>();
ArrayList vals = rg.getFiscalYear();
String val = "";
for (int i = 0; i < vals.size(); i++)
{
FiscalYear dcm = (FiscalYear) vals.get(i);
String si = new String(dcm.getCodice());
avs.add(si);
val = val + "," + dcm.getCodice();
}
as.setAttributeValues(avs);
aas.add(as);
paramExcell = paramExcell + "&FiscalYears=" + startWith(val,",");
searchCriteria.add(wdContext.currentLabelsElement().getLabelFiscalYear());
searchCriteria.add(wdContext.currentSelectedItemsElement().getSelectedFiscalYearText());
}
wdContext.currentContextElement().setParamExportExcell(paramExcell);
//msgM.reportSuccess("paramExcell "+paramExcell);
sc.setAttributeSearch(aas);
wdContext.currentContextElement().setSearchCriteria(sc);
wdThis.wdGetFGP_GRP_MKTSvs_SSearchController().executeSearch(sc, appID, false);
wdThis.wdFirePlugToResultView();
wdContext.currentContextElement().setResult_view_visible(WDVisibility.VISIBLE);
ISearchCriteriaListElement scle = wdContext.nodeSearchCriteriaList().createSearchCriteriaListElement();
wdContext.nodeSearchCriteriaList().addElement(scle);
wdContext.currentSearchCriteriaListElement().setSearchCriteria(searchCriteria);
//@@end
}
//wdThis.wdGetFGP_GRP_MKTSvs_SSearchController().executeSearch
public void executeSearch( com.ferrero.cm.beans.SearchCriteria sc, java.lang.String appID, boolean excel ) {
//@@begin executeSearch()
IWDMessageManager manager = wdComponentAPI.getMessageManager();
FGPSYSCMServices port = null;
try {
IWDRequest request = WDProtocolAdapter.getProtocolAdapter().getRequestObject();
URL serv=new URL("http://"+request.getServerName()+"/FGP_SYS_CM_Services/FGP_SYS_CM_Services?wsdl");
port = ServiceConnection.getService(request.getServerName());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//System.err.println("FRANCY SEARCH PRIMA DI CHIAMARE IL SERVIZIO appid "+appID);
ServiceResultEntity sv = port.fgpSYSCMSearch("", appID, sc);
// System.err.println("FRANCY SEARCH DOPO DI CHIAMARE IL SERVIZIO");
int trovati = 0;
List ar = null;
//System.err.println("FRANCY SEARCH DOPO getServiceMessage() "+sv.getServiceMessage());
if (sv.getServiceCode() != null && sv.getServiceCode().trim().equals("-1")) {
manager.reportException(sv.getServiceMessage());
return;
}
if (sv.getContentEntity() != null) {
String tot = sv.getServiceMessage();
trovati = sv.getContentEntity().size();
// System.err.println("FRANCY SEARCH Ricerche trovate n. "+trovati);
ar = sv.getContentEntity();
wdContext.currentPaginazioneElement().setNumRicTrovate(Integer.parseInt(tot));
int num4Page = new Integer(wdContext.currentContextElement().getNumRecord4Page()).intValue();
int itotpagine = Integer.parseInt(tot) / num4Page; // 100;
double dtotpagine = Double.parseDouble(tot) / num4Page; // 100;
// System.err.println("FRANCY SEARCH num4Page "+num4Page);
// System.err.println("FRANCY SEARCH itotpagine "+itotpagine);
// System.err.println("FRANCY SEARCH dtotpagine "+dtotpagine);
if (dtotpagine - (itotpagine) > 0) {
itotpagine++;
}
// System.err.println("FRANCY SEARCH itotpagine "+itotpagine);
wdContext.currentPaginazioneElement().setTotPages(itotpagine);
DecimalFormat df = new DecimalFormat("#,###,##0.##", new DecimalFormatSymbols(Locale.ITALIAN));
wdContext.currentPaginazioneElement().setLabelPagine("Result Set " + wdContext.currentPaginazioneElement().getCurrentPage() + " of " + itotpagine + " (" + df.format(Long.parseLong(tot)) + " total results)");
// System.err.println("FRANCY SEARCH getLabel Pagina "+wdContext.currentPaginazioneElement().getLabelPagine());
}
ArrayList ricercheGruppoList = new ArrayList();
RicercheGruppoList rgl = new RicercheGruppoList();
for (int i = 0; i < trovati; i++) {
ContentEntity ce = (ContentEntity) ar.get(i);
RicercheGruppo ric = wdThis.entity2RicercaGruppo(ce);
//System.err.println("FFRANCY RICERCA ce "+ce.getTitle());
ricercheGruppoList.add(ric);
}
rgl.setRicercheGruppo(ricercheGruppoList);
if (excel) {
// System.err.println("FRANCY SEARCH excell");
wdContext.nodeRicercheGruppoExcelList().bind(rgl);
} else {
// System.err.println("FRANCY SEARCH nodeRicercheGruppoList().bind(");
wdContext.nodeRicercheGruppoList().bind(rgl);
// System.err.println("FRANCY SEARCH wdContext.nodeRicercheGruppo().size() "+wdContext.nodeRicercheGruppo().size());
try{
for (int i = 0; i < wdContext.nodeRicercheGruppo().size(); i++) {
this.getNumAttach(wdContext.nodeRicercheGruppo().getRicercheGruppoElementAt(i).getRid());
wdContext.nodeRicercheGruppo().getRicercheGruppoElementAt(i).setNumAttach(Integer.parseInt(wdContext.currentContextElement().getNumAttach()));
wdContext.nodeRicercheGruppo().getRicercheGruppoElementAt(i).setOnePageSummary(wdContext.currentContextElement().getOnePageSummary());
}
}catch (Exception e ){
System.err.println("FRANCY SEARCH error get attach "+e.getMessage());
}
}
//System.err.println("FFRANCY FINE RICERCA");
//@@end
}
This is the code, what is the question ??
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Joseph, also I suggest to take a look at line at executeSearch() method (it is called by onActionAdvancedSearch(), right?):
ServiceResultEntity sv = port.fgpSYSCMSearch("", appID, sc);
this web-service(?) invoke may be a cause of performance degradation. Try to call it independently to examine its execution time.
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.