1
|
1 package org.mpi.openmind.scripts;
|
|
2
|
|
3 import java.util.ArrayList;
|
|
4 import java.util.List;
|
|
5
|
|
6 import org.mpi.openmind.cache.WrapperService;
|
|
7 import org.mpi.openmind.repository.bo.Attribute;
|
|
8 import org.mpi.openmind.repository.bo.Entity;
|
|
9 import org.mpi.openmind.repository.bo.Node;
|
|
10 import org.mpi.openmind.repository.services.ServiceRegistry;
|
|
11
|
|
12 public class PublicCodices {
|
|
13
|
|
14
|
|
15 private static String ATT_NAME = "public";
|
|
16 private static String CLASS_NAME = "CODEX";
|
|
17
|
|
18
|
|
19 private static List<Long> codexIdList = new ArrayList<Long>();
|
|
20 public static String userName = "public-codices-script";
|
|
21 static{
|
|
22 codexIdList.add(new Long(27543));
|
|
23 codexIdList.add(new Long(36745));
|
|
24 codexIdList.add(new Long(58453));
|
|
25 codexIdList.add(new Long(87298));
|
|
26 codexIdList.add(new Long(259646));
|
|
27 codexIdList.add(new Long(35093));
|
|
28 codexIdList.add(new Long(22863));
|
|
29 codexIdList.add(new Long(34870));
|
|
30 codexIdList.add(new Long(36882));
|
|
31 codexIdList.add(new Long(101488));
|
|
32 codexIdList.add(new Long(36696));
|
|
33 codexIdList.add(new Long(31794));
|
|
34 codexIdList.add(new Long(37240));
|
|
35 codexIdList.add(new Long(35014));
|
|
36 codexIdList.add(new Long(35583));
|
|
37 codexIdList.add(new Long(37025));
|
|
38 codexIdList.add(new Long(35960));
|
|
39 codexIdList.add(new Long(172492));
|
|
40 codexIdList.add(new Long(98286));
|
|
41 codexIdList.add(new Long(165721));
|
|
42 codexIdList.add(new Long(260111));
|
|
43 codexIdList.add(new Long(90980));
|
|
44 codexIdList.add(new Long(36316));
|
|
45 codexIdList.add(new Long(260120));
|
|
46 codexIdList.add(new Long(36241));
|
|
47 codexIdList.add(new Long(260129));
|
|
48 codexIdList.add(new Long(260138));
|
|
49 codexIdList.add(new Long(38860));
|
|
50 codexIdList.add(new Long(176694));
|
|
51 codexIdList.add(new Long(72545));
|
|
52 codexIdList.add(new Long(36185));
|
|
53 codexIdList.add(new Long(36575));
|
|
54 codexIdList.add(new Long(260146));
|
|
55 codexIdList.add(new Long(31672));
|
|
56 codexIdList.add(new Long(37739));
|
|
57 codexIdList.add(new Long(89861));
|
|
58 codexIdList.add(new Long(176778));
|
|
59 codexIdList.add(new Long(180743));
|
|
60 codexIdList.add(new Long(86328));
|
|
61 codexIdList.add(new Long(260150));
|
|
62 codexIdList.add(new Long(90658));
|
|
63 codexIdList.add(new Long(58423));
|
|
64 codexIdList.add(new Long(181058));
|
|
65 codexIdList.add(new Long(105948));
|
|
66 codexIdList.add(new Long(35526));
|
|
67 codexIdList.add(new Long(74078));
|
|
68 codexIdList.add(new Long(260158));
|
|
69 codexIdList.add(new Long(181096));
|
|
70 codexIdList.add(new Long(31606));
|
|
71 codexIdList.add(new Long(31568));
|
|
72 codexIdList.add(new Long(27872));
|
|
73 codexIdList.add(new Long(36938));
|
|
74 codexIdList.add(new Long(4836));
|
|
75 codexIdList.add(new Long(34668));
|
|
76 codexIdList.add(new Long(76866));
|
|
77 codexIdList.add(new Long(102230));
|
|
78 codexIdList.add(new Long(76888));
|
|
79 codexIdList.add(new Long(74070));
|
|
80 codexIdList.add(new Long(73757));
|
|
81 codexIdList.add(new Long(182685));
|
|
82 codexIdList.add(new Long(260162));
|
|
83 codexIdList.add(new Long(260170));
|
|
84 codexIdList.add(new Long(1102));
|
|
85 codexIdList.add(new Long(172888));
|
|
86 codexIdList.add(new Long(260174));
|
|
87 codexIdList.add(new Long(34806));
|
|
88 codexIdList.add(new Long(28088));
|
|
89 codexIdList.add(new Long(36713));
|
|
90 codexIdList.add(new Long(37323));
|
|
91 codexIdList.add(new Long(34551));
|
|
92 codexIdList.add(new Long(35943));
|
|
93 codexIdList.add(new Long(98095));
|
|
94 codexIdList.add(new Long(260178));
|
|
95 codexIdList.add(new Long(260182));
|
|
96 codexIdList.add(new Long(182770));
|
|
97 codexIdList.add(new Long(260186));
|
|
98 codexIdList.add(new Long(260190));
|
|
99 codexIdList.add(new Long(260194));
|
|
100 codexIdList.add(new Long(36114));
|
|
101 codexIdList.add(new Long(85003));
|
|
102 codexIdList.add(new Long(31630));
|
|
103 codexIdList.add(new Long(157290));
|
|
104 codexIdList.add(new Long(37153));
|
|
105 codexIdList.add(new Long(37213));
|
|
106 codexIdList.add(new Long(172952));
|
|
107 codexIdList.add(new Long(86871));
|
|
108 codexIdList.add(new Long(64406));
|
|
109 codexIdList.add(new Long(102590));
|
|
110 codexIdList.add(new Long(82615));
|
|
111 codexIdList.add(new Long(58245));
|
|
112 codexIdList.add(new Long(179791));
|
|
113 codexIdList.add(new Long(179550));
|
|
114 codexIdList.add(new Long(12419));
|
|
115 codexIdList.add(new Long(95861));
|
|
116 codexIdList.add(new Long(36429));
|
|
117 codexIdList.add(new Long(36099));
|
|
118 codexIdList.add(new Long(74237));
|
|
119 codexIdList.add(new Long(36065));
|
|
120 codexIdList.add(new Long(74822));
|
|
121 codexIdList.add(new Long(87549));
|
|
122 codexIdList.add(new Long(83765));
|
|
123 codexIdList.add(new Long(36733));
|
|
124 codexIdList.add(new Long(19259));
|
|
125 codexIdList.add(new Long(260198));
|
|
126 codexIdList.add(new Long(34986));
|
|
127 codexIdList.add(new Long(88041));
|
|
128 codexIdList.add(new Long(260202));
|
|
129 codexIdList.add(new Long(36550));
|
|
130 codexIdList.add(new Long(260206));
|
|
131 codexIdList.add(new Long(37228));
|
|
132 codexIdList.add(new Long(39880));
|
|
133 codexIdList.add(new Long(36318));
|
|
134 codexIdList.add(new Long(36597));
|
|
135 codexIdList.add(new Long(35035));
|
|
136 codexIdList.add(new Long(58328));
|
|
137 codexIdList.add(new Long(80831));
|
|
138 codexIdList.add(new Long(58354));
|
|
139 codexIdList.add(new Long(74277));
|
|
140 codexIdList.add(new Long(36529));
|
|
141 codexIdList.add(new Long(36380));
|
|
142 codexIdList.add(new Long(69450));
|
|
143 codexIdList.add(new Long(200246));
|
|
144 codexIdList.add(new Long(260222));
|
|
145 codexIdList.add(new Long(81178));
|
|
146 codexIdList.add(new Long(260226));
|
|
147 codexIdList.add(new Long(199952));
|
|
148 codexIdList.add(new Long(262557));
|
|
149 codexIdList.add(new Long(87212));
|
|
150 codexIdList.add(new Long(99059));
|
|
151 codexIdList.add(new Long(64270));
|
|
152 codexIdList.add(new Long(81811));
|
|
153 codexIdList.add(new Long(65785));
|
|
154 codexIdList.add(new Long(36645));
|
|
155 }
|
|
156
|
|
157
|
|
158 public static void prepareDefinitions(WrapperService ws) throws Exception{
|
|
159
|
|
160 Entity codex = ws.getDefinition(CLASS_NAME);
|
|
161
|
|
162 Attribute attPublic = ws.getDefAttributeByOwnValue(CLASS_NAME, ATT_NAME);
|
|
163
|
|
164 if(attPublic == null){
|
|
165 attPublic = new Attribute(Node.TYPE_TBOX, "boolean", ATT_NAME);
|
|
166 attPublic.setSourceId(codex.getId());
|
|
167 attPublic.setSourceObjectClass(Node.TYPE_TBOX);
|
|
168 attPublic.setSourceModif(codex.getModificationTime());
|
|
169 attPublic.setSystemStatus(Node.SYS_STATUS_CURRENT_VERSION);
|
|
170 ws.saveDefAttribute(attPublic, userName);
|
|
171 }
|
|
172 }
|
|
173
|
|
174 public static void makeCodicesPublic(WrapperService ws) throws Exception{
|
|
175
|
|
176 for(Long codexId : codexIdList){
|
|
177 Entity codex = ws.getEntityByIdWithContent(codexId);
|
|
178 if(codex != null){
|
|
179 if(codex.getAttributeByName(ATT_NAME) == null){
|
|
180 Attribute att = new Attribute(ATT_NAME, "boolean", "true");
|
|
181 codex.addAttribute(att);
|
|
182 }else{
|
|
183 codex.getAttributeByName(ATT_NAME).setValue("true");
|
|
184 }
|
|
185 }
|
|
186 ws.saveAssertion(codex, userName);
|
|
187 }
|
|
188 }
|
|
189
|
|
190
|
|
191
|
|
192 public static void main(String[] args){
|
|
193 ServiceRegistry services = new ServiceRegistry();
|
|
194
|
|
195 try {
|
|
196 prepareDefinitions(services.getWrapper());
|
|
197 makeCodicesPublic(services.getWrapper());
|
|
198 } catch (Exception e) {
|
|
199 e.printStackTrace();
|
|
200 }
|
|
201
|
|
202 System.exit(0);
|
|
203 }
|
|
204
|
|
205
|
|
206 }
|