List of usage examples for org.apache.commons.collections ListUtils union
public static List union(final List list1, final List list2)
From source file:de.hybris.platform.print.services.impl.DefaultPrintJobServiceTest.java
/** * TODO: Should create a test creating a job without a subject and check the workflow is named appropriately *//*from w ww .ja va 2 s. c o m*/ @Test public void testCreateJob() { // admin user will be owner of Workflow template and standard assignee for WorkflowActions final UserModel admin = getUserService().getUserForUID("admin"); // creator will be the user creating a job final UserModel creator = createUser("TestUser"); // assignee will be the defined special assignee for a WorkflowAction final UserModel assignee = createUser("OtherTestUser"); // create a comment final CommentModel comment = prepareComment("testComment1", "MyJob", 0, creator); // create a page and assign comment to page final PageModel page = preparePage(); final List<CommentModel> comments = new ArrayList<CommentModel>(); comments.add(comment); page.setComments(comments); // here the interceptor PageCommentsPrepareInterceptor is triggered when comment history of page is dirty getModelService().save(page); /** * TODO: Why are you starting a workflow to check later that it is started? Starting is done in PrintCollaborationFacade, so * it should be tested in DefaultPrintCollaborationFacadeTest.java */ createPrintJobWorkflowTemplate(admin, assignee); // execute job creation method from business logic final WorkflowModel workflow = printJobService.createJob(comment, page, creator); getModelService().save(workflow); comment.setWorkflow(workflow); getModelService().save(comment); workflowProcessingService.startWorkflow(workflow); // verify workflow assignee is creator of job assertEquals("job workflow has wrong PrincipalAssigned", comment.getWorkflow().getPrincipalAssigned(), creator); // verify Comment has appropriate workflow attached assertTrue("no appropriate workflow attached to the comment", comment.getWorkflow().getName().equals("MyJob")); // verify workflow has been started assertTrue("workflow not started yet!", newestWorkflowService.isRunning(comment.getWorkflow())); // verify WorkflowActions from type WorkflowActionType.START and WorkflowActionType.END have creator and page assigned final List<WorkflowActionModel> workflowStartEndActions = ListUtils.union( workflowActionService.getStartWorkflowActions(comment.getWorkflow()), workflowActionService.getEndWorkflowActions(comment.getWorkflow())); for (final WorkflowActionModel action : workflowStartEndActions) { assertEquals("wrong principal assigned for start-action or end-action", action.getPrincipalAssigned(), creator); assertTrue("wrong or no page attached to start-action or end-action", action.getAttachments().size() >= 1 && action.getAttachments().get(0).getItem().equals(page)); // verify start actions are set to IN_PROGRESS if (action.getActionType() == WorkflowActionType.START) { assertTrue("WorkflowAction of type start not activated", workflowActionService.isActive(action)); } } // verify WorkflowActions from type WorkflowActionType.NORMAL have correct assignee and attachement final List<WorkflowActionModel> workflowNormalActions = workflowActionService .getNormalWorkflowActions(comment.getWorkflow()); for (final WorkflowActionModel action : workflowNormalActions) { assertEquals("wrong principal assigned for middle-action", action.getPrincipalAssigned(), assignee); assertTrue("wrong or no page attached to middle-action", action.getAttachments().size() >= 1 && action.getAttachments().get(0).getItem().equals(page)); } }
From source file:com.eryansky.web.sys.DictionaryAction.java
/** * combotree?.//w w w . jav a 2 s. c o m */ @SuppressWarnings("unchecked") public void combotree() throws Exception { try { List<TreeNode> titleList = Lists.newArrayList(); // "------"?"------" if (!StringUtils.isBlank(selectType)) { SelectType s = SelectType.getSelectTypeValue(selectType); if (s != null) { TreeNode selectTreeNode = new TreeNode("", s.getDescription()); titleList.add(selectTreeNode); } } List<TreeNode> treeNodes = dictionaryManager.getByDictionaryTypeCode(model, model.getDictionaryTypeCode(), model.getId(), true); List<TreeNode> unionList = ListUtils.union(titleList, treeNodes); Struts2Utils.renderJson(unionList); } catch (Exception e) { throw e; } }
From source file:com.eryansky.modules.sys.web.ResourceController.java
/** * ?.// www .j a va 2s. c o m */ @RequestMapping(value = { "tree" }) @ResponseBody public List<TreeNode> tree(String selectType) throws Exception { List<TreeNode> treeNodes = null; List<TreeNode> titleList = Lists.newArrayList(); TreeNode selectTreeNode = SelectType.treeNode(selectType); if (selectTreeNode != null) { titleList.add(selectTreeNode); } treeNodes = resourceManager.findTreeNodeResources(); List<TreeNode> unionList = ListUtils.union(titleList, treeNodes); return unionList; }
From source file:com.lushapp.modules.sys.web.ResourceController.java
/** * ?./* ww w . jav a 2 s . c o m*/ */ @RequestMapping(value = { "tree" }) @ResponseBody public List<TreeNode> tree(String selectType) throws Exception { List<TreeNode> treeNodes = Lists.newArrayList(); List<TreeNode> titleList = Lists.newArrayList(); // "------"?"------" if (!StringUtils.isBlank(selectType)) { SelectType s = SelectType.getSelectTypeValue(selectType); if (s != null) { TreeNode selectTreeNode = new TreeNode("", s.getDescription()); titleList.add(selectTreeNode); } } treeNodes = resourceManager.getResourceTree(null, false); List<TreeNode> unionList = ListUtils.union(titleList, treeNodes); return unionList; }
From source file:net.rptools.accesscontrol.AccessLayerModel.java
@Override @SuppressWarnings("unchecked") protected List<? extends Model> getChildren() { return Collections.unmodifiableList(ListUtils.union(objectList, userList)); }
From source file:com.eryansky.web.base.ResourceAction.java
/** * ?./*from www . j a v a2s . c om*/ */ public void tree() throws Exception { List<TreeNode> treeNodes = Lists.newArrayList(); try { List<TreeNode> titleList = Lists.newArrayList(); // "------"?"------" if (!StringUtils.isBlank(selectType)) { SelectType s = SelectType.getSelectTypeValue(selectType); if (s != null) { TreeNode selectTreeNode = new TreeNode("", s.getDescription()); titleList.add(selectTreeNode); } } treeNodes = resourceManager.getResourceTree(null, true); List<TreeNode> unionList = ListUtils.union(titleList, treeNodes); Struts2Utils.renderJson(unionList); } catch (Exception e) { throw e; } }
From source file:com.eryansky.web.sys.DictionaryAction.java
/** * combobox?./* w w w .j a v a 2 s. c o m*/ */ @SuppressWarnings("unchecked") public void combobox() throws Exception { try { List<Combobox> titleList = Lists.newArrayList(); // combobox "------"?"------" if (!StringUtils.isBlank(selectType)) { SelectType s = SelectType.getSelectTypeValue(selectType); if (s != null) { Combobox selectCombobox = new Combobox("", s.getDescription()); titleList.add(selectCombobox); } } List<Combobox> cList = dictionaryManager.getByDictionaryTypeCode(dictionaryTypeCode); List<Combobox> unionList = ListUtils.union(titleList, cList); Struts2Utils.renderJson(unionList); } catch (Exception e) { throw e; } }
From source file:com.strider.datadefender.DatabaseDiscoverer.java
@SuppressWarnings("unchecked") public List<MatchMetaData> discover(final IDBFactory factory, final Properties dataDiscoveryProperties, String vendor) throws ParseException, DatabaseDiscoveryException { log.info("Data discovery in process"); // Get the probability threshold from property file final double probabilityThreshold = parseDouble( dataDiscoveryProperties.getProperty("probability_threshold")); String calculate_score = dataDiscoveryProperties.getProperty("score_calculation"); if (CommonUtils.isEmptyString(calculate_score)) { calculate_score = "false"; }// w w w.ja va2 s.c o m log.info("Probability threshold [" + probabilityThreshold + "]"); // Get list of models used in data discovery final String models = dataDiscoveryProperties.getProperty("models"); modelList = models.split(","); log.info("Model list [" + Arrays.toString(modelList) + "]"); List<MatchMetaData> finalList = new ArrayList<>(); for (final String model : modelList) { log.info("********************************"); log.info("Processing model " + model); log.info("********************************"); final Model modelPerson = createModel(dataDiscoveryProperties, model); matches = discoverAgainstSingleModel(factory, dataDiscoveryProperties, modelPerson, probabilityThreshold, vendor); finalList = ListUtils.union(finalList, matches); } final DecimalFormat decimalFormat = new DecimalFormat("#.##"); log.info("List of suspects:"); log.info(String.format("%20s %20s %20s %20s", "Table*", "Column*", "Probability*", "Model*")); final Score score = new Score(); int highRiskColumns = 0; int rowCount = 0; for (final MatchMetaData data : finalList) { // Row count if (YES.equals(calculate_score)) { log.debug("Skipping table rowcount..."); rowCount = ReportUtil.rowCount(factory, data.getTableName(), Integer.valueOf(dataDiscoveryProperties.getProperty("limit"))); } // Getting 5 sample values final List<String> sampleDataList = ReportUtil.sampleData(factory, data.getTableName(), data.getColumnName()); // Output log.info("Column : " + data.toString()); log.info(CommonUtils.fixedLengthString('=', data.toString().length() + 30)); log.info("Number of rows in the table: " + rowCount); log.info("Score : " + score.columnScore(rowCount)); log.info("Model : " + data.getModel()); if (YES.equals(calculate_score)) { log.info("Number of rows in the table : " + rowCount); log.info("Score : " + score.columnScore(rowCount)); } else { log.info("Number of rows in the table : N/A"); log.info("Score : N/A"); } log.info("Sample data"); log.info(CommonUtils.fixedLengthString('-', 11)); for (final String sampleData : sampleDataList) { log.info(sampleData); } log.info(""); final List<Probability> probabilityList = data.getProbabilityList(); Collections.sort(probabilityList, Comparator.comparingDouble(Probability::getProbabilityValue).reversed()); int y = 0; if (data.getProbabilityList().size() >= 5) { y = 5; } else { y = data.getProbabilityList().size(); } for (int i = 0; i < y; i++) { final Probability p = data.getProbabilityList().get(i); log.info(p.getSentence() + ":" + p.getProbabilityValue()); } log.info(""); // Score calculation is evaluated with score_calculation parameter if (YES.equals(calculate_score) && score.columnScore(rowCount).equals("High")) { highRiskColumns++; } } // Only applicable when parameter table_rowcount=yes otherwise score calculation should not be done if (YES.equals(calculate_score)) { log.info("Overall score: " + score.dataStoreScore()); log.info(""); if ((finalList != null) && (finalList.size() > 0)) { log.info("============================================"); final int threshold_count = Integer.valueOf(dataDiscoveryProperties.getProperty("threshold_count")); if (finalList.size() > threshold_count) { log.info("Number of PI [" + finalList.size() + "] columns is higher than defined threashold [" + threshold_count + "]"); } else { log.info("Number of PI [" + finalList.size() + "] columns is lower or equal than defined threashold [" + threshold_count + "]"); } final int threshold_highrisk = Integer .valueOf(dataDiscoveryProperties.getProperty("threshold_highrisk")); if (highRiskColumns > threshold_highrisk) { log.info("Number of High risk PI [" + highRiskColumns + "] columns is higher than defined threashold [" + threshold_highrisk + "]"); } else { log.info("Number of High risk PI [" + highRiskColumns + "] columns is lower or equal than defined threashold [" + threshold_highrisk + "]"); } } } else { log.info("Overall score: N/A"); } log.info("matches: " + matches.toString()); return matches; }
From source file:com.lushapp.modules.sys.web.DictionaryController.java
/** * combotree?./*w w w.j a v a 2 s. co m*/ */ @SuppressWarnings("unchecked") @RequestMapping(value = { "combotree" }) @ResponseBody public List<TreeNode> combotree(@ModelAttribute("model") Dictionary dictionary, String selectType) throws Exception { List<TreeNode> titleList = Lists.newArrayList(); // "------"?"------" if (!StringUtils.isBlank(selectType)) { SelectType s = SelectType.getSelectTypeValue(selectType); if (s != null) { TreeNode selectTreeNode = new TreeNode("", s.getDescription()); titleList.add(selectTreeNode); } } List<TreeNode> treeNodes = dictionaryManager.getByDictionaryTypeCode(dictionary, dictionary.getDictionaryTypeCode(), dictionary.getId(), false); List<TreeNode> unionList = ListUtils.union(titleList, treeNodes); return unionList; }
From source file:br.com.webbudget.domain.model.service.PeriodDetailService.java
/** * Metodo que monta o modelo do grafico de consumo por dia no periodo * * @param period o periodo//from www. j a va 2 s.c o m * @return o model para a view */ public LineChartModel bulidDailyChart(FinancialPeriod period) { // lista receitas e despesas do periodo final List<Movement> revenues = this.listMovementsFrom(period, MovementClassType.IN); final List<Movement> expenses = this.listMovementsFrom(period, MovementClassType.OUT); // agrupamos pelas datas das despesas e receitas final List<LocalDate> payDates = this.groupPaymentDates(ListUtils.union(revenues, expenses)); // monta o grafico de linhas final LineChartModel model = new LineChartModel(); // dados de despesas final LineChartDatasetBuilder<BigDecimal> expensesBuilder = new LineChartDatasetBuilder<>() .filledByColor("rgba(255,153,153,0.2)").withStrokeColor("rgba(255,77,77,1)") .withPointColor("rgba(204,0,0,1)").withPointStrokeColor("#fff").withPointHighlightFillColor("#fff") .withPointHighlightStroke("rgba(204,0,0,1)"); // dados de receitas final LineChartDatasetBuilder<BigDecimal> revenuesBuilder = new LineChartDatasetBuilder<>() .filledByColor("rgba(140,217,140,0.2)").withStrokeColor("rgba(51,153,51,1)") .withPointColor("rgba(45,134,45,1)").withPointStrokeColor("#fff") .withPointHighlightFillColor("#fff").withPointHighlightStroke("rgba(45,134,45,1)"); // para cada data de pagamento, printa o valor no dataset payDates.stream().forEach(payDate -> { model.addLabel(DateTimeFormatter.ofPattern("dd/MM").format(payDate)); final BigDecimal expensesTotal = expenses.stream() .filter(movement -> movement.getPaymentDate().equals(payDate)).map(Movement::getValue) .reduce(BigDecimal.ZERO, BigDecimal::add); final BigDecimal revenuesTotal = revenues.stream() .filter(movement -> movement.getPaymentDate().equals(payDate)).map(Movement::getValue) .reduce(BigDecimal.ZERO, BigDecimal::add); expensesBuilder.andData(expensesTotal); revenuesBuilder.andData(revenuesTotal); }); // joga os datasets no model model.addDataset(revenuesBuilder.build()); model.addDataset(expensesBuilder.build()); return model; }