1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  package org.kuali.student.r2.common.constants;
17  
18  import java.util.ArrayList;
19  import org.kuali.student.r2.common.dto.AttributeInfo;
20  import org.kuali.student.r2.common.dto.ContextInfo;
21  
22  
23  
24  
25  
26  
27  public class CommonServiceConstants {
28  
29      
30  
31  
32      public static final String REF_OBJECT_URI_GLOBAL_PREFIX = "http://student.kuali.org/wsdl/";
33      
34  
35  
36  
37  
38  
39      public static final String ALLOW_ID_ON_CREATE_CONTEXT_ATTRIBUTE_KEY = "kuali.context.allow.id.on.create";
40      public static final String ALLOW_ID_ON_CREATE_CONTEXT_ATTRIBUTE_TRUE_VALUE = "TRUE";
41      public static final String ALLOW_ID_ON_CREATE_CONTEXT_ATTRIBUTE_FALSE_VALUE = "FALSE";
42  
43      
44  
45  
46      public static boolean isIdAllowedOnCreate(ContextInfo context) {
47          if (context.getAttributes() == null) {
48              return false;
49          }
50          for (AttributeInfo attr : context.getAttributes()) {
51              if (ALLOW_ID_ON_CREATE_CONTEXT_ATTRIBUTE_KEY.equals(attr.getKey())) {
52                  if (ALLOW_ID_ON_CREATE_CONTEXT_ATTRIBUTE_TRUE_VALUE.equals(attr.getValue())) {
53                      return true;
54                  }
55              }
56          }
57          return false;
58      }
59      
60      public static void setIsIdAllowedOnCreate(ContextInfo context, boolean allowed) {
61          if (context.getAttributes() == null) {
62              context.setAttributes(new ArrayList<AttributeInfo>());
63          }
64          for (AttributeInfo attr : context.getAttributes()) {
65              if (ALLOW_ID_ON_CREATE_CONTEXT_ATTRIBUTE_KEY.equals(attr.getKey())) {
66                  attr.setValue(ALLOW_ID_ON_CREATE_CONTEXT_ATTRIBUTE_TRUE_VALUE);
67                  return;
68              }
69          }
70          AttributeInfo attr = new AttributeInfo ();
71          attr.setKey(ALLOW_ID_ON_CREATE_CONTEXT_ATTRIBUTE_KEY);
72          attr.setValue(ALLOW_ID_ON_CREATE_CONTEXT_ATTRIBUTE_TRUE_VALUE);
73          context.getAttributes().add(attr);
74      }
75  }