View Javadoc
1   /**
2    * Copyright 2014 Internet2
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *   http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  /*
17   * @author mchyzer
18   * $Id: AuditType.java,v 1.4 2009-04-15 15:56:21 mchyzer Exp $
19   */
20  package edu.internet2.middleware.grouper.audit;
21  
22  import java.io.StringWriter;
23  import java.sql.Timestamp;
24  import java.util.LinkedHashSet;
25  import java.util.Set;
26  
27  import org.apache.commons.lang.StringUtils;
28  import org.apache.commons.lang.builder.EqualsBuilder;
29  import org.apache.commons.lang.builder.HashCodeBuilder;
30  
31  import edu.internet2.middleware.grouper.GrouperAPI;
32  import edu.internet2.middleware.grouper.hibernate.HibernateSession;
33  import edu.internet2.middleware.grouper.internal.dao.QueryOptions;
34  import edu.internet2.middleware.grouper.internal.dao.hib3.Hib3GrouperVersioned;
35  import edu.internet2.middleware.grouper.misc.GrouperDAOFactory;
36  import edu.internet2.middleware.grouper.misc.GrouperVersion;
37  import edu.internet2.middleware.grouper.util.GrouperUtil;
38  import edu.internet2.middleware.grouper.xml.export.XmlExportAuditType;
39  import edu.internet2.middleware.grouper.xml.export.XmlImportable;
40  
41  
42  /**
43   * type of audit
44   */
45  @SuppressWarnings("serial")
46  public class AuditType extends GrouperAPI implements Hib3GrouperVersioned, XmlImportable<AuditType> {
47  
48    //*****  START GENERATED WITH GenerateFieldConstants.java *****//
49  
50    /** constant for field name for: actionName */
51    public static final String FIELD_ACTION_NAME = "actionName";
52  
53    /** constant for field name for: auditCategory */
54    public static final String FIELD_AUDIT_CATEGORY = "auditCategory";
55  
56    /** constant for field name for: contextId */
57    public static final String FIELD_CONTEXT_ID = "contextId";
58  
59    /** constant for field name for: createdOnDb */
60    public static final String FIELD_CREATED_ON_DB = "createdOnDb";
61  
62    /** constant for field name for: id */
63    public static final String FIELD_ID = "id";
64  
65    /** constant for field name for: labelInt01 */
66    public static final String FIELD_LABEL_INT01 = "labelInt01";
67  
68    /** constant for field name for: labelInt02 */
69    public static final String FIELD_LABEL_INT02 = "labelInt02";
70  
71    /** constant for field name for: labelInt03 */
72    public static final String FIELD_LABEL_INT03 = "labelInt03";
73  
74    /** constant for field name for: labelInt04 */
75    public static final String FIELD_LABEL_INT04 = "labelInt04";
76  
77    /** constant for field name for: labelInt05 */
78    public static final String FIELD_LABEL_INT05 = "labelInt05";
79  
80    /** constant for field name for: labelString01 */
81    public static final String FIELD_LABEL_STRING01 = "labelString01";
82  
83    /** constant for field name for: labelString02 */
84    public static final String FIELD_LABEL_STRING02 = "labelString02";
85  
86    /** constant for field name for: labelString03 */
87    public static final String FIELD_LABEL_STRING03 = "labelString03";
88  
89    /** constant for field name for: labelString04 */
90    public static final String FIELD_LABEL_STRING04 = "labelString04";
91  
92    /** constant for field name for: labelString05 */
93    public static final String FIELD_LABEL_STRING05 = "labelString05";
94  
95    /** constant for field name for: labelString06 */
96    public static final String FIELD_LABEL_STRING06 = "labelString06";
97  
98    /** constant for field name for: labelString07 */
99    public static final String FIELD_LABEL_STRING07 = "labelString07";
100 
101   /** constant for field name for: labelString08 */
102   public static final String FIELD_LABEL_STRING08 = "labelString08";
103 
104   /** constant for field name for: lastUpdatedDb */
105   public static final String FIELD_LAST_UPDATED_DB = "lastUpdatedDb";
106 
107   //*****  END GENERATED WITH GenerateFieldConstants.java *****//
108 
109   /**
110    * fields in to string deep method
111    */
112   private static final Set<String> TO_STRING_DEEP_FIELDS = GrouperUtil.toSet(
113       FIELD_ACTION_NAME, FIELD_AUDIT_CATEGORY, FIELD_CONTEXT_ID, FIELD_CREATED_ON_DB, 
114       FIELD_ID, FIELD_LABEL_INT01, FIELD_LABEL_INT02, FIELD_LABEL_INT03, 
115       FIELD_LABEL_INT04, FIELD_LABEL_INT05, FIELD_LABEL_STRING01, FIELD_LABEL_STRING02, 
116       FIELD_LABEL_STRING03, FIELD_LABEL_STRING04, FIELD_LABEL_STRING05, FIELD_LABEL_STRING06, 
117       FIELD_LABEL_STRING07, FIELD_LABEL_STRING08, FIELD_LAST_UPDATED_DB);
118 
119 
120   
121   /**
122    * empty constructor
123    */
124   public AuditType() {
125     
126   }
127   
128   /**
129    * see if one audit type is the same as another (not looking at last update, id, etc)
130    * @param auditType
131    * @return true if equals, false if not
132    */
133   public boolean equalsDeep(AuditType auditType) {
134     
135     return new EqualsBuilder().append(this.actionName, auditType.actionName)
136       .append(this.auditCategory, auditType.auditCategory)
137       .append(this.labelInt01, auditType.labelInt01)
138       .append(this.labelInt02, auditType.labelInt02)
139       .append(this.labelInt03, auditType.labelInt03)
140       .append(this.labelInt04, auditType.labelInt04)
141       .append(this.labelInt05, auditType.labelInt05)
142       .append(this.labelString01, auditType.labelString01)
143       .append(this.labelString02, auditType.labelString02)
144       .append(this.labelString03, auditType.labelString03)
145       .append(this.labelString04, auditType.labelString04)
146       .append(this.labelString05, auditType.labelString05)
147       .append(this.labelString06, auditType.labelString06)
148       .append(this.labelString07, auditType.labelString07)
149       .append(this.labelString08, auditType.labelString08).isEquals();
150       
151   }
152   
153   /**
154    * labels for this type
155    * @return the labels
156    */
157   public Set<String> labels() {
158     Set<String> labels = new LinkedHashSet<String>();
159     if (!StringUtils.isBlank(this.labelString01)) {
160       labels.add(this.labelString01);
161     }
162     if (!StringUtils.isBlank(this.labelString02)) {
163       labels.add(this.labelString02);
164     }
165     if (!StringUtils.isBlank(this.labelString03)) {
166       labels.add(this.labelString03);
167     }
168     if (!StringUtils.isBlank(this.labelString04)) {
169       labels.add(this.labelString04);
170     }
171     if (!StringUtils.isBlank(this.labelString05)) {
172       labels.add(this.labelString05);
173     }
174     if (!StringUtils.isBlank(this.labelString06)) {
175       labels.add(this.labelString06);
176     }
177     if (!StringUtils.isBlank(this.labelString07)) {
178       labels.add(this.labelString07);
179     }
180     if (!StringUtils.isBlank(this.labelString08)) {
181       labels.add(this.labelString08);
182     }
183 
184     if (!StringUtils.isBlank(this.labelInt01)) {
185       labels.add(this.labelInt01);
186     }
187     if (!StringUtils.isBlank(this.labelInt02)) {
188       labels.add(this.labelInt02);
189     }
190     if (!StringUtils.isBlank(this.labelInt03)) {
191       labels.add(this.labelInt03);
192     }
193     if (!StringUtils.isBlank(this.labelInt04)) {
194       labels.add(this.labelInt04);
195     }
196     if (!StringUtils.isBlank(this.labelInt05)) {
197       labels.add(this.labelInt05);
198     }
199     return labels;
200   }
201 
202   
203   /**
204    * get the field in audit entry for this label
205    * @param label
206    * @return the field
207    */
208   public String retrieveAuditEntryFieldForLabel(String label) {
209     return retrieveAuditEntryFieldForLabel(label, true);
210   }
211 
212   /**
213    * get the field in audit entry for this label
214    * @param label
215    * @param exceptionIfNotFound true if exception if not found
216    * @return the field
217    */
218   public String retrieveAuditEntryFieldForLabel(String label, boolean exceptionIfNotFound) {
219     if (StringUtils.equals(label, this.labelString01)) {
220       return "string01";
221     }
222     if (StringUtils.equals(label, this.labelString02)) {
223       return "string02";
224     }
225     if (StringUtils.equals(label, this.labelString03)) {
226       return "string03";
227     }
228     if (StringUtils.equals(label, this.labelString04)) {
229       return "string04";
230     }
231     if (StringUtils.equals(label, this.labelString05)) {
232       return "string05";
233     }
234     if (StringUtils.equals(label, this.labelString06)) {
235       return "string06";
236     }
237     if (StringUtils.equals(label, this.labelString07)) {
238       return "string07";
239     }
240     if (StringUtils.equals(label, this.labelString08)) {
241       return "string08";
242     }
243 
244     if (StringUtils.equals(label, this.labelInt01)) {
245       return "int01";
246     }
247     if (StringUtils.equals(label, this.labelInt02)) {
248       return "int02";
249     }
250     if (StringUtils.equals(label, this.labelInt03)) {
251       return "int03";
252     }
253     if (StringUtils.equals(label, this.labelInt04)) {
254       return "int04";
255     }
256     if (StringUtils.equals(label, this.labelInt05)) {
257       return "int05";
258     }
259     if (exceptionIfNotFound) {
260       throw new RuntimeException("Cant find label '" + label + "' for type: " + this);
261     }
262     return null;
263   }
264   
265   /**
266    * copy the argument into this
267    * @param auditType
268    */
269   public void copyArgFieldIntoThis(AuditType auditType) {
270     this.actionName = auditType.actionName;
271     this.auditCategory = auditType.auditCategory;
272     this.labelInt01 = auditType.labelInt01;
273     this.labelInt02 = auditType.labelInt02;
274     this.labelInt03 = auditType.labelInt03;
275     this.labelInt04 = auditType.labelInt04;
276     this.labelInt05 = auditType.labelInt05;
277     this.labelString01 = auditType.labelString01;
278     this.labelString02 = auditType.labelString02;
279     this.labelString03 = auditType.labelString03;
280     this.labelString04 = auditType.labelString04;
281     this.labelString05 = auditType.labelString05;
282     this.labelString06 = auditType.labelString06;
283     this.labelString07 = auditType.labelString07;
284     this.labelString08 = auditType.labelString08;
285   }
286   
287   /**
288    * the string repre
289    * @return string 
290    */
291   public String toStringDeep() {
292     return GrouperUtil.toStringFields(this, TO_STRING_DEEP_FIELDS);
293   }
294   
295   /**
296    * 
297    * @see java.lang.Object#toString()
298    */
299   public String toString() {
300     return "Audit type: " + this.auditCategory + ": " + this.actionName;
301   }
302   
303   /**
304    * construct with more params
305    * @param auditCategory1
306    * @param actionName1
307    * @param labelInt01a
308    * @param labelStrings up to 8 label strings
309    */
310   public AuditType(String auditCategory1, String actionName1, String labelInt01a, String... labelStrings) {
311     this.auditCategory = auditCategory1;
312     this.actionName = actionName1;
313     this.labelInt01 = labelInt01a;
314 
315     int index=1;
316     for (String labelString : GrouperUtil.nonNull(labelStrings, String.class)) {
317       GrouperUtil.assignField(this, "labelString" + (index<10 ? "0" : "") + index, labelString);
318       if (index > 8) {
319         throw new RuntimeException("Cant send more than 8 labelStrings: " + labelStrings.length);
320       }
321       index++;
322     }
323   }
324   
325   
326   /**
327    * 
328    * @see java.lang.Object#equals(java.lang.Object)
329    */
330   @Override
331   public boolean equals(Object obj) {
332     if (obj == this) {
333       return true;
334     }
335     if (!(obj instanceof AuditType)) {
336       return false;
337     }
338     AuditType/../edu/internet2/middleware/grouper/audit/AuditType.html#AuditType">AuditType otherAuditType = (AuditType)obj;
339     return new EqualsBuilder().append(this.auditCategory, otherAuditType.auditCategory)
340       .append(this.actionName, otherAuditType.actionName).isEquals();
341   }
342 
343   /**
344    * 
345    * @see java.lang.Object#hashCode()
346    */
347   @Override
348   public int hashCode() {
349     return new HashCodeBuilder().append(this.auditCategory)
350       .append(this.actionName).hashCode();
351   }
352 
353   /** name of the grouper audit type table in the db */
354   public static final String TABLE_GROUPER_AUDIT_TYPE = "grouper_audit_type";
355   
356   /** id of this type */
357   private String id;
358 
359   /** friendly label for the audit type */
360   private String auditCategory;
361   
362   /** friendly label for the action in the category */
363   private String actionName;
364   
365   /** when this record was last updated */
366   private Long lastUpdatedDb;
367   
368   /** when this record was created */
369   private Long createdOnDb;
370   
371   /** label for the string01 field */
372   private String labelString01;
373   
374   /** label for the string02 field */
375   private String labelString02;
376   
377   /** label for the string03 field */
378   private String labelString03;
379   
380   /** label for the string04 field */
381   private String labelString04;
382   
383   /** label for the string05 field */
384   private String labelString05;
385   
386   /** label for the string06 field */
387   private String labelString06;
388   
389   /** label for the string07 field */
390   private String labelString07;
391   
392   /** label for the string08 field */
393   private String labelString08;
394   
395   /** context id ties multiple db changes  */
396   private String contextId;
397   
398   /** label for the int01 field */
399   private String labelInt01;
400   
401   /** label for the int02 field */
402   private String labelInt02;
403 
404   /** label for the int03 field */
405   private String labelInt03;
406   
407   /** label for the int04 field */
408   private String labelInt04;
409   
410   /** label for the int05 field */
411   private String labelInt05;
412 
413   /**
414    * uuid of row
415    * @return id
416    */
417   public String getId() {
418     return this.id;
419   }
420 
421   /**
422    * uuid of row
423    * @param id1
424    */
425   public void setId(String id1) {
426     this.id = id1;
427   }
428 
429   /**
430    * category of audit
431    * @return audit type
432    */
433   public String getAuditCategory() {
434     return this.auditCategory;
435   }
436 
437   /**
438    * category of audit
439    * @param auditType1
440    */
441   public void setAuditCategory(String auditType1) {
442     this.auditCategory = auditType1;
443   }
444 
445   /**
446    * action within the audit category
447    * @return the action name
448    */
449   public String getActionName() {
450     return this.actionName;
451   }
452 
453   /**
454    * action within the audit category
455    * @param actionName
456    */
457   public void setActionName(String actionName) {
458     this.actionName = actionName;
459   }
460 
461   /**
462    * when last updated
463    * @return timestamp
464    */
465   public Timestamp getLastUpdated() {
466     return this.lastUpdatedDb == null ? null : new Timestamp(this.lastUpdatedDb);
467   }
468 
469   /**
470    * when last updated
471    * @return timestamp
472    */
473   public Long getLastUpdatedDb() {
474     return this.lastUpdatedDb;
475   }
476 
477   /**
478    * when last updated
479    * @param lastUpdated1
480    */
481   public void setLastUpdated(Timestamp lastUpdated1) {
482     this.lastUpdatedDb = lastUpdated1 == null ? null : lastUpdated1.getTime();
483   }
484 
485   /**
486    * when last updated
487    * @param lastUpdated1
488    */
489   public void setLastUpdatedDb(Long lastUpdated1) {
490     this.lastUpdatedDb = lastUpdated1;
491   }
492 
493   /**
494    * when created
495    * @return timestamp
496    */
497   public Timestamp getCreatedOn() {
498     return this.createdOnDb == null ? null : new Timestamp(this.createdOnDb);
499   }
500 
501   /**
502    * when created
503    * @return timestamp
504    */
505   public Long getCreatedOnDb() {
506     return this.createdOnDb;
507   }
508 
509   /**
510    * when created
511    * @param createdOn1
512    */
513   public void setCreatedOn(Timestamp createdOn1) {
514     this.createdOnDb = createdOn1 == null ? null : createdOn1.getTime();
515   }
516 
517   /**
518    * when created
519    * @param createdOn1
520    */
521   public void setCreatedOnDb(Long createdOn1) {
522     this.createdOnDb = createdOn1;
523   }
524 
525   /**
526    * 
527    * @see edu.internet2.middleware.grouper.GrouperAPI#onPreSave(edu.internet2.middleware.grouper.hibernate.HibernateSession)
528    */
529   @Override
530   public void onPreSave(HibernateSession hibernateSession) {
531     super.onPreSave(hibernateSession);
532     if (this.createdOnDb == null) {
533       this.createdOnDb = System.currentTimeMillis();
534     }
535     if (this.lastUpdatedDb == null) {
536       this.lastUpdatedDb = System.currentTimeMillis();
537     }
538   }
539 
540   /**
541    * 
542    * @see edu.internet2.middleware.grouper.GrouperAPI#onPreUpdate(edu.internet2.middleware.grouper.hibernate.HibernateSession)
543    */
544   @Override
545   public void onPreUpdate(HibernateSession hibernateSession) {
546     super.onPreUpdate(hibernateSession);
547     this.lastUpdatedDb = System.currentTimeMillis();
548   }
549 
550   /**
551    * label for string01
552    * @return label
553    */
554   public String getLabelString01() {
555     return this.labelString01;
556   }
557 
558   /**
559    * label for string01
560    * @param labelString01a
561    */
562   public void setLabelString01(String labelString01a) {
563     this.labelString01 = labelString01a;
564   }
565 
566   /**
567    * label for string02
568    * @return label
569    */
570   public String getLabelString02() {
571     return this.labelString02;
572   }
573 
574   /**
575    * label for string02
576    * @param labelString02a
577    */
578   public void setLabelString02(String labelString02a) {
579     this.labelString02 = labelString02a;
580   }
581 
582   /**
583    * label for string03
584    * @return label
585    */
586   public String getLabelString03() {
587     return this.labelString03;
588   }
589 
590   /**
591    * label for string03
592    * @param labelString03a
593    */
594   public void setLabelString03(String labelString03a) {
595     this.labelString03 = labelString03a;
596   }
597 
598   /**
599    * label for string04
600    * @return label
601    */
602   public String getLabelString04() {
603     return this.labelString04;
604   }
605 
606   /**
607    * label for string04
608    * @param labelString04a
609    */
610   public void setLabelString04(String labelString04a) {
611     this.labelString04 = labelString04a;
612   }
613 
614   /**
615    * label for string05
616    * @return label
617    */
618   public String getLabelString05() {
619     return this.labelString05;
620   }
621 
622   /**
623    * label for string05
624    * @param labelString05a
625    */
626   public void setLabelString05(String labelString05a) {
627     this.labelString05 = labelString05a;
628   }
629 
630   /**
631    * context id ties multiple db changes
632    * @return id
633    */
634   public String getContextId() {
635     return this.contextId;
636   }
637 
638   /**
639    * context id ties multiple db changes
640    * @param contextId1
641    */
642   public void setContextId(String contextId1) {
643     this.contextId = contextId1;
644   }
645 
646   /**
647    * label for int01
648    * @return label
649    */
650   public String getLabelInt01() {
651     return this.labelInt01;
652   }
653 
654   /**
655    * label for int01
656    * @param labelInt01a
657    */
658   public void setLabelInt01(String labelInt01a) {
659     this.labelInt01 = labelInt01a;
660   }
661 
662   /**
663    * label for int02
664    * @return label
665    */
666   public String getLabelInt02() {
667     return this.labelInt02;
668   }
669 
670   /**
671    * label for int02
672    * @param labelInt02a
673    */
674   public void setLabelInt02(String labelInt02a) {
675     this.labelInt02 = labelInt02a;
676   }
677   
678   /**
679    * label for int03
680    * @return label
681    */
682   public String getLabelInt03() {
683     return this.labelInt03;
684   }
685 
686   /**
687    * label for int03
688    * @param labelInt03a
689    */
690   public void setLabelInt03(String labelInt03a) {
691     this.labelInt03 = labelInt03a;
692   }
693 
694   /**
695    * label for int04
696    * @return label
697    */
698   public String getLabelInt04() {
699     return this.labelInt04;
700   }
701 
702   /**
703    * label for int04
704    * @param labelInt04a
705    */
706   public void setLabelInt04(String labelInt04a) {
707     this.labelInt04 = labelInt04a;
708   }
709 
710   /**
711    * label for int05
712    * @return label
713    */
714   public String getLabelInt05() {
715     return this.labelInt05;
716   }
717 
718   /**
719    * label for int05
720    * @param labelInt05
721    */
722   public void setLabelInt05(String labelInt05) {
723     this.labelInt05 = labelInt05;
724   }
725   
726   /**
727    * make sure this object will fit in the DB
728    */
729   public void truncate() {
730     this.actionName = GrouperUtil.truncateAscii(this.actionName, 50);
731     this.auditCategory = GrouperUtil.truncateAscii(this.auditCategory, 50);
732     this.contextId = GrouperUtil.truncateAscii(this.id, 128);
733     this.id = GrouperUtil.truncateAscii(this.id, 128);
734     this.labelInt01 = GrouperUtil.truncateAscii(this.labelInt01, 50);
735     this.labelInt02 = GrouperUtil.truncateAscii(this.labelInt02, 50);
736     this.labelInt03 = GrouperUtil.truncateAscii(this.labelInt03, 50);
737     this.labelInt04 = GrouperUtil.truncateAscii(this.labelInt04, 50);
738     this.labelInt05 = GrouperUtil.truncateAscii(this.labelInt05, 50);
739     this.labelString01 = GrouperUtil.truncateAscii(this.labelString01, 50);
740     this.labelString02 = GrouperUtil.truncateAscii(this.labelString02, 50);
741     this.labelString03 = GrouperUtil.truncateAscii(this.labelString03, 50);
742     this.labelString04 = GrouperUtil.truncateAscii(this.labelString04, 50);
743     this.labelString05 = GrouperUtil.truncateAscii(this.labelString05, 50);
744     this.labelString06 = GrouperUtil.truncateAscii(this.labelString06, 50);
745     this.labelString07 = GrouperUtil.truncateAscii(this.labelString07, 50);
746     this.labelString08 = GrouperUtil.truncateAscii(this.labelString08, 50);
747   }
748 
749   /**
750    * label for the string06 field
751    * @return label
752    */
753   public String getLabelString06() {
754     return this.labelString06;
755   }
756 
757   /**
758    * label for the string06 field
759    * @param labelString06a
760    */
761   public void setLabelString06(String labelString06a) {
762     this.labelString06 = labelString06a;
763   }
764 
765   /**
766    * label for the string07 field
767    * @return label
768    */
769   public String getLabelString07() {
770     return this.labelString07;
771   }
772 
773   /**
774    * label for the string07 field
775    * @param labelString07a
776    */
777   public void setLabelString07(String labelString07a) {
778     this.labelString07 = labelString07a;
779   }
780 
781   /**
782    * label for the string08 field
783    * @return label
784    */
785   public String getLabelString08() {
786     return this.labelString08;
787   }
788 
789   /**
790    * label for the string08 field
791    * @param labelString08a
792    */
793   public void setLabelString08(String labelString08a) {
794     this.labelString08 = labelString08a;
795   }
796 
797   /**
798    * @see edu.internet2.middleware.grouper.GrouperAPI#clone()
799    */
800   @Override
801   public GrouperAPI clone() {
802     throw new RuntimeException("not implemented");
803   }
804 
805   /**
806    * @see edu.internet2.middleware.grouper.xml.export.XmlImportable#xmlRetrieveByIdOrKey()
807    */
808   public XmlImportable<AuditType> xmlRetrieveByIdOrKey() {
809     return GrouperDAOFactory.getFactory().getAuditType().findByUuidOrName(this.id, this.auditCategory, this.actionName, false,
810         new QueryOptions().secondLevelCache(false));
811   }
812 
813   /**
814    * @see edu.internet2.middleware.grouper.xml.export.XmlImportableBase#xmlCopyBusinessPropertiesToExisting(java.lang.Object)
815    */
816   public void xmlCopyBusinessPropertiesToExisting(AuditType existingRecord) {
817     existingRecord.setActionName(this.actionName);
818     existingRecord.setAuditCategory(this.auditCategory);
819     existingRecord.setId(this.id);
820     existingRecord.setLabelInt01(this.labelInt01);
821     existingRecord.setLabelInt02(this.labelInt02);
822     existingRecord.setLabelInt03(this.labelInt03);
823     existingRecord.setLabelInt04(this.labelInt04);
824     existingRecord.setLabelInt05(this.labelInt05);
825     existingRecord.setLabelString01(this.labelString01);
826     existingRecord.setLabelString02(this.labelString02);
827     existingRecord.setLabelString03(this.labelString03);
828     existingRecord.setLabelString04(this.labelString04);
829     existingRecord.setLabelString05(this.labelString05);
830     existingRecord.setLabelString06(this.labelString06);
831     existingRecord.setLabelString07(this.labelString07);
832     existingRecord.setLabelString08(this.labelString08);
833   }
834 
835   /**
836    * @see edu.internet2.middleware.grouper.xml.export.XmlImportableBase#xmlDifferentBusinessProperties(java.lang.Object)
837    */
838   public boolean xmlDifferentBusinessProperties(AuditType other) {
839     if (!StringUtils.equals(this.actionName, other.actionName)) {
840       return true;
841     }
842     if (!StringUtils.equals(this.auditCategory, other.auditCategory)) {
843       return true;
844     }
845     if (!StringUtils.equals(this.id, other.id)) {
846       return true;
847     }
848     if (!StringUtils.equals(this.labelInt01, other.labelInt01)) {
849       return true;
850     }
851     if (!StringUtils.equals(this.labelInt02, other.labelInt02)) {
852       return true;
853     }
854     if (!StringUtils.equals(this.labelInt03, other.labelInt03)) {
855       return true;
856     }
857     if (!StringUtils.equals(this.labelInt04, other.labelInt04)) {
858       return true;
859     }
860     if (!StringUtils.equals(this.labelInt05, other.labelInt05)) {
861       return true;
862     }
863     if (!StringUtils.equals(this.labelString01, other.labelString01)) {
864       return true;
865     }
866     if (!StringUtils.equals(this.labelString02, other.labelString02)) {
867       return true;
868     }
869     if (!StringUtils.equals(this.labelString03, other.labelString03)) {
870       return true;
871     }
872     if (!StringUtils.equals(this.labelString04, other.labelString04)) {
873       return true;
874     }
875     if (!StringUtils.equals(this.labelString05, other.labelString05)) {
876       return true;
877     }
878     if (!StringUtils.equals(this.labelString06, other.labelString06)) {
879       return true;
880     }
881     if (!StringUtils.equals(this.labelString07, other.labelString07)) {
882       return true;
883     }
884     if (!StringUtils.equals(this.labelString08, other.labelString08)) {
885       return true;
886     }
887 
888     return false;
889   }
890 
891   /**
892    * @see edu.internet2.middleware.grouper.xml.export.XmlImportableBase#xmlDifferentUpdateProperties(java.lang.Object)
893    */
894   public boolean xmlDifferentUpdateProperties(AuditType other) {
895     if (!StringUtils.equals(this.contextId, other.contextId)) {
896       return true;
897     }
898     if (!GrouperUtil.equals(this.createdOnDb, other.createdOnDb)) {
899       return true;
900     }
901     if (!GrouperUtil.equals(this.getHibernateVersionNumber(), other.getHibernateVersionNumber())) {
902       return true;
903     }
904     if (!GrouperUtil.equals(this.lastUpdatedDb, other.lastUpdatedDb)) {
905       return true;
906     }
907     return false;
908   }
909 
910   /**
911    * @see edu.internet2.middleware.grouper.xml.export.XmlImportableBase#xmlGetId()
912    */
913   public String xmlGetId() {
914     return this.getId();
915   }
916 
917   /**
918    * @see edu.internet2.middleware.grouper.xml.export.XmlImportableBase#xmlSaveBusinessProperties(java.lang.Object)
919    */
920   public AuditTypeinternet2/middleware/grouper/audit/AuditType.html#AuditType">AuditType xmlSaveBusinessProperties(AuditType existingRecord) {
921     //if its an insert, call the business method
922     if (existingRecord == null) {
923       existingRecord = new AuditType();
924       existingRecord.setAuditCategory(this.auditCategory);
925       existingRecord.setActionName(this.actionName);
926       existingRecord.setId(this.id);
927     }
928     this.xmlCopyBusinessPropertiesToExisting(existingRecord);
929     //if its an insert or update, then do the rest of the fields
930     GrouperDAOFactory.getFactory().getAuditType().saveOrUpdate(existingRecord);
931     AuditTypeFinder.clearCache();
932     return existingRecord;
933   }
934 
935   /**
936    * @see edu.internet2.middleware.grouper.xml.export.XmlImportableBase#xmlSaveUpdateProperties()
937    */
938   public void xmlSaveUpdateProperties() {
939     GrouperDAOFactory.getFactory().getAuditType().saveUpdateProperties(this);
940   }
941 
942   /**
943    * @see edu.internet2.middleware.grouper.xml.export.XmlImportableBase#xmlSetId(java.lang.String)
944    */
945   public void xmlSetId(String theId) {
946     this.setId(theId);
947   }
948 
949   /**
950    * convert to xml bean for export
951    * @param grouperVersion
952    * @return xml bean
953    */
954   public XmlExportAuditType xmlToExportAuditType(GrouperVersion grouperVersion) {
955     if (grouperVersion == null) {
956       throw new RuntimeException();
957     }
958     
959     XmlExportAuditTypeportAuditType.html#XmlExportAuditType">XmlExportAuditType xmlExportAuditType = new XmlExportAuditType();
960     xmlExportAuditType.setActionName(this.getActionName());
961     xmlExportAuditType.setAuditCategory(this.getAuditCategory());
962     xmlExportAuditType.setContextId(this.getContextId());
963     xmlExportAuditType.setCreatedOn(GrouperUtil.dateStringValue(this.getCreatedOnDb()));
964     xmlExportAuditType.setHibernateVersionNumber(GrouperUtil.longValue(this.getHibernateVersionNumber(), 0));
965     xmlExportAuditType.setId(this.getId());
966     xmlExportAuditType.setLabelInt01(this.getLabelInt01());
967     xmlExportAuditType.setLabelInt02(this.getLabelInt02());
968     xmlExportAuditType.setLabelInt03(this.getLabelInt03());
969     xmlExportAuditType.setLabelInt04(this.getLabelInt04());
970     xmlExportAuditType.setLabelInt05(this.getLabelInt05());
971     xmlExportAuditType.setLabelString01(this.getLabelString01());
972     xmlExportAuditType.setLabelString02(this.getLabelString02());
973     xmlExportAuditType.setLabelString03(this.getLabelString03());
974     xmlExportAuditType.setLabelString04(this.getLabelString04());
975     xmlExportAuditType.setLabelString05(this.getLabelString05());
976     xmlExportAuditType.setLabelString06(this.getLabelString06());
977     xmlExportAuditType.setLabelString07(this.getLabelString07());
978     xmlExportAuditType.setLabelString08(this.getLabelString08());
979     xmlExportAuditType.setLastUpdated(GrouperUtil.dateStringValue(this.getLastUpdatedDb()));
980     return xmlExportAuditType;
981   }
982 
983   /**
984    * @see edu.internet2.middleware.grouper.xml.export.XmlImportableBase#xmlToString()
985    */
986   public String xmlToString() {
987     StringWriter stringWriter = new StringWriter();
988     
989     stringWriter.write("AuditType: " + this.getId() + ", " + this.auditCategory + " - " + this.actionName);
990 
991     return stringWriter.toString();
992     
993   }
994 
995 }