001/*
002 $Id: HitsFilterForGelBasedProjects.java 3312 2009-06-16 12:17:10Z gregory $
003 
004 Copyright (C) 2006, 2007 Gregory Vincic
005 
006 Files are copyright by their respective authors. The contributions to
007 files where copyright is not explicitly stated can be traced with the
008 source code revision system.
009 
010 This file is part of Proteios.
011 Available at http://www.proteios.org/
012 
013 Proteios is free software; you can redistribute it and/or
014 modify it under the terms of the GNU General Public License
015 as published by the Free Software Foundation; either version 2
016 of the License, or (at your option) any later version.
017 
018 Proteios is distributed in the hope that it will be useful,
019 but WITHOUT ANY WARRANTY; without even the implied warranty of
020 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
021 GNU General Public License for more details.
022 
023 You should have received a copy of the GNU General Public License
024 along with this program; if not, write to the Free Software
025 Foundation, Inc., 59 Temple Place - Suite 330,
026 Boston, MA  02111-1307, USA.
027 */
028package org.proteios.core;
029
030import org.proteios.AttributeDefinition;
031import org.proteios.AttributeFilter;
032import java.util.ArrayList;
033import java.util.HashSet;
034import java.util.List;
035import java.util.Set;
036
037/**
038 * A filter for basic item attributes. We want attributes to be shown and
039 * ordered consistently thus we specify attribute order and default visibility
040 * here. You should avoid having different order of attributes depending on
041 * class. Always try to make a good tradeoff when dealing with common attributes
042 * over several classes.
043 * 
044 * @author gregory
045 */
046public class HitsFilterForGelBasedProjects
047                implements AttributeFilter
048{
049        /**
050         * Default set of attributes that are shown in tables. Note that not all attributes are
051         * present in all classes though they are still defined here.
052         */
053        private static final Set<String> isDefault = new HashSet<String>(21);
054        static
055        {
056                isDefault.add("Id");
057                isDefault.add("Name");
058                isDefault.add("ConcentrationInGramsPerLiter");
059                isDefault.add("OriginalQuantityInMicroLiters");
060                isDefault.add("RemainingQuantityInMicroLiters");
061                isDefault.add("Pooled");
062                isDefault.add("StorageLocation");
063                isDefault.add("ExternalId");
064                isDefault.add("SpectrumStringId");
065                isDefault.add("CombinedFDR");
066                isDefault.add("ExpectationValue");
067                isDefault.add("GelExternalId");
068                isDefault.add("SpotId");
069                isDefault.add("IdentificationResultFile");
070                isDefault.add("PeakListFile");
071                isDefault.add("ExpectationValue");
072                isDefault.add("Score");
073                isDefault.add("Description");
074                isDefault.add("Created");
075                isDefault.add("Status");
076                isDefault.add("FileType");
077                isDefault.add("SizeInBytes");
078        }
079        /**
080         * This defines the overall order of all attributes. If you need class
081         * specific order call the sort(List, List) method.
082         */
083        private static final List<String> defaultOrder = new ArrayList<String>();
084        static
085        {
086                // First
087                defaultOrder.add("Id");
088                defaultOrder.add("GelExternalId");
089                defaultOrder.add("SpotId");
090                defaultOrder.add("SpectrumStringId");
091                defaultOrder.add("IdentificationResultFile");
092                defaultOrder.add("PeakListFile");
093                defaultOrder.add("SpectrumId");
094                defaultOrder.add("CombinedFDR");
095                defaultOrder.add("EValue");
096                defaultOrder.add("Score");
097                defaultOrder.add("Name");
098                defaultOrder.add("ExternalId");
099                defaultOrder.add("Size");
100                defaultOrder.add("MimeType");
101                defaultOrder.add("Used");
102                defaultOrder.add("Md5");
103                defaultOrder.add("Directory");
104                defaultOrder.add("FileType");
105                defaultOrder.add("AccessionNumber");
106                defaultOrder.add("SizeInBytes");
107                defaultOrder.add("QuotaTypeSystemId");
108                defaultOrder.add("Removed");
109                defaultOrder.add("Shared");
110                defaultOrder.add("Owner");
111                defaultOrder.add("Version");
112                defaultOrder.add("InDatabase");
113                defaultOrder.add("Detached");
114                defaultOrder.add("Description");
115                defaultOrder.add("Status");
116                defaultOrder.add("Created");
117                // Last
118        }
119
120
121        /*
122         * (non-Javadoc)
123         * 
124         * @see org.proteios.AttributeFilter#isDefault(org.proteios.AttributeDefinition)
125         */
126        public boolean isDefault(AttributeDefinition attribute)
127        {
128                return attribute != null ? isDefault.contains(attribute.getKey()) : false;
129        }
130
131
132        /**
133         * Get a list of overall order of all attributes.
134         * 
135         * @return List<String> A list of overall order of all attributes.
136         */
137        public List<String> getDefaultOrder()
138        {
139                return defaultOrder;
140        }
141}