| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.kim.document; |
| 17 | |
|
| 18 | |
import java.util.List; |
| 19 | |
|
| 20 | |
import org.apache.commons.lang.StringUtils; |
| 21 | |
import org.apache.log4j.Logger; |
| 22 | |
import org.kuali.rice.core.xml.dto.AttributeSet; |
| 23 | |
import org.kuali.rice.kew.util.KEWConstants; |
| 24 | |
import org.kuali.rice.kim.bo.impl.ResponsibilityImpl; |
| 25 | |
import org.kuali.rice.kim.bo.impl.ReviewResponsibility; |
| 26 | |
import org.kuali.rice.kim.bo.role.dto.KimResponsibilityTemplateInfo; |
| 27 | |
import org.kuali.rice.kim.bo.role.impl.KimResponsibilityImpl; |
| 28 | |
import org.kuali.rice.kim.service.KIMServiceLocator; |
| 29 | |
import org.kuali.rice.kim.service.KIMServiceLocatorInternal; |
| 30 | |
import org.kuali.rice.kim.util.KimConstants; |
| 31 | |
import org.kuali.rice.kns.bo.BusinessObject; |
| 32 | |
import org.kuali.rice.kns.bo.PersistableBusinessObject; |
| 33 | |
import org.kuali.rice.kns.document.MaintenanceDocument; |
| 34 | |
import org.kuali.rice.kns.maintenance.KualiMaintainableImpl; |
| 35 | |
import org.kuali.rice.kns.maintenance.Maintainable; |
| 36 | |
import org.kuali.rice.kns.web.ui.Field; |
| 37 | |
import org.kuali.rice.kns.web.ui.Row; |
| 38 | |
import org.kuali.rice.kns.web.ui.Section; |
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | 0 | public class ReviewResponsibilityMaintainable extends KualiMaintainableImpl { |
| 47 | |
|
| 48 | 0 | private static final Logger LOG = Logger.getLogger( ReviewResponsibilityMaintainable.class ); |
| 49 | |
private static final long serialVersionUID = -8102504656976243468L; |
| 50 | |
|
| 51 | 0 | protected static String reviewTemplateId = null; |
| 52 | |
|
| 53 | |
public List getSections(MaintenanceDocument document, Maintainable oldMaintainable) { |
| 54 | 0 | List<Section> sections = super.getSections(document, oldMaintainable); |
| 55 | 0 | if(document.isEdit()){ |
| 56 | 0 | for (Section section : sections) { |
| 57 | 0 | for (Row row : section.getRows()) { |
| 58 | 0 | for (Field field : row.getFields()) { |
| 59 | 0 | if(ReviewResponsibility.ACTION_DETAILS_AT_ROLE_MEMBER_LEVEL_FIELD_NAME.equals(field.getPropertyName())){ |
| 60 | 0 | field.setReadOnly(true); |
| 61 | |
} |
| 62 | |
} |
| 63 | |
} |
| 64 | |
} |
| 65 | |
} |
| 66 | 0 | return sections; |
| 67 | |
} |
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
@Override |
| 75 | |
public void saveBusinessObject() { |
| 76 | |
try { |
| 77 | 0 | if ( LOG.isInfoEnabled() ) { |
| 78 | 0 | LOG.info( "Attempting to save ReviewResponsibility BO via ResponsibilityUpdateService:" + getBusinessObject() ); |
| 79 | |
} |
| 80 | |
|
| 81 | 0 | if ( reviewTemplateId == null ) { |
| 82 | 0 | populateReviewTemplateInfo(); |
| 83 | |
} |
| 84 | 0 | ReviewResponsibility resp = (ReviewResponsibility)getBusinessObject(); |
| 85 | |
|
| 86 | 0 | AttributeSet details = new AttributeSet(); |
| 87 | 0 | details.put( KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME, resp.getDocumentTypeName() ); |
| 88 | 0 | details.put( KimConstants.AttributeConstants.ROUTE_NODE_NAME, resp.getRouteNodeName() ); |
| 89 | 0 | details.put( KimConstants.AttributeConstants.REQUIRED, resp.isRequired()?"true":"false" ); |
| 90 | 0 | details.put( KimConstants.AttributeConstants.ACTION_DETAILS_AT_ROLE_MEMBER_LEVEL, resp.isActionDetailsAtRoleMemberLevel()?"true":"false" ); |
| 91 | 0 | if ( StringUtils.isNotBlank(resp.getQualifierResolverProvidedIdentifier()) ) { |
| 92 | 0 | details.put( KimConstants.AttributeConstants.QUALIFIER_RESOLVER_PROVIDED_IDENTIFIER, resp.getQualifierResolverProvidedIdentifier() ); |
| 93 | |
} |
| 94 | |
|
| 95 | 0 | KIMServiceLocatorInternal.getResponsibilityUpdateService().saveResponsibility( resp.getResponsibilityId(), |
| 96 | |
reviewTemplateId, |
| 97 | |
resp.getNamespaceCode(), |
| 98 | |
resp.getName(), |
| 99 | |
resp.getDescription(), |
| 100 | |
resp.isActive(), |
| 101 | |
details ); |
| 102 | 0 | } catch ( RuntimeException ex ) { |
| 103 | 0 | LOG.error( "Exception in saveBusinessObject()", ex ); |
| 104 | 0 | throw ex; |
| 105 | 0 | } |
| 106 | 0 | } |
| 107 | |
|
| 108 | |
protected void populateReviewTemplateInfo() { |
| 109 | 0 | KimResponsibilityTemplateInfo template = KIMServiceLocator.getResponsibilityService().getResponsibilityTemplateByName( KEWConstants.KEW_NAMESPACE, KEWConstants.DEFAULT_RESPONSIBILITY_TEMPLATE_NAME); |
| 110 | |
|
| 111 | 0 | reviewTemplateId = template.getResponsibilityTemplateId(); |
| 112 | 0 | } |
| 113 | |
|
| 114 | |
|
| 115 | |
|
| 116 | |
|
| 117 | |
|
| 118 | |
|
| 119 | |
@Override |
| 120 | |
public Class<? extends PersistableBusinessObject> getBoClass() { |
| 121 | 0 | return ReviewResponsibility.class; |
| 122 | |
} |
| 123 | |
|
| 124 | |
|
| 125 | |
|
| 126 | |
|
| 127 | |
|
| 128 | |
|
| 129 | |
@Override |
| 130 | |
public boolean isExternalBusinessObject() { |
| 131 | 0 | return true; |
| 132 | |
} |
| 133 | |
|
| 134 | |
|
| 135 | |
|
| 136 | |
|
| 137 | |
|
| 138 | |
|
| 139 | |
@Override |
| 140 | |
public void prepareBusinessObject(BusinessObject businessObject) { |
| 141 | |
try { |
| 142 | 0 | if ( businessObject == null ) { |
| 143 | 0 | throw new RuntimeException( "Configuration ERROR: ReviewResponsibilityMaintainable.prepareBusinessObject passed a null object." ); |
| 144 | |
} |
| 145 | 0 | if ( businessObject instanceof ResponsibilityImpl ) { |
| 146 | 0 | KimResponsibilityImpl resp = getBusinessObjectService().findBySinglePrimaryKey(KimResponsibilityImpl.class, ((ResponsibilityImpl)businessObject).getResponsibilityId() ); |
| 147 | 0 | businessObject = new ReviewResponsibility( resp ); |
| 148 | 0 | } else if ( businessObject instanceof ReviewResponsibility ) { |
| 149 | |
|
| 150 | 0 | KimResponsibilityImpl resp = getBusinessObjectService().findBySinglePrimaryKey(KimResponsibilityImpl.class, ((ReviewResponsibility)businessObject).getResponsibilityId() ); |
| 151 | 0 | ((ReviewResponsibility)businessObject).loadFromKimResponsibility(resp); |
| 152 | 0 | } else { |
| 153 | 0 | throw new RuntimeException( "Configuration ERROR: ReviewResponsibilityMaintainable passed an unsupported object type: " + businessObject.getClass() ); |
| 154 | |
} |
| 155 | 0 | if ( businessObject instanceof PersistableBusinessObject ) { |
| 156 | 0 | setBusinessObject( (PersistableBusinessObject)businessObject ); |
| 157 | |
} |
| 158 | 0 | super.prepareBusinessObject(businessObject); |
| 159 | 0 | } catch ( RuntimeException ex ) { |
| 160 | 0 | LOG.error( "Exception in prepareBusinessObject()", ex ); |
| 161 | 0 | throw ex; |
| 162 | 0 | } |
| 163 | 0 | } |
| 164 | |
|
| 165 | |
} |