Example usage for org.apache.commons.collections ListUtils union

List of usage examples for org.apache.commons.collections ListUtils union

Introduction

In this page you can find the example usage for org.apache.commons.collections ListUtils union.

Prototype

public static List union(final List list1, final List list2) 

Source Link

Document

Returns a new list containing the second list appended to the first list.

Usage

From source file:com.eryansky.service.base.ResourceManager.java

/**
 * ??.//from   w  ww  .  ja v a  2 s . c  om
 * <br/>??? ???
 * @param entity ?
 * @throws DaoException
 * @throws SystemException
 * @throws ServiceException
 */
@CacheEvict(value = { CacheConstants.RESOURCE_USER_RESOURCE_TREE_CACHE,
        CacheConstants.RESOURCE_USER_AUTHORITY_URLS_CACHE,
        CacheConstants.RESOURCE_USER_MENU_TREE_CACHE }, allEntries = true)
public void saveResource(Resource entity) throws DaoException, SystemException, ServiceException {
    logger.debug(":{}",
            CacheConstants.RESOURCE_USER_RESOURCE_TREE_CACHE + ","
                    + CacheConstants.RESOURCE_USER_AUTHORITY_URLS_CACHE + ","
                    + CacheConstants.RESOURCE_USER_MENU_TREE_CACHE);
    Assert.notNull(entity, "?[entity]!");
    this.saveEntity(entity);
    if (entity.getType() != null && ResourceType.function.getValue().equals(entity.getType())) {
        List<Resource> subResources = entity.getSubResources();
        while (!Collections3.isEmpty(subResources)) {
            Iterator<Resource> iterator = subResources.iterator();
            while (iterator.hasNext()) {
                Resource subResource = iterator.next();
                subResource.setType(ResourceType.function.getValue());
                iterator.remove();
                subResources = ListUtils.union(subResources, subResource.getSubResources());
                super.update(subResource);
            }
        }
    }
}

From source file:com.lushapp.modules.sys.web.DictionaryController.java

/**
 * combobox?.//  ww w  . java2  s. c  om
 *
 * @param selectType
 * @param dictionaryTypeCode ?
 * @return
 * @throws Exception
 */
@SuppressWarnings("unchecked")
@RequestMapping(value = { "combobox" })
@ResponseBody
public List<Combobox> combobox(String selectType, String dictionaryTypeCode) throws Exception {
    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);
    return unionList;
}

From source file:com.cybernostics.jsp2thymeleaf.api.elements.JspTagElementConverter.java

@Override
protected List<Attribute> convertAttributes(JspElementContext node, JSPElementNodeConverter context) {
    final Map<String, String> emptyMap = new HashMap<>();
    Map<String, Object> attMap = new HashMap<>();
    final List<Attribute> sourceAtributes = super.convertAttributes(node, context);
    final List<Attribute> attributes = sourceAtributes.stream().filter((eachAttribute) -> {
        attMap.put(eachAttribute.getName(), eachAttribute.getValue());
        return !attributesToRemove.contains(eachAttribute.getName());
    }).collect(Collectors.toList());

    Map<String, String> childMap = childAttributeSource.map(i -> i.apply(nodeContext(node, context)))
            .orElse(emptyMap);/*w w w  . j a  v a2  s . co  m*/

    if (!childMap.isEmpty()) {
        attMap.put("_childAtts", childMap);
    }

    attMap.put("__tagname__", convertsTag);

    final List<Attribute> createdAttributes = newAttributeBuilders.stream()
            .flatMap(eachBuilder -> eachBuilder.buildNewAttributes(attMap).stream())
            .collect(Collectors.toList());

    for (Attribute createdAttribute : createdAttributes) {
        ActiveNamespaces.add(createdAttribute.getNamespace());
    }

    final List<Attribute> allAttributes = ListUtils.union(createdAttributes, attributes);
    if (isElementEmbeddedInAttribute(node)) {
        if (this.attributeToUseWhenQuoted.isPresent()) {
            String attributeToUse = attributeToUseWhenQuoted.get();
            allAttributes.stream().filter(it -> it.getName().equals(attributeToUse))
                    .forEach(it -> it.setName("data-replace-parent-attribute-value"));
        }

    }
    return allAttributes;
}

From source file:com.lushapp.modules.sys.web.ResourceController.java

/**
 * ?./*from   www . ja  va  2s . c  o m*/
 */
@SuppressWarnings("unchecked")
@RequestMapping(value = { "parentResource" })
@ResponseBody
public List<TreeNode> parentResource(@ModelAttribute("model") Resource resource, String selectType) {
    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(resource.getId(), false);
    List<TreeNode> unionList = ListUtils.union(titleList, treeNodes);
    return unionList;
}

From source file:com.eryansky.modules.sys.web.DictionaryController.java

/**
 * combobox?/*w  w  w.  ja va  2  s.  c  o m*/
 *
 * @param selectType {@link SelectType}
 * @param dictionaryCode ??
 * @return
 * @throws Exception
 */
@SuppressWarnings("unchecked")
@RequestMapping(value = { "combobox" })
@ResponseBody
public List<Combobox> combobox(String selectType, String dictionaryCode) throws Exception {
    List<Combobox> titleList = Lists.newArrayList();
    Combobox selectCombobox = SelectType.combobox(selectType);
    if (selectCombobox != null) {
        titleList.add(selectCombobox);
    }

    List<Combobox> cList = dictionaryItemService.getByDictionaryCode(dictionaryCode);
    List<Combobox> unionList = ListUtils.union(titleList, cList);
    return unionList;
}

From source file:com.eryansky.modules.sys.web.ResourceController.java

/**
 * ?./*from   ww  w  .ja  v a2 s .  c  o m*/
 */
@SuppressWarnings("unchecked")
@RequestMapping(value = { "parent" })
@ResponseBody
public List<TreeNode> parent(@ModelAttribute("model") Resource resource, String selectType) {
    List<TreeNode> treeNodes = null;
    List<TreeNode> titleList = Lists.newArrayList();
    TreeNode selectTreeNode = SelectType.treeNode(selectType);
    if (selectTreeNode != null) {
        titleList.add(selectTreeNode);
    }
    treeNodes = resourceManager.findTreeNodeResourcesWithExclude(resource.getId());
    List<TreeNode> unionList = ListUtils.union(titleList, treeNodes);
    return unionList;
}

From source file:com.eryansky.modules.sys.web.OrganController.java

/**
 *
 * @param selectType//  w  ww . j a v a 2 s. co m
 * @param dataScope {@link DataScope}
 * @return
 * @throws Exception
 */
@RequestMapping(value = { "tree" })
@ResponseBody
public List<TreeNode> tree(String parentId, String selectType, String dataScope,
        @RequestParam(value = "cascade", required = false, defaultValue = "false") Boolean cascade)
        throws Exception {
    List<TreeNode> treeNodes = null;
    List<TreeNode> titleList = Lists.newArrayList();
    TreeNode selectTreeNode = SelectType.treeNode(selectType);
    if (selectTreeNode != null) {
        titleList.add(selectTreeNode);
    }
    SessionInfo sessionInfo = SecurityUtils.getCurrentSessionInfo();
    String _parentId = parentId;
    if (StringUtils.isBlank(parentId)) {
        String organId = sessionInfo.getLoginOrganId();
        if (SecurityUtils.isCurrentUserAdmin()
                || (StringUtils.isNotBlank(dataScope) && dataScope.equals(DataScope.ALL.getValue()))) {
            organId = null;
        } else if ((StringUtils.isNotBlank(dataScope)
                && dataScope.equals(DataScope.COMPANY_AND_CHILD.getValue()))) {
            User user = userManager.loadById(sessionInfo.getUserId());
            organId = user.getCompanyId();

        } else if ((StringUtils.isNotBlank(dataScope)
                && dataScope.equals(DataScope.OFFICE_AND_CHILD.getValue()))) {
            User user = userManager.loadById(sessionInfo.getUserId());
            organId = user.getOfficeId();
        }
        _parentId = organId;
    }

    treeNodes = organManager.findOrganTree(_parentId, true, cascade);
    List<TreeNode> unionList = ListUtils.union(titleList, treeNodes);
    return unionList;
}

From source file:com.eryansky.web.base.ResourceAction.java

/**
 * ?.//from   ww  w  .  j  av  a2s  . co m
 */
@SuppressWarnings("unchecked")
public void parentResource() throws Exception {
    prepareModel();
    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(model.getId(), true);
        List<TreeNode> unionList = ListUtils.union(titleList, treeNodes);
        Struts2Utils.renderJson(unionList);
    } catch (Exception e) {
        throw e;
    }
}

From source file:Bean.CAT.ModifTestBean.java

public void unirListas() throws IOException, FileNotFoundException, ClassNotFoundException {

    System.out.println(" ingresando unir listas");
    ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext()
            .getContext();//  w w  w  .  j  a  v a  2 s .c  o  m
    String pathTermNuevos = (String) servletContext.getRealPath("/") + "/Terminos/NuevosTermDiccGlobal.obj";
    String pathTermNuevosAsoc = (String) servletContext.getRealPath("/")
            + "/Terminos/NuevosTermAsocDiccGlobal.obj";
    File f = new File(pathTermNuevos);
    File e = new File(pathTermNuevosAsoc);
    // if(f.exists() && !f.isDirectory()) { 

    if (f.exists() && e.exists()) {

        System.out.println(" la lista de cambios ya existe por lo que se deserializarn");
        listNuevosTermAsocDiccGlobal = deserializarNuevosTermAsocDiccGlobal();
        listNuevosTermDiccGlobal = deserializarlistNuevosTermDiccGlobal();

    }

    List<TerminoLamina>[] terminosTempGlobal = new ArrayList[10];
    System.out.println("comenzando union de listas asoc");
    for (int i = 0; i < 10; i++) {
        System.out.println("union " + i);
        List<TerminoLamina> terminosTemp = ListUtils.union(listNuevosTermAsocDicc[i],
                listNuevosTermAsocDiccGlobal[i]);
        terminosTempGlobal[i] = terminosTemp;

    }
    System.out.println("comenzando union de listas nuevos terminos");
    List<TerminoLamina>[] terminosTempGlobal2 = new ArrayList[10];
    for (int i = 0; i < 10; i++) {
        System.out.println("union " + i);
        List<TerminoLamina> terminosTemp2 = ListUtils.union(listNuevosTermDicc[i], listNuevosTermDiccGlobal[i]);
        terminosTempGlobal2[i] = terminosTemp2;

    }
    listNuevosTermAsocDiccGlobal = terminosTempGlobal;
    listNuevosTermDiccGlobal = terminosTempGlobal2;

    //serializamos los cambios en las listas del diccionario
    serializarListasCambiosDiccionario();
    System.out.println(" se serializaron las listas globales de cambios en diccionario");

}

From source file:hudson.plugins.cloneworkspace.CloneWorkspaceSCM.java

public List<String> getParentAndParamList() {
    return ListUtils.union(getDescriptor().getEligibleParents(), getParameterList());
}