View Javadoc
1   /*
2    * Copyright 2010 The Regents of the University of California.
3    */
4   package org.kuali.ole.sys.web.dddumper;
5   
6   import java.util.ArrayList;
7   import java.util.HashSet;
8   import java.util.List;
9   import java.util.Set;
10  
11  import org.apache.log4j.Logger;
12  import org.kuali.rice.kns.datadictionary.BusinessObjectEntry;
13  import org.kuali.rice.kns.datadictionary.MaintenanceDocumentEntry;
14  import org.kuali.rice.kns.document.MaintenanceDocument;
15  import org.kuali.rice.kns.web.struts.form.KualiForm;
16  import org.kuali.rice.krad.bo.BusinessObject;
17  import org.kuali.rice.krad.bo.GlobalBusinessObject;
18  import org.kuali.rice.krad.datadictionary.DataDictionaryEntry;
19  import org.kuali.rice.krad.datadictionary.DocumentEntry;
20  import org.kuali.rice.krad.service.KRADServiceLocator;
21  
22  public class DataDictionaryDumperForm extends KualiForm {
23  	private static final long serialVersionUID = 3632283509506923869L;
24      private Set<DataDictionaryEntry> dataDictionaryEntries = new HashSet<DataDictionaryEntry>();
25      private List<BusinessObjectEntry> businessObjectEntries = new ArrayList<BusinessObjectEntry>();
26      private List<DocumentEntry> documentEntries = new ArrayList<DocumentEntry>();
27      private List<DocumentEntry> maintenanceDocumentEntries = new ArrayList<DocumentEntry>();
28      private List<DocumentEntry> transactionalDocumentEntries = new ArrayList<DocumentEntry>();
29  
30      private static final Logger LOG = Logger.getLogger(DataDictionaryDumperForm.class);
31  
32      public Set<DataDictionaryEntry> getDataDictionaryEntries() {
33  		return dataDictionaryEntries;
34  	}
35  	public void setDataDictionaryEntries(Set<DataDictionaryEntry> dataDictionaryEntries) {
36  		this.dataDictionaryEntries = dataDictionaryEntries;
37  	}
38  	public List<DocumentEntry> getDocumentEntries() {
39  		return documentEntries;
40  	}
41  	public void setDocumentEntries(List<DocumentEntry> documentEntries) {
42  		for (DocumentEntry currentEntry : documentEntries){
43  //			try{
44  //				if (!KNSServiceLocator.getWorkflowInfoService().isCurrentActiveDocumentType(currentEntry.getDocumentTypeName())) continue; //Skip inactive.
45  //			}catch (WorkflowException we){
46  //				if(LOG.isInfoEnabled()){
47  //					LOG.info("Doc "+currentEntry.getDocumentTypeName()+" not listed due to exception. ", we);
48  //				}
49  //				continue; //Assume if this happens that we just want to skip this doc type.
50  //			}
51  			if (MaintenanceDocument.class.isAssignableFrom(currentEntry.getDocumentClass())){
52  				Class<? extends BusinessObject> boClass = ((MaintenanceDocumentEntry)currentEntry).getBusinessObjectClass();
53  
54  				if( GlobalBusinessObject.class.isAssignableFrom(boClass) )
55                   {
56                      continue; //Skip globals.
57                  }
58  				if ( !KRADServiceLocator.getPersistenceStructureService().isPersistable( boClass ))
59                   {
60                      continue;  //Skip user and its ilk.
61                  }
62  
63  				addMaintenanceDocumentEntry(currentEntry);
64  			}else{
65  				addTransactionalDocumentEntry(currentEntry);
66  			}
67  		}
68  		this.documentEntries = documentEntries;
69  	}
70  	public List<BusinessObjectEntry> getBusinessObjectEntries() {
71  		return businessObjectEntries;
72  	}
73  	public void setBusinessObjectEntries(
74  			List<BusinessObjectEntry> businessObjectEntries) {
75  		this.businessObjectEntries = businessObjectEntries;
76  	}
77  	public List<DocumentEntry> getMaintenanceDocumentEntries() {
78  		return maintenanceDocumentEntries;
79  	}
80  	public void addMaintenanceDocumentEntry(DocumentEntry maintenanceDocumentEntry) {
81  		this.maintenanceDocumentEntries.add(maintenanceDocumentEntry);
82  	}
83  	public List<DocumentEntry> getTransactionalDocumentEntries() {
84  		return transactionalDocumentEntries;
85  	}
86  	public void addTransactionalDocumentEntry(DocumentEntry transactionalDocumentEntry) {
87  		this.transactionalDocumentEntries.add(transactionalDocumentEntry);
88  	}
89  
90  }