List of usage examples for java.util SortedSet isEmpty
boolean isEmpty();
From source file:net.sourceforge.fenixedu.domain.studentCurriculum.RootCurriculumGroup.java
public CycleCurriculumGroup getLastOrderedCycleCurriculumGroup() { final SortedSet<CycleCurriculumGroup> cycleCurriculumGroups = new TreeSet<CycleCurriculumGroup>( CycleCurriculumGroup.COMPARATOR_BY_CYCLE_TYPE_AND_ID); cycleCurriculumGroups.addAll(getInternalCycleCurriculumGroups()); return cycleCurriculumGroups.isEmpty() ? null : cycleCurriculumGroups.last(); }
From source file:edu.harvard.med.screensaver.model.screenresults.ScreenResult.java
private SortedSet<AssayPlate> findOrCreateAssayPlatesDataLoaded(int plateNumber, int replicatesDataLoaded) { SortedSet<AssayPlate> mostRecentAssayPlatesForPlateNumber = Sets.newTreeSet(); SortedSet<AssayPlate> allAssayPlatesForPlateNumber = getScreen().findAssayPlates(plateNumber); if (!allAssayPlatesForPlateNumber.isEmpty()) { final LibraryScreening lastLibraryScreening = ImmutableSortedSet .copyOf(Iterables.transform(allAssayPlatesForPlateNumber, AssayPlate.ToLibraryScreening)) .last();// w w w. j ava 2 s. c o m assert lastLibraryScreening != null; mostRecentAssayPlatesForPlateNumber .addAll(Sets.filter(allAssayPlatesForPlateNumber, new Predicate<AssayPlate>() { public boolean apply(AssayPlate ap) { return lastLibraryScreening.equals(ap.getLibraryScreening()); } })); } SortedSet<AssayPlate> assayPlatesDataLoaded = Sets.newTreeSet(); // if there are fewer assay plates screened replicates than we have data // for, then a library screening must not have been recorded for the assay // plates that were used to generate this data, so we'll create them now if (mostRecentAssayPlatesForPlateNumber.size() < replicatesDataLoaded) { //log.warn("creating missing assay plate(s) for plate number " + plateNumber); for (int r = 0; r < replicatesDataLoaded; r++) { assayPlatesDataLoaded.add(getScreen().createAssayPlate(plateNumber, r)); } } else { for (AssayPlate assayPlate : mostRecentAssayPlatesForPlateNumber) { if (assayPlate.getReplicateOrdinal() < replicatesDataLoaded) { assayPlatesDataLoaded.add(assayPlate); } } } return assayPlatesDataLoaded; }
From source file:gov.nih.nci.firebird.service.registration.ProfileContentPdfHelper.java
private void addSpecialtyCredentials(String headingKey, int index, SortedSet<AbstractCredential<?>> credentials) throws DocumentException { PdfPTable table = pdfGenerator.createTable(FOUR_COLUMNS); addSpecialtyCredentialsHeading(table, index, headingKey); if (credentials.isEmpty()) { pdfGenerator.addCellAndCompleteRow(table, pdfGenerator.getValueNone()); } else {/*w w w . ja va 2s. com*/ addSpecialtyCredentials(table, credentials); } pdfGenerator.getDocument().add(table); }
From source file:net.sourceforge.fenixedu.domain.Alumni.java
public PhysicalAddress getLastPersonalAddress() { SortedSet<PhysicalAddress> addressSet = new TreeSet<PhysicalAddress>(DomainObjectUtil.COMPARATOR_BY_ID); addressSet.addAll(getStudent().getPerson().getPhysicalAddresses()); return !addressSet.isEmpty() && addressSet.last() != null ? addressSet.last() : null; }
From source file:org.jahia.services.content.nodetypes.initializers.TemplatesChoiceListInitializerImpl.java
public List<ChoiceListValue> getChoiceListValues(ExtendedPropertyDefinition declaringPropertyDefinition, String param, List<ChoiceListValue> values, Locale locale, Map<String, Object> context) { if (context == null) { return new ArrayList<ChoiceListValue>(); }//from ww w. j a v a 2s. c om JCRNodeWrapper node = (JCRNodeWrapper) context.get("contextNode"); JCRNodeWrapper parentNode = (JCRNodeWrapper) context.get("contextParent"); ExtendedNodeType realNodeType = (ExtendedNodeType) context.get("contextType"); String propertyName = context.containsKey("dependentProperties") ? ((List<String>) context.get("dependentProperties")).get(0) : null; JCRSiteNode site = null; SortedSet<View> views = new TreeSet<View>(); boolean subViews = false; try { if (node != null) { site = node.getResolveSite(); } if (site == null && parentNode != null) { site = parentNode.getResolveSite(); } final List<String> nodeTypeList = new ArrayList<String>(); String nextParam = ""; if (param.contains(",")) { nextParam = StringUtils.substringAfter(param, ","); param = StringUtils.substringBefore(param, ","); } if ("subnodes".equals(param)) { subViews = true; if (propertyName == null) { propertyName = "j:allowedTypes"; } if (context.containsKey(propertyName)) { List<String> types = (List<String>) context.get(propertyName); for (String type : types) { nodeTypeList.add(type); } } else if (node != null && node.hasProperty(propertyName)) { JCRPropertyWrapper property = node.getProperty(propertyName); if (property.isMultiple()) { Value[] types = property.getValues(); for (Value type : types) { nodeTypeList.add(type.getString()); } } else { nodeTypeList.add(property.getValue().getString()); } } else if (node != null && !"j:allowedTypes".equals(propertyName) && node.hasProperty("j:allowedTypes")) { Value[] types = node.getProperty("j:allowedTypes").getValues(); for (Value type : types) { nodeTypeList.add(type.getString()); } } else if (node != null) { // No restrictions get node type list from already existing nodes NodeIterator nodeIterator = node.getNodes(); while (nodeIterator.hasNext()) { Node next = (Node) nodeIterator.next(); String name = next.getPrimaryNodeType().getName(); if (!nodeTypeList.contains(name) && next.isNodeType("jnt:content")) { nodeTypeList.add(name); } } } param = nextParam; } else if ("reference".equals(param)) { if (propertyName == null) { propertyName = Constants.NODE; } if (context.containsKey(propertyName)) { JCRSessionWrapper session = JCRSessionFactory.getInstance().getCurrentUserSession(); List<String> refNodeUuids = (List<String>) context.get(propertyName); for (String refNodeUuid : refNodeUuids) { try { JCRNodeWrapper refNode = session.getNodeByUUID(refNodeUuid); nodeTypeList.addAll(refNode.getNodeTypes()); } catch (Exception e) { logger.warn("Referenced node not found to retrieve its nodetype for initializer", e); } } } else if (node != null && node.hasProperty(propertyName)) { try { JCRNodeWrapper refNode = (JCRNodeWrapper) node.getProperty(propertyName).getNode(); nodeTypeList.addAll(refNode.getNodeTypes()); } catch (ItemNotFoundException e) { } } else if (node != null && !Constants.NODE.equals(propertyName) && node.hasProperty(Constants.NODE)) { try { JCRNodeWrapper refNode = (JCRNodeWrapper) node.getProperty(Constants.NODE).getNode(); nodeTypeList.addAll(refNode.getNodeTypes()); } catch (ItemNotFoundException e) { } } param = nextParam; } else if ("mainresource".equals(param)) { JCRNodeWrapper matchingParent; JCRNodeWrapper parent; if (node == null) { parent = (JCRNodeWrapper) context.get("contextParent"); site = parent.getResolveSite(); } else { parent = node.getParent(); } try { while (true) { if (parent.isNodeType("jnt:template")) { matchingParent = parent; break; } parent = parent.getParent(); } if (matchingParent.hasProperty("j:applyOn")) { Value[] vs = matchingParent.getProperty("j:applyOn").getValues(); for (Value v : vs) { nodeTypeList.add(v.getString()); } } } catch (ItemNotFoundException e) { } if (nodeTypeList.isEmpty()) { nodeTypeList.add("jnt:page"); } param = nextParam; } else if (param != null && param.indexOf(":") > 0) { nodeTypeList.add(param); param = nextParam; } else { if (node != null) { nodeTypeList.addAll(node.getNodeTypes()); } else if (realNodeType != null) { nodeTypeList.add(realNodeType.getName()); } } if (nodeTypeList.isEmpty()) { nodeTypeList.add("nt:base"); } SortedSet<ViewWrapper> wrappedViews = new TreeSet<ViewWrapper>(); Set<ViewWrapper> wrappedViewsSet = new HashSet<ViewWrapper>(); for (String s : nodeTypeList) { SortedSet<View> viewsSet = RenderService.getInstance() .getViewsSet(NodeTypeRegistry.getInstance().getNodeType(s), site, "html"); if (!viewsSet.isEmpty()) { // use of wrapper class to get a simpler equals method, based on the key // to keep only views in common between sub nodes for (Iterator<View> iterator = viewsSet.iterator(); iterator.hasNext();) { wrappedViewsSet.add(new ViewWrapper(iterator.next())); } if (subViews && !wrappedViews.isEmpty()) { wrappedViews.retainAll(wrappedViewsSet); } else { wrappedViews.addAll(wrappedViewsSet); } } wrappedViewsSet.clear(); } for (Iterator<ViewWrapper> iterator = wrappedViews.iterator(); iterator.hasNext();) { views.add(iterator.next().getView()); } } catch (RepositoryException e) { logger.error(e.getMessage(), e); } List<ChoiceListValue> vs = new ArrayList<ChoiceListValue>(); for (View view : views) { HashMap<String, Object> map = new HashMap<String, Object>(); fillProperties(map, view.getDefaultProperties()); fillProperties(map, view.getProperties()); boolean isStudio = site != null && site.getPath().startsWith("/modules"); if (isViewVisible(view.getKey(), param, map, isStudio)) { JahiaTemplatesPackage pkg = view.getModule() != null ? view.getModule() : ServicesRegistry.getInstance().getJahiaTemplateManagerService() .getTemplatePackageById(JahiaTemplatesPackage.ID_DEFAULT); String displayName = Messages.get(pkg, declaringPropertyDefinition.getResourceBundleKey() + "." + JCRContentUtils.replaceColon(view.getKey()), locale, view.getKey()); ChoiceListValue c = new ChoiceListValue(displayName, map, new ValueImpl(view.getKey(), PropertyType.STRING, false)); try { final Resource imagePath = pkg.getResource( File.separator + "img" + File.separator + c.getValue().getString() + ".png"); if (imagePath != null && imagePath.exists()) { String s = Jahia.getContextPath(); if (s.equals("/")) { s = ""; } c.addProperty("image", s + (pkg.getRootFolderPath().startsWith("/") ? "" : "/") + pkg.getRootFolderPath() + "/img/" + c.getValue().getString() + ".png"); } } catch (RepositoryException e) { logger.error(e.getMessage(), e); } vs.add(c); } } Collections.sort(vs); return vs; }
From source file:gov.nih.nci.firebird.service.registration.ProfileContentPdfHelper.java
void addWorkHistory(int index) throws DocumentException { SortedSet<AbstractCredential<?>> credentials = getProfile() .getCurrentCredentials(CredentialType.WORK_HISTORY); PdfPTable table = pdfGenerator.createTable(FOUR_COLUMNS); addWorkHistoryHeading(table, index, WORK_HISTORY_TITLE_KEY); if (credentials.isEmpty()) { pdfGenerator.addCellAndCompleteRow(table, pdfGenerator.getValueNone()); } else {/* w w w . j ava 2s . c om*/ addWorkHistory(table, credentials); } pdfGenerator.getDocument().add(table); }
From source file:org.solenopsis.checkstyle.Checker.java
/** * Processes a list of files with all FileSetChecks. * @param files a list of files to process. * @throws CheckstyleException if error condition within Checkstyle occurs. * @noinspection ProhibitedExceptionThrown *//*from w ww .j a va 2s . c o m*/ private void processFiles(List<File> files) throws CheckstyleException { for (final File file : files) { try { final String fileName = file.getAbsolutePath(); final long timestamp = file.lastModified(); if (cache != null && cache.isInCache(fileName, timestamp) || !CommonUtils.matchesFileExtension(file, fileExtensions)) { continue; } fireFileStarted(fileName); final SortedSet<LocalizedMessage> fileMessages = processFile(file); fireErrors(fileName, fileMessages); fireFileFinished(fileName); if (cache != null && fileMessages.isEmpty()) { cache.put(fileName, timestamp); } } catch (Exception ex) { // We need to catch all exceptions to put a reason failure (file name) in exception throw new CheckstyleException("Exception was thrown while processing " + file.getPath(), ex); } catch (Error error) { // We need to catch all errors to put a reason failure (file name) in error throw new Error("Error was thrown while processing " + file.getPath(), error); } } }
From source file:ch.fork.AdHocRailway.manager.impl.TurnoutManagerImpl.java
@Override public int getNextFreeTurnoutNumber() { LOGGER.debug("getNextFreeTurnoutNumber()"); if (lastProgrammedNumber == 0) { final SortedSet<Turnout> turnoutsNumbers = new TreeSet<Turnout>(new Comparator<Turnout>() { @Override//www . j av a2 s .c o m public int compare(final Turnout o1, final Turnout o2) { return Integer.valueOf(o1.getNumber()).compareTo(o2.getNumber()); } }); turnoutsNumbers.addAll(getAllTurnouts()); if (turnoutsNumbers.isEmpty()) { lastProgrammedNumber = 0; } else { lastProgrammedNumber = turnoutsNumbers.last().getNumber(); } } return lastProgrammedNumber + 1; }
From source file:net.sourceforge.fenixedu.presentationTier.Action.administrativeOffice.lists.StudentsListByCurricularCourseDA.java
public ActionForward showActiveCurricularCourseScope(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws FenixActionException, FenixServiceException { final SearchStudentsByCurricularCourseParametersBean searchBean = getOrCreateSearchBean(); final SortedSet<DegreeModuleScope> degreeModuleScopes = new TreeSet<DegreeModuleScope>( DegreeModuleScope.COMPARATOR_BY_CURRICULAR_YEAR_AND_SEMESTER_AND_CURRICULAR_COURSE_NAME_AND_BRANCH); degreeModuleScopes.addAll(/*from www . j a va 2 s .c o m*/ searchBean.getDegreeCurricularPlan().getDegreeModuleScopesFor(searchBean.getExecutionYear())); if (degreeModuleScopes.isEmpty()) { addActionMessage("message", request, "error.nonExisting.AssociatedCurricularCourses"); } else { request.setAttribute("degreeModuleScopes", degreeModuleScopes); } request.setAttribute("searchBean", searchBean); return mapping.findForward("chooseCurricularCourse"); }
From source file:org.wrml.runtime.rest.DefaultApiLoader.java
protected Object decipherDocumentSurrogateKeyValue(final URI uri, final Prototype prototype) { final ApiNavigator apiNavigator = getParentApiNavigator(uri); if (apiNavigator == null) { return null; }/*from ww w . j av a2s .c om*/ final SortedSet<Parameter> surrogateKeyComponents = apiNavigator.getSurrogateKeyComponents(uri, prototype); if (surrogateKeyComponents == null || surrogateKeyComponents.isEmpty()) { return null; } final Set<String> allKeySlotNames = prototype.getAllKeySlotNames(); final Object surrogateKeyValue; if (surrogateKeyComponents.size() == 1) { final Parameter surrogateKeyPair = surrogateKeyComponents.first(); final String slotName = surrogateKeyPair.getName(); if (!allKeySlotNames.contains(slotName)) { return null; } final String slotTextValue = surrogateKeyPair.getValue(); final Object slotValue = parseSlotValueSyntacticText(prototype, slotName, slotTextValue); surrogateKeyValue = slotValue; } else { final SortedMap<String, Object> keySlots = new TreeMap<String, Object>(); for (final Parameter surrogateKeyPair : surrogateKeyComponents) { final String slotName = surrogateKeyPair.getName(); if (!allKeySlotNames.contains(slotName)) { continue; } final String slotTextValue = surrogateKeyPair.getValue(); final Object slotValue = parseSlotValueSyntacticText(prototype, slotName, slotTextValue); if (slotValue == null) { continue; } keySlots.put(slotName, slotValue); } if (keySlots.size() == 1) { surrogateKeyValue = keySlots.get(keySlots.firstKey()); } else { surrogateKeyValue = new CompositeKey(keySlots); } } return surrogateKeyValue; }