List of usage examples for java.util Set remove
boolean remove(Object o);
From source file:com.sun.socialsite.userapi.UserManagerImpl.java
public void revokeRole(String roleName, User user) throws UserManagementException { if (roleName == null) { throw new UserManagementException("Cannot revoke role with null roleName"); }/*from ww w . j a v a 2 s .c o m*/ if (user == null) { throw new UserManagementException("Cannot revoke role with null user"); } Query query = getNamedQuery("UserRole.findByRoleName"); query.setParameter("roleName", roleName); try { UserRole role = (UserRole) query.getSingleResult(); Set<UserRole> userRoles = user.getRoles(); userRoles.remove(role); user.setRoles(userRoles); } catch (NoResultException ex) { // no op } }
From source file:gov.nih.nci.cabig.caaers.domain.dto.EvaluationResultDTO.java
/** * Removes the report definition name.//from w w w . j av a2 s . c o m * * @param aeReportId the ae report id * @param theOne the the one */ public void removeReportDefinitionName(Integer aeReportId, String theOne) { Map<AdverseEvent, Set<String>> map = processedRulesEngineResultMap.get(aeReportId); for (Map.Entry<AdverseEvent, Set<String>> entry : map.entrySet()) { Set<String> reportDefinitionNames = entry.getValue(); reportDefinitionNames.remove(theOne); } }
From source file:gemlite.core.internal.support.context.GemliteIndexContext.java
private void removeIndexNamesByRegion(String indexName, String regionName) { Set<IndexRegion> indexNames = regionMap.get(regionName); if (indexNames != null) { Set<IndexRegion> copy = new HashSet<>(indexNames); for (Iterator<IndexRegion> it = copy.iterator(); it.hasNext();) { IndexRegion region = it.next(); if (region.indexName().equalsIgnoreCase(indexName)) { indexNames.remove(region); }/*w w w . j a v a 2 s . co m*/ } } if (indexNames == null || indexNames.size() == 0) regionMap.remove(regionName); }
From source file:com.meread.buildenv.BuildThread.java
private Set<HostInfo> getOtherHostInfo() { Set<HostInfo> result = new HashSet<>(); result.addAll(BuildEnv.ALL_HOST);/* w ww . j a v a 2s . co m*/ result.remove(hostInfo); return result; }
From source file:org.apache.nifi.processors.aws.wag.AbstractAWSGatewayApiProcessor.java
@Override public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) { if (descriptor.isDynamic()) { final Set<String> newDynamicPropertyNames = new HashSet<>(dynamicPropertyNames); if (newValue == null) { newDynamicPropertyNames.remove(descriptor.getName()); } else if (oldValue == null) { // new property newDynamicPropertyNames.add(descriptor.getName()); }/*www . j a va 2 s . co m*/ this.dynamicPropertyNames = Collections.unmodifiableSet(newDynamicPropertyNames); } else { // compile the attributes-to-send filter pattern if (PROP_ATTRIBUTES_TO_SEND.getName().equalsIgnoreCase(descriptor.getName())) { if (newValue == null || newValue.isEmpty()) { regexAttributesToSend = null; } else { final String trimmedValue = StringUtils.trimToEmpty(newValue); regexAttributesToSend = Pattern.compile(trimmedValue); } } } }
From source file:gov.nih.nci.cabig.caaers.domain.dto.EvaluationResultDTO.java
/** * Replace report definition name./*www. j a v a2 s .c om*/ * * @param aeReportId the ae report id * @param theOne the the one * @param anotherOne the another one */ public void replaceReportDefinitionName(Integer aeReportId, String theOne, String anotherOne) { Map<AdverseEvent, Set<String>> map = processedRulesEngineResultMap.get(aeReportId); for (Map.Entry<AdverseEvent, Set<String>> entry : map.entrySet()) { Set<String> reportDefinitionNames = entry.getValue(); if (reportDefinitionNames.remove(theOne)) { reportDefinitionNames.add(anotherOne); } } }
From source file:com.google.ie.business.service.impl.AdminServiceImpl.java
/** * Process rejected request by calling appropriate service based on the * given entity type./* w w w . j a v a 2 s . c o m*/ * * @param entityType Type of entity. * @param entityKey Key of Idea object * @param requestType Request type like Duplicate, Objectionable etc */ protected void processDenyRequest(String entityType, String entityKey, String requestType) { if (entityType.equalsIgnoreCase(Idea.class.getSimpleName())) { Idea idea = ideaService.getIdeaByKey(entityKey); Set<String> flagTypeSet = idea.getFlagType(); flagTypeSet.remove(requestType); idea.setOriginalIdeaKey(""); ideaService.updateIdea(idea); } else if (entityType.equalsIgnoreCase(IdeaComment.class.getSimpleName())) { Comment ideaComment = ideaCommentService.getCommentById(entityKey); ideaComment.setStatus(Comment.STATUS_SAVED); ideaCommentService.updateComment(ideaComment); } else if (entityType.equalsIgnoreCase(ProjectComment.class.getSimpleName())) { Comment projectComment = projectCommentService.getCommentById(entityKey); projectComment.setStatus(Comment.STATUS_SAVED); projectCommentService.updateComment(projectComment); } }
From source file:gemlite.core.internal.support.context.GemliteIndexContext.java
private void removeIndexNamesByTestRegion(String indexName, String regionName) { Set<IndexRegion> indexNames = testRegionMap.get(regionName); if (indexNames != null) { Set<IndexRegion> copy = new HashSet<>(indexNames); for (Iterator<IndexRegion> it = copy.iterator(); it.hasNext();) { IndexRegion region = it.next(); if (region.regionName().equalsIgnoreCase(regionName)) { indexNames.remove(region); }/*from ww w .j av a2 s. c o m*/ } } if (indexNames == null || indexNames.size() == 0) testRegionMap.remove(regionName); }
From source file:me.st28.flexseries.flexlib.plugin.FlexPlugin.java
@Override public final void onEnable() { if (status == PluginStatus.LOADING_ERROR) { LogHelper.severe(this, "Encountered errors while loading. To help prevent damage, the plugin will now be disabled."); Bukkit.getPluginManager().disablePlugin(this); return;/*from w w w.j a v a2s .c om*/ } status = PluginStatus.ENABLING; long loadStartTime = System.currentTimeMillis(); // Register self as a Listener if implemented. if (this instanceof Listener) { Bukkit.getPluginManager().registerEvents((Listener) this, this); } // Determine if this plugin has a configuration file or not, and save it if there is one. if (getResource("config.yml") != null) { saveDefaultConfig(); getConfig().options().copyDefaults(true); saveConfig(); reloadConfig(); hasConfig = true; } // LOAD MODULES // // Check for unused modules Set<FlexModule> unused = new HashSet<>(modules.values()); for (FlexModule module : modules.values()) { ModuleDescriptor descriptor = module.getDescriptor(); if (!descriptor.smartLoad()) { unused.remove(module); } Set<ModuleReference> allDependencies = new HashSet<>(); allDependencies.addAll(descriptor.getSoftDependencies()); allDependencies.addAll(descriptor.getHardDependencies()); for (ModuleReference reference : allDependencies) { FlexModule refModule = reference.getModule(); if (refModule != null) { unused.remove(refModule); } } } if (!unused.isEmpty()) { LogHelper.info(this, "Smart load stopped " + unused.size() + " unused module(s) from loading."); LogHelper.debug(this, "Unused modules: " + StringUtils.collectionToSortedString(unused, new StringConverter<FlexModule>() { @Override public String toString(FlexModule object) { return object.getName(); } })); } Set<FlexModule> checked = new HashSet<>(); for (FlexModule module : modules.values()) { if (unused.contains(module) || checked.contains(module) || module.getStatus() != ModuleStatus.PENDING) { continue; } checked.add(module); loadModule(unused, checked, module); } // LOAD MODULES // try { handleEnable(); } catch (Exception ex) { status = PluginStatus.ENABLING_ERROR; throw new RuntimeException("An exception occurred while enabling.", ex); } status = PluginStatus.ENABLED; LogHelper.info(this, String.format("%s v%s by %s ENABLED (%dms)", getName(), getDescription().getVersion(), getDescription().getAuthors(), System.currentTimeMillis() - loadStartTime)); }
From source file:com.evolveum.midpoint.web.page.admin.orgs.OrgTreePanel.java
private void initLayout(ModelServiceLocator serviceLocator) { WebMarkupContainer treeHeader = new WebMarkupContainer(ID_TREE_HEADER); treeHeader.setOutputMarkupId(true);/*from w w w.ja v a 2s . co m*/ add(treeHeader); String title = StringUtils.isEmpty(treeTitleKey) ? "TreeTablePanel.hierarchy" : treeTitleKey; Label treeTitle = new Label(ID_TREE_TITLE, createStringResource(title)); treeHeader.add(treeTitle); InlineMenu treeMenu = new InlineMenu(ID_TREE_MENU, new Model<>((Serializable) createTreeMenuInternal(serviceLocator.getAdminGuiConfiguration()))); treeHeader.add(treeMenu); ISortableTreeProvider provider = new OrgTreeProvider(this, getModel()) { private static final long serialVersionUID = 1L; @Override protected List<InlineMenuItem> createInlineMenuItems(OrgType org) { return createTreeChildrenMenu(org); } }; List<IColumn<SelectableBean<OrgType>, String>> columns = new ArrayList<>(); if (selectable) { columns.add(new CheckBoxHeaderColumn<>()); } columns.add(new TreeColumn<>(createStringResource("TreeTablePanel.hierarchy"))); columns.add(new InlineMenuHeaderColumn(createTreeChildrenMenu(null))); WebMarkupContainer treeContainer = new WebMarkupContainer(ID_TREE_CONTAINER) { private static final long serialVersionUID = 1L; @Override public void renderHead(IHeaderResponse response) { super.renderHead(response); // method computes height based on document.innerHeight() - // screen height; Component form = OrgTreePanel.this.getParent().get("memberPanel"); if (form != null) { response.render(OnDomReadyHeaderItem .forScript("updateHeight('" + getMarkupId() + "', ['#" + form.getMarkupId() + "'], ['#" + OrgTreePanel.this.get(ID_TREE_HEADER).getMarkupId() + "'])")); } } }; add(treeContainer); TreeStateModel treeStateMode = new TreeStateModel(this, provider) { private static final long serialVersionUID = 1L; @Override public Set<SelectableBean<OrgType>> getExpandedItems() { return OrgTreePanel.this.getExpandedItems(getOrgTreeStateStorage()); } @Override public SelectableBean<OrgType> getCollapsedItem() { return OrgTreePanel.this.getCollapsedItem(getOrgTreeStateStorage()); } @Override public void setCollapsedItem(SelectableBean<OrgType> item) { OrgTreePanel.this.setCollapsedItem(null, getOrgTreeStateStorage()); } }; TableTree<SelectableBean<OrgType>, String> tree = new TableTree<SelectableBean<OrgType>, String>(ID_TREE, columns, provider, Integer.MAX_VALUE, treeStateMode) { private static final long serialVersionUID = 1L; @Override protected Component newContentComponent(String id, IModel<SelectableBean<OrgType>> model) { return new SelectableFolderContent(id, this, model, selected) { private static final long serialVersionUID = 1L; @Override protected void onClick(AjaxRequestTarget target) { super.onClick(target); OrgTreePanel.this.setSelectedItem(selected.getObject(), getOrgTreeStateStorage()); selectTreeItemPerformed(selected.getObject(), target); } }; } @Override protected Item<SelectableBean<OrgType>> newRowItem(String id, int index, final IModel<SelectableBean<OrgType>> model) { Item<SelectableBean<OrgType>> item = super.newRowItem(id, index, model); item.add(AttributeModifier.append("class", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { SelectableBean<OrgType> itemObject = model.getObject(); if (itemObject != null && itemObject.equals(selected.getObject())) { return "success"; } return null; } })); return item; } @Override public void collapse(SelectableBean<OrgType> collapsedItem) { super.collapse(collapsedItem); Set<SelectableBean<OrgType>> items = OrgTreePanel.this.getExpandedItems(getOrgTreeStateStorage()); if (items != null && items.contains(collapsedItem)) { items.remove(collapsedItem); } OrgTreePanel.this.setExpandedItems((TreeStateSet) items, getOrgTreeStateStorage()); OrgTreePanel.this.setCollapsedItem(collapsedItem, getOrgTreeStateStorage()); } @Override protected void onModelChanged() { super.onModelChanged(); TreeStateSet<SelectableBean<OrgType>> items = (TreeStateSet) getModelObject(); if (!items.isInverse()) { OrgTreePanel.this.setExpandedItems(items, getOrgTreeStateStorage()); } } }; tree.setItemReuseStrategy(new ReuseIfModelsEqualStrategy()); tree.getTable().add(AttributeModifier.replace("class", "table table-striped table-condensed")); tree.add(new WindowsTheme()); // tree.add(AttributeModifier.replace("class", "tree-midpoint")); treeContainer.add(tree); }