1 package org.tigris.scarab.om; 2 3 48 49 import java.util.List ; 50 import java.util.ArrayList ; 51 import org.apache.torque.util.Criteria; 52 import org.apache.torque.om.Persistent; 53 import org.tigris.scarab.tools.localization.L10NKeySet; 54 import org.tigris.scarab.util.ScarabException; 55 import org.tigris.scarab.services.security.ScarabSecurity; 56 57 62 public class RIssueTypeOption 63 extends org.tigris.scarab.om.BaseRIssueTypeOption 64 implements Persistent 65 { 66 67 public void delete(ScarabUser user, Module module) 68 throws Exception 69 { 70 if (user.hasPermission(ScarabSecurity.DOMAIN__EDIT, module)) 71 { 72 List rios = getIssueType().getRIssueTypeOptions( 73 getAttributeOption().getAttribute(), false); 74 Criteria c = new Criteria() 75 .add(RIssueTypeOptionPeer.ISSUE_TYPE_ID, getIssueTypeId()) 76 .add(RIssueTypeOptionPeer.OPTION_ID, getOptionId()); 77 RIssueTypeOptionPeer.doDelete(c); 78 rios.remove(this); 79 if (rios.size() > 0) 80 { 81 ArrayList optIds = new ArrayList (); 83 for (int i=0; i<rios.size();i++) 84 { 85 RIssueTypeOption rio = (RIssueTypeOption)rios.get(i); 86 optIds.add(rio.getOptionId()); 87 } 88 Criteria c2 = new Criteria() 89 .addIn(RIssueTypeOptionPeer.OPTION_ID, optIds) 90 .add(RIssueTypeOptionPeer.PREFERRED_ORDER, getOrder(), 91 Criteria.GREATER_THAN); 92 List adjustRios = RIssueTypeOptionPeer.doSelect(c2); 93 for (int j=0; j<adjustRios.size();j++) 94 { 95 RIssueTypeOption rio = (RIssueTypeOption)adjustRios.get(j); 96 rio.setOrder(rio.getOrder() -1); 97 rio.save(); 98 } 99 } 100 } 101 else 102 { 103 throw new ScarabException(L10NKeySet.YouDoNotHavePermissionToAction); 104 } 105 } 106 107 110 public RIssueTypeOption copyRio() 111 throws Exception 112 { 113 RIssueTypeOption rio = new RIssueTypeOption(); 114 rio.setIssueTypeId(getIssueTypeId()); 115 rio.setOptionId(getOptionId()); 116 rio.setActive(getActive()); 117 rio.setOrder(getOrder()); 118 rio.setWeight(getWeight()); 119 return rio; 120 } 121 } 122 | Popular Tags |