1 40 41 package org.dspace.app.webui.util; 42 43 import java.util.ArrayList ; 44 import java.util.List ; 45 import java.util.Vector ; 46 import java.util.Map ; 47 48 54 55 public class DCInputSet 56 { 57 58 private String formName = null; 59 60 private DCInput[][] inputPages = null; 61 62 63 public DCInputSet(String formName, Vector pages, Map listMap) 64 { 65 this.formName = formName; 66 inputPages = new DCInput[pages.size()][]; 67 for ( int i = 0; i < inputPages.length; i++ ) 68 { 69 Vector page = (Vector )pages.get(i); 70 inputPages[i] = new DCInput[page.size()]; 71 for ( int j = 0; j < inputPages[i].length; j++ ) 72 { 73 inputPages[i][j] = new DCInput((Map )page.get(j), listMap); 74 } 75 } 76 } 77 78 82 public String getFormName() 83 { 84 return formName; 85 } 86 87 91 public int getNumberPages() 92 { 93 return inputPages.length; 94 } 95 96 105 106 public DCInput[] getPageRows(int pageNum, boolean addTitleAlternative, 107 boolean addPublishedBefore) 108 { 109 List filteredInputs = new ArrayList (); 110 if ( pageNum < inputPages.length ) 111 { 112 for (int i = 0; i < inputPages[pageNum].length; i++ ) 113 { 114 DCInput input = inputPages[pageNum][i]; 115 if (doField(input, addTitleAlternative, addPublishedBefore)) 116 { 117 filteredInputs.add(input); 118 } 119 } 120 } 121 122 DCInput[] inputArray = new DCInput[filteredInputs.size()]; 124 return (DCInput[])filteredInputs.toArray(inputArray); 125 } 126 127 132 public boolean isDefinedMultTitles() 133 { 134 return isFieldPresent("title.alternative"); 135 } 136 137 142 public boolean isDefinedPubBefore() 143 { 144 return ( isFieldPresent("date.issued") && 145 isFieldPresent("identifier.citation") && 146 isFieldPresent("publisher.null") ); 147 } 148 149 155 public boolean isFieldPresent(String fieldName) 156 { 157 for (int i = 0; i < inputPages.length; i++) 158 { 159 DCInput[] pageInputs = inputPages[i]; 160 for (int row = 0; row < pageInputs.length; row++) 161 { 162 String fullName = pageInputs[row].getElement() + "." + 163 pageInputs[row].getQualifier(); 164 if (fullName.equals(fieldName)) 165 { 166 return true; 167 } 168 } 169 } 170 return false; 171 } 172 173 private static boolean doField(DCInput dcf, boolean addTitleAlternative, 174 boolean addPublishedBefore) 175 { 176 String rowName = dcf.getElement() + "." + dcf.getQualifier(); 177 if ( rowName.equals("title.alternative") && ! addTitleAlternative ) 178 { 179 return false; 180 } 181 if (rowName.equals("date.issued") && ! addPublishedBefore ) 182 { 183 return false; 184 } 185 if (rowName.equals("publisher.null") && ! addPublishedBefore ) 186 { 187 return false; 188 } 189 if (rowName.equals("identifier.citation") && ! addPublishedBefore ) 190 { 191 return false; 192 } 193 194 return true; 195 } 196 } 197 | Popular Tags |