1 | |
|
2 | |
|
3 | |
|
4 | |
package edu.sampleu.bookstore.kew; |
5 | |
|
6 | |
import edu.sampleu.bookstore.bo.Book; |
7 | |
import edu.sampleu.bookstore.bo.BookstoreKimAttributes; |
8 | |
import org.apache.commons.lang.StringUtils; |
9 | |
import org.kuali.rice.kew.engine.RouteContext; |
10 | |
import org.kuali.rice.krad.document.MaintenanceDocument; |
11 | |
import org.kuali.rice.krad.maintenance.Maintainable; |
12 | |
import org.kuali.rice.krad.workflow.attribute.QualifierResolverBase; |
13 | |
|
14 | |
import java.util.ArrayList; |
15 | |
import java.util.Collections; |
16 | |
import java.util.HashMap; |
17 | |
import java.util.List; |
18 | |
import java.util.Map; |
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | 0 | public class BookTypeQualifierResolver extends QualifierResolverBase { |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
public List<Map<String, String>> resolve(RouteContext context) { |
30 | 0 | List<Map<String, String>> qualifiers = new ArrayList<Map<String, String>>(); |
31 | 0 | MaintenanceDocument doc = (MaintenanceDocument) getDocument(context); |
32 | 0 | Maintainable maint = doc.getNewMaintainableObject(); |
33 | 0 | Book book = (Book) maint.getDataObject(); |
34 | 0 | if (StringUtils.isNotEmpty(book.getTypeCode())) { |
35 | 0 | qualifiers.add(Collections.singletonMap(BookstoreKimAttributes.BOOK_TYPE_CODE, book.getTypeCode())); |
36 | 0 | decorateWithCommonQualifiers(qualifiers, context, null); |
37 | |
} |
38 | |
else { |
39 | 0 | Map<String, String> basicQualifier = new HashMap<String, String>(); |
40 | 0 | qualifiers.add(basicQualifier); |
41 | |
} |
42 | 0 | return qualifiers; |
43 | |
} |
44 | |
|
45 | |
} |