List of usage examples for java.util TreeSet add
public boolean add(E e)
From source file:au.edu.uq.cmm.paul.grabber.Analyser.java
private SortedSet<DatasetMetadata> buildInDatabaseMetadata() { TreeSet<DatasetMetadata> inDatabase = new TreeSet<DatasetMetadata>(ORDER_BY_BASE_PATH_AND_TIME_AND_ID); EntityManager em = emf.createEntityManager(); try {/* w ww . j av a 2 s . c o m*/ TypedQuery<DatasetMetadata> query = em.createQuery( "from DatasetMetadata m left join fetch m.datafiles " + "where m.facilityName = :name", DatasetMetadata.class); query.setParameter("name", getFacility().getFacilityName()); for (DatasetMetadata ds : query.getResultList()) { if (inDatabase.add(ds)) { ds.getDatafiles().size(); } } } finally { em.close(); } return inDatabase; }
From source file:fr.lirmm.graphik.graal.io.owl.OWLAxiomParser.java
@Override public Iterable<? extends Object> visit(OWLSubClassOfAxiom arg) { Collection<Object> objects = new LinkedList<Object>(); freeVarGen.setIndex(3);//from w w w . j av a 2 s. c o m OWLClassExpression superClass = OWLAPIUtils.classExpressionDisjunctiveNormalForm(arg.getSuperClass()); OWLClassExpression subClass = OWLAPIUtils.classExpressionDisjunctiveNormalForm(arg.getSubClass()); if (OWLAPIUtils.isIntersection(superClass)) { for (OWLClassExpression c : OWLAPIUtils.getObjectIntersectionOperands(superClass)) { CollectionsUtils.addAll(objects, new OWLSubClassOfAxiomImpl(subClass, c, emptyAnno).accept(this)); } } else if (superClass instanceof OWLObjectComplementOf) { TreeSet<OWLClassExpression> operands = new TreeSet<>(); operands.add(subClass); operands.add(((OWLObjectComplementOf) superClass).getOperand()); subClass = new OWLObjectIntersectionOfImpl(operands); CollectionsUtils.addAll(objects, new OWLSubClassOfAxiomImpl(subClass, NOTHING, emptyAnno).accept(this)); } else if (superClass instanceof OWLObjectAllValuesFrom) { OWLObjectAllValuesFrom allValuesFrom = (OWLObjectAllValuesFrom) superClass; subClass = new OWLObjectSomeValuesFromImpl(allValuesFrom.getProperty().getInverseProperty(), subClass); superClass = allValuesFrom.getFiller(); CollectionsUtils.addAll(objects, new OWLSubClassOfAxiomImpl(subClass, superClass, emptyAnno).accept(this)); } else if (superClass instanceof OWLObjectMaxCardinality && ((OWLObjectMaxCardinality) superClass).getCardinality() == 0) { TreeSet<OWLClassExpression> operands = new TreeSet<>(); operands.add(subClass); OWLObjectMaxCardinality maxCard = (OWLObjectMaxCardinality) superClass; operands.add(new OWLObjectSomeValuesFromImpl(maxCard.getProperty(), maxCard.getFiller())); subClass = new OWLObjectIntersectionOfImpl(operands); CollectionsUtils.addAll(objects, new OWLSubClassOfAxiomImpl(subClass, NOTHING, emptyAnno).accept(this)); } else if (superClass instanceof OWLDataMaxCardinality && ((OWLDataMaxCardinality) superClass).getCardinality() == 0) { TreeSet<OWLClassExpression> operands = new TreeSet<>(); operands.add(subClass); OWLDataMaxCardinality maxCard = (OWLDataMaxCardinality) superClass; operands.add(new OWLDataSomeValuesFromImpl(maxCard.getProperty(), maxCard.getFiller())); subClass = new OWLObjectIntersectionOfImpl(operands); CollectionsUtils.addAll(objects, new OWLSubClassOfAxiomImpl(subClass, NOTHING, emptyAnno).accept(this)); } else if (superClass instanceof OWLObjectExactCardinality && ((OWLObjectExactCardinality) superClass).getCardinality() <= 1) { OWLObjectExactCardinality exactCard = (OWLObjectExactCardinality) superClass; OWLObjectMaxCardinality maxCard = new OWLObjectMaxCardinalityImpl(exactCard.getProperty(), exactCard.getCardinality(), exactCard.getFiller()); OWLObjectMinCardinality minCard = new OWLObjectMinCardinalityImpl(exactCard.getProperty(), exactCard.getCardinality(), exactCard.getFiller()); CollectionsUtils.addAll(objects, new OWLSubClassOfAxiomImpl(subClass, maxCard, emptyAnno).accept(this)); CollectionsUtils.addAll(objects, new OWLSubClassOfAxiomImpl(subClass, minCard, emptyAnno).accept(this)); } else if (superClass instanceof OWLDataExactCardinality && ((OWLDataExactCardinality) superClass).getCardinality() <= 1) { OWLDataExactCardinality exactCard = (OWLDataExactCardinality) superClass; OWLDataMaxCardinality maxCard = new OWLDataMaxCardinalityImpl(exactCard.getProperty(), exactCard.getCardinality(), exactCard.getFiller()); OWLDataMinCardinality minCard = new OWLDataMinCardinalityImpl(exactCard.getProperty(), exactCard.getCardinality(), exactCard.getFiller()); CollectionsUtils.addAll(objects, new OWLSubClassOfAxiomImpl(subClass, maxCard, emptyAnno).accept(this)); CollectionsUtils.addAll(objects, new OWLSubClassOfAxiomImpl(subClass, minCard, emptyAnno).accept(this)); } else if (isSuperClass(superClass)) { if (subClass instanceof OWLObjectUnionOf) { for (OWLClassExpression c : OWLAPIUtils.getObjectUnionOperands(subClass)) { CollectionsUtils.addAll(objects, new OWLSubClassOfAxiomImpl(c, superClass, emptyAnno).accept(this)); } } else if (isEquivClass(subClass)) { CollectionsUtils.addAll(objects, mainProcess(arg)); } else { if (LOGGER.isWarnEnabled()) { LOGGER.warn( "[ " + subClass + "] is not supported as subClass. This axioms was skipped : " + arg); } } } else { if (LOGGER.isWarnEnabled()) { LOGGER.warn( "[ " + superClass + "] is not supported as superClass. This axioms was skipped : " + arg); } } return objects; }
From source file:io.apiman.manager.test.junit.ManagerRestTester.java
/** * Loads the test plans./*from ww w. j a v a 2s .c o m*/ * @param testClass * @throws InitializationError */ private void loadTestPlans(Class<?> testClass) throws InitializationError { try { ManagerRestTestPlan annotation = testClass.getAnnotation(ManagerRestTestPlan.class); if (annotation == null) { Method[] methods = testClass.getMethods(); TreeSet<ManagerRestTestPlan> annotations = new TreeSet<>(new Comparator<ManagerRestTestPlan>() { @Override public int compare(ManagerRestTestPlan o1, ManagerRestTestPlan o2) { Integer i1 = o1.order(); Integer i2 = o2.order(); return i1.compareTo(i2); } }); for (Method method : methods) { annotation = method.getAnnotation(ManagerRestTestPlan.class); if (annotation != null) { annotations.add(annotation); } } for (ManagerRestTestPlan anno : annotations) { TestPlanInfo planInfo = new TestPlanInfo(); planInfo.planPath = anno.value(); planInfo.name = new File(planInfo.planPath).getName(); planInfo.endpoint = TestUtil.doPropertyReplacement(anno.endpoint()); planInfo.plan = TestUtil.loadTestPlan(planInfo.planPath, testClass.getClassLoader()); testPlans.add(planInfo); } } else { TestPlanInfo planInfo = new TestPlanInfo(); planInfo.planPath = annotation.value(); planInfo.name = new File(planInfo.planPath).getName(); planInfo.plan = TestUtil.loadTestPlan(planInfo.planPath, testClass.getClassLoader()); planInfo.endpoint = TestUtil.doPropertyReplacement(annotation.endpoint()); testPlans.add(planInfo); } } catch (Throwable e) { throw new InitializationError(e); } if (testPlans.isEmpty()) { throw new InitializationError("No @ManagerRestTestPlan annotations found on test class: " + testClass); } }
From source file:com.xpn.xwiki.plugin.chronopolys.UserManager.java
public List getMyNextDeadlines(XWikiContext context) throws XWikiException { String key = context.getDatabase() + ':' + context.getLocalUser() + "-deadlines"; ArrayList<Deadline> list = null; Date today = new Date(); initUserdataCache(context);/*from w ww . ja v a2 s .co m*/ synchronized (key) { try { list = (ArrayList<Deadline>) userdataCache.getFromCache(key); } catch (XWikiCacheNeedsRefreshException e) { userdataCache.cancelUpdate(key); TreeSet<Deadline> deadlines = new TreeSet<Deadline>(); list = new ArrayList<Deadline>(); // meetings List meetings = this.getMyMeetings(context); for (Iterator it = meetings.iterator(); it.hasNext();) { String page = (String) it.next(); XWikiDocument doc = context.getWiki().getDocument(page, context); Date date = (Date) doc.newDocument(context).getValue("meetingend"); deadlines.add( new Deadline(doc.getFullName(), doc.getDisplayTitle(context), DEADLINE_MEETING, date)); } // tasks List tasks = this.getMyTasks(context); for (Iterator it = tasks.iterator(); it.hasNext();) { String page = (String) it.next(); XWikiDocument doc = context.getWiki().getDocument(page, context); Date date = (Date) doc.newDocument(context).getValue("taskduedate"); deadlines.add( new Deadline(doc.getFullName(), doc.getDisplayTitle(context), DEADLINE_TASK, date)); } // projects List projects = plugin.getProjectManager().getMyProjects(context); for (Iterator it = projects.iterator(); it.hasNext();) { String page = (String) it.next(); XWikiDocument doc = context.getWiki().getDocument(page + "." + Project.PROJECT_HOMEDOC, context); /* Date date = (Date) doc.newDocument(context).getValue("end"); if (date.after(today)) { deadlines.add(new Deadline(doc.getFullName(), doc.display("name", "view", context), DEADLINE_PROJECT, date)); } */ // Phases List phases = plugin.getProjectManager().getProject(doc.getSpace(), context).getPhases(); for (Iterator i = phases.iterator(); i.hasNext();) { Object phase = (Object) i.next(); Date date = (Date) phase.getProperty("end").getValue(); if (date.after(today)) { int type = Integer.parseInt((String) phase.getProperty("type").getValue()); deadlines.add(new Deadline(doc.getFullName(), phase.display("name", "view").toString(), type, date)); } } } list.addAll(deadlines); userdataCache.putInCache(key, list); } } return list; }
From source file:com.idega.block.cal.renderer.ScheduleDetailedDayRenderer.java
protected void writeEntries(FacesContext context, HtmlSchedule schedule, ScheduleDay day, ResponseWriter writer, int index) throws IOException { //final String clientId = schedule.getClientId(context); //FormInfo parentFormInfo = RendererUtils.findNestingForm(schedule, context); //String formId = parentFormInfo == null ? null : parentFormInfo.getFormName(); TreeSet entrySet = new TreeSet(); for (Iterator entryIterator = day.iterator(); entryIterator.hasNext();) { entrySet.add(new EntryWrapper((ScheduleEntry) entryIterator.next(), day)); }/* w w w . ja va2s . c o m*/ EntryWrapper[] entries = (EntryWrapper[]) entrySet.toArray(new EntryWrapper[entrySet.size()]); //determine overlaps scanEntries(entries, 0); //determine the number of columns within this day int maxColumn = 0; for (Iterator entryIterator = entrySet.iterator(); entryIterator.hasNext();) { EntryWrapper wrapper = (EntryWrapper) entryIterator.next(); maxColumn = Math.max(wrapper.column, maxColumn); } int numberOfColumns = maxColumn + 1; //make sure the entries take up all available space horizontally maximizeEntries(entries, numberOfColumns); //now determine the width in percent of 1 column float columnWidth = 100 / numberOfColumns; //and now draw the entries in the columns for (Iterator entryIterator = entrySet.iterator(); entryIterator.hasNext();) { EntryWrapper wrapper = (EntryWrapper) entryIterator.next(); boolean selected = isSelected(schedule, wrapper); //compose the CSS style for the entry box StringBuffer entryStyle = new StringBuffer(); entryStyle.append(wrapper.getBounds(schedule, columnWidth, index)); if (selected) { writer.startElement(HTML.DIV_ELEM, schedule); writer.writeAttribute(HTML.CLASS_ATTR, getStyleClass(schedule, "entry-selected"), null); //draw the tooltip if (showTooltip(schedule)) { getEntryRenderer(schedule).renderToolTip(context, writer, schedule, wrapper.entry, selected); } //draw the content getEntryRenderer(schedule).renderContent(context, writer, schedule, day, wrapper.entry, false, selected); writer.endElement(HTML.DIV_ELEM); } else { //if the schedule is read-only, the entries should not be //hyperlinks writer.startElement(schedule.isReadonly() ? HTML.DIV_ELEM : HTML.ANCHOR_ELEM, schedule); //draw the tooltip if (showTooltip(schedule)) { getEntryRenderer(schedule).renderToolTip(context, writer, schedule, wrapper.entry, selected); } if (!schedule.isReadonly()) { DateFormat format; String pattern = null; if ((pattern != null) && (pattern.length() > 0)) { format = new SimpleDateFormat(pattern); } else { if (context.getApplication().getDefaultLocale() != null) { format = DateFormat.getDateInstance(DateFormat.MEDIUM, context.getApplication().getDefaultLocale()); } else { format = DateFormat.getDateInstance(DateFormat.MEDIUM); } } String startTime = format.format(wrapper.entry.getStartTime()); startTime += " "; startTime += wrapper.entry.getStartTime().getHours(); startTime += ":"; if (wrapper.entry.getStartTime().getMinutes() < 10) { startTime += "0"; startTime += wrapper.entry.getStartTime().getMinutes(); } else { startTime += wrapper.entry.getStartTime().getMinutes(); } String endTime = ""; endTime += wrapper.entry.getEndTime().getHours(); endTime += ":"; if (wrapper.entry.getEndTime().getMinutes() < 10) { endTime += "0"; endTime += wrapper.entry.getEndTime().getMinutes(); } else { endTime += wrapper.entry.getEndTime().getMinutes(); } writer.writeAttribute(HTML.HREF_ATTR, "javascript:void(0)", null); writer.writeAttribute("entryid", wrapper.entry.getId(), null); } if (schedule.getModel().size() == 1) { writer.writeAttribute(HTML.CLASS_ATTR, getStyleClass(schedule, "entry"), null); } else { writer.writeAttribute(HTML.CLASS_ATTR, getStyleClass(schedule, "workweekEntry"), null); } writer.writeAttribute(HTML.STYLE_ATTR, entryStyle.toString(), null); //draw the content getEntryRenderer(schedule).renderContent(context, writer, schedule, day, wrapper.entry, false, selected); writer.endElement(schedule.isReadonly() ? HTML.DIV_ELEM : "a"); } } }
From source file:cpsControllers.ConversionController.java
public ArrayList<Double> kwantyzacjaZobcieciem(ArrayList<Double> sygSprobkowanyY) { //List<Double[]> results = signal; //List<Double[]> results2 = new ArrayList<Double[]>(); double max = sygSprobkowanyY.get(0); double min = sygSprobkowanyY.get(0); for (int i = 0; i < sygSprobkowanyY.size(); i++) { if (max < sygSprobkowanyY.get(i)) { max = sygSprobkowanyY.get(i); }/*w w w . j a v a 2s . co m*/ if (min > sygSprobkowanyY.get(i)) { min = sygSprobkowanyY.get(i); } } double sub = max - min; TreeSet<Double> treeset = new TreeSet<Double>(); for (int i = 0; i < iloscPoziomowKwantyzacji; i++) { treeset.add(min + ((sub / (iloscPoziomowKwantyzacji)) * i)); } for (int i = 0; i < sygSprobkowanyY.size(); i++) { Double tempX, tempY; // tempX = sygSprobkowanyX.get(i); tempY = treeset.floor(sygSprobkowanyY.get(i)); // sygSkwantowanyX.add(tempX); sygSkwantowanyY.add(tempY); } return sygSkwantowanyY; }
From source file:net.sourceforge.fenixedu.presentationTier.backBeans.coordinator.evaluation.CoordinatorEvaluationsBackingBean.java
public List<SelectItem> getExecutionPeriodSelectItems() throws FenixServiceException { final DegreeCurricularPlan degreeCurricularPlan = getDegreeCurricularPlan(); final TreeSet<ExecutionSemester> executionPeriods = new TreeSet<ExecutionSemester>(); for (final ExecutionDegree executionDegree : degreeCurricularPlan.getExecutionDegreesSet()) { final ExecutionYear executionYear = executionDegree.getExecutionYear(); for (final ExecutionSemester executionSemester : executionYear.getExecutionPeriodsSet()) { executionPeriods.add(executionSemester); }// w ww. java 2 s.co m } final List<SelectItem> selectItems = new ArrayList<SelectItem>(); for (final ExecutionSemester executionSemester : executionPeriods) { final SelectItem selectItem = new SelectItem(); selectItem .setLabel(executionSemester.getName() + " - " + executionSemester.getExecutionYear().getYear()); selectItem.setValue(executionSemester.getExternalId()); selectItems.add(selectItem); } return selectItems; }
From source file:com.openedit.users.filesystem.FileSystemUserManager.java
/** * @see com.openedit.users.UserManager#getGroups() *//*from w w w .j a v a 2 s . com*/ public HitTracker getGroups() { Collection ids = listGroupIds(); TreeSet treeSet = new java.util.TreeSet(new GroupComparator()); for (Iterator iterator = ids.iterator(); iterator.hasNext();) { String id = (String) iterator.next(); treeSet.add(getGroup(id)); } ListHitTracker list = new ListHitTracker(new ArrayList(treeSet)); list.setHitsName("groups"); list.setCatalogId("system"); return list; }
From source file:com.thoughtworks.go.server.dao.PipelineSqlMapDao.java
private Map<CaseInsensitiveString, TreeSet<Long>> groupPipelineInstanceIdsByPipelineName( List<PipelineInstanceModel> pipelines) { Map<CaseInsensitiveString, TreeSet<Long>> result = new HashMap<CaseInsensitiveString, TreeSet<Long>>(); for (PipelineInstanceModel pipeline : pipelines) { TreeSet<Long> ids = initializePipelineInstances(result, new CaseInsensitiveString(pipeline.getName())); ids.add(pipeline.getId()); }// w w w . j av a2s. c o m return result; }
From source file:edu.ku.brc.specify.config.init.SpecifyDBSetupWizard.java
/** * Sets up initial preference settings./*from w ww . ja v a2 s . c o m*/ */ protected void setupLoginPrefs() { String userName = props.getProperty("usrUsername"); String password = props.getProperty("usrPassword"); String saUserName = props.getProperty("saUserName"); String saPassword = props.getProperty("saPassword"); String hostName = props.getProperty("hostName"); hostName = hostName != null ? hostName : ""; String encryptedMasterUP = UserAndMasterPasswordMgr.encrypt(saUserName, saPassword, password); DatabaseDriverInfo driverInfo = dbPanel.getDriver(); AppPreferences ap = AppPreferences.getLocalPrefs(); String loginDBPrefName = "login.databases"; String loginDBs = ap.get(loginDBPrefName, null); if (StringUtils.isNotEmpty(loginDBs)) { TreeSet<String> dbNames = new TreeSet<String>(); for (String dbNm : StringUtils.splitPreserveAllTokens(loginDBs)) { dbNames.add(dbNm); } StringBuilder sb = new StringBuilder(); for (String dbNm : dbNames) { if (sb.length() > 0) sb.append(','); sb.append(dbNm); } if (sb.length() > 0) sb.append(','); sb.append(dbPanel.getDbName()); loginDBs = sb.toString(); } else { loginDBs = dbPanel.getDbName(); } ap.put(userName + "_master.islocal", "true"); ap.put(userName + "_master.path", encryptedMasterUP); ap.put("login.dbdriver_selected", driverInfo.getName()); ap.put("login.username", userName != null ? userName : ""); ap.put("login.databases_selected", dbPanel.getDbName()); ap.put("login.databases", loginDBs); ap.put("login.servers", hostName); ap.put("login.servers_selected", hostName); ap.put("login.rememberuser", "true"); ap.put("extra.check", "true"); ap.put("version_check.auto", "true"); try { ap.flush(); } catch (BackingStoreException ex) { } }