Search in sources :

Example 1 with SeniorDataMedia

use of com.alibaba.otter.manager.web.common.model.SeniorDataMedia in project otter by alibaba.

the class DataMediaList method execute.

public void execute(@Param("pageIndex") int pageIndex, @Param("searchKey") String searchKey, Context context) throws Exception {
    @SuppressWarnings("unchecked") Map<String, Object> condition = new HashMap<String, Object>();
    if ("请输入关键字(目前支持DataMedia的ID、名字搜索)".equals(searchKey)) {
        searchKey = "";
    }
    condition.put("searchKey", searchKey);
    int count = dataMediaService.getCount(condition);
    Paginator paginator = new Paginator();
    paginator.setItems(count);
    paginator.setPage(pageIndex);
    condition.put("offset", paginator.getOffset());
    condition.put("length", paginator.getLength());
    List<DataMedia> dataMedias = dataMediaService.listByCondition(condition);
    List<SeniorDataMedia> seniorDataMedias = new ArrayList<SeniorDataMedia>();
    for (DataMedia dataMedia : dataMedias) {
        SeniorDataMedia seniorDataMedia = new SeniorDataMedia();
        seniorDataMedia.setId(dataMedia.getId());
        seniorDataMedia.setEncode(dataMedia.getEncode());
        seniorDataMedia.setGmtCreate(dataMedia.getGmtCreate());
        seniorDataMedia.setGmtModified(dataMedia.getGmtModified());
        seniorDataMedia.setName(dataMedia.getName());
        seniorDataMedia.setNamespace(dataMedia.getNamespace());
        seniorDataMedia.setSource(dataMedia.getSource());
        List<DataMediaPair> pairs = dataMediaPairService.listByDataMediaId(dataMedia.getId());
        seniorDataMedia.setPairs(pairs);
        if (pairs.size() < 1) {
            seniorDataMedia.setUsed(false);
        } else {
            seniorDataMedia.setUsed(true);
        }
        seniorDataMedias.add(seniorDataMedia);
    }
    context.put("dataMedias", seniorDataMedias);
    context.put("paginator", paginator);
    context.put("searchKey", searchKey);
}
Also used : DataMediaPair(com.alibaba.otter.shared.common.model.config.data.DataMediaPair) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Paginator(com.alibaba.citrus.util.Paginator) SeniorDataMedia(com.alibaba.otter.manager.web.common.model.SeniorDataMedia) DataMedia(com.alibaba.otter.shared.common.model.config.data.DataMedia) SeniorDataMedia(com.alibaba.otter.manager.web.common.model.SeniorDataMedia)

Aggregations

Paginator (com.alibaba.citrus.util.Paginator)1 SeniorDataMedia (com.alibaba.otter.manager.web.common.model.SeniorDataMedia)1 DataMedia (com.alibaba.otter.shared.common.model.config.data.DataMedia)1 DataMediaPair (com.alibaba.otter.shared.common.model.config.data.DataMediaPair)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1