1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
package org.kuali.student.lum.program.server.metadata; |
10 | |
|
11 | |
import java.util.ArrayList; |
12 | |
import java.util.List; |
13 | |
|
14 | |
import org.kuali.student.common.assembly.data.ConstraintMetadata; |
15 | |
import org.kuali.student.common.assembly.dictionary.MetadataServiceImpl; |
16 | |
import org.kuali.student.common.dictionary.dto.FieldDefinition; |
17 | |
import org.kuali.student.common.dictionary.service.DictionaryService; |
18 | |
import org.kuali.student.common.dto.DtoConstants.DtoState; |
19 | |
import org.kuali.student.lum.lu.LUConstants; |
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
public class ProgramMetadataServiceImpl extends MetadataServiceImpl { |
27 | |
|
28 | |
public ProgramMetadataServiceImpl() { |
29 | 0 | super(); |
30 | 0 | } |
31 | |
|
32 | |
public ProgramMetadataServiceImpl(DictionaryService... dictionaryServices) { |
33 | 0 | super(dictionaryServices); |
34 | 0 | } |
35 | |
|
36 | |
@Override |
37 | |
protected List<ConstraintMetadata> getConstraints(FieldDefinition fd, String type, String state, String nextState, |
38 | |
String workflowNode, String documentTypeName) { |
39 | 0 | List<ConstraintMetadata> constraints = new ArrayList<ConstraintMetadata>(); |
40 | 0 | ConstraintMetadata constraintMetadata = new ConstraintMetadata(); |
41 | |
|
42 | 0 | String nextStateValue = nextState; |
43 | 0 | if (!LUConstants.PROPOSAL_TYPE_MAJOR_DISCIPLINE_MODIFY.equals(documentTypeName)) { |
44 | 0 | nextStateValue = getNextState(state); |
45 | |
} |
46 | 0 | updateConstraintMetadata(constraintMetadata, fd, type, getNonNullState(state), nextStateValue, workflowNode); |
47 | 0 | constraints.add(constraintMetadata); |
48 | |
|
49 | 0 | return constraints; |
50 | |
} |
51 | |
|
52 | |
private String getNonNullState(String state) { |
53 | 0 | return (null == state ? DtoState.DRAFT.toString() : state); |
54 | |
} |
55 | |
|
56 | |
private String getNextState(String state) { |
57 | 0 | if (null == state || DtoState.DRAFT.toString().equalsIgnoreCase(state)) { |
58 | 0 | return DtoState.APPROVED.toString(); |
59 | 0 | } else if (DtoState.APPROVED.toString().equalsIgnoreCase(state)) { |
60 | 0 | return DtoState.ACTIVE.toString(); |
61 | 0 | } else if (DtoState.ACTIVE.toString().equalsIgnoreCase(state)) { |
62 | 0 | return DtoState.SUPERSEDED.toString(); |
63 | |
} |
64 | 0 | return null; |
65 | |
} |
66 | |
} |