Java tutorial
/** * * Licensed under the Apache License, Version 2.0 (the "License"); * * Founder admin@love320.com * * http://www.love320.com */ package cms.pageList.entity; import java.util.List; import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Restrictions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; import org.springside.modules.orm.Page; import org.springside.modules.orm.PropertyFilter; import cms.entity.account.Archives; import cms.entity.account.Shop; import cms.entity.account.TagLabel; import cms.pageList.LabelInterface; import cms.service.account.ServicesManager; import cms.service.account.ShopManager; @Component @Scope("prototype") public class ShopLabel implements LabelInterface { private Page<Shop> page; private ServicesManager sm;// // ?PropertyFilter private String pfValue(String pfName, List<PropertyFilter> filters) { String pfValue = "0"; // ?? for (PropertyFilter pfTest : filters) { if (pfTest.getPropertyName().equals(pfName)) { // ? pfValue = pfTest.getMatchValue().toString(); } } return pfValue; } public String getIterativeString(TagLabel tagLabel, List<PropertyFilter> filters) { String strTag = tagLabel.getTagName();// ?? if (tagLabel == null) return strTag; // // ?? if ((!tagLabel.getOrderby().trim().equalsIgnoreCase("")) && (!tagLabel.getOrderbyType().trim().equalsIgnoreCase(""))) { String arcattStr = null;// for (Long flagid : tagLabel.getflagIds()) { arcattStr += "," + flagid; } // if (arcattStr != null) { // ?0,? if (tagLabel.getTypeid() == 0) { addArchivesList(tagLabel.getRow(), 1, tagLabel.getOrderby(), tagLabel.getOrderbyType(), Restrictions.ge("arcrank", 0), Restrictions.sqlRestriction( "shop_id in ( select shop_id from shop_arcatt where arcatt_id in(" + arcattStr + ") )")); } else { addArchivesList(tagLabel.getRow(), 1, tagLabel.getOrderby(), tagLabel.getOrderbyType(), Restrictions.eq("typeid", tagLabel.getTypeid()), Restrictions.ge("arcrank", 0), Restrictions.sqlRestriction( "shop_id in ( select shop_id from shop_arcatt where arcatt_id in(" + arcattStr + ") )")); } } else { // // ?0,? if (tagLabel.getTypeid() == 0) { addArchivesList(tagLabel.getRow(), 1, tagLabel.getOrderby(), tagLabel.getOrderbyType(), Restrictions.ge("arcrank", 0)); } else { addArchivesList(tagLabel.getRow(), 1, tagLabel.getOrderby(), tagLabel.getOrderbyType(), Restrictions.ge("arcrank", 0), Restrictions.eq("typeid", tagLabel.getTypeid())); } } } else { // ? // ?0,? if (tagLabel.getTypeid() == 0) { addArchivesList(tagLabel.getRow(), 1, "senddate", "desc", Restrictions.ge("arcrank", 0), Restrictions.eq("typeid", tagLabel.getTypeid())); } else { addArchivesList(tagLabel.getRow(), 1, "senddate", "desc", Restrictions.ge("arcrank", 0)); } } strTag = "<s:iterator value=\"pagecontent.listLabel.get(" + pfValue("getNum", filters) + ").getPage().getResult()\" status=\"st\">" + tagLabel.getBody() + "</s:iterator>"; return strTag; } // ?(?) public void addArchivesList(int size, final Criterion... criterions) { addArchivesList(size, 1, null, null, criterions); } // ?(?) public void addArchivesList(int size, int pageNo, String orderBy, String order, final Criterion... criterions) { // ? if (size == 0) size = 10; page = new Page<Shop>(size); // ?? if ((orderBy != null) && (order != null)) { page.setOrderBy(orderBy); page.setOrder(order); } // ?? if (!page.isOrderBySetted()) { page.setOrderBy("sortrank"); page.setOrder(Page.DESC); } // pageNo if (pageNo > 0) { page.setPageNo(pageNo); } ShopManager shopM = sm.getShopManager();//??? // ?? page = shopM.search(page, criterions); } public Page getPage() { return page; } @Autowired public void setSm(ServicesManager sm) { this.sm = sm; } }