List of usage examples for java.util TreeSet addAll
public boolean addAll(Collection<? extends E> c)
From source file:org.unitime.timetable.test.ExportPreferences.java
public void exportSubpartStructure(Element parent, SchedulingSubpart s) { Element el = parent.addElement("schedulingSubpart"); el.addAttribute("uniqueId", s.getUniqueId().toString()); el.addAttribute("itype", s.getItypeDesc()); el.addAttribute("suffix", s.getSchedulingSubpartSuffix()); el.addAttribute("minutesPerWk", s.getMinutesPerWk().toString()); TreeSet subparts = new TreeSet(subpartCmp); subparts.addAll(s.getChildSubparts()); for (Iterator i = subparts.iterator(); i.hasNext();) { exportSubpartStructure(el, (SchedulingSubpart) s); }//from w w w .j a v a 2 s. c om TreeSet classes = new TreeSet(classCmp); classes.addAll(s.getClasses()); for (Iterator i = classes.iterator(); i.hasNext();) { Class_ c = (Class_) i.next(); Element x = el.addElement("class"); x.addAttribute("uniqueId", c.getUniqueId().toString()); if (c.getParentClass() != null) x.addAttribute("parent", c.getParentClass().getUniqueId().toString()); x.addAttribute("expectedCapacity", c.getExpectedCapacity().toString()); x.addAttribute("maxExpectedCapacity", c.getMaxExpectedCapacity().toString()); x.addAttribute("roomRatio", c.getRoomRatio().toString()); x.addAttribute("nbrRooms", c.getNbrRooms().toString()); x.addAttribute("manager", c.getManagingDept().getDeptCode()); x.addAttribute("sectionNumber", String.valueOf(c.getSectionNumber())); } }
From source file:ca.uhn.fhir.rest.server.provider.dev.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); }/*from w w w.j a 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(); } } Parameter param; if (query == null) { // param = resource.addSearchParam(); } else { param = query.addParameter(); param.addUndeclaredExtension(false, ExtensionConstants.PARAM_IS_REQUIRED, new BooleanDt(nextParameter.isRequired())); } // param.setName(nextParamName); // if (StringUtils.isNotBlank(chain)) { // param.addChain(chain); // } // param.setDocumentation(nextParamDescription); // param.setType(nextParameter.getParamType()); for (Class<? extends IResource> nextTarget : nextParameter.getDeclaredTypes()) { RuntimeResourceDefinition targetDef = myRestfulServer.getFhirContext() .getResourceDefinition(nextTarget); if (targetDef != null) { // ResourceTypeEnum code = ResourceTypeEnum.VALUESET_BINDER.fromCodeString(targetDef.getName()); // if (code != null) { // param.addTarget(code); // } } } } } }
From source file:com.github.wellcomer.query3.core.Autocomplete.java
/** ?. ?, TreeSet ? ? ?. ? TreeSet . /*from w ww . j ava2s. com*/ @param queryList ?? ?. @param scanModifiedOnly ? ?. @param mergePrevious ?? ? ?? . */ public void autolearn(QueryList queryList, boolean scanModifiedOnly, boolean mergePrevious) throws IOException { FileTime timestamp; long modifiedSince = 0; Path timestampFilePath = Paths.get(filePath, ".timestamp"); if (scanModifiedOnly) { // try { // ? ? ? timestamp = Files.getLastModifiedTime(timestampFilePath); modifiedSince = timestamp.toMillis(); } catch (IOException e) { // ? ? Files.createFile(timestampFilePath); } } HashMap<String, TreeSet<String>> fields = new HashMap<>(); // - ? ?, - ? Iterator<Query> queryIterator = queryList.iterator(modifiedSince); // ? ?? ? ? ? String k, v; while (queryIterator.hasNext()) { Query query = queryIterator.next(); for (Map.Entry<String, String> entry : query.entrySet()) { k = entry.getKey().toLowerCase(); v = entry.getValue().trim(); if (v.length() < 2) continue; if (!fields.containsKey(k)) { TreeSet<String> treeSet = new TreeSet<>(); try { if (mergePrevious) { // ? ? List<String> lines = Files.readAllLines(Paths.get(filePath, k), charset); treeSet.addAll(lines); } } catch (IOException e) { e.printStackTrace(); } fields.put(k, treeSet); } TreeSet<String> treeSet = fields.get(k); treeSet.add(v); } } for (Map.Entry<String, TreeSet<String>> entry : fields.entrySet()) { k = entry.getKey(); ArrayList<String> lines = new ArrayList<>(fields.get(k)); FileWriter fileWriter = new FileWriter(Paths.get(filePath, k).toString()); fileWriter.write(StringUtils.join(lines, System.getProperty("line.separator"))); fileWriter.flush(); fileWriter.close(); } try { Files.setLastModifiedTime(timestampFilePath, FileTime.fromMillis(System.currentTimeMillis())); } catch (IOException e) { if (e.getClass().getSimpleName().equals("NoSuchFileException")) Files.createFile(timestampFilePath); e.printStackTrace(); } }
From source file:net.spfbl.core.Peer.java
public static TreeSet<String> getReputationKeyAllSet() { TreeSet<String> keySet = new TreeSet<String>(); for (Peer peer : Peer.getSet()) { keySet.addAll(peer.getReputationKeySet()); }/*from w w w. j a va 2s.c om*/ return keySet; }
From source file:org.unitime.timetable.test.ExportPreferences.java
public void exportInstructionalOffering(Element parent, InstructionalOffering io) throws Exception { sLog.info("Exporting " + io.getCourseName()); Element el = parent.addElement("instructionalOffering"); el.addAttribute("uniqueId", io.getUniqueId().toString()); el.addAttribute("subjectArea", io.getControllingCourseOffering().getSubjectAreaAbbv()); el.addAttribute("courseNbr", io.getControllingCourseOffering().getCourseNbr()); if (io.getInstrOfferingPermId() != null) el.addAttribute("instrOfferingPermId", io.getInstrOfferingPermId().toString()); for (Iterator i = io.getCourseOfferings().iterator(); i.hasNext();) { CourseOffering co = (CourseOffering) i.next(); Element x = el.addElement("courseOffering"); x.addAttribute("uniqueId", co.getUniqueId().toString()); x.addAttribute("subjectArea", co.getSubjectAreaAbbv()); x.addAttribute("courseNbr", co.getCourseNbr()); x.addAttribute("projectedDemand", co.getProjectedDemand().toString()); x.addAttribute("demand", co.getDemand().toString()); x.addAttribute("isControl", co.getIsControl().toString()); if (co.getPermId() != null) x.addAttribute("permId", co.getPermId()); }/*from www . j a va 2s . c om*/ for (Iterator i = io.getInstrOfferingConfigs().iterator(); i.hasNext();) { InstrOfferingConfig c = (InstrOfferingConfig) i.next(); Element x = el.addElement("instrOfferingConfig"); x.addAttribute("uniqueId", c.getUniqueId().toString()); x.addAttribute("limit", c.getLimit().toString()); TreeSet subparts = new TreeSet(subpartCmp); subparts.addAll(c.getSchedulingSubparts()); for (Iterator j = subparts.iterator(); j.hasNext();) { SchedulingSubpart s = (SchedulingSubpart) j.next(); if (s.getParentSubpart() == null) exportSubpartStructure(x, s); } } }
From source file:net.padlocksoftware.padlock.license.LicenseImpl.java
/** * Concatenate all keys and values into a single String *///ww w . j a v a2s . c om public String concatenate() { StringBuffer buffer = new StringBuffer(); TreeSet<String> keys = new TreeSet<String>(); keys.addAll(propertyNames(props)); for (String key : keys) { String value = props.getProperty(key); if (value != null && !"signature".equals(key)) { buffer.append(key); buffer.append(value); } } return buffer.toString(); }
From source file:ca.uhn.fhir.rest.server.provider.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('.')); }//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(); } } RestResourceSearchParam param; param = resource.addSearchParam(); param.setName(nextParamName); // if (StringUtils.isNotBlank(chain)) { // param.addChain(chain); // } param.setDocumentation(nextParamDescription); param.getTypeElement().setValue(nextParameter.getParamType().getCode()); } } }
From source file:org.jactr.core.module.declarative.search.local.DefaultSearchSystem.java
public Collection<IChunk> findFuzzy(ChunkTypeRequest pattern, Comparator<IChunk> sortRule) { /*/*from w w w . j av a 2s .c o m*/ * second pass, ditch all those that don't match our chunktype */ HashSet<IChunk> candidates = new HashSet<IChunk>(); IChunkType chunkType = pattern.getChunkType(); /* * first things first, find all the candidates based on the content of the * pattern. this is the same as findExact, but without the retainAll */ for (IConditionalSlot slot : pattern.getConditionalSlots()) { Collection<IChunk> containers = find(slot); if (chunkType == null) candidates.addAll(containers); else for (IChunk candidate : containers) if (candidate.isA(chunkType)) candidates.add(candidate); } if (LOGGER.isDebugEnabled()) LOGGER.debug("First pass candidates for " + pattern + " chunks: " + candidates); if (sortRule != null) { /* * finally, we sort them */ TreeSet<IChunk> sortedResults = new TreeSet<IChunk>(sortRule); sortedResults.addAll(candidates); return sortedResults; } return candidates; }
From source file:org.apache.hadoop.hbase.backup.impl.RestoreClientImpl.java
private boolean validate(HashMap<TableName, BackupManifest> backupManifestMap) throws IOException { boolean isValid = true; for (Entry<TableName, BackupManifest> manifestEntry : backupManifestMap.entrySet()) { TableName table = manifestEntry.getKey(); TreeSet<BackupImage> imageSet = new TreeSet<BackupImage>(); ArrayList<BackupImage> depList = manifestEntry.getValue().getDependentListByTable(table); if (depList != null && !depList.isEmpty()) { imageSet.addAll(depList); }/*from w ww. j av a2 s . co m*/ LOG.info("Dependent image(s) from old to new:"); for (BackupImage image : imageSet) { String imageDir = HBackupFileSystem.getTableBackupDir(image.getRootDir(), image.getBackupId(), table); if (!BackupClientUtil.checkPathExist(imageDir, conf)) { LOG.error("ERROR: backup image does not exist: " + imageDir); isValid = false; break; } // TODO More validation? LOG.info("Backup image: " + image.getBackupId() + " for '" + table + "' is available"); } } return isValid; }
From source file:org.jactr.core.module.declarative.search.local.DefaultSearchSystem.java
/** * this implementation fails fast// w w w .j a va 2 s.c om * * @see org.jactr.core.module.declarative.search.ISearchSystem#findExact(ChunkTypeRequest, * java.util.Comparator) */ public Collection<IChunk> findExact(ChunkTypeRequest pattern, Comparator<IChunk> sortRule) { /* * second pass, ditch all those that don't match our chunktype */ HashSet<IChunk> candidates = new HashSet<IChunk>(); IChunkType chunkType = pattern.getChunkType(); if (chunkType != null) candidates.addAll(chunkType.getSymbolicChunkType().getChunks()); /* * first things first, find all the candidates based on the content of the * pattern */ boolean first = chunkType == null; for (IConditionalSlot slot : pattern.getConditionalSlots()) { if (first) { candidates.addAll(find(slot)); first = false; } else candidates.retainAll(find(slot)); if (candidates.size() == 0) break; } if (LOGGER.isDebugEnabled()) LOGGER.debug("First pass candidates for " + pattern + " chunks: " + candidates); if (sortRule != null) { /* * finally, we sort them */ TreeSet<IChunk> sortedResults = new TreeSet<IChunk>(sortRule); sortedResults.addAll(candidates); return sortedResults; } return candidates; }