| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package edu.sampleu.travel.workflow; |
| 17 |
|
|
| 18 |
|
import edu.sampleu.travel.bo.TravelAccount; |
| 19 |
|
import org.kuali.rice.kew.engine.RouteContext; |
| 20 |
|
import org.kuali.rice.kew.identity.Id; |
| 21 |
|
import org.kuali.rice.kew.routeheader.DocumentContent; |
| 22 |
|
import org.kuali.rice.kew.rule.AbstractRoleAttribute; |
| 23 |
|
import org.kuali.rice.kew.rule.ResolvedQualifiedRole; |
| 24 |
|
import org.kuali.rice.kew.rule.Role; |
| 25 |
|
import org.kuali.rice.kew.identity.PrincipalName; |
| 26 |
|
import org.kuali.rice.kns.service.KNSServiceLocator; |
| 27 |
|
import org.kuali.rice.kns.workflow.WorkflowUtils; |
| 28 |
|
import org.w3c.dom.Node; |
| 29 |
|
import org.w3c.dom.NodeList; |
| 30 |
|
|
| 31 |
|
import javax.xml.namespace.QName; |
| 32 |
|
import javax.xml.xpath.XPath; |
| 33 |
|
import javax.xml.xpath.XPathConstants; |
| 34 |
|
import javax.xml.xpath.XPathExpressionException; |
| 35 |
|
import java.util.ArrayList; |
| 36 |
|
import java.util.Collections; |
| 37 |
|
import java.util.List; |
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
|
|
|
|
|
| 0% |
Uncovered Elements: 38 (38) |
Complexity: 8 |
Complexity Density: 0.28 |
|
| 46 |
|
public class AccountAttribute extends AbstractRoleAttribute { |
| 47 |
|
private static final Role FISCAL_OFFICER_ROLE = new Role(AccountAttribute.class, "FO", "Fiscal Officer"); |
| 48 |
|
private static final List<Role> ROLES; |
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 49 |
0
|
static {... |
| 50 |
0
|
List<Role> tmp = new ArrayList<Role>(1); |
| 51 |
0
|
tmp.add(FISCAL_OFFICER_ROLE); |
| 52 |
0
|
ROLES = Collections.unmodifiableList(tmp); |
| 53 |
|
} |
| 54 |
|
|
| 55 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
| 56 |
0
|
public List<String> getQualifiedRoleNames(String roleName, DocumentContent documentContent) {... |
| 57 |
0
|
List<String> qualifiedRoleNames = new ArrayList<String>(); |
| 58 |
0
|
XPath xpath = WorkflowUtils.getXPath(documentContent.getDocument()); |
| 59 |
|
|
| 60 |
0
|
NodeList accountNums = (NodeList) xstreamSafeEval(xpath, "/documentContent/applicationContent/org.kuali.rice.kns.workflow.KualiDocumentXmlMaterializer/document/travelAccounts/vector/default/elementData/edu.sampleu.travel.bo.TravelAccount/number", documentContent.getDocument(), XPathConstants.NODESET); |
| 61 |
0
|
for (int i = 0; i < accountNums.getLength(); i++) { |
| 62 |
0
|
Node accountNum = accountNums.item(i); |
| 63 |
0
|
String accuntNumVal = accountNum.getTextContent(); |
| 64 |
0
|
qualifiedRoleNames.add(accuntNumVal); |
| 65 |
|
} |
| 66 |
0
|
return qualifiedRoleNames; |
| 67 |
|
} |
| 68 |
|
|
| 69 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 70 |
0
|
public List<Role> getRoleNames() {... |
| 71 |
0
|
return ROLES; |
| 72 |
|
} |
| 73 |
|
|
| 74 |
|
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 2 |
Complexity Density: 0.15 |
|
| 75 |
0
|
public ResolvedQualifiedRole resolveQualifiedRole(RouteContext routeContext, String roleName, String qualifiedRole) {... |
| 76 |
0
|
String accountNum = qualifiedRole; |
| 77 |
0
|
TravelAccount account = new TravelAccount(); |
| 78 |
0
|
account.setNumber(accountNum); |
| 79 |
0
|
account = (TravelAccount) KNSServiceLocator.getBusinessObjectService().retrieve(account); |
| 80 |
0
|
if (account == null) { |
| 81 |
0
|
throw new RuntimeException("Account " + accountNum + " does not exist!"); |
| 82 |
|
} |
| 83 |
0
|
ResolvedQualifiedRole qualRole = new ResolvedQualifiedRole(); |
| 84 |
0
|
qualRole.setAnnotation("Account " + accountNum + " FO"); |
| 85 |
0
|
qualRole.setQualifiedRoleLabel("Fiscal Officer Account " + accountNum); |
| 86 |
0
|
List<Id> ids = new ArrayList<Id>(); |
| 87 |
0
|
ids.add(new PrincipalName(account.getFiscalOfficer().getUserName())); |
| 88 |
0
|
qualRole.setRecipients(ids); |
| 89 |
0
|
return qualRole; |
| 90 |
|
} |
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
|
| 95 |
|
|
| 96 |
|
|
| 97 |
|
|
| 98 |
|
@param |
| 99 |
|
@param |
| 100 |
|
@param |
| 101 |
|
@return |
| 102 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 103 |
0
|
public static final Object xstreamSafeEval(XPath xpath, String xpathExpression, Object item, QName returnType) {... |
| 104 |
0
|
String xstreamSafeXPath = new StringBuilder(WorkflowUtils.XSTREAM_SAFE_PREFIX).append(xpathExpression).append(WorkflowUtils.XSTREAM_SAFE_SUFFIX).toString(); |
| 105 |
0
|
try { |
| 106 |
0
|
return xpath.evaluate(xstreamSafeXPath, item, returnType); |
| 107 |
|
} |
| 108 |
|
catch (XPathExpressionException e) { |
| 109 |
0
|
throw new RuntimeException("XPathExpressionException occurred on xpath: " + xstreamSafeXPath, e); |
| 110 |
|
} |
| 111 |
|
} |
| 112 |
|
} |