📄 admingroupdatabean.java
字号:
Iterator i = getAccessRules().iterator(); while (i.hasNext()) { AccessRulesDataLocal ar = (AccessRulesDataLocal) i.next(); if (ar.getAccessRuleObject().getAccessRule().equals(accessrule)) { getAccessRules().remove(ar); try { ar.remove(); } catch (RemoveException e) { error("Error removing AccessRules: ", e); throw new EJBException(e); } break; } } } } // removeAccessRules /** * Returns the number of access rules in admingroup * * @return the number of accessrules in the database * @ejb.interface-method view-type="local" */ public int getNumberOfAccessRules() { return getAccessRules().size(); } // getNumberOfAccessRules /** * Returns all the accessrules as a Collection of AccessRules * @ejb.interface-method view-type="local" */ public Collection getAccessRuleObjects() { final Collection rules = getAccessRules(); ArrayList objects = new ArrayList(rules.size()); Iterator i = rules.iterator(); while (i.hasNext()) { AccessRulesDataLocal ar = (AccessRulesDataLocal) i.next(); objects.add(ar.getAccessRuleObject()); } return objects; } /** * Adds a Collection of AdminEntity to the database. Changing their values if they already exists * @ejb.interface-method view-type="local" */ public void addAdminEntities(Collection adminentities) { Iterator iter = adminentities.iterator(); while (iter.hasNext()) { AdminEntity adminentity = (AdminEntity) iter.next(); try { AdminEntityDataLocal data = createAdminEntity(adminentity); AdminEntityPK datapk = createAdminEntityPK(getAdminGroupName(), getCaId(), adminentity.getMatchWith(), adminentity.getMatchType(), adminentity.getMatchValue()); Iterator i = getAdminEntities().iterator(); while (i.hasNext()) { AdminEntityDataLocal ue = (AdminEntityDataLocal) i.next(); // TODO use ue.getPrimaryKey() ? AdminEntityPK uepk = createAdminEntityPK(getAdminGroupName(), getCaId(), ue.getMatchWith() , ue.getMatchType(), ue.getMatchValue()); if (uepk.equals(datapk)) { getAdminEntities().remove(ue); try { ue.remove(); } catch (RemoveException e) { error("Error adding AdminEntities: ", e); throw new EJBException(e); } break; } } getAdminEntities().add(data); } catch (Exception e) { error("Error adding AdminEntities: ", e); } } } // addAdminEntities /** * Removes a Collection if AdminEntity from the database. * @ejb.interface-method view-type="local" */ public void removeAdminEntities(Collection adminentities) { Iterator iter = adminentities.iterator(); while (iter.hasNext()) { AdminEntity adminentity = (AdminEntity) iter.next(); AdminEntityPK datapk = createAdminEntityPK(getAdminGroupName(), getCaId(), adminentity.getMatchWith(), adminentity.getMatchType(), adminentity.getMatchValue()); Iterator i = getAdminEntities().iterator(); while (i.hasNext()) { AdminEntityDataLocal ue = (AdminEntityDataLocal) i.next(); // TODO use ue.getPrimaryKey() ? AdminEntityPK uepk = createAdminEntityPK(getAdminGroupName(), getCaId(), ue.getMatchWith(), ue.getMatchType(), ue.getMatchValue()); if (uepk.equals(datapk)) { getAdminEntities().remove(ue); try { ue.remove(); } catch (RemoveException e) { error("Error removing AdminEntities: ", e); throw new EJBException(e); } break; } } } } // removeAdminEntities // this method is to avoid matching arguments errors while generating the class private AdminEntityPK createAdminEntityPK(String name, int id, int with, int type, String value){ AdminEntityPK pk = new AdminEntityPK(name, id, with, type, value); return pk; } /** * Returns the number of user entities in admingroup * * @return the number of user entities in the database * @ejb.interface-method view-type="local" */ public int getNumberOfAdminEntities() { return getAdminEntities().size(); } // getNumberOfAdminEntities /** * Returns all the adminentities as Collection of AdminEntity. * @ejb.interface-method view-type="local" */ public Collection getAdminEntityObjects() { ArrayList returnval = new ArrayList(); Iterator i = getAdminEntities().iterator(); while (i.hasNext()) { AdminEntityDataLocal ae = (AdminEntityDataLocal) i.next(); returnval.add(ae.getAdminEntity(getCaId())); } return returnval; } // getAdminEntityObjects /** * Returns the data in admingroup representation. * @ejb.interface-method view-type="local" */ public AdminGroup getAdminGroup() { ArrayList accessrules = new ArrayList(); ArrayList adminentities = new ArrayList(); Iterator i = null; i = getAdminEntities().iterator(); while (i.hasNext()) { AdminEntityDataLocal ae = (AdminEntityDataLocal) i.next(); adminentities.add(ae.getAdminEntity(getCaId())); } i = getAccessRules().iterator(); while (i.hasNext()) { AccessRulesDataLocal ar = (AccessRulesDataLocal) i.next(); accessrules.add(ar.getAccessRuleObject()); } return new AdminGroup(getPrimKey().intValue(), getAdminGroupName(), getCaId(), accessrules, adminentities); } // getAdminGroup /** * Returns an AdminGroup object only containing name and caid and no access data. * @ejb.interface-method view-type="local" */ public AdminGroup getAdminGroupNames() { return new AdminGroup(getPrimKey().intValue(), getAdminGroupName(), getCaId(), null, null); } // getAdminGroupNames // // Fields required by Container // /** * Entity Bean holding data of raadmin profilegroups. * @param admingroupname * * @ejb.create-method view-type="local" */ public Integer ejbCreate(Integer pk, String admingroupname, int caid) throws CreateException { setPrimKey(pk); setAdminGroupName(admingroupname); setCaId(caid); debug("Created admingroup : " + admingroupname); return pk; } public void ejbPostCreate(Integer pk, String admingroupname, int caid) { // Do nothing. Required. } // Private Methods. private AdminEntityDataLocal createAdminEntity(AdminEntity adminentity) throws CreateException { AdminEntityDataLocalHome home = (AdminEntityDataLocalHome) ServiceLocator.getInstance().getLocalHome(AdminEntityDataLocalHome.COMP_NAME); AdminEntityDataLocal returnval = home.create(getAdminGroupName(), getCaId(), adminentity.getMatchWith(), adminentity.getMatchType(), adminentity.getMatchValue()); return returnval; } private AccessRulesDataLocal createAccessRule(AccessRule accessrule) throws CreateException { AccessRulesDataLocalHome home = (AccessRulesDataLocalHome) ServiceLocator.getInstance().getLocalHome(AccessRulesDataLocalHome.COMP_NAME); AccessRulesDataLocal returnval = home.create(getAdminGroupName(), getCaId(), accessrule.getAccessRule(), accessrule.getRule(), accessrule.isRecursive()); return returnval; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -