List of usage examples for java.util SortedSet add
boolean add(E e);
From source file:dk.statsbiblioteket.netark.dvenabler.wrapper.SortedSetDocValuesWrapper.java
private List<BytesRef> fill() throws IOException { // TODO: Is this sort the same as the default BytesRef-based sort for DocValues? final SortedSet<BytesRef> values = new TreeSet<>(); for (int docID = 0; docID < reader.maxDoc(); docID++) { String[] stored = reader.document(docID, FIELDS).getValues(field.getName()); if (stored == null) { continue; }/*from ww w .ja v a2s. c om*/ for (String value : stored) { values.add(new BytesRef(value)); } } return new ArrayList<>(values); }
From source file:net.sourceforge.fenixedu.domain.organizationalStructure.ScientificAreaUnit.java
public List<CompetenceCourseGroupUnit> getCompetenceCourseGroupUnits() { final SortedSet<CompetenceCourseGroupUnit> result = new TreeSet<CompetenceCourseGroupUnit>( CompetenceCourseGroupUnit.COMPARATOR_BY_NAME_AND_ID); for (Unit unit : getSubUnits()) { if (unit.isCompetenceCourseGroupUnit()) { result.add((CompetenceCourseGroupUnit) unit); }/*from w ww. j a va 2s. c o m*/ } return new ArrayList<CompetenceCourseGroupUnit>(result); }
From source file:datacite.oai.provider.service.MDSSearchServiceSolrImpl.java
@Override public Pair<List<SetRecordBean>, Integer> getSets() throws ServiceException { SolrQuery query = new SolrQuery(); query.setQuery("*:*"); query.setRows(0);/* w w w . j a v a 2s. c om*/ query.setFacet(true); query.setFacetLimit(-1); query.addFacetField("allocator_facet", "datacentre_facet"); try { QueryResponse response = solrServer.query(query); SortedSet<String> facetValues = new TreeSet<String>(); for (FacetField facet : response.getFacetFields()) { for (Count count : facet.getValues()) { facetValues.add(count.getName()); } } ArrayList<SetRecordBean> sets = new ArrayList<SetRecordBean>(); for (String facetValue : facetValues) { String[] parts = facetValue.split(" - ", 2); String symbol = parts[0]; String name = parts[1]; sets.add(new SetRecordBean(symbol, name)); } return new Pair<List<SetRecordBean>, Integer>(sets, sets.size()); } catch (Exception e) { throw new ServiceException(e); } }
From source file:com.jd.survey.web.settings.QuestionColumnLabelController.java
@Secured({ "ROLE_ADMIN", "ROLE_SURVEY_ADMIN" }) @RequestMapping(value = "/{id}", params = "form", produces = "text/html") public String updateForm(@PathVariable("id") Long questionId, Principal principal, HttpServletRequest httpServletRequest, Model uiModel) { log.info("updateForm(): questionId=" + questionId); try {/*from w w w . ja v a 2 s . co m*/ String login = principal.getName(); User user = userService.user_findByLogin(login); Question question = surveySettingsService.question_findById(questionId); //Check if the user is authorized if (!securityService.userIsAuthorizedToManageSurvey(question.getPage().getSurveyDefinition().getId(), user) && !securityService.userBelongsToDepartment( question.getPage().getSurveyDefinition().getDepartment().getId(), user)) { log.warn("Unauthorized access to url path " + httpServletRequest.getPathInfo() + " attempted by user login:" + principal.getName() + "from IP:" + httpServletRequest.getLocalAddr()); return "accessDenied"; } SortedSet<QuestionColumnLabel> ColumnLabels = question.getColumnLabels(); log.info("initial set size" + ColumnLabels.size()); for (int i = 1; i <= EMPTY_OPTIONS_COUNT; i++) { log.info("adding to set" + i); ColumnLabels .add(new QuestionColumnLabel(question, (short) (question.getColumnLabels().size() + i))); } question.setColumnLabels(ColumnLabels); uiModel.addAttribute("question", question); return "settings/questionCols/update"; } catch (Exception e) { log.error(e.getMessage(), e); throw (new RuntimeException(e)); } }
From source file:eu.impact_project.wsclient.XmlServiceProvider.java
private void loadServices() { InputStream xmlFile = getRemoteFile(xmlUrl); if (xmlFile == null) throw new RuntimeException( "The file " + xmlUrl.toString() + " not reachable or the server certificate is invalid"); Document xmlDoc = convertToDoc(xmlFile); NodeList serviceNodes = applyXPath(xmlDoc, "//service", NO_NAMESPACE); SortedSet<Service> sortedSet = new TreeSet<Service>(); for (int i = 0; i < serviceNodes.getLength(); i++) { Node srv = serviceNodes.item(i); Service service = createServiceObjectFor(srv); sortedSet.add(service); }// w ww . j av a 2 s. c o m services = new ArrayList<Service>(sortedSet); }
From source file:com.gopivotal.cla.web.RepositoriesController.java
private SortedSet<Repository> getAdminRepositories() { SortedSet<Repository> adminRepositories = new TreeSet<>(); for (Organization organization : this.gitHubClient.getUser().getOrganizations()) { for (Repository repository : organization.getRepositories()) { if (repository.getPermissions().isAdmin()) { adminRepositories.add(repository); }// ww w.j ava 2s .c o m } } adminRepositories.addAll(this.gitHubClient.getUser().getRepositories()); return adminRepositories; }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.commons.curriculumHistoric.ReadActiveCurricularCourseScopeByDegreeCurricularPlanAndExecutionYear.java
@Deprecated public SortedSet<DegreeModuleScope> run(String degreeCurricularPlanID, String executioYearID) throws FenixServiceException { final DegreeCurricularPlan degreeCurricularPlan = FenixFramework.getDomainObject(degreeCurricularPlanID); final ExecutionYear executionYear = FenixFramework.getDomainObject(executioYearID); final ComparatorChain comparator = new ComparatorChain(); comparator.addComparator(new BeanComparator("curricularYear")); comparator.addComparator(new BeanComparator("curricularSemester")); comparator.addComparator(new BeanComparator("curricularCourse.externalId")); comparator.addComparator(new BeanComparator("branch")); final SortedSet<DegreeModuleScope> scopes = new TreeSet<DegreeModuleScope>(comparator); for (DegreeModuleScope degreeModuleScope : degreeCurricularPlan.getDegreeModuleScopes()) { if (degreeModuleScope.isActiveForExecutionYear(executionYear)) { scopes.add(degreeModuleScope); }/*w w w. j ava2 s.c o m*/ } return scopes; }
From source file:edu.cornell.kfs.coa.businessobject.AccountReversionGlobalDetail.java
/** * This returns a string of object code names associated with the object code in this org rev change detail. * /*from w w w. ja v a2s . c o m*/ * @return String of distinct object code names */ public String getObjectCodeNames() { String objectCodeNames = ""; if (!StringUtils.isBlank(this.getAccountReversionObjectCode())) { if (this.getParentGlobalAccountReversion().getUniversityFiscalYear() != null && this.getParentGlobalAccountReversion().getAccountReversionGlobalAccounts() != null && this.getParentGlobalAccountReversion().getAccountReversionGlobalAccounts().size() > 0) { // find distinct chart of account codes SortedSet<String> chartCodes = new TreeSet<String>(); for (AccountReversionGlobalAccount acct : this.getParentGlobalAccountReversion() .getAccountReversionGlobalAccounts()) { chartCodes.add(acct.getChartOfAccountsCode()); } String[] chartCodesArray = new String[chartCodes.size()]; int i = 0; for (String chartCode : chartCodes) { chartCodesArray[i] = chartCode; i++; } objectCodeNames = (String) SpringContext.getBean(ObjectCodeService.class) .getObjectCodeNamesByCharts( this.getParentGlobalAccountReversion().getUniversityFiscalYear(), chartCodesArray, this.getAccountReversionObjectCode()); } } return objectCodeNames; }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.commons.curriculumHistoric.ReadActiveCurricularCourseScopeByDegreeCurricularPlanAndExecutionYear.java
public SortedSet<DegreeModuleScope> run(String degreeCurricularPlanID, AcademicInterval academicInterval) throws FenixServiceException { final DegreeCurricularPlan degreeCurricularPlan = FenixFramework.getDomainObject(degreeCurricularPlanID); final ComparatorChain comparator = new ComparatorChain(); comparator.addComparator(new BeanComparator("curricularYear")); comparator.addComparator(new BeanComparator("curricularSemester")); comparator.addComparator(new BeanComparator("curricularCourse.externalId")); comparator.addComparator(new BeanComparator("branch")); final SortedSet<DegreeModuleScope> scopes = new TreeSet<DegreeModuleScope>(comparator); for (DegreeModuleScope degreeModuleScope : degreeCurricularPlan.getDegreeModuleScopes()) { if (degreeModuleScope.isActiveForAcademicInterval(academicInterval)) { scopes.add(degreeModuleScope); }//from w ww . j ava 2s. co m } return scopes; }
From source file:com.migratebird.script.repository.impl.FileSystemScriptLocation.java
/** * Adds all scripts available in the given directory or one of its subdirectories to the given set of files. Recursively * invokes itself to handle subdirectories. * * @param scripts aggregates the scripts found up until now during recursion. * @param scriptRoot the root script directory * @param relativeLocation the subdirectory in which we are now looking for scripts */// w w w.jav a2s. c o m protected void getScriptsAt(SortedSet<Script> scripts, String scriptRoot, String relativeLocation) { File currentLocation = new File(scriptRoot + "/" + relativeLocation); if (currentLocation.isFile() && isScriptFileName(currentLocation.getName())) { Script script = createScript(currentLocation, relativeLocation); scripts.add(script); return; } // recursively scan sub folders for script files if (currentLocation.isDirectory()) { for (File subLocation : currentLocation.listFiles()) { getScriptsAt(scripts, scriptRoot, "".equals(relativeLocation) ? subLocation.getName() : relativeLocation + '/' + subLocation.getName()); } } }