List of usage examples for java.util TreeSet addAll
public boolean addAll(Collection<? extends E> c)
From source file:org.openmrs.module.emrapi.encounter.EncounterTransactionMapper.java
private Set<Obs> getSortedTopLevelObservations(Encounter encounter, Boolean includeAll) { TreeSet<Obs> sortedObservations = new TreeSet<Obs>(new Comparator<Obs>() { @Override/*from w w w .jav a 2 s.c om*/ public int compare(Obs o1, Obs o2) { if (shouldNotCompareOnCreatedDates(o2.getDateCreated(), o1.getDateCreated())) { if (shouldNotCompareOnIds(o1.getId(), o2.getId())) return 0; return o2.getId().compareTo(o1.getId()); } return o2.getDateCreated().compareTo(o1.getDateCreated()); } }); Set<Obs> observations = encounter.getObsAtTopLevel(includeAll); sortedObservations.addAll(observations); return sortedObservations; }
From source file:ca.uhn.fhir.rest.server.provider.dstu2.ServerConformanceProvider.java
private void handleDynamicSearchMethodBinding(RestResource resource, RuntimeResourceDefinition def, TreeSet<String> includes, DynamicSearchMethodBinding searchMethodBinding) { includes.addAll(searchMethodBinding.getIncludes()); List<RuntimeSearchParam> searchParameters = new ArrayList<RuntimeSearchParam>(); searchParameters.addAll(searchMethodBinding.getSearchParams()); sortRuntimeSearchParameters(searchParameters); if (!searchParameters.isEmpty()) { for (RuntimeSearchParam nextParameter : searchParameters) { String nextParamName = nextParameter.getName(); // String chain = null; String nextParamUnchainedName = nextParamName; if (nextParamName.contains(".")) { // chain = nextParamName.substring(nextParamName.indexOf('.') + 1); nextParamUnchainedName = nextParamName.substring(0, nextParamName.indexOf('.')); }/* w w w .j ava 2s. co m*/ String nextParamDescription = nextParameter.getDescription(); /* * If the parameter has no description, default to the one from the resource */ if (StringUtils.isBlank(nextParamDescription)) { RuntimeSearchParam paramDef = def.getSearchParam(nextParamUnchainedName); if (paramDef != null) { nextParamDescription = paramDef.getDescription(); } } RestResourceSearchParam param; param = resource.addSearchParam(); param.setName(nextParamName); // if (StringUtils.isNotBlank(chain)) { // param.addChain(chain); // } param.setDocumentation(nextParamDescription); // param.setType(nextParameter.getParamType()); } } }
From source file:org.jactr.core.model.basic.BasicModel.java
public Collection<String> getPossibleParameters() { TreeSet<String> possible = new TreeSet<String>(READABLE_PARAMETERS); possible.addAll(WRITABLE_PARAMETERS); return possible; }
From source file:net.sf.jabref.model.database.BibtexDatabase.java
public TreeSet<String> getAllVisibleFields() { TreeSet<String> allFields = new TreeSet<>(); for (BibtexEntry e : getEntries()) { allFields.addAll(e.getFieldNames()); }/* w w w . j av a 2 s .c o m*/ TreeSet<String> toberemoved = new TreeSet<>(); for (String field : allFields) { if (field.startsWith("__")) { toberemoved.add(field); } } for (String field : toberemoved) { allFields.remove(field); } return allFields; }
From source file:org.hl7.fhir.instance.conf.ServerConformanceProvider.java
private void handleDynamicSearchMethodBinding(ConformanceRestResourceComponent resource, RuntimeResourceDefinition def, TreeSet<String> includes, DynamicSearchMethodBinding searchMethodBinding) { includes.addAll(searchMethodBinding.getIncludes()); List<RuntimeSearchParam> searchParameters = new ArrayList<RuntimeSearchParam>(); searchParameters.addAll(searchMethodBinding.getSearchParams()); sortRuntimeSearchParameters(searchParameters); if (!searchParameters.isEmpty()) { for (RuntimeSearchParam nextParameter : searchParameters) { String nextParamName = nextParameter.getName(); // String chain = null; String nextParamUnchainedName = nextParamName; if (nextParamName.contains(".")) { // chain = nextParamName.substring(nextParamName.indexOf('.') + 1); nextParamUnchainedName = nextParamName.substring(0, nextParamName.indexOf('.')); }/*from ww w . j ava 2 s .co m*/ String nextParamDescription = nextParameter.getDescription(); /* * If the parameter has no description, default to the one from the * resource */ if (StringUtils.isBlank(nextParamDescription)) { RuntimeSearchParam paramDef = def.getSearchParam(nextParamUnchainedName); if (paramDef != null) { nextParamDescription = paramDef.getDescription(); } } ConformanceRestResourceSearchParamComponent param = resource.addSearchParam(); param.setName(nextParamName); // if (StringUtils.isNotBlank(chain)) { // param.addChain(chain); // } param.setDocumentation(nextParamDescription); // param.setType(nextParameter.getParamType()); } } }
From source file:com.edgenius.wiki.service.impl.SpaceServiceImpl.java
/** * Do following during deleting space in permanently. * <li>Delete space database record.</li> * <li>Remove any draft for this space.</li> * <li>Delete all pages in this space.</li> * <li>Remove all page tags in this space.</li> * <li>Remove space group role.</li> * <li>Remove permissions, resources.</li> * <li>Remove repository.</li> * // w w w . j a va 2s . c o m * Remove space index job will do in SpaceIndexInterceptor class. */ public Space removeSpace(String spaceUname, boolean persist) throws SpaceException { Space space = spaceDAO.getByUname(spaceUname); if (space == null) { throw new SpaceException("Unable to find given space to remove: " + spaceUname); } if (persist) { // if 2 step remove(1st mark remove flag, 2nd physical remove): need // open this comments. // if (!space.isRemoved()) // throw new SpaceException("Space " + spaceUname + " must be trashed before physical removed."); log.info("Space {} is going to be removed permanently.", spaceUname); templateDAO.removeSpaceTemplates(space.getUid()); // remove all draft: draft refer to space, if they do not removed, space can not removed. // and draft remove must before page remove as draft refer to page in parent field. draftDAO.removeSpaceDrafts(space.getUid()); // TODO: it is must very slow action: delete page by page. But it is // complex as well if bulk delete. There are // too many relation table, such as page process, Page List<Page> pages = pageDAO.getSpaceAllPages(spaceUname); //delete children first TreeSet<Page> sortedSet = new TreeSet<Page>(new PageComparator(null)); sortedSet.addAll(pages); pages = new ArrayList<Page>(sortedSet); Collections.reverse(pages); for (Page page : pages) { try { pageService.removePage(spaceUname, page.getPageUuid(), false, persist); } catch (PageException e) { log.error("Remove space " + spaceUname + " page failed.Title " + page.getTitle() + ". UUID:" + page.getPageUuid(), e); } } try { ITicket fromTicket = repositoryService.login(spaceUname, spaceUname, spaceUname); repositoryService.removeWorkspace(fromTicket, spaceUname); } catch (RepositoryException e) { log.error("Unable remove space " + spaceUname + "'s repository stuff ", e); throw new SpaceException("Unable remove space " + spaceUname + "'s repository stuff " + e); } catch (RepositoryTiemoutExcetpion e) { log.error("Unable remove space " + spaceUname + "'s repository stuff ", e); throw new SpaceException("Unable remove space " + spaceUname + "'s repository stuff " + e); } //before resource delete, get this space admin user mail list so that it could send out notification. space.setAdminMailList(userReadingService.getSpaceAdminMailList(spaceUname)); //remove from DB pageTagDAO.removeTagsInSpace(spaceUname); roleService.removeRole(Role.SPACE_ROLE_PREFIX + spaceUname); securityService.removeResource(spaceUname); spaceDAO.removeObject(space); log.info("Space " + spaceUname + " is removed permanently."); } else { log.info("Space " + spaceUname + " is marked as removed."); space.setRemoved(true); //delay get admin user mail list until send mail Notify program space.setAdminMailList(null); WikiUtil.setTouchedInfo(userReadingService, space); spaceDAO.saveOrUpdate(space); } return space; }
From source file:ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition.java
private void scanCompositeElementForChildren() { Set<String> elementNames = new HashSet<String>(); TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> orderToElementDef = new TreeMap<Integer, BaseRuntimeDeclaredChildDefinition>(); TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> orderToExtensionDef = new TreeMap<Integer, BaseRuntimeDeclaredChildDefinition>(); scanCompositeElementForChildren(elementNames, orderToElementDef, orderToExtensionDef); if (forcedOrder != null) { /* /*from w ww . j av a 2 s .c om*/ * Find out how many elements don't match any entry in the list * for forced order. Those elements come first. */ TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> newOrderToExtensionDef = new TreeMap<Integer, BaseRuntimeDeclaredChildDefinition>(); int unknownCount = 0; for (BaseRuntimeDeclaredChildDefinition nextEntry : orderToElementDef.values()) { if (!forcedOrder.containsKey(nextEntry.getElementName())) { newOrderToExtensionDef.put(unknownCount, nextEntry); unknownCount++; } } for (BaseRuntimeDeclaredChildDefinition nextEntry : orderToElementDef.values()) { if (forcedOrder.containsKey(nextEntry.getElementName())) { Integer newOrder = forcedOrder.get(nextEntry.getElementName()); newOrderToExtensionDef.put(newOrder + unknownCount, nextEntry); } } orderToElementDef = newOrderToExtensionDef; } // while (orderToElementDef.size() > 0 && orderToElementDef.firstKey() < // 0) { // BaseRuntimeDeclaredChildDefinition elementDef = // orderToElementDef.remove(orderToElementDef.firstKey()); // if (elementDef.getElementName().equals("identifier")) { // orderToElementDef.put(theIdentifierOrder, elementDef); // } else { // throw new ConfigurationException("Don't know how to handle element: " // + elementDef.getElementName()); // } // } TreeSet<Integer> orders = new TreeSet<Integer>(); orders.addAll(orderToElementDef.keySet()); orders.addAll(orderToExtensionDef.keySet()); for (Integer i : orders) { BaseRuntimeChildDefinition nextChild = orderToElementDef.get(i); if (nextChild != null) { this.addChild(nextChild); } BaseRuntimeDeclaredChildDefinition nextExt = orderToExtensionDef.get(i); if (nextExt != null) { this.addExtension((RuntimeChildDeclaredExtensionDefinition) nextExt); } } }
From source file:org.eclipse.skalli.model.ext.maven.internal.MavenResolver.java
private Set<MavenModule> getModules(List<String> visitedPaths, String scmLocation, String relativePath, MavenModule parent) throws IOException, ValidationException { TreeSet<MavenModule> result = new TreeSet<MavenModule>(); MavenPom modulePom = pomResolver.getMavenPom(project, scmLocation, relativePath); if (modulePom == null) { return result; }/*w w w . j ava 2 s .com*/ MavenModule self = getSelf(modulePom, parent); result.add(self); Set<String> moduleTags = modulePom.getModuleTags(); for (String moduleTag : moduleTags) { String normalizedPath = getNormalizedPath(relativePath, moduleTag); if (normalizedPath != null && !visitedPaths.contains(normalizedPath)) { visitedPaths.add(normalizedPath); result.addAll(getModules(visitedPaths, scmLocation, normalizedPath, self)); } } return result; }
From source file:org.opennms.protocols.vmware.VmwareConfigBuilder.java
private void saveVMwareDatacollectionInclude() { StringBuffer buffer = new StringBuffer(); buffer.append("<?xml version=\"1.0\"?>\n"); buffer.append("\n<!--\n"); buffer.append(versionInformation);/*www. ja va 2s .c o m*/ buffer.append("-->\n\n"); buffer.append("<datacollection-group name=\"VMware" + apiVersion + "\">\n\n"); TreeSet<String> groupNames = new TreeSet<String>(); for (String collectionName : collections.keySet()) { Map<String, TreeSet<VMwareConfigMetric>> collection = collections.get(collectionName); groupNames.addAll(collection.keySet()); } for (String groupName : groupNames) { if (!"node".equalsIgnoreCase(groupName)) { buffer.append(" <resourceType name=\"vmware" + apiVersion + groupName + "\" label=\"VMware v" + apiVersion + " " + groupName + "\" resourceLabel=\"${vmware" + apiVersion + groupName + "Name}\">\n"); buffer.append( " <persistenceSelectorStrategy class=\"org.opennms.netmgt.collection.support.PersistAllSelectorStrategy\"/>\n"); buffer.append( " <storageStrategy class=\"org.opennms.netmgt.collection.support.IndexStorageStrategy\"/>\n"); buffer.append(" </resourceType>\n\n"); } } buffer.append("</datacollection-group>"); saveFile("vmware" + apiVersion + ".xml", buffer.toString()); }
From source file:ca.uhn.fhir.rest.server.provider.dstu2.ServerConformanceProvider.java
private void handleSearchMethodBinding(Rest rest, RestResource resource, String resourceName, RuntimeResourceDefinition def, TreeSet<String> includes, SearchMethodBinding searchMethodBinding) { includes.addAll(searchMethodBinding.getIncludes()); List<IParameter> params = searchMethodBinding.getParameters(); List<SearchParameter> searchParameters = new ArrayList<SearchParameter>(); for (IParameter nextParameter : params) { if ((nextParameter instanceof SearchParameter)) { searchParameters.add((SearchParameter) nextParameter); }// w w w. ja va2 s. com } sortSearchParameters(searchParameters); if (!searchParameters.isEmpty()) { // boolean allOptional = searchParameters.get(0).isRequired() == false; // // OperationDefinition query = null; // if (!allOptional) { // RestOperation operation = rest.addOperation(); // query = new OperationDefinition(); // operation.setDefinition(new ResourceReferenceDt(query)); // query.getDescriptionElement().setValue(searchMethodBinding.getDescription()); // query.addUndeclaredExtension(false, ExtensionConstants.QUERY_RETURN_TYPE, new CodeDt(resourceName)); // for (String nextInclude : searchMethodBinding.getIncludes()) { // query.addUndeclaredExtension(false, ExtensionConstants.QUERY_ALLOWED_INCLUDE, new StringDt(nextInclude)); // } // } for (SearchParameter nextParameter : searchParameters) { String nextParamName = nextParameter.getName(); String chain = null; String nextParamUnchainedName = nextParamName; if (nextParamName.contains(".")) { chain = nextParamName.substring(nextParamName.indexOf('.') + 1); nextParamUnchainedName = nextParamName.substring(0, nextParamName.indexOf('.')); } String nextParamDescription = nextParameter.getDescription(); /* * If the parameter has no description, default to the one from the resource */ if (StringUtils.isBlank(nextParamDescription)) { RuntimeSearchParam paramDef = def.getSearchParam(nextParamUnchainedName); if (paramDef != null) { nextParamDescription = paramDef.getDescription(); } } RestResourceSearchParam param = resource.addSearchParam(); param.setName(nextParamUnchainedName); if (StringUtils.isNotBlank(chain)) { param.addChain(chain); } if (nextParameter.getParamType() == RestSearchParameterTypeEnum.REFERENCE) { for (String nextWhitelist : new TreeSet<String>(nextParameter.getQualifierWhitelist())) { if (nextWhitelist.startsWith(".")) { param.addChain(nextWhitelist.substring(1)); } } } param.setDocumentation(nextParamDescription); if (nextParameter.getParamType() != null) { param.getTypeElement().setValueAsString(nextParameter.getParamType().getCode()); } for (Class<? extends IBaseResource> nextTarget : nextParameter.getDeclaredTypes()) { RuntimeResourceDefinition targetDef = myServerConfiguration.getFhirContext() .getResourceDefinition(nextTarget); if (targetDef != null) { ResourceTypeEnum code = ResourceTypeEnum.VALUESET_BINDER .fromCodeString(targetDef.getName()); if (code != null) { param.addTarget(code); } } } } } }