Changeset 1178
- Timestamp:
- 10/26/11 23:08:01 (19 months ago)
- Location:
- raptor-information-model/trunk/src/main/java/uk/ac/cardiff
- Files:
-
- 1 deleted
- 10 edited
-
model/event/AuthenticationFailureEvent.java (deleted)
-
model/event/Event.java (modified) (2 diffs)
-
model/report/AggregatorGraphModel.java (modified) (7 diffs)
-
model/wsmodel/EventPushMessage.java (modified) (1 diff)
-
model/wsmodel/LogFileUpload.java (modified) (2 diffs)
-
model/wsmodel/LogFileUploadResult.java (modified) (1 diff)
-
model/wsmodel/StatisticParameters.java (modified) (15 diffs)
-
model/wsmodel/SuggestionValues.java (modified) (8 diffs)
-
utility/EqualsUtil.java (modified) (1 diff)
-
utility/HashCodeUtil.java (modified) (7 diffs)
-
utility/StringUtils.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
raptor-information-model/trunk/src/main/java/uk/ac/cardiff/model/event/Event.java
r1172 r1178 40 40 private Long persistantId; 41 41 42 /** attributes generic to all entries. */42 /** The date and time the event was generated. */ 43 43 private DateTime eventTime; 44 44 … … 87 87 */ 88 88 public Event(Event event) { 89 // this has a defensive getter, so adirect assignment is possible89 // this has a defensive getter, so direct assignment is possible 90 90 this.eventTime = event.getEventTime(); 91 91 this.eventId = event.getEventId(); -
raptor-information-model/trunk/src/main/java/uk/ac/cardiff/model/report/AggregatorGraphModel.java
r1172 r1178 12 12 public class AggregatorGraphModel implements Serializable { 13 13 14 /** Class logger */14 /** Class logger. */ 15 15 private static final long serialVersionUID = 5372664739350074383L; 16 16 17 /** The list of <code>String</code> labels for the groups */17 /** The list of <code>String</code> labels for the groups. */ 18 18 private List<String> groupLabels; 19 19 20 /** The list of <code>String</code> labels for each series */20 /** The list of <code>String</code> labels for each series. */ 21 21 private List<String> seriesLabels; 22 22 23 /** The list of <code>Double</code> values assigned to each series */23 /** The list of <code>Double</code> values assigned to each series. */ 24 24 private List<List<Double>> chartValues; 25 25 26 /** A class that holds presentation information for this graph model */26 /** A class that holds presentation information for this graph model. */ 27 27 private Presentation presentation; 28 28 29 /** 30 * Instantiates a new aggregator graph model. 31 */ 29 32 public AggregatorGraphModel() { 30 33 seriesLabels = new ArrayList<String>(); 31 34 } 32 35 36 /** 37 * Gets the group labels. 38 * 39 * @return the group labels 40 */ 33 41 public List<String> getGroupLabels() { 34 42 return groupLabels; … … 36 44 } 37 45 46 /** 47 * Adds the group label. 48 * 49 * @param label 50 * the label 51 */ 38 52 public void addGroupLabel(String label) { 39 53 if (getGroupLabels() == null) … … 42 56 } 43 57 58 /** 59 * Adds the series label. 60 * 61 * @param label 62 * the label 63 */ 44 64 public void addSeriesLabel(String label) { 45 65 if (getSeriesLabels() == null) … … 48 68 } 49 69 70 /** 71 * Sort group labels alphabetically. 72 */ 50 73 public void sortGroupLabelsAlphabetically() { 51 74 Collections.sort(groupLabels); … … 53 76 } 54 77 78 /** 79 * Gets the series labels. 80 * 81 * @return the series labels 82 */ 55 83 public List<String> getSeriesLabels() { 56 84 return seriesLabels; … … 58 86 } 59 87 88 /** 89 * Adds the group value. 90 * 91 * @param values 92 * the values 93 */ 60 94 public void addGroupValue(List<Double> values) { 61 95 if (chartValues == null) … … 64 98 } 65 99 100 /** 101 * Gets the y values. 102 * 103 * @return the y values 104 */ 66 105 public List<List<Double>> getYValues() { 67 106 return chartValues; 68 107 } 69 108 109 /** 110 * Sets the y values. 111 * 112 * @param values 113 * the new y values 114 */ 70 115 public void setYValues(List<List<Double>> values) { 71 116 72 117 } 73 118 119 /** 120 * Sets the group labels. 121 * 122 * @param groupLabels 123 * the new group labels 124 */ 74 125 public void setGroupLabels(List<String> groupLabels) { 75 126 this.groupLabels = groupLabels; 76 127 } 77 128 129 /** 130 * Sets the series labels. 131 * 132 * @param seriesLabels 133 * the new series labels 134 */ 78 135 public void setSeriesLabels(List<String> seriesLabels) { 79 136 this.seriesLabels = seriesLabels; 80 137 } 81 138 139 /** 140 * Sets the chart values. 141 * 142 * @param chartValues 143 * the new chart values 144 */ 82 145 public void setChartValues(List<List<Double>> chartValues) { 83 146 this.chartValues = chartValues; 84 147 } 85 148 149 /** 150 * Gets the chart values. 151 * 152 * @return the chart values 153 */ 86 154 public List<List<Double>> getChartValues() { 87 155 return chartValues; 88 156 } 89 157 158 /** 159 * Sets the presentation. 160 * 161 * @param presentation 162 * the new presentation 163 */ 90 164 public void setPresentation(Presentation presentation) { 91 165 this.presentation = presentation; 92 166 } 93 167 168 /** 169 * Gets the presentation. 170 * 171 * @return the presentation 172 */ 94 173 public Presentation getPresentation() { 95 174 return presentation; -
raptor-information-model/trunk/src/main/java/uk/ac/cardiff/model/wsmodel/EventPushMessage.java
r1172 r1178 24 24 private ServiceMetadata clientMetadata; 25 25 26 /** The time instant the message was created push. */26 /** The time instant the message was created. */ 27 27 private Date timeOfPush; 28 28 -
raptor-information-model/trunk/src/main/java/uk/ac/cardiff/model/wsmodel/LogFileUpload.java
r1172 r1178 11 11 private static final long serialVersionUID = -6283086431616419079L; 12 12 13 /** The Name. */13 /** The filename of the file that has been uploaded. */ 14 14 private String Name; 15 15 16 /** The mime . */16 /** The mime type. */ 17 17 private String mime; 18 18 19 /** The length . */19 /** The length of the file. */ 20 20 private long length; 21 21 … … 65 65 private String processingStatus; 66 66 67 /** The processed. */67 /** Whether this file has be proccessed (parsed and stored). */ 68 68 private boolean processed; 69 69 -
raptor-information-model/trunk/src/main/java/uk/ac/cardiff/model/wsmodel/LogFileUploadResult.java
r1172 r1178 14 14 private long id; 15 15 16 /** The status . */16 /** The status message from the agent that processed this message. */ 17 17 private String status; 18 18 -
raptor-information-model/trunk/src/main/java/uk/ac/cardiff/model/wsmodel/StatisticParameters.java
r815 r1178 9 9 import java.util.List; 10 10 11 import org.slf4j.Logger;12 import org.slf4j.LoggerFactory;13 11 import org.joda.time.DateTime; 14 12 import org.joda.time.format.DateTimeFormat; 15 13 import org.joda.time.format.DateTimeFormatter; 14 import org.slf4j.Logger; 15 import org.slf4j.LoggerFactory; 16 16 17 17 import uk.ac.cardiff.model.report.Presentation; … … 20 20 /** 21 21 * @author philsmart 22 * 22 * 23 23 */ 24 public class StatisticParameters implements Serializable {25 26 /** generated serial ID */24 public class StatisticParameters implements Serializable { 25 26 /** generated serial ID */ 27 27 private static final long serialVersionUID = 9135524508369102248L; 28 28 … … 30 30 private final Logger log = LoggerFactory.getLogger(StatisticParameters.class); 31 31 32 private static final String OUTPUT_DATE_FORMAT ="dd/MM/yyyy HH:mm:ss";; 33 32 /** 33 * a constant date format used to convert start and end times into a formant suitable for human consumption. 34 */ 35 private static final String OUTPUT_DATE_FORMAT = "dd/MM/yyyy HH:mm:ss";; 36 37 /** 38 * The name of the statistic unit this {@link uk.ac.cardiff.model.wsmodel.StatisticParameters} is recording information about. 39 */ 34 40 private String unitName; 35 41 36 /** List of parameters passed into the <code>performStatistic</code> method */42 /** List of parameters passed into the <code>performStatistic</code> method */ 37 43 private List<MethodParameter> methodParameters; 38 44 … … 46 52 private DateTime endTime; 47 53 48 /** Its important that these dates (used for display in the view) are kept in sync with the 49 * Joda DateTime classes above*/ 54 /** 55 * 56 * The start date as a Java Date object. Its important that these dates (used for display in the view) are kept in sync with the Joda DateTime classes 57 * above. Used for remoting 58 */ 50 59 private Date startTimeJava; 60 61 /** 62 * The end date as a Java Date objects. Its important that these dates (used for display in the view) are kept in sync with the Joda DateTime classes above. 63 * Used for remoting 64 */ 51 65 private Date endTimeJava; 52 66 53 public enum ResourceCategory {54 /** For resources that are internal to the organisation */55 INTERNAL(new int[] {1}),56 /** For resources that are external to the organisation */57 EXTERNAL(new int[] {2}),67 public enum ResourceCategory { 68 /** For resources that are internal to the organisation */ 69 INTERNAL(new int[] { 1 }), 70 /** For resources that are external to the organisation */ 71 EXTERNAL(new int[] { 2 }), 58 72 /** For all resource categories */ 59 ALL(new int[] {1,2});73 ALL(new int[] { 1, 2 }); 60 74 61 75 private int[] resourceIdCategory; 62 76 63 ResourceCategory(int[] resourceIdCategory) {77 ResourceCategory(int[] resourceIdCategory) { 64 78 this.resourceIdCategory = resourceIdCategory; 65 79 } … … 73 87 74 88 /** 75 * Returns a <code>String</code> value that represents 76 * an IN SQL operator which specifies the resourceIdCategory(s) 77 * for this <code>ResourceCategory</code> for use in SQL WHERE clauses 78 * 89 * Returns a <code>String</code> value that represents an IN SQL operator which specifies the resourceIdCategory(s) for this 90 * <code>ResourceCategory</code> for use in SQL WHERE clauses 91 * 79 92 * @return an SQL IN clause 80 93 */ … … 82 95 StringBuilder sb = new StringBuilder(); 83 96 sb.append("in ("); 84 for (int i =0; i < resourceIdCategory.length; i++){97 for (int i = 0; i < resourceIdCategory.length; i++) { 85 98 sb.append(resourceIdCategory[i]); 86 if (i < resourceIdCategory.length -1){99 if (i < resourceIdCategory.length - 1) { 87 100 sb.append(","); 88 101 } … … 97 110 /** either system or user types */ 98 111 public enum StatisticType { 99 /** 100 * A statistic for use by the USER. Possibly removed in the future, in favour of individual 101 * user based statistics 102 */ 103 USER, 104 /** 105 * A statistic for use by the system level processes, e.g. to generate dashboard 106 * statistics 107 */ 108 SYSTEM}; 112 /** 113 * A statistic for use by the USER. Possibly removed in the future, in favour of individual user based statistics 114 */ 115 USER, 116 /** 117 * A statistic for use by the system level processes, e.g. to generate dashboard statistics 118 */ 119 SYSTEM 120 }; 109 121 110 122 /** The type of statistic */ 111 123 private StatisticType type; 112 124 113 //TODO should be constructed in XML 114 /** The type of event from the information model this statistic should be performed over*/ 115 public enum EventType{ 116 /** A Shibboleth Authentication Event Type*/ 117 SHIBBOLETH_AUTHENTICATION("ShibbolethIdpAuthenticationEvent", new String[]{"uk.ac.cardiff.model.event.ShibbolethIdpAuthenticationEvent","uk.ac.cardiff.model.event.AuthenticationEvent","uk.ac.cardiff.model.event.Event"}), 125 // TODO should be constructed in XML 126 /** The type of event from the information model this statistic should be performed over */ 127 public enum EventType { 128 /** A Shibboleth Authentication Event Type */ 129 SHIBBOLETH_AUTHENTICATION("ShibbolethIdpAuthenticationEvent", new String[] { "uk.ac.cardiff.model.event.ShibbolethIdpAuthenticationEvent", "uk.ac.cardiff.model.event.AuthenticationEvent", 130 "uk.ac.cardiff.model.event.Event" }), 118 131 /** An Ezproxy Authentication Event Type */ 119 EZPROXY_AUTHENTICATION("EzproxyAuthenticationEvent", new String[]{"uk.ac.cardiff.model.event.EzproxyAuthenticationEvent","uk.ac.cardiff.model.event.AuthenticationEvent","uk.ac.cardiff.model.event.Event"}); 132 EZPROXY_AUTHENTICATION("EzproxyAuthenticationEvent", new String[] { "uk.ac.cardiff.model.event.EzproxyAuthenticationEvent", "uk.ac.cardiff.model.event.AuthenticationEvent", 133 "uk.ac.cardiff.model.event.Event" }); 120 134 121 135 private String hibernateSimpleClassName; … … 123 137 private String[] classHierarchy; 124 138 125 private EventType(String hibernateSimpleClassName, String[] classHierarchy) {139 private EventType(String hibernateSimpleClassName, String[] classHierarchy) { 126 140 this.hibernateSimpleClassName = hibernateSimpleClassName; 127 141 this.classHierarchy = classHierarchy; 128 142 } 129 143 130 public String getHibernateSimpleClassName() {144 public String getHibernateSimpleClassName() { 131 145 return hibernateSimpleClassName; 132 146 } 133 147 134 public String[] getClassHierarchy() {148 public String[] getClassHierarchy() { 135 149 return classHierarchy; 136 150 } … … 140 154 private EventType eventType; 141 155 142 143 /* Configures the parameters used to view a graphical representation*/ 156 /** Configures the parameters used to view a graphical representation */ 144 157 private Presentation presentation; 145 158 146 /* A series to plot on the graph*/147 private List<Series> series;148 149 /** Default constructor. */150 public StatisticParameters(){151 presentation = new Presentation();152 presentation.setGraphTitle("");153 presentation.setxAxisLabel("");154 presentation.setyAxisLabel("");155 setSeries(new ArrayList<Series>());156 resourceCategory = ResourceCategory.ALL;157 }159 /** A series to plot on the graph */ 160 private List<Series> series; 161 162 /** Default constructor. */ 163 public StatisticParameters() { 164 presentation = new Presentation(); 165 presentation.setGraphTitle(""); 166 presentation.setxAxisLabel(""); 167 presentation.setyAxisLabel(""); 168 setSeries(new ArrayList<Series>()); 169 resourceCategory = ResourceCategory.ALL; 170 } 158 171 159 172 public void setUnitName(String unitName) { 160 this.unitName = unitName;173 this.unitName = unitName; 161 174 } 162 175 163 176 public String getUnitName() { 164 return unitName; 165 } 166 177 return unitName; 178 } 167 179 168 180 public void setMethodParams(List<MethodParameter> methodParams) { 169 this.methodParameters = methodParams;181 this.methodParameters = methodParams; 170 182 } 171 183 172 184 public List<MethodParameter> getMethodParams() { 173 return methodParameters;174 } 175 176 /** 177 * This method should be used as the primary method for setting the startTime on 178 * this class185 return methodParameters; 186 } 187 188 /** 189 * This method should be used as the primary method for setting the startTime on this class 190 * 179 191 * @param startTime 180 192 */ 181 193 public void setStartTime(DateTime startTime) { 182 this.startTime = startTime;183 this.startTimeJava = new Date(this.startTime.getMillis());194 this.startTime = startTime; 195 this.startTimeJava = new Date(this.startTime.getMillis()); 184 196 } 185 197 186 198 public DateTime getStartTimeAsDate() { 187 return startTime;188 } 189 190 /** 191 * This method should be used as the primary method for setting the endTime on 192 * this class199 return startTime; 200 } 201 202 /** 203 * This method should be used as the primary method for setting the endTime on this class 204 * 193 205 * @param endTime 194 206 */ 195 207 public void setEndTime(DateTime endTime) { 196 this.endTime = endTime;208 this.endTime = endTime; 197 209 } 198 210 199 211 public DateTime getEndTimeAsDate() { 200 return endTime;212 return endTime; 201 213 } 202 214 203 215 public void setStartTime(String startTime) { 204 this.startTime = formatDate(startTime, false);205 this.startTimeJava = new Date(this.startTime.getMillis());216 this.startTime = formatDate(startTime, false); 217 this.startTimeJava = new Date(this.startTime.getMillis()); 206 218 207 219 } 208 220 209 221 public String getStartTime() { 210 if (startTime!=null)return startTime.toString(OUTPUT_DATE_FORMAT); 211 return null; 222 if (startTime != null) 223 return startTime.toString(OUTPUT_DATE_FORMAT); 224 return null; 212 225 } 213 226 214 227 public void setEndTime(String endTime) { 215 this.endTime = formatDate(endTime, true);216 this.endTimeJava = new Date(this.endTime.getMillis());228 this.endTime = formatDate(endTime, true); 229 this.endTimeJava = new Date(this.endTime.getMillis()); 217 230 } 218 231 219 232 public String getEndTime() { 220 if (endTime!=null)return endTime.toString(OUTPUT_DATE_FORMAT); 221 return null;222 }223 233 if (endTime != null) 234 return endTime.toString(OUTPUT_DATE_FORMAT); 235 return null; 236 } 224 237 225 238 /** 226 239 * for output on the web page (just a date that can be rendered by trinidad) 240 * 227 241 * @return 228 242 */ 229 public Date getEndTimeAsJavaDate() {230 return endTimeJava;243 public Date getEndTimeAsJavaDate() { 244 return endTimeJava; 231 245 232 246 } … … 234 248 /** 235 249 * for output on the web page 250 * 236 251 * @param date 237 252 */ 238 public Date getStartTimeAsJavaDate(){ 239 return startTimeJava; 240 } 241 242 243 public void setEndTimeAsJavaDate(Date date){ 244 this.endTimeJava = date; 245 this.endTime = new DateTime(date); 246 } 247 248 public void setStartTimeAsJavaDate(Date date){ 249 this.startTimeJava = date; 250 this.startTime = new DateTime(date); 251 } 252 253 /* human consumable outputs */ 253 public Date getStartTimeAsJavaDate() { 254 return startTimeJava; 255 } 256 257 public void setEndTimeAsJavaDate(Date date) { 258 this.endTimeJava = date; 259 this.endTime = new DateTime(date); 260 } 261 262 public void setStartTimeAsJavaDate(Date date) { 263 this.startTimeJava = date; 264 this.startTime = new DateTime(date); 265 } 254 266 255 267 public String getStartTimeAsFormattedString() { 256 DateTimeFormatter dtf = DateTimeFormat.forPattern(OUTPUT_DATE_FORMAT);257 if (getStartTime() != null)258 return getStartTimeAsDate().toString(dtf);259 else260 return "First Entry";268 DateTimeFormatter dtf = DateTimeFormat.forPattern(OUTPUT_DATE_FORMAT); 269 if (getStartTime() != null) 270 return getStartTimeAsDate().toString(dtf); 271 else 272 return "First Entry"; 261 273 } 262 274 263 275 public String getEndTimeAsFormattedString() { 264 DateTimeFormatter dtf = DateTimeFormat.forPattern(OUTPUT_DATE_FORMAT); 265 if (getEndTime() != null) 266 return getEndTimeAsDate().toString(dtf); 267 else 268 return "Last Entry"; 269 } 270 276 DateTimeFormatter dtf = DateTimeFormat.forPattern(OUTPUT_DATE_FORMAT); 277 if (getEndTime() != null) 278 return getEndTimeAsDate().toString(dtf); 279 else 280 return "Last Entry"; 281 } 271 282 272 283 /** 273 284 * <p> 274 285 * </p> 275 * 286 * 276 287 * @param date 277 * @param isEndTime- if is endTime and only ddMMyyyy is given, then the endTime should be 23.59 as opposed to 00.00 as this is the end of the day 288 * @param isEndTime 289 * - if is endTime and only ddMMyyyy is given, then the endTime should be 23.59 as opposed to 00.00 as this is the end of the day 278 290 * @return 279 291 */ 280 292 private DateTime formatDate(String date, boolean isEndTime) { 281 /* this is not a nice hack, please tidy */ 282 //log.debug("Date format being parsed {} with {} characters",date,date.length()); 283 if (date.length() == 8) { 284 // assume ddMMyyy 285 String format = "ddMMyyyy"; 286 DateTimeFormatter dtf = DateTimeFormat.forPattern(format); 287 DateTime dt = dtf.parseDateTime(date.substring(0, date.length())); 288 if (isEndTime) { 289 dt = new DateTime(dt.getMillis() + 86340000); // where 86340000 is 23.59 hours 290 } 291 // log.debug("time set to " + dt.getDayOfMonth() + "th " + dt.getMonthOfYear() + " " + dt.getYear() + " " + dt.getHourOfDay() + ":" + dt.getMinuteOfHour() + ":" + dt.getSecondOfMinute() + " for " + getUnitName()); 292 return dt; 293 } else if (date.length() == 15) { 294 // assume yyyyMMdd'T'HHmmss 295 String format = "yyyyMMdd'T'HHmmss"; 296 DateTimeFormatter dtf = DateTimeFormat.forPattern(format); 297 DateTime dt = dtf.parseDateTime(date.substring(0, date.length())); 298 // log.debug("time set to " + dt.getDayOfMonth() + "th " + dt.getMonthOfYear() + " " + dt.getYear() + " " + dt.getHourOfDay() + ":" + dt.getMinuteOfHour() + ":" + dt.getSecondOfMinute() + " for " + getUnitName()); 299 return dt; 300 } else if (date.length()==19){ 301 // assume outputDateFormat 302 String format = OUTPUT_DATE_FORMAT; 303 DateTimeFormatter dtf = DateTimeFormat.forPattern(format); 304 DateTime dt = dtf.parseDateTime(date.substring(0, date.length())); 305 // log.debug("time set to " + dt.getDayOfMonth() + "th " + dt.getMonthOfYear() + " " + dt.getYear() + " " + dt.getHourOfDay() + ":" + dt.getMinuteOfHour() + ":" + dt.getSecondOfMinute() + " for " + getUnitName()); 306 return dt; 307 } 308 //which is instantiated with the current date and time 309 return new DateTime(); 310 } 311 312 /** methods to get and set the minutes seconds and hours of end and start time (for the web interface)*/ 313 314 public void setEndTimeHour(int hour){ 315 DateTime newTime = new DateTime(endTime.getYear(),endTime.getMonthOfYear(),endTime.getDayOfMonth(), 316 hour, endTime.getMinuteOfHour(), endTime.getSecondOfMinute(), endTime.getMillisOfSecond()); 317 endTime = newTime; 318 endTimeJava = new Date(endTime.getMillis()); 319 } 320 public void setEndTimeMinute(int minutes){ 321 DateTime newTime = new DateTime(endTime.getYear(),endTime.getMonthOfYear(),endTime.getDayOfMonth(), 322 endTime.getHourOfDay(), minutes, endTime.getSecondOfMinute(), endTime.getMillisOfSecond()); 323 endTime = newTime; 324 endTimeJava = new Date(endTime.getMillis()); 325 } 326 public void setEndTimeSecond(int seconds){ 327 DateTime newTime = new DateTime(endTime.getYear(),endTime.getMonthOfYear(),endTime.getDayOfMonth(), 328 endTime.getHourOfDay(), endTime.getMinuteOfHour(), seconds, endTime.getMillisOfSecond()); 329 endTime = newTime; 330 endTimeJava = new Date(endTime.getMillis()); 331 } 332 public int getEndTimeHour(){ 333 if (endTime!=null) 334 return endTime.getHourOfDay(); 335 return 0; 336 } 337 public int getEndTimeMinute(){ 338 if (endTime!=null) 339 return endTime.getMinuteOfHour(); 340 return 0; 341 } 342 public int getEndTimeSecond(){ 343 if (endTime!=null) 344 return endTime.getSecondOfMinute(); 345 return 0; 346 } 347 348 public void setStartTimeHour(int hour){ 349 DateTime newTime = new DateTime(startTime.getYear(),startTime.getMonthOfYear(),startTime.getDayOfMonth(), 350 hour, startTime.getMinuteOfHour(), startTime.getSecondOfMinute(), startTime.getMillisOfSecond()); 351 startTime = newTime; 352 startTimeJava = new Date(startTime.getMillis()); 353 } 354 public void setStartTimeMinute(int minutes){ 355 DateTime newTime = new DateTime(startTime.getYear(),startTime.getMonthOfYear(),startTime.getDayOfMonth(), 356 startTime.getHourOfDay(), minutes, startTime.getSecondOfMinute(), startTime.getMillisOfSecond()); 357 startTime = newTime; 358 startTimeJava = new Date(startTime.getMillis()); 359 } 360 public void setStartTimeSecond(int seconds){ 361 DateTime newTime = new DateTime(startTime.getYear(),startTime.getMonthOfYear(),startTime.getDayOfMonth(), 362 startTime.getHourOfDay(), startTime.getMinuteOfHour(), seconds, startTime.getMillisOfSecond()); 363 startTime = newTime; 364 startTimeJava = new Date(startTime.getMillis()); 365 } 366 public int getStartTimeHour(){ 367 if (startTime!=null) 368 return startTime.getHourOfDay(); 369 return 0; 370 } 371 public int getStartTimeMinute(){ 372 if (startTime!=null) 373 return startTime.getMinuteOfHour(); 374 return 0; 375 } 376 public int getStartTimeSecond(){ 377 if (startTime!=null) 378 return startTime.getSecondOfMinute(); 379 return 0; 293 // TODO this is not a nice hack, please tidy 294 // log.debug("Date format being parsed {} with {} characters",date,date.length()); 295 if (date.length() == 8) { 296 // assume ddMMyyy 297 String format = "ddMMyyyy"; 298 DateTimeFormatter dtf = DateTimeFormat.forPattern(format); 299 DateTime dt = dtf.parseDateTime(date.substring(0, date.length())); 300 if (isEndTime) { 301 dt = new DateTime(dt.getMillis() + 86340000); // where 86340000 is 23.59 hours 302 } 303 // log.debug("time set to " + dt.getDayOfMonth() + "th " + dt.getMonthOfYear() + " " + dt.getYear() + " " + dt.getHourOfDay() + ":" + 304 // dt.getMinuteOfHour() + ":" + dt.getSecondOfMinute() + " for " + getUnitName()); 305 return dt; 306 } else if (date.length() == 15) { 307 // assume yyyyMMdd'T'HHmmss 308 String format = "yyyyMMdd'T'HHmmss"; 309 DateTimeFormatter dtf = DateTimeFormat.forPattern(format); 310 DateTime dt = dtf.parseDateTime(date.substring(0, date.length())); 311 // log.debug("time set to " + dt.getDayOfMonth() + "th " + dt.getMonthOfYear() + " " + dt.getYear() + " " + dt.getHourOfDay() + ":" + 312 // dt.getMinuteOfHour() + ":" + dt.getSecondOfMinute() + " for " + getUnitName()); 313 return dt; 314 } else if (date.length() == 19) { 315 // assume outputDateFormat 316 String format = OUTPUT_DATE_FORMAT; 317 DateTimeFormatter dtf = DateTimeFormat.forPattern(format); 318 DateTime dt = dtf.parseDateTime(date.substring(0, date.length())); 319 // log.debug("time set to " + dt.getDayOfMonth() + "th " + dt.getMonthOfYear() + " " + dt.getYear() + " " + dt.getHourOfDay() + ":" + 320 // dt.getMinuteOfHour() + ":" + dt.getSecondOfMinute() + " for " + getUnitName()); 321 return dt; 322 } 323 // which is instantiated with the current date and time 324 return new DateTime(); 325 } 326 327 /** methods to get and set the minutes seconds and hours of end and start time (for the web interface) */ 328 329 public void setEndTimeHour(int hour) { 330 DateTime newTime = new DateTime(endTime.getYear(), endTime.getMonthOfYear(), endTime.getDayOfMonth(), hour, endTime.getMinuteOfHour(), endTime.getSecondOfMinute(), endTime.getMillisOfSecond()); 331 endTime = newTime; 332 endTimeJava = new Date(endTime.getMillis()); 333 } 334 335 public void setEndTimeMinute(int minutes) { 336 DateTime newTime = new DateTime(endTime.getYear(), endTime.getMonthOfYear(), endTime.getDayOfMonth(), endTime.getHourOfDay(), minutes, endTime.getSecondOfMinute(), endTime.getMillisOfSecond()); 337 endTime = newTime; 338 endTimeJava = new Date(endTime.getMillis()); 339 } 340 341 public void setEndTimeSecond(int seconds) { 342 DateTime newTime = new DateTime(endTime.getYear(), endTime.getMonthOfYear(), endTime.getDayOfMonth(), endTime.getHourOfDay(), endTime.getMinuteOfHour(), seconds, endTime.getMillisOfSecond()); 343 endTime = newTime; 344 endTimeJava = new Date(endTime.getMillis()); 345 } 346 347 public int getEndTimeHour() { 348 if (endTime != null) 349 return endTime.getHourOfDay(); 350 return 0; 351 } 352 353 public int getEndTimeMinute() { 354 if (endTime != null) 355 return endTime.getMinuteOfHour(); 356 return 0; 357 } 358 359 public int getEndTimeSecond() { 360 if (endTime != null) 361 return endTime.getSecondOfMinute(); 362 return 0; 363 } 364 365 public void setStartTimeHour(int hour) { 366 DateTime newTime = new DateTime(startTime.getYear(), startTime.getMonthOfYear(), startTime.getDayOfMonth(), hour, startTime.getMinuteOfHour(), startTime.getSecondOfMinute(), 367 startTime.getMillisOfSecond()); 368 startTime = newTime; 369 startTimeJava = new Date(startTime.getMillis()); 370 } 371 372 public void setStartTimeMinute(int minutes) { 373 DateTime newTime = new DateTime(startTime.getYear(), startTime.getMonthOfYear(), startTime.getDayOfMonth(), startTime.getHourOfDay(), minutes, startTime.getSecondOfMinute(), 374 startTime.getMillisOfSecond()); 375 startTime = newTime; 376 startTimeJava = new Date(startTime.getMillis()); 377 } 378 379 public void setStartTimeSecond(int seconds) { 380 DateTime newTime = new DateTime(startTime.getYear(), startTime.getMonthOfYear(), startTime.getDayOfMonth(), startTime.getHourOfDay(), startTime.getMinuteOfHour(), seconds, 381 startTime.getMillisOfSecond()); 382 startTime = newTime; 383 startTimeJava = new Date(startTime.getMillis()); 384 } 385 386 public int getStartTimeHour() { 387 if (startTime != null) 388 return startTime.getHourOfDay(); 389 return 0; 390 } 391 392 public int getStartTimeMinute() { 393 if (startTime != null) 394 return startTime.getMinuteOfHour(); 395 return 0; 396 } 397 398 public int getStartTimeSecond() { 399 if (startTime != null) 400 return startTime.getSecondOfMinute(); 401 return 0; 380 402 } 381 403 382 404 public void setStatisticType(String type) { 383 type = type.toUpperCase();384 for (StatisticType thisType : StatisticType.values()){385 if (thisType.toString().equals(type)){386 this.type=thisType;387 return;388 }389 }390 //set default391 this.type = StatisticType.USER;405 type = type.toUpperCase(); 406 for (StatisticType thisType : StatisticType.values()) { 407 if (thisType.toString().equals(type)) { 408 this.type = thisType; 409 return; 410 } 411 } 412 // set default 413 this.type = StatisticType.USER; 392 414 } 393 415 394 416 public void setType(StatisticType type) { 395 this.type = type;417 this.type = type; 396 418 } 397 419 398 420 public StatisticType getType() { 399 return type;421 return type; 400 422 } 401 423 402 424 public void setPresentation(Presentation presentation) { 403 this.presentation = presentation;425 this.presentation = presentation; 404 426 } 405 427 406 428 public Presentation getPresentation() { 407 return presentation; 408 } 409 429 return presentation; 430 } 410 431 411 432 public void setSeries(List<Series> series) { 412 this.series = series;433 this.series = series; 413 434 } 414 435 415 436 public List<Series> getSeries() { 416 return series;437 return series; 417 438 } 418 439 … … 422 443 423 444 public void setEventTypeString(String eventType) { 424 for (EventType type : EventType.values()) {425 if (type.toString().equals(eventType)) {445 for (EventType type : EventType.values()) { 446 if (type.toString().equals(eventType)) { 426 447 this.eventType = type; 427 448 } … … 429 450 } 430 451 431 public String getEventTypeString() {452 public String getEventTypeString() { 432 453 return eventType.toString(); 433 454 } … … 438 459 439 460 /** 440 * @param resourceCategory the resourceCategory to set 461 * @param resourceCategory 462 * the resourceCategory to set 441 463 */ 442 464 public void setResourceCategory(ResourceCategory resourceCategory) { … … 451 473 } 452 474 453 public void setResourceCategoryString(String resourceCategory) {454 for (ResourceCategory type : ResourceCategory.values()) {455 if (type.toString().equals(resourceCategory)) {475 public void setResourceCategoryString(String resourceCategory) { 476 for (ResourceCategory type : ResourceCategory.values()) { 477 if (type.toString().equals(resourceCategory)) { 456 478 this.resourceCategory = type; 457 479 } … … 459 481 } 460 482 461 public String getResourceCategoryString() {483 public String getResourceCategoryString() { 462 484 return resourceCategory.toString(); 463 485 } 464 486 465 466 467 468 487 } -
raptor-information-model/trunk/src/main/java/uk/ac/cardiff/model/wsmodel/SuggestionValues.java
r1023 r1178 8 8 import org.slf4j.LoggerFactory; 9 9 10 /** 11 * The Class SuggestionValues. 12 */ 10 13 public class SuggestionValues implements Serializable { 11 14 12 /** 13 * default serial UId 14 */ 15 /** default serial UId. */ 15 16 private static final long serialVersionUID = 7312337340123235532L; 16 17 17 /** Class logger */18 /** Class logger. */ 18 19 private final Logger log = LoggerFactory.getLogger(SuggestionValues.class); 19 20 20 /** The names of all fields from the information model */21 /** The names of all fields from the information model. */ 21 22 private List<Suggestion> possibleFieldNameValues; 22 23 23 /** The possible values of all known fields from the information model */24 /** The possible values of all known fields from the information model. */ 24 25 private List<Suggestion> possibleFieldValues; 25 26 27 /** The possible post processors. */ 26 28 private List<Suggestion> possiblePostProcessors; 27 29 30 /** 31 * Sets the possible field name values. 32 * 33 * @param possibleFieldNameValues 34 * the new possible field name values 35 */ 28 36 public void setPossibleFieldNameValues(List<Suggestion> possibleFieldNameValues) { 29 37 this.possibleFieldNameValues = possibleFieldNameValues; 30 38 } 31 39 40 /** 41 * Gets the possible field name values. 42 * 43 * @return the possible field name values 44 */ 32 45 public List<Suggestion> getPossibleFieldNameValues() { 33 46 return possibleFieldNameValues; 34 47 } 35 48 49 /** 50 * Gets the possible field name values list. 51 * 52 * @return the possible field name values list 53 */ 36 54 public List<String> getPossibleFieldNameValuesList() { 37 55 ArrayList<String> fields = new ArrayList<String>(); … … 44 62 } 45 63 64 /** 65 * Gets the possible field name values list. 66 * 67 * @param classFilters 68 * the class filters 69 * @return the possible field name values list 70 */ 46 71 public List<String> getPossibleFieldNameValuesList(String[] classFilters) { 47 72 ArrayList<String> fields = new ArrayList<String>(); … … 58 83 } 59 84 85 /** 86 * Autocomplete. 87 * 88 * @param fieldName 89 * the field name 90 * @return the array list 91 */ 60 92 public ArrayList<String> autocomplete(String fieldName) { 61 93 log.debug("Suggesting values for selectedfield {}", fieldName); … … 71 103 72 104 /** 105 * Sets the possible field values. 106 * 73 107 * @param possibleFieldValues 74 108 * the possibleFieldValues to set … … 79 113 80 114 /** 115 * Gets the possible field values. 116 * 81 117 * @return the possibleFieldValues 82 118 */ … … 86 122 87 123 /** 124 * Sets the possible post processors. 125 * 88 126 * @param possiblePostProcessors 89 127 * the possiblePostProcessors to set … … 94 132 95 133 /** 134 * Gets the possible post processors. 135 * 96 136 * @return the possiblePostProcessors 97 137 */ … … 100 140 } 101 141 142 /** 143 * Gets the possible post processor values list. 144 * 145 * @return the possible post processor values list 146 */ 102 147 public ArrayList<String> getPossiblePostProcessorValuesList() { 103 148 ArrayList<String> fields = new ArrayList<String>(); -
raptor-information-model/trunk/src/main/java/uk/ac/cardiff/utility/EqualsUtil.java
r367 r1178 4 4 package uk.ac.cardiff.utility; 5 5 6 import java.util.Arrays;7 6 8 7 /** 9 * Collected methods which allow easy implementation of <code>equals</code>. 10 * taken from http://www.javapractices.com/ 11 * 12 * Example use case in a class called Car: 13 * <pre> 14 public boolean equals(Object aThat){ 15 if ( this == aThat ) return true; 16 if ( !(aThat instanceof Car) ) return false; 17 Car that = (Car)aThat; 18 return 19 EqualsUtil.areEqual(this.fName, that.fName) && 20 EqualsUtil.areEqual(this.fNumDoors, that.fNumDoors) && 21 EqualsUtil.areEqual(this.fGasMileage, that.fGasMileage) && 22 EqualsUtil.areEqual(this.fColor, that.fColor) && 23 Arrays.equals(this.fMaintenanceChecks, that.fMaintenanceChecks); //array! 24 } 25 * </pre> 26 * 27 * <em>Arrays are not handled by this class</em>. 28 * This is because the <code>Arrays.equals</code> methods should be used for 29 * array fields. 30 */ 8 * Collected methods which allow easy implementation of <code>equals</code>. taken from http://www.javapractices.com/ 9 * 10 * Example use case in a class called Car: 11 * 12 * <pre> 13 * public boolean equals(Object aThat) { 14 * if (this == aThat) 15 * return true; 16 * if (!(aThat instanceof Car)) 17 * return false; 18 * Car that = (Car) aThat; 19 * return EqualsUtil.areEqual(this.fName, that.fName) && EqualsUtil.areEqual(this.fNumDoors, that.fNumDoors) && EqualsUtil.areEqual(this.fGasMileage, that.fGasMileage) 20 * && EqualsUtil.areEqual(this.fColor, that.fColor) && Arrays.equals(this.fMaintenanceChecks, that.fMaintenanceChecks); // array! 21 * } 22 * </pre> 23 * 24 * <em>Arrays are not handled by this class</em>. This is because the <code>Arrays.equals</code> methods should be used for array fields. 25 */ 31 26 public final class EqualsUtil { 32 27 33 static public boolean areEqual(boolean aThis, boolean aThat){ 34 //System.out.println("boolean"); 35 return aThis == aThat; 36 } 28 static public boolean areEqual(boolean aThis, boolean aThat) { 29 return aThis == aThat; 30 } 37 31 38 static public boolean areEqual(char aThis, char aThat){ 39 //System.out.println("char"); 40 return aThis == aThat; 41 } 32 static public boolean areEqual(char aThis, char aThat) { 33 return aThis == aThat; 34 } 42 35 43 static public boolean areEqual(long aThis, long aThat){ 44 /* 45 * Implementation Note 46 * Note that byte, short, and int are handled by this method, through 47 * implicit conversion. 48 */ 49 //System.out.println("long"); 50 return aThis == aThat; 51 } 36 static public boolean areEqual(long aThis, long aThat) { 37 /* 38 * Implementation Note Note that byte, short, and int are handled by this method, through implicit conversion. 39 */ 40 return aThis == aThat; 41 } 52 42 53 static public boolean areEqual(float aThis, float aThat){ 54 //System.out.println("float"); 55 return Float.floatToIntBits(aThis) == Float.floatToIntBits(aThat); 56 } 43 static public boolean areEqual(float aThis, float aThat) { 44 return Float.floatToIntBits(aThis) == Float.floatToIntBits(aThat); 45 } 57 46 58 static public boolean areEqual(double aThis, double aThat){ 59 //System.out.println("double"); 60 return Double.doubleToLongBits(aThis) == Double.doubleToLongBits(aThat); 61 } 47 static public boolean areEqual(double aThis, double aThat) { 48 return Double.doubleToLongBits(aThis) == Double.doubleToLongBits(aThat); 49 } 62 50 63 /** 64 * Possibly-null object field. 65 * 66 * Includes type-safe enumerations and collections, but does not include 67 * arrays. See class comment. 68 */ 69 static public boolean areEqual(Object aThis, Object aThat){ 70 //System.out.println("Object"); 71 return aThis == null ? aThat == null : aThis.equals(aThat); 72 } 51 /** 52 * Possibly-null object field. 53 * 54 * Includes type-safe enumerations and collections, but does not include arrays. See class comment. 55 */ 56 static public boolean areEqual(Object aThis, Object aThat) { 57 // System.out.println("Object"); 58 return aThis == null ? aThat == null : aThis.equals(aThat); 59 } 73 60 } -
raptor-information-model/trunk/src/main/java/uk/ac/cardiff/utility/HashCodeUtil.java
r367 r1178 5 5 /** 6 6 * Collected methods which allow easy implementation of <code>hashCode</code>. as taken from http://www.javapractices.com/ 7 * 7 * 8 8 * Example use case: 9 * 9 * 10 10 * <pre> 11 11 * public int hashCode() { 12 12 * int result = HashCodeUtil.SEED; 13 * // collect the contributions of various fields13 * // collect the contributions of various fields 14 14 * result = HashCodeUtil.hash(result, fPrimitive); 15 15 * result = HashCodeUtil.hash(result, fObject); … … 31 31 */ 32 32 public static int hash(int aSeed, boolean aBoolean) { 33 //System.out.println("boolean..."); 34 return firstTerm(aSeed) + (aBoolean ? 1 : 0); 33 return firstTerm(aSeed) + (aBoolean ? 1 : 0); 35 34 } 36 35 … … 39 38 */ 40 39 public static int hash(int aSeed, char aChar) { 41 //System.out.println("char..."); 42 return firstTerm(aSeed) + (int) aChar; 40 return firstTerm(aSeed) + (int) aChar; 43 41 } 44 42 … … 47 45 */ 48 46 public static int hash(int aSeed, int aInt) { 49 /* 50 * Implementation Note Note that byte and short are handled by this method, through implicit conversion. 51 */ 52 //System.out.println("int..."); 53 return firstTerm(aSeed) + aInt; 47 /* 48 * Implementation Note Note that byte and short are handled by this method, through implicit conversion. 49 */ 50 return firstTerm(aSeed) + aInt; 54 51 } 55 52 … … 58 55 */ 59 56 public static int hash(int aSeed, long aLong) { 60 //System.out.println("long..."); 61 return firstTerm(aSeed) + (int) (aLong ^ (aLong >>> 32)); 57 return firstTerm(aSeed) + (int) (aLong ^ (aLong >>> 32)); 62 58 } 63 59 … … 66 62 */ 67 63 public static int hash(int aSeed, float aFloat) { 68 return hash(aSeed, Float.floatToIntBits(aFloat));64 return hash(aSeed, Float.floatToIntBits(aFloat)); 69 65 } 70 66 … … 73 69 */ 74 70 public static int hash(int aSeed, double aDouble) { 75 return hash(aSeed, Double.doubleToLongBits(aDouble));71 return hash(aSeed, Double.doubleToLongBits(aDouble)); 76 72 } 77 78 73 79 74 /** 80 75 * <code>aObject</code> is a possibly-null object field, and possibly an array. 81 * 76 * 82 77 * If <code>aObject</code> is an array, then each element may be a primitive or a possibly-null object. 83 78 */ 84 79 public static int hash(int aSeed, Object aObject) { 85 int result = aSeed;86 if (aObject == null) {87 result = hash(result, 0);88 } else if (!isArray(aObject)) {89 result = hash(result, aObject.hashCode());90 } else {91 int length = Array.getLength(aObject);92 for (int idx = 0; idx < length; ++idx) {93 Object item = Array.get(aObject, idx);94 // recursive call!95 result = hash(result, item);96 }97 }98 return result;80 int result = aSeed; 81 if (aObject == null) { 82 result = hash(result, 0); 83 } else if (!isArray(aObject)) { 84 result = hash(result, aObject.hashCode()); 85 } else { 86 int length = Array.getLength(aObject); 87 for (int idx = 0; idx < length; ++idx) { 88 Object item = Array.get(aObject, idx); 89 // recursive call! 90 result = hash(result, item); 91 } 92 } 93 return result; 99 94 } 100 95 101 // / PRIVATE ///102 96 private static final int fODD_PRIME_NUMBER = 37; 103 97 104 98 private static int firstTerm(int aSeed) { 105 return fODD_PRIME_NUMBER * aSeed;99 return fODD_PRIME_NUMBER * aSeed; 106 100 } 107 101 108 102 private static boolean isArray(Object aObject) { 109 return aObject.getClass().isArray();103 return aObject.getClass().isArray(); 110 104 } 111 105 -
raptor-information-model/trunk/src/main/java/uk/ac/cardiff/utility/StringUtils.java
r1172 r1178 7 7 public class StringUtils { 8 8 9 /** 10 * Used to construct a string representation of all field value pairs in the object <code>obj</code> passed in as a parameter to the method. It does this 11 * using reflection. 12 * 13 * @param obj 14 * the object from which to construct a string representation from. 15 * @return a <code>String</code> representation of this object. 16 */ 9 17 public static String buildToString(Object obj) { 10 18 Method[] methods = obj.getClass().getMethods();
Note: See TracChangeset
for help on using the changeset viewer.
