| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.kns.util.documentserializer; |
| 17 | |
|
| 18 | |
import java.util.ArrayList; |
| 19 | |
import java.util.List; |
| 20 | |
|
| 21 | |
import org.apache.commons.lang.StringUtils; |
| 22 | |
import org.kuali.rice.kns.datadictionary.DataDictionary; |
| 23 | |
import org.kuali.rice.kns.datadictionary.MaintainableCollectionDefinition; |
| 24 | |
import org.kuali.rice.kns.datadictionary.MaintainableFieldDefinition; |
| 25 | |
import org.kuali.rice.kns.datadictionary.MaintainableItemDefinition; |
| 26 | |
import org.kuali.rice.kns.datadictionary.MaintainableSectionDefinition; |
| 27 | |
import org.kuali.rice.kns.datadictionary.MaintainableSubSectionHeaderDefinition; |
| 28 | |
import org.kuali.rice.kns.datadictionary.MaintenanceDocumentEntry; |
| 29 | |
import org.kuali.rice.kns.service.KNSServiceLocatorWeb; |
| 30 | |
|
| 31 | |
|
| 32 | 0 | public class MaintenanceDocumentPropertySerializibilityEvaluator |
| 33 | |
extends PropertySerializabilityEvaluatorBase implements PropertySerializabilityEvaluator { |
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
@Override |
| 41 | |
public void initializeEvaluatorForDataObject(Object businessObject){ |
| 42 | 0 | DataDictionary dictionary = KNSServiceLocatorWeb.getDataDictionaryService().getDataDictionary(); |
| 43 | 0 | MaintenanceDocumentEntry maintenanceDocumentEntry = |
| 44 | |
dictionary.getMaintenanceDocumentEntryForBusinessObjectClass(businessObject.getClass()); |
| 45 | 0 | serializableProperties = new PropertySerializerTrie(); |
| 46 | 0 | populateSerializableProperties(maintenanceDocumentEntry.getMaintainableSections()); |
| 47 | 0 | serializableProperties.addSerializablePropertyName("boNotes", true); |
| 48 | 0 | serializableProperties.addSerializablePropertyName("boNotes.attachment", true); |
| 49 | 0 | } |
| 50 | |
|
| 51 | |
private void populateSerializableProperties(List<MaintainableSectionDefinition> maintainableSectionDefinitions){ |
| 52 | 0 | for(MaintainableSectionDefinition maintainableSectionDefinition: maintainableSectionDefinitions){ |
| 53 | 0 | populateSerializablePropertiesWithItems("", maintainableSectionDefinition.getMaintainableItems()); |
| 54 | |
} |
| 55 | 0 | } |
| 56 | |
|
| 57 | |
private void populateSerializablePropertiesWithItems(String basePath, List<MaintainableItemDefinition> maintainableItems){ |
| 58 | 0 | for(MaintainableItemDefinition maintainableItemDefinition: maintainableItems){ |
| 59 | 0 | if(maintainableItemDefinition instanceof MaintainableFieldDefinition){ |
| 60 | 0 | serializableProperties.addSerializablePropertyName(getFullItemName(basePath, maintainableItemDefinition.getName()), true); |
| 61 | 0 | } else if(maintainableItemDefinition instanceof MaintainableCollectionDefinition){ |
| 62 | 0 | serializableProperties.addSerializablePropertyName(getFullItemName(basePath, maintainableItemDefinition.getName()), true); |
| 63 | 0 | populateSerializablePropertiesWithItems(getFullItemName(basePath, maintainableItemDefinition.getName()), |
| 64 | |
getAllMaintainableFieldDefinitionsForSerialization( |
| 65 | |
(MaintainableCollectionDefinition)maintainableItemDefinition)); |
| 66 | 0 | } else if(maintainableItemDefinition instanceof MaintainableSubSectionHeaderDefinition){ |
| 67 | |
|
| 68 | |
} |
| 69 | |
} |
| 70 | 0 | } |
| 71 | |
|
| 72 | |
private String getFullItemName(String basePath, String itemName){ |
| 73 | 0 | return StringUtils.isEmpty(basePath) ? itemName : basePath+"."+itemName; |
| 74 | |
} |
| 75 | |
|
| 76 | |
public List<MaintainableItemDefinition> getAllMaintainableFieldDefinitionsForSerialization( |
| 77 | |
MaintainableCollectionDefinition maintainableCollectionDefinition){ |
| 78 | 0 | List<MaintainableItemDefinition> allMaintainableItemDefinitions = new ArrayList<MaintainableItemDefinition>(); |
| 79 | |
|
| 80 | 0 | if(maintainableCollectionDefinition.getMaintainableFields()!=null){ |
| 81 | 0 | allMaintainableItemDefinitions.addAll(maintainableCollectionDefinition.getMaintainableFields()); |
| 82 | |
} |
| 83 | |
|
| 84 | 0 | if(maintainableCollectionDefinition.getSummaryFields()!=null){ |
| 85 | 0 | allMaintainableItemDefinitions.addAll( |
| 86 | |
(List<MaintainableFieldDefinition>)maintainableCollectionDefinition.getSummaryFields()); |
| 87 | |
} |
| 88 | |
|
| 89 | 0 | if(maintainableCollectionDefinition.getDuplicateIdentificationFields()!=null){ |
| 90 | 0 | allMaintainableItemDefinitions.addAll(maintainableCollectionDefinition.getDuplicateIdentificationFields()); |
| 91 | |
} |
| 92 | |
|
| 93 | |
|
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | 0 | if(maintainableCollectionDefinition.getMaintainableCollections()!=null){ |
| 98 | 0 | allMaintainableItemDefinitions.addAll(maintainableCollectionDefinition.getMaintainableCollections()); |
| 99 | |
} |
| 100 | |
|
| 101 | 0 | return allMaintainableItemDefinitions; |
| 102 | |
} |
| 103 | |
|
| 104 | |
} |