Example usage for java.util List removeAll

List of usage examples for java.util List removeAll

Introduction

In this page you can find the example usage for java.util List removeAll.

Prototype

boolean removeAll(Collection<?> c);

Source Link

Document

Removes from this list all of its elements that are contained in the specified collection (optional operation).

Usage

From source file:com.yahoo.sql4d.sql4ddriver.Joiner4All.java

/**
 * Generate a Tuple <A, B>//w w w.  j a v  a 2s .c  o  m
 * A = list of field names
 * B = map of <joinFeild, rowList> from jsonArray.
 * @param timestamp
 * @param jsonAllRows
 * @param joinFields 
 * @param requestType 
 * @param action 
 */
@Override
protected void extractAndTakeAction(String timestamp, JSONArray jsonAllRows, List<String> joinFields,
        RequestType requestType, ActionType action) {
    Map<Object, List<Object>> newBaseAllRows = new LinkedHashMap<>();
    JSONObject eachRow = null;
    for (int i = 0; i < jsonAllRows.length(); i++) {
        JSONObject jsonItem = jsonAllRows.getJSONObject(i);
        eachRow = dataItemAt(jsonItem, requestType, action);
        String actualTimestamp = timestamp;
        if (timestamp == null) {
            if (requestType == RequestType.SELECT) {
                actualTimestamp = eachRow.optString("timestamp");
                // Because the timestamp is within each row remove them once you extract it.
                eachRow.remove("timestamp");
            } else {
                actualTimestamp = jsonItem.optString("timestamp");
            }
        }
        Tuple2<Object, List<Object>> row = mapPkToRow(actualTimestamp, eachRow, joinFields);
        Object pk = row._1();// Primary key.
        List<Object> rowVal = row._2();
        if (action == ActionType.FIRST_CUT) {// First cut (no join).
            baseAllRows.put(pk, rowVal);
        } else {// Some Join action.
            if (baseAllRows.containsKey(pk)) {// If any item in set B exist in set A.
                rowVal.removeAll(splitCompositeKeys(pk.toString()));// Remove key(which is already available in baseAllRows)
                if (!joinFields.contains("timestamp")) {// If join field is not "timestamp" then remove timestamp data value from to be joined set.
                    rowVal.remove(0);// Because the 1st field is always timestamp.(See extractKeyAndRow() method)
                }
                if (action == ActionType.JOIN || action == ActionType.RIGHT_JOIN) {
                    newBaseAllRows.put(pk, baseAllRows.remove(pk));// Remove from existing map and add to new map.
                    newBaseAllRows.get(pk).addAll(rowVal);// Update the new map with partial to be joined data.
                } else if (action == ActionType.LEFT_JOIN) {// Left join
                    baseAllRows.get(pk).addAll(rowVal);
                }
            } else {// For right join we still need to continue with each row in set B.
                if (action == ActionType.RIGHT_JOIN) {// Right join
                    newBaseAllRows.put(pk, rowVal);
                }
            }
        }
        if (i == 0) {// Fill headers (only once)
            fillHeaders(eachRow, joinFields, action);
        }
    }
    if (!newBaseAllRows.isEmpty()) {// For join and right join.
        baseAllRows = newBaseAllRows;
    }
}

From source file:de.innovationgate.wgpublisher.design.sync.FileContainerDeployment.java

public void performUpdate(WGDatabase db)
        throws IOException, WGException, InstantiationException, IllegalAccessException, WGDesignSyncException {

    FileObject codeFile = getCodeFile();
    // Check if file has been deleted in the meantime
    if (!codeFile.exists()) {
        return;//from   w w  w .  j  ava  2s . com
    }

    WGFileContainer con = (WGFileContainer) db.getDocumentByDocumentKey(getDocumentKey());
    if (con == null) {
        WGDocumentKey docKey = new WGDocumentKey(getDocumentKey());
        con = db.createFileContainer(docKey.getName());
        con.save();
    }

    // Find new and updated files
    FileObject[] filesArray = codeFile.getChildren();
    if (filesArray == null) {
        throw new WGDesignSyncException("Cannot collect files from directory '"
                + codeFile.getName().getPathDecoded() + "'. Please verify directory existence.");
    }

    List<FileObject> files = new ArrayList<FileObject>(Arrays.asList(filesArray));
    Collections.sort(files, new FileNameComparator());

    FileObject file;
    Map existingFiles = new HashMap();
    for (int i = 0; i < files.size(); i++) {
        file = (FileObject) files.get(i);
        if (isExcludedFileContainerFile(file)) {
            continue;
        }

        ContainerFile containerFile = getContainerFile(file);
        if (containerFile != null) {
            if (existingFiles.containsKey(containerFile.getName())) {
                // Possible in case-sensitive file systems. Another file of the same name with another case is in the dir.
                continue;
            }

            if (file.getContent().getLastModifiedTime() != containerFile.getTimestamp()) {
                doRemoveFile(con, file.getName().getBaseName());
                doSaveDocument(con);
                doAttachFile(con, file);
                doSaveDocument(con);
                containerFile.setTimestamp(file.getContent().getLastModifiedTime());
            }
        } else {
            containerFile = new ContainerFile(file);
            if (con.hasFile(file.getName().getBaseName())) {
                doRemoveFile(con, file.getName().getBaseName());
                doSaveDocument(con);
            }
            doAttachFile(con, file);
            doSaveDocument(con);
        }
        existingFiles.put(containerFile.getName(), containerFile);
    }

    // Remove deleted files from container
    _files = existingFiles;
    List fileNamesInContainer = WGUtils.toLowerCase(con.getFileNames());
    fileNamesInContainer.removeAll(existingFiles.keySet());
    Iterator deletedFiles = fileNamesInContainer.iterator();
    while (deletedFiles.hasNext()) {
        con.removeFile((String) deletedFiles.next());
        con.save();
    }

    // Update metadata and save
    FCMetadata metaData = (FCMetadata) readMetaData();
    metaData.writeToDocument(con);
    con.save();
    FileObject metadataFile = getMetadataFile();
    if (metadataFile.exists()) {
        _timestampOfMetadataFile = metadataFile.getContent().getLastModifiedTime();
    }

    // We wont do this here, since this would rebuild all ContainerFiles, which is not neccessary
    // Instead we have updated just the metadata file timestamp
    // resetUpdateInformation();
}

From source file:fr.norad.visuwall.plugin.hudson.HudsonConnection.java

@Override
public List<String> findViews() {
    checkConnected();//  w  w w  .  ja v a2s .co  m
    List<String> views = hudson.findViews();
    views.removeAll(DEFAULT_VIEWS);
    return views;
}

From source file:eu.europa.ec.fisheries.uvms.rules.service.bean.RulesActivityServiceBean.java

private Map<ActivityTableType, List<IDType>> collectAllIdsFromMessage(FLUXFAReportMessage request) {
    Map<ActivityTableType, List<IDType>> idsmap = new EnumMap<>(ActivityTableType.class);
    idsmap.put(ActivityTableType.RELATED_FLUX_REPORT_DOCUMENT_ENTITY, new ArrayList<IDType>());
    if (request == null) {
        return idsmap;
    }//from   ww  w  .  jav a  2s .  com
    // FLUXReportDocument IDs
    FLUXReportDocument fluxReportDocument = request.getFLUXReportDocument();
    if (fluxReportDocument != null && CollectionUtils.isNotEmpty(fluxReportDocument.getIDS())) {
        idsmap.put(ActivityTableType.FLUX_REPORT_DOCUMENT_ENTITY, fluxReportDocument.getIDS());
    }
    // FAReportDocument.RelatedFLUXReportDocument IDs and ReferencedID
    List<FAReportDocument> faReportDocuments = request.getFAReportDocuments();
    if (CollectionUtils.isNotEmpty(faReportDocuments)) {
        for (FAReportDocument faRepDoc : faReportDocuments) {
            FLUXReportDocument relatedFLUXReportDocument = faRepDoc.getRelatedFLUXReportDocument();
            if (relatedFLUXReportDocument != null) {
                List<IDType> idTypes = new ArrayList<>();
                idTypes.addAll(relatedFLUXReportDocument.getIDS());
                idTypes.add(relatedFLUXReportDocument.getReferencedID());
                idTypes.removeAll(Collections.singletonList(null));
                idsmap.get(ActivityTableType.RELATED_FLUX_REPORT_DOCUMENT_ENTITY).addAll(idTypes);
            }
        }
    }
    return idsmap;
}

From source file:io.fabric8.kubernetes.api.KubernetesHelper.java

/**
 * Removes empty pods returned by Kubernetes
 *///from  w w  w .  j  a va  2 s.  c  o m
public static void removeEmptyPods(PodList podSchema) {
    List<Pod> list = notNullList(podSchema.getItems());

    List<Pod> removeItems = new ArrayList<Pod>();

    for (Pod pod : list) {
        if (StringUtils.isEmpty(getId(pod))) {
            removeItems.add(pod);

        }
    }
    list.removeAll(removeItems);
}

From source file:com.inkubator.hrm.web.appraisal.CompetencyGroupFormController.java

private AppraisalCompetencyGroupModel getModelFromEntity(AppraisalCompetencyGroup competencyGroup)
        throws Exception {
    AppraisalCompetencyGroupModel model = new AppraisalCompetencyGroupModel();
    model.setId(competencyGroup.getId());
    model.setCode(competencyGroup.getCode());
    model.setName(competencyGroup.getName());
    model.setDescription(competencyGroup.getDescription());
    model.setCompetencyTypeId(competencyGroup.getCompetencyType().getId());

    List<KlasifikasiKerja> sourceList = klasifikasiKerjaService.getAllData();
    List<KlasifikasiKerja> targetList = Lambda.extract(competencyGroup.getKlasifikasiKerjas(),
            Lambda.on(AppraisalCompetencyGroupKlasifikasiKerja.class).getKlasifikasiKerja());
    sourceList.removeAll(targetList);

    model.getDualListModelKlasifikasiKerja().setSource(sourceList);
    model.getDualListModelKlasifikasiKerja().setTarget(targetList);

    return model;
}

From source file:fr.gael.dhus.server.ftp.service.DHuSVFSService.java

/**
 * Computes the collection name within the virtual path
 * //  w  ww .j a v a 2 s  .c om
 * @param path
 * @return
 */
public List<FtpFile> listFiles(String path, User user) {
    fr.gael.dhus.database.object.User dhus_user = getDhusUserFromFtpUser(user);
    Collection col = getCollectionByVPath(path, user);
    List<Product> viewableProducts = new ArrayList<Product>();

    logger.debug("List path \"" + path + "\" -> Collection : " + ((col == null) ? "null" : col.getName()));

    // Case of no collection matches the path
    if (col == null)
        return ImmutableList.of();

    List<FtpFile> files = new ArrayList<FtpFile>();
    List<Collection> viewableChildren = collectionDao.getSubCollections(col.getId(), dhus_user);
    List<Collection> notViewableChildren = collectionDao.getAllSubCollection(col);
    notViewableChildren.removeAll(viewableChildren);

    // Display collections
    for (Collection c : viewableChildren) {
        String prefix = path;

        if (!path.equals("/"))
            prefix = path + "/";

        files.add(new DHuSFtpCollection(prefix + c.getName(), this, user));
    }

    for (Collection c : notViewableChildren) {
        if (collectionDao.hasViewableCollection(c, dhus_user)) {
            String prefix = path;

            if (!path.equals("/"))
                prefix = path + "/";

            files.add(new DHuSFtpCollection(prefix + c.getName(), this, user));
        }
    }

    // Sort collections by name
    Collections.sort(files, new Comparator<FtpFile>() {
        @Override
        public int compare(FtpFile o1, FtpFile o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });

    // Display no collection products
    if (collectionDao.isRoot(col)) {
        List<Product> products = productDao.getNoCollectionProducts(dhus_user);
        // ArrayList<FtpFile> noCollectionProduct = new ArrayList<FtpFile> ();

        for (Product p : products) {
            //   noCollectionProduct.add (new DHuSFtpProduct (path, p, this));
            viewableProducts.add(p);
        }
        // files.addAll (noCollectionProduct);
    }

    // Display collection's products
    List<fr.gael.dhus.database.object.User> users = collectionDao.getAuthorizedUsers(col);
    if (cfgManager.isDataPublic() || users.contains(dhus_user) || users.contains(userDao.getPublicData())) {
        List<Product> products = getViewableProductOfCollection(col, user);
        for (Product p : products) {
            // files.add (new DHuSFtpProduct (path, p, this));
            viewableProducts.add(p);
            logger.debug("   Child product : " + p.getIdentifier());
        }
    }

    // Display product order by date (.contentDate)
    if (viewableProducts.isEmpty())
        return files;
    files.add(new DHuSFtpFile(path + "/.contentDate", viewableProducts, DHuSFtpFileType.CONTENT_DATE, this,
            user));

    return files;
}

From source file:de.metas.procurement.webui.ui.model.ProductQtyReportRepository.java

public List<Product> getProductsNotContractedNorFavorite() {
    final List<Product> result = new ArrayList<>(getProductsNotContracted());
    result.removeAll(getProductsFavorite());
    return result;
}

From source file:org.shareok.data.lawlibrary.LawLibDataHandlerImpl.java

private List<String> getUnmatchedFileList() {
    List<String> unmatchedFileList = new ArrayList<String>();
    for (String fileName : pdfFileList) {
        unmatchedFileList.add(fileName);
    }/*  ww w. j a  v a 2 s .  co m*/
    unmatchedFileList.removeAll(matchedPdfFileList);
    return unmatchedFileList;
}

From source file:com.mycompany.controller.catalog.CategoryController.java

private List<?> getSizeFacets(ModelAndView model, List<SearchFacetDTO> searchFacets) {
    List<SearchFacetDTO> sizeFacets = new ArrayList<SearchFacetDTO>();

    for (SearchFacetDTO searchFacet : searchFacets) {
        String label = searchFacet.getFacet().getLabel();

        if (label.equals("euSize") || label.equals("usSize") || label.equals("ukSize")) {
            sizeFacets.add(searchFacet);
        }/*from  w w w .j  a v  a  2 s  .  co  m*/
    }

    searchFacets.removeAll(sizeFacets);

    return sizeFacets;
}