/* ================================================================== * Created [2009-4-27 下午11:32:55] by Jon.King * ================================================================== * TSS * ================================================================== * mailTo:jinpujun@hotmail.com * Copyright (c) Jon.King, 2009-2012 * ================================================================== */ package com.jinhe.tss.cms.helper.translator; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; import com.jinhe.tss.cms.CMSConstants; import com.jinhe.tss.core.util.EasyUtils; import com.jinhe.tss.core.web.dispaly.tree.ITreeTranslator; /** * <p> ChannelCanSelectTranslator.java </p> * 树栏目是否可选 转换器 */ public class ChannelCanSelectTranslator implements ITreeTranslator { private List<String> canAddChannelIds = new ArrayList<String>(); private Long channelId; public ChannelCanSelectTranslator(String canAddChannels, Long channelId) { if ( !EasyUtils.isNullOrEmpty(canAddChannels) ) { canAddChannelIds = Arrays.asList(canAddChannels.split(",")); } this.channelId = channelId; } public Map<String, Object> translate(Map<String, Object> attributes) { if( !canAddChannelIds.contains(attributes.get("id").toString()) ) attributes.put("canselected", "0"); if( CMSConstants.TRUE.equals(attributes.get("isSite")) ) attributes.put("canselected", "0"); if( channelId != null && channelId.equals(attributes.get("id")) ) attributes.put("canselected", "0"); return attributes; } }