cms.pageList.entity.GeneralArcPageLabel.java Source code

Java tutorial

Introduction

Here is the source code for cms.pageList.entity.GeneralArcPageLabel.java

Source

/**
 * 
 * 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.Arctype;
import cms.entity.account.TagLabel;
import cms.pageList.LabelInterface;
import cms.service.account.ArchivesTypeManager;

@Component
public class GeneralArcPageLabel implements LabelInterface {

    private Page<Archives> page;

    private ArchivesTypeManager atm;

    // ?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();
            }
            // System.out.println("propertyFilter:"+pfTest.getPropertyName()+":"+pfTest.getMatchValue());
        }

        return pfValue;
    }

    //
    private String arctypeidStr(Long id) {
        List<Arctype> arctypeList = atm.getArctypeManager().getAdviceList(id);
        String typeidStr = "";
        for (Arctype arctypeTest : arctypeList) {
            typeidStr += "," + arctypeTest.getId();
            typeidStr += arctypeidStr(arctypeTest.getId());
        }
        return typeidStr;
    }

    public String getIterativeString(TagLabel tagLabel, List<PropertyFilter> filters) {

        String strTag = tagLabel.getTagName();

        // System.out.println("3:"+pageNo);

        //???   
        String typeidStr = pfValue("typeId", filters);//??ID
        typeidStr += arctypeidStr(new Long(Integer.parseInt(pfValue("typeId", filters))));//???ID

        // ??
        if ((!tagLabel.getOrderby().trim().equalsIgnoreCase(""))
                && (!tagLabel.getOrderbyType().trim().equalsIgnoreCase(""))) {

            addArchivesList(tagLabel.getRow(), Integer.parseInt(pfValue("pageNo", filters)), tagLabel.getOrderby(),
                    tagLabel.getOrderbyType(), Restrictions.ge("arcrank", 0),
                    Restrictions.sqlRestriction("typeid in (" + typeidStr + ")"));

        } else {// ?
            System.out.println("B:" + typeidStr);
            addArchivesList(tagLabel.getRow(), Integer.parseInt(pfValue("pageNo", filters)), "senddate", "desc",
                    Restrictions.ge("arcrank", 0), Restrictions.sqlRestriction("typeid in (" + typeidStr + ")"));
        }

        // ??

        /*strTag = "<s:iterator value=\"pagecontent.listLabel.get("
        + pfValue("getNum", filters)
        + ").getPage().getResult()\" status=\"st\">"
        + tagLabel.getBody() + "</s:iterator>";*/
        strTag = "<#list pagecontent.listLabel.get(" + pfValue("getNum", filters)
                + ").getPage().getResult() as xx >" + tagLabel.getBody() + "</#list>";

        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<Archives>(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);
        }
        // ??
        page = atm.getArchivesManager().getAdviceList(page, criterions);
        // 

        // System.out.println("hivesList"+hivesList.size());
        // System.out.println(">>>>"+hivesList.get(0).getHivesPage().getResult().get(0));
    }

    public Page getPage() {
        return page;
    }

    @Autowired
    public void setAtm(ArchivesTypeManager atm) {
        this.atm = atm;
    }

}