1
2
3
4
5
6
7
8
9
10 package com.sri.emo;
11
12 import java.util.Enumeration;
13 import java.util.HashMap;
14 import java.util.Iterator;
15 import java.util.List;
16 import java.util.Map;
17
18 import org.picocontainer.MutablePicoContainer;
19 import org.picocontainer.PicoContainer;
20 import org.picocontainer.defaults.DefaultPicoContainer;
21
22 import com.jcorporate.expresso.core.ExpressoSchema;
23 import com.jcorporate.expresso.core.db.DBException;
24 import com.jcorporate.expresso.core.dbobj.DBObject;
25 import com.jcorporate.expresso.core.dbobj.RowSecuredDBObject;
26 import com.jcorporate.expresso.core.dbobj.SecuredDBObject;
27 import com.jcorporate.expresso.core.misc.ConfigManager;
28 import com.jcorporate.expresso.core.misc.StringUtil;
29 import com.jcorporate.expresso.core.security.SuperUser;
30 import com.jcorporate.expresso.core.security.User;
31 import com.jcorporate.expresso.core.security.filters.HtmlPlusURLFilter;
32 import com.jcorporate.expresso.ext.dbobj.RegisteredUser;
33 import com.jcorporate.expresso.kernel.InstallLog;
34 import com.jcorporate.expresso.services.dbobj.DBObjSecurity;
35 import com.jcorporate.expresso.services.dbobj.GroupMembers;
36 import com.jcorporate.expresso.services.dbobj.RegistrationDomain;
37 import com.jcorporate.expresso.services.dbobj.RegistrationObjectMap;
38 import com.jcorporate.expresso.services.dbobj.RowGroupPerms;
39 import com.jcorporate.expresso.services.dbobj.RowPermissions;
40 import com.jcorporate.expresso.services.dbobj.Setup;
41 import com.jcorporate.expresso.services.dbobj.UserGroup;
42 import com.sri.common.ComponentSchema;
43 import com.sri.common.controller.AbstractDBController;
44 import com.sri.common.controller.LoginAction;
45 import com.sri.common.util.PermGroup;
46 import com.sri.emo.annotations.NodeTag;
47 import com.sri.emo.annotations.NodeTagController;
48 import com.sri.emo.controller.AddNodeAction;
49 import com.sri.emo.controller.EmoAction;
50 import com.sri.emo.controller.EmoRegistration;
51 import com.sri.emo.controller.ImportExportModel;
52 import com.sri.emo.controller.NodeAction;
53 import com.sri.emo.controller.PartAction;
54 import com.sri.emo.controller.PermissionController;
55 import com.sri.emo.controller.PicklistAction;
56 import com.sri.emo.controller.SelectionWizardManager;
57 import com.sri.emo.dbobj.Attribute;
58 import com.sri.emo.dbobj.MatrixCell;
59 import com.sri.emo.dbobj.Node;
60 import com.sri.emo.dbobj.NodeType;
61 import com.sri.emo.dbobj.Part;
62 import com.sri.emo.dbobj.PickList;
63 import com.sri.emo.dbobj.Relation;
64 import com.sri.emo.dbobj.RelationType;
65 import com.sri.emo.dbobj.Setting;
66 import com.sri.emo.dbobj.StepAttributes;
67 import com.sri.emo.dbobj.WizDecisionEntities;
68 import com.sri.emo.dbobj.WizDecisionSet;
69 import com.sri.emo.dbobj.WizDefinition;
70 import com.sri.emo.dbobj.WizStep;
71 import com.sri.emo.wizard.WizardRepository;
72 import com.sri.emo.wizard.completion.CompletionRepository;
73 import com.sri.emo.wizard.completion.management.CompletionBeanManager;
74 import com.sri.emo.wizard.completion.management.CompletionEditor;
75 import com.sri.emo.wizard.completion.management.ICompletionBeanManager;
76 import com.sri.emo.wizard.completion.persistence.CompletionDBObjConverter;
77 import com.sri.emo.wizard.completion.persistence.CompletionDBObjConverterImpl;
78 import com.sri.emo.wizard.completion.persistence.CompletionDefinition;
79 import com.sri.emo.wizard.completion.persistence.CompletionDetails;
80 import com.sri.emo.wizard.completion.persistence.ExpressoCompletionRepository;
81 import com.sri.emo.wizard.defaults.ExpressoAwareWizardRepository;
82 import com.sri.emo.wizard.selection.WizardAction;
83 import com.sri.emo.wizard.selection.management.WizardStepController;
84 import com.sri.emo.wizard.wizardgateway.WizardGatewayController;
85
86
87 /***
88 * Register the Schemas for entire web application. This schema tells Expresso what
89 * database table objects need to be generated or check when the schema
90 * is read for the first time.
91 */
92 public class EmoSchema extends ComponentSchema {
93
94 /***
95 *
96 */
97 private static final long serialVersionUID = 1L;
98
99 public static final String EMO_GROUP = "emowrite";
100
101 public static final String[] REMOVED_REG_FIELDS = {
102 "!UserComment", "!Industry", "!Employees", "!JobTitle", "!Subscribe",
103 "!Contributing", "!Projects"
104 };
105
106 /***
107 * Map of wizard repositories keyed by data context string.
108 */
109 private Map wizardRepository = new HashMap();
110
111 /***
112 * name of setup value for how many levels deep a tree fetches by default
113 */
114 public static final String TREEVIEW_NESTING_LIMIT = "TREEVIEW_NESTING_LIMIT";
115
116 /***
117 * Default constructor. Adds references to all the dbobjects and controllers.
118 *
119 * @throws DBException
120 */
121 public EmoSchema() throws DBException {
122 try {
123
124
125
126 addDBObject(Node.class);
127 addDBObject(Relation.class);
128 addDBObject(RelationType.class);
129 addDBObject(NodeType.class);
130 addDBObject(Attribute.class);
131 addDBObject(NodeTag.class);
132
133 addDBObject(PickList.class);
134 addDBObject(Part.class);
135 addDBObject(MatrixCell.class);
136 addDBObject(Setting.class);
137
138
139 addDBObject(WizDefinition.class);
140 addDBObject(WizStep.class);
141 addDBObject(CompletionDefinition.class);
142 addDBObject(CompletionDetails.class);
143 addDBObject(WizDecisionEntities.class);
144 addDBObject(WizDecisionSet.class);
145 addDBObject(StepAttributes.class);
146
147
148 addDBObject(PermGroup.class);
149
150
151
152 addController(NodeAction.class);
153 addController(LoginAction.class);
154 addController(PicklistAction.class);
155 addController(AddNodeAction.class);
156 addController(PartAction.class);
157
158 addController(WizardAction.class);
159 addController(SelectionWizardManager.class);
160 addController(WizardStepController.class);
161
162 addController(CompletionEditor.class);
163
164 addController(EmoAction.class);
165 addController(ImportExportModel.class);
166
167
168 addController(PermissionController.class);
169
170
171 addController(WizardGatewayController.class);
172 addController(EmoRegistration.class);
173
174 addController(NodeTagController.class);
175
176 /***
177 * for each db context, add a repository; typically just default context
178 */
179 for (Enumeration e = ConfigManager.getAllConfigKeys(); e.hasMoreElements();) {
180 String context = (String) e.nextElement();
181 wizardRepository.put(context, new ExpressoAwareWizardRepository(this));
182 }
183
184 this.setApplicationContainer(
185 (MutablePicoContainer) this.initializeApplicationContainer());
186 } catch (Throwable t) {
187
188 throw new DBException(t.getClass().getName() + ": " + t.getMessage(), t);
189 }
190 }
191
192 /***
193 * Return the path, relative to the classpath, of the MessageBundle file for
194 * this schema. This is where it's message files are stored.
195 *
196 * @return java.lang.String
197 */
198 public String getMessageBundlePath() {
199 return "com/sri/emo";
200 }
201
202 /***
203 * Returns the default description for this schema. Useful for
204 * automated component testing/installation
205 *
206 * @return java.lang.String
207 */
208 public String getDefaultDescription() {
209 return "Emo web application";
210 }
211
212 /***
213 * Returns the default component code for this schema. Useful for
214 * automated component testing/installation
215 *
216 * @return java.lang.String
217 */
218 public String getDefaultComponentCode() {
219 return "emo";
220 }
221
222 /***
223 * Perform any additional setup/intialize functions required
224 * by this schema. This is where applications can set up default
225 * values for lookup tables, reference values, etc.
226 * Subclass does not extend this method if it is not needed.
227 *
228 * @param theLog The installation log
229 * @param dbName The database context to execute this process against.
230 * @throws DBException If there's a database communication error
231 */
232 public synchronized void otherSetup(final InstallLog theLog, final String dbName) throws DBException {
233
234
235
236
237
238 setDefaultReadWriteGroups(dbName);
239
240 addSetupValues(theLog, dbName);
241
242 addDefaultRelationTypes(dbName);
243 createTestUserAndGroups(theLog, dbName);
244 }
245
246 private void addDefaultRelationTypes(String dbName) throws DBException {
247
248
249 RelationType relationType = new RelationType();
250 relationType.setDataContext(dbName);
251 for (int i = 0; i < RelationType.ALL_RELATION_TYPES.length; i++) {
252 relationType.clear();
253 relationType.setRelType(RelationType.ALL_RELATION_TYPES[i][0]);
254
255 boolean exists = relationType.find();
256
257 if (exists) {
258 String descrip = relationType.getRelTypeDescrip();
259
260 if (descrip.length() <= 0) {
261 relationType.setRelDescrip(RelationType.ALL_RELATION_TYPES[i][2]);
262 }
263
264 if (relationType.getRelTypeDisplayName().length() == 0) {
265 relationType.setRelDisplayName(RelationType.ALL_RELATION_TYPES[i][1]);
266 }
267
268
269 if (relationType.getStrength().length() == 0) {
270 relationType.setStrength(RelationType.ALL_RELATION_TYPES[i][4]);
271 }
272
273 relationType.update();
274 } else {
275 relationType.setRelDisplayName(RelationType.ALL_RELATION_TYPES[i][1]);
276 relationType.setRelDescrip(RelationType.ALL_RELATION_TYPES[i][2]);
277 relationType.setStrength(RelationType.ALL_RELATION_TYPES[i][4]);
278 relationType.add();
279 }
280
281
282 DBObjSecurity sec = new DBObjSecurity(SuperUser.INSTANCE);
283 sec.setDataContext(dbName);
284 sec.setField(DBObjSecurity.DBOBJECT_NAME, relationType.getClass().getName());
285
286
287 sec.setField(DBObjSecurity.GROUP_NAME,
288 Setup.getValueRequired(PartAction.READ_GROUP_DEFAULT_SETUP_CODE));
289 sec.setField(DBObjSecurity.METHOD_ALLOWED_CODE, SecuredDBObject.SEARCH);
290 sec.addIfNeeded();
291
292 int rowpermsInt = relationType.getPermissions().permissions();
293 rowpermsInt |= RowPermissions.OTHERS_READ_MASK;
294 relationType.setPermissions(rowpermsInt);
295
296 }
297
298
299 for (int i = 0; i < RelationType.ALL_RELATION_TYPES.length; i++) {
300 relationType.clear();
301 relationType.setRelType(RelationType.ALL_RELATION_TYPES[i][0]);
302
303 boolean exists = relationType.find();
304
305 String inverse = RelationType.ALL_RELATION_TYPES[i][3];
306
307 if (StringUtil.notNull(inverse).length() > 0) {
308 relationType.setInverseRel(inverse);
309 }
310
311 if (exists) {
312 relationType.update();
313 } else {
314 throw new DBException("unexpectedly cannot find relation type: " +
315 relationType.getRelTypeName());
316 }
317 }
318
319 }
320
321 /***
322 * Add specific setup values.
323 *
324 * @param theLog InstallLog the installation log.
325 * @param dbName String the database name.
326 * @throws DBException upon error.
327 */
328 protected void addSetupValues(final InstallLog theLog, final String dbName) throws DBException {
329 Setup setup = new Setup();
330 setup.setDataContext(dbName);
331 setup.setSchemaClass(ExpressoSchema.class.getName());
332 setup.setCode(DBObject.IS_CHECK_RELATIONAL_INTEGRITY);
333 if (!setup.find()) {
334 setup.setDescrip("check relational integrity w/i middleware");
335 setup.setValue("No");
336 setup.add();
337 }
338
339 setup.clear();
340 setup.setSchemaClass(ExpressoSchema.class.getName());
341 setup.setCode(HtmlPlusURLFilter.MAX_CHARS_IN_URL_LABEL);
342
343 if (!setup.find()) {
344 setup.setDescrip("Max number of characters in a URL label, when creating " +
345 "labels automatically from user-entered URLs in fields");
346 setup.setValue("35");
347 setup.add();
348 theLog.info("Added 'Maximum URL Label Characters' Setup Value");
349 }
350
351 setup.clear();
352 setup.setSchemaClass(ExpressoSchema.class.getName());
353 setup.setCode(DBObject.UPDATE_CHANGED_ONLY);
354
355 if (!setup.find()) {
356 setup.setDescrip("policy for update()--efficient to update only if " +
357 "changed, but requires developer discipline");
358 setup.setValue("Yes");
359 setup.add();
360 theLog.info("Added Update Policy Setup Value");
361 }
362
363 setup.clear();
364 setup.setSchemaClass(ExpressoSchema.class.getName());
365 setup.setCode(AbstractDBController.COMMON_FOOTER_HANDLER);
366
367 if (!setup.find()) {
368 setup.setDescrip("Fully qualified class name of " +
369 "controller which has common footer code.");
370 setup.setValue(EmoAction.class.getName());
371 setup.add();
372 theLog.info("Added Common Footer Controller Classname Setup Value");
373 }
374
375 setup.clear();
376 setup.setSchemaClass(ExpressoSchema.class.getName());
377 setup.setCode(AbstractDBController.COMMON_HEADER_HANDLER);
378
379 if (!setup.find()) {
380 setup.setDescrip("Fully qualified class name of" +
381 " controller which has common header code.");
382 setup.setValue(EmoAction.class.getName());
383 setup.add();
384 theLog.info("Added Common Header Controller Classname Setup Value");
385 }
386
387 setup.clear();
388 setup.setSchemaClass(ExpressoSchema.class.getName());
389 setup.setCode(RowSecuredDBObject.DEFAULT_PERMISSION_CODE);
390
391 if (!setup.find()) {
392 setup.setDescrip("Permissions for new item (integer)");
393 setup.setValue(String.valueOf(RowPermissions.OWNER_WRITES_GROUP_AND_OTHERS_READ_ONLY_PERMISSIONS));
394 setup.add();
395 }
396
397 setup.clear();
398 setup.setSchemaClass(EmoSchema.class.getName());
399 setup.setCode(TREEVIEW_NESTING_LIMIT);
400
401 if (!setup.find()) {
402 setup.setDescrip("Maximum Depth To Iterate In a TreeView");
403 setup.setValue("3");
404 setup.add();
405 theLog.info("Added Maximum Depth Setup Value");
406 }
407
408 }
409
410 protected void setDefaultReadWriteGroups(String dbName) throws DBException {
411 Setup setup = new Setup();
412 setup.setDataContext(dbName);
413 setup.setSchemaClass(ExpressoSchema.class.getName());
414 setup.setCode(PartAction.WRITE_GROUP_DEFAULT_SETUP_CODE);
415
416 if (!setup.find()) {
417 setup.setDescrip("the group with write permissions for new items");
418 setup.setValue(UserGroup.ALL_USERS_GROUP);
419 setup.add();
420 }
421
422 setup.clear();
423 setup.setSchemaClass(ExpressoSchema.class.getName());
424 setup.setCode(PartAction.READ_GROUP_DEFAULT_SETUP_CODE);
425
426 if (!setup.find()) {
427 setup.setDescrip("the group with read permissions for new items");
428 setup.setValue(UserGroup.ALL_USERS_GROUP);
429 setup.add();
430 }
431
432 setup.clear();
433 setup.setSchemaClass(ExpressoSchema.class.getName());
434 setup.setCode(PartAction.MODEL_EDIT_GROUP_DEFAULT_SETUP_CODE);
435 if (!setup.find()) {
436 setup.setDescrip("the group with model-editing permissions");
437 setup.setValue(UserGroup.ALL_USERS_GROUP);
438 setup.add();
439 }
440
441 }
442
443 /***
444 * Constructs some user groups for demoing.
445 *
446 * @param dbname String the database context.
447 * @param theLog the Installation log to output messages to.
448 * @throws DBException upon error.
449 */
450 private void createTestUserAndGroups(final InstallLog theLog, final String dbname) throws DBException {
451
452
453 ensureGroup(Setup.getValueRequired(dbname, PartAction.READ_GROUP_DEFAULT_SETUP_CODE), "read group", dbname);
454 ensureGroup(Setup.getValueRequired(dbname, PartAction.WRITE_GROUP_DEFAULT_SETUP_CODE), "write group", dbname);
455 ensureGroup(Setup.getValueRequired(dbname, PartAction.MODEL_EDIT_GROUP_DEFAULT_SETUP_CODE), "model edit group", dbname);
456
457
458
459 PermGroup permgrp = new PermGroup();
460 permgrp.setDataContext(dbname);
461 permgrp.setGroupName(UserGroup.ALL_USERS_GROUP);
462
463 permgrp.retrieve();
464 int rowpermsInt = permgrp.getPermissions().permissions();
465 rowpermsInt |= RowPermissions.OTHERS_READ_MASK;
466 permgrp.setPermissions(rowpermsInt);
467
468
469
470
471 final String testUserName = "tester";
472
473 User user = new User();
474 user.setLoginName(testUserName);
475 user.setDataContext(dbname);
476 if (!user.find()) {
477 user.setDisplayName(testUserName);
478 user.setEmail("testerForEmo@codeguild.com");
479 user.setAccountStatus("A");
480 user.setPassword("test123");
481 user.setEmailValCode((String) null);
482 user.setRegComplete(true);
483 user.setRegistrationDomain("default");
484
485 user.add();
486 } else {
487 theLog.info("Test User Already Exists");
488 }
489
490 addToGroup(user, Setup.getValueRequired(dbname, PartAction.READ_GROUP_DEFAULT_SETUP_CODE), dbname);
491 addToGroup(user, Setup.getValueRequired(dbname, PartAction.WRITE_GROUP_DEFAULT_SETUP_CODE), dbname);
492 addToGroup(user, Setup.getValueRequired(dbname, PartAction.MODEL_EDIT_GROUP_DEFAULT_SETUP_CODE), dbname);
493
494 addDefaultObjPermissions(theLog, dbname);
495 adaptRegistration(dbname);
496 }
497
498 /***
499 * Add the specified group name to the given user.
500 *
501 * @param user User the user to add the group to.
502 * @param grpname String the group name to add.
503 * @return GroupMembers the resulting groupmember database object.
504 * @throws DBException upon find/add error
505 */
506 private GroupMembers addToGroup(final User user, final String grpname, String dbName) throws DBException {
507 GroupMembers oneMember = new GroupMembers();
508 oneMember.setDataContext(dbName);
509 oneMember.setGroupName(grpname);
510 oneMember.setUID(user.getUid());
511
512 if (!oneMember.find()) {
513 oneMember.add();
514 }
515
516 return oneMember;
517 }
518
519 /***
520 * Modify registration to match emo needs.
521 *
522 * @param dbname String the database context
523 * @throws DBException upon database error.
524 */
525 private void adaptRegistration(final String dbname) throws DBException {
526 RegistrationDomain rd = new RegistrationDomain();
527 rd.setDataContext(dbname);
528 rd.setField(RegistrationDomain.FLD_NAME, "default");
529
530
531 if (rd.find()) {
532
533
534 String groupName = rd.getField(RegistrationDomain.FLD_GROUPNAME);
535 if ((groupName == null) || (groupName.length() == 0)) {
536 groupName = Setup.getValueRequired(PartAction.READ_GROUP_DEFAULT_SETUP_CODE);
537 rd.setField(RegistrationDomain.FLD_GROUPNAME, groupName);
538 rd.update();
539 }
540
541
542 RegistrationObjectMap rdm = new RegistrationObjectMap();
543 rdm.setDataContext(dbname);
544 rdm.setField(RegistrationObjectMap.REG_DOMAIN_ID,
545 rd.getField(RegistrationObjectMap.REG_DOMAIN_ID));
546 rdm.setField(RegistrationObjectMap.REG_OBJ_CLASS,
547 RegisteredUser.class.getName());
548
549 if (rdm.find()) {
550
551
552 String skipFields = rdm.getField(RegistrationObjectMap.REG_FIELDS);
553 StringBuffer buf = new StringBuffer(skipFields);
554 boolean added = false;
555
556 for (int i = 0; i < REMOVED_REG_FIELDS.length; i++) {
557 String removedRegField = REMOVED_REG_FIELDS[i];
558
559 if (skipFields.indexOf(removedRegField) == -1) {
560 buf.append(",");
561 buf.append(removedRegField);
562 added = true;
563 }
564 }
565
566 if (added) {
567 rdm.setField(RegistrationObjectMap.REG_FIELDS, buf.toString());
568 rdm.update();
569 }
570 }
571 }
572
573
574 }
575
576 /***
577 * Constructs the default database object permissions.
578 *
579 * @param theLog the Installation log to output messages to.
580 * @throws DBException upon error.
581 */
582 private void addDefaultObjPermissions(final InstallLog theLog, String dbName) throws DBException {
583
584
585 String groupName = null;
586
587
588 DBObjSecurity security = new DBObjSecurity(SuperUser.INSTANCE);
589 security.setDataContext(dbName);
590 security.setField(DBObjSecurity.DBOBJECT_NAME, NodeType.class.getName());
591 security.setField(DBObjSecurity.GROUP_NAME, Setup.getValueRequired(dbName, PartAction.READ_GROUP_DEFAULT_SETUP_CODE));
592 security.setField(DBObjSecurity.METHOD_ALLOWED_CODE, SecuredDBObject.SEARCH);
593 security.addIfNeeded();
594
595 Enumeration enumeration = getMembers();
596
597 while (enumeration.hasMoreElements()) {
598 DBObject dbObject = (DBObject) enumeration.nextElement();
599 dbObject.setDataContext(dbName);
600 if (dbObject instanceof SecuredDBObject) {
601
602 security = new DBObjSecurity(SuperUser.INSTANCE);
603 security.setDataContext(dbName);
604 security.setField(DBObjSecurity.DBOBJECT_NAME, dbObject.getClass().getName());
605
606
607 security.setField(DBObjSecurity.GROUP_NAME,
608 Setup.getValueRequired(dbName, PartAction.READ_GROUP_DEFAULT_SETUP_CODE));
609 security.setField(DBObjSecurity.METHOD_ALLOWED_CODE, SecuredDBObject.SEARCH);
610 security.addIfNeeded();
611
612
613
614 String table = dbObject.getJDBCMetaData().getTargetTable();
615 if (table.equals(NodeType.NODE_TYPE_TABLE_NAME)
616 || table.equals(Part.PART_TYPE_TABLE_NAME)
617 || table.equals(PickList.TABLE_NAME)
618 || table.equals(UserGroup.TABLE_NAME)) {
619 groupName = Setup.getValueRequired(dbName, PartAction.MODEL_EDIT_GROUP_DEFAULT_SETUP_CODE);
620 } else {
621 groupName = Setup.getValueRequired(dbName, PartAction.WRITE_GROUP_DEFAULT_SETUP_CODE);
622 }
623
624 security.setField(DBObjSecurity.GROUP_NAME, groupName);
625
626 for (int j = 0; j < RowSecuredDBObject.ALL_FUNCTIONS.length; j++) {
627 String function = RowSecuredDBObject.ALL_FUNCTIONS[j];
628 security.setField(DBObjSecurity.METHOD_ALLOWED_CODE,
629 function);
630 security.addIfNeeded();
631 }
632 }
633 }
634
635
636 NodeType searchtype = new NodeType();
637 searchtype.setDataContext(dbName);
638 List alltypes = searchtype.searchAndRetrieveList();
639 for (Iterator iterator = alltypes.iterator(); iterator.hasNext();) {
640 NodeType nodetype = (NodeType) iterator.next();
641 int rowpermsInt = nodetype.getPermissions().permissions();
642 rowpermsInt |= RowPermissions.OTHERS_READ_MASK;
643 nodetype.setPermissions(rowpermsInt);
644 }
645
646 theLog.info("Default Object Permissions Complete");
647 }
648
649 private void ensureGroup(String group, String descrip, String dbName) throws DBException {
650 UserGroup grp = new UserGroup();
651 grp.setDataContext(dbName);
652 grp.setGroupName(group);
653 grp.setField(UserGroup.GROUP_DESCRIPTION, descrip);
654 grp.addIfNeeded();
655
656
657
658 addGroupRowPermsForGroupItself(group, dbName);
659 }
660
661 /***
662 * Add the group permission.
663 *
664 * @param grp String the group to add.
665 * @return PermGroup the constructed permissions group object.
666 * @throws DBException upon database access error.
667 */
668 private PermGroup addGroupRowPermsForGroupItself(final String grp, String dbName) throws DBException {
669
670
671
672 PermGroup permgrp = new PermGroup();
673 permgrp.setGroupName(grp);
674 permgrp.setDataContext(dbName);
675 permgrp.retrieve();
676
677
678 RowPermissions rowperms = new RowPermissions(UserGroup.TABLE_NAME, permgrp.getKey());
679 rowperms.setDataContext(dbName);
680 if (!rowperms.find()) {
681 rowperms.permissions(RowPermissions.OWNER_WRITES_GROUP_AND_OTHERS_READ_ONLY_PERMISSIONS);
682 rowperms.add();
683 }
684
685
686 RowGroupPerms grpperms = new RowGroupPerms(permgrp, grp);
687 grpperms.setDataContext(dbName);
688 if (!grpperms.find()) {
689 grpperms.permissions(RowPermissions.OWNER_WRITES_GROUP_AND_OTHERS_READ_ONLY_PERMISSIONS);
690 grpperms.add();
691 }
692
693 return permgrp;
694 }
695
696 /***
697 * Return an instance of the WizardRepository to retrieve what you need.
698 *
699 * @param dataContext the data context to retrieve for.
700 * @return WizardRepository instance.
701 */
702 public WizardRepository getWizardRepository(String dataContext) {
703 return (WizardRepository) wizardRepository.get(dataContext);
704 }
705
706 /***
707 * Method to return the current version number of an application
708 * Schema.
709 *
710 * @return the Version you define for your system.
711 */
712 public String getVersion() {
713 return "1.0.1";
714 }
715
716 /***
717 * Initialize the application container.
718 *
719 * @return PicoContainer
720 */
721 public PicoContainer initializeApplicationContainer() {
722
723 MutablePicoContainer pico = new DefaultPicoContainer();
724
725
726 pico.registerComponentImplementation(CompletionRepository.class, ExpressoCompletionRepository.class);
727 pico.registerComponentImplementation(ICompletionBeanManager.class, CompletionBeanManager.class);
728 pico.registerComponentImplementation(com.sri.emo.wizard.WizDefinitionRepository.class,
729 com.sri.emo.wizard.expressoimpl.SelectionWizDefinitionRepository.class);
730 pico.registerComponentImplementation(CompletionDBObjConverter.class, CompletionDBObjConverterImpl.class);
731 pico.registerComponentImplementation("CompletionMementoConverter",
732 com.sri.emo.wizard.completion.CompletionMementoConverter.class);
733
734
735
736 pico.registerComponentImplementation(com.sri.emo.wizard.completion.EmoCompletionFactory.class.getName(),
737 com.sri.emo.wizard.completion.EmoCompletionFactory.class);
738 pico.registerComponentImplementation(com.sri.emo.wizard.selection.EmoSelectionWizardFactory.class.getName(),
739 com.sri.emo.wizard.selection.EmoSelectionWizardFactory.class);
740
741 addAllSchemaElementsToContainer(pico);
742
743 return pico;
744 }
745 }