Source Code Cross Referenced for DCInputSet.java in  » Content-Management-System » dspace » org » dspace » app » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » dspace » org.dspace.app.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DCInputSet.java
003:         *
004:         * Version: $Revision: 2044 $
005:         *
006:         * Date: $Date: 2007-07-06 18:59:33 -0500 (Fri, 06 Jul 2007) $
007:         *
008:         * Copyright (c) 2002-2005, Hewlett-Packard Company and Massachusetts
009:         * Institute of Technology.  All rights reserved.
010:         *
011:         * Redistribution and use in source and binary forms, with or without
012:         * modification, are permitted provided that the following conditions are
013:         * met:
014:         *
015:         * - Redistributions of source code must retain the above copyright
016:         * notice, this list of conditions and the following disclaimer.
017:         *
018:         * - Redistributions in binary form must reproduce the above copyright
019:         * notice, this list of conditions and the following disclaimer in the
020:         * documentation and/or other materials provided with the distribution.
021:         *
022:         * - Neither the name of the Hewlett-Packard Company nor the name of the
023:         * Massachusetts Institute of Technology nor the names of their
024:         * contributors may be used to endorse or promote products derived from
025:         * this software without specific prior written permission.
026:         *
027:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
028:         * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
029:         * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
030:         * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
031:         * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
032:         * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
033:         * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
034:         * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
035:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
036:         * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
037:         * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
038:         * DAMAGE.
039:         */
040:
041:        package org.dspace.app.util;
042:
043:        import java.util.ArrayList;
044:        import java.util.List;
045:        import java.util.Vector;
046:        import java.util.Map;
047:
048:        /**
049:         * Class representing all DC inputs required for a submission, organized into pages
050:         *
051:         * @author Brian S. Hughes, based on work by Jenny Toves, OCLC
052:         * @version $Revision: 2044 $
053:         */
054:
055:        public class DCInputSet {
056:            /** name of the input set  */
057:            private String formName = null;
058:            /** the inputs ordered by page and row position */
059:            private DCInput[][] inputPages = null;
060:
061:            /** constructor */
062:            public DCInputSet(String formName, Vector pages, Map listMap) {
063:                this .formName = formName;
064:                inputPages = new DCInput[pages.size()][];
065:                for (int i = 0; i < inputPages.length; i++) {
066:                    Vector page = (Vector) pages.get(i);
067:                    inputPages[i] = new DCInput[page.size()];
068:                    for (int j = 0; j < inputPages[i].length; j++) {
069:                        inputPages[i][j] = new DCInput((Map) page.get(j),
070:                                listMap);
071:                    }
072:                }
073:            }
074:
075:            /**
076:             * Return the name of the form that defines this input set
077:             * @return formName 	the name of the form
078:             */
079:            public String getFormName() {
080:                return formName;
081:            }
082:
083:            /**
084:             * Return the number of pages in this  input set
085:             * @return number of pages
086:             */
087:            public int getNumberPages() {
088:                return inputPages.length;
089:            }
090:
091:            /**
092:             * Get all the rows for a page from the form definition
093:             *
094:             * @param  pageNum	desired page within set
095:             * @param  addTitleAlternative flag to add the additional title row
096:             * @param  addPublishedBefore  flag to add the additional published info
097:             *
098:             * @return  an array containing the page's displayable rows
099:             */
100:
101:            public DCInput[] getPageRows(int pageNum,
102:                    boolean addTitleAlternative, boolean addPublishedBefore) {
103:                List filteredInputs = new ArrayList();
104:                if (pageNum < inputPages.length) {
105:                    for (int i = 0; i < inputPages[pageNum].length; i++) {
106:                        DCInput input = inputPages[pageNum][i];
107:                        if (doField(input, addTitleAlternative,
108:                                addPublishedBefore)) {
109:                            filteredInputs.add(input);
110:                        }
111:                    }
112:                }
113:
114:                // Convert list into an array
115:                DCInput[] inputArray = new DCInput[filteredInputs.size()];
116:                return (DCInput[]) filteredInputs.toArray(inputArray);
117:            }
118:
119:            /**
120:             * Does this set of inputs include an alternate title field?
121:             *
122:             * @return true if the current set has an alternate title field
123:             */
124:            public boolean isDefinedMultTitles() {
125:                return isFieldPresent("title.alternative");
126:            }
127:
128:            /**
129:             * Does this set of inputs include the previously published fields?
130:             *
131:             * @return true if the current set has all the prev. published fields
132:             */
133:            public boolean isDefinedPubBefore() {
134:                return (isFieldPresent("date.issued")
135:                        && isFieldPresent("identifier.citation") && isFieldPresent("publisher.null"));
136:            }
137:
138:            /**
139:             * Does the current input set define the named field?
140:             * Scan through every field in every page of the input set
141:             *
142:             * @return true if the current set has the named field
143:             */
144:            public boolean isFieldPresent(String fieldName) {
145:                for (int i = 0; i < inputPages.length; i++) {
146:                    DCInput[] pageInputs = inputPages[i];
147:                    for (int row = 0; row < pageInputs.length; row++) {
148:                        String fullName = pageInputs[row].getElement() + "."
149:                                + pageInputs[row].getQualifier();
150:                        if (fullName.equals(fieldName)) {
151:                            return true;
152:                        }
153:                    }
154:                }
155:                return false;
156:            }
157:
158:            private static boolean doField(DCInput dcf,
159:                    boolean addTitleAlternative, boolean addPublishedBefore) {
160:                String rowName = dcf.getElement() + "." + dcf.getQualifier();
161:                if (rowName.equals("title.alternative") && !addTitleAlternative) {
162:                    return false;
163:                }
164:                if (rowName.equals("date.issued") && !addPublishedBefore) {
165:                    return false;
166:                }
167:                if (rowName.equals("publisher.null") && !addPublishedBefore) {
168:                    return false;
169:                }
170:                if (rowName.equals("identifier.citation")
171:                        && !addPublishedBefore) {
172:                    return false;
173:                }
174:
175:                return true;
176:            }
177:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.