1 package org.jahia.webapps.fichotheque; 2 3 import java.util.*; 4 import java.sql.*; 5 6 import org.jahia.tools.*; 7 import org.jahia.tools.db.*; 8 9 15 16 public class ListCards { 17 private static org.apache.log4j.Logger logger = 18 org.apache.log4j.Logger.getLogger(ListCards.class); 19 20 21 private Vector cards = new Vector(); 22 23 26 public ListCards () { 27 } 28 29 34 public void setCards (Vector card) { 35 this.cards = card; 36 } 37 38 43 public Vector getCards () { 44 return this.cards; 45 } 46 47 52 public int getSize () { 53 return this.cards.size(); 54 } 55 56 62 public int getNextCardId (int current_cardID) { 63 int next_id = 0; 64 65 if (this.cards.size() > 0) { 67 next_id = ( (Card)this.cards.get(0)).getId(); 68 } 69 70 for (int i = 0; i < this.cards.size(); i++) { 71 if ( ( (Card)this.cards.get(i)).getId() == current_cardID) { 73 if ( (i + 1) < this.cards.size()) { 76 next_id = ( (Card)this.cards.get(i + 1)).getId(); 78 } 79 } 80 } 81 return next_id; 82 } 83 84 90 public int getPreviousCardId (int current_cardID) { 91 int previous_id = 0; 92 93 if (this.cards.size() > 0) { 95 previous_id = ( (Card)this.cards.get(this.cards.size() - 1)).getId(); 96 } 97 98 for (int i = 0; i < this.cards.size(); i++) { 99 if ( ( (Card)this.cards.get(i)).getId() == current_cardID) { 101 if (i > 0) { 104 previous_id = ( (Card)this.cards.get(i - 1)).getId(); 106 } 107 } 108 } 109 return previous_id; 110 } 111 112 118 public int getCurrentCardId (int current_cardID) { 119 int current_id = current_cardID; 120 121 if (this.cards.size() != 0) { 122 current_id = ( (Card)this.cards.get(0)).getId(); 125 126 for (int i = 0; i < this.cards.size(); i++) { 127 if ( ( (Card)this.cards.get(i)).getId() == current_cardID) { 129 current_id = ( (Card)this.cards.get(i)).getId(); 130 } 131 } 132 } 133 return current_id; 134 } 135 136 144 public void loadList (String contextId, String inJahia, String useMode, 145 String remoteUser, String userRight, String sortFlag, 146 String sortedBy) { 147 Vector list = new Vector(); 148 logger.debug("userRight :" + userRight); 149 try { 151 if (userRight.equals("manager")) { 152 if (useMode.equals("user")) { 153 if (inJahia.equals("true")) { 154 list = AccessDB.loadListCard(remoteUser, contextId, 155 sortFlag, 156 sortedBy); 157 } else { 158 list = AccessDB.loadListCard(remoteUser, sortFlag, 159 sortedBy); 160 } 161 } else { 162 if (inJahia.equals("true")) { 163 list = AccessDB.loadListCardSinUser(contextId, sortFlag, 164 sortedBy); 165 } else { 166 list = AccessDB.loadListCardSinUser(sortFlag, sortedBy); 167 } 168 169 } 170 } else { 171 String status = "Validated"; 172 if (useMode.equals("user")) { 173 if (inJahia.equals("true")) { 174 175 list = AccessDB.loadList(remoteUser, contextId, status, 176 sortFlag, 177 sortedBy); 178 } 179 180 else { 181 list = AccessDB.loadList(remoteUser, status, sortFlag, 182 sortedBy); 183 184 } 185 } else { 186 if (inJahia.equals("true")) { 187 188 list = AccessDB.loadListSinUser(contextId, status, 189 sortFlag, 190 sortedBy); 191 } 192 193 else { 194 logger.debug("info passage " + status); 195 list = AccessDB.loadListSinUser(status, sortFlag, 196 sortedBy); 197 198 } 199 200 } 201 } 202 this.cards.clear(); 203 if (list == null) { 204 } else { 205 for (int i = 0; i < list.size(); i++) { 206 207 Vector v = new Vector(); 208 Card crd = (Card) list.get(i); 209 210 v.add("x"); 212 v.add(crd.getLastName()); 213 v.add(crd.getFirstName()); 214 v.add(crd.getAbsenceType()); 215 v.add(crd.getFirstAbsenceDay()); 216 v.add(crd.getLastAbsenceDay()); 217 v.add(crd.getUser()); 218 v.add(crd.getContextId()); 219 v.add(crd.getStatus()); 220 221 crd.setFields(v); 222 223 this.cards.add(crd); 224 } 225 226 } 227 } catch (Exception e) { 228 logger.error("ListCards: load", e); 229 } 230 231 } 232 233 } 234 | Popular Tags |