public void execute( @Param("pageIndex") int pageIndex, @Param("searchKey") String searchKey, @Param("local") String local, 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); context.put("dataMedias", dataMedias); context.put("paginator", paginator); context.put("searchKey", searchKey); context.put("local", local); }
public void execute(Context context) { Set<String> applications = new HashSet<String>(); Set<String> services = new HashSet<String>(); List<Provider> pList = new ArrayList<Provider>(); try { pList = providerService.findAll(); } catch (Exception e) { logger.error(e.getMessage(), e); } for (Provider p : pList) { applications.add(p.getApplication()); services.add(p.getService()); } List<Consumer> cList = new ArrayList<Consumer>(); try { cList = consumerService.findAll(); } catch (Exception e) { logger.error(e.getMessage(), e); } for (Consumer c : cList) { applications.add(c.getApplication()); services.add(c.getService()); } context.put("rootContextPath", new RootContextPath(request.getContextPath())); context.put("services", services.size()); context.put("providers", pList.size()); context.put("consumers", cList.size()); context.put("applications", applications.size()); }
@Test public void get() { assertEquals(111, context.get("pull1")); assertEquals(222, context.get("pull2")); assertEquals(333, context.get("parent")); assertEquals(444, context.get("child")); assertEquals(null, context.get("other")); }
@Test public void containsKey() { assertTrue(context.containsKey("pull1")); assertTrue(context.containsKey("pull2")); assertTrue(context.containsKey("parent")); assertTrue(context.containsKey("child")); assertFalse(context.containsKey("other")); }
public void execute( @Param(name = "company") String company, @Param(name = "page") int page, @Param(name = "pageSize") int pageSize, @Param(name = "userLevel") String userLevel, @Param(name = "status") String status, @Param(name = "name") String name, Context context) { UserQuery userQuery = new UserQuery(); if (page == 0) { page = 1; } if (pageSize == 0 || pageSize > QueryObject.maxPageSize) { pageSize = QueryObject.defaultPageSize; } userQuery.setStatus(status); userQuery.setUserLevel(userLevel); userQuery.setCompany(company); userQuery.setName(name); context.put("userList", userService.queryUser(userQuery, (page - 1) * 20, pageSize)); context.put("company", company); context.put("name", name); context.put("status", status); context.put("userLevel", userLevel); context.put("page", page); context.put("pageSize", pageSize); int totalCount = userService.queryCount(userQuery); context.put("totalCount", totalCount); context.put("totalPage", totalCount / pageSize + 1); }
@Test public void create_no_pullContext() { context = new PullableMappedContext(null); context.put("aaa", 111); assertTrue(context.containsKey("aaa")); assertEquals(111, context.get("aaa")); assertFalse(context.containsKey("bbb")); assertNull(context.get("bbb")); }
public void execute(@Param(name = "messageId") int messageId, Context context) { MessageDO messageDO; messageDO = messageService.getMessageById(messageId); if (messageDO == null) { context.put("message", "获取数据失败!"); } else { context.put("messageDO", messageDO); } }
public void execute(Context context, @Param("sId") String sid) throws Exception { Passport passport = (Passport) request.getAttribute("passport"); context.put("passport", passport); context.put("sId", sid); // 获取所有问题标签 SettingQuestionTagGetAllListRequest getAllListRequest = new SettingQuestionTagGetAllListRequest(); SettingQuestionTagGetAllListResponse getAllListResponse = platformHelper.getSettingQuestionTagAllList(getAllListRequest, passport); if (getAllListResponse != null) { context.put("tags", getAllListResponse.getResult()); } }
/** * 找到单个Channel,用于编辑Channel信息界面加载信息 * * @param channelId * @param context * @throws WebxException */ public void execute( @Param("userId") Long userId, @Param("pageIndex") int pageIndex, @Param("searchKey") String searchKey, Context context, Navigator nav) throws Exception { User user = userService.findUserById(userId); context.put("user", user); context.put("pageIndex", pageIndex); context.put("searchKey", searchKey); }
public void execute( @Param(name = "url") String url, Context context, Navigator navigator, HttpSession session) { url = "http://tp2.sinaimg.cn/2268916473/50/5608371350/1"; byte[] bytes = null; boolean isSuccess = true; Result result = httpClient.get(new HttpUrl(url, null), null, null, null); if (!result.isSuccess()) { isSuccess = false; } else { bytes = result.getResultBytes(); String s = "data:image/png;base64,"; context.put("data", s + Base64.encode(bytes)); } context.put("success", isSuccess); }
@Function("public") public void doQuery( Context context, @Param(name = "from") String from, @Param(name = "to") String to) { try { Date start = new Date(); Date end = new Date(); if (from == null || to == null) { end = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setTime(end); calendar.add(Calendar.DATE, -1); // 得到前一天 start = calendar.getTime(); } else { SimpleDateFormat fmt = new SimpleDateFormat("MM/dd/yyyy"); start = fmt.parse(from); end = fmt.parse(to); } EucaConsoleMessage message = eucaAC.genVolumeReport(start, end); JSONObject object = (JSONObject) message.getData(); JSONArray resluts = object.getJSONArray("reports"); context.put("json", resluts); } catch (Exception e) { logger.error(e.getMessage(), e); } }
public void execute(Context context, @Param("currentPage") int currentPage) { OptionsDO optionsDO = new OptionsDO(); int pageSize = 10; if (currentPage > 0) { optionsDO.setStartId((currentPage - 1) * pageSize); } else { optionsDO.setStartId(0); } optionsDO.setPageSize(pageSize); try { List<AssetsImageDO> assetsImageDOList = assetsImageService.queryAssetsImage(optionsDO); context.put("assetsImageList", assetsImageDOList); int total = assetsImageService.countAssetsImage(); context.put("total", total); } catch (LoveException e) { logger.error(e.getMessage(), e); } }
private void assertKeySet(Context ctx, boolean withoutPulling, String... keys) { List<String> keyList = createArrayList( withoutPulling && ctx instanceof PullableMappedContext ? ((PullableMappedContext) ctx).keySetWithoutPulling() : ctx.keySet()); Collections.sort(keyList); assertArrayEquals(keys, keyList.toArray(new String[keyList.size()])); }
@Before public void init() { PullContext pullContext = createMock(PullContext.class); expect(pullContext.pull("pull1")).andReturn(111).anyTimes(); expect(pullContext.pull("pull2")).andReturn(222).anyTimes(); Set<String> names = createHashSet(Arrays.asList("pull1", "pull2")); expect(pullContext.getToolNames()).andReturn(names).anyTimes(); expect(pullContext.pull(org.easymock.EasyMock.<String>anyObject())).andReturn(null).anyTimes(); replay(pullContext); parent = new PullableMappedContext(pullContext); parent.put("parent", 333); context = new MappedContext(parent); context.put("child", 444); }
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 ("请输入关键字(目前支持Node的ID、名字搜索)".equals(searchKey)) { searchKey = ""; } condition.put("searchKey", searchKey); int count = canalService.getCount(condition); Paginator paginator = new Paginator(); paginator.setItems(count); paginator.setPage(pageIndex); condition.put("offset", paginator.getOffset()); condition.put("length", paginator.getLength()); List<Canal> canals = canalService.listByCondition(condition); List<SeniorCanal> seniorCanals = new ArrayList<SeniorCanal>(); for (Canal canal : canals) { SeniorCanal seniorCanal = new SeniorCanal(); seniorCanal.setId(canal.getId()); seniorCanal.setName(canal.getName()); seniorCanal.setStatus(canal.getStatus()); seniorCanal.setDesc(canal.getDesc()); seniorCanal.setCanalParameter(canal.getCanalParameter()); seniorCanal.setGmtCreate(canal.getGmtCreate()); seniorCanal.setGmtModified(canal.getGmtModified()); List<Pipeline> pipelines = pipelineService.listByDestinationWithoutOther(canal.getName()); seniorCanal.setPipelines(pipelines); seniorCanal.setUsed(!pipelines.isEmpty()); seniorCanals.add(seniorCanal); } context.put("seniorCanals", seniorCanals); context.put("paginator", paginator); context.put("searchKey", searchKey); }
public void execute(HttpSession session, Context context, CookieParser parser) { User user = (User) session.getAttribute(WebConstants.CURRENT_USER_KEY); if (user != null) context.put("operator", user.getUsername()); RootContextPath rootContextPath = new RootContextPath(request.getContextPath()); context.put("rootContextPath", rootContextPath); if (!context.containsKey("bucLogoutAddress")) { context.put("bucLogoutAddress", rootContextPath.getURI("logout")); } if (!context.containsKey("helpUrl")) { context.put("helpUrl", "http://code.alibabatech.com/wiki/display/dubbo"); } context.put(WebConstants.CURRENT_USER_KEY, user); context.put("language", parser.getString("locale")); context.put("registryServerSync", registryServerSync); }
public void execute(@Param("page") Integer page, TurbineRunData rundata, Context context) throws Exception { if (page == null) { page = 1; } Result result = jokeAO.getReviewJoke(page); if (result.getModule("jokeDO") == null) { if (page == 1) { rundata.setRedirectLocation("reviewNomore.vm"); } else if (page > 1) { rundata.setRedirectLocation( getTurbineURIBroker("jokeModule").setTarget("jokeReview.vm").render()); } } context.put("jokeDO", result.getModule("jokeDO")); context.put("userDO", result.getModule("userDO")); context.put("currentLoginUser", getCurrentLoginUser()); context.put("nextPage", page + 1); context.put("index", "review"); }
public void execute( @Param("pageIndex") int pageIndex, @Param("searchKey") String searchKey, @Param("channelStatus") String status, @Param("channelId") Long channelId, Context context) throws Exception { @SuppressWarnings("unchecked") Map<String, Object> condition = new HashMap<String, Object>(); if ("请输入关键字(目前支持Channel的ID、名字搜索)".equals(searchKey)) { searchKey = ""; } condition.put("searchKey", searchKey); List<Long> theStatusPks = new ArrayList<Long>(); if (null != status) { List<Long> allChannelPks = channelService.listAllChannelId(); for (Long channelPk : allChannelPks) { ChannelStatus channelStatus = arbitrateManageService.channelEvent().status(channelPk); if (channelStatus.equals(ChannelStatus.valueOf(status))) { theStatusPks.add(channelPk); } } } int count = channelService.getCount(condition); Paginator paginator = new Paginator(); paginator.setItems(count); paginator.setPage(pageIndex); condition.put("offset", paginator.getOffset()); condition.put("length", paginator.getLength()); List<Channel> channels = new ArrayList<Channel>(); if ((null != channelId) && (channelId != 0l)) { channels.add(channelService.findById(channelId)); paginator.setItems(1); paginator.setPage(0); searchKey = String.valueOf(channelId); // 定义为新的searchKey } else { channels = channelService.listByConditionWithoutColumn(condition); } List<SeniorChannel> seniorChannels = new ArrayList<SeniorChannel>(); for (Channel channel : channels) { boolean processEmpty = false; List<Pipeline> pipelines = channel.getPipelines(); for (Pipeline pipeline : pipelines) { if (processStatService .listRealtimeProcessStat(channel.getId(), pipeline.getId()) .isEmpty()) { processEmpty = true; } } SeniorChannel seniorChannel = new SeniorChannel(); seniorChannel.setId(channel.getId()); seniorChannel.setName(channel.getName()); seniorChannel.setParameters(channel.getParameters()); seniorChannel.setPipelines(channel.getPipelines()); seniorChannel.setStatus(channel.getStatus()); seniorChannel.setDescription(channel.getDescription()); seniorChannel.setGmtCreate(channel.getGmtCreate()); seniorChannel.setGmtModified(channel.getGmtModified()); seniorChannel.setProcessEmpty(processEmpty); seniorChannels.add(seniorChannel); } context.put("channels", seniorChannels); context.put("paginator", paginator); context.put("searchKey", searchKey); }
public void execute(Context context, @Param(name = "alias") String alias) throws LoveException { context.put("category", wapService.getCategoryByAlias(alias, true)); }
public void execute( @Param(name = "id") Long id, @Param(name = "name") String name, Context context) { User user = userService.getUserById(id); context.put("user", user); }
@Function("public") public void doQueryLaunchConfigurations(Context context) { List<LaunchConfigurationBean> configurations = new ArrayList<>(); context.put("json", configurations); }
public void execute( Context context, @Param("nickName") String nickName, @Param("pageNum") Integer pageNum, @Param("countService") Boolean countService, @Param("responseTime") Boolean responseTime) throws Exception { Passport passport = (Passport) request.getAttribute("passport"); context.put("passport", passport); SysUserFindResponse userFindResponse = new SysUserFindResponse(); // passport.setType(PassportTypeEnum.MEMBER); ShowCalGetForMyRequest showCalGetForMyRequest = new ShowCalGetForMyRequest(); ShowCalGetForMyResponse showCalGetForMyResponse = serviceHelper.getMyShowCal(showCalGetForMyRequest, passport); List<UserTypeEnum> userTypeEnums = new ArrayList<>(); userTypeEnums.add(UserTypeEnum.SHOWCAL); SysUserFindRequest sysUserFindRequest = new SysUserFindRequest(); if (nickName != null) { sysUserFindRequest.setNickName(nickName); } if (countService != null) { sysUserFindRequest.setIsCountService(countService); } if (responseTime != null) { sysUserFindRequest.setIsResponseTime(responseTime); } if (pageNum != null) { sysUserFindRequest.setPageNumber(pageNum); } if (showCalGetForMyResponse.getShowCalInfo() != null) { sysUserFindRequest.setServiceId(showCalGetForMyResponse.getShowCalInfo().getId()); } sysUserFindRequest.setUsertypes(userTypeEnums); sysUserFindRequest.setPageSize(5); userFindResponse = platformHelper.findSysUser(sysUserFindRequest, passport); List<UserDetail> users = new ArrayList<>(); for (UserDetail user : userFindResponse.getResult()) { if (user.getAvatarId() != null && user.getAvatarId().intValue() != 0) { FilePathGetRequest filePathGetRequest = new FilePathGetRequest(); filePathGetRequest.setId(user.getAvatarId()); FilePathGetResponse filePathGetResponse = foundationService.getFilePath(filePathGetRequest, passport); user.setAvatarurl(filePathGetResponse.getUrl()); } else { if (user.getSex() != null) { if (user.getSex().equals(SexEnum.FEMALE)) { user.setAvatarurl("../images/girl.png"); } else if (user.getSex().equals(SexEnum.MALE)) { user.setAvatarurl("../images/boy.png"); } } else { user.setAvatarurl("../images/girl.png"); } } ArticleFindRequest request = new ArticleFindRequest(); request.setSubmitUserId(user.getId()); request.setCategoryId(CategoryEnum.INTRODUCTION.name()); request.setPageSize(0); ArticleFindResponse response = cmsHelper.findArticle(request, passport); if (response.getResult().size() != 0) { user.setContent(response.getResult().get(0).getContent()); } users.add(user); } userFindResponse.setResult(users); try { PrintWriter out = this.response.getWriter(); String json = JSON.toJSONString(userFindResponse, SerializerFeature.DisableCircularReferenceDetect); out.println(json); } catch (IOException e) { e.printStackTrace(); } }
public void execute(@Param("pipelineId") Long pipelineId, Context context) throws Exception { Pipeline pipeline = pipelineService.findById(pipelineId); context.put("pipeline", pipeline); context.put("nodes", nodeService.listAll()); }
public void execute(Navigator nav, TurbineRunData rundata, Context context) throws Exception { rundata.setLayoutEnabled(false); List<TreeNode> treeNodes = new ArrayList<TreeNode>(); TreeNode treeNode4 = new TreeNode( 0l, "笑话管理", getTurbineURIBroker("adminModule").setTarget("jokeList.vm").render(), "frmright"); TreeNode treeNode1 = new TreeNode( 0l, "笑话类别", getTurbineURIBroker("adminModule") .setTarget("generator.vm") .addQueryData("action", "category_action") .addQueryData("event_submit_do_generate_out_category", 1) .addQueryData("outType", "jokeType") .addQueryData("outId", "0") .render(), "frmright"); TreeNode treeNode2 = new TreeNode( 0l, "笑话TAG", getTurbineURIBroker("adminModule") .setTarget("generator.vm") .addQueryData("action", "category_action") .addQueryData("event_submit_do_generate_out_category", 1) .addQueryData("outType", "jokeTag") .addQueryData("outId", "0") .render(), "frmright"); TreeNode treeNode3 = new TreeNode(1l, 0l, "素材管理", true, null, null); TreeNode treeNode5 = new TreeNode( 1l, "剧集管理", getTurbineURIBroker("adminModule") .setTarget("generator.vm") .addQueryData("action", "category_action") .addQueryData("event_submit_do_generate_out_category", 1) .addQueryData("outType", "material_series") .addQueryData("outId", "0") .render(), "frmright"); TreeNode treeNode6 = new TreeNode( 1l, "未审核图片", getTurbineURIBroker("adminModule") .setTarget("picMaterialList.vm") .addQueryData("status", MainStatus.TO_REVIEW.getType()) .render(), "frmright"); TreeNode treeNode7 = new TreeNode( 1l, "已审核图片", getTurbineURIBroker("adminModule") .setTarget("picMaterialList.vm") .addQueryData("status", MainStatus.NORMAL.getType()) .render(), "frmright"); TreeNode treeNode8 = new TreeNode( 1l, "笑话类别管理", getTurbineURIBroker("adminModule") .setTarget("generator.vm") .addQueryData("action", "category_action") .addQueryData("event_submit_do_generate_out_category", 1) .addQueryData("outType", "material_joke_content") .addQueryData("outId", "0") .render(), "frmright"); TreeNode treeNode9 = new TreeNode( 1l, "未审核笑话", getTurbineURIBroker("adminModule") .setTarget("jokeMaterialList.vm") .addQueryData("status", MainStatus.TO_REVIEW.getType()) .render(), "frmright"); TreeNode treeNode10 = new TreeNode( 1l, "已审核笑话", getTurbineURIBroker("adminModule") .setTarget("jokeMaterialList.vm") .addQueryData("status", MainStatus.NORMAL.getType()) .render(), "frmright"); TreeNode treeNode100 = new TreeNode( 0l, "刷新类别缓存", getTurbineURIBroker("adminModule") .setTarget("generator.vm") .addQueryData("action", "category_action") .addQueryData("event_submit_do_put_to_cache", 1) .render(), "frmright"); treeNodes.add(treeNode4); treeNodes.add(treeNode1); treeNodes.add(treeNode2); treeNodes.add(treeNode3); treeNodes.add(treeNode5); treeNodes.add(treeNode6); treeNodes.add(treeNode7); treeNodes.add(treeNode8); treeNodes.add(treeNode9); treeNodes.add(treeNode10); treeNodes.add(treeNode100); context.put("treeNodesJson", new Gson().toJson(treeNodes)); }
public void execute( @Param(name = "company") String company, @Param(name = "b") Long[] b, @Param(name = "s") Long[] s, @Param(name = "order") String order, @Param(name = "orderDesc") String orderDesc, @Param(name = "page") int page, @Param(name = "pageSize") int pageSize, @Param(name = "userRole") String userRole, Context context) { // 如果是第一次请求,全部勾选 if ((b == null || b.length == 0) && (s == null || s.length == 0)) { List<ProductCategory> resourceCategoryList = productCategoryService.getAllResourceCategory(); List<ProductCategory> materialCategoryList = productCategoryService.getAllMaterialCategory(); if (UserRole.INNER_USER.equals(userRole)) { // 内部用户b是原材料类别 b = new Long[materialCategoryList.size()]; for (int i = 0; i < materialCategoryList.size(); i++) { b[i] = materialCategoryList.get(i).getId(); } s = new Long[resourceCategoryList.size()]; for (int i = 0; i < resourceCategoryList.size(); i++) { s[i] = resourceCategoryList.get(i).getId(); } } else { s = new Long[materialCategoryList.size()]; for (int i = 0; i < materialCategoryList.size(); i++) { s[i] = materialCategoryList.get(i).getId(); } b = new Long[resourceCategoryList.size()]; for (int i = 0; i < resourceCategoryList.size(); i++) { b[i] = resourceCategoryList.get(i).getId(); } } } // 分页参数处理 UserQuery userQuery = new UserQuery(); if (page == 0) { page = 1; } if (pageSize == 0 || pageSize > QueryObject.maxPageSize) { pageSize = QueryObject.defaultPageSize; } // 企业类型 if (UserRole.INNER_USER.equalsIgnoreCase(userRole)) { userQuery.setRole(UserRole.INNER_USER); } else { userQuery.setRole(UserRole.OUTER_USER); } // 公司名 userQuery.setCompany(company); // 采购类别 List<Long> buyInterestIds = null; if (b != null && b.length > 0) { buyInterestIds = new ArrayList<Long>(); for (Long id : b) { buyInterestIds.add(id); } userQuery.setBuyInterestIds(buyInterestIds); } // 销售类别 List<Long> saleInterestIds = null; if (s != null && s.length > 0) { saleInterestIds = new ArrayList<Long>(); for (Long id : s) { saleInterestIds.add(id); } userQuery.setSaleInterestIds(saleInterestIds); } // 排序 if (order != null) { userQuery.setOrderModified(true); // 排序方式 if (orderDesc != null && orderDesc.equals(QueryObject.ORDER_DESC)) { userQuery.setOrderDesc(true); } if (orderDesc != null && orderDesc.equals(QueryObject.ORDER_ASC)) { userQuery.setOrderAsc(true); } } // 查询结果 context.put("userList", userService.queryUser(userQuery, (page - 1) * pageSize, pageSize)); // 查询参数 context.put("buyInterestIds", b); context.put("saleInterestIds", s); context.put("company", company); context.put("order", order); context.put("userRole", userRole); context.put("page", page); context.put("orderDesc", orderDesc); context.put("pageSize", pageSize); int totalCount = userService.queryCount(userQuery); context.put("totalCount", totalCount); context.put("totalPage", (totalCount - 1) / pageSize + 1); // 类别信息,作为查询条件用 CategoryQuery categoryQuery = new CategoryQuery(); categoryQuery.setIsMaterial(IS.Y); context.put( "materialCategories", wrapProductCategoryVO( productCategoryService.query(categoryQuery), saleInterestIds, buyInterestIds)); categoryQuery.setIsMaterial(IS.N); context.put( "notMaterialCategories", wrapProductCategoryVO( productCategoryService.query(categoryQuery), saleInterestIds, buyInterestIds)); }
public void execute(Context context) throws Exception { User user = userManager.getUser(PetstoreUser.getCurrentUser().getId()); context.put("user", user); }