List of usage examples for org.apache.commons.io.filefilter WildcardFileFilter accept
public boolean accept(File file)
From source file:com.mucommander.ui.viewer.text.FileType.java
public boolean checkFile(File file) { for (WildcardFileFilter filter : fileFilters) { if (filter.accept(file)) { return true; }/* ww w . j a v a 2s . c om*/ } return false; }
From source file:gov.nih.nci.ncicb.tcga.dcc.qclive.common.action.validation.RnaSeqSdrfValidator.java
/** * Return <code>true</code> if references to all required files for Level 3 data are present, <code>false</code> otherwise. * <p/>/*from w w w . ja v a 2s.c o m*/ * For each aliquot represented in the SDRF, if there is Level 3 data, * then there must be a reference to a Level 3 gene file, an exon file, and a splice junction file. Wig files are optional. * * @param context the qclive context * @param sdrfNavigator a {@link TabDelimitedContentNavigator} for the SDRF * @return <code>true</code> if references to all required files for Level 3 data are present, <code>false</code> otherwise */ protected boolean validateDataFilesForBarcodes(final QcContext context, final TabDelimitedContentNavigator sdrfNavigator) { boolean isValid = true; // first build a map of all the barcodes that have each type of file final Map<String, String> geneFileForBarcodes = new HashMap<String, String>(); final Map<String, String> exonFileForBarcodes = new HashMap<String, String>(); final Map<String, String> junctionFileForBarcodes = new HashMap<String, String>(); final Map<String, String> wigFileForBarcodes = new HashMap<String, String>(); // rnaseqv2 files final Map<String, String> rsemGeneNormalized = new HashMap<String, String>(); final Map<String, String> rsemGeneResults = new HashMap<String, String>(); final Map<String, String> rsemIsoformNormalized = new HashMap<String, String>(); final Map<String, String> rsemIsoformResults = new HashMap<String, String>(); // List to store the aliquots that will need to be checked for required and optional files final List<String> aliquotsWithLevel3Data = new ArrayList<String>(); final Integer extractNameIndex = sdrfNavigator.getHeaderIDByName(EXTRACT_NAME_COLUMN_NAME); final List<Integer> dataFileIndexes = sdrfNavigator.getHeaderIdsForName(DERIVED_DATA_FILE_COLUMN_NAME); for (int i = 1; i < sdrfNavigator.getNumRows(); i++) { final String extractName = sdrfNavigator.getValueByCoordinates(extractNameIndex, i); for (final Integer dataFileIndex : dataFileIndexes) { final Map<String, Integer> commentColumns = getFileCommentColumns(sdrfNavigator, dataFileIndex); final Integer dataLevelColumn = commentColumns.get(COMMENT_DATA_LEVEL); final String dataLevel = sdrfNavigator.getValueByCoordinates(dataLevelColumn, i); if ("Level 3".equals(dataLevel)) { aliquotsWithLevel3Data.add(extractName); final String filename = sdrfNavigator.getValueByCoordinates(dataFileIndex, i); final WildcardFileFilter exonFilter = new WildcardFileFilter( Arrays.asList(RNASeqExonFileValidator.EXON_FILE_EXTENSION.split(","))); final WildcardFileFilter junctionFilter = new WildcardFileFilter( Arrays.asList(RNASeqJunctionFileValidator.JUNCTION_FILE_EXTENSION.split(","))); if (filename.endsWith(RNASeqGeneFileValidator.GENE_FILE_EXTENSION)) { geneFileForBarcodes.put(extractName, filename); } else if (exonFilter.accept(new File(filename))) { exonFileForBarcodes.put(extractName, filename); } else if (junctionFilter.accept(new File(filename))) { junctionFileForBarcodes.put(extractName, filename); } else if (filename.endsWith("wig")) { wigFileForBarcodes.put(extractName, filename); } else if (filename .endsWith(RNASeqRSEMGeneNormalizedFileValidator.RSEM_GENE_NORMAL_FILE_EXTENSION)) { rsemGeneNormalized.put(extractName, filename); } else if (filename .endsWith(RNASeqRSEMIsoformFileValidator.RSEM_ISOFORM_RESULTS_FILE_EXTENSION)) { rsemIsoformResults.put(extractName, filename); } else if (filename.endsWith( RNASeqRSEMIsoformNormalizedFileValidator.RSEM_ISOFORM_NORMAL_FILE_EXTENSION)) { rsemIsoformNormalized.put(extractName, filename); } else if (filename .endsWith(RNASeqRSEMGeneResultsFileValidator.RSEM_GENES_RESULTS_FILE_EXTENSION)) { rsemGeneResults.put(extractName, filename); } else { // find Data Transformation Name for this file if (sdrfNavigator.getHeaders().get(dataFileIndex - 1) .equals(DATA_TRANSFORMATION_NAME_COLUMN_NAME)) { final String dataTransformationName = sdrfNavigator .getValueByCoordinates(dataFileIndex - 1, i); if (dataTransformationName.toLowerCase().contains("gene")) { context.addError(MessageFormat.format(MessagePropertyType.FILE_EXTENSION_ERROR, (i + NUM_HEADERS), dataFileIndex, "gene", RNASeqGeneFileValidator.GENE_FILE_EXTENSION)); geneFileForBarcodes.put(extractName, filename); isValid = false; } else if (dataTransformationName.toLowerCase().contains("exon")) { context.addError(MessageFormat.format(MessagePropertyType.FILE_EXTENSION_ERROR, (i + NUM_HEADERS), dataFileIndex, "exon", RNASeqExonFileValidator.EXON_FILE_EXTENSION)); exonFileForBarcodes.put(extractName, filename); isValid = false; } else if (dataTransformationName.toLowerCase().contains("splice")) { context.addError(MessageFormat.format(MessagePropertyType.FILE_EXTENSION_ERROR, (i + NUM_HEADERS), dataFileIndex, "splice", RNASeqJunctionFileValidator.JUNCTION_FILE_EXTENSION)); junctionFileForBarcodes.put(extractName, filename); isValid = false; } else if (dataTransformationName.toLowerCase().contains("coverage")) { context.addError(MessageFormat.format(MessagePropertyType.FILE_EXTENSION_ERROR, (i + NUM_HEADERS), dataFileIndex, "coverage", ".wig")); wigFileForBarcodes.put(extractName, filename); isValid = false; } else { context.addWarning(MessageFormat.format( MessagePropertyType.NO_TRANSFORMATION_NAME_FOR_FILE_WARNING, (i + NUM_HEADERS), dataFileIndex, filename)); } } else { context.addError(MessageFormat.format(MessagePropertyType.COLUMN_PRECEDENCE_ERROR, (i + NUM_HEADERS), dataFileIndex, DATA_TRANSFORMATION_NAME_COLUMN_NAME, DERIVED_DATA_FILE_COLUMN_NAME)); isValid = false; } } } } } /** * check to make sure that v1 and v2 have the correct files and do not overlap */ if (isRNASeqV2Archive(context.getArchive().getPlatform())) { isValid &= checkRnaSeqV2Files(aliquotsWithLevel3Data, context, exonFileForBarcodes, junctionFileForBarcodes, rsemGeneNormalized, rsemGeneResults, rsemIsoformNormalized, rsemIsoformResults); } else { isValid &= checkRnaSeqV1Files(aliquotsWithLevel3Data, context, geneFileForBarcodes, exonFileForBarcodes, junctionFileForBarcodes, wigFileForBarcodes); } return isValid; }
From source file:de.dkfz.roddy.client.fxuiclient.RoddyUIController.java
private void refillListOfDataSets() { //TODO Think about a good update mechanism Maybe a counter which only allowes update if the count fits? if (!Platform.isFxApplicationThread()) { Platform.runLater(new Runnable() { @Override//from w w w . ja v a2 s . c o m public void run() { refillListOfDataSets(); } }); return; } List<FXDataSetWrapper> newList; List<FXDataSetWrapper> acceptedItems = new LinkedList<>(); synchronized (currentListOfDataSets) { newList = new LinkedList<>(currentListOfDataSets); } try { WildcardFileFilter wff = new WildcardFileFilter(txtDataSetFilter.getText()); listViewDataSets.getSelectionModel().select(-1); listViewDataSets.getItems().clear(); for (FXDataSetWrapper dsw : newList) { if (wff.accept(new File(dsw.getId()))) { acceptedItems.add(dsw); } } listViewDataSets.getItems().addAll(acceptedItems); } catch (Exception e) { e.printStackTrace(); } }
From source file:io.fabric8.git.internal.GitDataStore.java
@Override public void exportProfiles(final String version, final String outputFileName, String wildcard) { final File outputFile = new File(outputFileName); outputFile.getParentFile().mkdirs(); final FileFilter filter; if (Strings.isNotBlank(wildcard)) { final WildcardFileFilter matcher = new WildcardFileFilter(wildcard); filter = new FileFilter() { @Override/*from ww w. jav a 2 s . com*/ public boolean accept(File file) { // match either the file or parent folder boolean answer = matcher.accept(file); if (!answer) { File parentFile = file.getParentFile(); if (parentFile != null) { answer = accept(parentFile); } } return answer; } }; } else { filter = null; } assertValid(); gitOperation(new GitOperation<String>() { public String call(Git git, GitContext context) throws Exception { checkoutVersion(git, version); return doExportProfiles(git, context, outputFile, filter); } }); }
From source file:de.dkfz.roddy.client.fxuiclient.RoddyUIController.java
private TreeItem<FXICCWrapper> isProcessable(TreeItem<FXICCWrapper> currentNode, boolean hideUnprocessable, String idFilter, String analysisIDFilter) { WildcardFileFilter wffID = new WildcardFileFilter(idFilter); WildcardFileFilter wffAID = new WildcardFileFilter(analysisIDFilter); FXICCWrapper cWrapper = currentNode.getValue(); boolean isVisible = false; TreeItem<FXICCWrapper> copyOfTreeItem = new TreeItem<>(currentNode.getValue()); copyOfTreeItem.setExpanded(currentNode.isExpanded()); // System.out.println(currentNode.getValue().getID() + " " + currentNode.getChildren().size()); //At first: Check, if the node has children and if one of those children is visible. for (TreeItem<FXICCWrapper> treeItem : currentNode.getChildren()) { TreeItem<FXICCWrapper> childVisible = isProcessable(treeItem, hideUnprocessable, idFilter, analysisIDFilter);/*from w w w . j a va 2 s .c o m*/ if (childVisible != null) copyOfTreeItem.getChildren().add(childVisible); } //If there are no visible children, then check the node itself. if (copyOfTreeItem.getChildren().size() == 0) { // System.out.println(cWrapper.getID()); //Is this a project node or an analysis node? isVisible = wffID.accept(new File(cWrapper.getID())); if (!isVisible) return null; if (cWrapper.isAnalysisWrapper()) { isVisible = wffAID.accept(new File(cWrapper.getAnalysisID())); if (!isVisible) return null; } else { if (hideUnprocessable) { isVisible = false; return null; } else { if (cWrapper.hasAnalyses()) return null; } } // if (isVisible && !cWrapper.hasAnalyses()) { // if (currentNode.getChildren().size() > 0) // isVisible = false; // } } else { isVisible = true; } if (isVisible) return copyOfTreeItem; return null; }
From source file:org.kalypso.kalypso1d2d.internal.importNet.Import2dImportWizard.java
private IImport2dImportOperation getOperation(final File smsFile) { for (final IImport2dImportOperation operation : m_operations) { final String filterExtension = operation.getFilterExtension(); final WildcardFileFilter wildcardFilter = new WildcardFileFilter(filterExtension); if (wildcardFilter.accept(smsFile)) return operation; }//from ww w .j a va2 s. c o m throw new IllegalStateException(); }
From source file:org.wisdom.mojo.npm.NpmRunnerMojo.java
/** * If the watcher has a filter set, creates a wildcard filter and test the file name against this filter. * * @param file is the file./* w w w . j ava 2s . com*/ * @return {@code true} if the file is accepted. */ @Override public boolean accept(File file) { WildcardFileFilter filter = new WildcardFileFilter(watchFilter); return filter.accept(file); }
From source file:org.wisdom.mojo.traceur.TraceurMojo.java
/** * Checks whether the given file should be compiled or not. * * @param file the file// w w w. j ava2 s. c om * @return {@code true} if the file matches the wildcard filter ({@code includes} parameter), * or if the file contains a comment with {@literal !ecmascript6} or {@literal !es6}. */ public boolean shouldBeCompiled(File file) { if (includes != null) { WildcardFileFilter filter = new WildcardFileFilter(includes); if (filter.accept(file)) { return true; } } // It does not match the filter, we try the comment approach. String content; try { content = FileUtils.readFileToString(file); } catch (IOException e) { getLog().error("Cannot read the content of " + file.getAbsolutePath(), e); return false; } String lower = content.toLowerCase(); return lower.contains("!ecmascript6") || lower.contains("!es6"); }